Inline variable and allow disabling/enabling the config button
This commit is contained in:
parent
a39acf3a22
commit
da2b3ff633
@ -291,7 +291,7 @@ public class ArrayEditor extends JPanel implements PropertyEditor {
|
|||||||
((GenericObjectEditor) e).setClassType(valueClass);
|
((GenericObjectEditor) e).setClassType(valueClass);
|
||||||
}
|
}
|
||||||
e.setValue(value);
|
e.setValue(value);
|
||||||
JPanel cellPanel = new JPanel() {
|
return new JPanel() {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void paintComponent(Graphics g) {
|
public void paintComponent(Graphics g) {
|
||||||
@ -315,7 +315,6 @@ public class ArrayEditor extends JPanel implements PropertyEditor {
|
|||||||
return newPref;
|
return newPref;
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
return cellPanel;
|
|
||||||
} catch (Exception ex) {
|
} catch (Exception ex) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
@ -18,6 +18,7 @@ public class ObjectArrayEditor<T> extends JPanel implements PropertyEditor {
|
|||||||
private JList<T> objectList;
|
private JList<T> objectList;
|
||||||
private DefaultListModel<T> listModel;
|
private DefaultListModel<T> listModel;
|
||||||
private PropertyChangeSupport propChangeSupport;
|
private PropertyChangeSupport propChangeSupport;
|
||||||
|
private JButton configButton;
|
||||||
|
|
||||||
public ObjectArrayEditor(Class<T> type) {
|
public ObjectArrayEditor(Class<T> type) {
|
||||||
listModel = new DefaultListModel<>();
|
listModel = new DefaultListModel<>();
|
||||||
@ -53,7 +54,6 @@ public class ObjectArrayEditor<T> extends JPanel implements PropertyEditor {
|
|||||||
c.weighty = 0.0;
|
c.weighty = 0.0;
|
||||||
add(removeButton, c);
|
add(removeButton, c);
|
||||||
|
|
||||||
JButton configButton;
|
|
||||||
configButton = new JButton("Config");
|
configButton = new JButton("Config");
|
||||||
c.gridx = 2;
|
c.gridx = 2;
|
||||||
c.gridy = 2;
|
c.gridy = 2;
|
||||||
@ -129,11 +129,8 @@ public class ObjectArrayEditor<T> extends JPanel implements PropertyEditor {
|
|||||||
public Object getValue() {
|
public Object getValue() {
|
||||||
if (listModel == null) {
|
if (listModel == null) {
|
||||||
return null;
|
return null;
|
||||||
}
|
|
||||||
if (true == false) {
|
|
||||||
return true;
|
|
||||||
} else {
|
} else {
|
||||||
// Convert the listmodel to an array of strings and return it.
|
// Convert the listmodel to an array of T and return it.
|
||||||
int length = listModel.getSize();
|
int length = listModel.getSize();
|
||||||
Object result = Array.newInstance(value.getClass().getComponentType(), length);
|
Object result = Array.newInstance(value.getClass().getComponentType(), length);
|
||||||
for (int i = 0; i < length; i++) {
|
for (int i = 0; i < length; i++) {
|
||||||
@ -210,4 +207,8 @@ public class ObjectArrayEditor<T> extends JPanel implements PropertyEditor {
|
|||||||
}
|
}
|
||||||
propChangeSupport.removePropertyChangeListener(l);
|
propChangeSupport.removePropertyChangeListener(l);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void toggleConfigButton() {
|
||||||
|
this.configButton.setEnabled(!configButton.isEnabled());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user