📄 entrypanel.java
字号:
{ b.append(i + ". " + inputFormats[i].getClass().getName() + "\n " + inputFormats[i] + "\n"); } } b.append("\n\n"); b.append("Output Formats ---->\n\n"); if (outputFormats != null) { for (int i = 0; i < outputFormats.length; ++i) { b.append(i + ". " + outputFormats[i].getClass().getName() + "\n " + outputFormats[i] + "\n"); } } // TODO: other types case TYPE_MIME_TYPES: final String mimeType = (String) selectedValue; final List extensions = MimeManager.getExtensions(mimeType); for (int i = 0; i < extensions.size(); ++i) { b.append((String) extensions.get(i) + "\n"); } break; default: } detailsListener.onDetails(b.toString()); } /** * This method initializes this * */ private void initialize() { this.setLayout(new BorderLayout()); this.setSize(new Dimension(313, 280)); this.add(getActionPanel(), BorderLayout.EAST); this.add(getEntryPanel(), BorderLayout.CENTER); load(); } /** * This method initializes actionPanel * * @return javax.swing.JPanel */ private JPanel getActionPanel() { if (actionPanel == null) { final Insets insets = new Insets(2, 2, 2, 2); GridBagConstraints gridBagConstraints4 = new GridBagConstraints(); gridBagConstraints4.insets = insets; gridBagConstraints4.gridx = 0; gridBagConstraints4.gridy = 4; gridBagConstraints4.fill = GridBagConstraints.HORIZONTAL; GridBagConstraints gridBagConstraints3 = new GridBagConstraints(); gridBagConstraints3.insets = insets; gridBagConstraints3.gridx = 0; gridBagConstraints3.gridy = 3; gridBagConstraints3.fill = GridBagConstraints.HORIZONTAL; GridBagConstraints gridBagConstraints2 = new GridBagConstraints(); gridBagConstraints2.insets = insets; gridBagConstraints2.gridx = 0; gridBagConstraints2.gridy = 2; gridBagConstraints2.fill = GridBagConstraints.HORIZONTAL; GridBagConstraints gridBagConstraints1 = new GridBagConstraints(); gridBagConstraints1.insets = insets; gridBagConstraints1.gridx = 0; gridBagConstraints1.gridy = 1; gridBagConstraints1.fill = GridBagConstraints.HORIZONTAL; GridBagConstraints gridBagConstraints = new GridBagConstraints(); gridBagConstraints.insets = insets; gridBagConstraints.gridx = 0; gridBagConstraints.gridy = 0; gridBagConstraints.fill = GridBagConstraints.HORIZONTAL; actionPanel = new JPanel(); actionPanel.setLayout(new GridBagLayout()); //actionPanel.setPreferredSize(new Dimension(100, 0)); actionPanel.add(getAddButton(), gridBagConstraints); if (canMoveItems()) { actionPanel.add(getMoveUpButton(), gridBagConstraints1); actionPanel.add(getMoveDownButton(), gridBagConstraints2); } actionPanel.add(getRemoveButton(), gridBagConstraints3); actionPanel.add(getCommitButton(), gridBagConstraints4); } return actionPanel; } private boolean canMoveItems() { if (type == TYPE_MIME_TYPES) return false; return true; // TODO: others that cannot be moved? } /** * This method initializes addButton * * @return javax.swing.JButton */ private JButton getAddButton() { if (addButton == null) { addButton = new JButton(); addButton.setText("Add"); addButton.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent e) { final String value1 = getEntryTextField().getText(); final String value2; if (getEntryTextField2() != null) value2 = getEntryTextField2().getText(); else value2 = null; addEntry(value1, value2); } }); } return addButton; } /** * This method initializes moveUpButton * * @return javax.swing.JButton */ private JButton getMoveUpButton() { if (moveUpButton == null) { moveUpButton = new JButton(); moveUpButton.setText("Move Up"); moveUpButton.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent e) { int[] selectedIndices = getEntryList().getSelectedIndices(); for (int i=0; i<selectedIndices.length; i++) { int index = selectedIndices[i]; if (index == 0) { // dn't allow movement beyond start of list break; } Object entry = getEntryListModel().getElementAt(index); getEntryListModel().removeElementAt(index); getEntryListModel().insertElementAt(entry, index-1); selectedIndices[i]--; } getEntryList().setSelectedIndices(selectedIndices); } }); } return moveUpButton; } /** * This method initializes moveDownButton * * @return javax.swing.JButton */ private JButton getMoveDownButton() { if (moveDownButton == null) { moveDownButton = new JButton(); moveDownButton.setText("Move Down"); moveDownButton.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent e) { int[] selectedIndices = getEntryList().getSelectedIndices(); for (int i=selectedIndices.length-1; i>=0; i--) { int index = selectedIndices[i]; if (index == getEntryListModel().getSize()-1) { // don't allow movement beyond end of list return; } Object entry = getEntryListModel().getElementAt(index); getEntryListModel().removeElementAt(index); getEntryListModel().insertElementAt(entry, index+1); selectedIndices[i]++; } getEntryList().setSelectedIndices(selectedIndices); } }); } return moveDownButton; } /** * This method initializes removeButton * * @return javax.swing.JButton */ private JButton getRemoveButton() { if (removeButton == null) { removeButton = new JButton(); removeButton.setText("Remove"); removeButton.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent e) { int[] selectedIndices = getEntryList().getSelectedIndices(); for (int i=selectedIndices.length-1; i>=0; i--) { int index = selectedIndices[i]; Object entry = getEntryListModel().getElementAt(index); // remove plugin String value = (String) getEntryListModel().getElementAt(index); removeEntry(value); } } }); } return removeButton; } /** * This method initializes commitButton * * @return javax.swing.JButton */ private JButton getCommitButton() { if (commitButton == null) { commitButton = new JButton(); commitButton.setText("Commit"); commitButton.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent e) { commit(); } }); } return commitButton; } /** * This method initializes entryPanel * * @return javax.swing.JPanel */ private JPanel getEntryPanel() { if (entryPanel == null) { entryPanel = new JPanel(); entryPanel.setLayout(new BorderLayout()); entryPanel.add(getEntryTopPanel(), BorderLayout.NORTH); //entryPanel.add(getEntryList(), BorderLayout.CENTER); entryPanel.add(getListScrollPane(), BorderLayout.CENTER); } return entryPanel; } /** * This method initializes entryTopPanel * * @return javax.swing.JPanel */ private JPanel getEntryTopPanel() { if (entryTopPanel == null) { entryTopPanel = new JPanel(); final int rows = usesSecondEntryTextField() ? 3 : 2; entryTopPanel.setLayout(new GridLayout(rows, 1)); entryTopPanel.add(getEntryLabel()); entryTopPanel.add(getEntryTextField()); if (usesSecondEntryTextField()) entryTopPanel.add(getEntryTextField2()); } return entryTopPanel; } private boolean usesSecondEntryTextField() { return type == TYPE_MIME_TYPES; } private JLabel getEntryLabel() { if (entryLabel == null) { entryLabel = new JLabel(); entryLabel.setText("Title"); } return entryLabel; } /** * This method initializes entryTextField * * @return javax.swing.JTextField */ private JTextField getEntryTextField() { if (entryTextField == null) { entryTextField = new JTextField(); entryTextField.setEditable(true); } return entryTextField; } /** * This method initializes entryTextField2 * * @return javax.swing.JTextField */ private JTextField getEntryTextField2() { if (type != TYPE_MIME_TYPES) return null; if (entryTextField2 == null) { entryTextField2 = new JTextField(); entryTextField2.setEditable(true); } return entryTextField2; } /** * This method initializes entryList * * @return javax.swing.JList */ private JList getEntryList() { if (entryList == null) { entryList = new JList(getEntryListModel()); entryList.setDragEnabled(true); entryList.setSelectionMode(ListSelectionModel.SINGLE_SELECTION); entryList.addListSelectionListener(new ListSelectionListener() { public void valueChanged(ListSelectionEvent e) { if (!e.getValueIsAdjusting()) updateDetailsPane(entryList.getSelectedIndex(), entryList.getSelectedValue()); //logger.fine("e.getValueIsAdjusting()=" + e.getValueIsAdjusting() + "first=" + e.getFirstIndex() + "; last=" + e.getLastIndex() + "; index=" + entryList.getSelectedIndex() + "; o=" + entryList.getSelectedValue()); } }); } return entryList; } /** * This method initializes entryListModel * * @return javax.swing.DefaultComboBoxModel */ private DefaultComboBoxModel getEntryListModel() { if (entryListModel == null) { entryListModel = new DefaultComboBoxModel(); } return entryListModel; } /** * This method initializes listScrollPane * * @return javax.swing.JScrollPane */ private JScrollPane getListScrollPane() { if (listScrollPane == null) { listScrollPane = new JScrollPane(getEntryList()); } return listScrollPane; } public DetailsListener getDetailsListener() { return detailsListener; } public void setDetailsListener(DetailsListener detailsListener) { this.detailsListener = detailsListener; }} // @jve:decl-index=0:visual-constraint="10,10"
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -