Search in sources :

Example 6 with TableColumnModelEvent

use of javax.swing.event.TableColumnModelEvent in project blue by kunstmusik.

the class TracksEditor method setupTable.

private void setupTable() {
    table.setShowGrid(false);
    table.getTableHeader().setReorderingAllowed(false);
    table.setAutoResizeMode(JTable.AUTO_RESIZE_OFF);
    table.setDefaultRenderer(String.class, new TrackerCellRenderer());
    table.setDefaultEditor(String.class, new TrackColumnEditor());
    table.addComponentListener(new ComponentAdapter() {

        @Override
        public void componentResized(ComponentEvent e) {
            namePanel.updateSize();
        }
    });
    table.getColumnModel().addColumnModelListener(new TableColumnModelListener() {

        @Override
        public void columnAdded(TableColumnModelEvent e) {
        }

        @Override
        public void columnMarginChanged(ChangeEvent e) {
            if (trackList != null) {
                namePanel.updateLabelSizes();
            }
        }

        @Override
        public void columnMoved(TableColumnModelEvent e) {
        }

        @Override
        public void columnRemoved(TableColumnModelEvent e) {
        }

        @Override
        public void columnSelectionChanged(ListSelectionEvent e) {
        }
    });
    table.getColumnModel().getSelectionModel().addListSelectionListener((ListSelectionEvent e) -> {
        int h = table.getRowHeight();
        int y1 = table.getSelectedRow() * h;
        int selectionH = table.getSelectedRowCount() * h;
        table.repaint(0, y1, table.getWidth(), selectionH);
    });
    SwingUtil.installActions(table, new Action[] { new IncrementAction(), new DecrementAction(), new TieAction(), new SpaceBarAction(), new NoteOffAction(), new CutAction(), new CopyAction(), new PasteAction(), new InsertAction(), new DeleteAction(), new BackSpaceAction() });
}
Also used : TableColumnModelEvent(javax.swing.event.TableColumnModelEvent) TableColumnModelListener(javax.swing.event.TableColumnModelListener) ListSelectionEvent(javax.swing.event.ListSelectionEvent) Point(java.awt.Point) ChangeEvent(javax.swing.event.ChangeEvent) PropertyChangeEvent(java.beans.PropertyChangeEvent) ComponentEvent(java.awt.event.ComponentEvent) ComponentAdapter(java.awt.event.ComponentAdapter)

Example 7 with TableColumnModelEvent

use of javax.swing.event.TableColumnModelEvent in project cytoscape-impl by cytoscape.

the class PreviewTablePanel method getPreviewTable.

public JTable getPreviewTable() {
    if (previewTable == null) {
        previewTable = new JTable(new PreviewTableModel(new Vector<Vector<String>>(), new Vector<String>(), false));
        previewTable.setShowGrid(false);
        previewTable.setCellSelectionEnabled(false);
        previewTable.setAutoResizeMode(JTable.AUTO_RESIZE_OFF);
        previewTable.setDefaultEditor(Object.class, null);
        if (importType == NETWORK_IMPORT) {
            final TableCellRenderer netRenderer = new PreviewTableCellRenderer();
            previewTable.setDefaultRenderer(Object.class, netRenderer);
        } else {
            previewTable.setDefaultRenderer(Object.class, new PreviewTableCellRenderer());
        }
        final JTableHeader hd = previewTable.getTableHeader();
        hd.setReorderingAllowed(false);
        hd.setDefaultRenderer(new PreviewTableHeaderRenderer());
        final TableColumnModelListener colModelListener = new TableColumnModelListener() {

            @Override
            public void columnMoved(TableColumnModelEvent e) {
                disposeEditDialog();
            }

            @Override
            public void columnMarginChanged(ChangeEvent e) {
                disposeEditDialog();
            }

            @Override
            public void columnSelectionChanged(ListSelectionEvent e) {
            }

            @Override
            public void columnRemoved(TableColumnModelEvent e) {
            }

            @Override
            public void columnAdded(TableColumnModelEvent e) {
            }
        };
        hd.addMouseListener(new MouseAdapter() {

            @Override
            public void mousePressed(final MouseEvent e) {
                final TableColumnModel columnModel = previewTable.getColumnModel();
                final int newColIdx = columnModel.getColumnIndexAtX(e.getX());
                final int idx = editDialog != null ? editDialog.index : -1;
                disposeEditDialog();
                if (idx != newColIdx)
                    showEditDialog(newColIdx);
                // Do not show editor dialog when the user is resizing the columns
                previewTable.getColumnModel().removeColumnModelListener(colModelListener);
                previewTable.getColumnModel().addColumnModelListener(colModelListener);
            }

            @Override
            public void mouseReleased(MouseEvent e) {
                previewTable.getColumnModel().removeColumnModelListener(colModelListener);
            }
        });
        // Also close the editor dialog when the table changes
        previewTable.getModel().addTableModelListener(new TableModelListener() {

            @Override
            public void tableChanged(TableModelEvent e) {
                disposeEditDialog();
            }
        });
    }
    return previewTable;
}
Also used : TableCellRenderer(javax.swing.table.TableCellRenderer) DefaultTableCellRenderer(javax.swing.table.DefaultTableCellRenderer) TableColumnModelEvent(javax.swing.event.TableColumnModelEvent) TableColumnModelListener(javax.swing.event.TableColumnModelListener) MouseEvent(java.awt.event.MouseEvent) TableModelEvent(javax.swing.event.TableModelEvent) ListSelectionEvent(javax.swing.event.ListSelectionEvent) MouseAdapter(java.awt.event.MouseAdapter) JTableHeader(javax.swing.table.JTableHeader) TableColumnModel(javax.swing.table.TableColumnModel) ChangeEvent(javax.swing.event.ChangeEvent) PropertyChangeEvent(java.beans.PropertyChangeEvent) JTable(javax.swing.JTable) TableModelListener(javax.swing.event.TableModelListener) Vector(java.util.Vector)

Example 8 with TableColumnModelEvent

use of javax.swing.event.TableColumnModelEvent in project omegat by omegat-org.

the class ProjectFilesListController method setTableFilesModel.

private void setTableFilesModel(final List<IProject.FileInfo> files) {
    modelFiles = new FileInfoModel(files);
    list.tableFiles.setModel(modelFiles);
    TableColumnModel colModel = list.tableFiles.getColumnModel();
    colModel.addColumnModelListener(new TableColumnModelListener() {

        @Override
        public void columnAdded(TableColumnModelEvent e) {
        }

        @Override
        public void columnMarginChanged(ChangeEvent e) {
        }

        @Override
        public void columnMoved(TableColumnModelEvent e) {
            // Propagate movement to tableTotal
            list.tableTotal.getColumnModel().moveColumn(e.getFromIndex(), e.getToIndex());
        }

        @Override
        public void columnRemoved(TableColumnModelEvent e) {
        }

        @Override
        public void columnSelectionChanged(ListSelectionEvent e) {
        }
    });
    for (FilesTableColumn col : FilesTableColumn.values()) {
        TableColumn tCol = colModel.getColumn(col.index);
        tCol.setCellRenderer(new CustomRenderer(files, col.renderer));
    }
    currentSorter = new Sorter(files);
    currentSorter.addRowSorterListener(e -> updateTitle());
    list.tableFiles.setRowSorter(currentSorter);
}
Also used : TableColumnModelEvent(javax.swing.event.TableColumnModelEvent) TableColumnModelListener(javax.swing.event.TableColumnModelListener) ChangeEvent(javax.swing.event.ChangeEvent) ListSelectionEvent(javax.swing.event.ListSelectionEvent) RowSorter(javax.swing.RowSorter) TableColumnModel(javax.swing.table.TableColumnModel) TableColumn(javax.swing.table.TableColumn)

Example 9 with TableColumnModelEvent

use of javax.swing.event.TableColumnModelEvent in project gate-core by GateNLP.

the class AnnotationDiffGUI method initListeners.

protected void initListeners() {
    addWindowListener(new WindowAdapter() {

        @Override
        public void windowClosing(WindowEvent e) {
            new CloseAction().actionPerformed(null);
        }
    });
    addWindowFocusListener(new WindowAdapter() {

        @Override
        public void windowGainedFocus(WindowEvent e) {
            populateGUI();
        }
    });
    keyDocCombo.addActionListener(new ActionListener() {

        @Override
        public void actionPerformed(ActionEvent evt) {
            int keyDocSelectedIndex = keyDocCombo.getSelectedIndex();
            if (keyDocSelectedIndex == -1) {
                return;
            }
            Document newDoc = (Document) documents.get(keyDocSelectedIndex);
            if (keyDoc == newDoc) {
                return;
            }
            pairings.clear();
            diffTableModel.fireTableDataChanged();
            copyToTargetSetAction.setEnabled(false);
            keyDoc = newDoc;
            keySets = new ArrayList<AnnotationSet>();
            List<String> keySetNames = new ArrayList<String>();
            keySets.add(keyDoc.getAnnotations());
            keySetNames.add("[Default set]");
            if (keyDoc.getNamedAnnotationSets() != null) {
                for (Object o : keyDoc.getNamedAnnotationSets().keySet()) {
                    String name = (String) o;
                    keySetNames.add(name);
                    keySets.add(keyDoc.getAnnotations(name));
                }
            }
            keySetCombo.setModel(new DefaultComboBoxModel<String>(keySetNames.toArray(new String[keySetNames.size()])));
            if (!keySetNames.isEmpty()) {
                keySetCombo.setSelectedIndex(0);
                if (resSetCombo.getItemCount() > 0) {
                    // find first annotation set with annotation type in common
                    for (int res = 0; res < resSetCombo.getItemCount(); res++) {
                        resSetCombo.setSelectedIndex(res);
                        for (int key = 0; key < keySetCombo.getItemCount(); key++) {
                            if (keyDoc.equals(resDoc) && resSetCombo.getItemAt(res).equals(keySetCombo.getItemAt(key))) {
                                // same document, skip it
                                continue;
                            }
                            keySetCombo.setSelectedIndex(key);
                            if (annTypeCombo.getSelectedItem() != null) {
                                break;
                            }
                        }
                        if (annTypeCombo.getSelectedItem() != null) {
                            break;
                        }
                    }
                    if (annTypeCombo.getSelectedItem() == null) {
                        statusLabel.setText("There is no annotation type in common.");
                        statusLabel.setForeground(Color.RED);
                    } else if (statusLabel.getText().equals("There is no annotation type in common.")) {
                        statusLabel.setText("The first annotation sets with" + " annotation type in common have been automatically selected.");
                        statusLabel.setForeground(Color.BLACK);
                    }
                }
            }
        }
    });
    resDocCombo.addActionListener(new ActionListener() {

        @Override
        public void actionPerformed(ActionEvent evt) {
            int resDocSelectedIndex = resDocCombo.getSelectedIndex();
            if (resDocSelectedIndex == -1) {
                return;
            }
            Document newDoc = (Document) documents.get(resDocSelectedIndex);
            if (resDoc == newDoc) {
                return;
            }
            resDoc = newDoc;
            pairings.clear();
            diffTableModel.fireTableDataChanged();
            copyToTargetSetAction.setEnabled(false);
            resSets = new ArrayList<AnnotationSet>();
            List<String> resSetNames = new ArrayList<String>();
            resSets.add(resDoc.getAnnotations());
            resSetNames.add("[Default set]");
            if (resDoc.getNamedAnnotationSets() != null) {
                for (Object o : resDoc.getNamedAnnotationSets().keySet()) {
                    String name = (String) o;
                    resSetNames.add(name);
                    resSets.add(resDoc.getAnnotations(name));
                }
            }
            resSetCombo.setModel(new DefaultComboBoxModel<String>(resSetNames.toArray(new String[resSetNames.size()])));
            if (!resSetNames.isEmpty()) {
                resSetCombo.setSelectedIndex(0);
                if (keySetCombo.getItemCount() > 0) {
                    // find annotation sets with annotations in common
                    for (int res = 0; res < resSetCombo.getItemCount(); res++) {
                        resSetCombo.setSelectedIndex(res);
                        for (int key = 0; key < keySetCombo.getItemCount(); key++) {
                            if (keyDoc.equals(resDoc) && resSetCombo.getItemAt(res).equals(keySetCombo.getItemAt(key))) {
                                continue;
                            }
                            keySetCombo.setSelectedIndex(key);
                            if (annTypeCombo.getSelectedItem() != null) {
                                break;
                            }
                        }
                        if (annTypeCombo.getSelectedItem() != null) {
                            break;
                        }
                    }
                    if (annTypeCombo.getSelectedItem() == null) {
                        statusLabel.setText("There is no annotations in common.");
                        statusLabel.setForeground(Color.RED);
                    } else if (statusLabel.getText().equals("There is no annotations in common.")) {
                        statusLabel.setText("The first annotation sets with" + " annotations in common have been selected.");
                        statusLabel.setForeground(Color.BLACK);
                    }
                }
            }
        }
    });
    /**
     * This populates the types combo when set selection changes
     */
    ActionListener setComboActionListener = new ActionListener() {

        @Override
        public void actionPerformed(ActionEvent evt) {
            keySet = keySets == null || keySets.isEmpty() ? null : keySets.get(keySetCombo.getSelectedIndex());
            resSet = resSets == null || resSets.isEmpty() ? null : resSets.get(resSetCombo.getSelectedIndex());
            Set<String> keyTypes = (keySet == null || keySet.isEmpty()) ? new HashSet<String>() : keySet.getAllTypes();
            Set<String> resTypes = (resSet == null || resSet.isEmpty()) ? new HashSet<String>() : resSet.getAllTypes();
            Set<String> types = new HashSet<String>(keyTypes);
            types.retainAll(resTypes);
            List<String> typesList = new ArrayList<String>(types);
            Collections.sort(typesList);
            annTypeCombo.setModel(new DefaultComboBoxModel<String>(typesList.toArray(new String[typesList.size()])));
            if (typesList.size() > 0) {
                annTypeCombo.setSelectedIndex(0);
                diffAction.setEnabled(true);
                doDiffBtn.setForeground((Color) UIManager.getDefaults().get("Button.foreground"));
                doDiffBtn.setToolTipText((String) diffAction.getValue(Action.SHORT_DESCRIPTION));
            } else {
                diffAction.setEnabled(false);
                doDiffBtn.setForeground((Color) UIManager.getDefaults().get("Button.disabledText"));
                doDiffBtn.setToolTipText("Choose two annotation sets " + "that have at least one annotation type in common.");
            }
        }
    };
    keySetCombo.addActionListener(setComboActionListener);
    resSetCombo.addActionListener(setComboActionListener);
    someFeaturesBtn.addActionListener(new ActionListener() {

        @Override
        public void actionPerformed(ActionEvent evt) {
            if (someFeaturesBtn.isSelected()) {
                if (keySet == null || keySet.isEmpty() || annTypeCombo.getSelectedItem() == null)
                    return;
                Iterator<Annotation> annIter = keySet.get((String) annTypeCombo.getSelectedItem()).iterator();
                Set<String> featureSet = new HashSet<String>();
                while (annIter.hasNext()) {
                    Annotation ann = annIter.next();
                    Map<Object, Object> someFeatures = ann.getFeatures();
                    if (someFeatures == null) {
                        continue;
                    }
                    for (Object feature : someFeatures.keySet()) {
                        featureSet.add((String) feature);
                    }
                }
                List<String> featureList = new ArrayList<String>(featureSet);
                Collections.sort(featureList);
                featureslistModel.clear();
                Iterator<String> featIter = featureList.iterator();
                int index = 0;
                while (featIter.hasNext()) {
                    String aFeature = featIter.next();
                    featureslistModel.addElement(aFeature);
                    if (significantFeatures.contains(aFeature))
                        featuresList.addSelectionInterval(index, index);
                    index++;
                }
                int ret = JOptionPane.showConfirmDialog(AnnotationDiffGUI.this, new JScrollPane(featuresList), "Select features", JOptionPane.OK_CANCEL_OPTION, JOptionPane.QUESTION_MESSAGE);
                if (ret == JOptionPane.OK_OPTION) {
                    significantFeatures.clear();
                    int[] selIdxs = featuresList.getSelectedIndices();
                    for (int selIdx : selIdxs) {
                        significantFeatures.add(featureslistModel.get(selIdx));
                    }
                }
            }
        }
    });
    // enable/disable buttons according to the table state
    diffTableModel.addTableModelListener(new TableModelListener() {

        @Override
        public void tableChanged(javax.swing.event.TableModelEvent e) {
            if (diffTableModel.getRowCount() > 0) {
                htmlExportAction.setEnabled(true);
                htmlExportBtn.setToolTipText((String) htmlExportAction.getValue(Action.SHORT_DESCRIPTION));
                showDocumentAction.setEnabled(true);
                showDocumentBtn.setToolTipText((String) showDocumentAction.getValue(Action.SHORT_DESCRIPTION));
            } else {
                htmlExportAction.setEnabled(false);
                htmlExportBtn.setToolTipText("Use first the \"Compare\" button.");
                showDocumentAction.setEnabled(false);
                showDocumentBtn.setToolTipText("Use first the \"Compare\"" + " button then select an annotation in the table.");
            }
        }
    });
    // enable/disable buttons according to the table selection
    diffTable.getSelectionModel().addListSelectionListener(new ListSelectionListener() {

        @Override
        public void valueChanged(ListSelectionEvent e) {
            int row = diffTable.rowViewToModel(diffTable.getSelectedRow());
            if (row == -1) {
                showDocumentAction.setEnabled(false);
                return;
            }
            AnnotationDiffer.Pairing pairing = pairings.get(row);
            Annotation key = pairing.getKey();
            Annotation response = pairing.getResponse();
            int column = diffTable.convertColumnIndexToModel(diffTable.getSelectedColumn());
            boolean enabled;
            switch(column) {
                case DiffTableModel.COL_KEY_START:
                case DiffTableModel.COL_KEY_END:
                case DiffTableModel.COL_KEY_STRING:
                case DiffTableModel.COL_KEY_FEATURES:
                    enabled = (key != null);
                    break;
                case DiffTableModel.COL_RES_START:
                case DiffTableModel.COL_RES_END:
                case DiffTableModel.COL_RES_STRING:
                case DiffTableModel.COL_RES_FEATURES:
                    enabled = (response != null);
                    break;
                default:
                    enabled = false;
            }
            showDocumentAction.setEnabled(enabled);
        }
    });
    // enable/disable buttons according to the table selection
    diffTable.getColumnModel().addColumnModelListener(new TableColumnModelListener() {

        @Override
        public void columnAdded(TableColumnModelEvent e) {
        /* do nothing */
        }

        @Override
        public void columnRemoved(TableColumnModelEvent e) {
        /* do nothing */
        }

        @Override
        public void columnMoved(TableColumnModelEvent e) {
        /* do nothing */
        }

        @Override
        public void columnMarginChanged(ChangeEvent e) {
        /* do nothing */
        }

        @Override
        public void columnSelectionChanged(ListSelectionEvent e) {
            int row = diffTable.rowViewToModel(diffTable.getSelectedRow());
            if (row == -1) {
                showDocumentAction.setEnabled(false);
                return;
            }
            AnnotationDiffer.Pairing pairing = pairings.get(row);
            Annotation key = pairing.getKey();
            Annotation response = pairing.getResponse();
            int column = diffTable.convertColumnIndexToModel(diffTable.getSelectedColumn());
            boolean enabled;
            switch(column) {
                case DiffTableModel.COL_KEY_START:
                case DiffTableModel.COL_KEY_END:
                case DiffTableModel.COL_KEY_STRING:
                case DiffTableModel.COL_KEY_FEATURES:
                    enabled = (key != null);
                    break;
                case DiffTableModel.COL_RES_START:
                case DiffTableModel.COL_RES_END:
                case DiffTableModel.COL_RES_STRING:
                case DiffTableModel.COL_RES_FEATURES:
                    enabled = (response != null);
                    break;
                default:
                    enabled = false;
            }
            showDocumentAction.setEnabled(enabled);
        }
    });
    // inverse state of selected checkboxes when Space key is pressed
    diffTable.addKeyListener(new KeyAdapter() {

        @Override
        public void keyPressed(KeyEvent e) {
            if (e.getKeyCode() != KeyEvent.VK_SPACE || !(diffTable.isColumnSelected(DiffTableModel.COL_KEY_COPY) || diffTable.isColumnSelected(DiffTableModel.COL_RES_COPY))) {
                return;
            }
            // disable normal behavior of Space key in a table
            e.consume();
            int[] cols = { DiffTableModel.COL_KEY_COPY, DiffTableModel.COL_RES_COPY };
            for (int col : cols) {
                for (int row : diffTable.getSelectedRows()) {
                    if (diffTable.isCellSelected(row, col) && diffTable.isCellEditable(row, col)) {
                        diffTable.setValueAt(!(Boolean) diffTable.getValueAt(row, col), row, col);
                        diffTableModel.fireTableCellUpdated(row, col);
                    }
                }
            }
        }
    });
    // context menu for the check boxes to easily change their state
    diffTable.addMouseListener(new MouseAdapter() {

        private JPopupMenu mousePopup;

        JMenuItem menuItem;

        @Override
        public void mousePressed(MouseEvent e) {
            showContextMenu(e);
        }

        @Override
        public void mouseReleased(MouseEvent e) {
            showContextMenu(e);
        }

        private void showContextMenu(MouseEvent e) {
            int col = diffTable.convertColumnIndexToModel(diffTable.columnAtPoint(e.getPoint()));
            if (!e.isPopupTrigger() || (col != DiffTableModel.COL_KEY_COPY && col != DiffTableModel.COL_RES_COPY)) {
                return;
            }
            mousePopup = new JPopupMenu();
            for (final String tick : new String[] { "Tick", "Untick" }) {
                menuItem = new JMenuItem(tick + " selected check boxes");
                menuItem.addActionListener(new ActionListener() {

                    @Override
                    public void actionPerformed(ActionEvent ae) {
                        int keyCol = diffTable.convertColumnIndexToView(DiffTableModel.COL_KEY_COPY);
                        int responseCol = diffTable.convertColumnIndexToView(DiffTableModel.COL_RES_COPY);
                        for (int row = 0; row < diffTable.getRowCount(); row++) {
                            int rowModel = diffTable.rowViewToModel(row);
                            AnnotationDiffer.Pairing pairing = pairings.get(rowModel);
                            if (diffTable.isCellSelected(row, keyCol) && pairing.getKey() != null) {
                                diffTable.setValueAt(tick.equals("Tick"), row, keyCol);
                            }
                            if (diffTable.isCellSelected(row, responseCol) && pairing.getResponse() != null) {
                                diffTable.setValueAt(tick.equals("Tick"), row, responseCol);
                            }
                        }
                        diffTableModel.fireTableDataChanged();
                    }
                });
                mousePopup.add(menuItem);
            }
            mousePopup.addSeparator();
            String[] types = new String[] { "correct", "partially correct", "missing", "false positives", "mismatch" };
            String[] symbols = new String[] { "=", "~", "-?", "?-", "<>" };
            for (int i = 0; i < types.length; i++) {
                menuItem = new JMenuItem("Tick " + types[i] + " annotations");
                final String symbol = symbols[i];
                menuItem.addActionListener(new ActionListener() {

                    @Override
                    public void actionPerformed(ActionEvent ae) {
                        int matchCol = diffTable.convertColumnIndexToView(DiffTableModel.COL_MATCH);
                        for (int row = 0; row < diffTable.getRowCount(); row++) {
                            int rowModel = diffTable.rowViewToModel(row);
                            AnnotationDiffer.Pairing pairing = pairings.get(rowModel);
                            if (diffTable.getValueAt(row, matchCol).equals(symbol) && pairing.getKey() != null) {
                                keyCopyValueRows.set(diffTable.rowViewToModel(row), true);
                            } else if (diffTable.getValueAt(row, matchCol).equals(symbol) && pairing.getResponse() != null) {
                                resCopyValueRows.set(diffTable.rowViewToModel(row), true);
                            }
                        }
                        diffTableModel.fireTableDataChanged();
                    }
                });
                mousePopup.add(menuItem);
            }
            mousePopup.show(e.getComponent(), e.getX(), e.getY());
        }
    });
    // revert to default name if the field is empty and lost focus
    consensusASTextField.addFocusListener(new FocusAdapter() {

        @Override
        public void focusLost(FocusEvent e) {
            String target = consensusASTextField.getText().trim();
            if (target.length() == 0) {
                consensusASTextField.setText("consensus");
            }
            if (keyDoc != null && keyDoc.getAnnotationSetNames().contains(target)) {
                statusLabel.setText("Be careful, the annotation set " + target + " already exists.");
                statusLabel.setForeground(Color.RED);
            }
        }
    });
    bottomTabbedPane.addChangeListener(new ChangeListener() {

        @Override
        public void stateChanged(ChangeEvent e) {
            if (bottomTabbedPane.getSelectedIndex() == 0) {
                diffTable.hideColumn(DiffTableModel.COL_KEY_COPY);
                diffTable.hideColumn(DiffTableModel.COL_RES_COPY);
            } else {
                int middleIndex = Math.round(diffTable.getColumnCount() / 2);
                diffTable.showColumn(DiffTableModel.COL_KEY_COPY, middleIndex);
                diffTable.showColumn(DiffTableModel.COL_RES_COPY, middleIndex + 2);
                diffTable.getColumnModel().getColumn(DiffTableModel.COL_KEY_COPY).setPreferredWidth(10);
                diffTable.getColumnModel().getColumn(DiffTableModel.COL_RES_COPY).setPreferredWidth(10);
                diffTable.doLayout();
            }
        }
    });
    // define keystrokes action bindings at the level of the main window
    InputMap inputMap = ((JComponent) this.getContentPane()).getInputMap(JComponent.WHEN_IN_FOCUSED_WINDOW);
    ActionMap actionMap = ((JComponent) this.getContentPane()).getActionMap();
    inputMap.put(KeyStroke.getKeyStroke("F1"), "Help");
    actionMap.put("Help", new AbstractAction() {

        @Override
        public void actionPerformed(ActionEvent e) {
            new HelpAction().actionPerformed(null);
        }
    });
}
Also used : ActionEvent(java.awt.event.ActionEvent) KeyAdapter(java.awt.event.KeyAdapter) ArrayList(java.util.ArrayList) Document(gate.Document) FocusEvent(java.awt.event.FocusEvent) ArrayList(java.util.ArrayList) List(java.util.List) JList(javax.swing.JList) AbstractAction(javax.swing.AbstractAction) HashSet(java.util.HashSet) DefaultComboBoxModel(javax.swing.DefaultComboBoxModel) ListSelectionListener(javax.swing.event.ListSelectionListener) ActionListener(java.awt.event.ActionListener) TableModelListener(javax.swing.event.TableModelListener) InputMap(javax.swing.InputMap) Map(java.util.Map) FeatureMap(gate.FeatureMap) ActionMap(javax.swing.ActionMap) InputMap(javax.swing.InputMap) FocusAdapter(java.awt.event.FocusAdapter) TableColumnModelListener(javax.swing.event.TableColumnModelListener) Set(java.util.Set) HashSet(java.util.HashSet) AnnotationSet(gate.AnnotationSet) ListSelectionEvent(javax.swing.event.ListSelectionEvent) WindowAdapter(java.awt.event.WindowAdapter) KeyEvent(java.awt.event.KeyEvent) Iterator(java.util.Iterator) ChangeListener(javax.swing.event.ChangeListener) JMenuItem(javax.swing.JMenuItem) AnnotationDiffer(gate.util.AnnotationDiffer) JScrollPane(javax.swing.JScrollPane) TableColumnModelEvent(javax.swing.event.TableColumnModelEvent) MouseEvent(java.awt.event.MouseEvent) ActionMap(javax.swing.ActionMap) MouseAdapter(java.awt.event.MouseAdapter) JComponent(javax.swing.JComponent) Annotation(gate.Annotation) JPopupMenu(javax.swing.JPopupMenu) ChangeEvent(javax.swing.event.ChangeEvent) WindowEvent(java.awt.event.WindowEvent)

Aggregations

TableColumnModelEvent (javax.swing.event.TableColumnModelEvent)9 ChangeEvent (javax.swing.event.ChangeEvent)6 ListSelectionEvent (javax.swing.event.ListSelectionEvent)6 TableColumnModelListener (javax.swing.event.TableColumnModelListener)6 MouseAdapter (java.awt.event.MouseAdapter)3 MouseEvent (java.awt.event.MouseEvent)3 PropertyChangeEvent (java.beans.PropertyChangeEvent)2 TableModelListener (javax.swing.event.TableModelListener)2 TableColumnModel (javax.swing.table.TableColumnModel)2 JBScrollPane (com.intellij.ui.components.JBScrollPane)1 Annotation (gate.Annotation)1 AnnotationSet (gate.AnnotationSet)1 Document (gate.Document)1 FeatureMap (gate.FeatureMap)1 AnnotationDiffer (gate.util.AnnotationDiffer)1 BorderLayout (java.awt.BorderLayout)1 Dimension (java.awt.Dimension)1 GridBagConstraints (java.awt.GridBagConstraints)1 Insets (java.awt.Insets)1 Point (java.awt.Point)1