List of usage examples for java.awt.event KeyAdapter KeyAdapter
KeyAdapter
From source file:org.scify.talkandplay.gui.users.UserFormPanel.java
/** * The action listeners for the text fields and radio buttons *//*from w w w . j a v a 2s .c om*/ private void setActionListeners() { selectionSensorTextField1.addMouseListener(new MouseAdapter() { public void mouseClicked(MouseEvent me) { if (selectionSensorTextField1.isEnabled()) { selectionSensor = new MouseSensor(me.getButton(), me.getClickCount(), "mouse"); navigationSensor = null; selectionSensorTextField1.setText(setSensorText(selectionSensor)); } } }); selectionSensorTextField1.addKeyListener(new KeyAdapter() { public void keyReleased(KeyEvent ke) { if (selectionSensorTextField1.isEnabled()) { selectionSensor = new KeyboardSensor(ke.getKeyCode(), String.valueOf(ke.getKeyChar()), "keyboard"); navigationSensor = null; selectionSensorTextField1.setText(setSensorText(selectionSensor)); } } }); navigationSensorTextField.addMouseListener(new MouseAdapter() { public void mouseClicked(MouseEvent me) { if (navigationSensorTextField.isEnabled()) { navigationSensor = new MouseSensor(me.getButton(), me.getClickCount(), "mouse"); navigationSensorTextField.setText(setSensorText(navigationSensor)); } } }); navigationSensorTextField.addKeyListener(new KeyAdapter() { public void keyReleased(KeyEvent ke) { if (navigationSensorTextField.isEnabled()) { navigationSensor = new KeyboardSensor(ke.getKeyCode(), String.valueOf(ke.getKeyChar()), "keyboard"); navigationSensorTextField.setText(setSensorText(navigationSensor)); } } }); selectionSensorTextField2.addMouseListener(new MouseAdapter() { public void mouseClicked(MouseEvent me) { if (selectionSensorTextField2.isEnabled()) { selectionSensor = new MouseSensor(me.getButton(), me.getClickCount(), "mouse"); selectionSensorTextField2.setText(setSensorText(selectionSensor)); } } }); selectionSensorTextField2.addKeyListener(new KeyAdapter() { public void keyReleased(KeyEvent ke) { if (selectionSensorTextField2.isEnabled()) { selectionSensor = new KeyboardSensor(ke.getKeyCode(), String.valueOf(ke.getKeyChar()), "keyboard"); selectionSensorTextField2.setText(setSensorText(selectionSensor)); } } }); backButton.addMouseListener(new MouseAdapter() { public void mouseClicked(MouseEvent me) { parent.changePanel(new MainPanel(parent)); } }); autoScanRadioButton.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent ae) { if (autoScanRadioButton.isSelected()) { disableTextField(selectionSensorTextField2); disableTextField(navigationSensorTextField); enableTextField(selectionSensorTextField1); } } }); manualScanRadioButton.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent ae) { if (manualScanRadioButton.isSelected()) { disableTextField(selectionSensorTextField1); enableTextField(selectionSensorTextField2); enableTextField(navigationSensorTextField); } } }); }
From source file:com.peterbochs.instrument.InstrumentPanel.java
private JSearchTextField getJSearchTextField() { if (jSearchTextField == null) { jSearchTextField = new JSearchTextField(); jSearchTextField.addKeyListener(new KeyAdapter() { public void keyPressed(KeyEvent evt) { jSearchTextFieldKeyPressed(evt); }//from w w w . j ava 2 s . c o m }); } return jSearchTextField; }
From source file:com.mirth.connect.client.ui.browsers.message.MessageBrowser.java
/** * Sets the properties and adds the listeners for the Message Table. No data is loaded at this * point.//from w ww . jav a 2 s.c o m */ private void makeMessageTable() { messageTreeTable.setDragEnabled(true); messageTreeTable.setSortable(false); messageTreeTable.setSelectionMode(ListSelectionModel.SINGLE_SELECTION); messageTreeTable.setColumnFactory(new MessageBrowserTableColumnFactory()); messageTreeTable.setLeafIcon(null); messageTreeTable.setOpenIcon(null); messageTreeTable.setClosedIcon(null); messageTreeTable.setAutoCreateColumnsFromModel(false); messageTreeTable.setMirthColumnControlEnabled(true); messageTreeTable.setShowGrid(true, true); messageTreeTable.setHorizontalScrollEnabled(true); messageTreeTable.setPreferredScrollableViewportSize(messageTreeTable.getPreferredSize()); messageTreeTable.setMirthTransferHandlerEnabled(true); tableModel = new MessageBrowserTableModel(columnMap.size()); // Add a blank column to the column initially, otherwise it return an exception on load // Columns will be re-generated when the message browser is viewed tableModel.setColumnIdentifiers(Arrays.asList(new String[] { "" })); messageTreeTable.setTreeTableModel(tableModel); // Sets the alternating highlighter for the table if (Preferences.userNodeForPackage(Mirth.class).getBoolean("highlightRows", true)) { Highlighter highlighter = HighlighterFactory.createAlternateStriping(UIConstants.HIGHLIGHTER_COLOR, UIConstants.BACKGROUND_COLOR); messageTreeTable.setHighlighters(highlighter); } // Add the listener for when the table selection changes messageTreeTable.getSelectionModel().addListSelectionListener(new ListSelectionListener() { @Override public void valueChanged(ListSelectionEvent evt) { MessageListSelected(evt); } }); // Add the mouse listener messageTreeTable.addMouseListener(new java.awt.event.MouseAdapter() { public void mousePressed(java.awt.event.MouseEvent evt) { checkMessageSelectionAndPopupMenu(evt); } public void mouseReleased(java.awt.event.MouseEvent evt) { checkMessageSelectionAndPopupMenu(evt); } // Opens the send message dialog when a message is double clicked. // If the root message or source connector is selected, select all destination connectors initially // If a destination connector is selected, select only that destination connector initially public void mouseClicked(java.awt.event.MouseEvent evt) { if (evt.getClickCount() >= 2) { int row = getSelectedMessageIndex(); if (row >= 0) { MessageBrowserTableNode messageNode = (MessageBrowserTableNode) messageTreeTable .getPathForRow(row).getLastPathComponent(); if (messageNode.isNodeActive()) { Long messageId = messageNode.getMessageId(); Integer metaDataId = messageNode.getMetaDataId(); Message currentMessage = messageCache.get(messageId); ConnectorMessage connectorMessage = currentMessage.getConnectorMessages() .get(metaDataId); List<Integer> selectedMetaDataIds = new ArrayList<Integer>(); Map<String, Object> sourceMap = new HashMap<String, Object>(); if (connectorMessage.getSourceMap() != null) { sourceMap.putAll(connectorMessage.getSourceMap()); // Remove the destination set if it exists, because that will be determined by the selected metadata IDs sourceMap.remove("destinationSet"); } if (metaDataId == 0) { selectedMetaDataIds = null; } else { selectedMetaDataIds.add(metaDataId); } if (connectorMessage.getRaw() != null) { parent.editMessageDialog.setPropertiesAndShow( connectorMessage.getRaw().getContent(), connectorMessage.getRaw().getDataType(), channelId, parent.dashboardPanel.getDestinationConnectorNames(channelId), selectedMetaDataIds, sourceMap); } } } } } }); // Key Listener trigger for DEL messageTreeTable.addKeyListener(new KeyAdapter() { public void keyPressed(KeyEvent e) { int row = getSelectedMessageIndex(); if (row >= 0) { if (e.getKeyCode() == KeyEvent.VK_DELETE) { MessageBrowserTableNode messageNode = (MessageBrowserTableNode) messageTreeTable .getPathForRow(row).getLastPathComponent(); if (messageNode.isNodeActive()) { parent.doRemoveMessage(); } } else if (descriptionTabbedPane.getTitleAt(descriptionTabbedPane.getSelectedIndex()) .equals("Messages")) { if (e.getKeyCode() == KeyEvent.VK_LEFT) { List<AbstractButton> buttons = Collections.list(messagesGroup.getElements()); boolean passedSelected = false; for (int i = buttons.size() - 1; i >= 0; i--) { AbstractButton button = buttons.get(i); if (passedSelected && button.isShowing()) { lastUserSelectedMessageType = buttons.get(i).getText(); updateMessageRadioGroup(); break; } else if (button.isSelected()) { passedSelected = true; } } } else if (e.getKeyCode() == KeyEvent.VK_RIGHT) { List<AbstractButton> buttons = Collections.list(messagesGroup.getElements()); boolean passedSelected = false; for (int i = 0; i < buttons.size(); i++) { AbstractButton button = buttons.get(i); if (passedSelected && button.isShowing()) { lastUserSelectedMessageType = buttons.get(i).getText(); updateMessageRadioGroup(); break; } else if (button.isSelected()) { passedSelected = true; } } } } } } }); }
From source file:gtu._work.ui.DirectoryCompareUI.java
private JTextField getSearchText() { if (searchText == null) { searchText = new JTextField(); ToolTipManager.sharedInstance().setInitialDelay(0); searchText.setToolTipText(/*from w w w . j a v a 2 s . c om*/ ": date >= 20140829, ?: size < 1mb, ??: name *= action, path *= WEB-INF [:" + SEARCHTEXTPATTERN.pattern() + "]"); searchText.setPreferredSize(new java.awt.Dimension(222, 24)); searchText.addKeyListener(new KeyAdapter() { public void keyPressed(KeyEvent evt) { System.out.println("KeyEvent.getKeyCode = " + evt.getKeyCode()); int[] keyCodeIgnore = new int[] { 38, 40, 37, 39, 8, 17, 18, 16 }; if (!ArrayUtils.contains(keyCodeIgnore, evt.getKeyCode())) { totalScanFiles(evt); } } }); } return searchText; }
From source file:de.codesourcery.jasm16.ide.ui.views.SourceCodeView.java
protected final void setupKeyBindings(final JTextPane editor) { // 'Save' action addKeyBinding(editor, KeyStroke.getKeyStroke(KeyEvent.VK_S, Event.CTRL_MASK), new AbstractAction() { @Override/*from www . j av a2s . c om*/ public void actionPerformed(ActionEvent e) { saveCurrentFile(); } }); // 'Underline text when pressing CTRL while hovering over an identifier' editorPane.addKeyListener(new KeyAdapter() { private boolean isControlKey(KeyEvent e) { return e.getKeyCode() == KeyEvent.VK_CONTROL; } public void keyPressed(KeyEvent e) { if (isControlKey(e)) { final Point ptr = getMouseLocation(); if (ptr != null) { maybeUnderlineIdentifierAt(ptr); } } } public void keyReleased(KeyEvent e) { if (isControlKey(e)) { clearUnderlineHighlight(); } }; }); // "Undo" action addKeyBinding(editor, KeyStroke.getKeyStroke(KeyEvent.VK_Z, Event.CTRL_MASK), undoAction); addKeyBinding(editor, KeyStroke.getKeyStroke(KeyEvent.VK_Y, Event.CTRL_MASK), redoAction); // 'Search' action addKeyBinding(editor, KeyStroke.getKeyStroke(KeyEvent.VK_F, Event.CTRL_MASK), new AbstractAction() { @Override public void actionPerformed(ActionEvent e) { showSearchDialog(); } }); setupKeyBindingsHook(editor); }
From source file:net.sf.jabref.gui.BasePanel.java
private void createMainTable() { database.registerListener(tableModel.getListSynchronizer()); database.registerListener(SpecialFieldDatabaseChangeListener.getInstance()); tableFormat = new MainTableFormat(database); tableFormat.updateTableFormat();//from w ww . j av a 2 s . co m mainTable = new MainTable(tableFormat, tableModel, frame, this); selectionListener = new MainTableSelectionListener(this, mainTable); mainTable.updateFont(); mainTable.addSelectionListener(selectionListener); mainTable.addMouseListener(selectionListener); mainTable.addKeyListener(selectionListener); mainTable.addFocusListener(selectionListener); // Add the listener that will take care of highlighting groups as the selection changes: groupsHighlightListener = listEvent -> { HighlightMatchingGroupPreferences highlightMatchingGroupPreferences = new HighlightMatchingGroupPreferences( Globals.prefs); if (highlightMatchingGroupPreferences.isAny()) { getGroupSelector().showMatchingGroups(mainTable.getSelectedEntries(), false); } else if (highlightMatchingGroupPreferences.isAll()) { getGroupSelector().showMatchingGroups(mainTable.getSelectedEntries(), true); } else { // no highlight getGroupSelector().showMatchingGroups(null, true); } }; mainTable.addSelectionListener(groupsHighlightListener); mainTable.getActionMap().put(Actions.CUT, new AbstractAction() { @Override public void actionPerformed(ActionEvent e) { try { runCommand(Actions.CUT); } catch (Throwable ex) { LOGGER.warn("Could not cut", ex); } } }); mainTable.getActionMap().put(Actions.COPY, new AbstractAction() { @Override public void actionPerformed(ActionEvent e) { try { runCommand(Actions.COPY); } catch (Throwable ex) { LOGGER.warn("Could not copy", ex); } } }); mainTable.getActionMap().put(Actions.PASTE, new AbstractAction() { @Override public void actionPerformed(ActionEvent e) { try { runCommand(Actions.PASTE); } catch (Throwable ex) { LOGGER.warn("Could not paste", ex); } } }); mainTable.addKeyListener(new KeyAdapter() { @Override public void keyPressed(KeyEvent e) { final int keyCode = e.getKeyCode(); final TreePath path = frame.getGroupSelector().getSelectionPath(); final GroupTreeNodeViewModel node = path == null ? null : (GroupTreeNodeViewModel) path.getLastPathComponent(); if (e.isControlDown()) { switch (keyCode) { // The up/down/left/rightkeystrokes are displayed in the // GroupSelector's popup menu, so if they are to be changed, // edit GroupSelector.java accordingly! case KeyEvent.VK_UP: e.consume(); if (node != null) { frame.getGroupSelector().moveNodeUp(node, true); } break; case KeyEvent.VK_DOWN: e.consume(); if (node != null) { frame.getGroupSelector().moveNodeDown(node, true); } break; case KeyEvent.VK_LEFT: e.consume(); if (node != null) { frame.getGroupSelector().moveNodeLeft(node, true); } break; case KeyEvent.VK_RIGHT: e.consume(); if (node != null) { frame.getGroupSelector().moveNodeRight(node, true); } break; case KeyEvent.VK_PAGE_DOWN: frame.nextTab.actionPerformed(null); e.consume(); break; case KeyEvent.VK_PAGE_UP: frame.prevTab.actionPerformed(null); e.consume(); break; default: break; } } else if (keyCode == KeyEvent.VK_ENTER) { e.consume(); try { runCommand(Actions.EDIT); } catch (Throwable ex) { LOGGER.warn("Could not run action based on key press", ex); } } } }); }
From source file:ru.goodfil.catalog.ui.forms.FiltersPanel.java
private void initComponents() { // JFormDesigner - Component initialization - DO NOT MODIFY //GEN-BEGIN:initComponents // Generated using JFormDesigner Evaluation license - ???? ?????? panel2 = new JPanel(); panel12 = new JPanel(); label5 = new JLabel(); tbFilterCode = new JTextField(); btnSearchFilter = new JButton(); panel13 = new JPanel(); hSpacer1 = new JPanel(null); btnJoinFilters = new JButton(); btnCreateFilter = new JButton(); btnEditFilter = new JButton(); btnRemoveFilter = new JButton(); srcTblFilters = new JScrollPane(); tblFilters = new JTable(); panel15 = new JPanel(); label6 = new JLabel(); cbManufactors = new JComboBox(); label7 = new JLabel(); cbSeria = new JComboBox(); btnClearSearchModel = new JButton(); btnSearchMotors = new JButton(); panel1 = new JPanel(); label1 = new JLabel(); tbSeria = new JTextField(); label2 = new JLabel(); tbModel = new JTextField(); label3 = new JLabel(); tbEngine = new JTextField(); label4 = new JLabel(); tbDateF = new JTextField(); label9 = new JLabel(); tbDateT = new JTextField(); scrollPane11 = new JScrollPane(); tblMotors = new JTable(); panel18 = new JPanel(); btnAttachMotor = new JButton(); btnDetachMotor = new JButton(); vSpacer2 = new JPanel(null); scrollPane12 = new JScrollPane(); tblAllMotors = new JTable(); panel16 = new JPanel(); hSpacer3 = new JPanel(null); panel17 = new JPanel(); label8 = new JLabel(); tbOe = new JTextField(); btnOeSearch = new JButton(); scrollPane7 = new JScrollPane(); tblOes = new JTable(); panel19 = new JPanel(); btnAttachOe = new JButton(); btnDetachOe = new JButton(); vSpacer3 = new JPanel(null); scrollPane8 = new JScrollPane(); tblAllOes = new JTable(); tablesPopupMenu = new JPopupMenu(); miFullCopyToExcel = new JMenuItem(); menu1 = new JMenu(); miCopySelectedToExcel = new JMenuItem(); miCopyToExcel = new JMenuItem(); menu2 = new JMenu(); miCopySelectedToBuffer = new JMenuItem(); miCopyToBuffer = new JMenuItem(); miPasteFromBuffer = new JMenuItem(); miShowOnSiteMenu = new JMenu(); miShowOnSite = new JMenuItem(); miDontShowOnSite = new JMenuItem(); miApplyToAllMenu = new JMenu(); miApplyToVT1 = new JMenuItem(); miApplyToVT2 = new JMenuItem(); miApplyToVT3 = new JMenuItem(); miApplyToVT4 = new JMenuItem(); miDontApplyToAll = new JMenuItem(); CellConstraints cc = new CellConstraints(); //======== this ======== setMinimumSize(new Dimension(300, 207)); // JFormDesigner evaluation mark setBorder(/*from w w w .ja v a 2s . com*/ new javax.swing.border.CompoundBorder( new javax.swing.border.TitledBorder(new javax.swing.border.EmptyBorder(0, 0, 0, 0), "JFormDesigner Evaluation", javax.swing.border.TitledBorder.CENTER, javax.swing.border.TitledBorder.BOTTOM, new java.awt.Font("Dialog", java.awt.Font.BOLD, 12), java.awt.Color.red), getBorder())); addPropertyChangeListener(new java.beans.PropertyChangeListener() { public void propertyChange(java.beans.PropertyChangeEvent e) { if ("border".equals(e.getPropertyName())) throw new RuntimeException(); } }); setLayout(new FormLayout("default:grow", "fill:default:grow")); //======== panel2 ======== { panel2.setLayout(new FormLayout("default:grow, $lcgap, 21dlu, $lcgap, default:grow", "default, default:grow, $lgap, default, fill:default:grow, $lgap, default, fill:default:grow")); //======== panel12 ======== { panel12.setLayout(new FormLayout("default, default:grow, 21dlu", "default")); //---- label5 ---- label5.setText("\u0418\u0437\u0434\u0435\u043b\u0438\u0435"); panel12.add(label5, cc.xy(1, 1)); //---- tbFilterCode ---- tbFilterCode.setToolTipText( "\u0412\u0432\u0435\u0434\u0438\u0442\u0435 \u0442\u0435\u043a\u0441\u0442 \u0434\u043b\u044f \u043f\u043e\u0438\u0441\u043a\u0430 \u0444\u0438\u043b\u044c\u0442\u0440\u0430"); tbFilterCode.addKeyListener(new KeyAdapter() { @Override public void keyPressed(KeyEvent e) { tbFilterCodeKeyPressed(e); } @Override public void keyTyped(KeyEvent e) { tbFilterCodeKeyPressed(e); } }); tbFilterCode.addFocusListener(new FocusAdapter() { @Override public void focusGained(FocusEvent e) { tbFilterCodeFocusGained(e); } @Override public void focusLost(FocusEvent e) { tbFilterCodeFocusGained(e); } }); panel12.add(tbFilterCode, cc.xy(2, 1)); //---- btnSearchFilter ---- btnSearchFilter.setIcon( new ImageIcon(getClass().getResource("/ru/goodfil/catalog/ui/icons/find_next_24.png"))); btnSearchFilter.setToolTipText("\u041f\u043e\u0438\u0441\u043a"); btnSearchFilter.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { btnSearchFilterActionPerformed(e); } }); panel12.add(btnSearchFilter, cc.xy(3, 1)); } panel2.add(panel12, cc.xy(1, 1)); //======== panel13 ======== { panel13.setLayout(new FormLayout("default:grow, 2*($lcgap, 21dlu), 2*(21dlu)", "default")); panel13.add(hSpacer1, cc.xy(1, 1)); //---- btnJoinFilters ---- btnJoinFilters.setIcon( new ImageIcon(getClass().getResource("/ru/goodfil/catalog/ui/icons/recycle_24.png"))); btnJoinFilters.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { btnJoinFiltersActionPerformed(e); } }); panel13.add(btnJoinFilters, cc.xy(3, 1)); //---- btnCreateFilter ---- btnCreateFilter .setIcon(new ImageIcon(getClass().getResource("/ru/goodfil/catalog/ui/icons/add_24.png"))); btnCreateFilter.setToolTipText( "\u0414\u043e\u0431\u0430\u0432\u0438\u0442\u044c \u0444\u0438\u043b\u044c\u0442\u0440"); btnCreateFilter.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { btnCreateFilterActionPerformed(e); } }); panel13.add(btnCreateFilter, cc.xy(5, 1)); //---- btnEditFilter ---- btnEditFilter .setIcon(new ImageIcon(getClass().getResource("/ru/goodfil/catalog/ui/icons/edit_24.png"))); btnEditFilter.setToolTipText( "\u0420\u0435\u0434\u0430\u043a\u0442\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u0444\u0438\u043b\u044c\u0442\u0440"); btnEditFilter.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { btnEditFilterActionPerformed(e); } }); panel13.add(btnEditFilter, cc.xy(6, 1)); //---- btnRemoveFilter ---- btnRemoveFilter.setIcon( new ImageIcon(getClass().getResource("/ru/goodfil/catalog/ui/icons/delete_24.png"))); btnRemoveFilter.setToolTipText( "\u0423\u0434\u0430\u043b\u0438\u0442\u044c \u0444\u0438\u043b\u044c\u0442\u0440"); btnRemoveFilter.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { btnRemoveFilterActionPerformed(e); } }); panel13.add(btnRemoveFilter, cc.xy(7, 1)); } panel2.add(panel13, cc.xy(5, 1)); //======== srcTblFilters ======== { //---- tblFilters ---- tblFilters.setDoubleBuffered(true); tblFilters.setAutoCreateRowSorter(true); tblFilters.setToolTipText( "\u0424\u0438\u043b\u044c\u0442\u0440\u044b, \u043f\u043e\u0434\u043f\u0430\u0434\u0430\u044e\u0449\u0438\u0435 \u043f\u043e\u0434 \u0443\u0441\u043b\u043e\u0432\u0438\u044f \u043f\u043e\u0438\u0441\u043a\u0430"); tblFilters.addKeyListener(new KeyAdapter() { @Override public void keyPressed(KeyEvent e) { tblFiltersKeyPressed(e); } }); tblFilters.addMouseListener(new MouseAdapter() { @Override public void mouseClicked(MouseEvent e) { tblFiltersMouseClicked(e); } }); srcTblFilters.setViewportView(tblFilters); } panel2.add(srcTblFilters, cc.xywh(1, 2, 5, 1)); //======== panel15 ======== { panel15.setLayout(new FormLayout( "default, default:grow, $lcgap, default, default:grow, $rgap, $lcgap, default, $rgap, default, $lcgap", "2*(default)")); //---- label6 ---- label6.setText("\u041f\u0440\u043e\u0438\u0437\u0432\u043e\u0434\u0438\u0442\u0435\u043b\u044c"); panel15.add(label6, cc.xy(1, 1)); //---- cbManufactors ---- cbManufactors.setToolTipText( "\u0412\u044b\u0431\u0435\u0440\u0438\u0442\u0435 \u043f\u0440\u043e\u0438\u0437\u0432\u043e\u0434\u0438\u0442\u0435\u043b\u044f"); cbManufactors.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { cbManufactorsActionPerformed(e); } }); cbManufactors.addKeyListener(new KeyAdapter() { @Override public void keyPressed(KeyEvent e) { cbManufactorsKeyPressed(e); } }); panel15.add(cbManufactors, cc.xy(2, 1)); //---- label7 ---- label7.setText("\u0421\u0435\u0440\u0438\u044f"); panel15.add(label7, cc.xy(4, 1)); //---- cbSeria ---- cbSeria.setToolTipText( "\u0412\u044b\u0431\u0435\u0440\u0438\u0442\u0435 \u0441\u0435\u0440\u0438\u044e"); cbSeria.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { cbSeriaActionPerformed(e); } }); cbSeria.addKeyListener(new KeyAdapter() { @Override public void keyPressed(KeyEvent e) { cbSeriaKeyPressed(e); } }); panel15.add(cbSeria, cc.xywh(5, 1, 2, 1)); //---- btnClearSearchModel ---- btnClearSearchModel.setText("\u041e\u0447\u0438\u0441\u0442\u0438\u0442\u044c"); btnClearSearchModel.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { btnClearSearchModelActionPerformed(); } }); panel15.add(btnClearSearchModel, cc.xy(8, 1)); //---- btnSearchMotors ---- btnSearchMotors.setIcon( new ImageIcon(getClass().getResource("/ru/goodfil/catalog/ui/icons/find_next_24.png"))); btnSearchMotors.setToolTipText( "\u041f\u043e\u0438\u0441\u043a \u043c\u043e\u0442\u043e\u0440\u043e\u0432 \u0432\u044b\u0431\u0440\u0430\u043d\u043d\u043e\u0433\u043e \u043f\u0440\u043e\u0438\u0437\u0432\u043e\u0434\u0438\u0442\u0435\u043b\u044f \u0438\u0437 \u0432\u044b\u0431\u0440\u0430\u043d\u043d\u043e\u0439 \u0441\u0435\u0440\u0438\u0438"); btnSearchMotors.setText("\u041f\u043e\u0438\u0441\u043a"); btnSearchMotors.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { btnSearchMotorsActionPerformed(e); } }); panel15.add(btnSearchMotors, cc.xy(10, 1)); //======== panel1 ======== { panel1.setLayout(new FormLayout( "default, $lcgap, default:grow, $lcgap, default, $lcgap, default:grow, $lcgap, default, $lcgap, default:grow, $lcgap, default, $lcgap, default:grow, $lcgap, default, $lcgap, default:grow", "default")); //---- label1 ---- label1.setText("\u0421\u0435\u0440\u0438\u044f"); panel1.add(label1, cc.xy(1, 1)); //---- tbSeria ---- tbSeria.addKeyListener(new KeyAdapter() { @Override public void keyPressed(KeyEvent e) { tbSeriaKeyPressed(e); } @Override public void keyTyped(KeyEvent e) { tbSeriaKeyPressed(e); } }); panel1.add(tbSeria, cc.xy(3, 1)); //---- label2 ---- label2.setText("\u041c\u043e\u0434\u0435\u043b\u044c"); panel1.add(label2, cc.xy(5, 1)); //---- tbModel ---- tbModel.addKeyListener(new KeyAdapter() { @Override public void keyPressed(KeyEvent e) { tbModelKeyPressed(e); } @Override public void keyTyped(KeyEvent e) { tbModelKeyPressed(e); } }); panel1.add(tbModel, cc.xy(7, 1)); //---- label3 ---- label3.setText("\u0414\u0432\u0438\u0433\u0430\u0442\u0435\u043b\u044c"); panel1.add(label3, cc.xy(9, 1)); //---- tbEngine ---- tbEngine.addKeyListener(new KeyAdapter() { @Override public void keyPressed(KeyEvent e) { tbEngineKeyPressed(e); } @Override public void keyTyped(KeyEvent e) { tbEngineKeyPressed(e); } }); panel1.add(tbEngine, cc.xy(11, 1)); //---- label4 ---- label4.setText("\u0414\u0430\u0442\u0430 \"\u0421\""); panel1.add(label4, cc.xy(13, 1)); //---- tbDateF ---- tbDateF.addKeyListener(new KeyAdapter() { @Override public void keyPressed(KeyEvent e) { tbDateFKeyPressed(e); } @Override public void keyTyped(KeyEvent e) { tbDateFKeyPressed(e); } }); panel1.add(tbDateF, cc.xy(15, 1)); //---- label9 ---- label9.setText("\u0414\u0430\u0442\u0430 \"\u041f\u041e\""); panel1.add(label9, cc.xy(17, 1)); //---- tbDateT ---- tbDateT.addKeyListener(new KeyAdapter() { @Override public void keyPressed(KeyEvent e) { tbDateTKeyPressed(e); } @Override public void keyTyped(KeyEvent e) { tbDateTKeyPressed(e); } }); panel1.add(tbDateT, cc.xy(19, 1)); } panel15.add(panel1, cc.xywh(1, 2, 10, 1)); } panel2.add(panel15, cc.xywh(1, 4, 5, 1)); //======== scrollPane11 ======== { //---- tblMotors ---- tblMotors.setToolTipText( "\u041c\u043e\u0442\u043e\u0440\u044b, \u043f\u0440\u0438\u0432\u044f\u0437\u0430\u043d\u043d\u044b\u0435 \u043a \u0434\u0430\u043d\u043d\u043e\u043c\u0443 \u0444\u0438\u043b\u044c\u0442\u0440\u0443"); tblMotors.addKeyListener(new KeyAdapter() { @Override public void keyPressed(KeyEvent e) { tblMotorsKeyPressed(e); } }); tblMotors.addMouseListener(new MouseAdapter() { @Override public void mouseClicked(MouseEvent e) { tblMotorsMouseClicked(e); } }); scrollPane11.setViewportView(tblMotors); } panel2.add(scrollPane11, cc.xy(1, 5)); //======== panel18 ======== { panel18.setLayout(new FormLayout("21dlu", "2*(default, $lgap), fill:default:grow")); //---- btnAttachMotor ---- btnAttachMotor.setIcon(new ImageIcon( getClass().getResource("/ru/goodfil/catalog/ui/icons/arrow_left_green_24.png"))); btnAttachMotor.setToolTipText( "\u041f\u0440\u0438\u0432\u044f\u0437\u0430\u0442\u044c \u0432\u044b\u0431\u0440\u0430\u043d\u043d\u044b\u0439 \u043c\u043e\u0442\u043e\u0440 \u043a \u0444\u0438\u043b\u044c\u0442\u0440\u0443"); btnAttachMotor.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { btnAttachMotorActionPerformed(e); } }); panel18.add(btnAttachMotor, cc.xy(1, 1)); //---- btnDetachMotor ---- btnDetachMotor.setIcon(new ImageIcon( getClass().getResource("/ru/goodfil/catalog/ui/icons/arrow_right_green_24.png"))); btnDetachMotor.setToolTipText( "\u041e\u0442\u0432\u044f\u0437\u0430\u0442\u044c \u0432\u044b\u0431\u0440\u0430\u043d\u043d\u044b\u0439 \u043c\u043e\u0442\u043e\u0440 \u043e\u0442 \u0444\u0438\u043b\u044c\u0442\u0440\u0430"); btnDetachMotor.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { btnDetachMotorActionPerformed(e); } }); panel18.add(btnDetachMotor, cc.xy(1, 3)); panel18.add(vSpacer2, cc.xy(1, 5)); } panel2.add(panel18, cc.xy(3, 5)); //======== scrollPane12 ======== { //---- tblAllMotors ---- tblAllMotors.setToolTipText( "\u041c\u043e\u0442\u043e\u0440\u044b \u0432\u044b\u0431\u0440\u0430\u043d\u043d\u043e\u0433\u043e \u043f\u0440\u043e\u0438\u0437\u0432\u043e\u0434\u0438\u0442\u0435\u043b\u044f \u0438 \u0432\u044b\u0431\u0440\u0430\u043d\u043d\u043e\u0439 \u0441\u0435\u0440\u0438\u0438"); tblAllMotors.addKeyListener(new KeyAdapter() { @Override public void keyPressed(KeyEvent e) { tblAllMotorsKeyPressed(e); } }); tblAllMotors.addMouseListener(new MouseAdapter() { @Override public void mouseClicked(MouseEvent e) { tblAllMotorsMouseClicked(e); } }); scrollPane12.setViewportView(tblAllMotors); } panel2.add(scrollPane12, cc.xy(5, 5)); //======== panel16 ======== { panel16.setLayout(new FormLayout("default:grow", "default")); panel16.add(hSpacer3, cc.xy(1, 1)); } panel2.add(panel16, cc.xy(1, 7)); //======== panel17 ======== { panel17.setLayout(new FormLayout("default, default:grow, 21dlu", "default")); //---- label8 ---- label8.setText("\u041d\u043e\u043c\u0435\u0440 \u041e\u0415"); panel17.add(label8, cc.xy(1, 1)); //---- tbOe ---- tbOe.setToolTipText( "\u0412\u0432\u0435\u0434\u0438\u0442\u0435 \u041e\u0415 \u0434\u043b\u044f \u043f\u043e\u0438\u0441\u043a\u0430"); tbOe.addKeyListener(new KeyAdapter() { @Override public void keyReleased(KeyEvent e) { tbOeKeyTyped(e); } @Override public void keyTyped(KeyEvent e) { tbOeKeyTyped(e); } }); tbOe.addFocusListener(new FocusAdapter() { @Override public void focusGained(FocusEvent e) { tbOeFocusGained(e); } @Override public void focusLost(FocusEvent e) { tbOeFocusGained(e); } }); panel17.add(tbOe, cc.xy(2, 1)); //---- btnOeSearch ---- btnOeSearch.setIcon( new ImageIcon(getClass().getResource("/ru/goodfil/catalog/ui/icons/find_next_24.png"))); btnOeSearch.setToolTipText("\u041f\u043e\u0438\u0441\u043a \u043f\u043e \u041e\u0415"); btnOeSearch.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { btnOeSearchActionPerformed(e); } }); panel17.add(btnOeSearch, cc.xy(3, 1)); } panel2.add(panel17, cc.xy(5, 7)); //======== scrollPane7 ======== { //---- tblOes ---- tblOes.setSurrendersFocusOnKeystroke(true); tblOes.setToolTipText( "\u041e\u0415, \u043f\u0440\u0438\u0432\u044f\u0437\u0430\u043d\u043d\u044b\u0435 \u043a \u0432\u044b\u0431\u0440\u0430\u043d\u043d\u043e\u043c\u0443 \u0444\u0438\u043b\u044c\u0442\u0440\u0443"); tblOes.setAutoCreateRowSorter(true); tblOes.addKeyListener(new KeyAdapter() { @Override public void keyPressed(KeyEvent e) { tblOesKeyPressed(e); } }); tblOes.addMouseListener(new MouseAdapter() { @Override public void mouseClicked(MouseEvent e) { tblOesMouseClicked(e); } }); scrollPane7.setViewportView(tblOes); } panel2.add(scrollPane7, cc.xy(1, 8)); //======== panel19 ======== { panel19.setLayout( new FormLayout("21dlu", "fill:default, $lgap, default, $lgap, fill:default:grow")); //---- btnAttachOe ---- btnAttachOe.setIcon(new ImageIcon( getClass().getResource("/ru/goodfil/catalog/ui/icons/arrow_left_green_24.png"))); btnAttachOe.setToolTipText( "\u041f\u0440\u0438\u0432\u044f\u0437\u0430\u0442\u044c \u041e\u0415 \u043a \u0444\u0438\u043b\u044c\u0442\u0440\u0443"); btnAttachOe.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { btnAttachOeActionPerformed(e); } }); panel19.add(btnAttachOe, cc.xy(1, 1)); //---- btnDetachOe ---- btnDetachOe.setIcon(new ImageIcon( getClass().getResource("/ru/goodfil/catalog/ui/icons/arrow_right_green_24.png"))); btnDetachOe.setToolTipText( "\u041e\u0442\u0432\u044f\u0437\u0430\u0442\u044c \u041e\u0415 \u043e\u0442 \u0444\u0438\u043b\u044c\u0442\u0440\u0430"); btnDetachOe.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { btnDetachOeActionPerformed(e); } }); panel19.add(btnDetachOe, cc.xy(1, 3)); panel19.add(vSpacer3, cc.xy(1, 5)); } panel2.add(panel19, cc.xy(3, 8)); //======== scrollPane8 ======== { //---- tblAllOes ---- tblAllOes.setToolTipText( "\u041f\u0435\u0440\u0435\u0447\u0435\u043d\u044c \u041e\u0415, \u043f\u043e\u0434\u0445\u043e\u0434\u044f\u0449\u0438\u0445 \u043f\u043e\u0434 \u0443\u0441\u043b\u043e\u0432\u0438\u0435 \u043f\u043e\u0438\u0441\u043a\u0430"); tblAllOes.setAutoCreateRowSorter(true); tblAllOes.addKeyListener(new KeyAdapter() { @Override public void keyPressed(KeyEvent e) { tblAllOesKeyPressed(e); } }); tblAllOes.addMouseListener(new MouseAdapter() { @Override public void mouseClicked(MouseEvent e) { tblAllOesMouseClicked(e); } }); scrollPane8.setViewportView(tblAllOes); } panel2.add(scrollPane8, cc.xy(5, 8)); } add(panel2, cc.xy(1, 1)); //======== tablesPopupMenu ======== { tablesPopupMenu.addPopupMenuListener(new PopupMenuListener() { @Override public void popupMenuCanceled(PopupMenuEvent e) { } @Override public void popupMenuWillBecomeInvisible(PopupMenuEvent e) { } @Override public void popupMenuWillBecomeVisible(PopupMenuEvent e) { tablesPopupMenuPopupMenuWillBecomeVisible(e); } }); //---- miFullCopyToExcel ---- miFullCopyToExcel.setText( "\u041f\u043e\u043b\u043d\u0430\u044f \u0432\u044b\u0433\u0440\u0443\u0437\u043a\u0430 \u0438\u0437\u0434\u0435\u043b\u0438\u044f \u0432 Excel"); miFullCopyToExcel.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { miFullCopyToExcelActionPerformed(e); } }); tablesPopupMenu.add(miFullCopyToExcel); //======== menu1 ======== { menu1.setText("\u041a\u043e\u043f\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u0432 Excel"); //---- miCopySelectedToExcel ---- miCopySelectedToExcel.setText( "\u0422\u043e\u043b\u044c\u043a\u043e \u0432\u044b\u0434\u0435\u043b\u0435\u043d\u043d\u044b\u0435 \u0441\u0442\u0440\u043e\u043a\u0438"); miCopySelectedToExcel.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { miCopySelectedToExcelActionPerformed(e); } }); menu1.add(miCopySelectedToExcel); //---- miCopyToExcel ---- miCopyToExcel.setText("\u0412\u0441\u0435 \u0441\u0442\u0440\u043e\u043a\u0438"); miCopyToExcel.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { miCopyToExcelActionPerformed(e); } }); menu1.add(miCopyToExcel); } tablesPopupMenu.add(menu1); tablesPopupMenu.addSeparator(); //======== menu2 ======== { menu2.setText( "\u041a\u043e\u043f\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u0432 \u0431\u0443\u0444\u0435\u0440"); //---- miCopySelectedToBuffer ---- miCopySelectedToBuffer.setText( "\u0422\u043e\u043b\u044c\u043a\u043e \u0432\u044b\u0434\u0435\u043b\u0435\u043d\u043d\u044b\u0435 \u0441\u0442\u0440\u043e\u043a\u0438"); miCopySelectedToBuffer.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { miCopySelectedToBufferActionPerformed(e); } }); menu2.add(miCopySelectedToBuffer); //---- miCopyToBuffer ---- miCopyToBuffer.setText("\u0412\u0441\u0435 \u0441\u0442\u0440\u043e\u043a\u0438"); miCopyToBuffer.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { miCopyToBufferActionPerformed(e); } }); menu2.add(miCopyToBuffer); } tablesPopupMenu.add(menu2); //---- miPasteFromBuffer ---- miPasteFromBuffer.setText( "\u0412\u0441\u0442\u0430\u0432\u0438\u0442\u044c \u0438\u0437 \u0431\u0443\u0444\u0435\u0440\u0430"); miPasteFromBuffer.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { miPasteFromBufferActionPerformed(e); } }); tablesPopupMenu.add(miPasteFromBuffer); tablesPopupMenu.addSeparator(); //======== miShowOnSiteMenu ======== { miShowOnSiteMenu.setText( "\u041f\u043e\u043a\u0430\u0437\u044b\u0432\u0430\u0442\u044c \u043d\u0430 \u0441\u0430\u0439\u0442\u0435?"); //---- miShowOnSite ---- miShowOnSite.setText("\u041f\u043e\u043a\u0430\u0437\u044b\u0432\u0430\u0442\u044c"); miShowOnSite.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { miShowOnSiteActionPerformed(e); } }); miShowOnSiteMenu.add(miShowOnSite); //---- miDontShowOnSite ---- miDontShowOnSite .setText("\u041d\u0435 \u043f\u043e\u043a\u0430\u0437\u044b\u0432\u0430\u0442\u044c"); miDontShowOnSite.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { miDontShowOnSiteActionPerformed(e); } }); miShowOnSiteMenu.add(miDontShowOnSite); } tablesPopupMenu.add(miShowOnSiteMenu); //======== miApplyToAllMenu ======== { miApplyToAllMenu.setText( "\u0413\u043b\u043e\u0431\u043b\u044c\u043d\u0430\u044f \u043f\u0440\u0438\u0432\u044f\u0437\u043a\u0430?"); //---- miApplyToVT1 ---- miApplyToVT1.setText( "\u041a \u043b\u0435\u0433\u043a\u043e\u0432\u044b\u043c \u0430\u0432\u0442\u043e\u043c\u043e\u0431\u0438\u043b\u044f\u043c"); miApplyToVT1.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { miApplyToVT1ActionPerformed(e); } }); miApplyToAllMenu.add(miApplyToVT1); //---- miApplyToVT2 ---- miApplyToVT2.setText( "\u041a \u0433\u0440\u0443\u0437\u043e\u0432\u044b\u043c \u0430\u0432\u0442\u043e\u043c\u043e\u0431\u0438\u043b\u044f\u043c"); miApplyToVT2.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { miApplyToVT2ActionPerformed(e); } }); miApplyToAllMenu.add(miApplyToVT2); //---- miApplyToVT3 ---- miApplyToVT3.setText( "\u041a \u0441\u043f\u0435\u0446\u0438\u0430\u043b\u044c\u043d\u043e\u0439 \u0442\u0435\u0445\u043d\u0438\u043a\u0435"); miApplyToVT3.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { miApplyToVT3ActionPerformed(e); } }); miApplyToAllMenu.add(miApplyToVT3); //---- miApplyToVT4 ---- miApplyToVT4.setText( "\u041a \u043a\u0430\u0442\u0435\u0440\u0430\u043c \u0438 \u043c\u043e\u0442\u043e\u0446\u0438\u043a\u043b\u0430\u043c"); miApplyToVT4.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { miApplyToVT4ActionPerformed(e); } }); miApplyToAllMenu.add(miApplyToVT4); //---- miDontApplyToAll ---- miDontApplyToAll.setText( "\u0423\u0431\u0440\u0430\u0442\u044c \u0433\u043b\u043e\u0431\u0430\u043b\u044c\u043d\u0443\u044e \u043f\u0440\u0438\u0432\u044f\u0437\u043a\u0443"); miDontApplyToAll.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { miDontApplyToAllActionPerformed(e); } }); miApplyToAllMenu.add(miDontApplyToAll); } tablesPopupMenu.add(miApplyToAllMenu); } // JFormDesigner - End of component initialization //GEN-END:initComponents }
From source file:ru.goodfil.catalog.ui.forms.CarsPanel.java
private void initComponents() { // JFormDesigner - Component initialization - DO NOT MODIFY //GEN-BEGIN:initComponents // Generated using JFormDesigner Evaluation license - Sasha Ivanov DefaultComponentFactory compFactory = DefaultComponentFactory.getInstance(); panel1 = new JPanel(); label1 = new JLabel(); createTypeBtn = new JButton(); editTypeBtn = new JButton(); removeTypeBtn = new JButton(); label2 = new JLabel(); joinManufactorsBtn = new JButton(); createManufactorBtn = new JButton(); editManufactorBtn = new JButton(); removeManufactorBtn = new JButton(); label3 = new JLabel(); joinSeriesBtn = new JButton(); createSeriaBtn = new JButton(); editSeriaBtn = new JButton(); removeSeriaBtn = new JButton(); scrollPane1 = new JScrollPane(); vechicleTypesList = new JList(); scrollPane2 = new JScrollPane(); manufactorsList = new JList(); scrollPane3 = new JScrollPane(); seriesList = new JList(); panel10 = new JPanel(); label5 = new JLabel(); createMotorBtn = new JButton(); editMotorBtn = new JButton(); removeMotorBtn = new JButton(); joinMotorsBtn = new JButton(); scrollPane4 = new JScrollPane(); motorsTable = new JTable(); panel3 = new JPanel(); label6 = new JLabel(); label7 = new JLabel(); panel4 = new JPanel(); label4 = compFactory.createLabel("\u0424\u0438\u043b\u044c\u0442\u0440"); filterSearchField = new JTextField(); filterSearchBtn = new JButton(); scrollPane5 = new JScrollPane(); filtersTable = new JTable(); filterRelationComment = new JButton(); attachFilterBtn = new JButton(); scrollPane6 = new JScrollPane(); allFiltersTable = new JTable(); detachFilterBtn = new JButton(); listsPopupMenu = new JPopupMenu(); miCopyToExcel = new JMenuItem(); miExportToExcel = new JMenuItem(); menuItem1 = new JMenuItem(); menuItem3 = new JMenuItem(); menuItem2 = new JMenuItem(); menuItem4 = new JMenuItem(); CellConstraints cc = new CellConstraints(); //======== this ======== // JFormDesigner evaluation mark setBorder(/*from ww w . java 2 s . c om*/ new javax.swing.border.CompoundBorder( new javax.swing.border.TitledBorder(new javax.swing.border.EmptyBorder(0, 0, 0, 0), "JFormDesigner Evaluation", javax.swing.border.TitledBorder.CENTER, javax.swing.border.TitledBorder.BOTTOM, new java.awt.Font("Dialog", java.awt.Font.BOLD, 12), java.awt.Color.red), getBorder())); addPropertyChangeListener(new java.beans.PropertyChangeListener() { public void propertyChange(java.beans.PropertyChangeEvent e) { if ("border".equals(e.getPropertyName())) throw new RuntimeException(); } }); setLayout(new FormLayout("default:grow", "fill:default:grow")); //======== panel1 ======== { panel1.setLayout(new FormLayout( "default:grow, $lcgap, 3*(21pt), $lcgap, default:grow, $lcgap, 21dlu, $lcgap, 3*(21pt), $lcgap, default:grow, $lcgap, 21dlu, $lcgap, 3*(21pt)", "fill:21pt, fill:50dlu:grow, $lgap, min, fill:100dlu:grow, $lgap, fill:80dlu:grow")); //---- label1 ---- label1.setText("\u0422\u0438\u043f \u0422\u0421"); label1.setFont(label1.getFont().deriveFont(label1.getFont().getStyle() | Font.BOLD)); panel1.add(label1, cc.xy(1, 1)); //---- createTypeBtn ---- createTypeBtn.setIcon(new ImageIcon(getClass().getResource("/ru/goodfil/catalog/ui/icons/add_24.png"))); createTypeBtn.setAlignmentY(0.0F); createTypeBtn.setToolTipText( "\u0414\u043e\u0431\u0430\u0432\u0438\u0442\u044c \u0442\u0438\u043f \u0442\u0440\u0430\u043d\u0441\u043f\u043e\u0440\u0442\u043d\u043e\u0433\u043e \u0441\u0440\u0435\u0434\u0441\u0442\u0432\u0430"); createTypeBtn.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { createTypeBtnActionPerformed(e); } }); panel1.add(createTypeBtn, cc.xy(3, 1)); //---- editTypeBtn ---- editTypeBtn.setIcon(new ImageIcon(getClass().getResource("/ru/goodfil/catalog/ui/icons/edit_24.png"))); editTypeBtn.setToolTipText( "\u0420\u0435\u0434\u0430\u043a\u0442\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u0442\u0438\u043f \u0442\u0440\u0430\u043d\u0441\u043f\u043e\u0440\u0442\u043d\u043e\u0433\u043e \u0441\u0440\u0435\u0434\u0441\u0442\u0432\u0430"); editTypeBtn.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { editTypeBtnActionPerformed(e); } }); panel1.add(editTypeBtn, cc.xy(4, 1)); //---- removeTypeBtn ---- removeTypeBtn .setIcon(new ImageIcon(getClass().getResource("/ru/goodfil/catalog/ui/icons/delete_24.png"))); removeTypeBtn.setToolTipText( "\u0423\u0434\u0430\u043b\u0438\u0442\u044c \u0442\u0438\u043f \u0442\u0440\u0430\u043d\u0441\u043f\u043e\u0440\u0442\u043d\u043e\u0433\u043e \u0441\u0440\u0435\u0434\u0441\u0442\u0432\u0430"); removeTypeBtn.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { removeTypeBtnActionPerformed(e); } }); panel1.add(removeTypeBtn, cc.xy(5, 1)); //---- label2 ---- label2.setText("\u041f\u0440\u043e\u0438\u0437\u0432\u043e\u0434\u0438\u0442\u0435\u043b\u044c"); label2.setFont(label2.getFont().deriveFont(label2.getFont().getStyle() | Font.BOLD)); panel1.add(label2, cc.xy(7, 1)); //---- joinManufactorsBtn ---- joinManufactorsBtn .setIcon(new ImageIcon(getClass().getResource("/ru/goodfil/catalog/ui/icons/recycle_24.png"))); joinManufactorsBtn.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { joinManufactorsBtnActionPerformed(e); } }); panel1.add(joinManufactorsBtn, cc.xy(9, 1)); //---- createManufactorBtn ---- createManufactorBtn .setIcon(new ImageIcon(getClass().getResource("/ru/goodfil/catalog/ui/icons/add_24.png"))); createManufactorBtn.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { createManufactorBtnActionPerformed(e); } }); panel1.add(createManufactorBtn, cc.xy(11, 1)); //---- editManufactorBtn ---- editManufactorBtn .setIcon(new ImageIcon(getClass().getResource("/ru/goodfil/catalog/ui/icons/edit_24.png"))); editManufactorBtn.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { editManufactorBtnActionPerformed(e); } }); panel1.add(editManufactorBtn, cc.xy(12, 1)); //---- removeManufactorBtn ---- removeManufactorBtn .setIcon(new ImageIcon(getClass().getResource("/ru/goodfil/catalog/ui/icons/delete_24.png"))); removeManufactorBtn.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { removeManufactorBtnActionPerformed(e); } }); panel1.add(removeManufactorBtn, cc.xy(13, 1)); //---- label3 ---- label3.setText("\u0421\u0435\u0440\u0438\u044f"); label3.setFont(label3.getFont().deriveFont(label3.getFont().getStyle() | Font.BOLD)); panel1.add(label3, cc.xy(15, 1)); //---- joinSeriesBtn ---- joinSeriesBtn .setIcon(new ImageIcon(getClass().getResource("/ru/goodfil/catalog/ui/icons/recycle_24.png"))); joinSeriesBtn.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { joinSeriesBtnActionPerformed(e); } }); panel1.add(joinSeriesBtn, cc.xy(17, 1)); //---- createSeriaBtn ---- createSeriaBtn .setIcon(new ImageIcon(getClass().getResource("/ru/goodfil/catalog/ui/icons/add_24.png"))); createSeriaBtn.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { createSeriaBtnActionPerformed(e); } }); panel1.add(createSeriaBtn, cc.xy(19, 1)); //---- editSeriaBtn ---- editSeriaBtn.setIcon(new ImageIcon(getClass().getResource("/ru/goodfil/catalog/ui/icons/edit_24.png"))); editSeriaBtn.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { editSeriaBtnActionPerformed(e); } }); panel1.add(editSeriaBtn, cc.xy(20, 1)); //---- removeSeriaBtn ---- removeSeriaBtn .setIcon(new ImageIcon(getClass().getResource("/ru/goodfil/catalog/ui/icons/delete_24.png"))); removeSeriaBtn.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { removeSeriaBtnActionPerformed(e); } }); panel1.add(removeSeriaBtn, cc.xy(21, 1)); //======== scrollPane1 ======== { //---- vechicleTypesList ---- vechicleTypesList.setDoubleBuffered(true); vechicleTypesList.addListSelectionListener(new ListSelectionListener() { @Override public void valueChanged(ListSelectionEvent e) { vechicleTypesListValueChanged(e); } }); vechicleTypesList.addKeyListener(new KeyAdapter() { @Override public void keyPressed(KeyEvent e) { vechicleTypesListKeyPressed(e); } }); vechicleTypesList.addMouseListener(new MouseAdapter() { @Override public void mouseClicked(MouseEvent e) { vechicleTypesListMouseClicked(e); } }); scrollPane1.setViewportView(vechicleTypesList); } panel1.add(scrollPane1, cc.xywh(1, 2, 5, 1)); //======== scrollPane2 ======== { //---- manufactorsList ---- manufactorsList.setDoubleBuffered(true); manufactorsList.addListSelectionListener(new ListSelectionListener() { @Override public void valueChanged(ListSelectionEvent e) { manufactorsListValueChanged(e); } }); manufactorsList.addKeyListener(new KeyAdapter() { @Override public void keyPressed(KeyEvent e) { manufactorsListKeyPressed(e); } }); manufactorsList.addMouseListener(new MouseAdapter() { @Override public void mouseClicked(MouseEvent e) { manufactorsListMouseClicked(e); } }); scrollPane2.setViewportView(manufactorsList); } panel1.add(scrollPane2, cc.xywh(7, 2, 7, 1)); //======== scrollPane3 ======== { //---- seriesList ---- seriesList.addListSelectionListener(new ListSelectionListener() { @Override public void valueChanged(ListSelectionEvent e) { seriesListValueChanged(e); } }); seriesList.addKeyListener(new KeyAdapter() { @Override public void keyPressed(KeyEvent e) { seriesListKeyPressed(e); } }); seriesList.addMouseListener(new MouseAdapter() { @Override public void mouseClicked(MouseEvent e) { seriesListMouseClicked(e); } }); scrollPane3.setViewportView(seriesList); } panel1.add(scrollPane3, cc.xywh(15, 2, 7, 1)); //======== panel10 ======== { panel10.setLayout(new FormLayout("default, $lcgap, 4*(21dlu)", "default")); //---- label5 ---- label5.setText("\u0414\u0432\u0438\u0433\u0430\u0442\u0435\u043b\u0438"); label5.setFont(label5.getFont().deriveFont(label5.getFont().getStyle() | Font.BOLD)); panel10.add(label5, cc.xy(1, 1)); //---- createMotorBtn ---- createMotorBtn .setIcon(new ImageIcon(getClass().getResource("/ru/goodfil/catalog/ui/icons/add_24.png"))); createMotorBtn.setAlignmentY(0.0F); createMotorBtn.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { createMotorBtnActionPerformed(e); } }); panel10.add(createMotorBtn, cc.xy(3, 1)); //---- editMotorBtn ---- editMotorBtn .setIcon(new ImageIcon(getClass().getResource("/ru/goodfil/catalog/ui/icons/edit_24.png"))); editMotorBtn.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { editMotorBtnActionPerformed(e); } }); panel10.add(editMotorBtn, cc.xy(4, 1)); //---- removeMotorBtn ---- removeMotorBtn.setIcon( new ImageIcon(getClass().getResource("/ru/goodfil/catalog/ui/icons/delete_24.png"))); removeMotorBtn.setEnabled(false); removeMotorBtn.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { removeMotorBtnActionPerformed(e); } }); panel10.add(removeMotorBtn, cc.xy(5, 1)); //---- joinMotorsBtn ---- joinMotorsBtn.setIcon( new ImageIcon(getClass().getResource("/ru/goodfil/catalog/ui/icons/recycle_24.png"))); joinMotorsBtn.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { joinMotorsBtnActionPerformed(e); } }); panel10.add(joinMotorsBtn, cc.xy(6, 1)); } panel1.add(panel10, cc.xywh(1, 4, 21, 1)); //======== scrollPane4 ======== { //---- motorsTable ---- motorsTable.setAutoCreateRowSorter(true); motorsTable.addKeyListener(new KeyAdapter() { @Override public void keyPressed(KeyEvent e) { motorsTableKeyPressed(e); } }); motorsTable.addMouseListener(new MouseAdapter() { @Override public void mouseClicked(MouseEvent e) { motorsTableMouseClicked(e); } }); scrollPane4.setViewportView(motorsTable); } panel1.add(scrollPane4, cc.xywh(1, 5, 21, 1)); //======== panel3 ======== { panel3.setLayout(new FormLayout("default:grow, $lcgap, 21dlu, $lcgap, default:grow", "3*(default), $lgap, default, $lgap, fill:default:grow")); //---- label6 ---- label6.setText( "\u041f\u043e\u0434\u0445\u043e\u0434\u044f\u0449\u0438\u0435 \u0444\u0438\u043b\u044c\u0442\u0440\u044b"); label6.setFont(label6.getFont().deriveFont(label6.getFont().getStyle() | Font.BOLD)); panel3.add(label6, cc.xy(1, 1)); //---- label7 ---- label7.setText("\u0412\u0441\u0435 \u0444\u0438\u043b\u044c\u0442\u0440\u044b"); label7.setFont(label7.getFont().deriveFont(label7.getFont().getStyle() | Font.BOLD)); panel3.add(label7, cc.xy(5, 1)); //======== panel4 ======== { panel4.setLayout(new FormLayout("default, $lcgap, default:grow, 21pt", "21dlu")); panel4.add(label4, cc.xy(1, 1)); //---- filterSearchField ---- filterSearchField.addKeyListener(new KeyAdapter() { @Override public void keyPressed(KeyEvent e) { filterSearchFieldKeyPressed(e); } }); panel4.add(filterSearchField, cc.xy(3, 1)); //---- filterSearchBtn ---- filterSearchBtn.setIcon( new ImageIcon(getClass().getResource("/ru/goodfil/catalog/ui/icons/find_next_24.png"))); filterSearchBtn.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { filterSearchBtnActionPerformed(e); } }); panel4.add(filterSearchBtn, cc.xy(4, 1)); } panel3.add(panel4, cc.xy(5, 2)); //======== scrollPane5 ======== { //---- filtersTable ---- filtersTable.setAutoCreateRowSorter(true); filtersTable.addMouseListener(new MouseAdapter() { @Override public void mouseClicked(MouseEvent e) { filtersTableMouseClicked(e); } }); scrollPane5.setViewportView(filtersTable); } panel3.add(scrollPane5, cc.xywh(1, 2, 1, 6)); //---- filterRelationComment ---- filterRelationComment .setIcon(new ImageIcon(getClass().getResource("/ru/goodfil/catalog/ui/icons/edit.png"))); filterRelationComment.setToolTipText( "\u041a\u043e\u043c\u043c\u0435\u043d\u0442\u0430\u0440\u0438\u0439 \u043a \u0444\u0438\u043b\u044c\u0442\u0440\u0443 \u0443 \u0434\u0430\u043d\u043d\u043e\u0439 \u043c\u0430\u0448\u0438\u043d\u044b"); filterRelationComment.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { filterRelationCommentActionPerformed(e); } }); panel3.add(filterRelationComment, cc.xy(3, 2)); //---- attachFilterBtn ---- attachFilterBtn.setIcon(new ImageIcon( getClass().getResource("/ru/goodfil/catalog/ui/icons/arrow_left_green_24.png"))); attachFilterBtn.setToolTipText( "\u0414\u043e\u0431\u0430\u0432\u0438\u0442\u044c \u0444\u0438\u043b\u044c\u0442\u0440 \u0432 \u043f\u0440\u0438\u043c\u0435\u043d\u0438\u043c\u043e\u0441\u0442\u044c"); attachFilterBtn.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { attachFilterBtnActionPerformed(e); } }); panel3.add(attachFilterBtn, cc.xy(3, 3)); //======== scrollPane6 ======== { //---- allFiltersTable ---- allFiltersTable.setAutoCreateRowSorter(true); allFiltersTable.addMouseListener(new MouseAdapter() { @Override public void mouseClicked(MouseEvent e) { allFiltersTableMouseClicked(e); } }); scrollPane6.setViewportView(allFiltersTable); } panel3.add(scrollPane6, cc.xywh(5, 3, 1, 5)); //---- detachFilterBtn ---- detachFilterBtn.setIcon(new ImageIcon( getClass().getResource("/ru/goodfil/catalog/ui/icons/arrow_right_green_24.png"))); detachFilterBtn.setToolTipText( "\u0423\u0431\u0440\u0430\u0442\u044c \u0444\u0438\u043b\u044c\u0442\u0440 \u0438\u0437 \u043f\u0440\u0438\u043c\u0435\u043d\u0438\u043c\u043e\u0441\u0442\u0438"); detachFilterBtn.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { detachFilterBtnActionPerformed(e); } }); panel3.add(detachFilterBtn, cc.xy(3, 5)); } panel1.add(panel3, cc.xywh(1, 7, 21, 1)); } add(panel1, cc.xy(1, 1)); //======== listsPopupMenu ======== { listsPopupMenu.addPopupMenuListener(new PopupMenuListener() { @Override public void popupMenuCanceled(PopupMenuEvent e) { } @Override public void popupMenuWillBecomeInvisible(PopupMenuEvent e) { } @Override public void popupMenuWillBecomeVisible(PopupMenuEvent e) { listsPopupMenuPopupMenuWillBecomeVisible(e); } }); //---- miCopyToExcel ---- miCopyToExcel.setText("\u041a\u043e\u043f\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u0432 Excel"); miCopyToExcel.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { miCopyToExcelActionPerformed(e); } }); listsPopupMenu.add(miCopyToExcel); //---- miExportToExcel ---- miExportToExcel.setText("\u0412\u044b\u0433\u0440\u0443\u0437\u0438\u0442\u044c \u0432 Excel"); miExportToExcel.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { miExportToExcelActionPerformed(e); } }); listsPopupMenu.add(miExportToExcel); listsPopupMenu.addSeparator(); //---- menuItem1 ---- menuItem1.setText( "\u041a\u043e\u043f\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u0432 \u0431\u0443\u0444\u0435\u0440"); menuItem1.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { copyToClipboard(e); } }); listsPopupMenu.add(menuItem1); //---- menuItem3 ---- menuItem3.setText( "\u0412\u0441\u0442\u0430\u0432\u0438\u0442\u044c \u0438\u0437 \u0431\u0443\u0444\u0435\u0440\u0430"); menuItem3.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { pasteFromClipboard(e); } }); listsPopupMenu.add(menuItem3); listsPopupMenu.addSeparator(); //---- menuItem2 ---- menuItem2.setText( "\u041f\u0435\u0440\u0435\u043c\u0435\u0441\u0442\u0438\u0442\u044c \u0432 \u0431\u0443\u0444\u0435\u0440 (\u0421 \u0443\u0434\u0430\u043b\u0435\u043d\u0438\u0435\u043c)"); menuItem2.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { cutToClipboard(e); } }); listsPopupMenu.add(menuItem2); //---- menuItem4 ---- menuItem4.setText( "\u0412\u044b\u043d\u0435\u0441\u0442\u0438 \u0438\u0437 \u0431\u0443\u0444\u0435\u0440\u0430"); menuItem4.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { pasteFromClipboard(e); } }); listsPopupMenu.add(menuItem4); } // JFormDesigner - End of component initialization //GEN-END:initComponents }
From source file:com.mirth.connect.client.ui.codetemplate.CodeTemplatePanel.java
private void initComponents() { splitPane = new JSplitPane(); splitPane.setBackground(getBackground()); splitPane.setOrientation(JSplitPane.VERTICAL_SPLIT); splitPane.setBorder(BorderFactory.createEmptyBorder()); splitPane.setOneTouchExpandable(true); splitPane.setDividerLocation(//from w ww .j av a 2 s. c om Preferences.userNodeForPackage(Mirth.class).getInt("height", UIConstants.MIRTH_HEIGHT) / 3); splitPane.setResizeWeight(0.5); topPanel = new JPanel(); topPanel.setBackground(UIConstants.COMBO_BOX_BACKGROUND); final CodeTemplateTreeTableCellEditor templateCellEditor = new CodeTemplateTreeTableCellEditor(this); templateTreeTable = new MirthTreeTable("CodeTemplate", new HashSet<String>( Arrays.asList(new String[] { "Name", "Description", "Revision", "Last Modified" }))) { private TreeTableNode selectedNode; @Override public boolean isCellEditable(int row, int column) { return column == TEMPLATE_NAME_COLUMN; } @Override public TableCellEditor getCellEditor(int row, int column) { if (isHierarchical(column)) { return templateCellEditor; } else { return super.getCellEditor(row, column); } } @Override protected void beforeSort() { updateCurrentNode(); updateCurrentNode.set(false); int selectedRow = templateTreeTable.getSelectedRow(); selectedNode = selectedRow >= 0 ? (TreeTableNode) templateTreeTable.getPathForRow(selectedRow).getLastPathComponent() : null; } @Override protected void afterSort() { final TreePath selectedPath = selectPathFromNodeId(selectedNode, (CodeTemplateRootTreeTableNode) templateTreeTable.getTreeTableModel().getRoot()); if (selectedPath != null) { selectTemplatePath(selectedPath); } SwingUtilities.invokeLater(new Runnable() { @Override public void run() { if (selectedPath != null) { selectTemplatePath(selectedPath); } updateCurrentNode.set(true); } }); } }; DefaultTreeTableModel model = new CodeTemplateTreeTableModel(); model.setColumnIdentifiers( Arrays.asList(new String[] { "Name", "Id", "Type", "Description", "Revision", "Last Modified" })); CodeTemplateRootTreeTableNode rootNode = new CodeTemplateRootTreeTableNode(); model.setRoot(rootNode); fullModel = new CodeTemplateTreeTableModel(); fullModel.setColumnIdentifiers( Arrays.asList(new String[] { "Name", "Id", "Type", "Description", "Revision", "Last Modified" })); CodeTemplateRootTreeTableNode fullRootNode = new CodeTemplateRootTreeTableNode(); fullModel.setRoot(fullRootNode); templateTreeTable.setColumnFactory(new CodeTemplateTableColumnFactory()); templateTreeTable.setTreeTableModel(model); templateTreeTable.setOpenIcon(null); templateTreeTable.setClosedIcon(null); templateTreeTable.setLeafIcon(null); templateTreeTable.setRootVisible(false); templateTreeTable.setDoubleBuffered(true); templateTreeTable.setDragEnabled(false); templateTreeTable.setRowSelectionAllowed(true); templateTreeTable.setSelectionMode(ListSelectionModel.SINGLE_SELECTION); templateTreeTable.setRowHeight(UIConstants.ROW_HEIGHT); templateTreeTable.setFocusable(true); templateTreeTable.setOpaque(true); templateTreeTable.getTableHeader().setReorderingAllowed(true); templateTreeTable.putClientProperty("terminateEditOnFocusLost", Boolean.TRUE); templateTreeTable.setEditable(true); templateTreeTable.setSortable(true); templateTreeTable.setAutoCreateColumnsFromModel(false); templateTreeTable.setShowGrid(true, true); templateTreeTable.restoreColumnPreferences(); templateTreeTable.setMirthColumnControlEnabled(true); if (Preferences.userNodeForPackage(Mirth.class).getBoolean("highlightRows", true)) { templateTreeTable.setHighlighters(HighlighterFactory .createAlternateStriping(UIConstants.HIGHLIGHTER_COLOR, UIConstants.BACKGROUND_COLOR)); } templateTreeTable.addMouseListener(new MouseAdapter() { @Override public void mousePressed(MouseEvent evt) { checkSelection(evt); } @Override public void mouseReleased(MouseEvent evt) { checkSelection(evt); } private void checkSelection(MouseEvent evt) { int row = templateTreeTable.rowAtPoint(new Point(evt.getX(), evt.getY())); if (row < 0) { templateTreeTable.clearSelection(); } if (evt.isPopupTrigger()) { if (row != -1) { if (!templateTreeTable.isRowSelected(row)) { templateTreeTable.setRowSelectionInterval(row, row); } } codeTemplatePopupMenu.show(evt.getComponent(), evt.getX(), evt.getY()); } } }); templateTreeTable.addKeyListener(new KeyAdapter() { @Override public void keyReleased(KeyEvent e) { if (e.getKeyCode() == KeyEvent.VK_DELETE) { TreePath selectedPath = templateTreeTable.getTreeSelectionModel().getSelectionPath(); if (selectedPath != null) { MutableTreeTableNode selectedNode = (MutableTreeTableNode) selectedPath .getLastPathComponent(); if (selectedNode instanceof CodeTemplateLibraryTreeTableNode && codeTemplateTasks .getContentPane().getComponent(TASK_CODE_TEMPLATE_LIBRARY_DELETE).isVisible()) { doDeleteLibrary(); } else if (selectedNode instanceof CodeTemplateTreeTableNode && codeTemplateTasks .getContentPane().getComponent(TASK_CODE_TEMPLATE_DELETE).isVisible()) { doDeleteCodeTemplate(); } } } } }); templateTreeTable.getSelectionModel().addListSelectionListener(new ListSelectionListener() { @Override public void valueChanged(ListSelectionEvent evt) { if (!evt.getValueIsAdjusting() && !templateTreeTable.getSelectionModel().getValueIsAdjusting()) { int selectedRow = templateTreeTable.getSelectedRow(); boolean saveEnabled = isSaveEnabled(); boolean adjusting = saveAdjusting.getAndSet(true); printTreeTable(); updateCurrentNode(); currentSelectedRow = selectedRow; if (selectedRow < 0) { if (!adjusting) { switchSplitPaneComponent(blankPanel); } } else { TreePath path = templateTreeTable.getPathForRow(selectedRow); if (path != null) { TreeTableNode node = (TreeTableNode) path.getLastPathComponent(); if (node instanceof CodeTemplateLibraryTreeTableNode) { setLibraryProperties((CodeTemplateLibraryTreeTableNode) node); switchSplitPaneComponent(libraryPanel); } else if (node instanceof CodeTemplateTreeTableNode) { setCodeTemplateProperties((CodeTemplateTreeTableNode) node); switchSplitPaneComponent(templatePanel); } } } updateTasks(); setSaveEnabled(saveEnabled); if (!adjusting) { SwingUtilities.invokeLater(new Runnable() { @Override public void run() { saveAdjusting.set(false); } }); } } } }); templateTreeTable.addTreeWillExpandListener(new TreeWillExpandListener() { @Override public void treeWillExpand(TreeExpansionEvent event) throws ExpandVetoException { treeExpansionChanged(); } @Override public void treeWillCollapse(TreeExpansionEvent event) throws ExpandVetoException { treeExpansionChanged(); } private void treeExpansionChanged() { updateCurrentNode(); updateCurrentNode.set(false); SwingUtilities.invokeLater(new Runnable() { @Override public void run() { updateCurrentNode.set(true); } }); } }); templateTreeTableScrollPane = new JScrollPane(templateTreeTable); templateTreeTableScrollPane.setBorder(BorderFactory.createMatteBorder(0, 0, 1, 0, new Color(0x6E6E6E))); templateFilterNotificationLabel = new JLabel(); templateFilterLabel = new JLabel("Filter:"); templateFilterField = new JTextField(); templateFilterField.setToolTipText( "Filters (by name) the code templates and libraries that show up in the table above."); templateFilterField.getDocument().addDocumentListener(new DocumentListener() { @Override public void removeUpdate(DocumentEvent evt) { filterChanged(evt); } @Override public void insertUpdate(DocumentEvent evt) { filterChanged(evt); } @Override public void changedUpdate(DocumentEvent evt) { filterChanged(evt); } private void filterChanged(DocumentEvent evt) { try { updateTemplateFilter(evt.getDocument().getText(0, evt.getLength())); } catch (BadLocationException e) { } } }); templateFilterField.addKeyListener(new KeyAdapter() { @Override public void keyReleased(KeyEvent evt) { updateTemplateFilter(templateFilterField.getText()); } }); blankPanel = new JPanel(); libraryPanel = new JPanel(); libraryPanel.setBackground(splitPane.getBackground()); libraryLeftPanel = new JPanel(); libraryLeftPanel.setBackground(libraryPanel.getBackground()); librarySummaryLabel = new JLabel("Summary:"); librarySummaryValue = new JLabel(); libraryDescriptionLabel = new JLabel("Description:"); libraryDescriptionScrollPane = new MirthRTextScrollPane(null, false, SyntaxConstants.SYNTAX_STYLE_NONE, false); DocumentListener codeChangeListener = new DocumentListener() { @Override public void removeUpdate(DocumentEvent evt) { codeChanged(); } @Override public void insertUpdate(DocumentEvent evt) { codeChanged(); } @Override public void changedUpdate(DocumentEvent evt) { codeChanged(); } private void codeChanged() { if (codeChangeWorker != null) { codeChangeWorker.cancel(true); } int selectedRow = templateTreeTable.getSelectedRow(); if (selectedRow >= 0) { TreePath selectedPath = templateTreeTable.getPathForRow(selectedRow); if (selectedPath != null) { codeChangeWorker = new CodeChangeWorker( (String) ((TreeTableNode) selectedPath.getLastPathComponent()) .getValueAt(TEMPLATE_ID_COLUMN)); codeChangeWorker.execute(); } } } }; libraryDescriptionScrollPane.getDocument().addDocumentListener(codeChangeListener); libraryRightPanel = new JPanel(); libraryRightPanel.setBackground(libraryPanel.getBackground()); libraryChannelsSelectPanel = new JPanel(); libraryChannelsSelectPanel.setBackground(libraryRightPanel.getBackground()); libraryChannelsLabel = new JLabel("<html><b>Channels</b></html>"); libraryChannelsLabel.setForeground(new Color(64, 64, 64)); libraryChannelsSelectAllLabel = new JLabel("<html><u>Select All</u></html>"); libraryChannelsSelectAllLabel.setForeground(Color.BLUE); libraryChannelsSelectAllLabel.setCursor(new Cursor(Cursor.HAND_CURSOR)); libraryChannelsSelectAllLabel.addMouseListener(new MouseAdapter() { public void mouseReleased(MouseEvent evt) { if (evt.getComponent().isEnabled()) { for (int row = 0; row < libraryChannelsTable.getRowCount(); row++) { ChannelInfo channelInfo = (ChannelInfo) libraryChannelsTable.getValueAt(row, LIBRARY_CHANNELS_NAME_COLUMN); channelInfo.setEnabled(true); libraryChannelsTable.setValueAt(channelInfo, row, LIBRARY_CHANNELS_NAME_COLUMN); } setSaveEnabled(true); } } }); libraryChannelsDeselectAllLabel = new JLabel("<html><u>Deselect All</u></html>"); libraryChannelsDeselectAllLabel.setForeground(Color.BLUE); libraryChannelsDeselectAllLabel.setCursor(new Cursor(Cursor.HAND_CURSOR)); libraryChannelsDeselectAllLabel.addMouseListener(new MouseAdapter() { public void mouseReleased(MouseEvent evt) { if (evt.getComponent().isEnabled()) { for (int row = 0; row < libraryChannelsTable.getRowCount(); row++) { ChannelInfo channelInfo = (ChannelInfo) libraryChannelsTable.getValueAt(row, LIBRARY_CHANNELS_NAME_COLUMN); channelInfo.setEnabled(false); libraryChannelsTable.setValueAt(channelInfo, row, LIBRARY_CHANNELS_NAME_COLUMN); } setSaveEnabled(true); } } }); libraryChannelsFilterLabel = new JLabel("Filter:"); libraryChannelsFilterField = new JTextField(); libraryChannelsFilterField.getDocument().addDocumentListener(new DocumentListener() { @Override public void removeUpdate(DocumentEvent evt) { libraryChannelsTable.getRowSorter().allRowsChanged(); } @Override public void insertUpdate(DocumentEvent evt) { libraryChannelsTable.getRowSorter().allRowsChanged(); } @Override public void changedUpdate(DocumentEvent evt) { libraryChannelsTable.getRowSorter().allRowsChanged(); } }); libraryChannelsTable = new MirthTable(); libraryChannelsTable.setModel(new RefreshTableModel(new Object[] { "Name", "Id" }, 0)); libraryChannelsTable.setDragEnabled(false); libraryChannelsTable.setRowSelectionAllowed(false); libraryChannelsTable.setRowHeight(UIConstants.ROW_HEIGHT); libraryChannelsTable.setFocusable(false); libraryChannelsTable.setOpaque(true); libraryChannelsTable.getTableHeader().setReorderingAllowed(false); libraryChannelsTable.setEditable(true); OffsetRowSorter libraryChannelsRowSorter = new OffsetRowSorter(libraryChannelsTable.getModel(), 1); libraryChannelsRowSorter.setRowFilter(new RowFilter<TableModel, Integer>() { @Override public boolean include(Entry<? extends TableModel, ? extends Integer> entry) { String name = entry.getStringValue(LIBRARY_CHANNELS_NAME_COLUMN); return name.equals(NEW_CHANNELS) || StringUtils.containsIgnoreCase(name, StringUtils.trim(libraryChannelsFilterField.getText())); } }); libraryChannelsTable.setRowSorter(libraryChannelsRowSorter); if (Preferences.userNodeForPackage(Mirth.class).getBoolean("highlightRows", true)) { libraryChannelsTable.setHighlighters(HighlighterFactory .createAlternateStriping(UIConstants.HIGHLIGHTER_COLOR, UIConstants.BACKGROUND_COLOR)); } libraryChannelsTable.getColumnExt(LIBRARY_CHANNELS_NAME_COLUMN) .setCellRenderer(new ChannelsTableCellRenderer()); libraryChannelsTable.getColumnExt(LIBRARY_CHANNELS_NAME_COLUMN) .setCellEditor(new ChannelsTableCellEditor()); // Hide ID column libraryChannelsTable.getColumnExt(LIBRARY_CHANNELS_ID_COLUMN).setVisible(false); libraryChannelsScrollPane = new JScrollPane(libraryChannelsTable); templatePanel = new JPanel(); templatePanel.setBackground(splitPane.getBackground()); templateLeftPanel = new JPanel(); templateLeftPanel.setBackground(templatePanel.getBackground()); templateLibraryLabel = new JLabel("Library:"); templateLibraryComboBox = new JComboBox<String>(); templateLibraryComboBox.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent evt) { libraryComboBoxActionPerformed(); } }); templateTypeLabel = new JLabel("Type:"); templateTypeComboBox = new JComboBox<CodeTemplateType>(CodeTemplateType.values()); templateTypeComboBox.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent evt) { setSaveEnabled(true); } }); templateCodeLabel = new JLabel("Code:"); templateCodeTextArea = new MirthRTextScrollPane(ContextType.GLOBAL_DEPLOY); templateCodeTextArea.getDocument().addDocumentListener(codeChangeListener); templateAutoGenerateDocumentationButton = new JButton("Update JSDoc"); templateAutoGenerateDocumentationButton.setToolTipText( "<html>Generates/updates a JSDoc at the beginning of your<br/>code, with parameter/return annotations as needed.</html>"); templateAutoGenerateDocumentationButton.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent evt) { String currentText = templateCodeTextArea.getText(); String newText = CodeTemplateUtil.updateCode(templateCodeTextArea.getText()); templateCodeTextArea.setText(newText, false); if (!currentText.equals(newText)) { setSaveEnabled(true); } } }); templateRightPanel = new JPanel(); templateRightPanel.setBackground(templatePanel.getBackground()); templateContextSelectPanel = new JPanel(); templateContextSelectPanel.setBackground(templateRightPanel.getBackground()); templateContextLabel = new JLabel("<html><b>Context</b></html>"); templateContextLabel.setForeground(new Color(64, 64, 64)); templateContextSelectAllLabel = new JLabel("<html><u>Select All</u></html>"); templateContextSelectAllLabel.setForeground(Color.BLUE); templateContextSelectAllLabel.setCursor(new Cursor(Cursor.HAND_CURSOR)); templateContextSelectAllLabel.addMouseListener(new MouseAdapter() { public void mouseReleased(MouseEvent evt) { TreeTableNode root = (TreeTableNode) templateContextTreeTable.getTreeTableModel().getRoot(); for (Enumeration<? extends TreeTableNode> groups = root.children(); groups.hasMoreElements();) { TreeTableNode group = groups.nextElement(); ((MutablePair<Integer, String>) group.getUserObject()).setLeft(MirthTriStateCheckBox.CHECKED); for (Enumeration<? extends TreeTableNode> children = group.children(); children .hasMoreElements();) { ((MutablePair<Integer, String>) children.nextElement().getUserObject()) .setLeft(MirthTriStateCheckBox.CHECKED); } } templateContextTreeTable.updateUI(); setSaveEnabled(true); } }); templateContextDeselectAllLabel = new JLabel("<html><u>Deselect All</u></html>"); templateContextDeselectAllLabel.setForeground(Color.BLUE); templateContextDeselectAllLabel.setCursor(new Cursor(Cursor.HAND_CURSOR)); templateContextDeselectAllLabel.addMouseListener(new MouseAdapter() { public void mouseReleased(MouseEvent evt) { TreeTableNode root = (TreeTableNode) templateContextTreeTable.getTreeTableModel().getRoot(); for (Enumeration<? extends TreeTableNode> groups = root.children(); groups.hasMoreElements();) { TreeTableNode group = groups.nextElement(); ((MutablePair<Integer, String>) group.getUserObject()).setLeft(MirthTriStateCheckBox.UNCHECKED); for (Enumeration<? extends TreeTableNode> children = group.children(); children .hasMoreElements();) { ((MutablePair<Integer, String>) children.nextElement().getUserObject()) .setLeft(MirthTriStateCheckBox.UNCHECKED); } } templateContextTreeTable.updateUI(); setSaveEnabled(true); } }); final TableCellEditor contextCellEditor = new ContextTreeTableCellEditor(new ActionListener() { @Override public void actionPerformed(ActionEvent evt) { setSaveEnabled(true); } }); templateContextTreeTable = new MirthTreeTable() { @Override public TableCellEditor getCellEditor(int row, int column) { if (isHierarchical(column)) { return contextCellEditor; } else { return super.getCellEditor(row, column); } } }; DefaultMutableTreeTableNode rootContextNode = new DefaultMutableTreeTableNode(); DefaultMutableTreeTableNode globalScriptsNode = new DefaultMutableTreeTableNode( new MutablePair<Integer, String>(MirthTriStateCheckBox.CHECKED, "Global Scripts")); globalScriptsNode.add(new DefaultMutableTreeTableNode( new MutablePair<Integer, ContextType>(MirthTriStateCheckBox.CHECKED, ContextType.GLOBAL_DEPLOY))); globalScriptsNode.add(new DefaultMutableTreeTableNode( new MutablePair<Integer, ContextType>(MirthTriStateCheckBox.CHECKED, ContextType.GLOBAL_UNDEPLOY))); globalScriptsNode.add(new DefaultMutableTreeTableNode(new MutablePair<Integer, ContextType>( MirthTriStateCheckBox.CHECKED, ContextType.GLOBAL_PREPROCESSOR))); globalScriptsNode.add(new DefaultMutableTreeTableNode(new MutablePair<Integer, ContextType>( MirthTriStateCheckBox.CHECKED, ContextType.GLOBAL_POSTPROCESSOR))); rootContextNode.add(globalScriptsNode); DefaultMutableTreeTableNode channelScriptsNode = new DefaultMutableTreeTableNode( new MutablePair<Integer, String>(MirthTriStateCheckBox.CHECKED, "Channel Scripts")); channelScriptsNode.add(new DefaultMutableTreeTableNode( new MutablePair<Integer, ContextType>(MirthTriStateCheckBox.CHECKED, ContextType.CHANNEL_DEPLOY))); channelScriptsNode.add(new DefaultMutableTreeTableNode(new MutablePair<Integer, ContextType>( MirthTriStateCheckBox.CHECKED, ContextType.CHANNEL_UNDEPLOY))); channelScriptsNode.add(new DefaultMutableTreeTableNode(new MutablePair<Integer, ContextType>( MirthTriStateCheckBox.CHECKED, ContextType.CHANNEL_PREPROCESSOR))); channelScriptsNode.add(new DefaultMutableTreeTableNode(new MutablePair<Integer, ContextType>( MirthTriStateCheckBox.CHECKED, ContextType.CHANNEL_POSTPROCESSOR))); channelScriptsNode.add(new DefaultMutableTreeTableNode(new MutablePair<Integer, ContextType>( MirthTriStateCheckBox.CHECKED, ContextType.CHANNEL_ATTACHMENT))); channelScriptsNode.add(new DefaultMutableTreeTableNode( new MutablePair<Integer, ContextType>(MirthTriStateCheckBox.CHECKED, ContextType.CHANNEL_BATCH))); rootContextNode.add(channelScriptsNode); DefaultMutableTreeTableNode sourceConnectorNode = new DefaultMutableTreeTableNode( new MutablePair<Integer, String>(MirthTriStateCheckBox.CHECKED, "Source Connector")); sourceConnectorNode.add(new DefaultMutableTreeTableNode( new MutablePair<Integer, ContextType>(MirthTriStateCheckBox.CHECKED, ContextType.SOURCE_RECEIVER))); sourceConnectorNode.add(new DefaultMutableTreeTableNode(new MutablePair<Integer, ContextType>( MirthTriStateCheckBox.CHECKED, ContextType.SOURCE_FILTER_TRANSFORMER))); rootContextNode.add(sourceConnectorNode); DefaultMutableTreeTableNode destinationConnectorNode = new DefaultMutableTreeTableNode( new MutablePair<Integer, String>(MirthTriStateCheckBox.CHECKED, "Destination Connector")); destinationConnectorNode.add(new DefaultMutableTreeTableNode(new MutablePair<Integer, ContextType>( MirthTriStateCheckBox.CHECKED, ContextType.DESTINATION_FILTER_TRANSFORMER))); destinationConnectorNode.add(new DefaultMutableTreeTableNode(new MutablePair<Integer, ContextType>( MirthTriStateCheckBox.CHECKED, ContextType.DESTINATION_DISPATCHER))); destinationConnectorNode.add(new DefaultMutableTreeTableNode(new MutablePair<Integer, ContextType>( MirthTriStateCheckBox.CHECKED, ContextType.DESTINATION_RESPONSE_TRANSFORMER))); rootContextNode.add(destinationConnectorNode); DefaultTreeTableModel contextModel = new SortableTreeTableModel(rootContextNode); contextModel.setColumnIdentifiers(Arrays.asList(new String[] { "Context" })); templateContextTreeTable.setTreeTableModel(contextModel); templateContextTreeTable.setRootVisible(false); templateContextTreeTable.setDragEnabled(false); templateContextTreeTable.setRowSelectionAllowed(false); templateContextTreeTable.setRowHeight(UIConstants.ROW_HEIGHT); templateContextTreeTable.setFocusable(false); templateContextTreeTable.setOpaque(true); templateContextTreeTable.getTableHeader().setReorderingAllowed(false); templateContextTreeTable.setEditable(true); templateContextTreeTable.setSortable(false); templateContextTreeTable.setShowGrid(true, true); if (Preferences.userNodeForPackage(Mirth.class).getBoolean("highlightRows", true)) { templateContextTreeTable.setHighlighters(HighlighterFactory .createAlternateStriping(UIConstants.HIGHLIGHTER_COLOR, UIConstants.BACKGROUND_COLOR)); } templateContextTreeTable.setTreeCellRenderer(new ContextTreeTableCellRenderer()); templateContextTreeTable.setOpenIcon(null); templateContextTreeTable.setClosedIcon(null); templateContextTreeTable.setLeafIcon(null); templateContextTreeTable.addMouseListener(new MouseAdapter() { @Override public void mousePressed(MouseEvent evt) { checkSelection(evt); } @Override public void mouseReleased(MouseEvent evt) { checkSelection(evt); } private void checkSelection(MouseEvent evt) { if (templateContextTreeTable.rowAtPoint(new Point(evt.getX(), evt.getY())) < 0) { templateContextTreeTable.clearSelection(); } } }); templateContextTreeTable.getTreeTableModel().addTreeModelListener(new TreeModelListener() { @Override public void treeNodesChanged(TreeModelEvent evt) { if (ArrayUtils.isNotEmpty(evt.getChildren())) { TreeTableNode node = (TreeTableNode) evt.getChildren()[0]; if (evt.getTreePath().getPathCount() == 2) { boolean allChildren = true; boolean noChildren = true; for (Enumeration<? extends TreeTableNode> children = node.getParent().children(); children .hasMoreElements();) { TreeTableNode child = children.nextElement(); if (((Pair<Integer, ContextType>) child.getUserObject()) .getLeft() == MirthTriStateCheckBox.UNCHECKED) { allChildren = false; } else { noChildren = false; } } int value; if (allChildren) { value = MirthTriStateCheckBox.CHECKED; } else if (noChildren) { value = MirthTriStateCheckBox.UNCHECKED; } else { value = MirthTriStateCheckBox.PARTIAL; } ((MutablePair<Integer, String>) node.getParent().getUserObject()).setLeft(value); } else if (evt.getTreePath().getPathCount() == 1) { int value = ((Pair<Integer, String>) node.getUserObject()).getLeft(); for (Enumeration<? extends TreeTableNode> children = node.children(); children .hasMoreElements();) { ((MutablePair<Integer, ContextType>) children.nextElement().getUserObject()) .setLeft(value); } } } } @Override public void treeNodesInserted(TreeModelEvent evt) { } @Override public void treeNodesRemoved(TreeModelEvent evt) { } @Override public void treeStructureChanged(TreeModelEvent evt) { } }); templateContextTreeTableScrollPane = new JScrollPane(templateContextTreeTable); }
From source file:org.forester.archaeopteryx.ControlPanel.java
void setupSearchTools() { final String tip = "Enter text to search for. Use ',' for multiple searches (logical OR) and '+' for logical AND."; final JLabel search_label = new JLabel("Search:"); search_label.setFont(ControlPanel.jcb_bold_font); if (!getConfiguration().isUseNativeUI()) { search_label.setForeground(ControlPanel.jcb_text_color); }/* w w w . j a va2s . co m*/ add(search_label); search_label.setToolTipText(tip); _search_found_label = new JLabel(); getSearchFoundCountsLabel().setVisible(false); _search_found_label.setFont(ControlPanel.jcb_bold_font); if (!getConfiguration().isUseNativeUI()) { _search_found_label.setForeground(ControlPanel.jcb_text_color); //Color of Found: X } _search_tf = new JTextField(3); _search_tf.setToolTipText(tip); _search_tf.setEditable(true); if (!getConfiguration().isUseNativeUI()) { _search_tf.setForeground(Color.GREEN);//ControlPanel.jcb_text_color ); _search_tf.setBackground(ControlPanel.button_background_color); _search_tf.setBorder(null); } _search_reset_button = new JButton(); getSearchResetButton().setText("Reset"); getSearchResetButton().setEnabled(false); getSearchResetButton().setVisible(false); final JPanel s_panel_1 = new JPanel(new BorderLayout()); final JPanel s_panel_2 = new JPanel(new GridLayout(1, 2, 0, 0)); s_panel_1.setBackground(getBackground()); add(s_panel_1); s_panel_2.setBackground(getBackground()); add(s_panel_2); final KeyAdapter key_adapter = new KeyAdapter() { @Override public void keyReleased(final KeyEvent key_event) { search(); displayedPhylogenyMightHaveChanged(true); } }; final ActionListener action_listener = new ActionListener() { @Override public void actionPerformed(final ActionEvent e) { searchReset(); setSearchFoundCountsOnLabel(0); getSearchFoundCountsLabel().setVisible(false); getSearchTextField().setText(""); getSearchResetButton().setEnabled(false); getSearchResetButton().setVisible(false); displayedPhylogenyMightHaveChanged(true); } }; _search_reset_button.addActionListener(action_listener); _search_tf.addKeyListener(key_adapter); addJTextField(_search_tf, s_panel_1); s_panel_2.add(_search_found_label); addJButton(_search_reset_button, s_panel_2); }