parent
3325ec7a90
commit
8aac396938
@ -22,7 +22,6 @@ import java.beans.PropertyChangeListener;
|
|||||||
import java.beans.PropertyChangeSupport;
|
import java.beans.PropertyChangeSupport;
|
||||||
import java.lang.reflect.Proxy;
|
import java.lang.reflect.Proxy;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.HashMap;
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Vector;
|
import java.util.Vector;
|
||||||
import java.util.logging.Logger;
|
import java.util.logging.Logger;
|
||||||
@ -80,19 +79,18 @@ public class OptimizationEditorPanel extends JPanel implements ItemListener {
|
|||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
public OptimizationEditorPanel(Object target, Object backup, PropertyChangeSupport support, GenericObjectEditor goe, boolean withCancel) {
|
public OptimizationEditorPanel(Object target, Object backup, PropertyChangeSupport support, GenericObjectEditor goe, boolean withCancel) {
|
||||||
Object object = target;
|
|
||||||
backupObject = backup;
|
backupObject = backup;
|
||||||
propChangeSupport = support;
|
propChangeSupport = support;
|
||||||
genericObjectEditor = goe;
|
genericObjectEditor = goe;
|
||||||
|
|
||||||
try {
|
try {
|
||||||
if (!(Proxy.isProxyClass(object.getClass()))) {
|
if (!(Proxy.isProxyClass(target.getClass()))) {
|
||||||
backupObject = copyObject(object);
|
backupObject = copyObject(target);
|
||||||
}
|
}
|
||||||
} catch (OutOfMemoryError err) {
|
} catch (OutOfMemoryError err) {
|
||||||
backupObject = null;
|
backupObject = null;
|
||||||
System.gc();
|
System.gc();
|
||||||
System.err.println("Could not create backup object: not enough memory (OptimizationEditorPanel backup of " + object + ")");
|
System.err.println("Could not create backup object: not enough memory (OptimizationEditorPanel backup of " + target + ")");
|
||||||
}
|
}
|
||||||
comboBoxModel = new DefaultComboBoxModel(new Vector<Item>());
|
comboBoxModel = new DefaultComboBoxModel(new Vector<Item>());
|
||||||
objectChooser = new JComboBox(comboBoxModel);
|
objectChooser = new JComboBox(comboBoxModel);
|
||||||
@ -225,9 +223,9 @@ public class OptimizationEditorPanel extends JPanel implements ItemListener {
|
|||||||
* This method is duplicated from EvAModuleButtonPanelMaker. ToDo: Refactor
|
* This method is duplicated from EvAModuleButtonPanelMaker. ToDo: Refactor
|
||||||
* this.
|
* this.
|
||||||
*
|
*
|
||||||
* @param iconSrc
|
* @param iconSrc Source path of icon
|
||||||
* @param title
|
* @param title Title of button
|
||||||
* @return
|
* @return A JButton with the title and icon
|
||||||
*/
|
*/
|
||||||
private JButton makeIconButton(final String iconSrc, final String title) {
|
private JButton makeIconButton(final String iconSrc, final String title) {
|
||||||
JButton newButton;
|
JButton newButton;
|
||||||
@ -258,7 +256,6 @@ public class OptimizationEditorPanel extends JPanel implements ItemListener {
|
|||||||
try {
|
try {
|
||||||
SerializedObject so = new SerializedObject(source);
|
SerializedObject so = new SerializedObject(source);
|
||||||
result = so.getObject();
|
result = so.getObject();
|
||||||
so = null;
|
|
||||||
} catch (Exception ex) {
|
} catch (Exception ex) {
|
||||||
System.err.println("GenericObjectEditor: Problem making backup object");
|
System.err.println("GenericObjectEditor: Problem making backup object");
|
||||||
System.err.println(source.getClass().getName());
|
System.err.println(source.getClass().getName());
|
||||||
@ -324,7 +321,8 @@ public class OptimizationEditorPanel extends JPanel implements ItemListener {
|
|||||||
|
|
||||||
classesList.add(new Item(className, displayName, toolTips[i++]));
|
classesList.add(new Item(className, displayName, toolTips[i++]));
|
||||||
}
|
}
|
||||||
objectChooser.setModel(new DefaultComboBoxModel(classesList));
|
comboBoxModel = new DefaultComboBoxModel(classesList);
|
||||||
|
objectChooser.setModel(comboBoxModel);
|
||||||
objectChooser.setRenderer(new ToolTipComboBoxRenderer());
|
objectChooser.setRenderer(new ToolTipComboBoxRenderer());
|
||||||
GridBagConstraints gbConstraints = new GridBagConstraints();
|
GridBagConstraints gbConstraints = new GridBagConstraints();
|
||||||
gbConstraints.fill = GridBagConstraints.HORIZONTAL;
|
gbConstraints.fill = GridBagConstraints.HORIZONTAL;
|
||||||
@ -362,13 +360,10 @@ public class OptimizationEditorPanel extends JPanel implements ItemListener {
|
|||||||
|
|
||||||
public void updateChooser() {
|
public void updateChooser() {
|
||||||
String objectName = genericObjectEditor.getValue().getClass().getName();
|
String objectName = genericObjectEditor.getValue().getClass().getName();
|
||||||
boolean found = false;
|
|
||||||
for (int i = 0; i < comboBoxModel.getSize(); i++) {
|
for (int i = 0; i < comboBoxModel.getSize(); i++) {
|
||||||
Item element = (Item)comboBoxModel.getElementAt(i);
|
Item element = (Item)comboBoxModel.getElementAt(i);
|
||||||
|
|
||||||
System.out.println(objectName + " - " + element.getId());
|
|
||||||
if (objectName.equals(element.getId())) {
|
if (objectName.equals(element.getId())) {
|
||||||
found = true;
|
|
||||||
objectChooser.getModel().setSelectedItem(element);
|
objectChooser.getModel().setSelectedItem(element);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
@ -431,8 +426,7 @@ class ToolTipComboBoxRenderer extends BasicComboBoxRenderer {
|
|||||||
super.getListCellRendererComponent(list, value, index,
|
super.getListCellRendererComponent(list, value, index,
|
||||||
isSelected, cellHasFocus);
|
isSelected, cellHasFocus);
|
||||||
|
|
||||||
if (value != null)
|
if (value != null) {
|
||||||
{
|
|
||||||
Item item = (Item)value;
|
Item item = (Item)value;
|
||||||
setText(item.getDisplayName());
|
setText(item.getDisplayName());
|
||||||
|
|
||||||
@ -446,8 +440,7 @@ class ToolTipComboBoxRenderer extends BasicComboBoxRenderer {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (index == -1)
|
if (index == -1) {
|
||||||
{
|
|
||||||
Item item = (Item)value;
|
Item item = (Item)value;
|
||||||
setText(item.getDisplayName());
|
setText(item.getDisplayName());
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user