org.netbeans.swing.etable.ETable Java Examples

The following examples show how to use org.netbeans.swing.etable.ETable. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: NodePopupFactory.java    From netbeans with Apache License 2.0 6 votes vote down vote up
/**
 * Creates a popup menu with entries from the selected nodes
 * related to the given component (usually a ETable subclass). The popup
 * is created for the table element in given column and row (column
 *  and row are in the view's coordinates (not the model's)).
 */
public JPopupMenu createPopupMenu(int row, int column, Node[] selectedNodes,
        Component component) {
    
    Action[] actions = NodeOp.findActions (selectedNodes);
    JPopupMenu res = Utilities.actionsToPopup(actions, component);
    if (showQuickFilter) {
        if ((component instanceof ETable) && (column >= 0)) {
            ETable et = (ETable)component;
            if (row >= 0) {
                Object val = et.getValueAt(row, column);
                val = et.transformValue(val);
                String s = NbBundle.getMessage(NodePopupFactory.class, "LBL_QuickFilter");
                res.add(et.getQuickFilterPopup(column, val, s));
            } else if (et.getQuickFilterColumn() == column) {
                addNoFilterItem(et, res);
            }
        }
    }
    return res;
}
 
Example #2
Source File: BookmarksView.java    From netbeans with Apache License 2.0 6 votes vote down vote up
private void updateTableColumnSizes() {
    ETable table = tableView.getTable();
    Font font = tableView.getFont();
    FontMetrics fm = tableView.getFontMetrics(font);
    int maxCharWidth = fm.charWidth('A');
    int editingBorder = 4;
    TableColumnModel columnModel = table.getColumnModel();

    TableColumn nameColumn = columnModel.getColumn(0);
    nameColumn.setPreferredWidth(8 * maxCharWidth + editingBorder); // 8 chars for name

    TableColumn keyColumn = columnModel.getColumn(1);
    // Single char for key (but 3 chars to prevent "..." in column header)
    keyColumn.setPreferredWidth(3 * maxCharWidth + editingBorder);
    keyColumn.setMinWidth(keyColumn.getPreferredWidth());

    TableColumn locationColumn = columnModel.getColumn(2);
    Insets insets = tableView.getBorder().getBorderInsets(tableView);
    int remainingWidth = tableView.getParent().getWidth() - insets.left - insets.right;
    remainingWidth -= 2 * columnModel.getColumnMargin();
    remainingWidth -= nameColumn.getPreferredWidth();
    remainingWidth -= keyColumn.getPreferredWidth();
    locationColumn.setPreferredWidth(remainingWidth); // remaining space for location
}
 
Example #3
Source File: NodePopupFactory.java    From netbeans with Apache License 2.0 5 votes vote down vote up
void addNoFilterItem(ETable et, JPopupMenu popup) {
    if (showQuickFilter && et.getQuickFilterColumn() != -1) {
        String s = NbBundle.getMessage(NodePopupFactory.class, "LBL_QuickFilter");
        JMenu menu = new JMenu(s);
        JMenuItem noFilterItem = et.getQuickFilterNoFilterItem(et.getQuickFilterFormatStrings()[6]);
        menu.add(noFilterItem);
        popup.add(menu);
    }
}
 
Example #4
Source File: OutlineView.java    From netbeans with Apache License 2.0 5 votes vote down vote up
@Override
public JPopupMenu createPopupMenu(int row, int column, Node[] selectedNodes, Component component) {
    if (component instanceof ETable) {
        ETable et = (ETable)component;
        int modelRowIndex = et.convertColumnIndexToModel(column);
        setShowQuickFilter(modelRowIndex != 0);
    }
    return super.createPopupMenu(row, column, selectedNodes, component);
}
 
Example #5
Source File: SyncTable.java    From netbeans with Apache License 2.0 5 votes vote down vote up
public SyncTable (ModeKeeper modeKeeper) {
    this.modeKeeper = modeKeeper;
    tableModel = new NodeTableModel();
    table = new ETable(tableModel);
    table.setColumnHidingAllowed(false);
    table.setRowHeight(table.getRowHeight() * 6 / 5);
    component = new JScrollPane(table, JScrollPane.VERTICAL_SCROLLBAR_ALWAYS, JScrollPane.HORIZONTAL_SCROLLBAR_NEVER);
    component.getViewport().setBackground(table.getBackground());
    Color borderColor = UIManager.getColor("scrollpane_border"); // NOI18N
    if (borderColor == null) borderColor = UIManager.getColor("controlShadow"); // NOI18N
    component.setBorder(BorderFactory.createMatteBorder(1, 0, 0, 0, borderColor));
    table.addMouseListener(this);
    table.setDefaultRenderer(Node.Property.class, new SyncTableCellRenderer());
    table.getSelectionModel().addListSelectionListener(this);
    table.addAncestorListener(this);
    table.getAccessibleContext().setAccessibleName(NbBundle.getMessage(SyncTable.class, "ACSN_VersioningTable")); // NOI18N
    table.getAccessibleContext().setAccessibleDescription(NbBundle.getMessage(SyncTable.class, "ACSD_VersioningTable")); // NOI18N
    setColumns(new String[] {
        SyncFileNode.COLUMN_NAME_NAME,
        SyncFileNode.COLUMN_NAME_STATUS,
        SyncFileNode.COLUMN_NAME_PATH}
    );
    table.getInputMap(JComponent.WHEN_ANCESTOR_OF_FOCUSED_COMPONENT ).put(
            KeyStroke.getKeyStroke(KeyEvent.VK_F10, KeyEvent.SHIFT_DOWN_MASK ), "org.openide.actions.PopupAction");
    table.getActionMap().put("org.openide.actions.PopupAction", new AbstractAction() {
        @Override
        public void actionPerformed(ActionEvent e) {
            showPopup(org.netbeans.modules.versioning.util.Utils.getPositionForPopup(table));
        }
    });
    table.getInputMap(JComponent.WHEN_ANCESTOR_OF_FOCUSED_COMPONENT).put(
            KeyStroke.getKeyStroke(KeyEvent.VK_DELETE, 0), "DeleteAction");
    table.getActionMap().put("DeleteAction", SystemAction.get(DeleteLocalAction.class));
    table.getInputMap(JComponent.WHEN_FOCUSED).put(KeyStroke.getKeyStroke(KeyEvent.VK_ESCAPE, 0), "slideOut");
}
 
Example #6
Source File: SyncTable.java    From netbeans with Apache License 2.0 5 votes vote down vote up
public SyncTable() {
    tableModel = new NodeTableModel();
    table = new ETable(tableModel);
    table.setColumnHidingAllowed(false);
    table.setRowHeight(table.getRowHeight() * 6 / 5);
    component = new JScrollPane(table, JScrollPane.VERTICAL_SCROLLBAR_ALWAYS, JScrollPane.HORIZONTAL_SCROLLBAR_NEVER);
    component.getViewport().setBackground(table.getBackground());
    Color borderColor = UIManager.getColor("scrollpane_border"); // NOI18N
    if (borderColor == null) borderColor = UIManager.getColor("controlShadow"); // NOI18N
    component.setBorder(BorderFactory.createMatteBorder(1, 0, 0, 0, borderColor));
    table.addMouseListener(this);
    table.setDefaultRenderer(Node.Property.class, new SyncTableCellRenderer());
    table.getSelectionModel().addListSelectionListener(this);
    table.addAncestorListener(this);
    table.getAccessibleContext().setAccessibleName(NbBundle.getMessage(SyncTable.class, "ACSN_VersioningTable")); // NOI18N
    table.getAccessibleContext().setAccessibleDescription(NbBundle.getMessage(SyncTable.class, "ACSD_VersioningTable")); // NOI18N
    setColumns(new String[] {
        SyncFileNode.COLUMN_NAME_NAME,
        SyncFileNode.COLUMN_NAME_STATUS,
        SyncFileNode.COLUMN_NAME_PATH}
    );
    table.getInputMap(JComponent.WHEN_ANCESTOR_OF_FOCUSED_COMPONENT ).put(
            KeyStroke.getKeyStroke(KeyEvent.VK_F10, KeyEvent.SHIFT_DOWN_MASK ), "org.openide.actions.PopupAction"); // NOI18N
    table.getActionMap().put("org.openide.actions.PopupAction", new AbstractAction() { // NOI18N
        @Override
        public void actionPerformed(ActionEvent e) {
            showPopup(org.netbeans.modules.versioning.util.Utils.getPositionForPopup(table));
        }
    });
    table.getInputMap(JComponent.WHEN_ANCESTOR_OF_FOCUSED_COMPONENT).put(
            KeyStroke.getKeyStroke(KeyEvent.VK_DELETE, 0), "DeleteAction");
    table.getActionMap().put("DeleteAction", SystemAction.get(DeleteLocalAction.class));
}
 
Example #7
Source File: DbPagedTableTopComponent.java    From Llunatic with GNU General Public License v3.0 5 votes vote down vote up
private void initTable() {
        outlineView1.setNodePopupFactory(new TablePopupFactory());
        Outline outline = outlineView1.getOutline();
        outline.setRootVisible(false);
        outline.setCellSelectionEnabled(true);
//        outline.setAutoResizeMode(ETable.AUTO_RESIZE_OFF);
        outline.setAutoResizeMode(ETable.AUTO_RESIZE_ALL_COLUMNS);
        ((DefaultOutlineModel) outline.getOutlineModel()).setNodesColumnLabel("tid");
        outline.setFullyNonEditable(true);
    }
 
Example #8
Source File: DbTableTopComponent.java    From Llunatic with GNU General Public License v3.0 5 votes vote down vote up
private void initTable() {
        outlineView1.setNodePopupFactory(new TablePopupFactory());
        Outline outline = outlineView1.getOutline();
        outline.setRootVisible(false);
        outline.setCellSelectionEnabled(true);
        outline.setAutoResizeMode(ETable.AUTO_RESIZE_OFF);
//        TableColumnModel columnModel = outline.getColumnModel();
//        ETableColumn column = (ETableColumn) columnModel.getColumn(0);
//        ((ETableColumnModel) columnModel).setColumnHidden(column, true);
        ((DefaultOutlineModel) outline.getOutlineModel()).setNodesColumnLabel("tid");
        outline.setFullyNonEditable(true);
    }
 
Example #9
Source File: TableView.java    From netbeans with Apache License 2.0 4 votes vote down vote up
/**
 * Getter for the embeded table component.
 */
public ETable getTable() {
    return table;
}
 
Example #10
Source File: SheetCell.java    From netbeans with Apache License 2.0 4 votes vote down vote up
public TableSheetCell(NodeTableModel tableModel, ETable table) {
    this.tableModel = tableModel;
    this.table = table;
}
 
Example #11
Source File: RequestMappingNavigatorPanel.java    From nb-springboot with Apache License 2.0 4 votes vote down vote up
/**
 * public no arg constructor needed for system to instantiate provider well
 */
public RequestMappingNavigatorPanel() {
    table = new ETable();
    mappedElementsModel = new MappedElementsModel();
    mappedElementGatheringTaskFactory = new ElementScanningTaskFactory(table, mappedElementsModel);
    table.setModel(mappedElementsModel);
    table.setAutoResizeMode(JTable.AUTO_RESIZE_OFF);
    table.setColumnSorted(0, true, 1);
    table.setDefaultRenderer(RequestMethod.class, new RequestMethodCellRenderer());
    table.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
    table.getSelectionModel().addListSelectionListener(new ListSelectionListener() {
        @Override
        public void valueChanged(ListSelectionEvent event) {
            final int selectedRow = ((ListSelectionModel) event.getSource()).getMinSelectionIndex();
            if (event.getValueIsAdjusting() || selectedRow < 0) {
                return;
            }
            final MappedElement mappedElement = mappedElementsModel.getElementAt(table.convertRowIndexToModel(selectedRow));
            ElementOpen.open(mappedElement.getFileObject(), mappedElement.getHandle());
            try {
                final DataObject dataObject = DataObject.find(mappedElement.getFileObject());
                final EditorCookie editorCookie = dataObject.getLookup().lookup(EditorCookie.class);
                if (editorCookie != null) {
                    editorCookie.openDocument();
                    JEditorPane[] p = editorCookie.getOpenedPanes();
                    if (p.length > 0) {
                        p[0].requestFocus();
                    }
                }
            } catch (IOException e) {
            }
        }
    });
    final JPanel panel = new JPanel(new BorderLayout());
    panel.add(new JScrollPane(table), BorderLayout.CENTER);
    this.component = panel;
    this.contextListener = new LookupListener() {
        @Override
        public void resultChanged(LookupEvent le) {
        }
    };
}
 
Example #12
Source File: ElementScanningTaskFactory.java    From nb-springboot with Apache License 2.0 4 votes vote down vote up
public ElementScanningTask(ETable table, MappedElementsModel targetModel) {
    this.table = table;
    this.targetModel = targetModel;
}
 
Example #13
Source File: ElementScanningTaskFactory.java    From nb-springboot with Apache License 2.0 4 votes vote down vote up
public ElementScanningTaskFactory(final ETable table, final MappedElementsModel mappedElementsModel) {
    super(JavaSource.Phase.PARSED, JavaSource.Priority.NORMAL);
    this.table = table;
    this.mappedElementsModel = mappedElementsModel;
}