use of java.awt.event.MouseAdapter in project knime-core by knime.
the class MissingValueHandling2NodeDialogPane method loadSettingsFrom.
/**
* {@inheritDoc}
*/
@Override
protected void loadSettingsFrom(final NodeSettingsRO settings, final DataTableSpec[] specs) throws NotConfigurableException {
m_searchableListModifier = m_searchableListPanel.update(specs[0]);
MissingValueHandling2ColSetting[] defaults = MissingValueHandling2ColSetting.loadMetaColSettings(settings, specs[0]);
MissingValueHandling2ColSetting[] individuals = MissingValueHandling2ColSetting.loadIndividualColSettings(settings, specs[0]);
m_defaultsPanel.removeAll();
for (int i = 0; i < defaults.length; i++) {
final MissingValueHandling2Panel p = new MissingValueHandling2Panel(defaults[i], (DataColumnSpec) null);
m_defaultsPanel.add(p);
}
m_individualsPanel.removeAll();
Set<String> invalidColumns = new LinkedHashSet<String>();
for (int i = 0; i < individuals.length; i++) {
String[] names = individuals[i].getNames();
ArrayList<DataColumnSpec> colSpecs = new ArrayList<DataColumnSpec>();
for (int j = 0; j < names.length; j++) {
final DataColumnSpec cspec = specs[0].getColumnSpec(names[j]);
if (cspec == null) {
LOGGER.debug("No such column in spec: " + names[j]);
DataColumnSpec createUnkownSpec = createUnkownSpec(names[j], individuals[i]);
colSpecs.add(createUnkownSpec);
invalidColumns.add(names[j]);
} else {
colSpecs.add(cspec);
}
}
if (!colSpecs.isEmpty()) {
names = new String[colSpecs.size()];
for (int j = 0; j < names.length; j++) {
names[j] = colSpecs.get(j).getName();
}
individuals[i].setNames(names);
markIncompatibleTypedColumns(individuals[i].getType(), colSpecs);
final MissingValueHandling2Panel p = new MissingValueHandling2Panel(individuals[i], colSpecs.toArray(new DataColumnSpec[0]));
p.registerMouseListener(new MouseAdapter() {
/**
* {@inheritDoc}
*/
@Override
public void mouseClicked(final MouseEvent me) {
selectColumns(p.getSettings());
}
});
addToIndividualPanel(p);
}
}
m_searchableListModifier.addInvalidColumns(invalidColumns.toArray(new String[invalidColumns.size()]));
m_individualsPanel.setPreferredSize(m_defaultsPanel.getPreferredSize());
checkButtonStatus();
}
use of java.awt.event.MouseAdapter in project knime-core by knime.
the class MissingValueHandling2NodeDialogPane method onAdd.
private void onAdd(final List<DataColumnSpec> specs) {
if (specs == null || specs.isEmpty()) {
return;
}
final MissingValueHandling2Panel p = new MissingValueHandling2Panel(specs);
p.registerMouseListener(new MouseAdapter() {
/**
* {@inheritDoc}
*/
@Override
public void mouseClicked(final MouseEvent me) {
selectColumns(p.getSettings());
}
});
addToIndividualPanel(p);
checkButtonStatus();
}
use of java.awt.event.MouseAdapter in project knime-core by knime.
the class ColumnSelectionSearchableListPanel method addKeyMouseSelectionListerersToColumnList.
private void addKeyMouseSelectionListerersToColumnList() {
m_columnList.addKeyListener(new KeyAdapter() {
/**
* {@inheritDoc}
*/
@Override
public void keyTyped(final KeyEvent e) {
if (KeyEvent.VK_ENTER == e.getKeyChar()) {
fireConfigurationRequested(Type.CREATION);
} else if (KeyEvent.VK_DELETE == e.getKeyChar()) {
fireConfigurationRequested(Type.DELETION);
}
}
});
m_columnList.addMouseListener(new MouseAdapter() {
/**
* {@inheritDoc}
*/
@Override
public void mouseClicked(final MouseEvent e) {
if (e.getClickCount() == 2) {
fireConfigurationRequested(Type.CREATION);
}
}
});
m_columnList.addListSelectionListener(new ListSelectionListener() {
@Override
public void valueChanged(final ListSelectionEvent e) {
fireConfigurationRequested(Type.SELECTION);
}
});
}
use of java.awt.event.MouseAdapter in project knime-core by knime.
the class DataValidatorColPanel method createWestLayout.
/**
* @param tabPanel
* @param spec
* @param setting
* @param icon
* @param name
*/
private void createWestLayout(final JPanel tabPanel, final List<DataColumnSpec> spec) {
m_defaultListModel = new DefaultListModel<>();
for (DataColumnSpec s : spec) {
m_defaultListModel.addElement(s);
}
m_defaultListModel.addElement(DROP_COLUMN_PLACEHOLDER);
final JList<Object> jList = new JList<>(m_defaultListModel);
jList.setCellRenderer(new DataColumnSpecListCellRenderer() {
@Override
public Component getListCellRendererComponent(@SuppressWarnings("rawtypes") final JList list, final Object value, final int index, final boolean isSelected, final boolean cellHasFocus) {
super.getListCellRendererComponent(list, value, index, isSelected, cellHasFocus);
if (value != DROP_COLUMN_PLACEHOLDER) {
return this;
}
setIcon(DnDConfigurationPanel.ADD_ICON_16);
setText("<drop columns>");
setForeground(isSelected ? Color.white : Color.gray);
return this;
}
});
jList.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
jList.addMouseListener(new MouseAdapter() {
/**
* {@inheritDoc}
*/
@Override
public void mouseClicked(final MouseEvent e) {
if (e.getClickCount() == 2) {
Object selectedItem = jList.getSelectedValue();
if (selectedItem != null && selectedItem instanceof DataColumnSpec) {
DataColumnSpec selectedValue = (DataColumnSpec) selectedItem;
m_defaultListModel.removeElement(selectedValue);
String colName = selectedValue.getName();
List<String> asList = new ArrayList<>(Arrays.asList(m_setting.getNames()));
asList.remove(colName);
if (asList.isEmpty()) {
firePropertyChange(REMOVE_ACTION, null, null);
} else {
firePropertyChange(REMOVED_COLUMNS, null, new DataColumnSpec[] { selectedValue });
DataColumnSpec[] currSpecs = new DataColumnSpec[m_defaultListModel.size() - 1];
// let the last item go
for (int i = 0; i < m_defaultListModel.size() - 1; i++) {
currSpecs[i] = (DataColumnSpec) m_defaultListModel.get(i);
}
if (isInvalid(selectedValue)) {
DataValidatorColPanel.this.removeAll();
createContent(Arrays.asList(currSpecs));
} else {
updateUiElements(Arrays.asList(currSpecs));
DataValidatorColPanel.this.repaint();
}
}
m_setting.setNames(asList.toArray(new String[asList.size()]));
}
}
}
});
JScrollPane columns = new JScrollPane(jList);
GridBagConstraints c = new GridBagConstraints();
c.fill = GridBagConstraints.BOTH;
c.anchor = GridBagConstraints.WEST;
c.insets = new Insets(10, 10, 10, 10);
c.gridx = 0;
c.gridy = 1;
c.gridheight = 2;
c.weightx = 1;
tabPanel.add(columns, c);
}
use of java.awt.event.MouseAdapter in project knime-core by knime.
the class DataValidatorNodeDialogPane method onAdd.
private void onAdd(final List<DataColumnSpec> specs) {
if (specs == null || specs.isEmpty()) {
return;
}
final DataValidatorColPanel p = new DataValidatorColPanel(this, specs);
p.registerMouseListener(new MouseAdapter() {
/**
* {@inheritDoc}
*/
@Override
public void mouseClicked(final MouseEvent me) {
selectColumns(p.getSettings());
}
});
addToIndividualPanel(p);
moveToSelection();
}
Aggregations