use of org.knime.core.node.util.FilesHistoryPanel in project knime-core by knime.
the class FixedWidthFRNodeDialog method createFileNamePanel.
private JPanel createFileNamePanel() {
JPanel panel = new JPanel();
panel.setLayout(new BoxLayout(panel, BoxLayout.Y_AXIS));
panel.setBorder(BorderFactory.createTitledBorder(BorderFactory.createEtchedBorder(), "Enter ASCII data file location: (press 'Enter' to update preview)"));
FlowVariableModel flowVarBrowseModel = createFlowVariableModel(FixedWidthFRSettings.CFGKEY_URL, Type.STRING);
m_url = new FilesHistoryPanel(flowVarBrowseModel, FILEREADER_HISTORY_ID, LocationValidation.FileInput, new String[] { ".txt", ".csv" });
m_url.addChangeListener(new ChangeListener() {
@Override
public void stateChanged(final ChangeEvent e) {
if (!m_loadSettings) {
try {
URL newUrl = FileUtil.toURL(m_url.getSelectedFile());
m_nodeSettings.setFileLocation(newUrl);
} catch (IOException | InvalidPathException ioe) {
m_nodeSettings.setFileLocation(null);
}
if (!m_preserveSettings.isSelected() && !m_url.isVariableReplacementEnabled()) {
m_nodeSettings.reset();
}
m_hasColHeaders.setSelected(m_nodeSettings.getHasColHeaders());
m_hasRowHeaders.setSelected(m_nodeSettings.getHasRowHeader());
updateColPropTable();
updatePreview();
updateEnables();
}
}
});
// the checkbox for preserving the current settings on file change
Box preserveBox = Box.createHorizontalBox();
m_preserveSettings = new JCheckBox("Preserve user settings for new location");
m_preserveSettings.setToolTipText("if not checked, the settings you" + " have set are reset, if a new location is entered");
m_preserveSettings.setSelected(false);
m_preserveSettings.setEnabled(true);
preserveBox.add(Box.createHorizontalGlue());
preserveBox.add(m_preserveSettings);
preserveBox.add(Box.createHorizontalGlue());
panel.add(m_url);
panel.add(preserveBox);
panel.setMaximumSize(new Dimension(PANEL_WIDTH, 70));
panel.setMinimumSize(new Dimension(PANEL_WIDTH, 70));
return panel;
}
use of org.knime.core.node.util.FilesHistoryPanel in project knime-core by knime.
the class ListFilesNodeDialog method createLocationPanel.
/**
* This Methods build the Location Panel.
*
* @return Location Panel
*/
private JPanel createLocationPanel() {
JPanel panel = new JPanel();
panel.setLayout(new GridBagLayout());
panel.setBorder(BorderFactory.createTitledBorder(BorderFactory.createEtchedBorder(), "Location:"));
// Creating the browse button to get its preferred height
FlowVariableModel fvm = createFlowVariableModel("file_location", FlowVariable.Type.STRING);
// Directory (local location)
m_localdirectory = new FilesHistoryPanel(fvm, "filereader_history", LocationValidation.DirectoryInput, new String[] {});
m_localdirectory.setSelectMode(JFileChooser.DIRECTORIES_ONLY);
m_localdirectory.setAllowRemoteURLs(false);
m_recursive = new JCheckBox();
m_recursive.setText("include sub folders");
GridBagConstraints c = new GridBagConstraints();
c.fill = GridBagConstraints.HORIZONTAL;
c.gridwidth = 1;
c.gridx = 0;
c.gridy = 0;
c.weightx = 1;
c.weighty = 0;
panel.add(m_localdirectory, c);
c.gridy++;
panel.add(m_recursive, c);
return panel;
}
use of org.knime.core.node.util.FilesHistoryPanel in project knime-core by knime.
the class FileReaderNodeDialog method createFileNamePanel.
private JPanel createFileNamePanel() {
JPanel panel = new JPanel();
panel.setLayout(new BoxLayout(panel, BoxLayout.Y_AXIS));
panel.setBorder(BorderFactory.createTitledBorder(BorderFactory.createEtchedBorder(), "Enter ASCII data file location: (press 'Enter' to update " + "preview)"));
Box fileBox = Box.createHorizontalBox();
JButton rescan = new JButton("Rescan");
m_filePanel = new FilesHistoryPanel(createFlowVariableModel(FileReaderSettings.CFGKEY_DATAURL, FlowVariable.Type.STRING), FileReaderNodeModel.FILEREADER_HISTORY_ID, LocationValidation.FileInput, "");
m_filePanel.setToolTipText("Enter an URL of an ASCII datafile, select from recent files, or browse");
fileBox.add(Box.createHorizontalGlue());
fileBox.add(m_filePanel);
fileBox.add(Box.createVerticalStrut(50));
fileBox.add(Box.createHorizontalGlue());
// the checkbox for preserving the current settings on file change
Box preserveBox = Box.createHorizontalBox();
m_preserveSettings = new JCheckBox("Preserve user settings for new location");
m_preserveSettings.setToolTipText("if not checked, the settings you" + " have set are reset, if a new location is entered");
m_preserveSettings.setSelected(false);
m_preserveSettings.setEnabled(true);
preserveBox.add(Box.createHorizontalGlue());
preserveBox.add(m_preserveSettings);
preserveBox.add(rescan);
preserveBox.add(Box.createHorizontalGlue());
panel.add(fileBox);
panel.add(preserveBox);
panel.setMaximumSize(new Dimension(PANEL_WIDTH, 70));
panel.setMinimumSize(new Dimension(PANEL_WIDTH, 70));
/* install action listeners */
// set stuff to update preview when file location changes
m_filePanel.addChangeListener(new ChangeListener() {
@Override
public void stateChanged(final ChangeEvent e) {
setPreviewTable(null);
fileLocationChanged();
}
});
rescan.addActionListener(new ActionListener() {
@Override
public void actionPerformed(final ActionEvent e) {
if (!m_preserveSettings.isSelected()) {
resetSettings();
}
analyzeDataFileAndUpdatePreview(true);
}
});
return panel;
}
use of org.knime.core.node.util.FilesHistoryPanel in project knime-core by knime.
the class SleepNodeDialog method waitForFile.
private void waitForFile() {
m_events = new DialogComponentButtonGroup(new SettingsModelString(SleepNodeModel.CFGKEY_FILESTATUS, "Modification"), false, null, "Creation", "Modification", "Deletion");
FlowVariableModel fvm = createFlowVariableModel(SleepNodeModel.CFGKEY_FILEPATH, Type.STRING);
m_fileChooser = new FilesHistoryPanel(fvm, SleepNodeModel.CFGKEY_FILEPATH, LocationValidation.None);
m_fileRB = new JRadioButton("Wait for file.. ");
m_fileRB.addItemListener(new ItemListener() {
@Override
public void itemStateChanged(final ItemEvent e) {
if (m_fileRB.isSelected()) {
m_selection = 2;
}
m_fileChooser.setEnabled(m_fileRB.isSelected());
m_events.getModel().setEnabled(m_fileRB.isSelected());
}
});
}
Aggregations