Search in sources :

Example 1 with StringHistory

use of org.knime.core.node.util.StringHistory in project knime-core by knime.

the class ListFilesSettings method saveSettingsTo.

/**
 * Save settings in model & dialog.
 *
 * @param settings To save to.
 */
protected void saveSettingsTo(final NodeSettingsWO settings) {
    settings.addString(EXTENSIONS_SETTINGS, m_extensionsString);
    settings.addString(LOCATION_SETTINGS, m_locationString);
    settings.addBoolean(RECURSIVE_SETTINGS, m_recursive);
    settings.addString(FILTER_SETTINGS, m_filter.name());
    settings.addBoolean(CASE_SENSITIVE_STRING, m_caseSensitive);
    if (m_locationString != null) {
        StringHistory h = StringHistory.getInstance(LIST_FILES_HISTORY_ID);
        h.add(m_locationString);
    }
    if (m_extensionsString != null) {
        StringHistory h = StringHistory.getInstance(LIST_FILES_EXT_HISTORY_ID);
        h.add(m_extensionsString);
    }
}
Also used : StringHistory(org.knime.core.node.util.StringHistory)

Example 2 with StringHistory

use of org.knime.core.node.util.StringHistory in project knime-core by knime.

the class SQLTypeCellEditor method saveSettings.

/**
 * Save all SQL data types to StringHistory
 */
void saveSettings() {
    String historyId = createHistoryId(m_dbIdentifier);
    StringHistory sh = StringHistory.getInstance(historyId, STRING_HISTORY_MAX_ENTRY);
    for (Entry<String, SQLTypeComboBoxModel> entry : m_models.entrySet()) {
        String history = entry.getKey() + STRING_HISTORY_DELIMITER;
        final SQLTypeComboBoxModel model = entry.getValue();
        for (int i = 0; i < model.getSize(); i++) {
            sh.add(history + model.getElementAt(i));
        }
    }
}
Also used : StringHistory(org.knime.core.node.util.StringHistory)

Example 3 with StringHistory

use of org.knime.core.node.util.StringHistory in project knime-core by knime.

the class ListFilesSettings method saveSettingsTo.

/**
 * Save settings in model & dialog.
 *
 * @param settings To save to.
 */
protected void saveSettingsTo(final NodeSettingsWO settings) {
    settings.addString(EXTENSIONS_SETTINGS, m_extensionsString);
    settings.addString(LOCATION_SETTINGS, m_locationString);
    settings.addBoolean(RECURSIVE_SETTINGS, m_recursive);
    settings.addString(FILTER_SETTINGS, m_filter.name());
    settings.addBoolean(CASE_SENSITIVE_STRING, m_caseSensitive);
    if (m_locationString != null) {
        StringHistory h = StringHistory.getInstance(LIST_FILES_HISTORY_ID);
        h.add(m_locationString);
    }
    if (m_extensionsString != null) {
        StringHistory h = StringHistory.getInstance(LIST_FILES_EXT_HISTORY_ID);
        h.add(m_extensionsString);
    }
}
Also used : StringHistory(org.knime.core.node.util.StringHistory)

Example 4 with StringHistory

use of org.knime.core.node.util.StringHistory in project knime-core by knime.

the class JavaScriptingJarListPanel method onJarAdd.

private void onJarAdd() {
    DefaultListModel model = (DefaultListModel) m_addJarList.getModel();
    Set<Object> hash = new HashSet<Object>();
    for (Enumeration<?> e = model.elements(); e.hasMoreElements(); ) {
        hash.add(e.nextElement());
    }
    StringHistory history = StringHistory.getInstance("java_snippet_jar_dirs");
    if (m_jarFileChooser == null) {
        File dir = null;
        for (String h : history.getHistory()) {
            File temp = new File(h);
            if (temp.isDirectory()) {
                dir = temp;
                break;
            }
        }
        m_jarFileChooser = new JFileChooser(dir);
        m_jarFileChooser.setFileFilter(new SimpleFileFilter(".zip", ".jar"));
        m_jarFileChooser.setMultiSelectionEnabled(true);
    }
    int result = m_jarFileChooser.showDialog(m_addJarList, "Select");
    if (result == JFileChooser.APPROVE_OPTION) {
        for (File f : m_jarFileChooser.getSelectedFiles()) {
            String s = f.getAbsolutePath();
            if (hash.add(s)) {
                model.addElement(s);
            }
        }
        history.add(m_jarFileChooser.getCurrentDirectory().getAbsolutePath());
    }
}
Also used : JFileChooser(javax.swing.JFileChooser) DefaultListModel(javax.swing.DefaultListModel) StringHistory(org.knime.core.node.util.StringHistory) SimpleFileFilter(org.knime.core.util.SimpleFileFilter) File(java.io.File) HashSet(java.util.HashSet)

Example 5 with StringHistory

use of org.knime.core.node.util.StringHistory in project knime-core by knime.

the class JarListPanel method onJarFileAdd.

private void onJarFileAdd() {
    final Set<String> hash = new HashSet<>(Collections.list(m_listModel.elements()));
    final StringHistory history = StringHistory.getInstance("java_snippet_jar_dirs");
    if (m_jarFileChooser == null) {
        File dir = null;
        for (final String h : history.getHistory()) {
            final File temp = new File(h);
            if (temp.isDirectory()) {
                dir = temp;
                break;
            }
        }
        m_jarFileChooser = new JFileChooser(dir);
        m_jarFileChooser.setFileFilter(new SimpleFileFilter(".zip", ".jar"));
        m_jarFileChooser.setMultiSelectionEnabled(true);
    }
    final int result = m_jarFileChooser.showDialog(m_addJarList, "Select");
    if (result == JFileChooser.APPROVE_OPTION) {
        for (final File f : m_jarFileChooser.getSelectedFiles()) {
            final String s = f.getAbsolutePath();
            if (hash.add(s)) {
                m_listModel.addElement(s);
            }
        }
        history.add(m_jarFileChooser.getCurrentDirectory().getAbsolutePath());
    }
}
Also used : JFileChooser(javax.swing.JFileChooser) StringHistory(org.knime.core.node.util.StringHistory) SimpleFileFilter(org.knime.core.util.SimpleFileFilter) File(java.io.File) HashSet(java.util.HashSet)

Aggregations

StringHistory (org.knime.core.node.util.StringHistory)10 File (java.io.File)3 HashSet (java.util.HashSet)2 JFileChooser (javax.swing.JFileChooser)2 SimpleFileFilter (org.knime.core.util.SimpleFileFilter)2 Dimension (java.awt.Dimension)1 URISyntaxException (java.net.URISyntaxException)1 URL (java.net.URL)1 LinkedHashSet (java.util.LinkedHashSet)1 Vector (java.util.Vector)1 DefaultComboBoxModel (javax.swing.DefaultComboBoxModel)1 DefaultListModel (javax.swing.DefaultListModel)1 InvalidSettingsException (org.knime.core.node.InvalidSettingsException)1 SettingsStatus (org.knime.core.util.tokenizer.SettingsStatus)1