List of usage examples for java.awt.event MouseEvent getY
public int getY()
From source file:com.net2plan.gui.utils.viewEditTopolTables.specificTables.AdvancedJTable_multicastDemand.java
@Override public void doPopup(final MouseEvent e, final int row, final Object itemId) { JPopupMenu popup = new JPopupMenu(); final ITableRowFilter rf = callback.getVisualizationState().getTableRowFilter(); final List<MulticastDemand> demandRowsInTheTable = getVisibleElementsInTable(); /* Add the popup menu option of the filters */ final List<MulticastDemand> selectedDemands = (List<MulticastDemand>) (List<?>) getSelectedElements() .getFirst();/*from w ww . j a v a 2 s .c o m*/ if (!selectedDemands.isEmpty()) { final JMenu submenuFilters = new JMenu("Filters"); final JMenuItem filterKeepElementsAffectedThisLayer = new JMenuItem( "This layer: Keep elements associated to this demand traffic"); final JMenuItem filterKeepElementsAffectedAllLayers = new JMenuItem( "All layers: Keep elements associated to this demand traffic"); submenuFilters.add(filterKeepElementsAffectedThisLayer); if (callback.getDesign().getNumberOfLayers() > 1) submenuFilters.add(filterKeepElementsAffectedAllLayers); filterKeepElementsAffectedThisLayer.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { if (selectedDemands.size() > 1) throw new RuntimeException(); TBFToFromCarriedTraffic filter = new TBFToFromCarriedTraffic(selectedDemands.get(0), true); callback.getVisualizationState().updateTableRowFilter(filter); callback.updateVisualizationJustTables(); } }); filterKeepElementsAffectedAllLayers.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { if (selectedDemands.size() > 1) throw new RuntimeException(); TBFToFromCarriedTraffic filter = new TBFToFromCarriedTraffic(selectedDemands.get(0), false); callback.getVisualizationState().updateTableRowFilter(filter); callback.updateVisualizationJustTables(); } }); popup.add(submenuFilters); popup.addSeparator(); } if (callback.getVisualizationState().isNetPlanEditable()) { popup.add(getAddOption()); for (JComponent item : getExtraAddOptions()) popup.add(item); } if (!demandRowsInTheTable.isEmpty()) { if (callback.getVisualizationState().isNetPlanEditable()) { if (row != -1) { if (popup.getSubElements().length > 0) popup.addSeparator(); if (networkElementType == NetworkElementType.LAYER && callback.getDesign().getNumberOfLayers() == 1) { } else { JMenuItem removeItem = new JMenuItem("Remove " + networkElementType); removeItem.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { NetPlan netPlan = callback.getDesign(); try { netPlan.getMulticastDemandFromId((long) itemId).remove(); callback.getVisualizationState() .recomputeCanvasTopologyBecauseOfLinkOrNodeAdditionsOrRemovals(); callback.updateVisualizationAfterChanges( Collections.singleton(NetworkElementType.MULTICAST_DEMAND)); callback.getUndoRedoNavigationManager().addNetPlanChange(); } catch (Throwable ex) { ErrorHandling.addErrorOrException(ex, getClass()); ErrorHandling.showErrorDialog("Unable to remove " + networkElementType); } } }); popup.add(removeItem); } addPopupMenuAttributeOptions(e, row, itemId, popup); } if (networkElementType != NetworkElementType.LAYER) { JMenuItem removeItems = new JMenuItem("Remove all " + networkElementType + "s in table"); removeItems.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { NetPlan netPlan = callback.getDesign(); try { if (rf == null) netPlan.removeAllMulticastDemands(); else for (MulticastDemand d : demandRowsInTheTable) d.remove(); callback.getVisualizationState() .recomputeCanvasTopologyBecauseOfLinkOrNodeAdditionsOrRemovals(); callback.updateVisualizationAfterChanges( Collections.singleton(NetworkElementType.MULTICAST_DEMAND)); callback.getUndoRedoNavigationManager().addNetPlanChange(); } catch (Throwable ex) { ex.printStackTrace(); ErrorHandling.showErrorDialog(ex.getMessage(), "Unable to remove all " + networkElementType + "s"); } } }); popup.add(removeItems); } List<JComponent> extraOptions = getExtraOptions(row, itemId); if (!extraOptions.isEmpty()) { if (popup.getSubElements().length > 0) popup.addSeparator(); for (JComponent item : extraOptions) popup.add(item); } } List<JComponent> forcedOptions = getForcedOptions(); if (!forcedOptions.isEmpty()) { if (popup.getSubElements().length > 0) popup.addSeparator(); for (JComponent item : forcedOptions) popup.add(item); } } popup.show(e.getComponent(), e.getX(), e.getY()); }
From source file:base.BasePlayer.Main.java
public Main() { super(new GridBagLayout()); try {//from w w w . ja va 2 s .c o m //UIManager.put("PopupMenu.border", BorderFactory.createMatteBorder(0, 20, 0, 0, new Color(230,230,230))); //URL fontUrl = new URL("http://www.webpagepublicity.com/" + // "free-fonts/a/Airacobra%20Condensed.ttf"); // URL fontUrl = new URL("C:/HY-Data/RKATAINE/WinPython-64bit-3.5.3.1Qt5/python-3.5.3.amd64/share/numdifftools/docs/_build/html/_static/fonts/Inconsolata-Regular.ttf"); // URL fonturl = this.getClass().getResource("OpenSans-Regular.ttf"); // menuFont = Font.createFont(Font.TRUETYPE_FONT, new File(fonturl.getFile())); // C:\HY-Data\RKATAINE\WinPython-64bit-3.5.3.1Qt5\python-3.5.3.amd64\Lib\site-packages\reportlab\fonts Launcher.fromMain = true; Launcher.main(args); VariantHandler.main(argsit); glass = Toolkit.getDefaultToolkit().getImage(getClass().getResource("icons/glass.jpg")); ToolTipManager.sharedInstance().setInitialDelay(100); // ToolTipManager.sharedInstance().setDismissDelay(2000); UIManager.put("ToolTip.background", new Color(255, 255, 214)); UIManager.put("ToolTip.border", BorderFactory.createCompoundBorder( UIManager.getBorder("ToolTip.border"), BorderFactory.createEmptyBorder(4, 4, 4, 4))); lineseparator = System.getProperty("line.separator"); proxysettings = new ProxySettings(); panel = new JPanel(new GridBagLayout()); //menuFont = menuFont.deriveFont(Font.PLAIN,12); Draw.defaultFont = menuFont; gd = GraphicsEnvironment.getLocalGraphicsEnvironment().getDefaultScreenDevice(); width = gd.getDisplayMode().getWidth(); height = gd.getDisplayMode().getHeight(); if (Launcher.fontSize.equals("")) { if (width < 1500) { defaultFontSize = 11; buttonHeight = Main.defaultFontSize * 2; buttonWidth = Main.defaultFontSize * 6; } else if (width < 2000) { defaultFontSize = 12; buttonHeight = Main.defaultFontSize * 2 + 4; buttonWidth = Main.defaultFontSize * 6 + 4; } else if (width < 3000) { defaultFontSize = 15; buttonHeight = Main.defaultFontSize * 2 + 4; buttonWidth = Main.defaultFontSize * 6 + 4; } else { defaultFontSize = 19; buttonHeight = Main.defaultFontSize * 2 + 4; buttonWidth = Main.defaultFontSize * 6 + 4; } } else { try { defaultFontSize = Integer.parseInt(Launcher.fontSize); } catch (Exception e) { defaultFontSize = 12; } } menuFont = new Font("SansSerif", Font.PLAIN, Main.defaultFontSize); menuFontBold = new Font("SansSerif", Font.BOLD, Main.defaultFontSize); // menuFont = new Font("SansSerif", Font.BOLD, Main.defaultFontSize); } catch (Exception e) { e.printStackTrace(); } FileSystemView fsv = FileSystemView.getFileSystemView(); File[] paths = File.listRoots(); for (File path : paths) { if (fsv.getSystemDisplayName(path).contains("merit")) { pleiades = true; } } screenSize = new Dimension(width, height); drawHeight = (int) (screenSize.getHeight() * 0.6); sidebarWidth = (int) (screenSize.getWidth() * 0.1); drawWidth = (int) (screenSize.getWidth() - sidebarWidth); thisMainListener = this; try { htsjdk.samtools.util.Log.setGlobalLogLevel(htsjdk.samtools.util.Log.LogLevel.ERROR); /* for(int i=0;i<snow.length; i++) { snow[i][0] = (height*Math.random()); snow[i][1] = (4*Math.random() +1); snow[i][2] = (12*Math.random() -6); snow[i][3] = (2*Math.random() +1); }*/ frame.addWindowListener(new java.awt.event.WindowAdapter() { @Override public void windowClosing(java.awt.event.WindowEvent windowEvent) { /*if (JOptionPane.showConfirmDialog(frame, "Are you sure to close this window?", "Really Closing?", JOptionPane.YES_NO_OPTION, JOptionPane.QUESTION_MESSAGE) == JOptionPane.YES_OPTION){ System.exit(0); }*/ if (configChanged) { try { BufferedWriter fileWriter = new BufferedWriter(new FileWriter(Launcher.configfile)); for (int i = 0; i < Launcher.config.size(); i++) { fileWriter.write(Launcher.config.get(i) + lineseparator); } fileWriter.close(); } catch (Exception e) { e.printStackTrace(); } } } }); baseMap.put((byte) 'A', 1); baseMap.put((byte) 'C', 2); baseMap.put((byte) 'G', 3); baseMap.put((byte) 'T', 4); baseMap.put((byte) 'N', 5); baseMap.put((byte) 'I', 6); baseMap.put((byte) 'D', 7); mutTypes.put("TA", 0); mutTypes.put("AT", 0); mutTypes.put("TC", 1); mutTypes.put("AG", 1); mutTypes.put("TG", 2); mutTypes.put("AC", 2); mutTypes.put("CA", 3); mutTypes.put("GT", 3); mutTypes.put("CG", 4); mutTypes.put("GC", 4); mutTypes.put("CT", 5); mutTypes.put("GA", 5); getBase.put((byte) 'A', "A"); getBase.put((byte) 'C', "C"); getBase.put((byte) 'G', "G"); getBase.put((byte) 'T', "T"); getBase.put((byte) 'N', "N"); getBase.put((byte) 'a', "A"); getBase.put((byte) 'c', "C"); getBase.put((byte) 'g', "G"); getBase.put((byte) 't', "T"); getBase.put((byte) 'n', "N"); java.net.URL imgUrl = getClass().getResource("icons/save.gif"); save = new ImageIcon(imgUrl); imgUrl = getClass().getResource("icons/open.gif"); open = new ImageIcon(imgUrl); imgUrl = getClass().getResource("icons/settings.png"); settingsIcon = new ImageIcon(imgUrl); userDir = new File(Main.class.getProtectionDomain().getCodeSource().getLocation().getPath()).getParent() .replace("%20", " "); settings = new JMenuItem("Settings", settingsIcon); // Average.frame.setVisible(false); try { savedir = Launcher.defaultSaveDir; path = Launcher.defaultDir; gerp = Launcher.gerpfile; defaultGenome = Launcher.defaultGenome; defaultAnnotation = Launcher.defaultAnnotation; isProxy = Launcher.isProxy; proxyHost = Launcher.proxyHost; proxyPort = Launcher.proxyPort; proxyType = Launcher.proxyType; if (isProxy) { ProxySettings.useProxy.setSelected(true); } if (!proxyHost.equals("")) { ProxySettings.hostField.setText(proxyHost); } if (!proxyPort.equals("")) { ProxySettings.portField.setText(proxyPort); } if (!Launcher.proxyType.equals("")) { ProxySettings.proxytypes.setSelectedItem(proxyType); } if (Launcher.backColor.equals("")) { Draw.backColor = new Color(90, 90, 90); } else { Draw.backColor = new Color(Integer.parseInt(Launcher.backColor), Integer.parseInt(Launcher.backColor), Integer.parseInt(Launcher.backColor)); Settings.graySlider.setValue(Integer.parseInt(Launcher.backColor)); } if (Launcher.genomeDir.equals("")) { genomeDir = new File(userDir + "/genomes/"); } else { if (new File(Launcher.genomeDir).exists()) { genomeDir = new File(Launcher.genomeDir); } else { genomeDir = new File(userDir + "/genomes/"); } } annotationfile = defaultAnnotation; controlDir = Launcher.ctrldir; trackDir = Launcher.trackDir; projectDir = Launcher.projectDir; downloadDir = Launcher.downloadDir; } catch (Exception e) { e.printStackTrace(); } File[] genomes = genomeDir.listFiles(new FilenameFilter() { public boolean accept(File dir, String name) { return !name.contains(".txt") && !name.startsWith("."); } }); chromHeight = (int) (drawHeight * 0.1); drawDimensions = new Dimension(drawWidth, drawHeight - chromHeight); bedDimensions = new Dimension(drawWidth, bedHeight); chromDimensions = new Dimension(drawWidth - Main.sidebarWidth - 1, drawHeight); drawCanvas = new Draw((int) drawDimensions.getWidth(), (int) drawDimensions.getHeight()); controlDraw = new ControlCanvas((int) bedDimensions.getWidth(), (int) bedDimensions.getHeight()); iconImage = Toolkit.getDefaultToolkit().getImage(getClass().getResource("icons/icon.png")); frame.setIconImage(iconImage); /* if(args.length > 0) { for(int i = 0; i<args.length; i++) { if(args[i].startsWith("-opendir")) { path = args[i].substring(9).replace(" ", ""); } else if(args[i].startsWith("-ctrldir")) { Control.path = args[i].substring(9).replace(" ", ""); } } }*/ // BGZIPInputStream in = this.getClass().getResourceAsStream("SELEX_1505_representative_matrices.bedhead.gz"); searchField.getDocument().addDocumentListener(new DocumentListener() { private String searchstring; public void changedUpdate(DocumentEvent e) { if (searchField.getText().contains(";")) { searchList = searchField.getText().split(";"); for (int i = 0; i < searchList.length; i++) { warn(searchList[i].replace(" ", "")); } } else { warn(searchField.getText().replace(" ", "")); } } public void removeUpdate(DocumentEvent e) { if (searchField.getText().contains(";")) { searchList = searchField.getText().split(";"); for (int i = 0; i < searchList.length; i++) { warn(searchList[i].replace(" ", "")); } } else { warn(searchField.getText().replace(" ", "")); } } public void insertUpdate(DocumentEvent e) { if (searchField.getText().contains(";")) { searchList = searchField.getText().split(";"); for (int i = 0; i < searchList.length; i++) { warn(searchList[i].replace(" ", "")); } } else { warn(searchField.getText().replace(" ", "")); } } public void warn(String searchtext) { if (searchTable.containsKey(searchtext.toUpperCase())) { if (searchTable.get(searchtext.toUpperCase())[0] .equals(Main.chromosomeDropdown.getSelectedItem())) { searchChrom = searchTable.get(searchtext.toUpperCase())[0]; searchStart = Integer.parseInt(searchTable.get(searchtext.toUpperCase())[1]); searchEnd = Integer.parseInt(searchTable.get(searchtext.toUpperCase())[2]); } else { chromDraw.repaint(); searchStart = -1; searchEnd = -1; } chromDraw.repaint(); searchField.setForeground(Color.black); } else if (searchField.getText().toUpperCase().matches("CHR.{1,2}(?!:)")) { if (Main.chromnamevector.contains(searchtext.toUpperCase().substring(3))) { searchField.setForeground(Color.black); } else { chromDraw.repaint(); searchField.setForeground(Color.red); } } else if (searchtext.toUpperCase().replace(",", "").matches("(CHR)?(.+:)?\\d+(-\\d+)?")) { searchField.setForeground(Color.black); if (searchtext.contains(":")) { searchstring = searchtext.substring(searchtext.indexOf(":") + 1).replace(",", ""); } else { chromDraw.repaint(); searchstring = searchtext.replace(",", ""); } if (!searchstring.contains("-")) { try { searchStart = Integer.parseInt(searchstring); } catch (Exception ex) { } searchEnd = -1; } else { try { searchStart = Integer .parseInt(searchstring.substring(0, searchstring.indexOf("-"))); searchEnd = Integer.parseInt(searchstring.substring(searchstring.indexOf("-") + 1)); } catch (Exception ex) { } } chromDraw.repaint(); } else { chromDraw.repaint(); searchField.setForeground(Color.red); searchStart = -1; searchEnd = -1; } } }); try { A = Toolkit.getDefaultToolkit().getImage(getClass().getResource("SELEX/A.png")); C = Toolkit.getDefaultToolkit().getImage(getClass().getResource("SELEX/C.png")); G = Toolkit.getDefaultToolkit().getImage(getClass().getResource("SELEX/G.png")); T = Toolkit.getDefaultToolkit().getImage(getClass().getResource("SELEX/T.png")); } catch (Exception e) { e.printStackTrace(); } ErrorLog.main(args); this.setBackground(Color.black); UIManager.put("FileChooser.readOnly", Boolean.TRUE); panel.setBackground(Draw.sidecolor); panel.setBorder(BorderFactory.createLineBorder(Color.white)); searchField.addKeyListener(this); frame.addKeyListener(this); frame.getContentPane().setBackground(Color.black); glassPane.addMouseListener(this); glassPane.addMouseMotionListener(new MouseMotionListener() { @Override public void mouseDragged(MouseEvent arg0) { } @Override public void mouseMoved(MouseEvent event) { // g.drawRect(drawScroll.getWidth()/2-Main.canceltextwidth/2-Main.defaultFontSize/2, Main.drawScroll.getViewport().getHeight()*2/3+Draw.loadingFont.getSize()*3-Main.defaultFontSize/4, Main.canceltextwidth+Main.defaultFontSize, Draw.loadingFont.getSize()+Main.defaultFontSize/2); if (drawCanvas.loading && event.getX() > drawScroll.getWidth() / 2 - Main.canceltextwidth / 2 - Main.defaultFontSize / 2 && event.getX() < drawScroll.getWidth() / 2 + Main.canceltextwidth / 2 + Main.defaultFontSize / 2 && event.getY() > frame.getHeight() * 1 / 3 + Draw.loadingFont.getSize() * 3 - Main.defaultFontSize / 4 && event.getY() < frame.getHeight() * 1 / 3 + Draw.loadingFont.getSize() * 4 + Main.defaultFontSize / 2) { if (!Main.cancelhover) { Main.cancelhover = true; Main.glassPane.requestFocus(); } } else { if (Main.cancelhover) { Main.cancelhover = false; Main.glassPane.requestFocus(false); } } } }); background.put((byte) 'A', 0.3); background.put((byte) 'C', 0.2); background.put((byte) 'G', 0.2); background.put((byte) 'T', 0.3); bases = new Hashtable<String, String>(); bases.put("A", "A"); bases.put("C", "C"); bases.put("G", "G"); bases.put("T", "T"); bases.put("N", "N"); bases.put("delA", "delA"); bases.put("delC", "delC"); bases.put("delG", "delG"); bases.put("delT", "delT"); bases.put("insA", "insA"); bases.put("insC", "insC"); bases.put("insG", "insG"); bases.put("insT", "insT"); chromDraw = new ChromDraw(drawWidth, chromHeight); VariantCaller.main(argsit); PeakCaller.main(argsit); tablebrowser = new TableBrowser(); bedconverter = new BEDconvert(); try { File annodir; File[] annotations; addGenome.addMouseListener(this); genome = new JMenu("Genomes"); genome.setName("genomeMenu"); genome.add(addGenome); genome.addComponentListener(this); File[] fastadir; String[] empty = {}; refModel = new DefaultComboBoxModel<String>(empty); refDropdown = new SteppedComboBox(refModel); refDropdown.addMouseListener(this); String[] emptygenes = {}; refDropdown.addActionListener(refDropActionListener); geneModel = new DefaultComboBoxModel<String>(emptygenes); geneDropdown = new SteppedComboBox(geneModel); geneDropdown.addMouseListener(this); if (genomes != null) { for (int i = 0; i < genomes.length; i++) { if (!genomes[i].isDirectory()) { continue; } annodir = new File(genomes[i].getAbsolutePath() + "/annotation/"); if (genomes[i].isDirectory()) { fastadir = genomes[i].listFiles(); for (int f = 0; f < fastadir.length; f++) { if (fastadir[f].isDirectory()) { continue; } if (fastadir[f].getName().contains(".fai")) { continue; } else if (fastadir[f].getName().contains(".fa")) { fastahash.put(genomes[i].getName(), fastadir[f]); } } } annotations = annodir.listFiles(); genomehash.put(genomes[i].getName(), new ArrayList<File>()); refModel.addElement(genomes[i].getName()); if (genomes[i].getName().length() > reflength) { reflength = genomes[i].getName().length(); } JMenu addMenu = new JMenu(genomes[i].getName()); addMenu.addMouseListener(this); addMenu.setName(genomes[i].getName()); JMenuItem addAnnotation = new JMenuItem("Add new annotation file..."); addAnnotation.addMouseListener(this); addAnnotation.setName("add_annotation"); addMenu.add(addAnnotation); JLabel addLabel = new JLabel(" Select annotation: "); labels.add(addLabel); addMenu.add(addLabel); addMenu.add(new JSeparator()); genome.add(addMenu); addMenu.addComponentListener(this); if (annotations != null) { for (int j = 0; j < annotations.length; j++) { annofiles = annotations[j].listFiles(); for (int f = 0; f < annofiles.length; f++) { if (annofiles[f].getName().endsWith(".bed.gz")) { if (annofiles[f].getName() .substring(0, annofiles[f].getName().indexOf(".bed.gz")) .length() > annolength) { annolength = annofiles[f].getName().length(); } genomehash.get(genomes[i].getName()).add(annofiles[f].getAbsoluteFile()); JMenuItem additem = new JMenuItem(annofiles[f].getName().substring(0, annofiles[f].getName().indexOf(".bed.gz"))); additem.setName(annofiles[f].getName().substring(0, annofiles[f].getName().indexOf(".bed.gz"))); additem.addMouseListener(this); addMenu.add(additem); additem.addComponentListener(this); break; } } } } } refModel.addElement("Add new reference..."); } if (genomes.length == 0) { /*if(Launcher.firstStart) { Main.writeToConfig("FirstStart=false"); }*/ AddGenome.createAndShowGUI(); AddGenome.frame.setTitle("Add new genome"); AddGenome.remove.setEnabled(false); AddGenome.download.setEnabled(false); AddGenome.frame.setLocation((int) (screenSize.getWidth() / 2 - AddGenome.frame.getWidth() / 2), (int) (screenSize.getHeight() / 6)); AddGenome.frame.setState(JFrame.NORMAL); AddGenome.frame.setVisible(true); AddGenome.frame.setAlwaysOnTop(true); /* WelcomeScreen.main(args); WelcomeScreen.frame.setVisible(true); WelcomeScreen.frame.setLocation(frame.getLocationOnScreen().x+frame.getWidth()/2 - WelcomeScreen.frame.getWidth()/2, frame.getLocationOnScreen().y+frame.getHeight()/6); */ if (genomes.length != 0) { if (!genomehash.containsKey(defaultGenome)) { setChromDrop(genomes[0].getName()); defaultGenome = genomes[0].getName(); } else { setChromDrop(defaultGenome); } getBands(); getExons(); } else { setChromDrop(null); } } else { if (!genomehash.containsKey(defaultGenome)) { setChromDrop(genomes[0].getName()); defaultGenome = genomes[0].getName(); } else { setChromDrop(defaultGenome); } getBands(); getExons(); } if (Launcher.firstStart) { WelcomeScreen.createAndShowGUI(); WelcomeScreen.frame.setLocation( (int) (screenSize.getWidth() / 2 - WelcomeScreen.frame.getWidth() / 2), (int) (screenSize.getHeight() / 6)); WelcomeScreen.frame.setVisible(true); } setMenuBar(); setButtons(); Settings.main(args); // Settings.main(args); frame.requestFocus(); drawCanvas.addKeyListener(this); bedCanvas.addKeyListener(this); setFonts(); chromLabel.setText("Chromosome " + chromosomeDropdown.getSelectedItem().toString()); CheckUpdates check = new CheckUpdates(); check.execute(); // Main.drawCanvas.loading("test"); Main.drawCanvas.splits.get(0) .setCytoImage(Main.chromDraw.createBands(Main.drawCanvas.splits.get(0))); } catch (Exception e) { e.printStackTrace(); } } catch (Exception ex) { ex.printStackTrace(); Main.showError(ex.getMessage(), "Error"); } }
From source file:app.RunApp.java
/** * Action when mouse released of Co-ocurrence panel * //from ww w . j a v a 2s .com * @param evt Event */ private void panelCoOcurrenceMouseReleased(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_panelCoOcurrenceMouseReleased if (evt.getButton() == MouseEvent.BUTTON3) { jPopupMenu1.removeAll(); JMenuItem saver = new JMenuItem("Save as..."); saver.addActionListener(new java.awt.event.ActionListener() { @Override public void actionPerformed(java.awt.event.ActionEvent evt) { try { saveCoocurrenceGraph(); } catch (AWTException | IOException ex) { Logger.getLogger(RunApp.class.getName()).log(Level.SEVERE, null, ex); } } }); jPopupMenu1.add(saver); jPopupMenu1.show(evt.getComponent(), evt.getX(), evt.getY()); } }
From source file:com.peterbochs.PeterBochsDebugger.java
private void jELFTableMouseClicked(MouseEvent evt) { if (SwingUtilities.isRightMouseButton(evt)) { // select Point p = evt.getPoint(); int rowNumber = elfTable.rowAtPoint(p); int columnNumber = elfTable.columnAtPoint(p); ListSelectionModel model = elfTable.getSelectionModel(); model.setSelectionInterval(rowNumber, rowNumber); elfTable.getColumnModel().getSelectionModel().setSelectionInterval(columnNumber, columnNumber); // end select getJELFTablePopupMenu().show(evt.getComponent(), evt.getX(), evt.getY()); }// ww w . j ava 2s . c o m }
From source file:com.peterbochs.PeterBochsDebugger.java
private void jHexTable1MouseClicked(MouseEvent evt) { if (SwingUtilities.isRightMouseButton(evt)) { // select Point p = evt.getPoint(); int rowNumber = jHexTable1.rowAtPoint(p); int columnNumber = jHexTable1.columnAtPoint(p); ListSelectionModel model = jHexTable1.getSelectionModel(); model.setSelectionInterval(rowNumber, rowNumber); jHexTable1.getColumnModel().getSelectionModel().setSelectionInterval(columnNumber, columnNumber); // end select getJHexTablePopupMenu().show(evt.getComponent(), evt.getX(), evt.getY()); }// www . j a v a 2s .c o m }
From source file:com.peterbochs.PeterBochsDebugger.java
private void breakpointTableMouseClicked(MouseEvent evt) { if (SwingUtilities.isRightMouseButton(evt)) { // select Point p = evt.getPoint(); int rowNumber = breakpointTable.rowAtPoint(p); int columnNumber = breakpointTable.columnAtPoint(p); ListSelectionModel model = breakpointTable.getSelectionModel(); model.setSelectionInterval(rowNumber, rowNumber); breakpointTable.getColumnModel().getSelectionModel().setSelectionInterval(columnNumber, columnNumber); // end select getJBreakpointPopupMenu().show(evt.getComponent(), evt.getX(), evt.getY()); }/* w w w. java 2 s.c om*/ }
From source file:com.peterbochs.PeterBochsDebugger.java
private void jSearchMemoryTableMouseClicked(MouseEvent evt) { if (SwingUtilities.isRightMouseButton(evt)) { // select Point p = evt.getPoint(); int rowNumber = jSearchMemoryTable.rowAtPoint(p); int columnNumber = jSearchMemoryTable.columnAtPoint(p); ListSelectionModel model = jSearchMemoryTable.getSelectionModel(); model.setSelectionInterval(rowNumber, rowNumber); jSearchMemoryTable.getColumnModel().getSelectionModel().setSelectionInterval(columnNumber, columnNumber);// ww w . j a v a2s. c o m // end select getJSearchMemoryTablePopupMenu().show(evt.getComponent(), evt.getX(), evt.getY()); } }
From source file:com.peterbochs.PeterBochsDebugger.java
public void instructionTableMouseClicked(MouseEvent evt) { if (SwingUtilities.isRightMouseButton(evt)) { JTable jTable = (JTable) evt.getSource(); if (jTable == instructionTable) { Global.clickedWhichInstructionPanel = 0; } else {/* w ww . j a va2 s . c o m*/ Global.clickedWhichInstructionPanel = 1; } // select Point p = evt.getPoint(); int rowNumber = jTable.rowAtPoint(p); int columnNumber = jTable.columnAtPoint(p); ListSelectionModel model = jTable.getSelectionModel(); model.setSelectionInterval(rowNumber, rowNumber); jTable.getColumnModel().getSelectionModel().setSelectionInterval(columnNumber, columnNumber); // end select getJInstructionPanelPopupMenu().show(evt.getComponent(), evt.getX(), evt.getY()); } }
From source file:com.mirth.connect.client.ui.codetemplate.CodeTemplateImportDialog.java
private void initComponents() { setBackground(UIConstants.BACKGROUND_COLOR); getContentPane().setBackground(getBackground()); topPanel = new JPanel(); topPanel.setBackground(getBackground()); linkPanel = new JPanel(); linkPanel.setBackground(topPanel.getBackground()); linkLeftPanel = new JPanel(); linkLeftPanel.setBackground(linkPanel.getBackground()); linkLeftSelectAllLabel = new JLabel("<html><u>All</u></html>"); linkLeftSelectAllLabel.setForeground(Color.BLUE); linkLeftSelectAllLabel.setCursor(new Cursor(Cursor.HAND_CURSOR)); linkLeftSelectAllLabel.addMouseListener(new MouseAdapter() { public void mouseReleased(MouseEvent evt) { for (int row = 0; row < importTreeTable.getRowCount(); row++) { importTreeTable.getModel().setValueAt(true, row, IMPORT_SELECTED_COLUMN); }//w w w. j av a 2 s. com } }); linkLeftDeselectAllLabel = new JLabel("<html><u>None</u></html>"); linkLeftDeselectAllLabel.setForeground(Color.BLUE); linkLeftDeselectAllLabel.setCursor(new Cursor(Cursor.HAND_CURSOR)); linkLeftDeselectAllLabel.addMouseListener(new MouseAdapter() { public void mouseReleased(MouseEvent evt) { for (int row = 0; row < importTreeTable.getRowCount(); row++) { importTreeTable.getModel().setValueAt(false, row, IMPORT_SELECTED_COLUMN); } } }); linkRightPanel = new JPanel(); linkRightPanel.setBackground(linkPanel.getBackground()); linkRightOverwriteAllLabel = new JLabel("<html><u>All</u></html>"); linkRightOverwriteAllLabel.setForeground(Color.BLUE); linkRightOverwriteAllLabel.setCursor(new Cursor(Cursor.HAND_CURSOR)); linkRightOverwriteAllLabel.addMouseListener(new MouseAdapter() { public void mouseReleased(MouseEvent evt) { for (int row = 0; row < importTreeTable.getRowCount(); row++) { TreePath path = importTreeTable.getPathForRow(row); if (path != null) { ImportTreeTableNode node = (ImportTreeTableNode) path.getLastPathComponent(); if (node instanceof ImportLibraryTreeTableNode) { ImportLibraryTreeTableNode libraryNode = (ImportLibraryTreeTableNode) node; if (libraryNode.getConflicts().getMatchingLibrary() != null) { importTreeTable.getModel().setValueAt(true, row, IMPORT_OVERWRITE_COLUMN); } } else if (node instanceof ImportCodeTemplateTreeTableNode) { ImportCodeTemplateTreeTableNode codeTemplateNode = (ImportCodeTemplateTreeTableNode) node; if (codeTemplateNode.getConflicts().getMatchingCodeTemplate() != null) { importTreeTable.getModel().setValueAt(true, row, IMPORT_OVERWRITE_COLUMN); } } } } } }); linkRightOverwriteNoneLabel = new JLabel("<html><u>None</u></html>"); linkRightOverwriteNoneLabel.setForeground(Color.BLUE); linkRightOverwriteNoneLabel.setCursor(new Cursor(Cursor.HAND_CURSOR)); linkRightOverwriteNoneLabel.addMouseListener(new MouseAdapter() { public void mouseReleased(MouseEvent evt) { for (int row = 0; row < importTreeTable.getRowCount(); row++) { TreePath path = importTreeTable.getPathForRow(row); if (path != null) { ImportTreeTableNode node = (ImportTreeTableNode) path.getLastPathComponent(); if (node instanceof ImportLibraryTreeTableNode) { ImportLibraryTreeTableNode libraryNode = (ImportLibraryTreeTableNode) node; if (libraryNode.getConflicts().getMatchingLibrary() != null) { importTreeTable.getModel().setValueAt(false, row, IMPORT_OVERWRITE_COLUMN); } } else if (node instanceof ImportCodeTemplateTreeTableNode) { ImportCodeTemplateTreeTableNode codeTemplateNode = (ImportCodeTemplateTreeTableNode) node; if (codeTemplateNode.getConflicts().getMatchingCodeTemplate() != null) { importTreeTable.getModel().setValueAt(false, row, IMPORT_OVERWRITE_COLUMN); } } } } } }); final TableCellEditor templateCellEditor = new NameCellEditor(); importTreeTable = new JXTreeTable() { @Override public boolean isCellEditable(int row, int column) { return (column == IMPORT_OVERWRITE_COLUMN || column == IMPORT_SELECTED_COLUMN || column == IMPORT_NAME_COLUMN); } @Override public TableCellEditor getCellEditor(int row, int column) { if (isHierarchical(column)) { return templateCellEditor; } else { return super.getCellEditor(row, column); } } }; importTreeTable.setLargeModel(true); DefaultTreeTableModel model = new ImportTreeTableModel(); model.setColumnIdentifiers(Arrays.asList(new String[] { "", "Name", "Overwrite", "Conflicts", "Id" })); DefaultMutableTreeTableNode rootNode = new DefaultMutableTreeTableNode(); model.setRoot(rootNode); importTreeTable.setTreeTableModel(model); Set<String> addedCodeTemplateIds = new HashSet<String>(); if (unassignedCodeTemplates) { ImportTreeTableNode libraryNode = new ImportUnassignedLibraryTreeTableNode("Select a library", ""); CodeTemplateLibrary library = importLibraries.get(0); for (CodeTemplate codeTemplate : library.getCodeTemplates()) { if (!addedCodeTemplateIds.contains(codeTemplate.getId())) { libraryNode .add(new ImportCodeTemplateTreeTableNode(codeTemplate.getName(), codeTemplate.getId())); addedCodeTemplateIds.add(codeTemplate.getId()); importCodeTemplateMap.put(codeTemplate.getId(), codeTemplate); } } rootNode.add(libraryNode); } else { Set<String> addedLibraryIds = new HashSet<String>(); for (CodeTemplateLibrary library : importLibraries) { if (!addedLibraryIds.contains(library.getId())) { ImportTreeTableNode libraryNode = new ImportLibraryTreeTableNode(library.getName(), library.getId()); importLibraryMap.put(library.getId(), library); for (CodeTemplate codeTemplate : library.getCodeTemplates()) { if (!addedCodeTemplateIds.contains(codeTemplate.getId())) { libraryNode.add(new ImportCodeTemplateTreeTableNode(codeTemplate.getName(), codeTemplate.getId())); addedCodeTemplateIds.add(codeTemplate.getId()); importCodeTemplateMap.put(codeTemplate.getId(), codeTemplate); } } rootNode.add(libraryNode); addedLibraryIds.add(library.getId()); } } } importTreeTable.setOpenIcon(null); importTreeTable.setClosedIcon(null); importTreeTable.setLeafIcon(null); importTreeTable.setRootVisible(false); importTreeTable.setDoubleBuffered(true); importTreeTable.setDragEnabled(false); importTreeTable.setRowSelectionAllowed(true); importTreeTable.setSelectionMode(ListSelectionModel.SINGLE_SELECTION); importTreeTable.setRowHeight(UIConstants.ROW_HEIGHT); importTreeTable.setFocusable(true); importTreeTable.setOpaque(true); importTreeTable.getTableHeader().setReorderingAllowed(false); importTreeTable.putClientProperty("terminateEditOnFocusLost", Boolean.TRUE); importTreeTable.setEditable(true); importTreeTable.setSortable(false); importTreeTable.setAutoCreateColumnsFromModel(false); importTreeTable.setShowGrid(true, true); if (Preferences.userNodeForPackage(Mirth.class).getBoolean("highlightRows", true)) { importTreeTable.setHighlighters(HighlighterFactory .createAlternateStriping(UIConstants.HIGHLIGHTER_COLOR, UIConstants.BACKGROUND_COLOR)); } importTreeTable.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 = importTreeTable.rowAtPoint(new Point(evt.getX(), evt.getY())); if (row < 0) { importTreeTable.clearSelection(); } } }); importTreeTable.addTreeWillExpandListener(new TreeWillExpandListener() { @Override public void treeWillExpand(TreeExpansionEvent event) throws ExpandVetoException { } @Override public void treeWillCollapse(TreeExpansionEvent event) throws ExpandVetoException { throw new ExpandVetoException(event); } }); importTreeTable.setTreeCellRenderer(new NameCellRenderer()); importTreeTable.getModel().addTableModelListener(new TableModelListener() { @Override public void tableChanged(TableModelEvent evt) { if (evt.getColumn() != IMPORT_CONFLICTS_COLUMN) { for (int row = evt.getFirstRow(); row <= evt.getLastRow() && row < importTreeTable.getRowCount(); row++) { TreePath path = importTreeTable.getPathForRow(row); if (path != null) { ImportTreeTableNode node = (ImportTreeTableNode) path.getLastPathComponent(); if (path.getPathCount() == 2) { if (node instanceof ImportUnassignedLibraryTreeTableNode) { String libraryName = (String) node.getValueAt(IMPORT_NAME_COLUMN); String libraryId = null; for (CodeTemplateLibrary library : PlatformUI.MIRTH_FRAME.codeTemplatePanel .getCachedCodeTemplateLibraries().values()) { if (library.getName().equals(libraryName)) { libraryId = library.getId(); break; } } node.setValueAt(libraryId, IMPORT_ID_COLUMN); } else if (node instanceof ImportLibraryTreeTableNode) { ImportLibraryTreeTableNode libraryNode = (ImportLibraryTreeTableNode) node; libraryNode.setConflicts(getLibraryConflicts(node)); } for (Enumeration<? extends TreeTableNode> codeTemplateNodes = node .children(); codeTemplateNodes.hasMoreElements();) { ImportCodeTemplateTreeTableNode codeTemplateNode = (ImportCodeTemplateTreeTableNode) codeTemplateNodes .nextElement(); codeTemplateNode.setConflicts(getCodeTemplateConflicts(codeTemplateNode)); } importTreeTable.updateUI(); } else if (path.getPathCount() == 3) { ImportCodeTemplateTreeTableNode codeTemplateNode = (ImportCodeTemplateTreeTableNode) node; codeTemplateNode.setConflicts(getCodeTemplateConflicts(node)); } } } } updateImportButton(); updateErrorsAndWarnings(); } }); importTreeTable.getSelectionModel().addListSelectionListener(new ListSelectionListener() { @Override public void valueChanged(ListSelectionEvent evt) { if (!evt.getValueIsAdjusting()) { updateImportButton(); updateErrorsAndWarnings(); } } }); importTreeTable.expandAll(); importTreeTable.getColumnModel().getColumn(IMPORT_SELECTED_COLUMN).setMinWidth(20); importTreeTable.getColumnModel().getColumn(IMPORT_SELECTED_COLUMN).setMaxWidth(20); importTreeTable.getColumnModel().getColumn(IMPORT_SELECTED_COLUMN) .setCellRenderer(new ImportSelectedCellRenderer()); importTreeTable.getColumnModel().getColumn(IMPORT_SELECTED_COLUMN) .setCellEditor(new ImportSelectedCellEditor()); importTreeTable.getColumnModel().getColumn(IMPORT_OVERWRITE_COLUMN).setMinWidth(60); importTreeTable.getColumnModel().getColumn(IMPORT_OVERWRITE_COLUMN).setMaxWidth(60); importTreeTable.getColumnModel().getColumn(IMPORT_OVERWRITE_COLUMN) .setCellRenderer(new OverwriteCellRenderer()); importTreeTable.getColumnModel().getColumn(IMPORT_OVERWRITE_COLUMN) .setCellEditor(new OverwriteCellEditor()); importTreeTable.getColumnModel().getColumn(IMPORT_CONFLICTS_COLUMN).setMinWidth(60); importTreeTable.getColumnModel().getColumn(IMPORT_CONFLICTS_COLUMN).setMaxWidth(60); importTreeTable.getColumnModel().getColumn(IMPORT_CONFLICTS_COLUMN).setCellRenderer(new IconCellRenderer()); importTreeTable.getColumnModel().removeColumn(importTreeTable.getColumnModel().getColumn(IMPORT_ID_COLUMN)); importTreeTableScrollPane = new JScrollPane(importTreeTable); importTreeTableScrollPane.setBorder(BorderFactory.createMatteBorder(1, 1, 1, 1, new Color(0x6E6E6E))); warningsPanel = new JPanel(); warningsPanel.setBackground(getBackground()); warningsPanel.setVisible(false); warningsLabel = new JLabel(UIConstants.ICON_WARNING); warningsTextArea = new JTextArea(); warningsTextArea.setLineWrap(true); warningsTextArea.setWrapStyleWord(true); errorsPanel = new JPanel(); errorsPanel.setBackground(getBackground()); errorsPanel.setVisible(false); errorsLabel = new JLabel(UIConstants.ICON_ERROR); errorsTextArea = new JTextArea(); errorsTextArea.setLineWrap(true); errorsTextArea.setWrapStyleWord(true); separator = new JSeparator(); buttonPanel = new JPanel(); buttonPanel.setBackground(getBackground()); importButton = new JButton("Import"); importButton.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent evt) { try { boolean warnings = false; for (Enumeration<? extends TreeTableNode> libraryNodes = ((TreeTableNode) importTreeTable .getTreeTableModel().getRoot()).children(); libraryNodes.hasMoreElements();) { for (Enumeration<? extends TreeTableNode> codeTemplateNodes = libraryNodes.nextElement() .children(); codeTemplateNodes.hasMoreElements();) { ImportCodeTemplateTreeTableNode codeTemplateNode = (ImportCodeTemplateTreeTableNode) codeTemplateNodes .nextElement(); if ((boolean) codeTemplateNode.getValueAt(IMPORT_SELECTED_COLUMN)) { CodeTemplateConflicts conflicts = codeTemplateNode.getConflicts(); if (conflicts.getMatchingCodeTemplate() != null) { warnings = true; break; } } } if (warnings) { break; } } if (!warnings || PlatformUI.MIRTH_FRAME.alertOption(CodeTemplateImportDialog.this, "Some selected rows have warnings. Are you sure you wish to continue?")) { save(); dispose(); } } catch (Exception e) { PlatformUI.MIRTH_FRAME.alertThrowable(CodeTemplateImportDialog.this, e, "Unable to import: " + e.getMessage()); } } }); cancelButton = new JButton("Cancel"); cancelButton.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent evt) { if (confirmClose()) { dispose(); } } }); updateImportButton(); }