Several improvements to the main editor panel (padding, etc.)
This commit is contained in:
parent
cc09ce9381
commit
850664c313
@ -734,6 +734,7 @@ public class MainFrame extends JFrame implements OptimizationStateListener {
|
||||
if (false && (newModuleAdapter instanceof AbstractModuleAdapter)) {
|
||||
JComponent tree = null;
|
||||
tree = getEvATreeView(frameMaker.getOptimizationParametersPanel(), "OptimizationParameters", ((AbstractModuleAdapter) newModuleAdapter).getOptimizationParameters());
|
||||
|
||||
gbConstraints.gridx = 0;
|
||||
gbConstraints.gridy = 0;
|
||||
gbConstraints.fill = GridBagConstraints.BOTH;
|
||||
|
@ -13,12 +13,9 @@ import javax.swing.filechooser.FileFilter;
|
||||
import javax.swing.filechooser.FileNameExtensionFilter;
|
||||
import javax.swing.plaf.basic.BasicComboBoxRenderer;
|
||||
import java.awt.*;
|
||||
import java.awt.event.ActionEvent;
|
||||
import java.awt.event.ActionListener;
|
||||
import java.awt.event.ItemEvent;
|
||||
import java.awt.event.ItemListener;
|
||||
import java.beans.PropertyChangeEvent;
|
||||
import java.beans.PropertyChangeListener;
|
||||
import java.beans.PropertyChangeSupport;
|
||||
import java.lang.reflect.Proxy;
|
||||
import java.util.ArrayList;
|
||||
@ -37,7 +34,7 @@ public class OptimizationEditorPanel extends JPanel implements ItemListener {
|
||||
/**
|
||||
* The chooser component
|
||||
*/
|
||||
private JComboBox objectChooser;
|
||||
private JComboBox<Item> objectChooser;
|
||||
/**
|
||||
* The component that performs classifier customization
|
||||
*/
|
||||
@ -45,7 +42,7 @@ public class OptimizationEditorPanel extends JPanel implements ItemListener {
|
||||
/**
|
||||
* The model containing the list of names to select from
|
||||
*/
|
||||
private DefaultComboBoxModel comboBoxModel;
|
||||
private DefaultComboBoxModel<Item> comboBoxModel;
|
||||
/**
|
||||
* Open object from disk
|
||||
*/
|
||||
@ -90,102 +87,89 @@ public class OptimizationEditorPanel extends JPanel implements ItemListener {
|
||||
} catch (OutOfMemoryError err) {
|
||||
backupObject = null;
|
||||
System.gc();
|
||||
System.err.println("Could not create backup object: not enough memory (OptimizationEditorPanel backup of " + target + ")");
|
||||
LOGGER.severe("Could not create backup object: not enough memory (OptimizationEditorPanel backup of " + target + ")");
|
||||
}
|
||||
comboBoxModel = new DefaultComboBoxModel(new Vector<Item>());
|
||||
objectChooser = new JComboBox(comboBoxModel);
|
||||
|
||||
comboBoxModel = new DefaultComboBoxModel<>(new Vector<>());
|
||||
objectChooser = new JComboBox<>(comboBoxModel);
|
||||
objectChooser.setEditable(false);
|
||||
propertySheetPanel = new PropertySheetPanel();
|
||||
propertySheetPanel.addPropertyChangeListener(
|
||||
new PropertyChangeListener() {
|
||||
@Override
|
||||
public void propertyChange(final PropertyChangeEvent event) {
|
||||
propChangeSupport.firePropertyChange("", backupObject, genericObjectEditor.getValue());
|
||||
}
|
||||
});
|
||||
propertySheetPanel.addPropertyChangeListener(event -> propChangeSupport.firePropertyChange("", backupObject, genericObjectEditor.getValue()));
|
||||
openButton = makeIconButton("images/Open16.gif", "Open");
|
||||
openButton.setToolTipText("Load a configured object");
|
||||
openButton.setEnabled(true);
|
||||
openButton.addActionListener(new ActionListener() {
|
||||
@Override
|
||||
public void actionPerformed(final ActionEvent event) {
|
||||
FileFilter filter = new FileNameExtensionFilter("YAML file", "yml", "yaml");
|
||||
Object object = FileTools.openObject(openButton, genericObjectEditor.getClassType(), filter);
|
||||
if (object != null) {
|
||||
// setValue takes care of: Making sure obj is of right type,
|
||||
// and firing property change.
|
||||
genericObjectEditor.setValue(object);
|
||||
// Need a second setValue to get property values filled in OK.
|
||||
// Not sure why.
|
||||
genericObjectEditor.setValue(object); // <- Hannes ?!?!?
|
||||
}
|
||||
openButton.addActionListener(event -> {
|
||||
FileFilter filter = new FileNameExtensionFilter("YAML file", "yml", "yaml");
|
||||
Object object = FileTools.openObject(openButton, genericObjectEditor.getClassType(), filter);
|
||||
if (object != null) {
|
||||
// setValue takes care of: Making sure obj is of right type,
|
||||
// and firing property change.
|
||||
genericObjectEditor.setValue(object);
|
||||
// Need a second setValue to get property values filled in OK.
|
||||
// Not sure why.
|
||||
genericObjectEditor.setValue(object); // <- Hannes ?!?!?
|
||||
}
|
||||
});
|
||||
|
||||
saveButton = makeIconButton("images/Save16.gif", "Save");
|
||||
saveButton.setToolTipText("Save the current configured object");
|
||||
saveButton.setEnabled(true);
|
||||
saveButton.addActionListener(new ActionListener() {
|
||||
@Override
|
||||
public void actionPerformed(final ActionEvent event) {
|
||||
FileFilter filter = new FileNameExtensionFilter("YAML file", "yml", "yaml");
|
||||
FileTools.saveObjectWithFileChooser(saveButton, BeanSerializer.serializeObject(genericObjectEditor.getValue()), filter);
|
||||
}
|
||||
saveButton.addActionListener(event -> {
|
||||
FileFilter filter = new FileNameExtensionFilter("YAML file", "yml", "yaml");
|
||||
FileTools.saveObjectWithFileChooser(saveButton, BeanSerializer.serializeObject(genericObjectEditor.getValue()), filter);
|
||||
});
|
||||
|
||||
okayButton = new JButton("OK");
|
||||
okayButton.setEnabled(true);
|
||||
okayButton.addActionListener(new ActionListener() {
|
||||
@Override
|
||||
public void actionPerformed(final ActionEvent event) {
|
||||
//backupObject = copyObject(genericObjectEditor.getValue());
|
||||
okayButton.addActionListener(event -> {
|
||||
updateClassType();
|
||||
updateChildPropertySheet();
|
||||
|
||||
updateClassType();
|
||||
updateChildPropertySheet();
|
||||
|
||||
/*
|
||||
* ToDo: This is really ugly. Find a way to make this better.
|
||||
*/
|
||||
Container container = OptimizationEditorPanel.this.getParent();
|
||||
while (!(container instanceof JDialog)) {
|
||||
container = container.getParent();
|
||||
}
|
||||
((JDialog) container).dispose();
|
||||
/*
|
||||
* ToDo: This is really ugly. Find a way to make this better.
|
||||
*/
|
||||
Container container = OptimizationEditorPanel.this.getParent();
|
||||
while (!(container instanceof JDialog)) {
|
||||
container = container.getParent();
|
||||
}
|
||||
((JDialog) container).dispose();
|
||||
});
|
||||
|
||||
cancelButton = new JButton("Cancel");
|
||||
cancelButton.setEnabled(true);
|
||||
cancelButton.addActionListener(new ActionListener() {
|
||||
@Override
|
||||
public void actionPerformed(final ActionEvent event) {
|
||||
if (backupObject != null) {
|
||||
genericObjectEditor.setValue(copyObject(backupObject));
|
||||
updateClassType();
|
||||
updateChooser();
|
||||
updateChildPropertySheet();
|
||||
}
|
||||
/*
|
||||
* ToDo: This is really ugly. Find a way to make this better.
|
||||
*/
|
||||
Container container = OptimizationEditorPanel.this.getParent();
|
||||
while (!(container instanceof JDialog)) {
|
||||
container = container.getParent();
|
||||
}
|
||||
((JDialog) container).dispose();
|
||||
cancelButton.addActionListener(event -> {
|
||||
if (backupObject != null) {
|
||||
genericObjectEditor.setValue(copyObject(backupObject));
|
||||
updateClassType();
|
||||
updateChooser();
|
||||
updateChildPropertySheet();
|
||||
}
|
||||
/*
|
||||
* ToDo: This is really ugly. Find a way to make this better.
|
||||
*/
|
||||
Container container = OptimizationEditorPanel.this.getParent();
|
||||
while (!(container instanceof JDialog)) {
|
||||
container = container.getParent();
|
||||
}
|
||||
((JDialog) container).dispose();
|
||||
});
|
||||
|
||||
setBorder(BorderFactory.createEmptyBorder(10, 10, 10, 10));
|
||||
|
||||
setLayout(new GridBagLayout());
|
||||
GridBagConstraints gbConstraints = new GridBagConstraints();
|
||||
|
||||
gbConstraints.fill = GridBagConstraints.HORIZONTAL;
|
||||
gbConstraints.gridx = 0;
|
||||
gbConstraints.gridy = 0;
|
||||
add(objectChooser, gbConstraints);
|
||||
|
||||
gbConstraints.gridy = 1;
|
||||
add(new JSeparator(JSeparator.HORIZONTAL), gbConstraints);
|
||||
|
||||
gbConstraints.weightx = 1.0;
|
||||
gbConstraints.weighty = 1.0;
|
||||
gbConstraints.gridy = 1;
|
||||
gbConstraints.gridy = 2;
|
||||
gbConstraints.gridheight = GridBagConstraints.RELATIVE;
|
||||
gbConstraints.fill = GridBagConstraints.BOTH;
|
||||
add(propertySheetPanel, gbConstraints);
|
||||
@ -206,7 +190,7 @@ public class OptimizationEditorPanel extends JPanel implements ItemListener {
|
||||
|
||||
gbConstraints.weightx = 0.0;
|
||||
gbConstraints.weighty = 0.0;
|
||||
gbConstraints.gridy = 2;
|
||||
gbConstraints.gridy = 3;
|
||||
gbConstraints.anchor = GridBagConstraints.LINE_START;
|
||||
gbConstraints.fill = GridBagConstraints.HORIZONTAL;
|
||||
add(buttonBar, gbConstraints);
|
||||
@ -321,16 +305,20 @@ public class OptimizationEditorPanel extends JPanel implements ItemListener {
|
||||
|
||||
classesList.add(new Item(className, displayName, toolTips[i++]));
|
||||
}
|
||||
comboBoxModel = new DefaultComboBoxModel(classesList);
|
||||
comboBoxModel = new DefaultComboBoxModel<>(classesList);
|
||||
objectChooser.setModel(comboBoxModel);
|
||||
objectChooser.setRenderer(new ToolTipComboBoxRenderer());
|
||||
/*
|
||||
GridBagConstraints gbConstraints = new GridBagConstraints();
|
||||
gbConstraints.fill = GridBagConstraints.HORIZONTAL;
|
||||
gbConstraints.gridx = 0;
|
||||
gbConstraints.gridy = 0;
|
||||
gbConstraints.gridy = 1;
|
||||
add(objectChooser, gbConstraints);
|
||||
*/
|
||||
objectChooser.setVisible(true);
|
||||
} else {
|
||||
remove(objectChooser);
|
||||
objectChooser.setVisible(false);
|
||||
//remove(objectChooser);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -228,6 +228,8 @@ public final class PropertySheetPanel extends JPanel implements PropertyChangeLi
|
||||
gbConstraints.fill = GridBagConstraints.HORIZONTAL;
|
||||
gbConstraints.anchor = GridBagConstraints.PAGE_START;
|
||||
add(infoPanel, gbConstraints);
|
||||
gbConstraints.gridy = 1;
|
||||
add(new JSeparator(JSeparator.HORIZONTAL), gbConstraints);
|
||||
}
|
||||
}
|
||||
|
||||
@ -307,7 +309,7 @@ public final class PropertySheetPanel extends JPanel implements PropertyChangeLi
|
||||
|
||||
JScrollPane scrollableTable = new JScrollPane(propertyTable, JScrollPane.VERTICAL_SCROLLBAR_AS_NEEDED, JScrollPane.HORIZONTAL_SCROLLBAR_AS_NEEDED);
|
||||
gbConstraints.gridx = 0;
|
||||
gbConstraints.gridy = 1;
|
||||
gbConstraints.gridy = 2;
|
||||
gbConstraints.weightx = 1.0;
|
||||
gbConstraints.weighty = 1.0;
|
||||
gbConstraints.fill = GridBagConstraints.BOTH;
|
||||
|
@ -82,7 +82,6 @@ public class TabbedFrameMaker implements Serializable, PanelMaker, InterfaceNoti
|
||||
|
||||
/**
|
||||
* @return The toolbar with control buttons
|
||||
* @deprecated
|
||||
*/
|
||||
public JExtToolBar getToolBar() {
|
||||
return extToolBar;
|
||||
|
@ -20,7 +20,7 @@ import java.util.logging.Logger;
|
||||
*/
|
||||
@Description("Terminate if a given number of optima has been found. Works for problems implementing InterfaceMultimodalProblemKnown, e.g. FM0.")
|
||||
public class KnownOptimaFoundTerminator implements InterfaceTerminator, Serializable {
|
||||
private Logger LOGGER = Logger.getLogger(KnownOptimaFoundTerminator.class.getName());
|
||||
private static final Logger LOGGER = Logger.getLogger(KnownOptimaFoundTerminator.class.getName());
|
||||
private InterfaceMultimodalProblemKnown mProblem = null;
|
||||
private int reqOptima = 1;
|
||||
private String msg = "";
|
||||
|
Loading…
x
Reference in New Issue
Block a user