List of usage examples for javax.swing JDialog setModal
public void setModal(boolean modal)
From source file:org.nuclos.client.relation.MyGraphModel.java
public JPopupMenu createRelationPopupMenu(final mxCell cell, boolean delete) { final JPopupMenu pop = new JPopupMenu(); JMenuItem i1 = new JMenuItem( getSpringLocaleDelegate().getMessage("nuclos.entityrelation.editor.1", "Bezug zu Stammdaten")); i1.addActionListener(new ActionListener() { @Override//from w ww . j av a 2 s .c o m public void actionPerformed(ActionEvent e) { editPanel.setIsPopupShown(false); if (cell.getTarget() == null || cell.getSource() == null) { remove(cell); return; } Object cells[] = { cell }; mxUtils.setCellStyles(graphComponent.getGraph().getModel(), cells, mxConstants.STYLE_ENDARROW, mxConstants.ARROW_OPEN); mxUtils.setCellStyles(graphComponent.getGraph().getModel(), cells, mxConstants.STYLE_ENDSIZE, "12"); mxUtils.setCellStyles(graphComponent.getGraph().getModel(), cells, mxConstants.STYLE_ELBOW, mxConstants.ELBOW_VERTICAL); mxUtils.setCellStyles(graphComponent.getGraph().getModel(), cells, EDGESTYLE, ELBOWCONNECTOR); RelationAttributePanel panel = new RelationAttributePanel(RelationAttributePanel.TYPE_ENTITY); mxCell target = (mxCell) cell.getTarget(); mxCell source = (mxCell) cell.getSource(); panel.setEntity((EntityMetaDataVO) target.getValue()); panel.setEntitySource((EntityMetaDataVO) source.getValue()); EntityMetaDataVO voSource = (EntityMetaDataVO) source.getValue(); EntityMetaDataVO voTarget = (EntityMetaDataVO) target.getValue(); panel.setEntityFields( MetaDataDelegate.getInstance().getAllEntityFieldsByEntity(voSource.getEntity()).values()); double cellsDialog[][] = { { 5, TableLayout.PREFERRED, 5 }, { 5, TableLayout.PREFERRED, 5 } }; JDialog dia = new JDialog(mf); dia.setLayout(new TableLayout(cellsDialog)); dia.setTitle(getSpringLocaleDelegate().getMessage("nuclos.entityrelation.editor.10", "Bezug zu Stammdaten bearbeiten")); dia.setLocationRelativeTo(editPanel); dia.add(panel, "1,1"); dia.setModal(true); panel.setDialog(dia); dia.pack(); dia.setVisible(true); if (panel.getState() == 1) { EntityFieldMetaDataVO vo = panel.getField(); cell.setValue(vo); mpTransation.put(vo, panel.getTranslation().getRows()); List<EntityFieldMetaDataTO> toList = new ArrayList<EntityFieldMetaDataTO>(); EntityFieldMetaDataTO toField = new EntityFieldMetaDataTO(); toField.setEntityFieldMeta(vo); toField.setTranslation(panel.getTranslation().getRows()); toList.add(toField); MetaDataDelegate.getInstance().modifyEntityMetaData(voSource, toList); editPanel.loadReferenz(); } else { remove(cell); } } }); final JMenuItem i2 = new JMenuItem(getSpringLocaleDelegate().getMessage("nuclos.entityrelation.editor.3", "Bezug zu Vorg\u00e4ngen (Unterformularbezug)")); i2.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { editPanel.setIsPopupShown(false); if (cell.getTarget() == null || cell.getSource() == null) { remove(cell); return; } Object cells[] = { cell }; mxUtils.setCellStyles(graphComponent.getGraph().getModel(), cells, mxConstants.STYLE_ENDARROW, mxConstants.ARROW_DIAMOND); mxUtils.setCellStyles(graphComponent.getGraph().getModel(), cells, mxConstants.STYLE_ENDSIZE, "12"); mxUtils.setCellStyles(graphComponent.getGraph().getModel(), cells, mxConstants.STYLE_ELBOW, mxConstants.ELBOW_VERTICAL); mxUtils.setCellStyles(graphComponent.getGraph().getModel(), cells, EDGESTYLE, ELBOWCONNECTOR); mxCell target = (mxCell) cell.getTarget(); mxCell source = (mxCell) cell.getSource(); EntityMetaDataVO voSource = (EntityMetaDataVO) source.getValue(); EntityMetaDataVO voTarget = (EntityMetaDataVO) target.getValue(); String sFieldName = null; boolean blnNotSet = true; while (blnNotSet) { sFieldName = JOptionPane.showInputDialog(editPanel, getSpringLocaleDelegate().getMessage( "nuclos.entityrelation.editor.1", "Bitte geben Sie den Namen des Feldes an!")); if (sFieldName == null || sFieldName.length() < 1) { MyGraphModel.this.remove(cell); return; } else if (sFieldName != null) { blnNotSet = false; } } EntityFieldMetaDataVO vo = new EntityFieldMetaDataVO(); vo.setModifiable(true); vo.setLogBookTracking(false); vo.setReadonly(false); vo.setShowMnemonic(true); vo.setInsertable(true); vo.setSearchable(true); vo.setNullable(false); vo.setUnique(true); vo.setDataType("java.lang.String"); List<TranslationVO> lstTranslation = new ArrayList<TranslationVO>(); for (LocaleInfo voLocale : LocaleDelegate.getInstance().getAllLocales(false)) { String sLocaleLabel = voLocale.language; Integer iLocaleID = voLocale.localeId; String sCountry = voLocale.title; Map<String, String> map = new HashMap<String, String>(); TranslationVO translation = new TranslationVO(iLocaleID, sCountry, sLocaleLabel, map); for (String sLabel : labels) { translation.getLabels().put(sLabel, sFieldName); } lstTranslation.add(translation); } vo.setForeignEntity(voTarget.getEntity()); vo.setField(sFieldName); vo.setDbColumn("INTID_" + sFieldName); cell.setValue(vo); List<EntityFieldMetaDataTO> toList = new ArrayList<EntityFieldMetaDataTO>(); EntityFieldMetaDataTO toField = new EntityFieldMetaDataTO(); toField.setEntityFieldMeta(vo); toField.setTranslation(lstTranslation); toList.add(toField); MetaDataDelegate.getInstance().modifyEntityMetaData(voSource, toList); editPanel.loadReferenz(); } }); final JMenuItem i4 = new JMenuItem( getSpringLocaleDelegate().getMessage("nuclos.entityrelation.editor.5", "Arbeitsschritt")); i4.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { editPanel.setIsPopupShown(false); if (cell.getTarget() == null || cell.getSource() == null) { remove(cell); return; } Object cells[] = { cell }; mxUtils.setCellStyles(graphComponent.getGraph().getModel(), cells, mxConstants.STYLE_ENDARROW, mxConstants.ARROW_OVAL); mxUtils.setCellStyles(graphComponent.getGraph().getModel(), cells, mxConstants.STYLE_ENDSIZE, "12"); mxUtils.setCellStyles(graphComponent.getGraph().getModel(), cells, mxConstants.STYLE_ELBOW, mxConstants.ELBOW_VERTICAL); mxUtils.setCellStyles(graphComponent.getGraph().getModel(), cells, EDGESTYLE, ELBOWCONNECTOR); try { mxCell cellSource = (mxCell) cell.getSource(); mxCell cellTarget = (mxCell) cell.getTarget(); EntityMetaDataVO sourceModule = (EntityMetaDataVO) cellSource.getValue(); EntityMetaDataVO targetModule = (EntityMetaDataVO) cellTarget.getValue(); String sSourceModule = sourceModule.getEntity(); String sTargetModule = targetModule.getEntity(); boolean blnFound = false; for (MasterDataVO voGeneration : MasterDataCache.getInstance() .get(NuclosEntity.GENERATION.getEntityName())) { String sSource = (String) voGeneration.getField("sourceModule"); String sTarget = (String) voGeneration.getField("targetModule"); if (org.apache.commons.lang.StringUtils.equals(sSource, sSourceModule) && org.apache.commons.lang.StringUtils.equals(sTarget, sTargetModule)) { GenerationCollectController gcc = (GenerationCollectController) NuclosCollectControllerFactory .getInstance().newMasterDataCollectController( NuclosEntity.GENERATION.getEntityName(), null, null); gcc.runViewSingleCollectableWithId(voGeneration.getId()); blnFound = true; break; } } if (!blnFound) { GenerationCollectController gcc = (GenerationCollectController) NuclosCollectControllerFactory .getInstance().newMasterDataCollectController( NuclosEntity.GENERATION.getEntityName(), null, null); Map<String, Object> mp = new HashMap<String, Object>(); mp.put("sourceModule", sSourceModule); mp.put("sourceModuleId", new Integer( MetaDataClientProvider.getInstance().getEntity(sSourceModule).getId().intValue())); mp.put("targetModule", sTargetModule); mp.put("targetModuleId", new Integer( MetaDataClientProvider.getInstance().getEntity(sTargetModule).getId().intValue())); MasterDataVO vo = new MasterDataVO(NuclosEntity.GENERATION.getEntityName(), null, null, null, null, null, null, mp); gcc.runWithNewCollectableWithSomeFields(vo); } } catch (NuclosBusinessException e1) { LOG.warn("actionPerformed: " + e1); } catch (CommonPermissionException e1) { LOG.warn("actionPerformed: " + e1); } catch (CommonFatalException e1) { LOG.warn("actionPerformed: " + e1); } catch (CommonBusinessException e1) { LOG.warn("actionPerformed: " + e1); } } }); JMenuItem i5 = new JMenuItem( getSpringLocaleDelegate().getMessage("nuclos.entityrelation.editor.12", "Verbindung l\u00f6sen")); i5.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { mxGraphModel model = (mxGraphModel) graphComponent.getGraph().getModel(); model.remove(cell); } }); pop.add(i1); pop.add(i2); //pop.add(i3); pop.add(i4); if (delete) { pop.addSeparator(); pop.add(i5); } return pop; }
From source file:org.openmicroscopy.shoola.util.ui.UIUtilities.java
/** * Creates a modal JDialog containing the specified JComponent * for the specified parent./*from w ww .j ava2 s . c o m*/ * The newly created dialog is then centered on the screen and made visible. * * @param parent The parent component. * @param title The title of the dialog. * @param c The component to display. * @see #centerAndShow(Component) */ public static void makeForDialog(Component parent, String title, JComponent c) { if (c == null) return; JDialog dialog = null; if (parent instanceof Frame) dialog = new JDialog((Frame) parent); else if (parent instanceof Dialog) dialog = new JDialog((Dialog) parent); else if (dialog == null) dialog = new JDialog(); //no parent dialog.setDefaultCloseOperation(JDialog.DISPOSE_ON_CLOSE); dialog.setModal(true); dialog.setTitle(title); dialog.setSize(DIALOG_WIDTH, DIALOG_HEIGHT); Container container = dialog.getContentPane(); container.setLayout(new BorderLayout(0, 0)); container.add(c, BorderLayout.CENTER); centerAndShow(dialog); }
From source file:pl.otros.vfs.browser.JOtrosVfsBrowserDialog.java
protected JDialog createDialog(Component parent) throws HeadlessException { Frame toUse = (Frame) SwingUtilities.getAncestorOfClass(Frame.class, parent); final JDialog dialog = new JDialog(toUse); dialog.getContentPane().add(vfsBrowser); dialog.addWindowListener(new WindowAdapter() { public void windowClosing(WindowEvent e) { cancelSelection();/*from ww w . ja v a 2 s . c o m*/ } }); vfsBrowser.setApproveAction(new AbstractAction(Messages.getMessage("general.openButtonText")) { @Override public void actionPerformed(ActionEvent actionEvent) { returnValue = ReturnValue.Approve; dialog.dispose(); } }); vfsBrowser.setCancelAction(new AbstractAction(Messages.getMessage("general.cancelButtonText")) { @Override public void actionPerformed(ActionEvent actionEvent) { cancelSelection(); dialog.dispose(); } }); dialog.setModal(true); dialog.invalidate(); dialog.repaint(); return dialog; }
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 {// www . java 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:tvbrowser.TVBrowser.java
/** * Entry point of the application// w w w .j a v a2 s. co m * @param args The arguments given in the command line. */ public static void main(String[] args) { // Read the command line parameters parseCommandline(args); try { Toolkit.getDefaultToolkit().setDynamicLayout( (Boolean) Toolkit.getDefaultToolkit().getDesktopProperty("awt.dynamicLayoutSupported")); } catch (Exception e) { e.printStackTrace(); } mLocalizer = util.ui.Localizer.getLocalizerFor(TVBrowser.class); // Check whether the TV-Browser was started in the right directory if (!new File("imgs").exists()) { String msg = "Please start TV-Browser in the TV-Browser directory!"; if (mLocalizer != null) { msg = mLocalizer.msg("error.2", "Please start TV-Browser in the TV-Browser directory!"); } JOptionPane.showMessageDialog(null, msg); System.exit(1); } if (mIsTransportable) { System.getProperties().remove("propertiesfile"); } // setup logging // Get the default Logger Logger mainLogger = Logger.getLogger(""); // Use a even simpler Formatter for console logging mainLogger.getHandlers()[0].setFormatter(createFormatter()); if (mIsTransportable) { File settingsDir = new File("settings"); try { File test = File.createTempFile("write", "test", settingsDir); test.delete(); } catch (IOException e) { try { UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName()); } catch (Exception e1) { //ignore } JTextArea area = new JTextArea(mLocalizer.msg("error.noWriteRightsText", "You are using the transportable version of TV-Browser but you have no writing rights in the settings directory:\n\n{0}'\n\nTV-Browser will be closed.", settingsDir.getAbsolutePath())); area.setFont(new JLabel().getFont()); area.setFont(area.getFont().deriveFont((float) 14).deriveFont(Font.BOLD)); area.setLineWrap(true); area.setWrapStyleWord(true); area.setPreferredSize(new Dimension(500, 100)); area.setEditable(false); area.setBorder(null); area.setOpaque(false); JOptionPane.showMessageDialog(null, area, mLocalizer.msg("error.noWriteRightsTitle", "No write rights in settings directory"), JOptionPane.ERROR_MESSAGE); System.exit(1); } } // Load the settings Settings.loadSettings(); Locale.setDefault(new Locale(Settings.propLanguage.getString(), Settings.propCountry.getString())); if (Settings.propFirstStartDate.getDate() == null) { Settings.propFirstStartDate.setDate(Date.getCurrentDate()); } if (!createLockFile()) { updateLookAndFeel(); showTVBrowserIsAlreadyRunningMessageBox(); } String logDirectory = Settings.propLogdirectory.getString(); if (logDirectory != null) { try { File logDir = new File(logDirectory); logDir.mkdirs(); mainLogger.addHandler( new FileLoggingHandler(logDir.getAbsolutePath() + "/tvbrowser.log", createFormatter())); } catch (IOException exc) { String msg = mLocalizer.msg("error.4", "Can't create log file."); ErrorHandler.handle(msg, exc); } } else { // if no logging is configured, show WARNING or worse for normal usage, show everything for unstable versions if (TVBrowser.isStable()) { mainLogger.setLevel(Level.WARNING); } } // log warning for OpenJDK users if (!isJavaImplementationSupported()) { mainLogger.warning(SUN_JAVA_WARNING); } //Update plugin on version change if (Settings.propTVBrowserVersion.getVersion() != null && VERSION.compareTo(Settings.propTVBrowserVersion.getVersion()) > 0) { updateLookAndFeel(); updatePluginsOnVersionChange(); } // Capture unhandled exceptions //System.setErr(new PrintStream(new MonitoringErrorStream())); String timezone = Settings.propTimezone.getString(); if (timezone != null) { TimeZone.setDefault(TimeZone.getTimeZone(timezone)); } mLog.info("Using timezone " + TimeZone.getDefault().getDisplayName()); // refresh the localizers because we know the language now Localizer.emptyLocalizerCache(); mLocalizer = Localizer.getLocalizerFor(TVBrowser.class); ProgramInfo.resetLocalizer(); ReminderPlugin.resetLocalizer(); Date.resetLocalizer(); ProgramFieldType.resetLocalizer(); // Set the proxy settings updateProxySettings(); // Set the String to use for indicating the user agent in http requests System.setProperty("http.agent", MAINWINDOW_TITLE); Version tmpVer = Settings.propTVBrowserVersion.getVersion(); final Version currentVersion = tmpVer != null ? new Version(tmpVer.getMajor(), tmpVer.getMinor(), Settings.propTVBrowserVersionIsStable.getBoolean()) : tmpVer; /*TODO Create an update service for installed TV data services that doesn't * work with TV-Browser 3.0 and updates for them are known. */ if (!isTransportable() && Launch.isOsWindowsNtBranch() && currentVersion != null && currentVersion.compareTo(new Version(3, 0, true)) < 0) { String tvDataDir = Settings.propTVDataDirectory.getString().replace("/", File.separator); if (!tvDataDir.startsWith(System.getenv("appdata"))) { StringBuilder oldDefaultTvDataDir = new StringBuilder(System.getProperty("user.home")) .append(File.separator).append("TV-Browser").append(File.separator).append("tvdata"); if (oldDefaultTvDataDir.toString().equals(tvDataDir)) { Settings.propTVDataDirectory.setString(Settings.propTVDataDirectory.getDefault()); } } } Settings.propTVBrowserVersion.setVersion(VERSION); Settings.propTVBrowserVersionIsStable.setBoolean(VERSION.isStable()); final Splash splash; if (mShowSplashScreen && Settings.propSplashShow.getBoolean()) { splash = new SplashScreen(Settings.propSplashImage.getString(), Settings.propSplashTextPosX.getInt(), Settings.propSplashTextPosY.getInt(), Settings.propSplashForegroundColor.getColor()); } else { splash = new DummySplash(); } splash.showSplash(); /* Initialize the MarkedProgramsList */ MarkedProgramsList.getInstance(); /*Maybe there are tvdataservices to install (.jar.inst files)*/ PluginLoader.getInstance().installPendingPlugins(); PluginLoader.getInstance().loadAllPlugins(); mLog.info("Loading TV listings service..."); splash.setMessage(mLocalizer.msg("splash.dataService", "Loading TV listings service...")); TvDataServiceProxyManager.getInstance().init(); ChannelList.createForTvBrowserStart(); ChannelList.initSubscribedChannels(); if (!lookAndFeelInitialized) { mLog.info("Loading Look&Feel..."); splash.setMessage(mLocalizer.msg("splash.laf", "Loading look and feel...")); updateLookAndFeel(); } mLog.info("Loading plugins..."); splash.setMessage(mLocalizer.msg("splash.plugins", "Loading plugins...")); try { PluginProxyManager.getInstance().init(); } catch (TvBrowserException exc) { ErrorHandler.handle(exc); } splash.setMessage(mLocalizer.msg("splash.tvData", "Checking TV database...")); mLog.info("Checking TV listings inventory..."); TvDataBase.getInstance().checkTvDataInventory(); mLog.info("Starting up..."); splash.setMessage(mLocalizer.msg("splash.ui", "Starting up...")); Toolkit.getDefaultToolkit().getSystemEventQueue().push(new TextComponentPopupEventQueue()); // Init the UI final boolean fStartMinimized = Settings.propMinimizeAfterStartup.getBoolean() || mMinimized; SwingUtilities.invokeLater(new Runnable() { public void run() { initUi(splash, fStartMinimized); new Thread("Start finished callbacks") { public void run() { setPriority(Thread.MIN_PRIORITY); mLog.info("Deleting expired TV listings..."); TvDataBase.getInstance().deleteExpiredFiles(1, false); // first reset "starting" flag of mainframe mainFrame.handleTvBrowserStartFinished(); // initialize program info for fast reaction to program table click ProgramInfo.getInstance().handleTvBrowserStartFinished(); // load reminders and favorites ReminderPlugin.getInstance().handleTvBrowserStartFinished(); FavoritesPlugin.getInstance().handleTvBrowserStartFinished(); // now handle all plugins and services GlobalPluginProgramFormatingManager.getInstance(); PluginProxyManager.getInstance().fireTvBrowserStartFinished(); TvDataServiceProxyManager.getInstance().fireTvBrowserStartFinished(); // finally submit plugin caused updates to database TvDataBase.getInstance().handleTvBrowserStartFinished(); startPeriodicSaveSettings(); } }.start(); SwingUtilities.invokeLater(new Runnable() { public void run() { ChannelList.completeChannelLoading(); initializeAutomaticDownload(); if (Launch.isOsWindowsNtBranch()) { try { RegistryKey desktopSettings = new RegistryKey(RootKey.HKEY_CURRENT_USER, "Control Panel\\Desktop"); RegistryValue autoEnd = desktopSettings.getValue("AutoEndTasks"); if (autoEnd.getData().equals("1")) { RegistryValue killWait = desktopSettings.getValue("WaitToKillAppTimeout"); int i = Integer.parseInt(killWait.getData().toString()); if (i < 5000) { JOptionPane pane = new JOptionPane(); String cancel = mLocalizer.msg("registryCancel", "Close TV-Browser"); String dontDoIt = mLocalizer.msg("registryJumpOver", "Not this time"); pane.setOptions(new String[] { Localizer.getLocalization(Localizer.I18N_OK), dontDoIt, cancel }); pane.setOptionType(JOptionPane.YES_NO_CANCEL_OPTION); pane.setMessageType(JOptionPane.WARNING_MESSAGE); pane.setMessage(mLocalizer.msg("registryWarning", "The fast shutdown of Windows is activated.\nThe timeout to wait for before Windows is closing an application is too short,\nto give TV-Browser enough time to save all settings.\n\nThe setting hasn't the default value. It was changed by a tool or by you.\nTV-Browser will now try to change the timeout.\n\nIf you don't want to change this timeout select 'Not this time' or 'Close TV-Browser'.")); pane.setInitialValue(mLocalizer.msg("registryCancel", "Close TV-Browser")); JDialog d = pane.createDialog(UiUtilities.getLastModalChildOf(mainFrame), UIManager.getString("OptionPane.messageDialogTitle")); d.setModal(true); UiUtilities.centerAndShow(d); if (pane.getValue() == null || pane.getValue().equals(cancel)) { mainFrame.quit(); } else if (!pane.getValue().equals(dontDoIt)) { try { killWait.setData("5000"); desktopSettings.setValue(killWait); JOptionPane.showMessageDialog( UiUtilities.getLastModalChildOf(mainFrame), mLocalizer.msg("registryChanged", "The timeout was changed successfully.\nPlease reboot Windows!")); } catch (Exception registySetting) { JOptionPane.showMessageDialog( UiUtilities.getLastModalChildOf(mainFrame), mLocalizer.msg("registryNotChanged", "<html>The Registry value couldn't be changed. Maybe you haven't the right to do it.<br>If it is so contact you Administrator and let him do it for you.<br><br><b><Attention:/b> The following description is for experts. If you change or delete the wrong value in the Registry you could destroy your Windows installation.<br><br>To get no warning on TV-Browser start the Registry value <b>WaitToKillAppTimeout</b> in the Registry path<br><b>HKEY_CURRENT_USER\\Control Panel\\Desktop</b> have to be at least <b>5000</b> or the value for <b>AutoEndTasks</b> in the same path have to be <b>0</b>.</html>"), Localizer.getLocalization(Localizer.I18N_ERROR), JOptionPane.ERROR_MESSAGE); } } } } } catch (Throwable registry) { } } if (currentVersion != null && currentVersion.compareTo(new Version(2, 71, false)) < 0) { if (Settings.propProgramPanelMarkedMinPriorityColor.getColor() .equals(Settings.propProgramPanelMarkedMinPriorityColor.getDefaultColor())) { Settings.propProgramPanelMarkedMinPriorityColor.setColor(new Color(255, 0, 0, 30)); } if (Settings.propProgramPanelMarkedMediumPriorityColor.getColor() .equals(Settings.propProgramPanelMarkedMediumPriorityColor.getDefaultColor())) { Settings.propProgramPanelMarkedMediumPriorityColor .setColor(new Color(140, 255, 0, 60)); } if (Settings.propProgramPanelMarkedHigherMediumPriorityColor.getColor().equals( Settings.propProgramPanelMarkedHigherMediumPriorityColor.getDefaultColor())) { Settings.propProgramPanelMarkedHigherMediumPriorityColor .setColor(new Color(255, 255, 0, 60)); } if (Settings.propProgramPanelMarkedMaxPriorityColor.getColor() .equals(Settings.propProgramPanelMarkedMaxPriorityColor.getDefaultColor())) { Settings.propProgramPanelMarkedMaxPriorityColor .setColor(new Color(255, 180, 0, 110)); } } // check if user should select picture settings if (currentVersion != null && currentVersion.compareTo(new Version(2, 22)) < 0) { TvBrowserPictureSettingsUpdateDialog.createAndShow(mainFrame); } else if (currentVersion != null && currentVersion.compareTo(new Version(2, 51, true)) < 0) { Settings.propAcceptedLicenseArrForServiceIds.setStringArray(new String[0]); } if (currentVersion != null && currentVersion.compareTo(new Version(2, 60, true)) < 0) { int startOfDay = Settings.propProgramTableStartOfDay.getInt(); int endOfDay = Settings.propProgramTableEndOfDay.getInt(); if (endOfDay - startOfDay < -1) { Settings.propProgramTableEndOfDay.setInt(startOfDay); JOptionPane.showMessageDialog(UiUtilities.getLastModalChildOf(mainFrame), mLocalizer.msg("timeInfoText", "The time range of the program table was corrected because the defined day was shorter than 24 hours.\n\nIf the program table should show less than 24h use a time filter for that. That time filter can be selected\nto be the default filter by selecting it in the filter settings and pressing on the button 'Default'."), mLocalizer.msg("timeInfoTitle", "Times corrected"), JOptionPane.INFORMATION_MESSAGE); Settings.handleChangedSettings(); } } MainFrame.getInstance().getProgramTableScrollPane().requestFocusInWindow(); } }); } }); // register the shutdown hook Runtime.getRuntime().addShutdownHook(new Thread("Shutdown hook") { public void run() { deleteLockFile(); MainFrame.getInstance().quit(false); } }); }
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); info.setUndecorated(true);/* w ww .jav a 2 s.c o m*/ 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); } }
From source file:util.ui.UiUtilities.java
/** * @param parent//from w w w . j a va 2 s. c o m * A component in the component tree where the dialog should be * created for. * @param modal * Should the new dialog be modal? * @return A new JDialog. */ public static JDialog createDialog(Component parent, boolean modal) { Window parentWin = getBestDialogParent(parent); final JDialog result = new JDialog(parentWin); result.setModal(modal); return result; }
From source file:Widgets.Simulation.java
public Simulation(final JFrame aFrame, NetworkElement item) { super(aFrame); grn = ((DynamicalModelElement) item).getGeneNetwork(); plot = new Plot2DPanel(); //closing listener this.addWindowListener(new WindowAdapter() { @Override//from w w w .j a v a 2 s.c o m public void windowClosing(WindowEvent windowEvent) { if (simulation != null && simulation.myThread_.isAlive()) { simulation.stop(); System.out.print("Simulation is canceled.\n"); JOptionPane.showMessageDialog(new Frame(), "Simulation is canceled.", "Warning!", JOptionPane.INFORMATION_MESSAGE); } escapeAction(); } }); // Model model_.setModel(new DefaultComboBoxModel(new String[] { "Deterministic Model (ODEs)", "Stochastic Model (SDEs)", "Stochastic Simulation (Gillespie Algorithm)" })); model_.setSelectedIndex(0); setModelAction(); //set plot part //display result if (grn.getTimeScale().size() >= 1) { //update parameters numTimeSeries_.setValue(grn.getTraj_itsValue()); tmax_.setValue(grn.getTraj_maxTime()); sdeDiffusionCoeff_.setValue(grn.getTraj_noise()); if (grn.getTraj_model().equals("ode")) model_.setSelectedIndex(0); else if (grn.getTraj_model().equals("sde")) model_.setSelectedIndex(1); else model_.setSelectedIndex(2); //update plot trajPlot.removeAll(); trajPlot.add(trajectoryTabb()); trajPlot.updateUI(); trajPlot.setVisible(true); trajPlot.repaint(); analyzeResult.setVisible(true); } /** * ACTIONS */ model_.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent arg0) { setModelAction(); } }); analyzeResult.addActionListener(new ActionListener() { public void actionPerformed(final ActionEvent arg0) { final JDialog a = new JDialog(); a.setSize(new Dimension(500, 450)); a.setModal(true); a.setTitle("Gene List (seperated by ';')"); a.setLocationRelativeTo(null); final JTextArea focusGenesArea = new JTextArea(); focusGenesArea.setLineWrap(true); focusGenesArea.setEditable(false); focusGenesArea.setRows(3); String geneNames = ""; for (int i = 0; i < grn.getNodes().size(); i++) geneNames += grn.getNodes().get(i).getLabel() + ";"; focusGenesArea.setText(geneNames); JButton submitButton = new JButton("Submit"); JButton cancelButton = new JButton("Cancel"); JPanel buttonPanel = new JPanel(); buttonPanel.setLayout(new BoxLayout(buttonPanel, BoxLayout.X_AXIS)); buttonPanel.add(submitButton); buttonPanel.add(cancelButton); cancelButton.addActionListener(new ActionListener() { public void actionPerformed(final ActionEvent arg0) { a.dispose(); } }); submitButton.addActionListener(new ActionListener() { public void actionPerformed(final ActionEvent arg0) { a.dispose(); final JDialog a = new JDialog(); a.setSize(new Dimension(500, 450)); a.setModal(true); a.setTitle("Statistics"); a.setLocationRelativeTo(null); if (grn.getTimeSeries().isEmpty()) { JOptionPane.showMessageDialog(new Frame(), "Please run the simulation first.", "Warning!", JOptionPane.INFORMATION_MESSAGE); } else { JPanel infoPanel = new JPanel(); infoPanel.setLayout(new BorderLayout()); //output String[] focusGenes = focusGenesArea.getText().split(";"); ; String content = ""; //discrete the final state int dimension = grn.getNodes().size(); //get gene index int[] focus_index = new int[focusGenes.length]; for (int j = 0; j < focusGenes.length; j++) for (int i = 0; i < dimension; i++) if (grn.getNode(i).getLabel().equals(focusGenes[j])) focus_index[j] = i; JScrollPane jsp = new JScrollPane(); //calculate steady states grn.setLand_itsValue((Integer) numTimeSeries_.getModel().getValue()); int[] isConverge = new int[grn.getTraj_itsValue()]; String out = calculateSteadyStates(focusGenes, focus_index, isConverge); //show the convergence final JDialog ifconvergent = new JDialog(); ifconvergent.setSize(new Dimension(500, 450)); ifconvergent.setModal(true); ifconvergent.setTitle("Convergence"); ifconvergent.setLocationRelativeTo(null); ConvergenceTable tablePanel = new ConvergenceTable(isConverge); JButton continueButton = new JButton("Click to check the attractors."); continueButton.addActionListener(new ActionListener() { public void actionPerformed(final ActionEvent arg0) { ifconvergent.dispose(); } }); JPanel ifconvergentPanel = new JPanel(); ifconvergentPanel.setLayout(new BorderLayout()); ifconvergentPanel.add(tablePanel, BorderLayout.NORTH); ifconvergentPanel.add(continueButton, BorderLayout.SOUTH); ifconvergent.add(ifconvergentPanel); ifconvergent.setVisible(true); //show attractors if (out.equals("ok")) { AttractorTable panel = new AttractorTable(grn, focusGenes); jsp.setViewportView(panel); } else if (grn.getSumPara().size() == 0) content += "Cannot find a steady state!"; else content += "\nI dont know why!"; if (content != "") { JLabel warningLabel = new JLabel(); warningLabel.setText(content); jsp.setViewportView(warningLabel); } grn.setSumPara(null); grn.setCounts(null); //jsp.setPreferredSize(new Dimension(280,130)); jsp.setVerticalScrollBarPolicy(ScrollPaneConstants.VERTICAL_SCROLLBAR_AS_NEEDED); jsp.setHorizontalScrollBarPolicy(ScrollPaneConstants.HORIZONTAL_SCROLLBAR_AS_NEEDED); infoPanel.add(jsp, BorderLayout.CENTER); a.add(infoPanel); a.setVisible(true); } //end of else } }); JPanel options3 = new JPanel(); options3.setLayout(new BorderLayout()); options3.add(focusGenesArea, BorderLayout.NORTH); options3.add(buttonPanel); options3.setBorder(new EmptyBorder(5, 0, 5, 0)); a.add(options3); a.setVisible(true); } }); runButton_.addActionListener(new ActionListener() { public void actionPerformed(final ActionEvent arg0) { //System.out.print("Memory start: "+s_runtime.totalMemory()+"\n"); enterAction(); } }); cancelButton_.addActionListener(new ActionListener() { public void actionPerformed(final ActionEvent arg0) { if (simulation != null) simulation.stop(); System.out.print("Simulation is canceled!\n"); } }); fixButton.addActionListener(new ActionListener() { public void actionPerformed(final ActionEvent arg0) { JDialog a = new JDialog(); a.setTitle("Fixed initial values"); a.setSize(new Dimension(400, 400)); a.setLocationRelativeTo(null); JPanel speciesPanel = new JPanel(); String[] columnName = { "Name", "InitialValue" }; boolean editable = false; //false; new SpeciesTable(speciesPanel, columnName, grn, editable); /** LAYOUT **/ JPanel wholePanel = new JPanel(); wholePanel.setLayout(new BoxLayout(wholePanel, BoxLayout.Y_AXIS)); wholePanel.add(speciesPanel); a.add(wholePanel); a.setModal(true); a.setVisible(true); } }); randomButton.addActionListener(new ActionListener() { public void actionPerformed(final ActionEvent arg0) { final JDialog a = new JDialog(); a.setTitle("Set boundaries"); a.setSize(new Dimension(300, 200)); a.setModal(true); a.setLocationRelativeTo(null); JPanel upPanel = new JPanel(); JLabel upLabel = new JLabel("Input the upper boundary: "); final JTextField upValue = new JTextField("3"); upPanel.setLayout(new BoxLayout(upPanel, BoxLayout.X_AXIS)); upPanel.add(upLabel); upPanel.add(upValue); JPanel lowPanel = new JPanel(); JLabel lowLabel = new JLabel("Input the lower boundary: "); final JTextField lowValue = new JTextField("0"); lowPanel.setLayout(new BoxLayout(lowPanel, BoxLayout.X_AXIS)); lowPanel.add(lowLabel); lowPanel.add(lowValue); JPanel buttonPanel = new JPanel(); JButton submit = new JButton("Submit"); JButton cancel = new JButton("Cancel"); buttonPanel.setLayout(new BoxLayout(buttonPanel, BoxLayout.X_AXIS)); buttonPanel.add(submit); buttonPanel.add(cancel); buttonPanel.setBorder(new EmptyBorder(5, 5, 5, 5)); submit.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { if (upValue.getText().equals("")) JOptionPane.showMessageDialog(null, "Please input upper boundary", "Error", JOptionPane.ERROR_MESSAGE); else { try { upbound = Double.parseDouble(upValue.getText()); if (lowValue.getText().equals("")) JOptionPane.showMessageDialog(null, "Please input lower boundary", "Error", JOptionPane.ERROR_MESSAGE); else { try { lowbound = Double.parseDouble(lowValue.getText()); if (upbound < lowbound) JOptionPane.showMessageDialog(null, "Upper boundary should be not less than lower boundary", "Error", JOptionPane.ERROR_MESSAGE); else a.dispose(); } catch (Exception er) { JOptionPane.showMessageDialog(null, "Invalid value", "Error", JOptionPane.INFORMATION_MESSAGE); MsgManager.Messages.errorMessage(er, "Error", ""); } } } catch (Exception er) { JOptionPane.showMessageDialog(null, "Invalid value", "Error", JOptionPane.INFORMATION_MESSAGE); MsgManager.Messages.errorMessage(er, "Error", ""); } } } }); cancel.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { JOptionPane.showMessageDialog(null, "The default values are used!", "", JOptionPane.INFORMATION_MESSAGE); a.dispose(); } }); JPanel wholePanel = new JPanel(); wholePanel.setLayout(new BoxLayout(wholePanel, BoxLayout.Y_AXIS)); wholePanel.add(upPanel); wholePanel.add(lowPanel); wholePanel.add(buttonPanel); wholePanel.setBorder(new EmptyBorder(5, 5, 5, 5)); a.add(wholePanel); a.setVisible(true); } }); }