Search in sources :

Example 1 with FilesHistoryPanel

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;
}
Also used : FlowVariableModel(org.knime.core.node.FlowVariableModel) JCheckBox(javax.swing.JCheckBox) JPanel(javax.swing.JPanel) ChangeEvent(javax.swing.event.ChangeEvent) PropertyChangeEvent(java.beans.PropertyChangeEvent) BoxLayout(javax.swing.BoxLayout) FilesHistoryPanel(org.knime.core.node.util.FilesHistoryPanel) ChangeListener(javax.swing.event.ChangeListener) PropertyChangeListener(java.beans.PropertyChangeListener) Box(javax.swing.Box) JCheckBox(javax.swing.JCheckBox) Dimension(java.awt.Dimension) URL(java.net.URL)

Example 2 with FilesHistoryPanel

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;
}
Also used : FlowVariableModel(org.knime.core.node.FlowVariableModel) JCheckBox(javax.swing.JCheckBox) JPanel(javax.swing.JPanel) GridBagConstraints(java.awt.GridBagConstraints) GridBagLayout(java.awt.GridBagLayout) FilesHistoryPanel(org.knime.core.node.util.FilesHistoryPanel)

Example 3 with FilesHistoryPanel

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;
}
Also used : JCheckBox(javax.swing.JCheckBox) JPanel(javax.swing.JPanel) ChangeEvent(javax.swing.event.ChangeEvent) PropertyChangeEvent(java.beans.PropertyChangeEvent) ActionListener(java.awt.event.ActionListener) ActionEvent(java.awt.event.ActionEvent) BoxLayout(javax.swing.BoxLayout) FilesHistoryPanel(org.knime.core.node.util.FilesHistoryPanel) JButton(javax.swing.JButton) JComboBox(javax.swing.JComboBox) Box(javax.swing.Box) JCheckBox(javax.swing.JCheckBox) ChangeListener(javax.swing.event.ChangeListener) PropertyChangeListener(java.beans.PropertyChangeListener) Dimension(java.awt.Dimension)

Example 4 with FilesHistoryPanel

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());
        }
    });
}
Also used : FlowVariableModel(org.knime.core.node.FlowVariableModel) DialogComponentButtonGroup(org.knime.core.node.defaultnodesettings.DialogComponentButtonGroup) ItemEvent(java.awt.event.ItemEvent) JRadioButton(javax.swing.JRadioButton) FilesHistoryPanel(org.knime.core.node.util.FilesHistoryPanel) ItemListener(java.awt.event.ItemListener) SettingsModelString(org.knime.core.node.defaultnodesettings.SettingsModelString)

Aggregations

FilesHistoryPanel (org.knime.core.node.util.FilesHistoryPanel)4 JCheckBox (javax.swing.JCheckBox)3 JPanel (javax.swing.JPanel)3 FlowVariableModel (org.knime.core.node.FlowVariableModel)3 Dimension (java.awt.Dimension)2 PropertyChangeEvent (java.beans.PropertyChangeEvent)2 PropertyChangeListener (java.beans.PropertyChangeListener)2 Box (javax.swing.Box)2 BoxLayout (javax.swing.BoxLayout)2 ChangeEvent (javax.swing.event.ChangeEvent)2 ChangeListener (javax.swing.event.ChangeListener)2 GridBagConstraints (java.awt.GridBagConstraints)1 GridBagLayout (java.awt.GridBagLayout)1 ActionEvent (java.awt.event.ActionEvent)1 ActionListener (java.awt.event.ActionListener)1 ItemEvent (java.awt.event.ItemEvent)1 ItemListener (java.awt.event.ItemListener)1 URL (java.net.URL)1 JButton (javax.swing.JButton)1 JComboBox (javax.swing.JComboBox)1