List of usage examples for javax.swing JPopupMenu add
public JMenuItem add(Action a)
Action
object. From source file:base.BasePlayer.Main.java
void setMenuBar() { //filemenu.addMouseListener(this); //toolmenu.addMouseListener(this); filemenu = new JMenu("File"); toolmenu = new JMenu("Tools"); help = new JMenu("Help"); about = new JMenu("About"); menubar = new JMenuBar(); //help.addMouseListener(this); exit = new JMenuItem("Exit"); manual = new JButton("Online manual"); manual.addActionListener(new ActionListener() { @Override/*from w ww.j a va2 s . c om*/ public void actionPerformed(ActionEvent arg0) { Main.gotoURL("https://baseplayer.fi/BPmanual"); } }); // opensamples = new JMenuItem("Add samples"); zoomout = new JButton("Zoom out"); back = new JButton("<<"); forward = new JButton(">>"); manage = new JButton("Variant Manager"); openvcfs = new JMenuItem("Add VCFs", open); openbams = new JMenuItem("Add BAMs", open); average = new JMenuItem("Coverage calculator"); update = new JMenuItem("Update"); update.setVisible(false); errorlog = new JMenuItem("View log"); //helpLabel = new JLabel("This is pre-release version of BasePlayer\nContact: help@baseplayer.fi\n\nUniversity of Helsinki"); addURL = new JMenu("Add from URL"); urlField = new JTextField("Enter URL"); addtracks = new JMenuItem("Add tracks"); fromURL = new JMenuItem("Add track from URL"); addcontrols = new JMenuItem("Add controls"); pleiadesButton = new JMenuItem("PLEIADES"); saveProject = new JMenuItem("Save project"); saveProjectAs = new JMenuItem("Save project as..."); openProject = new JMenuItem("Open project"); clear = new JMenuItem("Clear data"); clearMemory = new JMenuItem("Clean memory"); // welcome = new JMenuItem("Welcome screen"); filemenu.add(openvcfs); filemenu.add(openbams); variantCaller = new JMenuItem("Variant Caller"); tbrowser = new JMenuItem("Table Browser"); bconvert = new JMenuItem("BED converter"); peakCaller = new JMenuItem("Peak Caller"); addtracks = new JMenuItem("Add tracks", open); filemenu.add(addtracks); addcontrols = new JMenuItem("Add controls", open); filemenu.add(addcontrols); filemenu.add(fromURL); if (pleiades) { pleiadesButton.setPreferredSize(buttonDimension); pleiadesButton.addActionListener(this); filemenu.add(pleiadesButton); } filemenu.add(new JSeparator()); openProject = new JMenuItem("Open project", open); filemenu.add(openProject); saveProject = new JMenuItem("Save project", save); filemenu.add(saveProject); saveProjectAs = new JMenuItem("Save project as...", save); filemenu.add(saveProjectAs); filemenu.add(new JSeparator()); filemenu.add(genome); filemenu.add(update); filemenu.add(clear); filemenu.add(new JSeparator()); filemenu.add(exit); exit.addActionListener(this); menubar.add(filemenu); manage.addActionListener(this); manage.addMouseListener(this); update.addActionListener(this); average.addActionListener(this); average.setEnabled(false); average.setToolTipText("No bam/cram files opened"); tbrowser.addActionListener(this); bconvert.addActionListener(this); toolmenu.add(tbrowser); toolmenu.add(average); toolmenu.add(variantCaller); toolmenu.add(bconvert); fromURL.addMouseListener(this); fromURL.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent arg0) { final JPopupMenu menu = new JPopupMenu(); final JTextField area = new JTextField(); JButton add = new JButton("Fetch"); JLabel label = new JLabel("Paste track URL below"); JScrollPane menuscroll = new JScrollPane(); add.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { try { String urltext = area.getText().trim(); Boolean size = true; if (urltext.contains("pleiades")) { openPleiades(urltext); return; } if (!FileRead.isTrackFile(urltext)) { showError("The file format is not supported.\n" + "Supported formats: bed, bigwig, bigbed, gff, bedgraph", "Error"); return; } if (!urltext.toLowerCase().endsWith(".bw") && !urltext.toLowerCase().endsWith(".bigwig") && !urltext.toLowerCase().endsWith(".bb") && !urltext.toLowerCase().endsWith(".bigbed")) { URL url = null; try { url = new URL(urltext); } catch (Exception ex) { menu.setVisible(false); Main.showError("Please paste whole url (protocol included)", "Error"); return; } URL testurl = url; HttpURLConnection huc = (HttpURLConnection) testurl.openConnection(); huc.setRequestMethod("HEAD"); int responseCode = huc.getResponseCode(); if (responseCode != 404) { SeekableStream stream = SeekableStreamFactory.getInstance().getStreamFor(url); TabixReader tabixReader = null; String index = null; try { if (stream.length() / (double) 1048576 >= Settings.settings .get("bigFile")) { size = false; } tabixReader = new TabixReader(urltext, urltext + ".tbi", stream); index = urltext + ".tbi"; testurl = new URL(index); huc = (HttpURLConnection) testurl.openConnection(); huc.setRequestMethod("HEAD"); responseCode = huc.getResponseCode(); if (responseCode == 404) { menu.setVisible(false); Main.showError("Index file (.tbi) not found in the URL.", "Error"); return; } } catch (Exception ex) { try { tabixReader = new TabixReader(urltext, urltext.substring(0, urltext.indexOf(".gz")) + ".tbi", stream); index = urltext.substring(0, urltext.indexOf(".gz")) + ".tbi"; } catch (Exception exc) { menu.setVisible(false); Main.showError("Could not read tabix file.", "Error"); } } if (tabixReader != null && index != null) { stream.close(); tabixReader.close(); menu.setVisible(false); FileRead filereader = new FileRead(); filereader.readBED(urltext, index, size); } } else { menu.setVisible(false); Main.showError("Not a valid URL", "Error"); } } else { URL url = null; try { url = new URL(urltext); } catch (Exception ex) { Main.showError("Please paste whole url (protocol included)", "Error"); return; } final URL testurl = url; HttpURLConnection huc = (HttpURLConnection) testurl.openConnection(); huc.setRequestMethod("HEAD"); int responseCode = huc.getResponseCode(); if (responseCode != 404) { menu.setVisible(false); FileRead filereader = new FileRead(); filereader.readBED(urltext, "nan", true); } else { menu.setVisible(false); Main.showError("Not a valid URL", "Error"); } } } catch (Exception ex) { ex.printStackTrace(); } } }); area.setFont(Main.menuFont); //area.setText("https://baseplayer.fi/tracks/Mappability_1000Genomes_pilot_mask.bed.gz"); menu.add(label); menu.add(menuscroll); menu.add(add); area.setPreferredSize(new Dimension(300, Main.defaultFontSize + 8)); area.setCaretPosition(0); area.revalidate(); menuscroll.getViewport().add(area); area.requestFocus(); menu.pack(); menu.show(frame, mouseX + 20, fromURL.getY()); } }); //toolmenu.add(peakCaller); variantCaller.setToolTipText("No bam/cram files opened"); variantCaller.addActionListener(this); variantCaller.setEnabled(false); peakCaller.setEnabled(true); peakCaller.addActionListener(this); settings.addActionListener(this); clearMemory.addActionListener(this); errorlog.addActionListener(this); toolmenu.add(clearMemory); toolmenu.add(errorlog); toolmenu.add(new JSeparator()); toolmenu.add(settings); menubar.add(toolmenu); menubar.add(manage); area = new JEditorPane(); String infotext = "<html><h2>BasePlayer</h2>This is a version " + version + " of BasePlayer (<a href=https://baseplayer.fi>https://baseplayer.fi</a>)<br/> Author: Riku Katainen <br/> University of Helsinki<br/>" + "Tumor Genomics Group (<a href=http://research.med.helsinki.fi/gsb/aaltonen/>http://research.med.helsinki.fi/gsb/aaltonen/</a>) <br/> " + "Contact: help@baseplayer.fi <br/> <br/>" + "Supported filetype for variants is VCF and VCF.gz (index file will be created if missing)<br/> " + "Supported filetypes for reads are BAM and CRAM. Index files required (.bai or .crai). <br/> " + "Supported filetypes for additional tracks are BED(.gz), GFF.gz, BedGraph, BigWig, BigBed.<br/> (tabix index required for bgzipped files). <br/><br/> " + "For optimal usage, you should have vcf.gz and bam -files for each sample. <br/> " + "e.g. in case you have a sample named as sample1, name all files similarly and <br/>" + "place in the same folder:<br/>" + "sample1.vcf.gz<br/>" + "sample1.vcf.gz.tbi<br/>" + "sample1.bam<br/>" + "sample1.bam.bai<br/><br/>" + "When you open sample1.vcf.gz, sample1.bam is recognized and opened<br/>" + "on the same track.<br/><br/>" + "Instructional videos can be viewed at our <a href=https://www.youtube.com/channel/UCywq-T7W0YPzACyB4LT7Q3g> Youtube channel</a>"; area = new JEditorPane(); area.setEditable(false); area.setEditorKit(JEditorPane.createEditorKitForContentType("text/html")); area.setText(infotext); area.setFont(Main.menuFont); area.addHyperlinkListener(new HyperlinkListener() { public void hyperlinkUpdate(HyperlinkEvent hyperlinkEvent) { HyperlinkEvent.EventType type = hyperlinkEvent.getEventType(); final URL url = hyperlinkEvent.getURL(); if (type == HyperlinkEvent.EventType.ACTIVATED) { Main.gotoURL(url.toString()); } } }); about.add(area); about.addMouseListener(this); help.add(about); help.add(manual); menubar.add(help); JLabel emptylab = new JLabel(" "); emptylab.setEnabled(false); emptylab.setOpaque(false); menubar.add(emptylab); chromosomeDropdown.setBorder(BorderFactory.createMatteBorder(1, 0, 1, 1, Color.lightGray)); chromosomeDropdown.setBorder(BorderFactory.createCompoundBorder(chromosomeDropdown.getBorder(), BorderFactory.createEmptyBorder(0, 0, 0, 0))); chromlabel.setToolTipText("Current chromosome"); chromlabel.setFocusable(false); chromlabel.addMouseListener(this); chromlabel.setBackground(Color.white); chromlabel.setEditable(false); chromlabel.setBorder(BorderFactory.createMatteBorder(1, 1, 1, 0, Color.lightGray)); chromlabel.setBorder(BorderFactory.createCompoundBorder(chromlabel.getBorder(), BorderFactory.createEmptyBorder(0, 0, 0, 0))); menubar.add(chromlabel); chromosomeDropdown.setBackground(Color.white); chromosomeDropdown.setToolTipText("Current chromosome"); menubar.add(chromosomeDropdown); JLabel empty3 = new JLabel(" "); empty3.setEnabled(false); empty3.setOpaque(false); menubar.add(empty3); menubar.add(back); menubar.add(searchField); searchField.setForeground(Color.gray); searchField.setBorder(BorderFactory.createCompoundBorder(searchField.getBorder(), BorderFactory.createEmptyBorder(0, 0, 0, 0))); searchField.addMouseListener(this); menubar.add(back); menubar.add(searchField); searchField.setForeground(Color.gray); back.addMouseListener(this); back.setToolTipText("Back"); forward.addMouseListener(this); forward.setToolTipText("Forward"); back.setEnabled(false); forward.setEnabled(false); searchField.addMouseListener(this); menubar.add(back); menubar.add(searchField); searchField.setForeground(Color.gray); back.addMouseListener(this); forward.addMouseListener(this); back.setEnabled(false); forward.setEnabled(false); forward.setMargin(new Insets(0, 2, 0, 2)); back.setMargin(new Insets(0, 2, 0, 2)); menubar.add(forward); JLabel empty4 = new JLabel(" "); empty4.setOpaque(false); empty4.setEnabled(false); menubar.add(empty4); menubar.add(zoomout); JLabel empty5 = new JLabel(" "); empty5.setEnabled(false); empty5.setOpaque(false); menubar.add(empty5); positionField.setEditable(false); positionField.setBackground(new Color(250, 250, 250)); positionField.setMargin(new Insets(0, 2, 0, 0)); positionField.setBorder(BorderFactory.createCompoundBorder(widthLabel.getBorder(), BorderFactory.createEmptyBorder(0, 0, 0, 0))); menubar.add(positionField); widthLabel.setEditable(false); widthLabel.setBackground(new Color(250, 250, 250)); widthLabel.setMargin(new Insets(0, 2, 0, 0)); widthLabel.setBorder(BorderFactory.createCompoundBorder(widthLabel.getBorder(), BorderFactory.createEmptyBorder(0, 0, 0, 0))); JLabel empty6 = new JLabel(" "); empty6.setEnabled(false); empty6.setOpaque(false); menubar.add(empty6); menubar.add(widthLabel); JLabel empty7 = new JLabel(" "); empty7.setOpaque(false); empty7.setEnabled(false); menubar.add(empty7); }
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())); }/* www . j av 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:nl.tudelft.goal.SimpleIDE.FilePanel.java
private JPopupMenu createPopupMenu() throws IllegalAccessException, InstantiationException { JPopupMenu popup = new JPopupMenu(); popup.add(new JMenuItem(ActionFactory.getAction(EditAction.class))); popup.add(new JMenuItem(ActionFactory.getAction(SaveFileAction.class))); popup.add(new JMenuItem(ActionFactory.getAction(ReloadFileAction.class))); popup.add(new JMenuItem(ActionFactory.getAction(CloseAndRemoveAction.class))); popup.add(new JMenuItem(ActionFactory.getAction(RenameAction.class))); popup.add(new JSeparator()); popup.add(new JMenuItem(ActionFactory.getAction(OpenFileAction.class))); popup.add(new JMenuItem(ActionFactory.getAction(NewFileAction.class))); popup.add(new JMenuItem(ActionFactory.getAction(DeleteAction.class))); popup.add(new JSeparator()); popup.add(new JMenuItem(ActionFactory.getAction(RunAction.class))); popup.add(new JSeparator()); popup.add(new JMenuItem(ActionFactory.getAction(QuitAction.class))); return popup; }
From source file:nz.govt.natlib.ndha.manualdeposit.bulkupload.BulkUploadQueueManagement.java
public JPopupMenu getBulkUploadMenu() { JPopupMenu menu = new JPopupMenu(); String text = "Cancel job"; if (theBulkUploadItemsTable.getSelectedRowCount() > 1) { text += "s"; }/*from ww w . j a v a 2 s .c o m*/ JMenuItem item = new JMenuItem(text); item.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { cancelJobs(evt); } }); menu.add(item); BulkUploadTableModel model = (BulkUploadTableModel) theBulkUploadItemsTable.getModel(); int noOfErrorJobsSelected = model.getSelectedErrorCount(theBulkUploadItemsTable); if (noOfErrorJobsSelected > 0) { if (noOfErrorJobsSelected > 1) { text = "Resubmit jobs in error"; } else { text = "Resubmit job in error"; } item = new JMenuItem(text); item.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { resubmitErrorJobs(evt); } }); menu.add(item); } if (menu == null || menu.getComponentCount() == 0) { return null; } else { return menu; } }
From source file:nz.govt.natlib.ndha.manualdeposit.jobmanagement.JobQueueManagement.java
public JPopupMenu getJobQueueMenu(final JTable table) { theTableSelected = table;//from w ww . ja v a 2 s.c o m final JPopupMenu menu = new JPopupMenu(); boolean sortAscending = false; if (table.equals(theJobQueueRunningTable)) { sortAscending = personalSettings.isSortRunningAscending(); } else if (table.equals(theJobQueuePendingTable)) { sortAscending = personalSettings.isSortPendingAscending(); } else if (table.equals(theJobQueueFailedTable)) { sortAscending = personalSettings.isSortFailedAscending(); } else if (table.equals(theJobQueueDepositedTable)) { sortAscending = personalSettings.isSortDepositedAscending(); } else if (table.equals(theJobQueueInPermanentTable)) { sortAscending = personalSettings.isSortCompleteAscending(); } JMenuItem item; if (sortAscending) { item = new JMenuItem("Sort by date in descending order"); } else { item = new JMenuItem("Sort by date in ascending order"); } item.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(final java.awt.event.ActionEvent evt) { resortTable(evt); } }); menu.add(item); if ((table.equals(theJobQueueRunningTable)) || (table.equals(theJobQueuePendingTable)) || (table.equals(theJobQueueFailedTable))) { StringBuffer text = new StringBuffer(); text.append("Cancel job"); if (table.getSelectedRowCount() > 1) { text.append('s'); } item = new JMenuItem(text.toString()); item.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(final java.awt.event.ActionEvent evt) { try { cancelJobs(evt); } catch (JobQueueException ex) { String message = "Error cancelling jobs"; LOG.error(message, ex); mainFrame.showError("An error occurred", message, ex); } } }); menu.add(item); if (table.equals(theJobQueueFailedTable)) { text = new StringBuffer(); text.append("Resubmit job"); if (table.getSelectedRowCount() > 1) { text.append('s'); } item = new JMenuItem(text.toString()); item.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(final java.awt.event.ActionEvent evt) { resubmitJob(evt); } }); menu.add(item); } } if (table.equals(theJobQueueInPermanentTable)) { item = new JMenuItem("Clear completed jobs"); item.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(final java.awt.event.ActionEvent evt) { clearFinishedJobs(evt); } }); menu.add(item); } if (menu == null || menu.getComponentCount() == 0) { return null; } else { return menu; } }
From source file:nz.govt.natlib.ndha.manualdeposit.ManualDepositPresenter.java
public JPopupMenu getProducerMenu() { final JPopupMenu menu = new JPopupMenu(); final JMenuItem item = new JMenuItem("Refresh producer list"); item.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(final java.awt.event.ActionEvent evt) { itmRefreshProducerListActionPerformed(evt); }//from w ww . ja v a 2 s. c o m }); menu.add(item); return menu; }
From source file:nz.govt.natlib.ndha.manualdeposit.ManualDepositPresenter.java
public JPopupMenu getFileSystemMenu(final DefaultMutableTreeNode node) { JPopupMenu menu = null; fsoRootFileTemp = null;// w w w . j a v a 2 s . c om if (node.getUserObject() instanceof FileSystemObject) { boolean allowBulkUpload = false; final FileSystemObject fso = (FileSystemObject) node.getUserObject(); menu = new JPopupMenu(); if ((fso != null) && (fso.getFile() != null) && (fso.getFile().exists())) { if (!entityRootSet) { stopEditingMetaData(); allowBulkUpload = applicationProperties.getUserData() .getUser(applicationProperties.getLoggedOnUser()).isAllowBulkLoad(); String addRootText; boolean canAddMultiRoot = false; setCustomizeMetaData(false); if (fso.getIsFile()) { addRootText = "Use file to describe IE root"; final DefaultMutableTreeNode nodeParent = (DefaultMutableTreeNode) node.getParent(); if (nodeParent.getUserObject() instanceof FileSystemObject) { fsoRootTemp = (FileSystemObject) nodeParent.getUserObject(); fsoRootFileTemp = fso; } else { fsoRootTemp = fso; } } else { addRootText = "Set as root of Intellectual Entity"; canAddMultiRoot = (userGroupData != null && userGroupData.isIncludeMultiEntityMenuItem()); fsoRootTemp = fso; } JMenuItem item = new JMenuItem(addRootText); item.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(final java.awt.event.ActionEvent evt) { manualDepositFrame.setWaitCursor(true); itmSetRootActionPerformed(evt); manualDepositFrame.setWaitCursor(false); } }); menu.add(item); if (canAddMultiRoot) { item = new JMenuItem("Set each file as an Intellectual Entity"); item.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(final java.awt.event.ActionEvent evt) { itmSetMultipleRootActionPerformed(evt); } }); menu.add(item); // Added 5/09/2013 by Ben // New menu option for creating multiple complex IEs item = new JMenuItem("Set each folder as an Intellectual Entity"); item.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(final java.awt.event.ActionEvent evt) { itmSetMultipleRootFolderActionPerformed(evt); } }); menu.add(item); } } if (fso.getIsFile()) { if (menu.getComponentCount() > 0) { menu.addSeparator(); } if (isWindows()) { JMenuItem item = new JMenuItem("Open File"); item.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(final java.awt.event.ActionEvent evt) { itmOpenFile(evt); } }); menu.add(item); item = new JMenuItem("Open File Location"); item.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(final java.awt.event.ActionEvent evt) { itmOpenFileLocation(evt); } }); menu.add(item); } } else { if (menu.getComponentCount() > 0) { menu.addSeparator(); } JMenuItem item = new JMenuItem("Store this directory as a favourite"); item.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(final java.awt.event.ActionEvent evt) { itmStoreAsFavourite(evt); } }); menu.add(item); item = new JMenuItem("Refresh directory file list"); item.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(final java.awt.event.ActionEvent evt) { itmRefreshDirectory(evt); } }); menu.add(item); if (allowBulkUpload) { item = new JMenuItem("Bulk load this directory"); item.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(final java.awt.event.ActionEvent evt) { bulkLoadDirectory(evt); } }); if (!metaDataOkay(false)) { item.setEnabled(false); item.setToolTipText("Meta data incomplete"); } menu.add(item); item = new JMenuItem("Bulk load each file as an Intellectual Entity"); item.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(final java.awt.event.ActionEvent evt) { bulkLoadDirectoryAsIEs(evt); } }); if (!metaDataOkay(false)) { item.setEnabled(false); item.setToolTipText("Meta data incomplete"); } menu.add(item); } } } } if (menu == null || menu.getComponentCount() == 0) { return null; } else { return menu; } }
From source file:nz.govt.natlib.ndha.manualdeposit.ManualDepositPresenter.java
private JPopupMenu getEntityMenu(FileSystemObject fso) { final JPopupMenu menu = new JPopupMenu(); if (fso.getIsFile()) { JMenuItem item;/*from w ww . j a va 2s . com*/ ArrayList<FileGroupCollection> entities = getEntities(); if (entities.size() == 1) { item = new JMenuItem("Delete File"); item.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { itmDeleteEntityItem(evt); } }); menu.add(item); } item = new JMenuItem("Rename File"); item.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { itmRenameEntity(evt); } }); menu.add(item); if (menu.getComponentCount() > 0) { menu.addSeparator(); } item = new JMenuItem("Open File"); item.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { itmOpenFile(evt); } }); menu.add(item); } else { JMenuItem item = new JMenuItem("Delete Directory (and children)"); item.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { itmDeleteEntityItem(evt); } }); menu.add(item); item = new JMenuItem("Rename Directory"); item.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { itmRenameEntity(evt); } }); menu.add(item); } return menu; }
From source file:nz.govt.natlib.ndha.manualdeposit.ManualDepositPresenter.java
private JPopupMenu getEntityMenu(FileGroupCollection entitiesClicked) { if (!entityRootSet) { return null; // Don't want to have a menu unless we are editing an // entity }/* ww w . jav a 2 s. c om*/ final JPopupMenu menu = new JPopupMenu(); JMenuItem item = new JMenuItem("Rename Intellectual Entity"); item.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { itmRenameEntity(evt); } }); menu.add(item); ArrayList<FileGroupCollection> entities = getEntities(); if (entities.size() == 1) { menu.addSeparator(); JMenu addTypes = new JMenu("Add Representation Type"); boolean entityTypesAdded = false; for (int i = 0; i < RepresentationTypes.values().length; i++) { final RepresentationTypes typeToAdd = RepresentationTypes.values()[i]; boolean addType = true; if (!typeToAdd.allowMultiples()) { addType = (!entityTypeAdded(typeToAdd, entities)); } if (addType) { entityTypesAdded = true; JMenuItem subItem = new JMenuItem("Add " + typeToAdd.description()); subItem.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { itmAddEntity(evt, typeToAdd); } }); addTypes.add(subItem); } } if (entityTypesAdded) { menu.add(addTypes); } } else { item = new JMenuItem("Delete Intellectual Entity"); item.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { itmDeleteEntityItem(evt); } }); menu.add(item); } if (thereAreMissingFiles()) { menu.addSeparator(); item = new JMenuItem("Show Missing Files"); item.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { showMissingFiles(); } }); menu.add(item); } return menu; }
From source file:nz.govt.natlib.ndha.manualdeposit.ManualDepositPresenter.java
private JPopupMenu getEntityMenu(FileGroup entity) { final JPopupMenu menu = new JPopupMenu(); JMenuItem item;/*from w w w .j a v a 2 s. c om*/ ArrayList<FileGroupCollection> entities = getEntities(); if (entities.size() == 1) { item = new JMenuItem("Delete Representation Type"); item.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { itmDeleteEntityItem(evt); } }); menu.add(item); } return menu; }