List of usage examples for javax.swing JFileChooser setApproveButtonText
@BeanProperty(preferred = true, description = "The text that goes in the ApproveButton.") public void setApproveButtonText(String approveButtonText)
ApproveButton
in the FileChooserUI
. From source file:com.igormaznitsa.sciareto.ui.MainFrame.java
private void menuNewProjectActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_menuNewProjectActionPerformed final JFileChooser folder = new JFileChooser(); folder.setFileSelectionMode(JFileChooser.DIRECTORIES_ONLY); folder.setDialogTitle("Create project folder"); folder.setApproveButtonText("Create"); folder.setFileSelectionMode(JFileChooser.DIRECTORIES_ONLY); if (folder.showOpenDialog(Main.getApplicationFrame()) == JFileChooser.APPROVE_OPTION) { final File file = folder.getSelectedFile(); if (file.exists()) { DialogProviderManager.getInstance().getDialogProvider() .msgError("File '" + file.getName() + "' already exists!"); } else if (file.mkdirs()) { if (PreferencesManager.getInstance().getPreferences() .getBoolean(PreferencesPanel.PREFERENCE_KEY_KNOWLEDGEFOLDER_ALLOWED, true)) { final File knowledgeFolder = new File(file, ".projectKnowledge"); knowledgeFolder.mkdirs(); }/* www . j a va 2 s . com*/ if (openProject(file, true)) { this.focusInTree(file); } } else { LOGGER.error("Can't create folder : " + file); DialogProviderManager.getInstance().getDialogProvider().msgError("Can't create folder: " + file); } } }
From source file:com.igormaznitsa.sciareto.ui.MainFrame.java
@Nullable @Override/* w w w. ja v a 2 s . c o m*/ public File createMindMapFile(@Nullable final File folder) { final JFileChooser chooser = new JFileChooser(folder); chooser.setDialogTitle("Create new Mind Map"); chooser.setFileFilter(MMDEditor.MMD_FILE_FILTER); chooser.setMultiSelectionEnabled(false); chooser.setApproveButtonText("Create"); File result = null; if (chooser.showSaveDialog(Main.getApplicationFrame()) == JFileChooser.APPROVE_OPTION) { File file = chooser.getSelectedFile(); if (!file.getName().endsWith(".mmd")) { file = new File(file.getAbsolutePath() + ".mmd"); } if (file.exists()) { DialogProviderManager.getInstance().getDialogProvider() .msgError("File '" + file + "' already exists!"); } else { try { final MindMap mindMap = new MindMap(null, true); final String text = mindMap.write(new StringWriter()).toString(); SystemUtils.saveUTFText(file, text); result = file; } catch (IOException ex) { DialogProviderManager.getInstance().getDialogProvider() .msgError("Can't save mind map into file '" + file.getName() + "'"); } } } return result; }
From source file:lejos.pc.charting.LogChartFrame.java
private void selectFolderButton_actionPerformed(ActionEvent e) { this.setCursor(Cursor.getPredefinedCursor(Cursor.WAIT_CURSOR)); JFileChooser jfc = new JFileChooser(new File(FQPathTextArea.getText(), "")); jfc.setFileSelectionMode(JFileChooser.DIRECTORIES_ONLY); jfc.setApproveButtonText("Select"); jfc.setDialogTitle("Select Directory"); jfc.setDialogType(JFileChooser.OPEN_DIALOG); this.setCursor(Cursor.getPredefinedCursor(Cursor.DEFAULT_CURSOR)); int returnVal = jfc.showOpenDialog(this); if (returnVal == JFileChooser.APPROVE_OPTION) { FQPathTextArea.setText(getCanonicalName(jfc.getSelectedFile())); jfc.setCurrentDirectory(jfc.getSelectedFile()); System.out.println("folder set to \"" + getCanonicalName(jfc.getSelectedFile()) + "\""); }// w w w. jav a2s . com }
From source file:edu.synth.SynthHelper.java
public String openDialogFileChooser(String path, boolean dirOnly, String name, String button, String filterType) {// ww w .j a va2s. c om JFileChooser fileOpen = new JFileChooser(); if (!path.isEmpty()) fileOpen.setCurrentDirectory(new File(path)); else fileOpen.setCurrentDirectory(new File(".")); if (dirOnly) fileOpen.setFileSelectionMode(JFileChooser.DIRECTORIES_ONLY); else { fileOpen.setFileSelectionMode(JFileChooser.FILES_AND_DIRECTORIES); switch (filterType) { case "abn": FileFilter filter = new FileNameExtensionFilter("*.abn - Abundances file", "abn"); fileOpen.setFileFilter(filter); break; case "model": filter = new FileNameExtensionFilter("*.atl - Kurucz's format model file", "atl"); fileOpen.setFileFilter(filter); break; case "lns": filter = new FileNameExtensionFilter("*.lns - Lines file", "lns"); fileOpen.setFileFilter(filter); break; } } fileOpen.setDialogTitle(name); fileOpen.setApproveButtonText(button); int returnVal = fileOpen.showOpenDialog(fileOpen); if (returnVal == JFileChooser.APPROVE_OPTION) { File selectedPath = fileOpen.getSelectedFile(); if (selectedPath != null) return selectedPath.getAbsolutePath(); } return ""; }
From source file:ElectionGUI.java
private void saveElectionBtnActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_saveElectionBtnActionPerformed JFileChooser fileChooser = new JFileChooser(); fileChooser.setApproveButtonText("Save"); fileChooser.setCurrentDirectory(folder); int result = fileChooser.showOpenDialog(this); if (result == JFileChooser.APPROVE_OPTION) { folder = fileChooser.getCurrentDirectory(); File selectedFile = fileChooser.getSelectedFile(); Store2dElection store = new Store2dElection(this, selectedFile); store.writeToFile();/*from w w w . ja v a2s . c o m*/ systemTxt.append("-Election saved successfully." + eol); saved = true; } else if (result == JFileChooser.CANCEL_OPTION) { systemTxt.append("-Saving cancelled" + eol); } }
From source file:com.emental.mindraider.ui.frames.MindRaiderMainWindow.java
private void exportActiveOutlineToAtom() { if (MindRaider.profile.getActiveOutline() == null) { JOptionPane.showMessageDialog(MindRaiderMainWindow.this, Messages.getString("MindRaiderJFrame.exportNotebookWarning"), Messages.getString("MindRaiderJFrame.exportError"), JOptionPane.ERROR_MESSAGE); return;//from w w w.j a v a2 s . co m } JFileChooser fc = new JFileChooser(); fc.setApproveButtonText(Messages.getString("MindRaiderJFrame.export")); fc.setControlButtonsAreShown(true); fc.setDialogTitle(Messages.getString("MindRaiderJFrame.chooseExportDirectory")); fc.setFileSelectionMode(JFileChooser.DIRECTORIES_ONLY); // prepare directory String exportDirectory = MindRaider.profile.getHomeDirectory() + File.separator + "export" + File.separator + "sharing"; Utils.createDirectory(exportDirectory); fc.setCurrentDirectory(new File(exportDirectory)); int returnVal = fc.showOpenDialog(MindRaiderMainWindow.this); if (returnVal == JFileChooser.APPROVE_OPTION) { String dstDirectory = fc.getSelectedFile().getAbsolutePath(); Utils.createDirectory(dstDirectory); final String dstFileName = dstDirectory + File.separator + "MindRaider-" + MindRaider.outlineCustodian.getActiveNotebookNcName() + "-" + Utils.getCurrentDataTimeAsPrettyString() + ".atom.xml"; logger.debug(Messages.getString("MindRaiderJFrame.exportingToFile", dstFileName)); MindRaider.outlineCustodian.exportOutline(OutlineCustodian.FORMAT_ATOM, dstFileName); } else { logger.debug(Messages.getString("MindRaiderJFrame.exportCommandCancelledByUser")); } }
From source file:org.jets3t.apps.uploader.Uploader.java
/** * Handles GUI actions.//from www.j a v a 2 s .co m */ public void actionPerformed(ActionEvent actionEvent) { if ("Next".equals(actionEvent.getActionCommand())) { wizardStepForward(); } else if ("Back".equals(actionEvent.getActionCommand())) { wizardStepBackward(); } else if ("ChooseFile".equals(actionEvent.getActionCommand())) { JFileChooser fileChooser = new JFileChooser(); if (validFileExtensions.size() > 0) { UploaderFileExtensionFilter filter = new UploaderFileExtensionFilter("Allowed files", validFileExtensions); fileChooser.setFileFilter(filter); } fileChooser.setMultiSelectionEnabled(fileMaxCount > 1); fileChooser.setDialogTitle("Choose file" + (fileMaxCount > 1 ? "s" : "") + " to upload"); fileChooser.setFileSelectionMode(JFileChooser.FILES_ONLY); fileChooser.setApproveButtonText("Choose file" + (fileMaxCount > 1 ? "s" : "")); int returnVal = fileChooser.showOpenDialog(ownerFrame); if (returnVal != JFileChooser.APPROVE_OPTION) { return; } List fileList = new ArrayList(); if (fileChooser.getSelectedFiles().length > 0) { fileList.addAll(Arrays.asList(fileChooser.getSelectedFiles())); } else { fileList.add(fileChooser.getSelectedFile()); } if (checkProposedUploadFiles(fileList)) { wizardStepForward(); } } else if ("CancelUpload".equals(actionEvent.getActionCommand())) { if (uploadCancelEventTrigger != null) { uploadCancelEventTrigger.cancelTask(this); progressBar.setValue(0); } else { log.warn("Ignoring attempt to cancel file upload when cancel trigger is not available"); } } else { log.warn("Unrecognised action command, ignoring: " + actionEvent.getActionCommand()); } }
From source file:com.emental.mindraider.ui.frames.MindRaiderMainWindow.java
/** * Build main menu./*from w ww . jav a2 s. com*/ * * @param spiders */ private void buildMenu(final SpidersGraph spiders) { JMenuBar menuBar; JMenu menu, submenu; JMenuItem menuItem, subMenuItem; JRadioButtonMenuItem rbMenuItem; // create the menu bar menuBar = new JMenuBar(); setJMenuBar(menuBar); // - main menu ------------------------------------------------------- menu = new JMenu(MindRaiderConstants.MR_TITLE); menu.setMnemonic(KeyEvent.VK_M); menuItem = new JMenuItem(Messages.getString("MindRaiderJFrame.setActiveNotebookAsHome")); menuItem.setMnemonic(KeyEvent.VK_H); menuItem.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { MindRaider.profile.setHomeNotebook(); } }); menu.add(menuItem); menu.add(menuItem); menuItem = new JMenuItem(Messages.getString("MindRaiderJFrame.preferences")); menuItem.setMnemonic(KeyEvent.VK_P); menuItem.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { new PreferencesJDialog(); } }); menu.add(menuItem); menu.addSeparator(); menuItem = new JMenuItem(Messages.getString("MindRaiderJFrame.exit"), KeyEvent.VK_X); menuItem.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { exitMindRaider(); } }); menu.add(menuItem); menuBar.add(menu); // - Find ---------------------------------------------------------- menu = new JMenu(Messages.getString("MindRaiderJFrame.search")); menu.setMnemonic(KeyEvent.VK_F); menuItem = new JMenuItem(Messages.getString("MindRaiderJFrame.searchNotebooks")); menuItem.setMnemonic(KeyEvent.VK_N); menuItem.setAccelerator( KeyStroke.getKeyStroke(KeyEvent.VK_O, ActionEvent.CTRL_MASK | ActionEvent.SHIFT_MASK)); menuItem.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { new OpenOutlineJDialog(); } }); menu.add(menuItem); menuItem = new JMenuItem(Messages.getString("MindRaiderJFrame.searchFulltext")); menuItem.setMnemonic(KeyEvent.VK_F); menuItem.setAccelerator( KeyStroke.getKeyStroke(KeyEvent.VK_F, ActionEvent.CTRL_MASK | ActionEvent.SHIFT_MASK)); menuItem.setEnabled(true); menuItem.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { new FtsJDialog(); } }); menu.add(menuItem); menuItem = new JMenuItem(Messages.getString("MindRaiderJFrame.searchConceptsInNotebook")); menuItem.setMnemonic(KeyEvent.VK_C); menuItem.setAccelerator( KeyStroke.getKeyStroke(KeyEvent.VK_N, ActionEvent.CTRL_MASK | ActionEvent.SHIFT_MASK)); menuItem.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { if (MindRaider.profile.getActiveOutlineUri() != null) { new OpenNoteJDialog(); } } }); menu.add(menuItem); // search by tag menuItem = new JMenuItem(Messages.getString("MindRaiderJFrame.searchConceptsByTag")); menuItem.setEnabled(true); menuItem.setMnemonic(KeyEvent.VK_T); menuItem.setAccelerator( KeyStroke.getKeyStroke(KeyEvent.VK_T, ActionEvent.CTRL_MASK | ActionEvent.SHIFT_MASK)); menuItem.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { new OpenConceptByTagJDialog(); } }); menu.add(menuItem); menu.addSeparator(); menuItem = new JMenuItem(Messages.getString("MindRaiderMainWindow.previousNote")); menuItem.setEnabled(true); menuItem.setMnemonic(KeyEvent.VK_P); menuItem.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_LEFT, ActionEvent.ALT_MASK)); menuItem.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { MindRaider.recentConcepts.moveOneNoteBack(); } }); menu.add(menuItem); // global RDF search // menuItem = new JMenuItem(Messages.getString("MindRaiderJFrame.searchRdql")); // menuItem.setEnabled(false); // menuItem.setMnemonic(KeyEvent.VK_R); // menuItem.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_R, // ActionEvent.CTRL_MASK | ActionEvent.SHIFT_MASK)); // menuItem.addActionListener(new ActionListener() { // // public void actionPerformed(ActionEvent e) { // // TODO rdql to be implemented // } // }); // menu.add(menuItem); menuBar.add(menu); // - view ------------------------------------------------------------ menu = new JMenu(Messages.getString("MindRaiderJFrame.view")); menu.setMnemonic(KeyEvent.VK_V); // TODO localize L&F menu ButtonGroup lfGroup = new ButtonGroup(); submenu = new JMenu(Messages.getString("MindRaiderJFrame.lookAndFeel")); logger.debug("Look and feel is: " + MindRaider.profile.getLookAndFeel()); // {{debug}} submenu.setMnemonic(KeyEvent.VK_L); subMenuItem = new JRadioButtonMenuItem(Messages.getString("MindRaiderJFrame.lookAndFeelNative")); if (MindRaider.LF_NATIVE.equals(MindRaider.profile.getLookAndFeel())) { subMenuItem.setSelected(true); } subMenuItem.setEnabled(true); subMenuItem.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { setLookAndFeel(MindRaider.LF_NATIVE); } }); submenu.add(subMenuItem); lfGroup.add(subMenuItem); subMenuItem = new JRadioButtonMenuItem(Messages.getString("MindRaiderJFrame.lookAndFeelJava")); if (MindRaider.LF_JAVA_DEFAULT.equals(MindRaider.profile.getLookAndFeel())) { subMenuItem.setSelected(true); } subMenuItem.setEnabled(true); subMenuItem.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { setLookAndFeel(MindRaider.LF_JAVA_DEFAULT); } }); submenu.add(subMenuItem); lfGroup.add(subMenuItem); menu.add(submenu); menu.addSeparator(); menuItem = new JMenuItem(Messages.getString("MindRaiderJFrame.leftSideBar")); menuItem.setMnemonic(KeyEvent.VK_L); menuItem.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { if (leftSidebarSplitPane.getDividerLocation() == 1) { leftSidebarSplitPane.resetToPreferredSizes(); } else { closeLeftSidebar(); } } }); menu.add(menuItem); menuItem = new JMenuItem(Messages.getString("MindRaiderJFrame.rightSideBar")); menuItem.setMnemonic(KeyEvent.VK_R); menuItem.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { OutlineJPanel.getInstance().toggleRightSidebar(); } }); menu.add(menuItem); // TODO tips to be implemented // JCheckBoxMenuItem helpCheckbox=new JCheckBoxMenuItem("Tips",true); // menu.add(helpCheckbox); // TODO localize menuItem = new JMenuItem(Messages.getString("MindRaiderJFrame.toolbar")); menuItem.setMnemonic(KeyEvent.VK_T); menuItem.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { MindRaider.masterToolBar.toggleVisibility(); } }); menu.add(menuItem); menuItem = new JMenuItem(Messages.getString("MindRaiderJFrame.rdfNavigatorDashboard")); menuItem.setMnemonic(KeyEvent.VK_D); menuItem.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { MindRaider.spidersGraph.getGlPanel().toggleControlPanel(); } }); menu.add(menuItem); JCheckBoxMenuItem checkboxMenuItem; ButtonGroup colorSchemeGroup; // if (!MindRaider.OUTLINER_PERSPECTIVE.equals(MindRaider.profile // .getUiPerspective())) { menu.addSeparator(); // Facets submenu = new JMenu(Messages.getString("MindRaiderJFrame.facet")); submenu.setMnemonic(KeyEvent.VK_F); colorSchemeGroup = new ButtonGroup(); String[] facetLabels = FacetCustodian.getInstance().getFacetLabels(); if (!ArrayUtils.isEmpty(facetLabels)) { for (String facetLabel : facetLabels) { rbMenuItem = new JRadioButtonMenuItem(facetLabel); rbMenuItem.addActionListener(new FacetActionListener(facetLabel)); colorSchemeGroup.add(rbMenuItem); submenu.add(rbMenuItem); if (BriefFacet.LABEL.equals(facetLabel)) { rbMenuItem.setSelected(true); } } } menu.add(submenu); checkboxMenuItem = new JCheckBoxMenuItem(Messages.getString("MindRaiderJFrame.graphLabelAsUri")); checkboxMenuItem.setMnemonic(KeyEvent.VK_G); checkboxMenuItem.setState(MindRaider.spidersGraph.isUriLabels()); checkboxMenuItem.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { if (e.getSource() instanceof JCheckBoxMenuItem) { JCheckBoxMenuItem j = (JCheckBoxMenuItem) e.getSource(); MindRaider.spidersGraph.setUriLabels(j.getState()); MindRaider.spidersGraph.renderModel(); MindRaider.profile.setGraphShowLabelsAsUris(j.getState()); MindRaider.profile.save(); } } }); menu.add(checkboxMenuItem); checkboxMenuItem = new JCheckBoxMenuItem(Messages.getString("MindRaiderJFrame.predicateNodes")); checkboxMenuItem.setMnemonic(KeyEvent.VK_P); checkboxMenuItem.setState(!MindRaider.spidersGraph.getHidePredicates()); checkboxMenuItem.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { if (e.getSource() instanceof JCheckBoxMenuItem) { JCheckBoxMenuItem j = (JCheckBoxMenuItem) e.getSource(); MindRaider.spidersGraph.hidePredicates(!j.getState()); MindRaider.spidersGraph.renderModel(); MindRaider.profile.setGraphHidePredicates(!j.getState()); MindRaider.profile.save(); } } }); menu.add(checkboxMenuItem); checkboxMenuItem = new JCheckBoxMenuItem(Messages.getString("MindRaiderJFrame.multilineLabels")); checkboxMenuItem.setMnemonic(KeyEvent.VK_M); checkboxMenuItem.setState(MindRaider.spidersGraph.isMultilineNodes()); checkboxMenuItem.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { if (e.getSource() instanceof JCheckBoxMenuItem) { JCheckBoxMenuItem j = (JCheckBoxMenuItem) e.getSource(); MindRaider.spidersGraph.setMultilineNodes(j.getState()); MindRaider.spidersGraph.renderModel(); MindRaider.profile.setGraphMultilineLabels(j.getState()); MindRaider.profile.save(); } } }); menu.add(checkboxMenuItem); // } menu.addSeparator(); // Antialias checkboxMenuItem = new JCheckBoxMenuItem(Messages.getString("MindRaiderJFrame.antiAliased"), true); checkboxMenuItem.setMnemonic(KeyEvent.VK_A); checkboxMenuItem.setState(SpidersGraph.antialiased); checkboxMenuItem.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { if (e.getSource() instanceof JCheckBoxMenuItem) { JCheckBoxMenuItem j = (JCheckBoxMenuItem) e.getSource(); SpidersGraph.antialiased = j.getState(); MindRaider.spidersGraph.renderModel(); } } }); menu.add(checkboxMenuItem); // Enable hyperbolic checkboxMenuItem = new JCheckBoxMenuItem(Messages.getString("MindRaiderJFrame.hyperbolic"), true); checkboxMenuItem.setMnemonic(KeyEvent.VK_H); checkboxMenuItem.setState(SpidersGraph.hyperbolic); checkboxMenuItem.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { if (e.getSource() instanceof JCheckBoxMenuItem) { JCheckBoxMenuItem j = (JCheckBoxMenuItem) e.getSource(); SpidersGraph.hyperbolic = j.getState(); MindRaider.spidersGraph.renderModel(); } } }); menu.add(checkboxMenuItem); // Show FPS checkboxMenuItem = new JCheckBoxMenuItem(Messages.getString("MindRaiderJFrame.fps"), true); checkboxMenuItem.setMnemonic(KeyEvent.VK_F); checkboxMenuItem.setState(SpidersGraph.fps); checkboxMenuItem.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { if (e.getSource() instanceof JCheckBoxMenuItem) { JCheckBoxMenuItem j = (JCheckBoxMenuItem) e.getSource(); SpidersGraph.fps = j.getState(); MindRaider.spidersGraph.renderModel(); } } }); menu.add(checkboxMenuItem); // Graph color scheme submenu = new JMenu(Messages.getString("MindRaiderJFrame.colorScheme")); submenu.setMnemonic(KeyEvent.VK_C); String[] allProfilesUris = MindRaider.spidersColorProfileRegistry.getAllProfilesUris(); colorSchemeGroup = new ButtonGroup(); for (int i = 0; i < allProfilesUris.length; i++) { rbMenuItem = new UriJRadioButtonMenuItem( MindRaider.spidersColorProfileRegistry.getColorProfileByUri(allProfilesUris[i]).getLabel(), allProfilesUris[i]); rbMenuItem.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { if (e.getSource() instanceof UriJRadioButtonMenuItem) { MindRaider.spidersColorProfileRegistry .setCurrentProfile(((UriJRadioButtonMenuItem) e.getSource()).uri); MindRaider.spidersGraph .setRenderingProfile(MindRaider.spidersColorProfileRegistry.getCurrentProfile()); MindRaider.spidersGraph.renderModel(); } } }); colorSchemeGroup.add(rbMenuItem); submenu.add(rbMenuItem); } menu.add(submenu); // Annotation color scheme submenu = new JMenu(Messages.getString("MindRaiderJFrame.colorSchemeAnnotation")); submenu.setMnemonic(KeyEvent.VK_A); allProfilesUris = MindRaider.annotationColorProfileRegistry.getAllProfilesUris(); colorSchemeGroup = new ButtonGroup(); for (int i = 0; i < allProfilesUris.length; i++) { rbMenuItem = new UriJRadioButtonMenuItem( MindRaider.annotationColorProfileRegistry.getColorProfileByUri(allProfilesUris[i]).getLabel(), allProfilesUris[i]); rbMenuItem.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { if (e.getSource() instanceof UriJRadioButtonMenuItem) { MindRaider.annotationColorProfileRegistry .setCurrentProfile(((UriJRadioButtonMenuItem) e.getSource()).uri); OutlineJPanel.getInstance().conceptJPanel.refresh(); } } }); colorSchemeGroup.add(rbMenuItem); submenu.add(rbMenuItem); } menu.add(submenu); menu.addSeparator(); checkboxMenuItem = new JCheckBoxMenuItem(Messages.getString("MindRaiderJFrame.fullScreen")); checkboxMenuItem.setMnemonic(KeyEvent.VK_U); checkboxMenuItem.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_F11, 0)); checkboxMenuItem.setState(false); checkboxMenuItem.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { if (e.getSource() instanceof JCheckBoxMenuItem) { JCheckBoxMenuItem j = (JCheckBoxMenuItem) e.getSource(); if (j.getState()) { Gfx.toggleFullScreen(MindRaiderMainWindow.this); } else { Gfx.toggleFullScreen(null); } } } }); menu.add(checkboxMenuItem); menuBar.add(menu); // - outline // ---------------------------------------------------------------------- menu = new JMenu(Messages.getString("MindRaiderJFrame.notebook")); menu.setMnemonic(KeyEvent.VK_N); menuItem = new JMenuItem(Messages.getString("MindRaiderJFrame.newNotebook")); menuItem.setMnemonic(KeyEvent.VK_N); menuItem.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_O, ActionEvent.CTRL_MASK)); menuItem.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { // TODO clear should be optional - only if creation finished // MindRider.spidersGraph.clear(); new NewOutlineJDialog(); } }); menu.add(menuItem); menuItem = new JMenuItem(Messages.getString("MindRaiderJFrame.open")); menuItem.setMnemonic(KeyEvent.VK_O); menuItem.setAccelerator( KeyStroke.getKeyStroke(KeyEvent.VK_O, ActionEvent.CTRL_MASK | ActionEvent.SHIFT_MASK)); menuItem.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { new OpenOutlineJDialog(); } }); menu.add(menuItem); menuItem = new JMenuItem(Messages.getString("MindRaiderJFrame.close")); menuItem.setMnemonic(KeyEvent.VK_C); menuItem.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { MindRaider.outlineCustodian.close(); OutlineJPanel.getInstance().refresh(); MindRaider.spidersGraph.renderModel(); } }); menu.add(menuItem); menuItem = new JMenuItem(Messages.getString("MindRaiderJFrame.discard")); menuItem.setMnemonic(KeyEvent.VK_D); menuItem.setEnabled(false); // TODO discard method must be implemented menuItem.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { int result = JOptionPane.showConfirmDialog(MindRaiderMainWindow.this, Messages.getString( "MindRaiderJFrame.confirmDiscardNotebook", MindRaider.profile.getActiveOutline())); if (result == JOptionPane.YES_OPTION) { if (MindRaider.profile.getActiveOutlineUri() != null) { try { MindRaider.labelCustodian .discardOutline(MindRaider.profile.getActiveOutlineUri().toString()); MindRaider.outlineCustodian.close(); } catch (Exception e1) { logger.error(Messages.getString("MindRaiderJFrame.unableToDiscardNotebook"), e1); } } } } }); menu.add(menuItem); menu.addSeparator(); // export submenu = new JMenu(Messages.getString("MindRaiderJFrame.export")); submenu.setMnemonic(KeyEvent.VK_E); // Atom subMenuItem = new JMenuItem("Atom"); subMenuItem.setEnabled(true); subMenuItem.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { exportActiveOutlineToAtom(); } }); submenu.add(subMenuItem); // OPML subMenuItem = new JMenuItem(Messages.getString("MindRaiderJFrame.opml")); subMenuItem.setEnabled(true); subMenuItem.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { if (MindRaider.profile.getActiveOutline() == null) { JOptionPane.showMessageDialog(MindRaiderMainWindow.this, Messages.getString("MindRaiderJFrame.exportNotebookWarning"), Messages.getString("MindRaiderJFrame.exportError"), JOptionPane.ERROR_MESSAGE); return; } JFileChooser fc = new JFileChooser(); fc.setApproveButtonText(Messages.getString("MindRaiderJFrame.export")); fc.setControlButtonsAreShown(true); fc.setDialogTitle(Messages.getString("MindRaiderJFrame.chooseExportDirectory")); fc.setFileSelectionMode(JFileChooser.DIRECTORIES_ONLY); // prepare directory String exportDirectory = MindRaider.profile.getHomeDirectory() + File.separator + "export" + File.separator + "opml"; Utils.createDirectory(exportDirectory); fc.setCurrentDirectory(new File(exportDirectory)); int returnVal = fc.showOpenDialog(MindRaiderMainWindow.this); if (returnVal == JFileChooser.APPROVE_OPTION) { String dstFileName = fc.getSelectedFile().getAbsolutePath() + File.separator + "OPML-EXPORT-" + MindRaider.outlineCustodian.getActiveNotebookNcName() + ".xml"; logger.debug(Messages.getString("MindRaiderJFrame.exportingToFile", dstFileName)); MindRaider.outlineCustodian.exportOutline(OutlineCustodian.FORMAT_OPML, dstFileName); Launcher.launchViaStart(dstFileName); } else { logger.debug(Messages.getString("MindRaiderJFrame.exportCommandCancelledByUser")); } } }); submenu.add(subMenuItem); // TWiki subMenuItem = new JMenuItem("TWiki"); subMenuItem.setEnabled(true); subMenuItem.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { if (MindRaider.profile.getActiveOutline() == null) { JOptionPane.showMessageDialog(MindRaiderMainWindow.this, Messages.getString("MindRaiderJFrame.exportNotebookWarning"), Messages.getString("MindRaiderJFrame.exportError"), JOptionPane.ERROR_MESSAGE); return; } JFileChooser fc = new JFileChooser(); fc.setApproveButtonText(Messages.getString("MindRaiderJFrame.export")); fc.setControlButtonsAreShown(true); fc.setDialogTitle(Messages.getString("MindRaiderJFrame.chooseExportDirectory")); fc.setFileSelectionMode(JFileChooser.DIRECTORIES_ONLY); // prepare directory String exportDirectory = MindRaider.profile.getHomeDirectory() + File.separator + "export" + File.separator + "twiki"; Utils.createDirectory(exportDirectory); fc.setCurrentDirectory(new File(exportDirectory)); int returnVal = fc.showOpenDialog(MindRaiderMainWindow.this); if (returnVal == JFileChooser.APPROVE_OPTION) { final String dstFileName = fc.getSelectedFile().getAbsolutePath() + File.separator + "TWIKI-EXPORT-" + MindRaider.outlineCustodian.getActiveNotebookNcName() + ".txt"; logger.debug(Messages.getString("MindRaiderJFrame.exportingToFile", dstFileName)); MindRaider.outlineCustodian.exportOutline(OutlineCustodian.FORMAT_TWIKI, dstFileName); } else { logger.debug(Messages.getString("MindRaiderJFrame.exportCommandCancelledByUser")); } } }); submenu.add(subMenuItem); menu.add(submenu); // import submenu = new JMenu(Messages.getString("MindRaiderJFrame.import")); submenu.setMnemonic(KeyEvent.VK_I); subMenuItem = new JMenuItem("Atom"); subMenuItem.setEnabled(true); subMenuItem.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { importFromAtom(); } }); submenu.add(subMenuItem); // TWiki subMenuItem = new JMenuItem("TWiki"); subMenuItem.setEnabled(true); subMenuItem.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { // choose file to be transformed OutlineJPanel.getInstance().clear(); MindRaider.profile.setActiveOutlineUri(null); JFileChooser fc = new JFileChooser(); int returnVal = fc.showOpenDialog(MindRaiderMainWindow.this); if (returnVal == JFileChooser.APPROVE_OPTION) { final File file = fc.getSelectedFile(); MindRaider.profile.deleteActiveModel(); logger.debug( Messages.getString("MindRaiderJFrame.importingTWikiTopic", file.getAbsolutePath())); // perform it async final SwingWorker worker = new SwingWorker() { public Object construct() { ProgressDialogJFrame progressDialogJFrame = new ProgressDialogJFrame( Messages.getString("MindRaiderJFrame.twikiImport"), Messages.getString("MindRaiderJFrame.processingTopicTWiki")); try { MindRaider.outlineCustodian.importNotebook(OutlineCustodian.FORMAT_TWIKI, (file != null ? file.getAbsolutePath() : null), progressDialogJFrame); } finally { if (progressDialogJFrame != null) { progressDialogJFrame.dispose(); } } return null; } }; worker.start(); } else { logger.debug(Messages.getString("MindRaiderJFrame.openCommandCancelledByUser")); } } }); submenu.add(subMenuItem); menu.add(submenu); menuBar.add(menu); // - note // ---------------------------------------------------------------------- menu = new JMenu(Messages.getString("MindRaiderJFrame.concept")); menu.setMnemonic(KeyEvent.VK_C); menuItem = new JMenuItem(Messages.getString("MindRaiderJFrame.new")); menuItem.setMnemonic(KeyEvent.VK_N); menuItem.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_N, ActionEvent.CTRL_MASK)); menuItem.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { OutlineJPanel.getInstance().newConcept(); } }); menu.add(menuItem); menuItem = new JMenuItem(Messages.getString("MindRaiderJFrame.open")); menuItem.setMnemonic(KeyEvent.VK_O); menuItem.setAccelerator( KeyStroke.getKeyStroke(KeyEvent.VK_N, ActionEvent.CTRL_MASK | ActionEvent.SHIFT_MASK)); menuItem.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { if (MindRaider.profile.getActiveOutlineUri() != null) { new OpenNoteJDialog(); } } }); menu.add(menuItem); menuItem = new JMenuItem(Messages.getString("MindRaiderJFrame.discard")); // do not accelerate this command with DEL - it's already handled // elsewhere menuItem.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_DELETE, 0)); menuItem.setMnemonic(KeyEvent.VK_D); menuItem.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { OutlineJPanel.getInstance().conceptDiscard(); } }); menu.add(menuItem); menu.addSeparator(); menuItem = new JMenuItem(Messages.getString("MindRaiderJFrame.up")); menuItem.setMnemonic(KeyEvent.VK_U); menuItem.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_UP, ActionEvent.CTRL_MASK)); menuItem.setEnabled(true); menuItem.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { OutlineJPanel.getInstance().conceptUp(); } }); menu.add(menuItem); menuItem = new JMenuItem(Messages.getString("MindRaiderJFrame.promote")); menuItem.setMnemonic(KeyEvent.VK_P); menuItem.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_LEFT, ActionEvent.CTRL_MASK)); menuItem.setEnabled(true); menuItem.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { OutlineJPanel.getInstance().conceptPromote(); } }); menu.add(menuItem); menuItem = new JMenuItem(Messages.getString("MindRaiderJFrame.demote")); menuItem.setMnemonic(KeyEvent.VK_D); menuItem.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_RIGHT, ActionEvent.CTRL_MASK)); menuItem.setEnabled(true); menuItem.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { OutlineJPanel.getInstance().conceptDemote(); } }); menu.add(menuItem); menuItem = new JMenuItem(Messages.getString("MindRaiderJFrame.down")); menuItem.setMnemonic(KeyEvent.VK_O); menuItem.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_DOWN, ActionEvent.CTRL_MASK)); menuItem.setEnabled(true); menuItem.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { OutlineJPanel.getInstance().conceptDown(); } }); menu.add(menuItem); menuBar.add(menu); // - Tools ----------------------------------------------------------- menu = new JMenu(Messages.getString("MindRaiderJFrame.tools")); menu.setMnemonic(KeyEvent.VK_T); menuItem = new JMenuItem(Messages.getString("MindRaiderMainWindow.checkAndFix")); menuItem.setMnemonic(KeyEvent.VK_F); menuItem.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { Checker.checkAndFixRepositoryAsync(); } }); menu.add(menuItem); menuItem = new JMenuItem(Messages.getString("MindRaiderJFrame.backupRepository")); menuItem.setMnemonic(KeyEvent.VK_B); menuItem.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { Installer.backupRepositoryAsync(); } }); menu.add(menuItem); menuItem = new JMenuItem(Messages.getString("MindRaiderJFrame.rebuildSearchIndex")); menuItem.setMnemonic(KeyEvent.VK_R); menuItem.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { SearchCommander.rebuildSearchAndTagIndices(); } }); menu.add(menuItem); menu.addSeparator(); menuItem = new JMenuItem(Messages.getString("MindRaiderMainWindow.captureScreen")); menuItem.setMnemonic(KeyEvent.VK_S); menuItem.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { JFileChooser fc = new JFileChooser(); fc.setApproveButtonText(Messages.getString("MindRaiderJFrame.screenshot")); fc.setControlButtonsAreShown(true); fc.setDialogTitle(Messages.getString("MindRaiderJFrame.chooseScreenshotDirectory")); fc.setFileSelectionMode(JFileChooser.DIRECTORIES_ONLY); // prepare directory String exportDirectory = MindRaider.profile.getHomeDirectory() + File.separator + "Screenshots"; Utils.createDirectory(exportDirectory); fc.setCurrentDirectory(new File(exportDirectory)); int returnVal = fc.showOpenDialog(MindRaiderMainWindow.this); if (returnVal == JFileChooser.APPROVE_OPTION) { final String filename = fc.getSelectedFile().getAbsolutePath() + File.separator + "screenshot.jpg"; // do it in async (redraw screen) Thread thread = new Thread() { public void run() { OutputStream file = null; try { file = new FileOutputStream(filename); Robot robot = new Robot(); robot.delay(1000); JPEGImageEncoder encoder = JPEGCodec.createJPEGEncoder(file); encoder.encode(robot.createScreenCapture( new Rectangle(Toolkit.getDefaultToolkit().getScreenSize()))); } catch (Exception e1) { logger.error("Unable to capture screen!", e1); } finally { if (file != null) { try { file.close(); } catch (IOException e1) { logger.error("Unable to close stream", e1); } } } } }; thread.setDaemon(true); thread.start(); } } }); menu.add(menuItem); menuBar.add(menu); // - MindForger ----------------------------------------------------------- menu = new JMenu(Messages.getString("MindRaiderMainWindow.menuMindForger")); menu.setMnemonic(KeyEvent.VK_O); //menu.setIcon(IconsRegistry.getImageIcon("tasks-internet.png")); menuItem = new JMenuItem(Messages.getString("MindRaiderMainWindow.menuMindForgerVideoTutorial")); menuItem.setMnemonic(KeyEvent.VK_G); menuItem.setToolTipText("http://mindraider.sourceforge.net/mindforger.html"); menuItem.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { Launcher.launchInBrowser("http://mindraider.sourceforge.net/mindforger.html"); } }); menuItem.setEnabled(true); menu.add(menuItem); menuItem = new JMenuItem(Messages.getString("MindRaiderMainWindow.signUp")); menuItem.setMnemonic(KeyEvent.VK_S); menuItem.setToolTipText("http://www.mindforger.com"); menuItem.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { Launcher.launchInBrowser("http://www.mindforger.com"); } }); menuItem.setEnabled(true); menu.add(menuItem); menu.addSeparator(); menuItem = new JMenuItem(Messages.getString("MindRaiderMainWindow.menuMindForgerUpload")); menuItem.setMnemonic(KeyEvent.VK_U); menuItem.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { // fork in order to enable status updates in the main window new MindForgerUploadOutlineJDialog(); } }); menuItem.setEnabled(true); menu.add(menuItem); menuItem = new JMenuItem(Messages.getString("MindRaiderMainWindow.menuMindForgerDownload")); menuItem.setMnemonic(KeyEvent.VK_U); menuItem.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { downloadAnOutlineFromMindForger(); } }); menuItem.setEnabled(true); menu.add(menuItem); menu.addSeparator(); menuItem = new JMenuItem(Messages.getString("MindRaiderMainWindow.menuMindForgerMyOutlines")); menuItem.setMnemonic(KeyEvent.VK_O); menuItem.setEnabled(true); menuItem.setToolTipText("http://web.mindforger.com"); menuItem.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { Launcher.launchInBrowser("http://web.mindforger.com"); } }); menu.add(menuItem); menuBar.add(menu); // - align Help on right ------------------------------------------------------------- menuBar.add(Box.createHorizontalGlue()); // - help ------------------------------------------------------------- menu = new JMenu(Messages.getString("MindRaiderJFrame.help")); menu.setMnemonic(KeyEvent.VK_H); menuItem = new JMenuItem(Messages.getString("MindRaiderJFrame.documentation")); menuItem.setMnemonic(KeyEvent.VK_D); menuItem.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { try { MindRaider.outlineCustodian.loadOutline(new URI(MindRaiderVocabulary .getNotebookUri(OutlineCustodian.MR_DOC_NOTEBOOK_DOCUMENTATION_LOCAL_NAME))); OutlineJPanel.getInstance().refresh(); } catch (Exception e1) { logger.error(Messages.getString("MindRaiderJFrame.unableToLoadHelp", e1.getMessage())); } } }); menu.add(menuItem); menu.addSeparator(); menuItem = new JMenuItem(Messages.getString("MindRaiderMainWindow.webHomepage")); menuItem.setMnemonic(KeyEvent.VK_H); menuItem.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { Launcher.launchInBrowser("http://mindraider.sourceforge.net"); } }); menu.add(menuItem); menuItem = new JMenuItem(Messages.getString("MindRaiderMainWindow.reportBug")); menuItem.setMnemonic(KeyEvent.VK_R); menuItem.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { Launcher.launchInBrowser("http://sourceforge.net/forum/?group_id=128454"); } }); menu.add(menuItem); menuItem = new JMenuItem(Messages.getString("MindRaiderMainWindow.updateCheck")); menuItem.setMnemonic(KeyEvent.VK_F); menuItem.setEnabled(true); menuItem.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { // just open html page at: // http://mindraider.sourceforge.net/update-7.2.html // this page will either contain "you have the last version" or will ask user to // download the latest version from main page Launcher.launchInBrowser("http://mindraider.sourceforge.net/" + "update-" + MindRaiderConstants.majorVersion + "." + MindRaiderConstants.minorVersion + ".html"); } }); menu.add(menuItem); menu.addSeparator(); menuItem = new JMenuItem(Messages.getString("MindRaiderJFrame.about", MindRaiderConstants.MR_TITLE)); menuItem.setMnemonic(KeyEvent.VK_A); menuItem.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { new AboutJDialog(); } }); menu.add(menuItem); menuBar.add(menu); }
From source file:simMPLS.ui.simulator.JVentanaHija.java
/** * Este mtodo se encarga de controlar que todo ocurre como debe con respecto al * escenario, cuando se pulsa en el men principal la opcin de "Guardar como..." * @since 1.0/* w w w .j a va 2s .c o m*/ */ public void gestionarGuardarComo() { anotarDatosDeEscenario(); JFileChooser dialogoGuardar = new JFileChooser(); dialogoGuardar.setFileFilter(new JOSMFilter()); dialogoGuardar.setDialogType(JFileChooser.CUSTOM_DIALOG); dialogoGuardar.setApproveButtonMnemonic('A'); dialogoGuardar.setApproveButtonText(java.util.ResourceBundle.getBundle("simMPLS/lenguajes/lenguajes") .getString("JVentanaHija.DialogoGuardar.OK")); dialogoGuardar.setDialogTitle(java.util.ResourceBundle.getBundle("simMPLS/lenguajes/lenguajes") .getString("JVentanaHija.DialogoGuardar.Almacenar") + this.getTitle() + java.util.ResourceBundle.getBundle("simMPLS/lenguajes/lenguajes").getString("-")); dialogoGuardar.setAcceptAllFileFilterUsed(false); dialogoGuardar.setSelectedFile(new File(this.getTitle())); dialogoGuardar.setFileSelectionMode(JFileChooser.FILES_ONLY); int resultado = dialogoGuardar.showSaveDialog(VentanaPadre); if (resultado == JFileChooser.APPROVE_OPTION) { String ext = null; String nombreFich = dialogoGuardar.getSelectedFile().getPath(); int i = nombreFich.lastIndexOf('.'); if (i > 0 && i < nombreFich.length() - 1) { ext = nombreFich.substring(i + 1).toLowerCase(); } if (ext == null) { nombreFich += java.util.ResourceBundle.getBundle("simMPLS/lenguajes/lenguajes").getString(".osm"); } else { if (!ext.equals( java.util.ResourceBundle.getBundle("simMPLS/lenguajes/lenguajes").getString("osm"))) { nombreFich += java.util.ResourceBundle.getBundle("simMPLS/lenguajes/lenguajes") .getString(".osm"); } } dialogoGuardar.setSelectedFile(new File(nombreFich)); escenario.setFile(dialogoGuardar.getSelectedFile()); this.escenario.setSaved(true); this.setTitle(this.escenario.obtenerFichero().getName()); TOSMSaver almacenador = new TOSMSaver(escenario); // JVentanaBooleana vb = new JVentanaBooleana(this.VentanaPadre, true, this.dispensadorDeImagenes); // vb.mostrarPregunta(java.util.ResourceBundle.getBundle("simMPLS/lenguajes/lenguajes").getString("JVentanaHija.PreguntaEmpotrarCRC")); // vb.show(); // boolean conCRC = vb.obtenerRespuesta(); // boolean correcto = almacenador.save(escenario.obtenerFichero(), conCRC); JVentanaBooleana vb = new JVentanaBooleana(this.VentanaPadre, true, this.dispensadorDeImagenes); vb.mostrarPregunta("Do you want to save the routing tables ?"); vb.show(); boolean saveTables = vb.obtenerRespuesta(); boolean correcto = almacenador.save(escenario.obtenerFichero(), false, saveTables); if (correcto) { this.escenario.setModified(false); this.escenario.setSaved(true); } } }
From source file:org.jets3t.apps.cockpit.Cockpit.java
/** * Event handler for this application, handles all menu items. *///from w ww . j a v a 2 s . c om public void actionPerformed(ActionEvent event) { // Service Menu Events if ("LoginEvent".equals(event.getActionCommand())) { loginEvent(null); } else if ("LogoutEvent".equals(event.getActionCommand())) { logoutEvent(); } else if (event.getActionCommand() != null && event.getActionCommand().startsWith("LoginSwitch")) { String loginName = event.getActionCommand().substring("LoginSwitch:".length()); ProviderCredentials credentials = loginAwsCredentialsMap.get(loginName); loginEvent(credentials); } else if ("QuitEvent".equals(event.getActionCommand())) { System.exit(0); } // Bucket Events. else if ("ViewBucketProperties".equals(event.getActionCommand())) { listBucketProperties(); } else if ("RefreshBuckets".equals(event.getActionCommand())) { listAllBuckets(); } else if ("CreateBucket".equals(event.getActionCommand())) { createBucketAction(); } else if ("DeleteBucket".equals(event.getActionCommand())) { deleteSelectedBucket(); } else if ("ManageDistributions".equals(event.getActionCommand())) { S3Bucket[] buckets = bucketTableModel.getBuckets(); String[] bucketNames = new String[buckets.length]; for (int i = 0; i < buckets.length; i++) { bucketNames[i] = buckets[i].getName(); } ManageDistributionsDialog.showDialog(ownerFrame, cloudFrontService, bucketNames, this); } else if ("AddThirdPartyBucket".equals(event.getActionCommand())) { addThirdPartyBucket(); } else if ("UpdateBucketACL".equals(event.getActionCommand())) { updateBucketAccessControlList(); } else if ("UpdateBucketRequesterPaysStatus".equals(event.getActionCommand())) { updateBucketRequesterPaysSetting(); } // Object Events else if ("ViewOrModifyObjectAttributes".equals(event.getActionCommand())) { displayObjectsAttributesDialog(); } else if ("CopyObjects".equals(event.getActionCommand())) { copyObjects(); } else if ("RefreshObjects".equals(event.getActionCommand())) { listObjects(); } else if ("UpdateObjectACL".equals(event.getActionCommand())) { displayAclModificationDialog(); } else if ("GeneratePublicGetURLs".equals(event.getActionCommand())) { generatePublicGetUrls(); } else if ("GenerateTorrentURL".equals(event.getActionCommand())) { generateTorrentUrl(); } else if ("DeleteObjects".equals(event.getActionCommand())) { deleteSelectedObjects(); } else if ("DownloadObjects".equals(event.getActionCommand())) { downloadSelectedObjects(); } else if ("UploadFiles".equals(event.getActionCommand())) { JFileChooser fileChooser = new JFileChooser(); fileChooser.setMultiSelectionEnabled(true); fileChooser.setDialogTitle("Choose files to upload"); fileChooser.setFileSelectionMode(JFileChooser.FILES_AND_DIRECTORIES); fileChooser.setApproveButtonText("Upload files"); fileChooser.setCurrentDirectory(fileChoosersLastUploadDirectory); int returnVal = fileChooser.showOpenDialog(ownerFrame); if (returnVal != JFileChooser.APPROVE_OPTION) { return; } final File[] uploadFiles = fileChooser.getSelectedFiles(); if (uploadFiles.length == 0) { return; } // Save the chosen directory location for next time. fileChoosersLastUploadDirectory = uploadFiles[0].getParentFile(); uploadFiles(uploadFiles); } else if (event.getSource().equals(filterObjectsCheckBox)) { if (filterObjectsCheckBox.isSelected()) { filterObjectsPanel.setVisible(true); } else { filterObjectsPanel.setVisible(false); filterObjectsPrefix.setText(""); if (filterObjectsDelimiter.getSelectedIndex() != 0) { filterObjectsDelimiter.setSelectedIndex(0); } } } // Tools events else if ("BucketLogging".equals(event.getActionCommand())) { S3Bucket[] buckets = bucketTableModel.getBuckets(); BucketLoggingDialog.showDialog(ownerFrame, s3ServiceMulti.getS3Service(), buckets, this); } // Preference Events else if ("PreferencesDialog".equals(event.getActionCommand())) { PreferencesDialog.showDialog(cockpitPreferences, ownerFrame, this); // Save a user's preferences if requested, otherwise wipe any existing preferences file. File cockpitPreferencesPropertiesFile = new File(cockpitHomeDirectory, Constants.COCKPIT_PROPERTIES_FILENAME); if (cockpitPreferences.isRememberPreferences()) { try { Properties properties = cockpitPreferences.toProperties(); if (!cockpitHomeDirectory.exists()) { cockpitHomeDirectory.mkdir(); } properties.list(new PrintStream(new FileOutputStream(cockpitPreferencesPropertiesFile))); } catch (IOException e) { String message = "Unable to save your preferences"; log.error(message, e); ErrorDialog.showDialog(ownerFrame, this, message, e); } } else if (cockpitPreferencesPropertiesFile.exists()) { // User elected not to store preferences, delete the existing preferences file. cockpitPreferencesPropertiesFile.delete(); } if (cockpitPreferences.isEncryptionPasswordSet()) { try { encryptionUtil = new EncryptionUtil(cockpitPreferences.getEncryptionPassword(), cockpitPreferences.getEncryptionAlgorithm(), EncryptionUtil.DEFAULT_VERSION); } catch (Exception e) { String message = "Unable to start encryption utility"; log.error(message, e); ErrorDialog.showDialog(ownerFrame, this, message, e); } } else { encryptionUtil = null; } } // Ooops... else { log.debug("Unrecognised ActionEvent command '" + event.getActionCommand() + "' in " + event); } }