List of usage examples for javax.swing JPopupMenu JPopupMenu
public JPopupMenu()
JPopupMenu
without an "invoker". From source file:org.tinymediamanager.ui.movies.MoviePanel.java
private void buildMenu() { menu.setMnemonic(KeyEvent.VK_M); // menu items JMenuItem menuItem = menu.add(actionUpdateDataSources2); menuItem.setMnemonic(KeyEvent.VK_U); menuItem.setAccelerator(//from w w w . ja v a2s . com KeyStroke.getKeyStroke(KeyEvent.VK_U, ActionEvent.CTRL_MASK + ActionEvent.SHIFT_MASK)); final JMenu menuUpdateDatasources = new JMenu(BUNDLE.getString("update.datasource")); //$NON-NLS-1$ final JMenu menuFindMissingMovies = new JMenu(BUNDLE.getString("movie.findmissing")); //$NON-NLS-1$ menuUpdateDatasources.addMenuListener(new MenuListener() { @Override public void menuCanceled(MenuEvent arg0) { } @Override public void menuDeselected(MenuEvent arg0) { } @Override public void menuSelected(MenuEvent arg0) { menuUpdateDatasources.removeAll(); menuFindMissingMovies.removeAll(); for (String ds : MovieModuleManager.MOVIE_SETTINGS.getMovieDataSource()) { JMenuItem item = new JMenuItem(new MovieUpdateSingleDatasourceAction(ds)); menuUpdateDatasources.add(item); item = new JMenuItem(new MovieFindMissingAction(ds)); menuFindMissingMovies.add(item); } } }); menu.add(menuUpdateDatasources); menu.add(new MovieFindMissingAction()); menu.add(menuFindMissingMovies); menu.add(new MovieCreateOfflineAction(true)); menu.addSeparator(); JMenu menuScrape = new JMenu(BUNDLE.getString("Button.scrape")); //$NON-NLS-1$ menuScrape.setMnemonic(KeyEvent.VK_S); menuItem = menuScrape.add(actionScrape2); menuItem.setMnemonic(KeyEvent.VK_S); menuItem.setAccelerator( KeyStroke.getKeyStroke(KeyEvent.VK_S, ActionEvent.CTRL_MASK + ActionEvent.SHIFT_MASK)); menuItem = menuScrape.add(actionScrapeSelected); menuItem.setMnemonic(KeyEvent.VK_F); menuItem.setAccelerator( KeyStroke.getKeyStroke(KeyEvent.VK_F, ActionEvent.CTRL_MASK + ActionEvent.SHIFT_MASK)); menuItem = menuScrape.add(actionScrapeUnscraped); menuItem.setMnemonic(KeyEvent.VK_U); menuItem.setAccelerator( KeyStroke.getKeyStroke(KeyEvent.VK_U, ActionEvent.CTRL_MASK + ActionEvent.SHIFT_MASK)); menuItem = menuScrape.add(actionScrapeMetadataSelected); menuItem.setMnemonic(KeyEvent.VK_M); menuScrape.add(actionAssignMovieSets); menu.add(menuScrape); JMenu menuEdit = new JMenu(BUNDLE.getString("Button.edit")); //$NON-NLS-1$ menuEdit.setMnemonic(KeyEvent.VK_E); menuItem = menuEdit.add(actionEditMovie2); menuItem.setMnemonic(KeyEvent.VK_E); menuItem.setAccelerator( KeyStroke.getKeyStroke(KeyEvent.VK_E, ActionEvent.CTRL_MASK + ActionEvent.SHIFT_MASK)); menuItem = menuEdit.add(actionBatchEdit); menuItem.setMnemonic(KeyEvent.VK_B); menuItem.setAccelerator( KeyStroke.getKeyStroke(KeyEvent.VK_B, ActionEvent.CTRL_MASK + ActionEvent.SHIFT_MASK)); menuItem = menuEdit.add(actionSetWatchedFlag); menuItem.setMnemonic(KeyEvent.VK_W); menuItem.setAccelerator( KeyStroke.getKeyStroke(KeyEvent.VK_W, ActionEvent.CTRL_MASK + ActionEvent.SHIFT_MASK)); menuItem = menuEdit.add(actionRename2); menuItem.setMnemonic(KeyEvent.VK_R); menuItem.setAccelerator( KeyStroke.getKeyStroke(KeyEvent.VK_R, ActionEvent.CTRL_MASK + ActionEvent.SHIFT_MASK)); menuItem = menuEdit.add(actionRenamerPreview); menuItem.setMnemonic(KeyEvent.VK_P); menu.add(menuEdit); menuItem = menu.add(actionRewriteNfo); menuItem.setMnemonic(KeyEvent.VK_N); menuItem = menu.add(actionTrailerDownload); menuItem = menu.add(actionSearchSubtitle); menuItem = menu.add(actionDownloadSubtitle); menu.addSeparator(); menuItem = menu.add(actionMediaInformation2); menuItem.setMnemonic(KeyEvent.VK_M); menuItem.setAccelerator( KeyStroke.getKeyStroke(KeyEvent.VK_M, ActionEvent.CTRL_MASK + ActionEvent.SHIFT_MASK)); menuItem = menu.add(actionExport); menuItem.setMnemonic(KeyEvent.VK_X); menuItem.setAccelerator( KeyStroke.getKeyStroke(KeyEvent.VK_X, ActionEvent.CTRL_MASK + ActionEvent.SHIFT_MASK)); menuItem = menu.add(actionRemove2); menuItem.setMnemonic(KeyEvent.VK_R); menuItem.setAccelerator(KeyStroke.getKeyStroke((char) KeyEvent.VK_DELETE)); menuItem = menu.add(actionDelete2); menuItem.setMnemonic(KeyEvent.VK_R); menuItem.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_DELETE, ActionEvent.SHIFT_MASK)); menu.addSeparator(); menuItem = menu.add(actionSyncTrakt); menuItem.setMnemonic(KeyEvent.VK_T); menuItem = menu.add(actionSyncWatchedTrakt); menuItem.setMnemonic(KeyEvent.VK_W); menuItem = menu.add(actionSyncSelectedTrakt); menu.addSeparator(); menuItem = menu.add(actionClearImageCache); menuItem.setMnemonic(KeyEvent.VK_C); // popup menu JPopupMenu popupMenu = new JPopupMenu(); popupMenu.add(actionScrape2); popupMenu.add(actionScrapeSelected); popupMenu.add(actionScrapeUnscraped); popupMenu.add(actionScrapeMetadataSelected); popupMenu.add(actionAssignMovieSets); popupMenu.addSeparator(); popupMenu.add(actionEditMovie2); popupMenu.add(actionBatchEdit); popupMenu.add(actionSetWatchedFlag); popupMenu.add(actionRewriteNfo); popupMenu.add(actionRename2); popupMenu.add(actionRenamerPreview); popupMenu.add(actionMediaInformation2); popupMenu.add(actionExport); popupMenu.add(actionTrailerDownload); popupMenu.add(actionSearchSubtitle); popupMenu.add(actionDownloadSubtitle); popupMenu.addSeparator(); popupMenu.add(actionSyncTrakt); popupMenu.add(actionSyncWatchedTrakt); popupMenu.add(actionSyncSelectedTrakt); popupMenu.addSeparator(); popupMenu.add(actionClearImageCache); popupMenu.addSeparator(); popupMenu.add(actionRemove2); popupMenu.add(actionDelete2); if (Globals.isDebug()) { JMenu menuDebug = new JMenu("Debug"); //$NON-NLS-1$ menuDebug.add(debugDumpMovie); menuDebug.addSeparator(); menuDebug.add(new FakeTmmTaskAction("download", 1, 10)); menuDebug.add(new FakeTmmTaskAction("download", 10, 10)); menuDebug.add(new FakeTmmTaskAction("image", 1, 10)); menuDebug.add(new FakeTmmTaskAction("image", 10, 10)); menuDebug.add(new FakeTmmTaskAction("unnamed", 1, 10)); menuDebug.add(new FakeTmmTaskAction("unnamed", 10, 10)); popupMenu.add(menuDebug); } MouseListener mouseListener = new MovieTableMouseListener(popupMenu, table); table.addMouseListener(mouseListener); }
From source file:org.tinymediamanager.ui.tvshows.TvShowPanel.java
/** * Builds the menu.//from ww w.j a v a 2 s .com */ private void buildMenu() { menu.setMnemonic(KeyEvent.VK_V); // menu items JMenuItem menuItem = menu.add(actionUpdateDatasources2); menuItem.setMnemonic(KeyEvent.VK_U); menuItem.setAccelerator( KeyStroke.getKeyStroke(KeyEvent.VK_U, ActionEvent.CTRL_MASK + ActionEvent.SHIFT_MASK)); menu.addSeparator(); JMenu menuScrape = new JMenu(BUNDLE.getString("Button.scrape")); //$NON-NLS-1$ menuScrape.setMnemonic(KeyEvent.VK_S); menuItem = menuScrape.add(actionScrape2); menuItem.setMnemonic(KeyEvent.VK_S); menuItem.setAccelerator( KeyStroke.getKeyStroke(KeyEvent.VK_S, ActionEvent.CTRL_MASK + ActionEvent.SHIFT_MASK)); menuItem = menuScrape.add(actionScrapeSelected); menuItem.setMnemonic(KeyEvent.VK_F); menuItem.setAccelerator( KeyStroke.getKeyStroke(KeyEvent.VK_F, ActionEvent.CTRL_MASK + ActionEvent.SHIFT_MASK)); menuItem = menuScrape.add(actionScrapeNewItems); menuItem.setMnemonic(KeyEvent.VK_N); menuItem.setAccelerator( KeyStroke.getKeyStroke(KeyEvent.VK_N, ActionEvent.CTRL_MASK + ActionEvent.SHIFT_MASK)); menu.add(menuScrape); JMenu menuEdit = new JMenu(BUNDLE.getString("Button.edit")); //$NON-NLS-1$ menuEdit.setMnemonic(KeyEvent.VK_E); menuItem = menuEdit.add(actionEdit2); menuItem.setMnemonic(KeyEvent.VK_E); menuItem.setAccelerator( KeyStroke.getKeyStroke(KeyEvent.VK_E, ActionEvent.CTRL_MASK + ActionEvent.SHIFT_MASK)); menuItem = menuEdit.add(actionBatchEdit); menuItem.setMnemonic(KeyEvent.VK_B); menuItem.setAccelerator( KeyStroke.getKeyStroke(KeyEvent.VK_B, ActionEvent.CTRL_MASK + ActionEvent.SHIFT_MASK)); menuItem = menuEdit.add(actionSetWatchedFlag); menuItem.setMnemonic(KeyEvent.VK_W); menuItem.setAccelerator( KeyStroke.getKeyStroke(KeyEvent.VK_W, ActionEvent.CTRL_MASK + ActionEvent.SHIFT_MASK)); menuItem = menuEdit.add(actionChangeSeasonPoster2); menuItem.setMnemonic(KeyEvent.VK_S); menuEdit.add(actionChangeToDvdOrder); menuEdit.add(actionChangeToAiredOrder); menu.add(menuEdit); menu.add(actionRewriteTvShowNfo); menu.add(actionRewriteTvShowEpisodeNfo); menuItem = menu.add(actionRename); menuItem.setMnemonic(KeyEvent.VK_R); menuItem.setAccelerator( KeyStroke.getKeyStroke(KeyEvent.VK_R, ActionEvent.CTRL_MASK + ActionEvent.SHIFT_MASK)); menuItem = menu.add(actionMediaInformation2); menuItem.setMnemonic(KeyEvent.VK_M); menuItem.setAccelerator( KeyStroke.getKeyStroke(KeyEvent.VK_M, ActionEvent.CTRL_MASK + ActionEvent.SHIFT_MASK)); menuItem = menu.add(actionExport); menuItem.setMnemonic(KeyEvent.VK_X); menuItem.setAccelerator( KeyStroke.getKeyStroke(KeyEvent.VK_X, ActionEvent.CTRL_MASK + ActionEvent.SHIFT_MASK)); menuItem = menu.add(actionClearImageCache); menuItem.setMnemonic(KeyEvent.VK_C); menu.addSeparator(); menuItem = menu.add(actionRemove2); menuItem.setAccelerator(KeyStroke.getKeyStroke((char) KeyEvent.VK_DELETE)); menuItem = menu.add(actionDelete2); menuItem.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_DELETE, ActionEvent.SHIFT_MASK)); menu.addSeparator(); menuItem = menu.add(actionSyncTrakt); menuItem.setMnemonic(KeyEvent.VK_T); menuItem = menu.add(actionSyncWatchedTrakt); menuItem.setMnemonic(KeyEvent.VK_W); menuItem = menu.add(actionSyncSelectedTrakt); // popup menu JPopupMenu popupMenu = new JPopupMenu(); popupMenu.add(actionScrape2); popupMenu.add(actionScrapeSelected); popupMenu.add(actionScrapeEpisodes); popupMenu.add(actionScrapeEpisodes2); popupMenu.add(actionScrapeNewItems); // popupMenu.add(actionScrapeMetadataSelected); popupMenu.addSeparator(); popupMenu.add(actionUpdateTvShow); popupMenu.addSeparator(); popupMenu.add(actionEdit2); popupMenu.add(actionChangeSeasonPoster2); popupMenu.add(actionBatchEdit); popupMenu.add(actionSetWatchedFlag); popupMenu.add(actionChangeToDvdOrder); popupMenu.add(actionChangeToAiredOrder); popupMenu.add(actionRewriteTvShowNfo); popupMenu.add(actionRewriteTvShowEpisodeNfo); // popupMenu.add(actionBatchEdit); popupMenu.add(actionRename); popupMenu.add(actionMediaInformation2); popupMenu.add(actionExport); popupMenu.add(actionClearImageCache); popupMenu.addSeparator(); popupMenu.add(actionDownloadSubtitles); popupMenu.add(actionSearchAndDownloadSubtitles); popupMenu.addSeparator(); popupMenu.add(actionSyncTrakt); popupMenu.add(actionSyncWatchedTrakt); popupMenu.add(actionSyncSelectedTrakt); popupMenu.addSeparator(); popupMenu.add(actionRemove2); popupMenu.add(actionDelete2); popupMenu.addSeparator(); popupMenu.add(new ExpandAllAction()); popupMenu.add(new CollapseAllAction()); if (Globals.isDebug()) { JMenu menuDebug = new JMenu("Debug"); //$NON-NLS-1$ menuDebug.add(debugDumpShow); popupMenu.addSeparator(); popupMenu.add(menuDebug); } MouseListener popupListener = new TreePopupListener(popupMenu, tree); tree.addMouseListener(popupListener); }
From source file:org.ut.biolab.medsavant.client.cohort.CohortDetailedView.java
public JPopupMenu createHospitalPopup(final String[] hospitalIds) { JPopupMenu popupMenu = new JPopupMenu(); //Filter by patient JMenuItem filter1Item = new JMenuItem(String.format("<html>Filter by %s</html>", hospitalIds.length == 1 ? "Hospital ID <i>" + hospitalIds[0] + "</i>" : "Selected Hospital IDs")); filter1Item.addActionListener(new ActionListener() { @Override/* w w w . j a va 2s. co m*/ public void actionPerformed(ActionEvent e) { String cohort = null; if (cohorts.length == 1) { cohort = cohorts[0].getName(); } QueryUtils.addQueryOnHospitals(hospitalIds, cohort); DialogUtils.displayMessage( "Selected Cohort and Hospital IDS have been added to query. Click 'Variants' to review and execute search."); } }); popupMenu.add(filter1Item); return popupMenu; }
From source file:org.ut.biolab.medsavant.client.cohort.CohortDetailedView.java
@Override public JPopupMenu createPopup() { JPopupMenu popupMenu = new JPopupMenu(); if (ProjectController.getInstance().getCurrentVariantTableSchema() == null) { popupMenu.add(new JLabel("(You must choose a variant table before filtering)")); } else {/*from w w w .ja v a 2s .com*/ //Filter by patient JMenuItem filter1Item = new JMenuItem(String.format("<html>Filter by %s</html>", cohorts.length == 1 ? "Cohort <i>" + cohorts[0] + "</i>" : "Selected Cohorts")); filter1Item.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { QueryViewController qvc = SearchBar.getInstance().getQueryViewController(); SearchConditionGroupItem p = qvc.getQueryRootGroup(); List<SearchConditionItem> sciList = new ArrayList<SearchConditionItem>(cohorts.length); List<String> cohortStrings = new ArrayList(cohorts.length); for (Cohort cohort : cohorts) { cohortStrings.add(cohort.getName()); /* SearchConditionItem cohortItem = new SearchConditionItem("Cohort", SearchConditionGroupItem.QueryRelation.AND, p); cohortItem.setDescription(cohort.toString()); cohortItem.setSearchConditionEncoding(StringConditionEncoder.encodeConditions(Arrays.asList(new String[]{cohort.toString()}))); sciList.add(cohortItem); * */ } String description = StringConditionEncoder.getDescription(cohortStrings); String encodedConditions = StringConditionEncoder.encodeConditions(cohortStrings); qvc.replaceFirstLevelItem("Cohort", encodedConditions, description); /* if (cohorts.length < 2) { SearchConditionItem sci = sciList.get(0); qvc.generateItemViewAndAddToGroup(sci, p); } else { qvc.replaceFirstLevelGroup("Cohorts", sciList, QueryRelation.AND, true); }*/ qvc.refreshView(); DialogUtils.displayMessage( "Selected Cohorts have been added to query. Click 'Variants' to review and execute search."); } }); popupMenu.add(filter1Item); } return popupMenu; }
From source file:org.ut.biolab.medsavant.client.query.QueryViewController.java
private List<JComponent> getComponentsFromQueryModel(SearchConditionGroupItem g, int depth) { List<JComponent> components = new ArrayList<JComponent>(); int w = 0;//from w w w . j a v a 2s.c o m for (final SearchConditionItem item : g.getItems()) { if (item instanceof SearchConditionGroupItem) { String addition = ""; if (item.getParent() != null) { addition = item.getRelation() + ""; } final JPanel p = ViewUtil.getClearPanel(); MigLayout ml = new MigLayout("wrap 1, hidemode 1, insets 2"); p.setLayout(ml); Border border = ViewUtil.getThickLeftLineBorder(); p.setBorder(border); final PillView pv = new PillView(true); pv.indent(depth); pv.setActivated(true); final ActionListener toggleGroupExpand = new ActionListener() { @Override public void actionPerformed(ActionEvent ae) { expandedItemsMap.put((SearchConditionGroupItem) item, !p.isVisible()); p.setVisible(!p.isVisible()); pv.setText(getGroupTitle((SearchConditionGroupItem) item)); } }; pv.setExpandListener(toggleGroupExpand); pv.setPopupGenerator(new ConditionPopupGenerator() { @Override public JPopupMenu generatePopup() { final SearchConditionGroupItem groupItem = (SearchConditionGroupItem) item; final JPopupMenu m = new JPopupMenu(); if (!item.getParent().isFirstItem(item)) { if (item.getRelation() == QueryRelation.AND) { JMenuItem b = new JMenuItem("Change to \"or\""); b.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent ae) { item.setRelation(QueryRelation.OR); pv.setText(getGroupTitle(groupItem)); } }); m.add(b); } else { JMenuItem b = new JMenuItem("Change to \"and\""); b.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent ae) { item.setRelation(QueryRelation.AND); pv.setText(getGroupTitle(groupItem)); } }); m.add(b); } } JMenuItem delgroup = new JMenuItem("Delete"); delgroup.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent ae) { groupItem.getParent().removeItem(groupItem); refreshView(); expandedItemsMap.remove((SearchConditionGroupItem) item); } }); m.add(delgroup); return m; } }); SearchConditionGroupItem g2 = (SearchConditionGroupItem) item; pv.setText(getGroupTitle(g2)); Boolean exp = expandedItemsMap.get((SearchConditionGroupItem) item); if (exp == null) { p.setVisible(false); pv.collapse(); } else { p.setVisible(true); pv.expand(); } components.add(pv); for (JComponent c : getComponentsFromQueryModel((SearchConditionGroupItem) item, depth + 1)) { p.add(c, "left"); } components.add(p); w = pv.getMaximumSize().width; } else { SearchConditionItemView sciv = itemToViewMap.get(item); ((PillView) sciv).indent(depth); w = sciv.getMaximumSize().width; sciv.refresh(); components.add(sciv); } } if (w == 0) { w = BOTTOM_SEARCH_TEXTFIELD_WIDTH; } JComponent c = getInputFieldForGroup(g, w); components.add(c); return components; }
From source file:org.ut.biolab.medsavant.client.view.genetics.charts.SummaryChart.java
private JPopupMenu createPopup(final Chart chart) { JPopupMenu menu = new JPopupMenu(); //Filter by selections JMenuItem filter1Item = new JMenuItem("Filter by Selection" + (mapGenerator.isNumeric() ? "" : "(s)")); filter1Item.addActionListener(new ActionListener() { @Override/* www .j a va 2 s . c o m*/ public void actionPerformed(ActionEvent e) { ThreadController.getInstance().cancelWorkers(pageName); boolean isGender = mapGenerator.getName().equalsIgnoreCase(BasicPatientColumns.GENDER.getAlias()); try { List<String> values = new ArrayList<String>(); ListSelectionModel selectionModel = chart.getSelectionsForModel(chart.getModel(0)); QueryViewController qvc = SearchBar.getInstance().getQueryViewController(); for (int i = selectionModel.getMinSelectionIndex(); i <= selectionModel .getMaxSelectionIndex(); i++) { if (selectionModel.isSelectedIndex(i)) { String v = ((ChartPoint) chart.getModel().getPoint(i)).getHighlight().name(); values.add(v); if (mapGenerator.isNumeric() && !isGender) { double low = 0; double high = 0; String[] s = v.split(" - "); if (s.length < 2) { LOG.error("Invalid range detected for numeric condition " + mapGenerator.getName() + " val=" + v); } NumberFormat format = NumberFormat.getInstance(); low = format.parse(s[0]).doubleValue(); high = format.parse(s[1]).doubleValue(); QueryUtils.addNumericQuery(chartName, low, high, false); } } } if (values.isEmpty()) { return; } if (!mapGenerator.isNumeric() || isGender) { QueryUtils.addMultiStringQuery(chartName, values); } } catch (Exception ex) { ClientMiscUtils.reportError("Error filtering by selection: %s", ex); } } }); menu.add(filter1Item); return menu; }
From source file:org.ut.biolab.medsavant.client.view.genetics.TablePanel.java
private JPopupMenu createPopupSingle() { JPopupMenu menu = new JPopupMenu(); TableModel model = searchableTablePanel.getTable().getModel(); int r = TableModelWrapperUtils.getActualRowAt(model, searchableTablePanel.getTable().getSelectedRow()); final String chrom = (String) model.getValueAt(r, INDEX_OF_CHROM); final int startpos = (Integer) model.getValueAt(r, INDEX_OF_START_POSITION); final int endpos = (Integer) model.getValueAt(r, INDEX_OF_END_POSITION); final String alt = (String) model.getValueAt(r, INDEX_OF_ALT); //Filter by position JMenuItem posItem = new JMenuItem("Filter by Position"); posItem.addActionListener(new ActionListener() { @Override//from www. j a v a2 s . com public void actionPerformed(ActionEvent ae) { //QueryUtils.addQueryOnChromPosition(chrom,pos); List<GenomicRegion> gr = new ArrayList<GenomicRegion>(1); gr.add(new GenomicRegion(null, chrom, startpos, endpos)); QueryUtils.addQueryOnRegions(gr, null); } }); menu.add(posItem); //Filter by position and alt JMenuItem posAndAltItem = new JMenuItem("Filter by Position and Alt"); posAndAltItem.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent ae) { QueryUtils.addQueryOnRegionWithAlt(new GenomicRegion(null, chrom, startpos, endpos), alt); } }); menu.add(posAndAltItem); return menu; }
From source file:org.ut.biolab.medsavant.client.view.genetics.TablePanel.java
private JPopupMenu createPopupMultiple() { JPopupMenu menu = new JPopupMenu(); JMenuItem posItem = new JMenuItem("Filter by Selected Positions"); posItem.addActionListener(new ActionListener() { @Override/* w w w. j a va 2s. com*/ public void actionPerformed(ActionEvent ae) { ThreadController.getInstance().cancelWorkers(pageName); //QueryViewController qvc = SearchBar.getInstance().getQueryViewController(); List<GenomicRegion> regions = new ArrayList<GenomicRegion>(); TableModel model = searchableTablePanel.getTable().getModel(); int[] selRows = TableModelWrapperUtils.getActualRowsAt(model, searchableTablePanel.getTable().getSelectedRows(), false); List<SearchConditionItem> sciList = new ArrayList<SearchConditionItem>(selRows.length); for (int r : selRows) { String chrom = (String) model.getValueAt(r, INDEX_OF_CHROM); int startpos = (Integer) model.getValueAt(r, INDEX_OF_START_POSITION); int endpos = (Integer) model.getValueAt(r, INDEX_OF_END_POSITION); regions.add(new GenomicRegion(null, chrom, startpos, endpos)); /* SearchConditionGroupItem posGroup = new SearchConditionGroupItem(SearchConditionGroupItem.QueryRelation.OR, null, null); posGroup.setDescription("Chromosome "+chrom+", Pos. "+pos); SearchConditionItem chromItem = new SearchConditionItem(BasicVariantColumns.CHROM.getAlias(), SearchConditionGroupItem.QueryRelation.AND, posGroup); chromItem.setDescription(chrom); chromItem.setSearchConditionEncoding(StringConditionEncoder.encodeConditions(Arrays.asList(new String[]{chrom}))); SearchConditionItem startPosItem = new SearchConditionItem(BasicVariantColumns.POSITION.getAlias(), SearchConditionGroupItem.QueryRelation.AND, posGroup); startPosItem.setDescription(Integer.toString(pos)); startPosItem.setSearchConditionEncoding(NumericConditionEncoder.encodeConditions(pos, pos)); qvc.generateItemViewAndAddToGroup(chromItem, posGroup); qvc.generateItemViewAndAddToGroup(startPosItem, posGroup); sciList.add(posGroup); */ } //qvc.replaceFirstLevelGroup("Selected Position(s)", sciList, QueryRelation.OR, false); //qvc.refreshView(); QueryUtils.addQueryOnRegions(regions, null); } }); menu.add(posItem); return menu; }
From source file:org.ut.biolab.medsavant.client.view.genetics.variantinfo.GeneManiaSubInspector.java
private JPopupMenu getRegionSetsMenu(Gene gene) { final JPopupMenu regionSets = new JPopupMenu(); final RegionController regionController = RegionController.getInstance(); final Gene g = gene; try {//from w w w. j av a 2s . c om for (RegionSet s : regionController.getRegionSets()) { final RegionSet finalRegionSet = s; JMenuItem menuItem = new JMenuItem(s.getName()); menuItem.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent ae) { try { regionController.addToRegionSet(finalRegionSet, g.getChrom(), g.getStart(), g.getEnd(), g.getName()); DialogUtils.displayMessage(String.format("Successfully added %s to %s list", g.getName(), finalRegionSet.getName())); } catch (Exception ex) { ClientMiscUtils.reportError(String.format("Unable to add %s to %s list: %%s", g.getName(), finalRegionSet.getName()), ex); } } }); regionSets.add(menuItem); } } catch (Exception ex) { return new JPopupMenu(); } return regionSets; }
From source file:org.ut.biolab.medsavant.client.view.Menu.java
private JPanel getLoginMenuItem() { //loginStatusLabel = new JLabel(""); final JPanel loginMenu = ViewUtil.getClearPanel(); ViewUtil.applyHorizontalBoxLayout(loginMenu); userButton = ViewUtil.getIconButton(IconFactory.getInstance().getIcon(IconFactory.StandardIcon.MENU_USER)); loginMenu.add(ViewUtil.subTextComponent(userButton, "Log Out"));//LoginController.getInstance().getUserName())); final JPopupMenu m = new JPopupMenu(); userButton.addActionListener(new ActionListener() { @Override//from w w w.java 2s .com public void actionPerformed(ActionEvent ae) { MedSavantFrame.getInstance().requestClose(); } }); //loginMenu.add(ViewUtil.getSmallSeparator()); return loginMenu; }