List of usage examples for java.awt.event MouseEvent getY
public int getY()
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 w w . jav a 2 s. com 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:nz.govt.natlib.ndha.manualdeposit.ManualDepositMain.java
private void treeEntitiesMouseReleased(java.awt.event.MouseEvent evt) { if (evt.isPopupTrigger()) { TreePath path = treeEntities.getClosestPathForLocation(evt.getX(), evt.getY()); if (path != null) { treeEntities.setSelectionPath(path); DefaultMutableTreeNode node = (DefaultMutableTreeNode) path.getLastPathComponent(); JPopupMenu menu = depositPresenter.getEntityMenu(node); if (menu != null) { menu.show(evt.getComponent(), evt.getX(), evt.getY()); }//from w w w.j av a2s . c om } } }
From source file:nz.govt.natlib.ndha.manualdeposit.ManualDepositMain.java
private void treeStructMapMousePressed(java.awt.event.MouseEvent evt) { if (evt.isPopupTrigger()) { TreePath path = treeStructMap.getClosestPathForLocation(evt.getX(), evt.getY()); if (path != null) { treeStructMap.setSelectionPath(path); DefaultMutableTreeNode node = (DefaultMutableTreeNode) path.getLastPathComponent(); JPopupMenu menu = depositPresenter.getStructMapMenu(node); if (menu != null) { menu.show(evt.getComponent(), evt.getX(), evt.getY()); }/*from w w w. ja v a 2s . c o m*/ } } }
From source file:nz.govt.natlib.ndha.manualdeposit.ManualDepositMain.java
private void treeStructMapMouseReleased(java.awt.event.MouseEvent evt) { if (evt.isPopupTrigger()) { TreePath path = treeStructMap.getClosestPathForLocation(evt.getX(), evt.getY()); if (path != null) { treeStructMap.setSelectionPath(path); DefaultMutableTreeNode node = (DefaultMutableTreeNode) path.getLastPathComponent(); JPopupMenu menu = depositPresenter.getStructMapMenu(node); if (menu != null) { menu.show(evt.getComponent(), evt.getX(), evt.getY()); }/*from w w w .j a v a 2 s. com*/ } } }
From source file:nl.detoren.ijsco.ui.Mainscreen.java
public JPanel createDeelnemersPanel() { JPanel panel = new JPanel(false); panel.setBackground(Color.BLACK); //panel.setLayout(new GridLayout(1, 0)); panel.setLayout(new BorderLayout()); JPanel innerPanel = new JPanel(); JLabel lbAanwezig = new JLabel("Deelnemers: "); innerPanel.add(lbAanwezig, BorderLayout.NORTH); tfAanwezig = new JLabel(Integer.toString(status.deelnemers.aantalAanwezig()), 10); innerPanel.add(tfAanwezig, BorderLayout.NORTH); //innerPanel.setLayout(new GridLayout(1, 0)); innerPanel.add(new JLabel("Naam:"), BorderLayout.NORTH); JTextField deelnemer = new JTextField(15); ArrayList<String> words = new ArrayList<>(); if (status.OSBOSpelers != null) { for (Speler s : status.OSBOSpelers.values()) { words.add(s.getNaam().trim()); words.add(Integer.toString(s.getKnsbnummer())); }//from www.ja v a 2 s . co m } @SuppressWarnings("unused") Suggesties suggesties = new Suggesties(deelnemer, this, words, 2); innerPanel.add(deelnemer, BorderLayout.NORTH); deelnemer.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent event) { actieVoegSpelerToe(deelnemer.getText().trim()); deelnemer.setText(""); } }); JButton btVoegToe = new JButton("Voeg toe"); btVoegToe.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent event) { actieVoegSpelerToe(deelnemer.getText().trim()); deelnemer.setText(""); } }); innerPanel.add(btVoegToe); panel.add(innerPanel); // panel_deelnemers.add(new JLabel("Deelnemers IJSCO toernooi")); deelnemersModel = new DeelnemersModel(panel, status.deelnemers); JTable deelnemersTabel = new JTable(deelnemersModel) { private static final long serialVersionUID = -8293073016982337108L; @Override public Component prepareRenderer(TableCellRenderer renderer, int row, int column) { Component c = super.prepareRenderer(renderer, row, column); DeelnemersModel model = (DeelnemersModel) getModel(); // Tooltip if (c instanceof JComponent) { ((JComponent) c) .setToolTipText(model.getToolTip(convertRowIndexToModel(row), column).toString()); } // Alternate row color if (!isRowSelected(row)) { c.setBackground(row % 2 == 0 ? Color.WHITE : Color.LIGHT_GRAY); } // Highlight overruled entries if (status.deelnemers.get(convertRowIndexToModel(row)).isOverruleNaam() || status.deelnemers.get(convertRowIndexToModel(row)).isOverruleNaam()) { c.setForeground(Color.BLUE); } else { c.setForeground(Color.BLACK); } return c; } }; deelnemersTabel.getModel().addTableModelListener(new TableModelListener() { @Override public void tableChanged(TableModelEvent arg0) { status.groepen = null; status.schemas = null; status.schema = null; groepenText.setText(""); schemaModel.setSchemas(null); schemaModel.fireTableDataChanged(); if (status.deelnemers != null && tfAanwezig != null) { tfAanwezig.setText(Integer.toString(status.deelnemers.aantalAanwezig())); } panel.repaint(); } }); deelnemersTabel.addMouseListener(new MouseAdapter() { @Override public void mouseReleased(MouseEvent e) { logger.log(Level.INFO, "MouseEvent on table fired, type : " + e.toString()); logger.log(Level.INFO, "Popup trigger? : " + e.isPopupTrigger()); if (e.isPopupTrigger()) { int row = deelnemersTabel.rowAtPoint(e.getPoint()); JPopupMenu popup = new JPopupMenu(); JMenuItem menuItem = new JMenuItem("Bewerk speler"); menuItem.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { logger.log(Level.INFO, "Bewerk Speler : " + deelnemersTabel.convertRowIndexToModel(row)); Speler s = status.deelnemers.get(deelnemersTabel.convertRowIndexToModel(row)); BewerkSpelerDialoog rd = new BewerkSpelerDialoog(new JFrame(), "Bewerk Speler", s, deelnemersModel); rd.addWindowListener(new WindowAdapter() { @Override public void windowClosed(WindowEvent e) { System.out.println("closing..."); } }); rd.setVisible(true); } }); popup.add(menuItem); menuItem = new JMenuItem("Verwijder Speler"); popup.add(menuItem); menuItem.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { logger.log(Level.INFO, "Verwijder Speler : " + deelnemersTabel.convertRowIndexToModel(row)); Speler s = status.deelnemers.get(deelnemersTabel.convertRowIndexToModel(row)); status.deelnemers.remove(s); deelnemersModel.fireTableDataChanged(); } }); popup.show(e.getComponent(), e.getX(), e.getY()); } } }); JScrollPane scrollPane = new JScrollPane(); scrollPane.setViewportView(deelnemersTabel); innerPanel.add(scrollPane, BorderLayout.CENTER); TableRowSorter<TableModel> sorter = new TableRowSorter<TableModel>(deelnemersModel); deelnemersTabel.setRowSorter(sorter); innerPanel.add(new JLabel("Filter op : ")); JTextField tfFilter = new JTextField(10); tfFilter.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent event) { String text = tfFilter.getText(); logger.log(Level.INFO, "Filter tabel op : " + text); if (text.length() == 0) { sorter.setRowFilter(null); } else { sorter.setRowFilter(RowFilter.regexFilter("(?i)" + text)); } } }); innerPanel.add(tfFilter); JButton btPasToe = new JButton("Apply"); btPasToe.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent event) { String text = tfFilter.getText(); logger.log(Level.INFO, "Filter tabel op : " + text); if (text.length() == 0) { sorter.setRowFilter(null); } else { sorter.setRowFilter(RowFilter.regexFilter("(?i)" + text)); } } }); innerPanel.add(btPasToe); JButton btWis = new JButton("Wis"); btWis.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent event) { tfFilter.setText(""); logger.log(Level.INFO, "Wis filter"); sorter.setRowFilter(null); } }); innerPanel.add(btWis); Utils.fixedColumSize(deelnemersTabel.getColumnModel().getColumn(0), 30); Utils.fixedColumSize(deelnemersTabel.getColumnModel().getColumn(1), 55); Utils.fixedColumSize(deelnemersTabel.getColumnModel().getColumn(2), 170); Utils.fixedColumSize(deelnemersTabel.getColumnModel().getColumn(3), 40); Utils.fixedColumSize(deelnemersTabel.getColumnModel().getColumn(4), 40); Utils.fixedColumSize(deelnemersTabel.getColumnModel().getColumn(5), 30); Utils.fixedComponentSize(scrollPane, 400, 580); return panel; }
From source file:nz.govt.natlib.ndha.manualdeposit.ManualDepositMain.java
private void treeEntitiesMousePressed(java.awt.event.MouseEvent evt) { if (evt.isPopupTrigger()) { TreePath path = treeEntities.getClosestPathForLocation(evt.getX(), evt.getY()); if (path != null) { treeEntities.setSelectionPath(path); DefaultMutableTreeNode node = (DefaultMutableTreeNode) path.getLastPathComponent(); JPopupMenu menu = depositPresenter.getEntityMenu(node); if (menu != null) { menu.show(evt.getComponent(), evt.getX(), evt.getY()); }//from w ww . j av a 2 s .c o m } } else { setDragSourceEntity(); } }
From source file:nz.govt.natlib.ndha.manualdeposit.ManualDepositMain.java
private void treeFileSystemMouseReleased(java.awt.event.MouseEvent evt) { if (evt.isPopupTrigger()) { TreePath path = treeFileSystem.getClosestPathForLocation(evt.getX(), evt.getY()); if (path != null) { treeFileSystem.setSelectionPath(path); DefaultMutableTreeNode node = (DefaultMutableTreeNode) path.getLastPathComponent(); JPopupMenu menu = depositPresenter.getFileSystemMenu(node); if (menu != null) { menu.show(evt.getComponent(), evt.getX(), evt.getY()); }/*www . j av a 2 s. c o m*/ } } }
From source file:nz.govt.natlib.ndha.manualdeposit.ManualDepositMain.java
private void treeFileSystemMousePressed(java.awt.event.MouseEvent evt) { if (evt.isPopupTrigger()) { TreePath path = treeFileSystem.getClosestPathForLocation(evt.getX(), evt.getY()); if (path != null) { treeFileSystem.setSelectionPath(path); DefaultMutableTreeNode node = (DefaultMutableTreeNode) path.getLastPathComponent(); JPopupMenu menu = depositPresenter.getFileSystemMenu(node); if (menu != null) { menu.show(evt.getComponent(), evt.getX(), evt.getY()); }// www . jav a 2s .co m } } else { setDragSourceFileSystem(); } }
From source file:net.sf.dvstar.transmission.TransmissionView.java
private void showTblTorrentListPopupMenu(MouseEvent e) { tblTorrentListPopupMenu.show(e.getComponent(), e.getX(), e.getY()); }
From source file:nz.govt.natlib.ndha.manualdeposit.ManualDepositMain.java
private void lstProducersMousePressed(java.awt.event.MouseEvent evt) { if (evt.isPopupTrigger()) { JPopupMenu menu = depositPresenter.getProducerMenu(); if (menu != null) { menu.show(evt.getComponent(), evt.getX(), evt.getY()); }/*from w w w .j a v a2s. c om*/ } }