List of usage examples for javax.swing JMenuItem setIcon
@BeanProperty(visualUpdate = true, description = "The button's default icon") public void setIcon(Icon defaultIcon)
From source file:org.gtdfree.GTDFree.java
/** * This method initializes jMenu //w w w .ja va2 s . c o m * * @return javax.swing.JMenu */ private JMenu getFileMenu() { if (fileMenu == null) { fileMenu = new JMenu(); fileMenu.setText(Messages.getString("GTDFree.File")); //$NON-NLS-1$ fileMenu.add(getSaveMenuItem()); autoSaveMenuItem = new JCheckBoxMenuItem(); autoSaveMenuItem.setText(Messages.getString("GTDFree.File.ASave")); //$NON-NLS-1$ if (getEngine().getGTDModel().getDataRepository() instanceof GTDDataXML) { autoSaveMenuItem.setSelected( getEngine().getGlobalProperties().getBoolean(GlobalProperties.AUTO_SAVE, true)); } else { autoSaveMenuItem.setSelected(true); autoSaveMenuItem.setEnabled(false); } autoSaveMenuItem.setToolTipText(Messages.getString("GTDFree.File.ASave.desc")); //$NON-NLS-1$ autoSaveMenuItem.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { getEngine().setAutoSave(autoSaveMenuItem.isSelected()); getEngine().getGlobalProperties().putProperty(GlobalProperties.AUTO_SAVE, autoSaveMenuItem.isSelected()); } }); fileMenu.add(autoSaveMenuItem); /*fileMenu.add(new JSeparator()); printCurrentMenuItem= new JMenuItem(); printCurrentMenuItem.setText("Print current view..."); printCurrentMenuItem.setEnabled(false); printCurrentMenuItem.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { WorkflowPane p= getEngine().getActiveWorkflowPane(); if (p!=null) { try { p.printTable(); } catch (PrinterException e1) { e1.printStackTrace(); JOptionPane.showMessageDialog(getJFrame(), "Printing failed, error: "+e1.toString(), "Printing failed", JOptionPane.ERROR_MESSAGE); } } } }); getEngine().addPropertyChangeListener("activePane", new PropertyChangeListener() { @Override public void propertyChange(PropertyChangeEvent evt) { printCurrentMenuItem.setEnabled(getEngine().getActiveWorkflowPane()!=null); } }); fileMenu.add(printCurrentMenuItem);*/ fileMenu.add(new JSeparator()); JMenuItem jmi = new JMenuItem(Messages.getString("GTDFree.File.Print")); //$NON-NLS-1$ jmi.setIcon(ApplicationHelper.getIcon(ApplicationHelper.icon_name_large_print)); jmi.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { getPrintDialog().setVisible(true); } }); fileMenu.add(jmi); fileMenu.add(new JSeparator()); jmi = new JMenuItem(Messages.getString("GTDFree.File.Import")); //$NON-NLS-1$ jmi.setIcon(ApplicationHelper.getIcon(ApplicationHelper.icon_name_large_import)); jmi.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { importFile(); } }); fileMenu.add(jmi); jmi = new JMenuItem(Messages.getString("GTDFree.File.Export")); //$NON-NLS-1$ jmi.setIcon(ApplicationHelper.getIcon(ApplicationHelper.icon_name_large_export)); jmi.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { getExportDialog().setVisible(true); } }); fileMenu.add(jmi); jmi = new JMenuItem(Messages.getString("GTDFree.File.All")); //$NON-NLS-1$ jmi.setToolTipText(Messages.getString("GTDFree.File.All.desc")); //$NON-NLS-1$ jmi.setIcon(ApplicationHelper.getIcon(ApplicationHelper.icon_name_large_export)); jmi.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { exportFile(); } }); fileMenu.add(jmi); fileMenu.add(new JSeparator()); fileMenu.add(getExitMenuItem()); } return fileMenu; }
From source file:org.gtdfree.GTDFree.java
/** * This method initializes jMenu //from w ww. j ava2 s .c om * * @return javax.swing.JMenu */ private JMenu getHelpMenu() { if (helpMenu == null) { helpMenu = new JMenu(); helpMenu.setText(Messages.getString("GTDFree.Help")); //$NON-NLS-1$ JMenuItem jmi = new JMenuItem(Messages.getString("GTDFree.Help.Home")); //$NON-NLS-1$ jmi.setIcon(ApplicationHelper.getIcon(ApplicationHelper.icon_name_large_browser)); jmi.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { URI uri; try { uri = new URI(getEngine().getConfiguration().getProperty("home.url", //$NON-NLS-1$ "http://gtd-free.sourceforge.net")); //$NON-NLS-1$ Desktop.getDesktop().browse(uri); } catch (Exception e1) { Logger.getLogger(this.getClass()).error("URL load failed.", e1); //$NON-NLS-1$ } } }); helpMenu.add(jmi); jmi = new JMenuItem(Messages.getString("GTDFree.Help.Manuals")); //$NON-NLS-1$ jmi.setIcon(ApplicationHelper.getIcon(ApplicationHelper.icon_name_large_browser)); jmi.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { URI uri; try { uri = new URI(getEngine().getConfiguration().getProperty("manuals.url", //$NON-NLS-1$ "http://gtd-free.sourceforge.net/manuals.html")); //$NON-NLS-1$ //$NON-NLS-3$ Desktop.getDesktop().browse(uri); } catch (Exception e1) { Logger.getLogger(this.getClass()).error("URL load failed.", e1); //$NON-NLS-1$ } } }); helpMenu.add(jmi); jmi = new JMenuItem(getActionMap().get("importDialog")); //$NON-NLS-1$ helpMenu.add(jmi); helpMenu.add(new JSeparator()); jmi = new JMenuItem(); jmi.setText(Messages.getString("GTDFree.Check")); //$NON-NLS-1$ jmi.setIcon(ApplicationHelper.getIcon(ApplicationHelper.icon_name_large_update)); jmi.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { new Thread() { @Override public void run() { checkForUpdates(true); } }.start(); } }); helpMenu.add(jmi); JCheckBoxMenuItem jcbmi = new JCheckBoxMenuItem(); jcbmi.setText(Messages.getString("GTDFree.CheckAtStartup")); //$NON-NLS-1$ try { getEngine().getGlobalProperties().connectBooleanProperty(GlobalProperties.CHECK_FOR_UPDATE_AT_START, jcbmi, "selected", "isSelected", "setSelected", true); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ } catch (Exception e1) { logger.debug("Internal error.", e1); //$NON-NLS-1$ } helpMenu.add(jcbmi); helpMenu.add(new JSeparator()); jmi = new JMenuItem(); jmi.setText(Messages.getString("GTDFree.Help.Mon")); //$NON-NLS-1$ jmi.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { getMonitor().getDialog().setVisible(true); } }); helpMenu.add(jmi); helpMenu.add(new JSeparator()); helpMenu.add(getAboutMenuItem()); } return helpMenu; }
From source file:org.netbeans.jpa.modeler.core.widget.attribute.AttributeWidget.java
@Override protected List<JMenuItem> getPopupMenuItemList() { List<JMenuItem> menuList = super.getPopupMenuItemList(); JMenuItem delete; delete = new JMenuItem("Delete"); delete.setIcon(DELETE_ICON); delete.addActionListener(e -> {// ww w. ja v a2 s. c om AttributeWidget.this.remove(true); }); menuList.add(0, delete); return menuList; }
From source file:org.nuclos.client.genericobject.GenericObjectCollectController.java
protected void setupResultContextMenuStates() { this.getResultPanel().popupmenuRow.addPopupMenuListener(new PopupMenuListener() { @Override/* w w w .jav a 2s . c o m*/ public void popupMenuWillBecomeVisible(PopupMenuEvent e) { UIUtils.runCommand(getTab(), new Runnable() { @Override public void run() { try { final List<StateVO> lstSubsequenteStates = getSubsequentStates( getSelectedCollectables()); JMenu mi = getResultPanel().miStates; mi.setVisible(lstSubsequenteStates.size() != 0); // try to find single soruce state... StateVO statevoSource = getSingleSourceStateIfAny(getSelectedCollectables()); for (final StateVO statevoTarget : lstSubsequenteStates) { final JMenuItem miStateChange = new JMenuItem( new StateChangeAction(statevoSource, statevoTarget)); miStateChange.setIcon(null); mi.add(miStateChange); } } catch (Exception e1) { getResultPanel().miStates.setVisible(false); LOG.warn("popupMenuWillBecomeVisible failed: " + e1 + ", setting it invisible"); } } }); } @Override public void popupMenuWillBecomeInvisible(PopupMenuEvent e) { clearStatesMenu(); } @Override public void popupMenuCanceled(PopupMenuEvent e) { clearStatesMenu(); } private void clearStatesMenu() { getResultPanel().miStates.removeAll(); } }); }
From source file:org.openmicroscopy.shoola.env.ui.TaskBarView.java
/** * Makes and returns a copy of the specified item. * * @param original The item to handle./*from ww w . j a v a 2s .c o m*/ * @return See above. */ private JMenuItem copyItem(JMenuItem original) { JMenuItem item = new JMenuItem(original.getAction()); item.setIcon(original.getIcon()); item.setText(original.getText()); item.setToolTipText(original.getToolTipText()); ActionListener[] al = original.getActionListeners(); for (int j = 0; j < al.length; j++) item.addActionListener(al[j]); return item; }
From source file:org.openscience.jmol.app.Jmol.java
/** * This is the hook through which all menu items are * created. It registers the result with the menuitem * hashtable so that it can be fetched with getMenuItem(). * @param cmd//from w w w.j a va 2s .c om * @return Menu item created * @see #getMenuItem */ protected JMenuItem createMenuItem(String cmd) { JMenuItem mi; if (cmd.endsWith("Check")) { mi = guimap.newJCheckBoxMenuItem(cmd, false); } else { mi = guimap.newJMenuItem(cmd); } ImageIcon f = JmolResourceHandler.getIconX(cmd + "Image"); if (f != null) { mi.setHorizontalTextPosition(SwingConstants.RIGHT); mi.setIcon(f); } if (cmd.endsWith("Script")) { mi.setActionCommand(JmolResourceHandler.getStringX(cmd)); mi.addActionListener(executeScriptAction); } else { mi.setActionCommand(cmd); Action a = getAction(cmd); if (a != null) { mi.addActionListener(a); a.addPropertyChangeListener(new ActionChangedListener(mi)); mi.setEnabled(a.isEnabled()); } else { mi.setEnabled(false); } } menuItems.put(cmd, mi); return mi; }
From source file:org.pdfsam.guiclient.commons.panels.JVisualPdfPageSelectionPanel.java
/** * panel initialization//from ww w . jav a 2 s . c om */ private void init() { setLayout(new GridBagLayout()); thumbnailList.setDrawDeletedItems(drawDeletedItems); if (dndSupport == DND_SUPPORT_FILES) { thumbnailList.setTransferHandler(new VisualListExportTransferHandler(pdfLoader)); } else if (dndSupport == DND_SUPPORT_JAVAOBJECTS) { thumbnailList.setTransferHandler(new VisualListTransferHandler()); } else if (dndSupport == DND_SUPPORT_FILES_AND_JAVAOBJECTS) { thumbnailList.setTransferHandler(new VisualListTransferHandler(pdfLoader)); } else { thumbnailList.setTransferHandler(new VisualListExportTransferHandler(null)); } thumbnailList.setDragEnabled(true); thumbnailList.setDropMode(DropMode.INSERT); pagesWorker = new PagesWorker(thumbnailList); thumbnailList.addKeyListener(new VisualPdfSelectionKeyAdapter(pagesWorker)); thumbnailList.addMouseListener(new PageOpenerMouseAdapter(thumbnailList)); if (showButtonPanel) { initButtonPanel(pagesWorker); initKeyListener(); } //JList orientation if (HORIZONTAL_ORIENTATION == orientation) { thumbnailList.setLayoutOrientation(JList.HORIZONTAL_WRAP); } else { if (wrap) { thumbnailList.setLayoutOrientation(JList.VERTICAL_WRAP); } } topPanel.setLayout(new BoxLayout(topPanel, BoxLayout.LINE_AXIS)); topPanel.setPreferredSize(new Dimension(400, 30)); pdfSelectionActionListener = new VisualPdfSelectionActionListener(this, pdfLoader); if (topPanelStyle >= STYLE_TOP_PANEL_FULL) { //load button loadFileButton.setMargin(new Insets(1, 1, 1, 1)); loadFileButton.setText(GettextResource.gettext(config.getI18nResourceBundle(), "Open")); loadFileButton.setPreferredSize(new Dimension(100, 30)); loadFileButton .setToolTipText(GettextResource.gettext(config.getI18nResourceBundle(), "Load a pdf document")); loadFileButton.setIcon(new ImageIcon(this.getClass().getResource("/images/add.png"))); loadFileButton.addKeyListener(new EnterDoClickListener(loadFileButton)); loadFileButton.setAlignmentX(Component.CENTER_ALIGNMENT); loadFileButton.setAlignmentY(Component.CENTER_ALIGNMENT); loadFileButton.setActionCommand(VisualPdfSelectionActionListener.ADD); loadFileButton.addActionListener(pdfSelectionActionListener); } documentProperties.setIcon(new ImageIcon(this.getClass().getResource("/images/info.png"))); documentProperties.setVisible(false); if (topPanelStyle >= STYLE_TOP_PANEL_MEDIUM) { clearButton.setMargin(new Insets(1, 1, 1, 1)); clearButton.setMinimumSize(new Dimension(30, 30)); clearButton.setText(GettextResource.gettext(config.getI18nResourceBundle(), "Clear")); clearButton.setIcon(new ImageIcon(this.getClass().getResource("/images/clear.png"))); clearButton.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { resetPanel(); } }); } zoomInButton.setMargin(new Insets(1, 1, 1, 1)); zoomInButton.setMinimumSize(new Dimension(30, 30)); zoomInButton.setText(GettextResource.gettext(config.getI18nResourceBundle(), "Zoom in")); zoomInButton.setIcon(new ImageIcon(this.getClass().getResource("/images/zoomin.png"))); zoomInButton.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { try { thumbnailList.incZoomLevel(); zoomOutButton.setEnabled(true); if (thumbnailList.getCurrentZoomLevel() >= JVisualSelectionList.MAX_ZOOM_LEVEL) { zoomInButton.setEnabled(false); } ((VisualListModel) thumbnailList.getModel()).elementsChanged(); } catch (Exception ex) { log.error(GettextResource.gettext(config.getI18nResourceBundle(), "Error setting zoom level."), ex); } } }); zoomOutButton.setMargin(new Insets(1, 1, 1, 1)); zoomOutButton.setMinimumSize(new Dimension(30, 30)); zoomOutButton.setText(GettextResource.gettext(config.getI18nResourceBundle(), "Zoom out")); zoomOutButton.setIcon(new ImageIcon(this.getClass().getResource("/images/zoomout.png"))); zoomOutButton.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { try { thumbnailList.deincZoomLevel(); zoomInButton.setEnabled(true); if (thumbnailList.getCurrentZoomLevel() <= JVisualSelectionList.MIN_ZOOM_LEVEL) { zoomOutButton.setEnabled(false); } ((VisualListModel) thumbnailList.getModel()).elementsChanged(); } catch (Exception ex) { log.error(GettextResource.gettext(config.getI18nResourceBundle(), "Error setting zoom level."), ex); } } }); thumbnailList.setModel(new VisualListModel()); thumbnailList.setCellRenderer(new VisualListRenderer()); thumbnailList.setVisibleRowCount(-1); thumbnailList.setSelectionMode(selectionType); JScrollPane listScroller = new JScrollPane(thumbnailList); //preview item menuItemPreview.setIcon(new ImageIcon(this.getClass().getResource("/images/preview-viewer.png"))); menuItemPreview.setText(GettextResource.gettext(config.getI18nResourceBundle(), "Preview")); menuItemPreview.addMouseListener(new MouseAdapter() { public void mouseReleased(MouseEvent e) { int[] selection = thumbnailList.getSelectedIndices(); if (selection != null && selection.length == 1) { VisualPageListItem item = (VisualPageListItem) thumbnailList.getModel() .getElementAt(selection[0]); PagePreviewOpener.getInstance().openPreview(item.getParentFileCanonicalPath(), item.getDocumentPassword(), item.getPageNumber()); } } }); if (showContextMenu) { //popup final JMenuItem menuItemMoveUp = new JMenuItem(); menuItemMoveUp.setIcon(new ImageIcon(this.getClass().getResource("/images/up.png"))); menuItemMoveUp.setText(GettextResource.gettext(config.getI18nResourceBundle(), "Move Up")); menuItemMoveUp.addMouseListener(new VisualPdfSelectionMouseAdapter(PagesWorker.MOVE_UP, pagesWorker)); popupMenu.add(menuItemMoveUp); final JMenuItem menuItemMoveDown = new JMenuItem(); menuItemMoveDown.setIcon(new ImageIcon(this.getClass().getResource("/images/down.png"))); menuItemMoveDown.setText(GettextResource.gettext(config.getI18nResourceBundle(), "Move Down")); menuItemMoveDown .addMouseListener(new VisualPdfSelectionMouseAdapter(PagesWorker.MOVE_DOWN, pagesWorker)); popupMenu.add(menuItemMoveDown); final JMenuItem menuItemRemove = new JMenuItem(); menuItemRemove.setIcon(new ImageIcon(this.getClass().getResource("/images/remove.png"))); menuItemRemove.setText(GettextResource.gettext(config.getI18nResourceBundle(), "Delete")); menuItemRemove.addMouseListener(new VisualPdfSelectionMouseAdapter(PagesWorker.REMOVE, pagesWorker)); popupMenu.add(menuItemRemove); //if elements are physically deleted i don't need this item if (drawDeletedItems) { final JMenuItem menuItemUndelete = new JMenuItem(); menuItemUndelete.setIcon(new ImageIcon(this.getClass().getResource("/images/remove.png"))); menuItemUndelete.setText(GettextResource.gettext(config.getI18nResourceBundle(), "Undelete")); menuItemUndelete .addMouseListener(new VisualPdfSelectionMouseAdapter(PagesWorker.UNDELETE, pagesWorker)); popupMenu.add(menuItemUndelete); } //rotate item final JMenuItem menuItemRotate = new JMenuItem(); menuItemRotate.setIcon(new ImageIcon(this.getClass().getResource("/images/clockwise.png"))); menuItemRotate.setText(GettextResource.gettext(config.getI18nResourceBundle(), "Rotate clockwise")); menuItemRotate .addMouseListener(new VisualPdfSelectionMouseAdapter(PagesWorker.ROTATE_CLOCK, pagesWorker)); popupMenu.add(menuItemRotate); //rotate anticlock item final JMenuItem menuItemAntiRotate = new JMenuItem(); menuItemAntiRotate.setIcon(new ImageIcon(this.getClass().getResource("/images/anticlockwise.png"))); menuItemAntiRotate .setText(GettextResource.gettext(config.getI18nResourceBundle(), "Rotate anticlockwise")); menuItemAntiRotate.addMouseListener( new VisualPdfSelectionMouseAdapter(PagesWorker.ROTATE_ANTICLOCK, pagesWorker)); popupMenu.add(menuItemAntiRotate); //reverse item final JMenuItem menuItemReverse = new JMenuItem(); menuItemReverse.setIcon(new ImageIcon(this.getClass().getResource("/images/reverse.png"))); menuItemReverse.setText(GettextResource.gettext(config.getI18nResourceBundle(), "Reverse")); menuItemReverse.addMouseListener(new VisualPdfSelectionMouseAdapter(PagesWorker.REVERSE, pagesWorker)); popupMenu.add(menuItemReverse); enableSetOutputPathMenuItem(); addPopupShower(); } popupMenu.add(menuItemPreview); if (topPanelStyle >= STYLE_TOP_PANEL_FULL) { topPanel.add(Box.createRigidArea(new Dimension(5, 0))); topPanel.add(loadFileButton); } if (topPanelStyle >= STYLE_TOP_PANEL_MEDIUM) { topPanel.add(Box.createRigidArea(new Dimension(5, 0))); topPanel.add(clearButton); } topPanel.add(Box.createRigidArea(new Dimension(5, 0))); topPanel.add(documentProperties); topPanel.add(Box.createHorizontalGlue()); topPanel.add(zoomInButton); topPanel.add(Box.createRigidArea(new Dimension(5, 0))); topPanel.add(zoomOutButton); GridBagConstraints topConstraints = new GridBagConstraints(); topConstraints.fill = GridBagConstraints.BOTH; topConstraints.gridx = 0; topConstraints.gridy = 0; topConstraints.gridwidth = 3; topConstraints.gridheight = 1; topConstraints.insets = new Insets(5, 5, 5, 5); topConstraints.weightx = 1.0; topConstraints.weighty = 0.0; if (topPanelStyle > STYLE_TOP_PANEL_HIDE) { add(topPanel, topConstraints); } GridBagConstraints thumbConstraints = new GridBagConstraints(); thumbConstraints.fill = GridBagConstraints.BOTH; thumbConstraints.gridx = 0; thumbConstraints.gridy = 1; thumbConstraints.gridwidth = (showButtonPanel ? 2 : 3); thumbConstraints.gridheight = 2; thumbConstraints.insets = new Insets(5, 5, 5, 5); thumbConstraints.weightx = 1.0; thumbConstraints.weighty = 1.0; add(listScroller, thumbConstraints); if (showButtonPanel) { GridBagConstraints buttonsConstraints = new GridBagConstraints(); buttonsConstraints.fill = GridBagConstraints.BOTH; buttonsConstraints.gridx = 2; buttonsConstraints.gridy = 1; buttonsConstraints.gridwidth = 1; buttonsConstraints.gridheight = 2; buttonsConstraints.insets = new Insets(5, 5, 5, 5); buttonsConstraints.weightx = 0.0; buttonsConstraints.weighty = 1.0; add(buttonPanel, buttonsConstraints); } }
From source file:org.photovault.swingui.BrowserWindow.java
protected void createUI(PhotoCollection collection) { window.setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE); tabPane = new JTabbedPane(); queryPane = new QueryPane(); PhotoFolderTreeController treeCtrl = new PhotoFolderTreeController(window, this); viewCtrl = new PhotoViewController(window, this); treePane = treeCtrl.folderTree;/*from ww w . j av a2 s. co m*/ viewPane = viewCtrl.getThumbPane(); previewPane = viewCtrl.getPreviewPane(); tabPane.addTab("Query", queryPane); tabPane.addTab("Folders", treePane); VolumeTreeController volTreeCtrl = new VolumeTreeController(this); JTree volumeTree = volTreeCtrl.getView(); JScrollPane voltreeScrollPane = new JScrollPane(volumeTree); voltreeScrollPane.setPreferredSize(new Dimension(200, 500)); tabPane.add("Volumes", voltreeScrollPane); // TODO: get rid of this!!!! EditSelectionColorsAction colorAction = (EditSelectionColorsAction) viewPane.getEditSelectionColorsAction(); colorAction.setPreviewCtrl(previewPane); // Set listeners to both query and folder tree panes /* If an actionEvent comes from query pane, swich to query results. */ queryPane.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { viewCtrl.setCollection(queryPane.getResultCollection()); } }); /* If the selected folder is changed in treePane, switch to that immediately */ treeCtrl.registerEventListener(PhotoFolderTreeEvent.class, new DefaultEventListener<PhotoCollection>() { public void handleEvent(DefaultEvent<PhotoCollection> event) { PhotoCollection c = event.getPayload(); if (c != null) { viewCtrl.setCollection(c); if (c instanceof PhotoFolder) { PhotoFolder f = (PhotoFolder) c; if (f.getExternalDir() != null) { ExternalDir ed = f.getExternalDir(); folderIndexer.updateDir(ed.getVolume(), ed.getPath()); viewCtrl.setIndexingOngoing(true); } } } } }); volTreeCtrl.registerEventListener(PhotoFolderTreeEvent.class, new DefaultEventListener<PhotoCollection>() { public void handleEvent(DefaultEvent<PhotoCollection> event) { PhotoCollection c = event.getPayload(); if (c != null) { viewCtrl.setCollection(c); if (c instanceof ExtDirPhotos) { ExtDirPhotos photos = (ExtDirPhotos) c; ExternalVolume vol = (ExternalVolume) viewCtrl.getDAOFactory().getVolumeDAO() .getVolume(photos.getVolId()); folderIndexer.updateDir(vol, photos.getDirPath()); viewCtrl.setIndexingOngoing(true); } } } }); collectionPane = viewCtrl.getCollectionPane(); JSplitPane split = new JSplitPane(JSplitPane.HORIZONTAL_SPLIT, tabPane, collectionPane); split.putClientProperty(JSplitPane.ONE_TOUCH_EXPANDABLE_PROPERTY, new Boolean(true)); Container cp = window.getContentPane(); cp.setLayout(new BorderLayout()); cp.add(split, BorderLayout.CENTER); statusBar = new StatusBar(); cp.add(statusBar, BorderLayout.SOUTH); // Create actions for BrowserWindow UI ImageIcon indexDirIcon = getIcon("index_dir.png"); DefaultAction indexDirAction = new DefaultAction("Index directory...", indexDirIcon) { public void actionPerformed(ActionEvent e) { indexDir(); } }; indexDirAction.putValue(AbstractAction.MNEMONIC_KEY, KeyEvent.VK_D); indexDirAction.putValue(AbstractAction.SHORT_DESCRIPTION, "Index all images in a directory"); this.registerAction("new_ext_vol", indexDirAction); ImageIcon importIcon = getIcon("import.png"); importAction = new AbstractAction("Import image...", importIcon) { public void actionPerformed(ActionEvent e) { importFile(); } }; importAction.putValue(AbstractAction.MNEMONIC_KEY, KeyEvent.VK_O); importAction.putValue(AbstractAction.ACCELERATOR_KEY, KeyStroke.getKeyStroke(KeyEvent.VK_O, Toolkit.getDefaultToolkit().getMenuShortcutKeyMask())); importAction.putValue(AbstractAction.SHORT_DESCRIPTION, "Import new image into database"); ImageIcon updateIcon = getIcon("update_indexed_dirs.png"); UpdateIndexAction updateIndexAction = new UpdateIndexAction(viewCtrl, "Update indexed dirs", updateIcon, "Check for changes in previously indexed directories", KeyEvent.VK_U); this.registerAction("update_indexed_dirs", updateIndexAction); updateIndexAction.addStatusChangeListener(statusBar); ImageIcon previewTopIcon = getIcon("view_preview_top.png"); DefaultAction previewTopAction = new DefaultAction("Preview on top", previewTopIcon) { public void actionPerformed(ActionEvent e) { viewCtrl.setLayout(PhotoViewController.Layout.PREVIEW_HORIZONTAL_THUMBS); } }; previewTopAction.putValue(AbstractAction.SHORT_DESCRIPTION, "Show preview on top of thumbnails"); previewTopAction.putValue(AbstractAction.MNEMONIC_KEY, KeyEvent.VK_T); this.registerAction("view_preview_top", previewTopAction); ImageIcon previewRightIcon = getIcon("view_preview_right.png"); DefaultAction previewRightAction = new DefaultAction("Preview on right", previewRightIcon) { public void actionPerformed(ActionEvent e) { viewCtrl.setLayout(PhotoViewController.Layout.PREVIEW_VERTICAL_THUMBS); } }; previewRightAction.putValue(AbstractAction.SHORT_DESCRIPTION, "Show preview on right of thumbnails"); previewRightAction.putValue(AbstractAction.MNEMONIC_KEY, KeyEvent.VK_R); this.registerAction("view_preview_right", previewRightAction); ImageIcon previewNoneIcon = getIcon("view_no_preview.png"); DefaultAction previewNoneAction = new DefaultAction("No preview", previewNoneIcon) { public void actionPerformed(ActionEvent e) { viewCtrl.setLayout(PhotoViewController.Layout.ONLY_THUMBS); } }; previewNoneAction.putValue(AbstractAction.SHORT_DESCRIPTION, "Show no preview image"); previewNoneAction.putValue(AbstractAction.MNEMONIC_KEY, KeyEvent.VK_O); this.registerAction("view_no_preview", previewNoneAction); DefaultAction previewLargeAction = new DefaultAction("Large", null) { public void actionPerformed(ActionEvent e) { viewCtrl.setPreviewSize(200); } }; DefaultAction previewSmallAction = new DefaultAction("Small", null) { public void actionPerformed(ActionEvent e) { viewCtrl.setPreviewSize(100); } }; JToolBar tb = createToolbar(); cp.add(tb, BorderLayout.NORTH); // Create the menu bar & menus JMenuBar menuBar = new JMenuBar(); window.setJMenuBar(menuBar); // File menu JMenu fileMenu = new JMenu("File"); fileMenu.setMnemonic(KeyEvent.VK_F); menuBar.add(fileMenu); JMenuItem newWindowItem = new JMenuItem("New window", KeyEvent.VK_N); newWindowItem.setIcon(getIcon("window_new.png")); newWindowItem.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { BrowserWindow br = new BrowserWindow(getParentController(), null); // br.setVisible( true ); } }); fileMenu.add(newWindowItem); JMenuItem importItem = new JMenuItem(importAction); fileMenu.add(importItem); JMenuItem indexDirItem = new JMenuItem(indexDirAction); fileMenu.add(indexDirItem); fileMenu.add(new JMenuItem(viewCtrl.getActionAdapter("update_indexed_dirs"))); ExportSelectedAction exportAction = (ExportSelectedAction) viewPane.getExportSelectedAction(); JMenuItem exportItem = new JMenuItem(exportAction); exportAction.addStatusChangeListener(statusBar); fileMenu.add(exportItem); JMenu dbMenu = new JMenu("Database"); dbMenu.setMnemonic(KeyEvent.VK_B); dbMenu.setIcon(getIcon("empty_icon.png")); ExportMetadataAction exportMetadata = new ExportMetadataAction("Export as XML...", null, "Export whole database as XML file", KeyEvent.VK_E); dbMenu.add(new JMenuItem(exportMetadata)); ImportXMLAction importMetadata = new ImportXMLAction("Import XML data...", null, "Import data from other Photovault database as XML", KeyEvent.VK_I); importMetadata.addStatusChangeListener(statusBar); dbMenu.add(new JMenuItem(importMetadata)); fileMenu.add(dbMenu); JMenuItem exitItem = new JMenuItem("Exit", KeyEvent.VK_X); exitItem.setIcon(getIcon("exit.png")); exitItem.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { System.exit(0); } }); fileMenu.add(exitItem); JMenu viewMenu = new JMenu("View"); viewMenu.setMnemonic(KeyEvent.VK_V); menuBar.add(viewMenu); JMenuItem vertIconsItem = new JMenuItem(previewRightAction); viewMenu.add(vertIconsItem); JMenuItem horzIconsItem = new JMenuItem(previewTopAction); viewMenu.add(horzIconsItem); JMenuItem noPreviewItem = new JMenuItem(previewNoneAction); viewMenu.add(noPreviewItem); JMenuItem nextPhotoItem = new JMenuItem(viewPane.getSelectNextAction()); viewMenu.add(nextPhotoItem); JMenuItem prevPhotoItem = new JMenuItem(viewPane.getSelectPreviousAction()); viewMenu.add(prevPhotoItem); viewMenu.add(new JMenuItem(previewSmallAction)); viewMenu.add(new JMenuItem(previewLargeAction)); JMenu sortMenu = new JMenu("Sort by"); sortMenu.setMnemonic(KeyEvent.VK_S); sortMenu.setIcon(getIcon("empty_icon.png")); JMenuItem byDateItem = new JMenuItem(new SetPhotoOrderAction(viewCtrl, new ShootingDateComparator(), "Date", null, "Order photos by date", KeyEvent.VK_D)); sortMenu.add(byDateItem); JMenuItem byPlaceItem = new JMenuItem(new SetPhotoOrderAction(viewCtrl, new ShootingPlaceComparator(), "Place", null, "Order photos by shooting place", KeyEvent.VK_P)); sortMenu.add(byPlaceItem); JMenuItem byQualityItem = new JMenuItem(new SetPhotoOrderAction(viewCtrl, new QualityComparator(), "Quality", null, "Order photos by quality", KeyEvent.VK_Q)); sortMenu.add(byQualityItem); viewMenu.add(sortMenu); // Set default ordering by date byDateItem.getAction().actionPerformed(new ActionEvent(this, 0, "Setting default")); JMenu imageMenu = new JMenu("Image"); imageMenu.setMnemonic(KeyEvent.VK_I); menuBar.add(imageMenu); imageMenu.add(new JMenuItem(viewPane.getEditSelectionPropsAction())); imageMenu.add(new JMenuItem(viewPane.getShowSelectedPhotoAction())); imageMenu.add(new JMenuItem(viewCtrl.getActionAdapter("rotate_cw"))); imageMenu.add(new JMenuItem(viewCtrl.getActionAdapter("rotate_ccw"))); imageMenu.add(new JMenuItem(viewCtrl.getActionAdapter("rotate_180"))); imageMenu.add(new JMenuItem(previewPane.getCropAction())); imageMenu.add(new JMenuItem(viewPane.getEditSelectionColorsAction())); imageMenu.add(new JMenuItem(viewPane.getDeleteSelectedAction())); // Create the Quality submenu JMenu qualityMenu = new JMenu("Quality"); qualityMenu.setIcon(getIcon("empty_icon.png")); for (int n = 0; n < 6; n++) { Action qualityAction = viewCtrl.getActionAdapter("quality_" + n); JMenuItem qualityMenuItem = new JMenuItem(qualityAction); qualityMenu.add(qualityMenuItem); } imageMenu.add(qualityMenu); JMenu aboutMenu = new JMenu("About"); aboutMenu.setMnemonic(KeyEvent.VK_A); aboutMenu.add(new JMenuItem(new ShowAboutDlgAction("About Photovault...", null, "", null))); menuBar.add(Box.createHorizontalGlue()); menuBar.add(aboutMenu); window.pack(); window.setVisible(true); }
From source file:org.photovault.swingui.PhotoCollectionThumbView.java
void createUI() { photoTransferHandler = new PhotoCollectionTransferHandler(this); setTransferHandler(photoTransferHandler); setAutoscrolls(true);//from w ww .j a va2 s. c o m addMouseListener(this); addMouseMotionListener(this); // Create the popup menu popup = new JPopupMenu(); ImageIcon propsIcon = getIcon("view_properties.png"); editSelectionPropsAction = new EditSelectionPropsAction(this, "Properties...", propsIcon, "Edit properties of the selected photos", KeyEvent.VK_P); JMenuItem propsItem = new JMenuItem(editSelectionPropsAction); ImageIcon colorsIcon = getIcon("colors.png"); editSelectionColorsAction = new EditSelectionColorsAction(this, null, "Adjust colors...", colorsIcon, "Adjust colors of the selected photos", KeyEvent.VK_A); JMenuItem colorsItem = new JMenuItem(editSelectionColorsAction); ImageIcon showIcon = getIcon("show_new_window.png"); showSelectedPhotoAction = new ShowSelectedPhotoAction(this, "Show image", showIcon, "Show the selected phot(s)", KeyEvent.VK_S); JMenuItem showItem = new JMenuItem(showSelectedPhotoAction); showHistoryAction = new ShowPhotoHistoryAction(this, "Show history", null, "Show history of selected photo", KeyEvent.VK_H, null); resolveConflictsAction = new ResolvePhotoConflictsAction(this, "Resolve conflicts", null, "Resolve synchronization conflicts", KeyEvent.VK_R, null); JMenuItem rotateCW = new JMenuItem(ctrl.getActionAdapter("rotate_cw")); JMenuItem rotateCCW = new JMenuItem(ctrl.getActionAdapter("rotate_ccw")); JMenuItem rotate180deg = new JMenuItem(ctrl.getActionAdapter("rotate_180")); JMenuItem addToFolder = new JMenuItem("Add to folder..."); addToFolder.addActionListener(this); addToFolder.setActionCommand(PHOTO_ADD_TO_FOLDER_CMD); addToFolder.setIcon(getIcon("empty_icon.png")); ImageIcon exportIcon = getIcon("filesave.png"); exportSelectedAction = new ExportSelectedAction(this, "Export selected...", exportIcon, "Export the selected photos to from archive database to image files", KeyEvent.VK_E); JMenuItem exportSelected = new JMenuItem(exportSelectedAction); ImageIcon deleteSelectedIcon = getIcon("delete_image.png"); deleteSelectedAction = new DeletePhotoAction(this, "Delete", deleteSelectedIcon, "Delete selected photos including all of their instances", KeyEvent.VK_D); JMenuItem deleteSelected = new JMenuItem(deleteSelectedAction); starIcon = getIcon("star_normal_border.png"); rejectedIcon = getIcon("quality_unusable.png"); rawIcon = getIcon("raw_icon.png"); JMenuItem showHistory = new JMenuItem(showHistoryAction); JMenuItem resolveConflicts = new JMenuItem(resolveConflictsAction); AddTagAction addTagAction = new AddTagAction(ctrl, "Add tag...", null, "Add tag to image", KeyEvent.VK_T); JMenuItem addTag = new JMenuItem(addTagAction); popup.add(showItem); popup.add(propsItem); popup.add(colorsItem); popup.add(rotateCW); popup.add(rotateCCW); popup.add(rotate180deg); popup.add(addToFolder); popup.add(exportSelected); popup.add(deleteSelected); popup.add(showHistory); popup.add(resolveConflicts); popup.add(addTag); MouseListener popupListener = new PopupListener(); addMouseListener(popupListener); ImageIcon selectNextIcon = getIcon("next.png"); selectNextAction = new ChangeSelectionAction(this, ChangeSelectionAction.MOVE_FWD, "Next photo", selectNextIcon, "Move to next photo", KeyEvent.VK_N, KeyStroke.getKeyStroke(KeyEvent.VK_N, Toolkit.getDefaultToolkit().getMenuShortcutKeyMask())); ImageIcon selectPrevIcon = getIcon("previous.png"); selectPrevAction = new ChangeSelectionAction(this, ChangeSelectionAction.MOVE_BACK, "Previous photo", selectPrevIcon, "Move to previous photo", KeyEvent.VK_P, KeyStroke.getKeyStroke(KeyEvent.VK_P, Toolkit.getDefaultToolkit().getMenuShortcutKeyMask())); creatingThumbIcon = getIcon("creating_thumb.png"); }
From source file:org.rdv.DockingDataPanelManager.java
/** * Creates the root window and the views. *///www . j a v a2s . c om private void createRootWindow() { // The mixed view map makes it easy to mix static and dynamic views inside the same root window MixedViewHandler handler = new MixedViewHandler(viewMap_, new ViewSerializer() { public void writeView(View view, ObjectOutputStream out) throws IOException { out.writeInt(((DockingView) view).getId()); } public View readView(ObjectInputStream in) throws IOException { return viewMap_.getView(in.readInt()); } }); rootWindow_ = DockingUtil.createRootWindow(viewMap_, handler, true); // turn off tab window buttons rootWindow_.getRootWindowProperties().getTabWindowProperties().getCloseButtonProperties().setVisible(false);//getTabProperties().getFocusedButtonProperties().getCloseButtonProperties().setVisible(false); //rootWindow_.getRootWindowProperties().getTabWindowProperties().getCloseButtonProperties().setVisible(false); rootWindow_.getRootWindowProperties().setRecursiveTabsEnabled(true); rootWindow_.getRootWindowProperties().getFloatingWindowProperties().setUseFrame(true); // disable per-tab buttons like undock/minimize rootWindow_.getRootWindowProperties().getTabWindowProperties().getTabProperties() .getHighlightedButtonProperties().getUndockButtonProperties().setVisible(false); rootWindow_.getRootWindowProperties().getTabWindowProperties().getTabProperties() .getHighlightedButtonProperties().getDockButtonProperties().setVisible(false); rootWindow_.getRootWindowProperties().getTabWindowProperties().getTabProperties() .getHighlightedButtonProperties().getMinimizeButtonProperties().setVisible(false); final Icon closeIcon = rootWindow_.getRootWindowProperties().getTabWindowProperties() .getCloseButtonProperties().getIcon(); final Icon undockIcon = rootWindow_.getRootWindowProperties().getTabWindowProperties() .getUndockButtonProperties().getIcon(); final Icon dockIcon = rootWindow_.getRootWindowProperties().getTabWindowProperties() .getDockButtonProperties().getIcon(); rootWindow_.setPopupMenuFactory(new WindowPopupMenuFactory() { public JPopupMenu createPopupMenu(final DockingWindow window) { JPopupMenu menu = new JPopupMenu(); // Check that the window is a View if (window instanceof View) { final View v = (View) window; if (window instanceof DockingPanelView) { final DockingPanelView dpv = (DockingPanelView) window; JMenuItem renameItem = menu.add("Set Description"); renameItem.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { String s = (String) JOptionPane.showInputDialog(window, "Enter new description:\n", "Set Description", JOptionPane.PLAIN_MESSAGE, null, null, dpv.getDataPanel().getDescription()); if (s != null) { //v.setName(s); //v.getViewProperties().setTitle(s); dpv.getDataPanel().setDescription((s.isEmpty()) ? null : s); } } }); } JMenuItem closeItem = menu.add("Close"); closeItem.setIcon(closeIcon); closeItem.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { try { window.closeWithAbort(); } catch (OperationAbortedException e1) { //e1.printStackTrace(); } } }); if (v.isUndocked()) { JMenuItem dockItem = menu.add("Dock"); dockItem.setIcon(dockIcon); dockItem.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { try { window.dock(); } catch (Exception e1) { //e1.printStackTrace(); } } }); } else { JMenuItem undockItem = menu.add("Undock"); undockItem.setIcon(undockIcon); undockItem.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { try { window.undock(new Point(0, 0)); } catch (Exception e1) { //e1.printStackTrace(); } } }); } } return menu; } }); properties_.addSuperObject(titleBarStyleProperties); titleBarTheme_ = true; // Set gradient theme. The theme properties object is the super object of our properties object, which // means our property value settings will override the theme values properties_.addSuperObject(currentTheme_.getRootWindowProperties()); // Our properties object is the super object of the root window properties object, so all property values of the // theme and in our property object will be used by the root window rootWindow_.getRootWindowProperties().addSuperObject(properties_); // Enable the bottom window bar rootWindow_.getWindowBar(Direction.DOWN).setEnabled(true); // Add a listener which shows dialogs when a window is closing or closed. rootWindow_.addListener(new DockingWindowAdapter() { public void windowAdded(DockingWindow addedToWindow, DockingWindow addedWindow) { updateViews(addedWindow, true); // If the added window is a floating window, then update it if (addedWindow instanceof FloatingWindow) updateFloatingWindow((FloatingWindow) addedWindow); } public void windowRemoved(DockingWindow removedFromWindow, DockingWindow removedWindow) { //updateViews(removedWindow, false); } public void windowClosing(DockingWindow window) throws OperationAbortedException { // Confirm close operation if (JOptionPane.showConfirmDialog(UIUtilities.getMainFrame(), "Really close data panel '" + window + "'?") != JOptionPane.YES_OPTION) throw new OperationAbortedException("Data panel close was aborted!"); updateViews(window, false); } public void windowDocking(DockingWindow window) throws OperationAbortedException { // Confirm dock operation if (JOptionPane.showConfirmDialog(UIUtilities.getMainFrame(), "Really dock data panel '" + window + "'?") != JOptionPane.YES_OPTION) throw new OperationAbortedException("Data panel dock was aborted!"); } public void windowUndocking(DockingWindow window) throws OperationAbortedException { // Confirm undock operation if (JOptionPane.showConfirmDialog(UIUtilities.getMainFrame(), "Really undock data panel '" + window + "'?") != JOptionPane.YES_OPTION) throw new OperationAbortedException("Data panel undock was aborted!"); } }); // Add a mouse button listener that closes a window when it's clicked with the middle mouse button. rootWindow_.addTabMouseButtonListener(DockingWindowActionMouseButtonListener.MIDDLE_BUTTON_CLOSE_LISTENER); mainPanel_.add(rootWindow_); }