Search in sources :

Example 86 with KeyEvent

use of java.awt.event.KeyEvent in project keystore-explorer by kaikramer.

the class JPolicyMappings method initComponents.

private void initComponents() {
    jbAdd = new JButton(new ImageIcon(Toolkit.getDefaultToolkit().createImage(getClass().getResource(res.getString("JPolicyMappings.jbAdd.image")))));
    jbAdd.setMargin(new Insets(2, 2, 0, 0));
    jbAdd.setToolTipText(res.getString("JPolicyMappings.jbAdd.tooltip"));
    jbAdd.setMnemonic(res.getString("JPolicyMappings.jbAdd.mnemonic").charAt(0));
    jbAdd.addActionListener(new ActionListener() {

        @Override
        public void actionPerformed(ActionEvent evt) {
            try {
                CursorUtil.setCursorBusy(JPolicyMappings.this);
                addPressed();
            } finally {
                CursorUtil.setCursorFree(JPolicyMappings.this);
            }
        }
    });
    jbEdit = new JButton(new ImageIcon(Toolkit.getDefaultToolkit().createImage(getClass().getResource(res.getString("JPolicyMappings.jbEdit.image")))));
    jbEdit.setMargin(new Insets(2, 2, 0, 0));
    jbEdit.setToolTipText(res.getString("JPolicyMappings.jbEdit.tooltip"));
    jbEdit.setMnemonic(res.getString("JPolicyMappings.jbEdit.mnemonic").charAt(0));
    jbEdit.setEnabled(false);
    jbEdit.addActionListener(new ActionListener() {

        @Override
        public void actionPerformed(ActionEvent evt) {
            try {
                CursorUtil.setCursorBusy(JPolicyMappings.this);
                editPressed();
            } finally {
                CursorUtil.setCursorFree(JPolicyMappings.this);
            }
        }
    });
    jbRemove = new JButton(new ImageIcon(Toolkit.getDefaultToolkit().createImage(getClass().getResource(res.getString("JPolicyMappings.jbRemove.image")))));
    jbRemove.setMargin(new Insets(2, 2, 0, 0));
    jbRemove.setToolTipText(res.getString("JPolicyMappings.jbRemove.tooltip"));
    jbRemove.setMnemonic(res.getString("JPolicyMappings.jbRemove.mnemonic").charAt(0));
    jbRemove.setEnabled(false);
    jbRemove.addActionListener(new ActionListener() {

        @Override
        public void actionPerformed(ActionEvent evt) {
            try {
                CursorUtil.setCursorBusy(JPolicyMappings.this);
                removePressed();
            } finally {
                CursorUtil.setCursorFree(JPolicyMappings.this);
            }
        }
    });
    jpPolicyMappingButtons = new JPanel();
    jpPolicyMappingButtons.setLayout(new BoxLayout(jpPolicyMappingButtons, BoxLayout.Y_AXIS));
    jpPolicyMappingButtons.add(Box.createVerticalGlue());
    jpPolicyMappingButtons.add(jbAdd);
    jpPolicyMappingButtons.add(Box.createVerticalStrut(3));
    jpPolicyMappingButtons.add(jbEdit);
    jpPolicyMappingButtons.add(Box.createVerticalStrut(3));
    jpPolicyMappingButtons.add(jbRemove);
    jpPolicyMappingButtons.add(Box.createVerticalGlue());
    PolicyMappingsTableModel policyMappingsTableModel = new PolicyMappingsTableModel();
    jtPolicyMappings = new JKseTable(policyMappingsTableModel);
    TableRowSorter<TableModel> sorter = new TableRowSorter<TableModel>(policyMappingsTableModel);
    sorter.setComparator(0, new PolicyMappingsTableModel.IssuerDomainPolicyComparator());
    sorter.setComparator(1, new PolicyMappingsTableModel.SubjectDomainPolicyComparator());
    jtPolicyMappings.setRowSorter(sorter);
    jtPolicyMappings.setShowGrid(false);
    jtPolicyMappings.setRowMargin(0);
    jtPolicyMappings.getColumnModel().setColumnMargin(0);
    jtPolicyMappings.getTableHeader().setReorderingAllowed(false);
    jtPolicyMappings.setAutoResizeMode(JKseTable.AUTO_RESIZE_ALL_COLUMNS);
    jtPolicyMappings.setRowHeight(Math.max(18, jtPolicyMappings.getRowHeight()));
    for (int i = 0; i < jtPolicyMappings.getColumnCount(); i++) {
        TableColumn column = jtPolicyMappings.getColumnModel().getColumn(i);
        column.setHeaderRenderer(new PolicyMappingsTableHeadRend(jtPolicyMappings.getTableHeader().getDefaultRenderer()));
        column.setCellRenderer(new PolicyMappingsTableCellRend());
    }
    ListSelectionModel selectionModel = jtPolicyMappings.getSelectionModel();
    selectionModel.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
    selectionModel.addListSelectionListener(new ListSelectionListener() {

        @Override
        public void valueChanged(ListSelectionEvent evt) {
            if (!evt.getValueIsAdjusting()) {
                updateButtonControls();
            }
        }
    });
    jtPolicyMappings.addMouseListener(new MouseAdapter() {

        @Override
        public void mouseClicked(MouseEvent evt) {
            maybeEditPolicyMapping(evt);
        }
    });
    jtPolicyMappings.addKeyListener(new KeyAdapter() {

        boolean deleteLastPressed = false;

        @Override
        public void keyPressed(KeyEvent evt) {
            // Record delete pressed on non-Macs
            if (!OperatingSystem.isMacOs()) {
                deleteLastPressed = evt.getKeyCode() == KeyEvent.VK_DELETE;
            }
        }

        @Override
        public void keyReleased(KeyEvent evt) {
            // Delete on non-Mac if delete was pressed and is now released
            if (!OperatingSystem.isMacOs() && deleteLastPressed && evt.getKeyCode() == KeyEvent.VK_DELETE) {
                try {
                    CursorUtil.setCursorBusy(JPolicyMappings.this);
                    deleteLastPressed = false;
                    removeSelectedPolicyMapping();
                } finally {
                    CursorUtil.setCursorFree(JPolicyMappings.this);
                }
            }
        }

        @Override
        public void keyTyped(KeyEvent evt) {
            // Delete on Mac if back space typed
            if (OperatingSystem.isMacOs() && evt.getKeyChar() == 0x08) {
                try {
                    CursorUtil.setCursorBusy(JPolicyMappings.this);
                    removeSelectedPolicyMapping();
                } finally {
                    CursorUtil.setCursorFree(JPolicyMappings.this);
                }
            }
        }
    });
    jspPolicyMappings = PlatformUtil.createScrollPane(jtPolicyMappings, ScrollPaneConstants.VERTICAL_SCROLLBAR_AS_NEEDED, ScrollPaneConstants.HORIZONTAL_SCROLLBAR_NEVER);
    jspPolicyMappings.getViewport().setBackground(jtPolicyMappings.getBackground());
    this.setLayout(new BorderLayout(5, 5));
    setPreferredSize(new Dimension(400, 150));
    add(jspPolicyMappings, BorderLayout.CENTER);
    add(jpPolicyMappingButtons, BorderLayout.EAST);
    populate();
}
Also used : ImageIcon(javax.swing.ImageIcon) JPanel(javax.swing.JPanel) Insets(java.awt.Insets) ActionEvent(java.awt.event.ActionEvent) BoxLayout(javax.swing.BoxLayout) KeyAdapter(java.awt.event.KeyAdapter) JButton(javax.swing.JButton) ListSelectionEvent(javax.swing.event.ListSelectionEvent) KeyEvent(java.awt.event.KeyEvent) BorderLayout(java.awt.BorderLayout) TableRowSorter(javax.swing.table.TableRowSorter) MouseEvent(java.awt.event.MouseEvent) JKseTable(org.kse.gui.JKseTable) MouseAdapter(java.awt.event.MouseAdapter) ListSelectionModel(javax.swing.ListSelectionModel) Dimension(java.awt.Dimension) TableColumn(javax.swing.table.TableColumn) Point(java.awt.Point) ListSelectionListener(javax.swing.event.ListSelectionListener) ActionListener(java.awt.event.ActionListener) TableModel(javax.swing.table.TableModel)

Example 87 with KeyEvent

use of java.awt.event.KeyEvent in project keystore-explorer by kaikramer.

the class DDateTimeChooser method initComponents.

private void initComponents(Date date) {
    jcbMonth = new JComboBox<Object>(MONTH_NAMES);
    jcbMonth.addItemListener(new ItemListener() {

        @Override
        public void itemStateChanged(ItemEvent evt) {
            update();
        }
    });
    jsYear = new JSpinner(new SpinnerListModel(YEARS));
    jsYear.addChangeListener(new ChangeListener() {

        @Override
        public void stateChanged(ChangeEvent evt) {
            update();
        }
    });
    jlDaysOfMonth = new JLabel[7][7];
    for (int i = 0; i < 7; i++) {
        jlDaysOfMonth[0][i] = new JLabel(DAY_NAMES[i], SwingConstants.RIGHT);
        jlDaysOfMonth[0][i].setOpaque(true);
        jlDaysOfMonth[0][i].setForeground(WEEK_DAY_FOREGROUND);
        jlDaysOfMonth[0][i].setBackground(WEEK_DAY_BACKGROUND);
        jlDaysOfMonth[0][i].setBorder(new EmptyBorder(0, 0, 0, 3));
    }
    for (int i = 1; i < 7; i++) {
        for (int j = 0; j < 7; j++) {
            jlDaysOfMonth[i][j] = new JLabel(EMPTY_DAY, SwingConstants.RIGHT);
            jlDaysOfMonth[i][j].setOpaque(true);
            jlDaysOfMonth[i][j].setForeground(DAY_FOREGROUND);
            jlDaysOfMonth[i][j].setBackground(DAY_BACKGROUND);
            jlDaysOfMonth[i][j].addMouseListener(new MouseAdapter() {

                @Override
                public void mouseClicked(MouseEvent evt) {
                    selectDay((JLabel) evt.getSource());
                }
            });
            jlDaysOfMonth[i][j].setBorder(new CompoundBorder(new MatteBorder(2, 0, 0, 0, Color.WHITE), new EmptyBorder(0, 0, 0, 3)));
        }
    }
    jpMonthYear = new JPanel();
    jpMonthYear.add(jcbMonth);
    jpMonthYear.add(jsYear);
    jpDaysOfMonth = new JPanel(new DayOfMonthGridLayout(7, 7));
    jpDaysOfMonth.setBackground(DAY_BACKGROUND);
    jpDaysOfMonth.setBorder(new CompoundBorder(BorderFactory.createLoweredBevelBorder(), new EmptyBorder(2, 2, 2, 2)));
    jpDaysOfMonth.setFocusable(true);
    jpDaysOfMonth.addFocusListener(new FocusListener() {

        @Override
        public void focusGained(FocusEvent evt) {
            setSelectedDay(jlSelectedDayOfMonth);
        }

        @Override
        public void focusLost(FocusEvent evt) {
            setSelectedDay(jlSelectedDayOfMonth);
        }
    });
    jpDaysOfMonth.addKeyListener(new KeyAdapter() {

        @Override
        public void keyPressed(KeyEvent evt) {
            calendarKeyboardNavigation(evt);
        }
    });
    for (int i = 0; i < 7; i++) {
        for (int j = 0; j < 7; j++) {
            jpDaysOfMonth.add(jlDaysOfMonth[i][j]);
        }
    }
    jsHour = new JSpinner(new SpinnerListModel(HOURS));
    jlTimeSeparator1 = new JLabel(":");
    jsMinute = new JSpinner(new SpinnerListModel(MINUTES));
    jlTimeSeparator2 = new JLabel(":");
    jsSecond = new JSpinner(new SpinnerListModel(SECONDS));
    jpTime = new JPanel(new FlowLayout(FlowLayout.CENTER));
    jpTime.add(jsHour);
    jpTime.add(jlTimeSeparator1);
    jpTime.add(jsMinute);
    jpTime.add(jlTimeSeparator2);
    jpTime.add(jsSecond);
    JPanel jpDateTime = new JPanel(new BorderLayout(0, 0));
    jpDateTime.setBorder(new CompoundBorder(new EmptyBorder(5, 5, 5, 5), new CompoundBorder(new EtchedBorder(), new EmptyBorder(5, 5, 5, 5))));
    jpDateTime.add(BorderLayout.NORTH, jpMonthYear);
    jpDateTime.add(BorderLayout.CENTER, jpDaysOfMonth);
    jpDateTime.add(BorderLayout.SOUTH, jpTime);
    jbOK = new JButton(res.getString("DDateTimeChooser.jbOK.text"));
    jbOK.addActionListener(new ActionListener() {

        @Override
        public void actionPerformed(ActionEvent evt) {
            okPressed();
        }
    });
    jbCancel = new JButton(res.getString("DDateTimeChooser.jbCancel.text"));
    jbCancel.addActionListener(new ActionListener() {

        @Override
        public void actionPerformed(ActionEvent evt) {
            cancelPressed();
        }
    });
    jbCancel.getInputMap(JComponent.WHEN_IN_FOCUSED_WINDOW).put(KeyStroke.getKeyStroke(KeyEvent.VK_ESCAPE, 0), CANCEL_KEY);
    jbCancel.getActionMap().put(CANCEL_KEY, new AbstractAction() {

        private static final long serialVersionUID = 1L;

        @Override
        public void actionPerformed(ActionEvent evt) {
            cancelPressed();
        }
    });
    jpButtons = PlatformUtil.createDialogButtonPanel(jbOK, jbCancel, false);
    getContentPane().setLayout(new BorderLayout());
    getContentPane().add(BorderLayout.CENTER, jpDateTime);
    getContentPane().add(BorderLayout.SOUTH, jpButtons);
    if (date == null) {
        date = new Date();
    }
    populate(date);
    setResizable(false);
    getRootPane().setDefaultButton(jbOK);
    pack();
}
Also used : JPanel(javax.swing.JPanel) ItemEvent(java.awt.event.ItemEvent) FlowLayout(java.awt.FlowLayout) ActionEvent(java.awt.event.ActionEvent) KeyAdapter(java.awt.event.KeyAdapter) JButton(javax.swing.JButton) FocusEvent(java.awt.event.FocusEvent) KeyEvent(java.awt.event.KeyEvent) MatteBorder(javax.swing.border.MatteBorder) BorderLayout(java.awt.BorderLayout) ChangeListener(javax.swing.event.ChangeListener) CompoundBorder(javax.swing.border.CompoundBorder) EmptyBorder(javax.swing.border.EmptyBorder) AbstractAction(javax.swing.AbstractAction) MouseEvent(java.awt.event.MouseEvent) MouseAdapter(java.awt.event.MouseAdapter) JLabel(javax.swing.JLabel) Date(java.util.Date) EtchedBorder(javax.swing.border.EtchedBorder) ChangeEvent(javax.swing.event.ChangeEvent) ActionListener(java.awt.event.ActionListener) JSpinner(javax.swing.JSpinner) ItemListener(java.awt.event.ItemListener) SpinnerListModel(javax.swing.SpinnerListModel) FocusListener(java.awt.event.FocusListener)

Example 88 with KeyEvent

use of java.awt.event.KeyEvent in project keystore-explorer by kaikramer.

the class JPasswordQualityField method initComponents.

private void initComponents(int columns) {
    jpfPassword = new JPasswordField(columns);
    GridBagConstraints gbc_jpfPassword = new GridBagConstraints();
    gbc_jpfPassword.gridwidth = 1;
    gbc_jpfPassword.gridheight = 1;
    gbc_jpfPassword.gridx = 0;
    gbc_jpfPassword.gridy = 0;
    gbc_jpfPassword.insets = new Insets(0, 0, 1, 0);
    gbc_jpfPassword.fill = GridBagConstraints.HORIZONTAL;
    if (getMinPasswordQuality() >= 0) {
        jpqmQuality = new JPasswordQualityMeter(getMinPasswordQuality());
    } else {
        jpqmQuality = new JPasswordQualityMeter();
    }
    jpqmQuality.setPreferredSize(new Dimension(0, 6));
    initQualityBar();
    GridBagConstraints gbc_jpbQuality = new GridBagConstraints();
    gbc_jpbQuality.gridwidth = 1;
    gbc_jpbQuality.gridheight = 1;
    gbc_jpbQuality.gridx = 0;
    gbc_jpbQuality.gridy = 1;
    gbc_jpbQuality.insets = new Insets(0, 0, 0, 0);
    gbc_jpbQuality.fill = GridBagConstraints.HORIZONTAL;
    jpfPassword.addKeyListener(new KeyAdapter() {

        @Override
        public void keyReleased(KeyEvent evt) {
            passwordChanged();
        }
    });
    setLayout(new GridBagLayout());
    add(jpfPassword, gbc_jpfPassword);
    add(jpqmQuality, gbc_jpbQuality);
}
Also used : KeyEvent(java.awt.event.KeyEvent) GridBagConstraints(java.awt.GridBagConstraints) Insets(java.awt.Insets) GridBagLayout(java.awt.GridBagLayout) JPasswordField(javax.swing.JPasswordField) KeyAdapter(java.awt.event.KeyAdapter) Dimension(java.awt.Dimension)

Example 89 with KeyEvent

use of java.awt.event.KeyEvent in project cytoscape-impl by cytoscape.

the class NetworkViewMainPanel method addNetworkView.

public RenderingEngine<CyNetwork> addNetworkView(final CyNetworkView view, final RenderingEngineFactory<CyNetwork> engineFactory, final RenderingEngineFactory<CyNetwork> thumbnailFactory) {
    if (isRendered(view))
        return null;
    final NetworkViewContainer vc = new NetworkViewContainer(view, view.equals(getCurrentNetworkView()), engineFactory, thumbnailFactory, gridViewToggleModel, serviceRegistrar);
    vc.getDetachViewButton().addActionListener(evt -> {
        detachNetworkView(view);
    });
    vc.getReattachViewButton().addActionListener(evt -> {
        reattachNetworkView(view);
    });
    vc.getExportButton().addActionListener(evt -> {
        showExportPopup(vc.getExportButton(), view);
    });
    vc.getViewTitleTextField().addActionListener(evt -> {
        changeCurrentViewTitle(vc);
        vc.requestFocusInWindow();
    });
    vc.getViewTitleTextField().addKeyListener(new KeyAdapter() {

        @Override
        public void keyPressed(KeyEvent e) {
            if (e.getKeyCode() == KeyEvent.VK_ESCAPE)
                cancelViewTitleChange(vc);
        }
    });
    vc.getViewTitleTextField().addFocusListener(new FocusAdapter() {

        @Override
        public void focusLost(FocusEvent e) {
            changeCurrentViewTitle(vc);
            vc.requestFocusInWindow();
            Toolkit.getDefaultToolkit().addAWTEventListener(mousePressedAWTEventListener, MouseEvent.MOUSE_EVENT_MASK);
        }

        @Override
        public void focusGained(FocusEvent e) {
            Toolkit.getDefaultToolkit().removeAWTEventListener(mousePressedAWTEventListener);
        }
    });
    allViewContainers.put(view, vc);
    viewCards.put(vc.getName(), vc);
    networkViewGrid.addItem(vc.getRenderingEngine(), vc.getThumbnailEngineFactory());
    getContentPane().add(vc, vc.getName());
    if (isGridMode())
        updateGrid();
    return vc.getRenderingEngine();
}
Also used : KeyEvent(java.awt.event.KeyEvent) FocusAdapter(java.awt.event.FocusAdapter) KeyAdapter(java.awt.event.KeyAdapter) FocusEvent(java.awt.event.FocusEvent)

Example 90 with KeyEvent

use of java.awt.event.KeyEvent in project cytoscape-impl by cytoscape.

the class InstallAppsPanel method initComponents.

private void initComponents() {
    searchAppsLabel = new JLabel("Search:");
    installFromFileButton = new JButton("Install from File...");
    filterTextField = new JTextField();
    descriptionSplitPane = new JSplitPane();
    tagsSplitPane = new JSplitPane();
    tagsScrollPane = new JScrollPane();
    tagsTree = new JTree();
    resultsScrollPane = new JScrollPane();
    resultsTree = new JTree();
    descriptionPanel = new JPanel();
    descriptionScrollPane = new JScrollPane();
    descriptionTextPane = new JTextPane();
    viewOnAppStoreButton = new JButton("View on App Store");
    installButton = new JButton("Install");
    downloadSiteLabel = new JLabel("Download Site:");
    downloadSiteComboBox = new JComboBox();
    manageSitesButton = new JButton("Manage Sites...");
    searchAppsLabel.setVisible(!LookAndFeelUtil.isAquaLAF());
    // Aqua LAF only
    filterTextField.putClientProperty("JTextField.variant", "search");
    filterTextField.setToolTipText("To search, start typing");
    installFromFileButton.addActionListener(new ActionListener() {

        @Override
        public void actionPerformed(ActionEvent evt) {
            installFromFileButtonActionPerformed(evt);
        }
    });
    descriptionSplitPane.setBorder(null);
    descriptionSplitPane.setDividerLocation(390);
    tagsSplitPane.setDividerLocation(175);
    tagsSplitPane.setBorder(null);
    DefaultMutableTreeNode treeNode1 = new DefaultMutableTreeNode("root");
    DefaultMutableTreeNode treeNode2 = new DefaultMutableTreeNode("all apps (0)");
    DefaultMutableTreeNode treeNode3 = new DefaultMutableTreeNode("collections (0)");
    DefaultMutableTreeNode treeNode4 = new DefaultMutableTreeNode("apps by tag");
    treeNode1.add(treeNode2);
    treeNode1.add(treeNode3);
    treeNode1.add(treeNode4);
    tagsTree.setModel(new DefaultTreeModel(treeNode1));
    tagsTree.setFocusable(false);
    tagsTree.setRootVisible(false);
    tagsTree.getSelectionModel().setSelectionMode(TreeSelectionModel.SINGLE_TREE_SELECTION);
    tagsScrollPane.setViewportView(tagsTree);
    tagsSplitPane.setLeftComponent(tagsScrollPane);
    treeNode1 = new DefaultMutableTreeNode("root");
    resultsTree.setModel(new DefaultTreeModel(treeNode1));
    resultsTree.setFocusable(false);
    resultsTree.setRootVisible(false);
    resultsTree.getSelectionModel().setSelectionMode(TreeSelectionModel.SINGLE_TREE_SELECTION);
    resultsScrollPane.setViewportView(resultsTree);
    tagsSplitPane.setRightComponent(resultsScrollPane);
    descriptionSplitPane.setLeftComponent(tagsSplitPane);
    descriptionTextPane.setContentType("text/html");
    descriptionTextPane.setEditable(false);
    // descriptionTextPane.setText("<html>\n  <head>\n\n  </head>\n  <body>\n    <p style=\"margin-top: 0\">\n      App description is displayed here.\n    </p>\n  </body>\n</html>\n");
    descriptionTextPane.setText("");
    descriptionScrollPane.setViewportView(descriptionTextPane);
    final GroupLayout descriptionPanelLayout = new GroupLayout(descriptionPanel);
    descriptionPanel.setLayout(descriptionPanelLayout);
    descriptionPanelLayout.setHorizontalGroup(descriptionPanelLayout.createParallelGroup(Alignment.LEADING).addComponent(descriptionScrollPane, GroupLayout.DEFAULT_SIZE, 162, Short.MAX_VALUE));
    descriptionPanelLayout.setVerticalGroup(descriptionPanelLayout.createParallelGroup(Alignment.LEADING).addComponent(descriptionScrollPane, GroupLayout.DEFAULT_SIZE, 354, Short.MAX_VALUE));
    descriptionSplitPane.setRightComponent(descriptionPanel);
    viewOnAppStoreButton.setEnabled(false);
    viewOnAppStoreButton.addActionListener(new ActionListener() {

        public void actionPerformed(ActionEvent evt) {
            viewOnAppStoreButtonActionPerformed(evt);
        }
    });
    installButton.setEnabled(false);
    installButton.addActionListener(new ActionListener() {

        public void actionPerformed(ActionEvent evt) {
            installButtonActionPerformed(evt);
        }
    });
    downloadSiteComboBox.setModel(new DefaultComboBoxModel(new String[] { WebQuerier.DEFAULT_APP_STORE_URL }));
    downloadSiteComboBox.addItemListener(new ItemListener() {

        public void itemStateChanged(ItemEvent evt) {
            downloadSiteComboBoxItemStateChanged(evt);
        }
    });
    downloadSiteComboBox.addActionListener(new ActionListener() {

        public void actionPerformed(ActionEvent evt) {
            downloadSiteComboBoxActionPerformed(evt);
        }
    });
    downloadSiteComboBox.addKeyListener(new KeyAdapter() {

        public void keyPressed(KeyEvent evt) {
            downloadSiteComboBoxKeyPressed(evt);
        }
    });
    manageSitesButton.addActionListener(new ActionListener() {

        public void actionPerformed(ActionEvent evt) {
            manageSitesButtonActionPerformed(evt);
        }
    });
    LookAndFeelUtil.equalizeSize(installFromFileButton, viewOnAppStoreButton, installButton);
    final JSeparator sep = new JSeparator();
    final GroupLayout layout = new GroupLayout(this);
    this.setLayout(layout);
    layout.setAutoCreateContainerGaps(true);
    layout.setAutoCreateGaps(true);
    layout.setHorizontalGroup(layout.createParallelGroup(Alignment.LEADING).addGroup(layout.createSequentialGroup().addComponent(downloadSiteLabel).addComponent(downloadSiteComboBox, DEFAULT_SIZE, DEFAULT_SIZE, Short.MAX_VALUE).addComponent(manageSitesButton)).addComponent(sep, DEFAULT_SIZE, DEFAULT_SIZE, Short.MAX_VALUE).addGroup(layout.createSequentialGroup().addComponent(searchAppsLabel).addComponent(filterTextField, DEFAULT_SIZE, DEFAULT_SIZE, Short.MAX_VALUE)).addComponent(descriptionSplitPane).addGroup(layout.createSequentialGroup().addComponent(installFromFileButton).addPreferredGap(ComponentPlacement.RELATED, 80, Short.MAX_VALUE).addComponent(viewOnAppStoreButton).addComponent(installButton)));
    layout.setVerticalGroup(layout.createSequentialGroup().addGroup(layout.createParallelGroup(Alignment.BASELINE).addComponent(downloadSiteLabel).addComponent(downloadSiteComboBox, PREFERRED_SIZE, DEFAULT_SIZE, PREFERRED_SIZE).addComponent(manageSitesButton, PREFERRED_SIZE, DEFAULT_SIZE, PREFERRED_SIZE)).addComponent(sep, PREFERRED_SIZE, DEFAULT_SIZE, PREFERRED_SIZE).addGroup(layout.createParallelGroup(Alignment.BASELINE).addComponent(searchAppsLabel).addComponent(filterTextField, PREFERRED_SIZE, DEFAULT_SIZE, PREFERRED_SIZE)).addComponent(descriptionSplitPane, DEFAULT_SIZE, 360, Short.MAX_VALUE).addGroup(layout.createParallelGroup(Alignment.BASELINE).addComponent(installFromFileButton).addComponent(viewOnAppStoreButton).addComponent(installButton)));
    // Add a key listener to the download site combo box to listen for the enter key event
    final WebQuerier webQuerier = this.appManager.getWebQuerier();
    downloadSiteComboBox.getEditor().getEditorComponent().addKeyListener(new KeyAdapter() {

        @Override
        public void keyPressed(KeyEvent e) {
            final ComboBoxEditor editor = downloadSiteComboBox.getEditor();
            final Object selectedValue = editor.getItem();
            if (e.isActionKey() || e.getKeyCode() == KeyEvent.VK_ENTER) {
                if (downloadSiteComboBox.getModel() instanceof DefaultComboBoxModel && selectedValue != null) {
                    final DefaultComboBoxModel comboBoxModel = (DefaultComboBoxModel) downloadSiteComboBox.getModel();
                    SwingUtilities.invokeLater(new Runnable() {

                        @Override
                        public void run() {
                            boolean selectedAlreadyInList = false;
                            for (int i = 0; i < comboBoxModel.getSize(); i++) {
                                Object listElement = comboBoxModel.getElementAt(i);
                                if (listElement.equals(selectedValue)) {
                                    selectedAlreadyInList = true;
                                    break;
                                }
                            }
                            if (!selectedAlreadyInList) {
                                comboBoxModel.insertElementAt(selectedValue, 1);
                                editor.setItem(selectedValue);
                            }
                        }
                    });
                }
                if (webQuerier.getCurrentAppStoreUrl() != selectedValue.toString()) {
                    webQuerier.setCurrentAppStoreUrl(selectedValue.toString());
                    queryForApps();
                }
            }
        }
    });
    // Make the JTextPane render HTML using the default UI font
    Font font = UIManager.getFont("Label.font");
    String bodyRule = "body { font-family: " + font.getFamily() + "; " + "font-size: " + font.getSize() + "pt; }";
    ((HTMLDocument) descriptionTextPane.getDocument()).getStyleSheet().addRule(bodyRule);
    // Setup the TreeCellRenderer to make the app tags use the folder icon instead of the default leaf icon,
    // and have it use the opened folder icon when selected
    DefaultTreeCellRenderer tagsTreeCellRenderer = new DefaultTreeCellRenderer() {

        @Override
        public Component getTreeCellRendererComponent(JTree tree, Object value, boolean selected, boolean expanded, boolean leaf, int row, boolean hasFocus) {
            super.getTreeCellRendererComponent(tree, value, selected, expanded, leaf, row, hasFocus);
            // Make leaves use the open folder icon when selected
            if (selected && leaf)
                this.setIcon(getOpenIcon());
            return this;
        }
    };
    tagsTreeCellRenderer.setLeafIcon(tagsTreeCellRenderer.getDefaultClosedIcon());
    tagsTree.setCellRenderer(tagsTreeCellRenderer);
}
Also used : JPanel(javax.swing.JPanel) ItemEvent(java.awt.event.ItemEvent) DefaultMutableTreeNode(javax.swing.tree.DefaultMutableTreeNode) ActionEvent(java.awt.event.ActionEvent) KeyAdapter(java.awt.event.KeyAdapter) JButton(javax.swing.JButton) JTextField(javax.swing.JTextField) ComboBoxEditor(javax.swing.ComboBoxEditor) DefaultTreeCellRenderer(javax.swing.tree.DefaultTreeCellRenderer) JSeparator(javax.swing.JSeparator) Font(java.awt.Font) KeyEvent(java.awt.event.KeyEvent) JTextPane(javax.swing.JTextPane) GroupLayout(javax.swing.GroupLayout) JScrollPane(javax.swing.JScrollPane) JComboBox(javax.swing.JComboBox) JLabel(javax.swing.JLabel) DefaultTreeModel(javax.swing.tree.DefaultTreeModel) DefaultComboBoxModel(javax.swing.DefaultComboBoxModel) JTree(javax.swing.JTree) ActionListener(java.awt.event.ActionListener) ItemListener(java.awt.event.ItemListener) JSplitPane(javax.swing.JSplitPane) WebQuerier(org.cytoscape.app.internal.net.WebQuerier)

Aggregations

KeyEvent (java.awt.event.KeyEvent)301 KeyAdapter (java.awt.event.KeyAdapter)159 MouseEvent (java.awt.event.MouseEvent)79 ActionEvent (java.awt.event.ActionEvent)74 JPanel (javax.swing.JPanel)69 ActionListener (java.awt.event.ActionListener)61 MouseAdapter (java.awt.event.MouseAdapter)59 KeyListener (java.awt.event.KeyListener)54 Dimension (java.awt.Dimension)50 JLabel (javax.swing.JLabel)48 JTextField (javax.swing.JTextField)44 BorderLayout (java.awt.BorderLayout)40 JButton (javax.swing.JButton)40 JScrollPane (javax.swing.JScrollPane)35 Insets (java.awt.Insets)33 Point (java.awt.Point)33 FocusEvent (java.awt.event.FocusEvent)31 GridBagConstraints (java.awt.GridBagConstraints)23 BoxLayout (javax.swing.BoxLayout)22 GridBagLayout (java.awt.GridBagLayout)20