Search in sources :

Example 1 with TableView

use of org.knime.core.node.tableview.TableView in project knime-core by knime.

the class VariableFileReaderNodeDialog method createPreviewPanel.

private JPanel createPreviewPanel() {
    JPanel panel = new JPanel();
    panel.setLayout(new BoxLayout(panel, BoxLayout.Y_AXIS));
    panel.setBorder(BorderFactory.createTitledBorder(BorderFactory.createEtchedBorder(), "Preview"));
    Box hintBox = Box.createHorizontalBox();
    Box tableBox = Box.createHorizontalBox();
    hintBox.add(Box.createGlue());
    hintBox.add(new JLabel("Click column header to change " + "column properties (* = name/type user settings)"));
    hintBox.add(Box.createGlue());
    PreviewTableContentView ptcv = new PreviewTableContentView();
    m_previewTableView = new TableView(ptcv);
    tableBox.add(m_previewTableView);
    // add the analyzer warning at the bottom
    m_analyzeWarn = new JLabel("");
    m_analyzeWarn.setForeground(Color.red);
    JPanel analBox = new JPanel();
    analBox.setLayout(new BoxLayout(analBox, BoxLayout.X_AXIS));
    analBox.add(Box.createHorizontalGlue());
    analBox.add(m_analyzeWarn);
    // reserve a certain height for the (in the beginning invisible) label
    analBox.add(Box.createVerticalStrut(25));
    analBox.add(Box.createHorizontalGlue());
    panel.add(Box.createGlue());
    panel.add(hintBox);
    panel.add(Box.createVerticalStrut(10));
    panel.add(tableBox);
    panel.add(analBox);
    panel.add(Box.createGlue());
    // this is the callback for the preview table header click
    ptcv.addPropertyChangeListener(PreviewTableContentView.PROPERTY_SPEC_CHANGED, new PropertyChangeListener() {

        @Override
        public void propertyChange(final PropertyChangeEvent evt) {
            // thats the col idx the mouse was clicked on
            Integer colNr = (Integer) evt.getNewValue();
            setNewUserSettingsForColumn(colNr.intValue());
        }
    });
    return panel;
}
Also used : JPanel(javax.swing.JPanel) PropertyChangeEvent(java.beans.PropertyChangeEvent) PropertyChangeListener(java.beans.PropertyChangeListener) BoxLayout(javax.swing.BoxLayout) JLabel(javax.swing.JLabel) JComboBox(javax.swing.JComboBox) Box(javax.swing.Box) JCheckBox(javax.swing.JCheckBox) TableView(org.knime.core.node.tableview.TableView)

Example 2 with TableView

use of org.knime.core.node.tableview.TableView in project knime-core by knime.

the class FixedWidthFRNodeDialog method createPreviewPanel.

/**
 * @return jpanel with all the preview components
 */
private JPanel createPreviewPanel() {
    JPanel panel = new JPanel();
    panel.setLayout(new BoxLayout(panel, BoxLayout.Y_AXIS));
    panel.setBorder(BorderFactory.createTitledBorder(BorderFactory.createEtchedBorder(), "Preview"));
    Box tableBox = Box.createHorizontalBox();
    PreviewTableContentView ptcv = new PreviewTableContentView();
    m_previewTableView = new TableView(ptcv);
    tableBox.add(m_previewTableView);
    panel.add(Box.createGlue());
    panel.add(tableBox);
    ptcv.addPropertyChangeListener(PreviewTableContentView.PROPERTY_SPEC_CHANGED, new PropertyChangeListener() {

        @Override
        public void propertyChange(final PropertyChangeEvent evt) {
            m_colIdx = (int) evt.getNewValue();
            m_colIdx = m_nodeSettings.getColIdxIncluded(m_colIdx);
            if (m_colIdx < m_nodeSettings.getNumberOfColumns() - 1) {
                // don't open edit dialog if clicked column equals
                // remaining characters column
                onEdit(m_colIdx);
            }
        }
    });
    return panel;
}
Also used : JPanel(javax.swing.JPanel) PropertyChangeEvent(java.beans.PropertyChangeEvent) PropertyChangeListener(java.beans.PropertyChangeListener) BoxLayout(javax.swing.BoxLayout) Box(javax.swing.Box) JCheckBox(javax.swing.JCheckBox) PreviewTableContentView(org.knime.base.node.io.filereader.PreviewTableContentView) TableView(org.knime.core.node.tableview.TableView)

Example 3 with TableView

use of org.knime.core.node.tableview.TableView in project knime-core by knime.

the class NodeOutputView method createPartControl.

/**
 * {@inheritDoc}
 */
@Override
public void createPartControl(final Composite parent) {
    // Toolbar
    IToolBarManager toolbarMGR = getViewSite().getActionBars().getToolBarManager();
    // create button for stick with branch.
    final RetargetAction lockAction = new RetargetAction("StayOnBranch", "Pin view to new node added to branch", IAction.AS_CHECK_BOX);
    lockAction.setImageDescriptor(ImageDescriptor.createFromFile(this.getClass(), "icons/lock.png"));
    lockAction.setChecked(m_branchLocked);
    lockAction.setEnabled(m_pinned);
    lockAction.addPropertyChangeListener(new IPropertyChangeListener() {

        @Override
        public void propertyChange(final PropertyChangeEvent event) {
            if (lockAction.isChecked()) {
                m_branchLocked = true;
                m_selectionWhenLocked = m_lastSelection;
            } else {
                m_branchLocked = false;
                selectionChanged(null, m_lastSelectionWhilePinned);
            }
        }
    });
    toolbarMGR.add(lockAction);
    // create button which allows to "pin" selection:
    m_pinButton = new RetargetAction("PinView", "Pin view to selected node", IAction.AS_CHECK_BOX);
    m_pinButton.setImageDescriptor(ImageDescriptor.createFromFile(this.getClass(), "icons/pin.png"));
    m_pinButton.setChecked(m_pinned);
    m_pinButton.setEnabled(true);
    m_pinButton.addPropertyChangeListener(new IPropertyChangeListener() {

        @Override
        public void propertyChange(final PropertyChangeEvent event) {
            if (m_pinButton.isChecked()) {
                m_pinned = true;
                m_lastSelectionWhilePinned = m_lastSelection;
                lockAction.setEnabled(true);
            } else {
                m_pinned = false;
                selectionChanged(null, m_lastSelectionWhilePinned);
                lockAction.setEnabled(false);
            }
        }
    });
    toolbarMGR.add(m_pinButton);
    toolbarMGR.add(new Separator());
    // configure drop down menu
    IMenuManager dropDownMenu = getViewSite().getActionBars().getMenuManager();
    // drop down menu entry for outport table:
    final RetargetAction menuentrytable = new RetargetAction("OutputTable", "Show Output Table", IAction.AS_RADIO_BUTTON);
    menuentrytable.setChecked(DISPLAYOPTIONS.TABLE.equals(m_choice));
    menuentrytable.setEnabled(true);
    menuentrytable.addPropertyChangeListener(new IPropertyChangeListener() {

        @Override
        public void propertyChange(final PropertyChangeEvent event) {
            if (menuentrytable.isChecked()) {
                m_choice = DISPLAYOPTIONS.TABLE;
                updateNodeContainerInfo(m_lastNode);
            }
        }
    });
    dropDownMenu.add(menuentrytable);
    // drop down menu entry for node variables:
    final RetargetAction dropdownmenuvars = new RetargetAction("NodeVariables", "Show Variables", IAction.AS_RADIO_BUTTON);
    dropdownmenuvars.setChecked(DISPLAYOPTIONS.VARS.equals(m_choice));
    dropdownmenuvars.setEnabled(true);
    dropdownmenuvars.addPropertyChangeListener(new IPropertyChangeListener() {

        @Override
        public void propertyChange(final PropertyChangeEvent event) {
            if (dropdownmenuvars.isChecked()) {
                m_choice = DISPLAYOPTIONS.VARS;
                updateNodeContainerInfo(m_lastNode);
            }
        }
    });
    dropDownMenu.add(dropdownmenuvars);
    // drop down menu entry for configuration/settings:
    final RetargetAction menuentrysettings = new RetargetAction("NodeConf", "Show Configuration", IAction.AS_RADIO_BUTTON);
    menuentrysettings.setChecked(DISPLAYOPTIONS.SETTINGS.equals(m_choice));
    menuentrysettings.setEnabled(true);
    menuentrysettings.addPropertyChangeListener(new IPropertyChangeListener() {

        @Override
        public void propertyChange(final PropertyChangeEvent event) {
            if (menuentrysettings.isChecked()) {
                m_choice = DISPLAYOPTIONS.SETTINGS;
                updateNodeContainerInfo(m_lastNode);
            }
        }
    });
    dropDownMenu.add(menuentrysettings);
    // drop down menu entry for configuration/settings:
    final RetargetAction menuentryallsettings = new RetargetAction("NodeConfAll", "Show Entire Configuration", IAction.AS_RADIO_BUTTON);
    menuentryallsettings.setChecked(DISPLAYOPTIONS.ALLSETTINGS.equals(m_choice));
    menuentryallsettings.setEnabled(true);
    menuentryallsettings.addPropertyChangeListener(new IPropertyChangeListener() {

        @Override
        public void propertyChange(final PropertyChangeEvent event) {
            if (menuentryallsettings.isChecked()) {
                m_choice = DISPLAYOPTIONS.ALLSETTINGS;
                updateNodeContainerInfo(m_lastNode);
            }
        }
    });
    dropDownMenu.add(menuentryallsettings);
    // drop down menu entry for node graph annotations
    final RetargetAction menuentrygraphannotations = new RetargetAction("NodeGraphAnno", "Show Graph Annotations", IAction.AS_RADIO_BUTTON);
    menuentrygraphannotations.setChecked(DISPLAYOPTIONS.GRAPHANNOTATIONS.equals(m_choice));
    menuentrygraphannotations.setEnabled(true);
    menuentrygraphannotations.addPropertyChangeListener(new IPropertyChangeListener() {

        @Override
        public void propertyChange(final PropertyChangeEvent event) {
            if (menuentrygraphannotations.isChecked()) {
                m_choice = DISPLAYOPTIONS.GRAPHANNOTATIONS;
                updateNodeContainerInfo(m_lastNode);
            }
        }
    });
    dropDownMenu.add(menuentrygraphannotations);
    // Content
    GridLayoutFactory.swtDefaults().numColumns(2).applyTo(parent);
    // Node Title:
    Label titlelabel = new Label(parent, SWT.NONE);
    titlelabel.setLayoutData(new GridData(SWT.LEFT, SWT.CENTER, false, false));
    titlelabel.setText("Node: ");
    m_title = new Text(parent, SWT.BORDER);
    m_title.setEditable(false);
    m_title.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, false, false));
    m_title.setText("n/a.");
    // Panel for currently displayed information (some information
    // providers will add more elements to this):
    Composite infoPanel = new Composite(parent, SWT.NONE);
    GridData infoGrid = new GridData(SWT.FILL, SWT.TOP, true, false);
    infoGrid.horizontalSpan = 2;
    infoPanel.setLayoutData(infoGrid);
    GridLayoutFactory.swtDefaults().numColumns(3).applyTo(infoPanel);
    m_info = new Label(infoPanel, SWT.NONE);
    m_info.setLayoutData(new GridData(SWT.LEFT, SWT.CENTER, false, false));
    m_info.setText("n/a.                        ");
    m_portIndex = new ComboViewer(infoPanel);
    m_portIndex.add(new String[] { "port 0", "port 1", "port 2" });
    m_portIndex.getCombo().setEnabled(false);
    m_portIndex.getCombo().setSelection(new Point(m_portIndexInit, m_portIndexInit));
    m_portIndex.addSelectionChangedListener(new ISelectionChangedListener() {

        @Override
        public void selectionChanged(final SelectionChangedEvent event) {
            ISelection sel = event.getSelection();
            try {
                int newIndex = Integer.parseInt(sel.toString().substring(5).replace(']', ' ').trim());
                NodeContainer node;
                if (m_workflow.containsNodeContainer(m_lastNode)) {
                    node = m_workflow.getNodeContainer(m_lastNode);
                    updateDataTable(node, newIndex);
                }
            } catch (NumberFormatException nfe) {
            // ignore.
            }
        }
    });
    // Table:
    // stack panel switches between KNIME data table view and SWT table for other info
    m_stackPanel = new Composite(parent, SWT.NONE);
    m_stackPanel.setLayout(new StackLayout());
    GridData tableGrid = new GridData(SWT.FILL, SWT.FILL, true, true);
    m_stackPanel.setLayoutData(tableGrid);
    // DataTable view wrapped in AWT-SWT bridge
    m_tableView = new TableView();
    m_tableViewPanel = new Panel2CompositeWrapper(m_stackPanel, m_tableView, SWT.NONE);
    m_errorLabel = new Label(m_stackPanel, SWT.NONE);
    // SWT Table for the other info
    m_table = new Table(m_stackPanel, SWT.MULTI | SWT.BORDER);
    m_table.setLinesVisible(true);
    m_table.setHeaderVisible(true);
    tableGrid.horizontalSpan = 2;
    m_table.setLayoutData(tableGrid);
    String[] titles = { "Name", "Value" };
    for (int i = 0; i < titles.length; i++) {
        TableColumn column = new TableColumn(m_table, SWT.NONE);
        column.setText(titles[i]);
    }
    for (int i = 0; i < titles.length; i++) {
        m_table.getColumn(i).pack();
    }
    m_lastNode = null;
    getViewSite().getPage().addSelectionListener(this);
    if (m_choice.equals(DISPLAYOPTIONS.TABLE)) {
        ((StackLayout) m_stackPanel.getLayout()).topControl = m_tableViewPanel;
        m_stackPanel.layout();
    } else {
        ((StackLayout) m_stackPanel.getLayout()).topControl = m_table;
        m_stackPanel.layout();
    }
    m_stackPanel.layout();
    selectionChanged(null, m_lastSelection);
}
Also used : Label(org.eclipse.swt.widgets.Label) SelectionChangedEvent(org.eclipse.jface.viewers.SelectionChangedEvent) NodeContainer(org.knime.core.node.workflow.NodeContainer) NativeNodeContainer(org.knime.core.node.workflow.NativeNodeContainer) SingleNodeContainer(org.knime.core.node.workflow.SingleNodeContainer) ISelection(org.eclipse.jface.viewers.ISelection) StackLayout(org.eclipse.swt.custom.StackLayout) TableView(org.knime.core.node.tableview.TableView) IPropertyChangeListener(org.eclipse.jface.util.IPropertyChangeListener) Panel2CompositeWrapper(org.knime.workbench.ui.wrapper.Panel2CompositeWrapper) PropertyChangeEvent(org.eclipse.jface.util.PropertyChangeEvent) BufferedDataTable(org.knime.core.node.BufferedDataTable) Table(org.eclipse.swt.widgets.Table) DataTable(org.knime.core.data.DataTable) Composite(org.eclipse.swt.widgets.Composite) RetargetAction(org.eclipse.ui.actions.RetargetAction) ISelectionChangedListener(org.eclipse.jface.viewers.ISelectionChangedListener) Text(org.eclipse.swt.widgets.Text) Point(org.eclipse.swt.graphics.Point) TableColumn(org.eclipse.swt.widgets.TableColumn) Point(org.eclipse.swt.graphics.Point) IToolBarManager(org.eclipse.jface.action.IToolBarManager) ComboViewer(org.eclipse.jface.viewers.ComboViewer) GridData(org.eclipse.swt.layout.GridData) IMenuManager(org.eclipse.jface.action.IMenuManager) Separator(org.eclipse.jface.action.Separator)

Example 4 with TableView

use of org.knime.core.node.tableview.TableView in project knime-core by knime.

the class FileReaderNodeDialog method createPreviewPanel.

private JPanel createPreviewPanel() {
    JPanel panel = new JPanel();
    panel.setLayout(new BoxLayout(panel, BoxLayout.Y_AXIS));
    panel.setBorder(BorderFactory.createTitledBorder(BorderFactory.createEtchedBorder(), "Preview"));
    Box hintBox = Box.createHorizontalBox();
    Box tableBox = Box.createHorizontalBox();
    hintBox.add(Box.createGlue());
    hintBox.add(new JLabel("Click column header to change " + "column properties (* = name/type user settings)"));
    hintBox.add(Box.createGlue());
    PreviewTableContentView ptcv = new PreviewTableContentView();
    m_previewTableView = new TableView(ptcv);
    tableBox.add(m_previewTableView);
    // add the analyzer warning at the bottom
    m_analyzeWarn = new JTextArea("");
    m_analyzeWarn.setForeground(Color.red);
    m_analyzeWarn.setWrapStyleWord(true);
    m_analyzeWarn.setLineWrap(true);
    m_analyzeWarn.setOpaque(false);
    m_analyzeWarn.setEditable(false);
    m_analyzeWarn.setFocusable(false);
    m_analyzeWarn.setFont(UIManager.getFont("Label.font"));
    JPanel analBox = new JPanel();
    analBox.setLayout(new BoxLayout(analBox, BoxLayout.X_AXIS));
    analBox.add(Box.createHorizontalGlue());
    analBox.add(m_analyzeWarn);
    // reserve a certain height for the (in the beginning invisible) label
    analBox.add(Box.createVerticalStrut(25));
    analBox.add(Box.createHorizontalGlue());
    panel.add(Box.createGlue());
    panel.add(hintBox);
    panel.add(Box.createVerticalStrut(10));
    panel.add(tableBox);
    panel.add(analBox);
    panel.add(Box.createGlue());
    // this is the callback for the preview table header click
    ptcv.addPropertyChangeListener(PreviewTableContentView.PROPERTY_SPEC_CHANGED, new PropertyChangeListener() {

        @Override
        public void propertyChange(final PropertyChangeEvent evt) {
            // thats the col idx the mouse was clicked on
            Integer colNr = (Integer) evt.getNewValue();
            setNewUserSettingsForColumn(colNr.intValue());
        }
    });
    return panel;
}
Also used : JPanel(javax.swing.JPanel) PropertyChangeEvent(java.beans.PropertyChangeEvent) JTextArea(javax.swing.JTextArea) PropertyChangeListener(java.beans.PropertyChangeListener) BoxLayout(javax.swing.BoxLayout) JLabel(javax.swing.JLabel) JComboBox(javax.swing.JComboBox) Box(javax.swing.Box) JCheckBox(javax.swing.JCheckBox) TableView(org.knime.core.node.tableview.TableView)

Aggregations

TableView (org.knime.core.node.tableview.TableView)4 PropertyChangeEvent (java.beans.PropertyChangeEvent)3 PropertyChangeListener (java.beans.PropertyChangeListener)3 Box (javax.swing.Box)3 BoxLayout (javax.swing.BoxLayout)3 JCheckBox (javax.swing.JCheckBox)3 JPanel (javax.swing.JPanel)3 JComboBox (javax.swing.JComboBox)2 JLabel (javax.swing.JLabel)2 JTextArea (javax.swing.JTextArea)1 IMenuManager (org.eclipse.jface.action.IMenuManager)1 IToolBarManager (org.eclipse.jface.action.IToolBarManager)1 Separator (org.eclipse.jface.action.Separator)1 IPropertyChangeListener (org.eclipse.jface.util.IPropertyChangeListener)1 PropertyChangeEvent (org.eclipse.jface.util.PropertyChangeEvent)1 ComboViewer (org.eclipse.jface.viewers.ComboViewer)1 ISelection (org.eclipse.jface.viewers.ISelection)1 ISelectionChangedListener (org.eclipse.jface.viewers.ISelectionChangedListener)1 SelectionChangedEvent (org.eclipse.jface.viewers.SelectionChangedEvent)1 StackLayout (org.eclipse.swt.custom.StackLayout)1