use of javax.swing.JComponent in project knime-core by knime.
the class JSnippetPanel method layoutLeftComponent.
/**
* Subclasses can override this method to customize the left side layout of the main split pain.
* If the subclass uses self-defined components make sure that these are already created and
* initialized during the call of {@link #initSubComponents()}.
*
* @return the component for the left side of the main split-panel
* @since 2.10
*/
protected JComponent layoutLeftComponent() {
JComponent leftComponent;
if (m_showColumns && m_showFlowVariables) {
final JSplitPane varSplitPane = new JSplitPane(JSplitPane.VERTICAL_SPLIT);
leftComponent = varSplitPane;
JScrollPane colListPane = new JScrollPane(m_colList);
colListPane.setBorder(createEmptyTitledBorder("Column List"));
varSplitPane.setTopComponent(colListPane);
// set variable panel
JScrollPane pane = new JScrollPane(m_flowVarsList);
pane.setBorder(createEmptyTitledBorder("Flow Variable List"));
varSplitPane.setBottomComponent(pane);
varSplitPane.setOneTouchExpandable(true);
varSplitPane.setResizeWeight(0.9);
} else if (m_showColumns && !m_showFlowVariables) {
leftComponent = new JScrollPane(m_colList);
leftComponent.setBorder(createEmptyTitledBorder("Column List"));
} else if (m_showFlowVariables) {
leftComponent = new JScrollPane(m_flowVarsList);
leftComponent.setBorder(createEmptyTitledBorder("Flow Variable List"));
} else {
leftComponent = new JPanel();
}
return leftComponent;
}
use of javax.swing.JComponent in project knime-core by knime.
the class DateTimeBasedRowFilterNodeDialog method checkPeriodOrDuration.
/**
* Checks if period or duration can be parsed
*/
private void checkPeriodOrDuration() {
String warning = "";
try {
DurationPeriodFormatUtils.parsePeriod(((SettingsModelString) m_dialogCompPeriodOrDurationValue.getModel()).getStringValue());
if (m_dialogCompColSelection.getSelectedAsSpec().getType().isCompatible(LocalTimeValue.class)) {
warning = "A date-based duration cannot be applied on a time!";
}
} catch (DateTimeParseException e) {
try {
DurationPeriodFormatUtils.parseDuration(((SettingsModelString) m_dialogCompPeriodOrDurationValue.getModel()).getStringValue());
if (m_dialogCompColSelection.getSelectedAsSpec().getType().isCompatible(LocalDateValue.class)) {
warning = "A time-based duration cannot be applied on a date!";
}
} catch (DateTimeParseException e2) {
warning = "Value does not represent a duration!";
}
}
if (!warning.equals("")) {
((JComponent) m_dialogCompPeriodOrDurationValue.getComponentPanel().getComponent(1)).setBorder(BorderFactory.createLineBorder(Color.RED));
m_typeWarningLabel.setText(warning);
} else {
((JComponent) m_dialogCompPeriodOrDurationValue.getComponentPanel().getComponent(1)).setBorder(UIManager.getBorder("TextField.border"));
}
}
use of javax.swing.JComponent in project knime-core by knime.
the class TimeMissingValueHandlingPanel method createContent.
private void createContent(final TimeMissingValueHandlingColSetting setting, final DataColumnSpec... spec) throws InternalError {
final List<String> warningMessages = new ArrayList<String>();
// if we got incompatible types the original type is overwritten by unkown.
ConfigType settingTypeBackup = setting.getType();
JPanel tabPanel = new JPanel(new BorderLayout(0, 5));
final JPanel comboRemovePanel = new JPanel(new BorderLayout(0, 2));
Border border;
final JComponent removePanel;
final String typeName = ConfigType.NUMERICAL.equals(setting.getType()) ? "Numeric Columns" : "Non-numeric Columns";
if (setting.isMetaConfig()) {
border = BorderFactory.createTitledBorder(typeName);
removePanel = new JLabel();
} else {
final List<String> names = new ArrayList<String>(Arrays.asList(setting.getNames()));
for (DataColumnSpec cspec : spec) {
names.remove(cspec.getName());
}
if (!names.isEmpty()) {
throw new NullPointerException("Not equal on init: '" + Arrays.toString(setting.getNames()) + "' vs. '" + Arrays.toString(spec) + "'.");
}
JButton requestRemoveButton = new JButton("Remove");
requestRemoveButton.addActionListener(new ActionListener() {
/**
* {@inheritDoc}
*/
@Override
public void actionPerformed(final ActionEvent e) {
firePropertyChange(REMOVE_ACTION, null, null);
}
});
removePanel = new JPanel();
removePanel.setLayout(new BorderLayout());
removePanel.add(requestRemoveButton, BorderLayout.NORTH);
final List<DataColumnSpec> notExistingColumns = getNotExistingColumns(spec);
final List<DataColumnSpec> incompatibleColumns = getIncompatibleTypedColumns(setting.getType(), spec);
if (!notExistingColumns.isEmpty()) {
warningMessages.add("Some columns no longer exist (red bordered)");
}
if (!incompatibleColumns.isEmpty()) {
warningMessages.add(String.format("Some columns have an incompatible type to %s (yellow borderd)", ConfigType.typeToString(setting.getType())));
}
final Set<DataColumnSpec> invalidColumns = new HashSet<DataColumnSpec>();
invalidColumns.addAll(notExistingColumns);
invalidColumns.addAll(incompatibleColumns);
if (!invalidColumns.isEmpty() && // if all columns are invalid a clean is the same as a remove
!(invalidColumns.size() == spec.length)) {
JButton removeNotExistingColumns = new JButton("Clean");
removeNotExistingColumns.setToolTipText("Removes all invalid columns from the configuration.");
removeNotExistingColumns.addActionListener(new ActionListener() {
/**
* {@inheritDoc}
*/
@Override
public void actionPerformed(final ActionEvent e) {
TimeMissingValueHandlingPanel.this.removeAll();
// recreate the content, based on the new settings with removed invalid columns
createContent(diff(m_setting, invalidColumns), diff(spec, invalidColumns));
firePropertyChange(REMOVED_INVALID_COLUMNS, null, invalidColumns.toArray(new DataColumnSpec[invalidColumns.size()]));
}
});
removePanel.add(removeNotExistingColumns);
}
if (!warningMessages.isEmpty()) {
LOGGER.warn("get warnings during panel validation: " + warningMessages);
border = BorderFactory.createLineBorder(Color.RED, 2);
tabPanel.add(createWarningLabel(warningMessages), BorderLayout.NORTH);
} else {
border = BorderFactory.createLineBorder(Color.BLACK);
}
}
createWestLayout(setting, tabPanel, typeName, spec);
comboRemovePanel.add(m_comboBox, BorderLayout.CENTER);
comboRemovePanel.add(removePanel, BorderLayout.EAST);
fillComboBox(setting);
setting.setType(settingTypeBackup);
m_setting = setting;
setBorder(border != null ? BorderFactory.createTitledBorder(border, typeName) : null);
tabPanel.add(comboRemovePanel, BorderLayout.NORTH);
tabPanel.add(createSpacer(65), BorderLayout.SOUTH);
add(tabPanel);
}
use of javax.swing.JComponent in project knime-core by knime.
the class MissingValueHandling2Panel method createContent.
/**
* @param setting
* @param spec
* @throws InternalError
*/
private void createContent(final MissingValueHandling2ColSetting setting, final DataColumnSpec... spec) throws InternalError {
final List<String> warningMessages = new ArrayList<String>();
// if we got incompatible types the original type is overwritten by unkown.
int settingTypeBackup = setting.getType();
JPanel tabPanel = new JPanel(new BorderLayout(0, 5));
final JPanel panel = new JPanel(new GridLayout(0, 2));
final Icon icon;
final String name;
final Border border;
final JComponent removePanel;
if (setting.isMetaConfig()) {
switch(setting.getType()) {
case MissingValueHandling2ColSetting.TYPE_INT:
icon = IntCell.TYPE.getIcon();
name = "Integer";
border = BorderFactory.createTitledBorder("Integer Columns");
break;
case MissingValueHandling2ColSetting.TYPE_STRING:
icon = StringCell.TYPE.getIcon();
name = "String";
border = BorderFactory.createTitledBorder("String Columns");
break;
case MissingValueHandling2ColSetting.TYPE_DOUBLE:
icon = DoubleCell.TYPE.getIcon();
name = "Double";
border = BorderFactory.createTitledBorder("Double Columns");
break;
case MissingValueHandling2ColSetting.TYPE_UNKNOWN:
icon = DataType.getType(DataCell.class).getIcon();
name = "Unknown";
border = BorderFactory.createTitledBorder("Unknown Columns");
break;
default:
throw new InternalError("No such type.");
}
removePanel = new JLabel();
} else {
final List<String> names = new ArrayList<String>(Arrays.asList(setting.getNames()));
for (DataColumnSpec cspec : spec) {
names.remove(cspec.getName());
}
if (!names.isEmpty()) {
throw new NullPointerException("Not equal on init: '" + Arrays.toString(setting.getNames()) + "' vs. '" + Arrays.toString(spec) + "'.");
}
name = setting.getDisplayName();
icon = spec[0].getType().getIcon();
JButton requestRemoveButton = new JButton("Remove");
requestRemoveButton.addActionListener(new ActionListener() {
/**
* {@inheritDoc}
*/
@Override
public void actionPerformed(final ActionEvent e) {
firePropertyChange(REMOVE_ACTION, null, null);
}
});
removePanel = new JPanel();
removePanel.setLayout(new GridLayout(2, 0));
removePanel.add(requestRemoveButton);
final List<DataColumnSpec> notExistingColumns = getNotExistingColumns(spec);
final List<DataColumnSpec> incompatibleColumns = getIncompatibleTypedColumns(setting.getType(), spec);
if (!notExistingColumns.isEmpty()) {
warningMessages.add("Some columns no longer exist (red bordered)");
}
if (!incompatibleColumns.isEmpty()) {
warningMessages.add(String.format("Some columns have an incompatible type to %s (yellow borderd)", typeToString(setting.getType())));
}
final Set<DataColumnSpec> invalidColumns = new HashSet<DataColumnSpec>();
invalidColumns.addAll(notExistingColumns);
invalidColumns.addAll(incompatibleColumns);
if (!incompatibleColumns.isEmpty()) {
setting.setType(MissingValueHandling2ColSetting.TYPE_UNKNOWN);
}
if (!invalidColumns.isEmpty() && // if all columns are invalid a clean is the same as a remove
!(invalidColumns.size() == spec.length)) {
JButton removeNotExistingColumns = new JButton("Clean");
removeNotExistingColumns.setToolTipText("Removes all invalid columns from the configuration.");
removeNotExistingColumns.addActionListener(new ActionListener() {
/**
* {@inheritDoc}
*/
@Override
public void actionPerformed(final ActionEvent e) {
MissingValueHandling2Panel.this.removeAll();
// recreate the content, based on the new settings with removed invalid columns
createContent(diff(m_setting, invalidColumns), diff(spec, invalidColumns));
firePropertyChange(REMOVED_INVALID_COLUMNS, null, invalidColumns.toArray(new DataColumnSpec[invalidColumns.size()]));
}
});
removePanel.add(removeNotExistingColumns);
}
if (!warningMessages.isEmpty()) {
LOGGER.warn("get warnings during panel validation: " + warningMessages);
border = BorderFactory.createLineBorder(Color.RED, 2);
tabPanel.add(createWarningLabel(warningMessages), BorderLayout.NORTH);
} else {
border = BorderFactory.createLineBorder(Color.BLACK);
}
}
createWestLayout(setting, tabPanel, icon, name, spec);
panel.add(createSpacer(1));
panel.add(removePanel);
createEastLayout(setting, panel, spec);
setting.setType(settingTypeBackup);
m_setting = setting;
setBorder(border);
tabPanel.add(panel, BorderLayout.CENTER);
tabPanel.add(createSpacer(65), BorderLayout.SOUTH);
add(tabPanel);
}
use of javax.swing.JComponent in project knime-core by knime.
the class ImagePortObjectSpec method getViews.
/**
* {@inheritDoc}
*/
@Override
public JComponent[] getViews() {
JLabel l = new JLabel("Image of type \"" + getDataType() + "\"");
l.setName("Image Spec");
return new JComponent[] { l };
}
Aggregations