List of usage examples for javax.swing JDialog setVisible
public void setVisible(boolean b)
From source file:psidev.psi.mi.validator.client.gui.DragAndDropValidator.java
/** * Sets up the menu bar of the main window. * * @param frame the frame onto which we attach the menu bar * @param table the table that allow to command the validator. * @param level the level of log message. *///from w w w . j a va 2 s. co m public static void setupMenus(final JFrame frame, final Validator validator, final ValidatorTable table, final MessageLevel level) { // Create the fileMenu bar JMenuBar menuBar = new JMenuBar(); final UserPreferences preferences = validator.getUserPreferences(); //////////////////////////// // 1. Create a file menu JMenu fileMenu = new JMenu("File"); menuBar.add(fileMenu); // Create a file Menu items JMenuItem openFile = new JMenuItem("Open file..."); openFile.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { GuiUserPreferences guiPrefs = new GuiUserPreferences(preferences); File lastDirectory = userPreferences.getLastOpenedDirectory(); JFileChooser fileChooser = new JFileChooser(lastDirectory); fileChooser.addChoosableFileFilter(new XmlFileFilter()); // Open file dialog. fileChooser.showOpenDialog(frame); File selected = fileChooser.getSelectedFile(); if (selected != null) { userPreferences.setLastOpenedDirectory(selected.getParentFile()); // start validation of the selected file. ValidatorTableRow row = new ValidatorTableRow(selected, level, true); table.addTableRow(row); } } }); fileMenu.add(openFile); // exit menu item JMenuItem exit = new JMenuItem("Exit"); exit.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { System.exit(0); } }); fileMenu.add(exit); /////////////////////////////// // 2. TODO setup messages menu // JMenu msgMenu = new JMenu( "Messages" ); // menuBar.add( msgMenu ); // // // Create a clear all messages item // JMenuItem clearAll = new JMenuItem( "Clear all" ); // openFile.addActionListener( new ActionListener() { // // public void actionPerformed( ActionEvent e ) { // // // remove all elements // table.removeAllRows( ); // } // } ); // msgMenu.add( clearAll ); ////////////////////////////// // Log level // TODO create a menu that allows to switch log level at run time. ///////////////////////// // 3. setup help menu JMenu helpMenu = new JMenu("Help"); menuBar.add(helpMenu); JMenuItem about = new JMenuItem("About..."); about.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { JOptionPane msg = new JOptionPane("Version " + VERSION + NEW_LINE + "Authors: " + AUTHORS); JDialog dialog = msg.createDialog(frame, "About PSI Validator"); dialog.setResizable(true); dialog.pack(); dialog.setVisible(true); } }); helpMenu.add(about); // Install the fileMenu bar in the frame frame.setJMenuBar(menuBar); }
From source file:pt.lsts.neptus.util.logdownload.LogsDownloaderWorkerActions.java
@SuppressWarnings("serial") private AbstractAction createDeleteSelectedLogFoldersAction() { return new AbstractAction() { @Override//from w w w . j av a 2s . c o m public void actionPerformed(ActionEvent e) { if (!gui.validateAndSetUI()) { gui.popupErrorConfigurationDialog(); return; } AsyncTask task = new AsyncTask() { @Override public Object run() throws Exception { gui.deleteSelectedLogFoldersButton.setEnabled(false); // logFolderList.setEnabled(false); // logFilesList.setEnabled(false); Object[] objArray = gui.logFolderList.getSelectedValues(); if (objArray.length == 0) return null; JOptionPane jop = new JOptionPane( I18n.text("Are you sure you want to delete " + "selected log folders from remote system?"), JOptionPane.QUESTION_MESSAGE, JOptionPane.YES_NO_OPTION); JDialog dialog = jop.createDialog(gui.frameCompHolder, I18n.text("Remote Delete Confirmation")); dialog.setModalityType(ModalityType.DOCUMENT_MODAL); dialog.setVisible(true); Object userChoice = jop.getValue(); try { if (((Integer) userChoice) != JOptionPane.YES_OPTION) { return null; } } catch (Exception e2) { NeptusLog.pub().error(e2.getMessage()); return null; } gui.deleteSelectedLogFoldersButton.setEnabled(true); for (Object comp : objArray) { try { LogFolderInfo logFd = (LogFolderInfo) comp; boolean resDel = worker.deleteLogFolderFromServer(logFd); if (resDel) { logFd.setState(LogFolderInfo.State.LOCAL); LinkedHashSet<LogFileInfo> logFiles = logFd.getLogFiles(); LinkedHashSet<LogFileInfo> toDelFL = LogsDownloaderWorkerGUIUtil .updateLogFilesStateDeleted(logFiles, gui.downloadWorkersHolder, worker.getDirBaseToStoreFiles(), worker.getLogLabel()); for (LogFileInfo lfx : toDelFL) { if (resetting) break; logFd.getLogFiles().remove(lfx); } } } catch (Exception e) { NeptusLog.pub().debug(e.getMessage()); } if (resetting) break; } worker.updateFilesListGUIForFolderSelected(); return true; } @Override public void finish() { gui.deleteSelectedLogFoldersButton.setEnabled(true); gui.logFilesList.revalidate(); gui.logFilesList.repaint(); gui.logFilesList.setEnabled(true); gui.logFolderList.revalidate(); gui.logFolderList.repaint(); gui.logFolderList.setEnabled(true); try { this.getResultOrThrow(); } catch (Exception e) { e.printStackTrace(); } } }; AsyncWorker.getWorkerThread().postTask(task); } }; }
From source file:pt.lsts.neptus.util.logdownload.LogsDownloaderWorkerActions.java
@SuppressWarnings("serial") private AbstractAction createDeleteSelectedLogFilesAction() { return new AbstractAction() { @Override// www . j a va2s.co m public void actionPerformed(ActionEvent e) { if (!gui.validateAndSetUI()) { gui.popupErrorConfigurationDialog(); return; } AsyncTask task = new AsyncTask() { @Override public Object run() throws Exception { gui.deleteSelectedLogFilesButton.setEnabled(false); Object[] objArray = gui.logFilesList.getSelectedValues(); if (objArray.length == 0) return null; JOptionPane jop = new JOptionPane( I18n.text("Are you sure you want to delete selected log files from remote system?"), JOptionPane.QUESTION_MESSAGE, JOptionPane.YES_NO_OPTION); JDialog dialog = jop.createDialog(gui.frameCompHolder, I18n.text("Remote Delete Confirmation")); dialog.setModalityType(ModalityType.DOCUMENT_MODAL); dialog.setVisible(true); Object userChoice = jop.getValue(); try { if (((Integer) userChoice) != JOptionPane.YES_OPTION) { return null; } } catch (Exception e2) { NeptusLog.pub().error(e2.getMessage()); return null; } gui.deleteSelectedLogFoldersButton.setEnabled(true); LinkedHashSet<LogFileInfo> logFiles = new LinkedHashSet<LogFileInfo>(); for (Object comp : objArray) { if (resetting) break; try { LogFileInfo lfx = (LogFileInfo) comp; if (worker.deleteLogFileFromServer(lfx)) logFiles.add(lfx); } catch (Exception e) { NeptusLog.pub().debug(e.getMessage()); } } if (!resetting) { LogsDownloaderWorkerGUIUtil.updateLogFilesStateDeleted(logFiles, gui.downloadWorkersHolder, worker.getDirBaseToStoreFiles(), worker.getLogLabel()); worker.updateFilesListGUIForFolderSelected(); } return true; } @Override public void finish() { gui.deleteSelectedLogFilesButton.setEnabled(true); gui.logFilesList.revalidate(); gui.logFilesList.repaint(); gui.logFilesList.setEnabled(true); gui.logFolderList.revalidate(); gui.logFolderList.repaint(); gui.logFolderList.setEnabled(true); try { this.getResultOrThrow(); } catch (Exception e) { e.printStackTrace(); } } }; AsyncWorker.getWorkerThread().postTask(task); } }; }
From source file:ro.nextreports.designer.action.chart.PreviewChartAction.java
public void actionPerformed(ActionEvent event) { executorThread = new Thread(new Runnable() { public void run() { if (ChartUtil.chartUndefined(chart)) { return; }// ww w. java 2s . com ParametersBean pBean = NextReportsUtil.selectParameters(chart.getReport(), null); if (pBean == null) { return; } UIActivator activator = new UIActivator(Globals.getMainFrame(), I18NSupport.getString("preview.chart.execute")); activator.start(new PreviewStopAction()); ChartWebServer webServer = ChartWebServer.getInstance(); String webRoot = webServer.getWebRoot(); ChartRunner runner = new ChartRunner(); runner.setFormat(chartRunnerType); runner.setGraphicType(chartGraphicType); runner.setChart(chart); runner.setQueryTimeout(Globals.getQueryTimeout()); runner.setParameterValues(pBean.getParamValues()); I18nLanguage language = I18nUtil.getDefaultLanguage(chart); if (language != null) { runner.setLanguage(language.getName()); } if (ChartRunner.IMAGE_FORMAT.equals(runner.getFormat())) { runner.setImagePath(Globals.USER_DATA_DIR + "/reports"); } Connection con = null; try { DataSource runDS = Globals.getChartLayoutPanel().getRunDataSource(); boolean csv = runDS.getDriver().equals(CSVDialect.DRIVER_CLASS); con = Globals.createTempConnection(runDS); runner.setConnection(con, csv); if (ChartRunner.IMAGE_FORMAT.equals(runner.getFormat())) { runner.run(); JDialog dialog = new JDialog(Globals.getMainFrame(), ""); dialog.setBackground(Color.WHITE); dialog.setLayout(new BorderLayout()); ShowImagePanel panel = new ShowImagePanel(runner.getChartImageAbsolutePath()); dialog.add(panel, BorderLayout.CENTER); dialog.pack(); dialog.setResizable(false); Show.centrateComponent(Globals.getMainFrame(), dialog); dialog.setVisible(true); } else { String jsonFile = "data.json"; if (ChartRunner.HTML5_TYPE == runner.getGraphicType()) { jsonFile = "data-html5.json"; } OutputStream outputStream = new FileOutputStream(webRoot + File.separatorChar + jsonFile); boolean result = runner.run(outputStream); outputStream.close(); if (result) { if (!webServer.isStarted()) { webServer.start(); } if (ChartRunner.HTML5_TYPE == runner.getGraphicType()) { FileUtil.openUrl( "http://localhost:" + Globals.getChartWebServerPort() + "/chart-html5.html", PreviewChartAction.class); } else { FileUtil.openUrl("http://localhost:" + Globals.getChartWebServerPort() + "/chart.html?ofc=data.json", PreviewChartAction.class); } } } } catch (NoDataFoundException e) { Show.info(I18NSupport.getString("run.nodata")); } catch (InterruptedException e) { Show.dispose(); // close a possible previous dialog message Show.info(I18NSupport.getString("preview.cancel")); } catch (Exception e) { e.printStackTrace(); Show.error(e); } finally { if (con != null) { try { con.close(); } catch (SQLException e) { e.printStackTrace(); LOG.error(e.getMessage(), e); } } stop = false; if (activator != null) { activator.stop(); activator = null; } // restore old parameters if chart was runned from tree if (oldParameters != null) { ParameterManager.getInstance().setParameters(oldParameters); } } } }, "NEXT : " + getClass().getSimpleName()); executorThread.setPriority(EngineProperties.getRunPriority()); executorThread.start(); }
From source file:ro.nextreports.designer.wizpublish.DownloadListWizardPanel.java
private void createSelectionDialog(final byte type) { WebServiceClient client = (WebServiceClient) context.getAttribute(PublishWizard.CLIENT); final JcrBrowserTree jcrBrowserTree = new JcrBrowserTree(type, client); jcrBrowserTree.getSelectionModel().setSelectionMode(TreeSelectionModel.DISCONTIGUOUS_TREE_SELECTION); JPanel selectionPanel = JcrBrowserTreeUtil.createSelectionPanel(jcrBrowserTree, type); JDialog dialog = new BaseDialog(selectionPanel, I18NSupport.getString("wizard.publish.file.path.select"), true) {// w w w. j a v a 2 s .c om protected boolean ok() { return selection(jcrBrowserTree, type); } }; dialog.pack(); Show.centrateComponent((JDialog) context.getAttribute(PublishWizard.MAIN_FRAME), dialog); dialog.setVisible(true); }
From source file:ro.nextreports.designer.wizpublish.PublishFileWizardPanel.java
private void createSelectionDialog(final byte type) { WebServiceClient client = (WebServiceClient) context.getAttribute(PublishWizard.CLIENT); final JcrBrowserTree jcrBrowserTree = new JcrBrowserTree(type, client); JPanel selectionPanel = JcrBrowserTreeUtil.createSelectionPanel(jcrBrowserTree, type); String message = ""; if ((type == DBObject.REPORTS_GROUP) || (type == DBObject.CHARTS_GROUP)) { message = I18NSupport.getString("wizard.publish.file.path.select"); } else if (type == DBObject.DATABASE) { message = I18NSupport.getString("wizard.publish.file.source"); }/*from w ww. jav a2s . c o m*/ JDialog dialog = new BaseDialog(selectionPanel, message, true) { protected boolean ok() { return selection(jcrBrowserTree, type); } }; dialog.pack(); Show.centrateComponent((JDialog) context.getAttribute(PublishWizard.MAIN_FRAME), dialog); dialog.setVisible(true); }
From source file:ro.nextreports.designer.wizpublish.SelectEntityWizardPanel.java
private void add() { // ignore double click listener for tree (which opens the query) // and create our own listener (which just selects the path) final DBBrowserTree dbBrowserTree = new DBBrowserTree(type, false); dbBrowserTree.getSelectionModel().setSelectionMode(TreeSelectionModel.DISCONTIGUOUS_TREE_SELECTION); dbBrowserTree.addMouseListener(new MouseAdapter() { public void mousePressed(MouseEvent e) { job(e, true);//from w w w . j a v a 2 s .c om } public void mouseReleased(MouseEvent e) { job(e, false); } private void job(MouseEvent e, boolean pressed) { TreePath[] paths = dbBrowserTree.getSelectionPaths(); if (paths == null) { return; } dbBrowserTree.setSelectionPaths(paths); } }); JScrollPane scroll = new JScrollPane(dbBrowserTree); scroll.setPreferredSize(scrTreeDim); JPanel panel = new JPanel(); panel.add(scroll); JDialog dialog = new BaseDialog(panel, I18NSupport.getString("wizard.publish.entities.select"), true) { protected boolean ok() { TreePath[] paths = dbBrowserTree.getSelectionPaths(); if (paths == null) { return false; } for (TreePath selPath : paths) { final DBBrowserNode selectedNode = (DBBrowserNode) selPath.getLastPathComponent(); if (!selectedNode.getDBObject().isFolder()) { String path = selectedNode.getDBObject().getAbsolutePath(); if (!listModel.contains(path)) { // convert xml if needed before add to list if (selectedNode.getDBObject().getType() == DBObject.REPORTS) { byte result = ConverterUtil.convertIfNeeded(path); if (result != ConverterUtil.TYPE_CONVERSION_EXCEPTION) { listModel.addElement(path); } } else { listModel.addElement(path); } } } } return true; } }; dialog.setBackground(Color.WHITE); dialog.pack(); Show.centrateComponent(Globals.getMainFrame(), dialog); dialog.setVisible(true); }
From source file:savant.format.SavantFileFormatter.java
public static void reportFormattingError(final Throwable x, final File inFile) { if (x instanceof InterruptedException) { DialogUtils.displayMessage("Format cancelled."); } else if (x instanceof SavantFileFormattingException) { // Not a Savant error. They've just chosen the wrong kind of file. DialogUtils.displayMessage("Format Unsuccessful", x.getMessage()); } else {//ww w . j a va 2 s . c o m JideOptionPane optionPane = new JideOptionPane(String.format( "<html>Message: <i>%s</i><br><br>Click the <i>Details</i> button to see more information...<br><br>" + "Please report any issues you experience to the to the development team.</html>", MiscUtils.getMessage(x)), JOptionPane.ERROR_MESSAGE, JideOptionPane.CLOSE_OPTION); optionPane.setTitle("A problem was encountered while formatting."); optionPane.setOptions(new String[] {}); JButton reportButton = new JButton("Report Issue"); ((JComponent) optionPane.getComponent(optionPane.getComponentCount() - 1)).add(reportButton); final JDialog dialog = optionPane.createDialog(DialogUtils.getMainWindow(), "Format Unsuccessful"); dialog.setModal(true); dialog.setResizable(true); optionPane.setDetails(MiscUtils.getStackTrace(x)); //optionPane.setDetailsVisible(true); dialog.pack(); reportButton.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e2) { String issue = "I am having trouble formatting my file for use with Savant.\nI have provided additional diagnostic information below.\n\n"; issue += "SOURCE OF FILE: [e.g. UCSC]\n\n"; issue += "TYPE: [e.g. BED]\n\n"; issue += "CONTENTS: [e.g. human genes]\n\n"; issue += "PATH: " + inFile + "\n\n"; issue += "ADDITIONAL COMMENTS:\n\n"; dialog.dispose(); new BugReportDialog(Savant.getInstance(), issue).setVisible(true); } }); dialog.setVisible(true); } }
From source file:savant.view.swing.BookmarkSheet.java
private void loadBookmarks(JTable table) { final BookmarksTableModel btm = (BookmarksTableModel) table.getModel(); List<Bookmark> bookmarks = btm.getData(); if (bookmarks.size() > 0) { String message = "Clear existing bookmarks?"; String title = "Clear Bookmarks"; // display the JOptionPane showConfirmDialog int reply = JOptionPane.showConfirmDialog(null, message, title, JOptionPane.YES_NO_OPTION); if (reply == JOptionPane.YES_OPTION) { btm.clearData();// ww w.jav a 2 s.c o m BookmarkController.getInstance().clearBookmarks(); } } final File selectedFile = DialogUtils.chooseFileForOpen("Load Bookmarks", null, null); // set the genome if (selectedFile != null) { int result = JOptionPane.showOptionDialog(null, "Would you like to add padding to each bookmark range?", "Add a margin?", JOptionPane.YES_NO_OPTION, JOptionPane.QUESTION_MESSAGE, null, null, null); final boolean addMargin = (result == JOptionPane.YES_OPTION); Window w = SwingUtilities.getWindowAncestor(BookmarkSheet.this); JOptionPane optionPane = new JOptionPane( "<html>Loading bookmarks from file.<br>This may take a moment.</html>", JOptionPane.INFORMATION_MESSAGE, JOptionPane.CANCEL_OPTION); final JDialog dialog = new JDialog(w, "Loading Bookmarks", Dialog.ModalityType.MODELESS); dialog.setContentPane(optionPane); dialog.pack(); dialog.setLocationRelativeTo(w); dialog.setVisible(true); new Thread("BookmarkSheet.loadBookmarks") { @Override public void run() { try { BookmarkController.getInstance().addBookmarksFromFile(selectedFile, addMargin); btm.fireTableDataChanged(); } catch (Exception ex) { DialogUtils.displayError("Error", "Unable to load bookmarks: " + ex.getMessage()); } finally { dialog.setVisible(false); dialog.dispose(); } } }.start(); } }
From source file:tvbrowser.ui.mainframe.MainFrame.java
private void quit(boolean log, boolean export) { mTimer.stop(); // disable the update timer to avoid new update events if (log && downloadingThread != null && downloadingThread.isAlive()) { final JDialog info = new JDialog(UiUtilities.getLastModalChildOf(this)); info.setModal(true);/*from w w w .j a v a 2 s . com*/ info.setUndecorated(true); info.toFront(); JPanel main = new JPanel(new FormLayout("5dlu,pref,5dlu", "5dlu,pref,5dlu")); main.setBorder(BorderFactory.createLineBorder(Color.black)); main.add( new JLabel(mLocalizer.msg("downloadinfo", "A data update is running. TV-Browser will be closed when the update is done.")), new CellConstraints().xy(2, 2)); info.setContentPane(main); info.pack(); info.setLocationRelativeTo(this); SwingUtilities.invokeLater(new Runnable() { public void run() { if (downloadingThread != null && downloadingThread.isAlive()) { try { downloadingThread.join(); } catch (InterruptedException e) { e.printStackTrace(); } } info.setVisible(false); info.dispose(); } }); info.setVisible(true); } if (log && this.isUndecorated()) { switchFullscreenMode(); } if (mShuttingDown) { return; } mShuttingDown = true; if (log) { FavoritesPlugin.getInstance().handleTvBrowserIsShuttingDown(); } if (log) { mLog.info("Finishing plugins"); } PluginProxyManager.getInstance().shutdownAllPlugins(log); if (log) { mLog.info("Storing dataservice settings"); } TvDataServiceProxyManager.getInstance().shutDown(); FavoritesPlugin.getInstance().store(); ReminderPlugin.getInstance().store(); TVBrowser.shutdown(log); if (log) { mLog.info("Closing TV data base"); } try { TvDataBase.getInstance().close(); } catch (Exception exc) { if (log) { mLog.log(Level.WARNING, "Closing database failed", exc); } } if (export) { Settings.propTVDataDirectory.resetToDefault(); Settings.copyToSystem(); } if (log) { mLog.info("Quitting"); System.exit(0); } }