List of usage examples for javax.swing JOptionPane OK_OPTION
int OK_OPTION
To view the source code for javax.swing JOptionPane OK_OPTION.
Click Source Link
From source file:org.svv.acmate.gui.ACTestingPanel.java
protected void bttnCustomiseUserPassFieldsActionPerformed(ActionEvent evt) { Authentication authentication = model.getConfigModel().getAuthentication(); LoginDialog dialog = new LoginDialog(authentication.getUserFieldName(), authentication.getPasswordFieldName()); dialog.setVisible(true);/*from w ww . j av a2 s.c o m*/ if (dialog.getSelectedOption() == JOptionPane.OK_OPTION) { authentication.setUserFieldName(dialog.getUsernameParamName()); authentication.setPasswordFieldName(dialog.getPasswordParamName()); } dialog.dispose(); }
From source file:org.tinymediamanager.ui.MainWindow.java
private void checkForUpdate() { try {//from w w w .j a va 2s . co m final UpdaterTask updateWorker = new UpdaterTask(); updateWorker.addPropertyChangeListener(new PropertyChangeListener() { public void propertyChange(PropertyChangeEvent evt) { if ("state".equals(evt.getPropertyName()) && evt.getNewValue() == StateValue.DONE) { try { boolean update = updateWorker.get(); LOGGER.debug("update result was: " + update); if (update) { // we might need this somewhen... if (updateWorker.isForcedUpdate()) { LOGGER.info("Updating (forced)..."); closeTmmAndStart(Utils.getPBforTMMupdate()); return; } // show whatsnewdialog with the option to update if (StringUtils.isNotBlank(updateWorker.getChangelog())) { UpdateDialog dialog = new UpdateDialog(updateWorker.getChangelog()); dialog.setVisible(true); } else { // do the update without changelog popup int answer = JOptionPane.showConfirmDialog(null, BUNDLE.getString("tmm.update.message"), BUNDLE.getString("tmm.update.title"), JOptionPane.YES_NO_OPTION); if (answer == JOptionPane.OK_OPTION) { LOGGER.info("Updating..."); // spawn getdown and exit TMM closeTmmAndStart(Utils.getPBforTMMupdate()); } } } } catch (Exception e) { LOGGER.error("Update task failed!" + e.getMessage()); } } } }); // update task start a few secs after GUI... Timer timer = new Timer(5000, new ActionListener() { @Override public void actionPerformed(ActionEvent e) { updateWorker.execute(); } }); timer.setRepeats(false); timer.start(); } catch (Exception e) { LOGGER.error("Update task failed!" + e.getMessage()); } }
From source file:org.wso2.appserver.sample.flickr.client.FlickrServiceFrame.java
private boolean checkToken(String permNedded) { if (this.sharedSecret == null) { if (!getSharedSecret()) { return false; }//from www.j a v a 2 s .co m } if (this.token == null || !hasPerms(permNedded)) { String frob; int result = JOptionPane.showConfirmDialog(this, "<html><h2>This Program Requires authorization <br></br>before it can read or modify your photos <br></br>and data on Flickr.</h2>" + "<p>Authorization is a simple process which takes place in your <br></br>" + "web browser. When your finished return to this window <br></br>" + "to complete authorization and begin using FlickrClient.</p>" + "<p>(You must be connected to the internet in order to authorize<br></br>this program.)</p></html>", "Flickr API-Based FlickrClient", JOptionPane.INFORMATION_MESSAGE); if (result == JOptionPane.OK_OPTION) { try { frob = client.flickrAuthGetFrob(key, host, port, sharedSecret); String sig = DigestUtils .md5Hex(sharedSecret + "api_key" + key + "frob" + frob + "perms" + permNedded); openURL("http://flickr.com/services/auth/?api_key=" + key + "&perms=" + permNedded + "&frob=" + frob + "&api_sig=" + sig); result = JOptionPane.showConfirmDialog(this, "<html><h2>Return to this window after you have <br></br>" + "finished the authorization process on <br></br>" + "Flickr.com</h2>" + "<p>Once you're done, click the 'ok' button <br></br>" + "below and you can begin using FlickrClient.</p>" + "<p>(You can revoke this program's authorization at any time in your " + "account page on Flickr.com.)</p></html>", "Flickr API-Based FlickrClient", JOptionPane.INFORMATION_MESSAGE); if (result == JOptionPane.OK_OPTION) { token = client.flickrAuthGetToken(key, host, port, sharedSecret, frob); return true; } } catch (Exception e) { //todo e.printStackTrace(); } } return false; } return true; }
From source file:org.wso2.carbon.cluster.ui.ClusterWizard.java
private void populateDBWithScripts(Connection con, String dbName) throws Exception { if (!DBConnection.dbAlreadyExists(con, dbName)) { DBConnection.createDatabase(con, dbName); } else {//from ww w .java2 s .com int option = JOptionPane.showConfirmDialog(null, dbName + " DB already exists and it will be Dropped...!!! ", "Warning", JOptionPane.WARNING_MESSAGE); if (option == JOptionPane.OK_OPTION) { DBConnection.dropDatabase(con, dbName); DBConnection.createDatabase(con, dbName); } else { logMessage("ERROR :: Aborting cluster Wizard, DB Already Exists " + dbName); throw new Exception(dbName + " Already Exisits..!!!"); } } //run script file DBConnection.useDatabase(con, dbName); DBConnection.runScript(con, new File(getMgrSQLScriptFilePath())); //DBConnection.grantPermission(con, dbName, regDbUsername.getText(), regHostName.getText()); }
From source file:org.wso2.carbon.cluster.utils.FileUtils.java
public static boolean deleteProducts(String absPath, String productName) { boolean success = true; File managerFolder = new File(absPath + File.separator + ClusterConstants.PREFIX_MANAGER + productName); File workerFolder = new File(absPath + File.separator + ClusterConstants.PREFIX_WORKER + productName); try {// w ww . j ava 2s . c o m if (managerFolder.exists()) { int option = JOptionPane.showConfirmDialog(null, ClusterConstants.PREFIX_MANAGER + productName + " folder already exists and it will be replaced...!!! ", "Warning", JOptionPane.WARNING_MESSAGE); if (option == JOptionPane.OK_OPTION) { textArea.append("INFO :: Manager folder already Exists...!!! " + "\n"); textArea.append( "========================================================================" + "\n"); org.apache.commons.io.FileUtils.deleteDirectory(managerFolder); textArea.append("INFO :: Deleted manager folder " + "\n"); textArea.append( "========================================================================" + "\n"); } else { success = false; } } if (workerFolder.exists()) { int option = JOptionPane.showConfirmDialog(null, ClusterConstants.PREFIX_WORKER + productName + " folder already exists and it will be replaced...!!! ", "Warning", JOptionPane.WARNING_MESSAGE); if (option == JOptionPane.OK_OPTION) { textArea.append("INFO :: Worker folder already Exists...!!! " + "\n"); textArea.append( "========================================================================" + "\n"); org.apache.commons.io.FileUtils.deleteDirectory(workerFolder); textArea.append("INFO :: Deleted worker folder " + "\n"); textArea.append( "========================================================================" + "\n"); } else { success = false; } } } catch (Exception e) { textArea.append("ERROR :: Unable to delete folder " + e.toString() + "\n"); textArea.append("========================================================================" + "\n"); } return success; }
From source file:org.zaproxy.zap.extension.ascan.ExtensionActiveScan.java
protected void showPolicyDialog(PolicyManagerDialog parent, String name) throws ConfigurationException { ScanPolicy policy;/*ww w . j a va 2 s . c om*/ if (name != null) { policy = this.getPolicyManager().getPolicy(name); } else { policy = this.getPolicyManager().getTemplatePolicy(); } PolicyDialog dialog = new PolicyDialog(this, parent, policy); dialog.initParam(getModel().getOptionsParam()); for (AbstractParamPanel panel : policyPanels) { dialog.addPolicyPanel(panel); } int result = dialog.showDialog(true); if (result == JOptionPane.OK_OPTION) { try { getModel().getOptionsParam().getConfig().save(); } catch (ConfigurationException ce) { logger.error(ce.getMessage(), ce); getView().showWarningDialog(Constant.messages.getString("scanner.save.warning")); } } }
From source file:org.zaproxy.zap.extension.ascan.PolicyManagerDialog.java
private JButton getRemoveButton() { if (this.removeButton == null) { this.removeButton = new JButton(Constant.messages.getString("ascan.policymgr.button.remove")); this.removeButton.setEnabled(false); this.removeButton.addActionListener(new ActionListener() { @Override/*from ww w . ja v a2s . co m*/ public void actionPerformed(ActionEvent e) { String name = (String) getParamsModel().getValueAt(getParamsTable().getSelectedRow(), 0); if (name != null) { if (View.getSingleton().showConfirmDialog(PolicyManagerDialog.this, Constant.messages .getString("ascan.policymgr.warn.delete")) == JOptionPane.OK_OPTION) { extension.getPolicyManager().deletePolicy(name); policyNamesChanged(); } } } }); } return this.removeButton; }
From source file:org.zaproxy.zap.extension.autoupdate.ExtensionAutoUpdate.java
public void alertIfNewVersions() { // Kicks off a thread and pops up a window if there are new versions. // Depending on the options the user has chosen. // Only expect this to be called on startup and in desktop mode final OptionsParamCheckForUpdates options = getModel().getOptionsParam().getCheckForUpdatesParam(); if (View.isInitialised()) { if (options.isCheckOnStartUnset()) { // First time in int result = getView().showConfirmDialog(Constant.messages.getString("cfu.confirm.startCheck")); if (result == JOptionPane.OK_OPTION) { options.setCheckOnStart(true); options.setCheckAddonUpdates(true); options.setDownloadNewRelease(true); } else { options.setCheckOnStart(false); }/*w ww . j a v a 2 s . c om*/ // Save try { this.getModel().getOptionsParam().getConfig().save(); } catch (ConfigurationException ce) { logger.error(ce.getMessage(), ce); getView().showWarningDialog(Constant.messages.getString("cfu.confirm.error")); return; } } if (!options.isCheckOnStart()) { alertIfOutOfDate(false); return; } } if (!options.checkOnStart()) { // Top level option not set, dont do anything, unless already downloaded last release if (View.isInitialised() && this.getPreviousVersionInfo() != null) { ZapRelease rel = this.getPreviousVersionInfo().getZapRelease(); if (rel != null && rel.isNewerThan(this.getCurrentVersion())) { File f = new File(Constant.FOLDER_LOCAL_PLUGIN, rel.getFileName()); if (f.exists() && f.length() >= rel.getSize()) { // Already downloaded, prompt to install and exit this.promptToLaunchReleaseAndClose(rel.getVersion(), f); } } } return; } // Handle the response in a callback this.getLatestVersionInfo(this); }
From source file:org.zaproxy.zap.extension.autoupdate.ExtensionAutoUpdate.java
private void alertIfOutOfDate(boolean alwaysPrompt) { final OptionsParamCheckForUpdates options = getModel().getOptionsParam().getCheckForUpdatesParam(); Date today = new Date(); Date releaseCreated = Constant.getReleaseCreateDate(); Date lastInstallWarning = options.getDayLastInstallWarned(); int result = -1; logger.debug("Install created " + releaseCreated); if (releaseCreated != null) { // Should only be null for dev builds int daysOld = dayDiff(today, releaseCreated); logger.debug("Install is " + daysOld + " days old"); if (daysOld > 365) { // Oh no, its more than a year old! boolean setCfuOnStart = false; if (alwaysPrompt || lastInstallWarning == null || dayDiff(today, lastInstallWarning) > 30) { JCheckBox cfuOnStart = new JCheckBox(Constant.messages.getString("cfu.label.cfuonstart")); cfuOnStart.setSelected(true); String msg = Constant.messages.getString("cfu.label.oldzap"); result = View.getSingleton().showYesNoDialog(View.getSingleton().getMainFrame(), new Object[] { msg, cfuOnStart }); setCfuOnStart = cfuOnStart.isSelected(); }//from w w w.ja v a2 s. c o m options.setDayLastInstallWarned(); if (result == JOptionPane.OK_OPTION) { if (setCfuOnStart) { options.setCheckOnStart(true); } getAddOnsDialog().setVisible(true); getAddOnsDialog().checkForUpdates(); } else if (!oldZapAlertAdded) { JButton button = new JButton(Constant.messages.getString("cfu.label.outofdatezap")); button.setIcon( new ImageIcon(ExtensionAutoUpdate.class.getResource("/resource/icon/16/050.png"))); // Alert triangle button.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { alertIfOutOfDate(true); } }); View.getSingleton().getMainFrame().getMainFooterPanel().addFooterToolbarLeftComponent(button); oldZapAlertAdded = true; } return; } } Date lastChecked = options.getDayLastChecked(); Date lastUpdateWarning = options.getDayLastUpdateWarned(); Date installDate = Constant.getInstallDate(); if (installDate == null || dayDiff(today, installDate) < 90) { // Dont warn if installed in the last 3 months } else if (lastChecked == null || dayDiff(today, lastChecked) > 90) { // Not checked for updates in 3 months :( boolean setCfuOnStart = false; if (alwaysPrompt || lastUpdateWarning == null || dayDiff(today, lastUpdateWarning) > 30) { JCheckBox cfuOnStart = new JCheckBox(Constant.messages.getString("cfu.label.cfuonstart")); cfuOnStart.setSelected(true); String msg = Constant.messages.getString("cfu.label.norecentcfu"); result = View.getSingleton().showYesNoDialog(View.getSingleton().getMainFrame(), new Object[] { msg, cfuOnStart }); setCfuOnStart = cfuOnStart.isSelected(); } options.setDayLastUpdateWarned(); if (result == JOptionPane.OK_OPTION) { if (setCfuOnStart) { options.setCheckOnStart(true); } getAddOnsDialog().setVisible(true); getAddOnsDialog().checkForUpdates(); if (noCfuAlertAdded) { View.getSingleton().getMainFrame().getMainFooterPanel() .removeFooterToolbarLeftComponent(getOutOfDateButton()); } } else if (!noCfuAlertAdded) { View.getSingleton().getMainFrame().getMainFooterPanel() .addFooterToolbarLeftComponent(getOutOfDateButton()); noCfuAlertAdded = true; } } }
From source file:org.zaproxy.zap.extension.autoupdate.ExtensionAutoUpdate.java
protected void promptToLaunchReleaseAndClose(String version, File f) { int ans = View.getSingleton().showConfirmDialog(MessageFormat .format(Constant.messages.getString("cfu.confirm.launch"), version, f.getAbsolutePath())); if (ans == JOptionPane.OK_OPTION) { Control.getSingleton().exit(false, f); }//www .ja va2s. c o m }