use of javax.swing.JComponent in project knime-core by knime.
the class DatabasePortObjectSpec method getViews.
/**
* {@inheritDoc}
*/
@Override
public JComponent[] getViews() {
JComponent[] views = super.getViews();
views = Arrays.copyOf(views, views.length + 1);
views[views.length - 1] = new DataTableSpecView(m_spec);
return views;
}
use of javax.swing.JComponent in project knime-core by knime.
the class DialogComponentDoubleRange method validateSettingsBeforeSave.
/**
* {@inheritDoc}
*/
@Override
protected void validateSettingsBeforeSave() throws InvalidSettingsException {
final SettingsModelDoubleRange model = (SettingsModelDoubleRange) getModel();
double newMin;
double newMax;
// try to commit Minimum
try {
m_spinnerMin.commitEdit();
newMin = ((Double) m_spinnerMin.getValue()).doubleValue();
} catch (final ParseException e) {
final JComponent editor = m_spinnerMin.getEditor();
if (editor instanceof DefaultEditor) {
showError(((DefaultEditor) editor).getTextField());
}
String errMsg = "Invalid number format. ";
errMsg += "Please enter a valid minimum.";
throw new InvalidSettingsException(errMsg);
}
// try to commit Maximum
try {
m_spinnerMax.commitEdit();
newMax = ((Double) m_spinnerMax.getValue()).doubleValue();
} catch (final ParseException e) {
final JComponent editor = m_spinnerMax.getEditor();
if (editor instanceof DefaultEditor) {
showError(((DefaultEditor) editor).getTextField());
}
String errMsg = "Invalid number format. ";
errMsg += "Please enter a valid maximum.";
throw new InvalidSettingsException(errMsg);
}
try {
new SettingsModelDoubleRange(model.getConfigName(), newMin, newMax);
} catch (final IllegalArgumentException iae) {
JComponent editor = m_spinnerMax.getEditor();
if (editor instanceof DefaultEditor) {
showError(((DefaultEditor) editor).getTextField());
}
editor = m_spinnerMin.getEditor();
if (editor instanceof DefaultEditor) {
showError(((DefaultEditor) editor).getTextField());
}
throw new InvalidSettingsException(iae.getMessage());
}
}
use of javax.swing.JComponent in project knime-core by knime.
the class DialogComponentNumber method updateComponent.
/**
* {@inheritDoc}
*/
@Override
protected void updateComponent() {
final JComponent editor = m_spinner.getEditor();
if (editor instanceof DefaultEditor) {
clearError(((DefaultEditor) editor).getTextField());
}
// model
try {
m_spinner.commitEdit();
if (getModel() instanceof SettingsModelDouble) {
final SettingsModelDouble model = (SettingsModelDouble) getModel();
final double val = ((Double) m_spinner.getValue()).doubleValue();
if (val != model.getDoubleValue()) {
m_spinner.setValue(new Double(model.getDoubleValue()));
}
} else if (getModel() instanceof SettingsModelInteger) {
final SettingsModelInteger model = (SettingsModelInteger) getModel();
final int val = ((Integer) m_spinner.getValue()).intValue();
if (val != model.getIntValue()) {
m_spinner.setValue(Integer.valueOf(model.getIntValue()));
}
} else {
final SettingsModelLong model = (SettingsModelLong) getModel();
final long val = ((Long) m_spinner.getValue()).longValue();
if (val != model.getLongValue()) {
m_spinner.setValue(Long.valueOf(model.getLongValue()));
}
}
} catch (final ParseException e) {
// spinner contains invalid value - update component!
if (getModel() instanceof SettingsModelDouble) {
final SettingsModelDouble model = (SettingsModelDouble) getModel();
m_spinner.setValue(new Double(model.getDoubleValue()));
} else if (getModel() instanceof SettingsModelInteger) {
final SettingsModelInteger model = (SettingsModelInteger) getModel();
m_spinner.setValue(Integer.valueOf(model.getIntValue()));
} else {
final SettingsModelLong model = (SettingsModelLong) getModel();
m_spinner.setValue(Long.valueOf(model.getLongValue()));
}
}
// also update the enable status of all components...
setEnabledComponents(getModel().isEnabled());
}
use of javax.swing.JComponent in project knime-core by knime.
the class FilterDefinitionHandlerPortObject method getViews.
/**
* {@inheritDoc}
*/
@Override
public JComponent[] getViews() {
ModelContent model = new ModelContent("FilterDefinition");
Config columnConfig = model.addConfig("Column");
getSpec().forEach(col -> col.getFilterHandler().ifPresent(handler -> handler.save(columnConfig.addConfig(col.getName()))));
return new JComponent[] { new ModelContentOutPortView(model) };
}
use of javax.swing.JComponent in project knime-core by knime.
the class SizeHandlerPortObject method getViews.
/**
* {@inheritDoc}
*/
@Override
public JComponent[] getViews() {
ModelContent model = new ModelContent("Size");
getSpec().getColumnSpec(0).getSizeHandler().save(model);
return new JComponent[] { new ModelContentOutPortView(model) };
}
Aggregations