All Downloads are FREE. Search and download functionalities are using the official Maven repository.

de.invation.code.toval.graphic.dialog.DefineGenerateDialog Maven / Gradle / Ivy

Go to download

TOVAL comprises a set of java classes for common programming issues. It includes utils for arrays, lists, sets and collections for convenient handling and modification, but also support for mathematic definitions concerning logic (clauses + resolution) together with some algorithms for permutations, powersets and resolution. Additionally it contains a number of types for multisets, matrices with object keys and much more.

The newest version!
package de.invation.code.toval.graphic.dialog;

import java.awt.BorderLayout;
import java.awt.Window;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.util.ArrayList;
import java.util.List;

import javax.swing.DefaultListModel;
import javax.swing.JButton;
import javax.swing.JList;
import javax.swing.JOptionPane;
import javax.swing.JPanel;
import javax.swing.JScrollPane;
import javax.swing.ListSelectionModel;
import javax.swing.ScrollPaneConstants;
import javax.swing.event.ListSelectionEvent;
import javax.swing.event.ListSelectionListener;

import de.invation.code.toval.graphic.component.BoxLayoutPanel;
import de.invation.code.toval.graphic.renderer.AlternatingRowColorListCellRenderer;

public class DefineGenerateDialog extends AbstractDialog> {

	private static final long serialVersionUID = -1396837102031308301L;
	
	private JList stringList;
	private JButton btnDefine;
	private JButton btnGenerate;
	private DefaultListModel stringListModel;
	
	protected DefineGenerateDialog(Window owner, String title) {
		super(owner, title);
		initialize();
	}

	protected void initialize() {
		stringListModel = new DefaultListModel();
	}

	@Override
	protected void addComponents() throws Exception {
		mainPanel().setLayout(new BorderLayout());
		
		JPanel buttonPanel = new BoxLayoutPanel();
		buttonPanel.add(getButtonDefine());
		buttonPanel.add(getButtonGenerate());
		mainPanel().add(buttonPanel, BorderLayout.PAGE_START);

		JScrollPane scrollPane = new JScrollPane(getActivityList());
		scrollPane.setVerticalScrollBarPolicy(ScrollPaneConstants.VERTICAL_SCROLLBAR_ALWAYS);
		scrollPane.setHorizontalScrollBarPolicy(ScrollPaneConstants.HORIZONTAL_SCROLLBAR_NEVER);
		mainPanel().add(scrollPane, BorderLayout.CENTER);
	}
	
	@Override
	protected void setTitle() {}
	
	private JButton getButtonDefine(){
		if(btnDefine == null){
			btnDefine = new JButton("Define...");
			btnDefine.addActionListener(new ActionListener() {
				public void actionPerformed(ActionEvent e) {
					List definedStrings = null;
					try {
						definedStrings = StringListDefinitionDialog.showDialog(DefineGenerateDialog.this, "Define " + getTitle());
					} catch (Exception e1) {
						JOptionPane.showMessageDialog(DefineGenerateDialog.this, "Cannot launch string list definition dialog.
Reason: " + e1.getMessage() + "", "Internal Exception", JOptionPane.ERROR_MESSAGE); } if(definedStrings != null){ stringListModel.clear(); for(String string: definedStrings){ stringListModel.addElement(string); } } } }); } return btnDefine; } private JButton getButtonGenerate(){ if(btnGenerate == null){ btnGenerate = new JButton("Generate..."); btnGenerate.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { List generatedStrings = null; try { generatedStrings = StringListGeneratorDialog.showDialog(DefineGenerateDialog.this, "Generate " + getTitle()); } catch (Exception e1) { JOptionPane.showMessageDialog(DefineGenerateDialog.this, "Cannot launch string list generator dialog.
Reason: " + e1.getMessage() + "", "Internal Exception", JOptionPane.ERROR_MESSAGE); } if(generatedStrings != null){ stringListModel.clear(); for(String string: generatedStrings){ stringListModel.addElement(string); } } } }); } return btnGenerate; } @Override protected void okProcedure() { if(!stringListModel.isEmpty()){ if(getDialogObject() == null) setDialogObject(new ArrayList()); for(int i=0; i showDialog(Window owner, String title) throws Exception{ DefineGenerateDialog activityDialog = new DefineGenerateDialog(owner, title); activityDialog.setUpGUI(); return activityDialog.getDialogObject(); } }




© 2015 - 2025 Weber Informatics LLC | Privacy Policy