use of de.embl.rieslab.emu.ui.uiparameters.ComboUIParameter in project micro-manager by micro-manager.
the class ConfigurablePanelTest method testGetComboUIParameterNullValue.
@Test(expected = NullPointerException.class)
public void testGetComboUIParameterNullValue() throws IncorrectUIParameterTypeException, UnknownUIParameterException {
final int defval = 2;
final String[] vals = { "SuperVal", "MediocreVal", "UnitTesting is tough", "SomeVal" };
final String param = "Param";
ConfigurableTestPanel cp = new ConfigurableTestPanel("MyPanel") {
private static final long serialVersionUID = 1L;
@Override
protected void initializeParameters() {
this.addUIParameter(new ComboUIParameter(this, param, "", vals, defval));
}
};
cp.getStringUIParameterValue(null);
}
use of de.embl.rieslab.emu.ui.uiparameters.ComboUIParameter in project micro-manager by micro-manager.
the class ParametersTable method createTable.
private void createTable(DefaultTableModel model) {
table = new JTable(model) {
private static final long serialVersionUID = 1L;
@Override
public TableCellRenderer getCellRenderer(int row, int column) {
switch(column) {
case 0:
return new BoldTableCellRenderer();
case 1:
String s = (String) table.getValueAt(row, 0);
if (uiparameterSet_.get(s).getType().equals(UIParameter.UIParameterType.COLOR)) {
// if Color parameter
return new IconTableCellRenderer();
} else if (uiparameterSet_.get(s).getType().equals(UIParameter.UIParameterType.BOOL)) {
// if checkbox
return super.getDefaultRenderer(Boolean.class);
} else {
return new DefaultTableCellRenderer();
}
default:
return super.getCellRenderer(row, column);
}
}
@Override
public TableCellEditor getCellEditor(int row, int column) {
switch(column) {
case 0:
return super.getCellEditor(row, column);
case 1:
String s = (String) table.getValueAt(row, 0);
if (uiparameterSet_.get(s).getType().equals(UIParameter.UIParameterType.COLOR)) {
return new DefaultCellEditor(color);
} else if (uiparameterSet_.get(s) instanceof ComboUIParameter) {
return new DefaultCellEditor(new JComboBox<String>(((ComboUIParameter) uiparameterSet_.get(s)).getComboValues()));
} else if (uiparameterSet_.get(s).getType().equals(UIParameter.UIParameterType.BOOL)) {
return super.getDefaultEditor(Boolean.class);
} else if (uiparameterSet_.get(s).getType().equals(UIParameter.UIParameterType.UIPROPERTY)) {
return new DefaultCellEditor(new JComboBox<String>(getAvailableProperties((UIPropertyParameter) uiparameterSet_.get(s))));
} else {
return new DefaultCellEditor(new JTextField());
}
default:
return super.getCellEditor(row, column);
}
}
@Override
public boolean isCellEditable(int row, int col) {
// only second column is editable
if (col < 1) {
return false;
} else {
return true;
}
}
};
table.setAutoCreateRowSorter(false);
table.setRowHeight(23);
table.addMouseListener(new java.awt.event.MouseAdapter() {
@Override
public void mouseClicked(java.awt.event.MouseEvent evt) {
int row = table.rowAtPoint(evt.getPoint());
updateHelper(row);
}
});
}
use of de.embl.rieslab.emu.ui.uiparameters.ComboUIParameter in project micro-manager by micro-manager.
the class ConfigurablePanelTest method testGetComboUIParameterWrongValue.
@Test(expected = UnknownUIParameterException.class)
public void testGetComboUIParameterWrongValue() throws IncorrectUIParameterTypeException, UnknownUIParameterException {
final int defval = 2;
final String[] vals = { "SuperVal", "MediocreVal", "UnitTesting is tough", "SomeVal" };
final String param = "Param";
ConfigurableTestPanel cp = new ConfigurableTestPanel("MyPanel") {
private static final long serialVersionUID = 1L;
@Override
protected void initializeParameters() {
this.addUIParameter(new ComboUIParameter(this, param, "", vals, defval));
}
};
cp.getStringUIParameterValue("Rosebud");
}
use of de.embl.rieslab.emu.ui.uiparameters.ComboUIParameter in project micro-manager by micro-manager.
the class ConfigurablePanelTest method testGetStringUIParameterWithAllTypes.
public void testGetStringUIParameterWithAllTypes() throws UnknownUIParameterException {
final String parambool = "Param";
final String paramcombo = "Param";
final String paramuiprop = "Param";
final String paramstring = "Param";
final String paramcolor = "Param";
final String paramdouble = "Param";
final String paramint = "Param";
final boolean defbool = false;
final String defstring = "Papouasie";
final String defstring2 = "New Guinea";
final double defdouble = 42.5;
final int defval = 2;
final String[] vals = { "SuperVal", "MediocreVal", "UnitTesting is tough", "SomeVal" };
ConfigurableTestPanel cp = new ConfigurableTestPanel("MyPanel") {
private static final long serialVersionUID = 1L;
@Override
protected void initializeParameters() {
this.addUIParameter(new ComboUIParameter(this, paramcombo, "", vals, defval));
this.addUIParameter(new BoolUIParameter(this, parambool, "", defbool));
UIPropertyParameter p = new UIPropertyParameter(this, paramuiprop, "", new NoFlag());
this.addUIParameter(p);
p.setStringValue(defstring2);
this.addUIParameter(new StringUIParameter(this, paramstring, "", defstring));
this.addUIParameter(new ColorUIParameter(this, paramcolor, "", Color.BLACK));
this.addUIParameter(new DoubleUIParameter(this, paramdouble, "", defdouble));
this.addUIParameter(new IntegerUIParameter(this, paramint, "", defval));
}
};
assertEquals(String.valueOf(defbool), cp.getStringUIParameterValue(parambool));
assertEquals(vals[defval], cp.getStringUIParameterValue(paramcombo));
assertEquals(defstring2, cp.getStringUIParameterValue(paramuiprop));
assertEquals(defstring, cp.getStringUIParameterValue(paramstring));
assertEquals("black", cp.getStringUIParameterValue(paramcolor));
assertEquals(String.valueOf(defdouble), cp.getStringUIParameterValue(paramdouble));
assertEquals(String.valueOf(defval), cp.getStringUIParameterValue(paramint));
}
use of de.embl.rieslab.emu.ui.uiparameters.ComboUIParameter in project micro-manager by micro-manager.
the class ConfigurablePanelTest method testgetStringUIParameterValue.
// get ComboUIParameter value
@Test
public void testgetStringUIParameterValue() throws IncorrectUIParameterTypeException, UnknownUIParameterException {
final int defval = 2;
final String[] vals = { "SuperVal", "MediocreVal", "UnitTesting is tough", "SomeVal" };
final String param = "Param";
ConfigurableTestPanel cp = new ConfigurableTestPanel("MyPanel") {
private static final long serialVersionUID = 1L;
@Override
protected void initializeParameters() {
this.addUIParameter(new ComboUIParameter(this, param, "", vals, defval));
}
};
assertEquals(vals[defval], cp.getStringUIParameterValue(param));
cp.getUIParameter(param).setStringValue(vals[0]);
assertEquals(vals[0], String.valueOf(cp.getStringUIParameterValue(param)));
}
Aggregations