List of usage examples for javax.swing JOptionPane WARNING_MESSAGE
int WARNING_MESSAGE
To view the source code for javax.swing JOptionPane WARNING_MESSAGE.
Click Source Link
From source file:ca.uviccscu.lp.server.main.ShutdownListener.java
@Override public void windowClosing(WindowEvent e) { if (Shared.hashInProgress) { JOptionPane.showMessageDialog(null, "Closing not allowed - stop or finish hashing first!", "Hash in progress!", JOptionPane.WARNING_MESSAGE); } else {/*from w w w .java 2 s. c om*/ SwingWorker worker = new SwingWorker<Void, Void>() { @Override public Void doInBackground() { try { int ans1 = JOptionPane.showConfirmDialog(null, "Are you sure you want to shutdown? " + "Clients will switch to passive mode until restarted.", "Confirmation", JOptionPane.OK_CANCEL_OPTION, JOptionPane.QUESTION_MESSAGE); if (ans1 == JOptionPane.OK_OPTION) { l.debug("MainFrame window closing requested"); MainFrame.lockInterface(); MainFrame.setReportingActive(); MainFrame.updateTask("Shutting down", true); MainFrame.updateProgressBar(0, 0, 0, "Shutting down settings manager!", true, true); l.trace("Shutting down settings manager and saving session"); int ans2 = JOptionPane.showConfirmDialog(null, "Do you want to save the games list", "Save confirmation", JOptionPane.OK_CANCEL_OPTION, JOptionPane.QUESTION_MESSAGE); if (ans2 == JOptionPane.OK_OPTION) { SettingsManager.showSaveSettingsDialog(); } SettingsManager.shutdown(); l.trace("OK"); l.trace("Stopping net manager"); MainFrame.updateProgressBar(0, 0, 0, "Shutting down net manager!", true, true); ServerNetManager.shutdown(); l.trace("OK"); l.trace("Shutting down tracker manager - might have errors here!"); MainFrame.updateProgressBar(0, 0, 0, "Shutting down azureus - might take a while!", true, true); //Errors due to Azureus stupid shutdown thread killing routine(see AzureusCoreImpl) //Basically it kills all other threads it doesnt recognise on JVM and then terminates //Not designed to work with other application, and so it also kills the shutdown thread = BAD //Library modified to prevent system shutdown, but exceptions still coming - irrelevant TrackerManager.shutdown(); Thread.yield(); l.trace("OK"); Thread.yield(); Thread.sleep(5000); while (!Shared.azShutdownDone) { try { l.trace("Awaiting az shutdown"); Thread.sleep(500); } catch (InterruptedException ex) { l.error("Az shutdown monitor interrupted", ex); } } MainFrame.updateProgressBar(0, 0, 0, "Cleaning temporary files - might take a while!", true, true); File f = new File(Shared.workingDirectory); /* //delete until files unlocked or timeout if (!deleteFolder(f, true, 3000, 15000)) { l.trace("Advanced file deletion measures required"); releaseLocks(); deleteFolder(f, false, 0, 0); //Advanced thread killing, stolen from azureus...except now it kills itself l.error("Delete timeout - attempting threadicide"); l.trace("Starting thread killing"); //First kill azureus SM - allows to do whatever we want with threads l.trace("Removed SM"); System.setSecurityManager(null); // ThreadGroup tg = Thread.currentThread().getThreadGroup(); while (tg.getParent() != null) { tg = tg.getParent(); } Thread[] threads = new Thread[tg.activeCount() + 1024]; tg.enumerate(threads, true); //VERY BAD WAY TO STOP THREAD BUT NO CHOICE - need to release the file locks for (int i = 0; i < threads.length; i++) { Thread th = threads[i]; if (th != null && th != Thread.currentThread() && AEThread2.isOurThread(th)) { l.trace("Stopping " + th.getName()); try { th.stop(); l.trace("ok"); } catch (SecurityException e) { l.trace("Stop vetoed by SM", e); } } } // deleteFolder(f, false, 0, 0); l.error("Trying to stop more threads, list:"); //List remaining threads ThreadGroup tg2 = Thread.currentThread().getThreadGroup(); while (tg2.getParent() != null) { tg2 = tg2.getParent(); } //Object o = new Object(); //o.notifyAll(); Thread[] threads2 = new Thread[tg2.activeCount() + 1024]; tg2.enumerate(threads2, true); //VERY BAD WAY TO STOP THREAD BUT NO CHOICE - need to release the file locks for (int i = 0; i < threads2.length; i++) { Thread th = threads2[i]; if (th != null) { l.trace("Have thread: " + th.getName()); if (th != null && th != Thread.currentThread() && (AEThread2.isOurThread(th) || isAzThread(th))) { l.trace("Stopping " + th.getName()); try { th.stop(); l.trace("ok"); } catch (SecurityException e) { l.trace("Stop vetoed by SM", e); } } } } try { Utils.cleanupDir(); l.trace("OK"); } catch (IOException e) { l.trace("Cleaning failed after more thread cleanup", e); Thread.yield(); } threadCleanup(f); l.error("Last resort - scheduling delete on JVM exit - might FAIL, CHECK MANUALLY"); try { FileUtils.forceDeleteOnExit(f); } catch (IOException iOException) { l.fatal("All delete attempts failed - clean manually"); } } File test = new File("C:\\AZTest\\AZ\\logs\\debug_1.log"); test.deleteOnExit(); try { Thread.sleep(30000); } catch (InterruptedException ex) { java.util.logging.Logger.getLogger(ShutdownListener.class.getName()).log(Level.SEVERE, null, ex); } * */ threadReadout(); try { Utils.cleanupDir(); l.trace("OK"); } catch (IOException e) { l.trace("Cleaning failed - expected due to stupid Azureus file lock", e); Thread.yield(); } System.exit(0); return null; } else { return null; } } catch (Exception ex) { l.fatal("Exception during shutdown!!!", ex); //just end it System.exit(4); return null; } } }; worker.execute(); } }
From source file:com.bsoft.baseframe.baseframe_utils.beanUtils.Classgenerator.java
/** * ?/*from ww w . jav a 2s . co m*/ * @param e * @return int */ private int clickSaveBtn(ActionEvent e) { int msg_code = 0; //? if (!validateText()) { JOptionPane.showMessageDialog(this, msg, "", JOptionPane.WARNING_MESSAGE); return msg_code; } String tbName = _tb.getText().trim(), stPath = _stb.getText().trim(), ibtsPath = _ibatis.getText().trim(), svcPath = _sv.getText().trim(); //?bean String filePath = FileUtils.getFilePathName(tbName, stPath); CreateBeanFile createFile = new CreateBeanFile(stPath, tbName); String fileCode = createFile.createBeanCode(); if (StringUtils.isBlank(fileCode)) { msg_code = 1; return msg_code; } if (!FileUtils.writeData(fileCode, filePath)) { msg_code = 2; return msg_code; } //?XML String xmlPath = FileUtils.getXMLFilePath("src/main/resources", ibtsPath); CreateXMLFile xmlFile = new CreateXMLFile(tbName, stPath, xmlPath); if (!xmlFile.createXMLFile()) { msg_code = 3; return msg_code; } //?Service&ServiceImpl if (StringUtils.isNotBlank(svcPath)) { CreateServiceFile csf = new CreateServiceFile(svcPath, tbName); if (!csf.createService()) { msg_code = 4; return msg_code; } if (!csf.createServiceImpl()) { msg_code = 5; return msg_code; } } return msg_code; }
From source file:net.sf.keystore_explorer.gui.actions.ExportTrustedCertificateAction.java
/** * Do action.//from w w w .j av a2s . c o m */ @Override protected void doAction() { File exportFile = null; try { DExportCertificates dExportCertificates = null; X509Certificate cert = null; if (certFromConstructor == null) { String alias = kseFrame.getSelectedEntryAlias(); dExportCertificates = new DExportCertificates(frame, alias, false); cert = getCertificate(alias); } else { cert = certFromConstructor; dExportCertificates = new DExportCertificates(frame, X509CertUtil.getCertificateAlias(cert), false); } dExportCertificates.setLocationRelativeTo(frame); dExportCertificates.setVisible(true); if (!dExportCertificates.exportSelected()) { return; } exportFile = dExportCertificates.getExportFile(); boolean pemEncode = dExportCertificates.pemEncode(); byte[] encoded = null; if (dExportCertificates.exportFormatX509()) { if (pemEncode) { encoded = X509CertUtil.getCertEncodedX509Pem(cert).getBytes(); } else { encoded = X509CertUtil.getCertEncodedX509(cert); } } else if (dExportCertificates.exportFormatPkcs7()) { if (pemEncode) { encoded = X509CertUtil.getCertEncodedPkcs7Pem(cert).getBytes(); } else { encoded = X509CertUtil.getCertEncodedPkcs7(cert); } } else if (dExportCertificates.exportFormatPkiPath()) { encoded = X509CertUtil.getCertEncodedPkiPath(cert); } else if (dExportCertificates.exportFormatSpc()) { encoded = X509CertUtil.getCertEncodedPkcs7(cert); // SPC is just DER PKCS #7 } exportEncodedCertificate(encoded, exportFile); JOptionPane.showMessageDialog(frame, res.getString("ExportTrustedCertificateAction.ExportCertificateSuccessful.message"), res.getString("ExportTrustedCertificateAction.ExportCertificate.Title"), JOptionPane.INFORMATION_MESSAGE); } catch (FileNotFoundException ex) { String message = MessageFormat .format(res.getString("ExportTrustedCertificateAction.NoWriteFile.message"), exportFile); JOptionPane.showMessageDialog(frame, message, res.getString("ExportTrustedCertificateAction.ExportCertificate.Title"), JOptionPane.WARNING_MESSAGE); } catch (Exception ex) { DError.displayError(frame, ex); } }
From source file:me.childintime.childintime.InitialSetup.java
/** * Clean and refresh the application environment for developers. * This deletes all application files and configurations from previous versions. * This ensures that a fresh application instance is used for development. */// w w w .ja va2 s . c om private void cleanApplicationEnvironment() { // Show a status message this.progressDialog.setStatus("Confirming environment cleanup..."); // Make sure the clean environment feature is enabled if (!App.APP_CLEAN_ENVIRONMENT) return; // Show a warning if (!Arrays.asList(Core.getInstance().getStarupArgs()).contains(FLAG_HIDE_CLEAN_ENVIRONMENT_WARNING)) { // Create a list with the buttons to show in the option dialog List<String> buttons = new ArrayList<>(); buttons.add("Clean Environment"); buttons.add("Keep Environment"); // Reverse the button list if we're on a Mac OS X system if (Platform.isMacOsX()) Collections.reverse(buttons); // Show the option dialog final int option = JOptionPane.showOptionDialog(this.progressDialog, "The developer option Clean Environment is enabled.\n\n" + "Would you like to clean your application environment?\n\n" + "Cleaning the environment will delete all previous application files and configurations,\n" + "to ensure that you're using a fresh application instance for development.\n\n" + "This feature must be disabled in production.", App.APP_NAME + " - Developer mode - Environment cleanup", JOptionPane.YES_NO_OPTION, JOptionPane.WARNING_MESSAGE, null, buttons.toArray(), buttons.get(!Platform.isMacOsX() ? 0 : 1)); // Make sure the clean option is pressed if (option != (!Platform.isMacOsX() ? 0 : 1)) return; } // Show a status message this.progressDialog.setStatus("Refreshing application environment..."); // Delete the application directory try { if (App.getDirectory().exists()) FileUtils.deleteDirectory(App.getDirectory()); } catch (IOException e) { showError("Failed to refresh application environment."); e.printStackTrace(); } }
From source file:eu.asterics.mw.services.AstericsErrorHandling.java
/** * This method is used by the components to report an error. It logs the error in "warning" logger * and sets the status of the ARE to "ERROR" to denote that an error has occurred * @param component the component instance that reports the error * @param errorMsg the error message//from www. j av a2 s. com */ public void reportError(IRuntimeComponentInstance component, final String errorMsg) { if (component != null) { String componentID = DeploymentManager.instance .getIRuntimeComponentInstanceIDFromIRuntimeComponentInstance(component); if (componentID != null) { //System.out.println("componentID: "+componentID); logger.warning(componentID + ": " + errorMsg); setStatusObject(AREStatus.ERROR.toString(), componentID, errorMsg); } } AREProperties props = AREProperties.instance; if (props.checkProperty("showErrorDialogs", "1")) { SwingUtilities.invokeLater(new Runnable() { @Override public void run() { ErrorLogPane.appendLog(errorMsg); DeploymentManager.instance.setStatus(AREStatus.ERROR); AstericsErrorHandling.this.notifyAREEventListeners("onAreError", errorMsg); JOptionPane op = new JOptionPane(errorMsg, JOptionPane.WARNING_MESSAGE); JDialog dialog = op.createDialog("AsTeRICS Runtime Environment:"); dialog.setAlwaysOnTop(true); dialog.setModal(false); dialog.setDefaultCloseOperation(JDialog.DISPOSE_ON_CLOSE); dialog.setVisible(true); } }); } }
From source file:com.ln.gui.Main.java
public void swingupd() { EventQueue.invokeLater(new Runnable() { public void run() { try { String av = "Updates available!"; JOptionPane pane1 = new JOptionPane(av, JOptionPane.WARNING_MESSAGE, JOptionPane.DEFAULT_OPTION); JDialog dialog1 = pane1.createDialog("Update"); dialog1.setLocationRelativeTo(null); dialog1.setVisible(true); dialog1.setAlwaysOnTop(true); Updatechecker upd = new Updatechecker(); upd.setVisible(true);/*from ww w . java2 s . co m*/ upd.setLocationRelativeTo(rootPane); upd.setDefaultCloseOperation(DISPOSE_ON_CLOSE); } catch (Exception e) { } } }); }
From source file:net.sf.keystore_explorer.gui.actions.ExamineFileAction.java
private void openCrl(File crlFile) { if (crlFile == null) { return;//ww w . ja v a 2 s. co m } X509CRL crl = null; try { crl = X509CertUtil.loadCRL(new FileInputStream(crlFile)); } catch (FileNotFoundException ex) { JOptionPane.showMessageDialog(frame, MessageFormat.format(res.getString("ExamineFileAction.NoReadFile.message"), crlFile), res.getString("ExamineFileAction.OpenCrl.Title"), JOptionPane.WARNING_MESSAGE); } catch (Exception ex) { String problemStr = MessageFormat.format(res.getString("ExamineFileAction.NoOpenCrl.Problem"), crlFile.getName()); String[] causes = new String[] { res.getString("ExamineFileAction.NotCrl.Cause"), res.getString("ExamineFileAction.CorruptedCrl.Cause") }; Problem problem = new Problem(problemStr, causes, ex); DProblem dProblem = new DProblem(frame, res.getString("ExamineFileAction.ProblemOpeningCrl.Title"), problem); dProblem.setLocationRelativeTo(frame); dProblem.setVisible(true); } if (crl != null) { DViewCrl dViewCrl = new DViewCrl(frame, MessageFormat .format(res.getString("ExamineFileAction.CrlDetailsFile.Title"), crlFile.getName()), crl); dViewCrl.setLocationRelativeTo(frame); dViewCrl.setVisible(true); } }
From source file:net.sf.keystore_explorer.gui.actions.ExportKeyPairCertificateChainAction.java
/** * Do action.//from ww w . j a v a 2 s. c o m */ @Override protected void doAction() { File exportFile = null; try { String alias = kseFrame.getSelectedEntryAlias(); DExportCertificates dExportCertificates = new DExportCertificates(frame, alias, true); dExportCertificates.setLocationRelativeTo(frame); dExportCertificates.setVisible(true); if (!dExportCertificates.exportSelected()) { return; } exportFile = dExportCertificates.getExportFile(); boolean pemEncode = dExportCertificates.pemEncode(); boolean exportChain = dExportCertificates.exportChain(); byte[] encoded = null; if (exportChain) { X509Certificate[] certChain = getCertificateChain(alias); if (dExportCertificates.exportFormatPkcs7()) { if (pemEncode) { encoded = X509CertUtil.getCertsEncodedPkcs7Pem(certChain).getBytes(); } else { encoded = X509CertUtil.getCertsEncodedPkcs7(certChain); } } else if (dExportCertificates.exportFormatPkiPath()) { encoded = X509CertUtil.getCertsEncodedPkiPath(certChain); } else if (dExportCertificates.exportFormatSpc()) { // SPC is just DER PKCS #7 encoded = X509CertUtil.getCertsEncodedPkcs7(certChain); } } else { X509Certificate cert = getHeadCertificate(alias); if (dExportCertificates.exportFormatX509()) { if (pemEncode) { encoded = X509CertUtil.getCertEncodedX509Pem(cert).getBytes(); } else { encoded = X509CertUtil.getCertEncodedX509(cert); } } else if (dExportCertificates.exportFormatPkcs7()) { if (pemEncode) { encoded = X509CertUtil.getCertEncodedPkcs7Pem(cert).getBytes(); } else { encoded = X509CertUtil.getCertEncodedPkcs7(cert); } } else if (dExportCertificates.exportFormatPkiPath()) { encoded = X509CertUtil.getCertEncodedPkiPath(cert); } else if (dExportCertificates.exportFormatSpc()) { encoded = X509CertUtil.getCertEncodedPkcs7(cert); // SPC is just DER PKCS #7 } } exportEncodedCertificates(encoded, exportFile); JOptionPane.showMessageDialog(frame, res.getString("ExportKeyPairCertificateChainAction.ExportCertificateChainSuccessful.message"), res.getString("ExportKeyPairCertificateChainAction.ExportCertificateChain.Title"), JOptionPane.INFORMATION_MESSAGE); } catch (FileNotFoundException ex) { String message = MessageFormat .format(res.getString("ExportKeyPairCertificateChainAction.NoWriteFile.message"), exportFile); JOptionPane.showMessageDialog(frame, message, res.getString("ExportKeyPairCertificateChainAction.ExportCertificateChain.Title"), JOptionPane.WARNING_MESSAGE); } catch (Exception ex) { DError.displayError(frame, ex); } }
From source file:iics.Connection.java
public String excutePost(String targetURL, String urlParameters) { URL url;/*from w ww . java2 s. c o m*/ HttpURLConnection connection = null; try { //Create connection url = new URL(targetURL); connection = (HttpURLConnection) url.openConnection(); connection.setRequestMethod("POST"); connection.setRequestProperty("Content-Type", "application/x-www-form-urlencoded"); connection.setRequestProperty("Content-Length", "" + Integer.toString(urlParameters.getBytes().length)); connection.setRequestProperty("Content-Language", "en-US"); connection.setUseCaches(false); connection.setDoInput(true); connection.setDoOutput(true); //Send request DataOutputStream wr = new DataOutputStream(connection.getOutputStream()); wr.writeBytes(urlParameters); wr.flush(); wr.close(); //Get Response InputStream is = connection.getInputStream(); BufferedReader rd = new BufferedReader(new InputStreamReader(is)); String line; StringBuffer response = new StringBuffer(); while ((line = rd.readLine()) != null) { if (!line.equals("")) { response.append(line); } //response.append('\r'); } rd.close(); // System.out.println("gigig " + response.toString()); if (response.toString().substring(0, 8).equals("Response")) { String[] dett = response.toString().split("~~~"); det = dett[1]; create_dir(); openweb(f.toString()); } else { //System.out.println("err "+ex.getMessage()); JOptionPane.showMessageDialog(null, " An error occured!! \n Try again later or contact your system admin for help."); close_loda(); } return response.toString(); } catch (Exception e) { JOptionPane.showMessageDialog(null, " An error occured!! \n Contact your system admin for help.", null, JOptionPane.WARNING_MESSAGE); close_loda(); return null; } finally { if (connection != null) { connection.disconnect(); } } }
From source file:com.compomics.cell_coord.gui.controller.load.LoadTracksController.java
/** * Initialize the view components.//from ww w . j av a 2 s. c o m */ private void initView() { // create new view loadTracksPanel = new LoadTracksPanel(); // disable the IMPORT FILES button loadTracksPanel.getImportFilesButton().setEnabled(false); // initialize the flag to keep track of importing isImported = false; // populate the combobox with available file formats // note: these are annoatated as spring beans Set<String> parsers = TrackFileParserFactory.getInstance().getParserBeanNames(); for (String parser : parsers) { loadTracksPanel.getFileFormatComboBox().addItem(parser); } // format the table JTableHeader tracksTableHeader = loadTracksPanel.getTracksTable().getTableHeader(); tracksTableHeader.setBackground(GuiUtils.getHeaderColor()); tracksTableHeader.setFont(GuiUtils.getHeaderFont()); tracksTableHeader.setReorderingAllowed(false); /** * Action Listeners. */ // load directory loadTracksPanel.getLoadDirectoryButton().addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { if (directory == null) { chooseDirectoryAndLoadData(); } else { // otherwise we ask the user if they want to reload the directory Object[] options = { "Load a different directory", "Cancel" }; int showOptionDialog = JOptionPane.showOptionDialog(null, "It seems a directory was already loaded.\nWhat do you want to do?", "", JOptionPane.CANCEL_OPTION, JOptionPane.WARNING_MESSAGE, null, options, options[1]); switch (showOptionDialog) { case 0: // load a different directory: // reset the model of the directory tree DefaultTreeModel model = (DefaultTreeModel) loadTracksPanel.getDirectoryTree().getModel(); DefaultMutableTreeNode rootNote = (DefaultMutableTreeNode) model.getRoot(); rootNote.removeAllChildren(); model.reload(); chooseDirectoryAndLoadData(); loadTracksPanel.getChosenDirectoryTextArea().setText(directory.getAbsolutePath()); break; // cancel: do nothing } } } }); // import the selected files in the tree loadTracksPanel.getImportFilesButton().addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { // check if an import already took place if (!isImported) { // get the selected file(s) from the JTree TreePath[] selectionPaths = loadTracksPanel.getDirectoryTree().getSelectionPaths(); if (selectionPaths != null && selectionPaths.length != 0) { // at least a file was selected -- proceed with the import importFiles(); isImported = true; cellCoordController.showMessage(selectionPaths.length + " file(s) successfully imported!", "success loading", JOptionPane.INFORMATION_MESSAGE); // do basic computations preprocess(); // go to child controllers and show samples in the tables summaryDataController.showSamplesInTable(); computationMainController.showSamplesInTable(); // proceed with next step in the plugin cellCoordController.getCellCoordFrame().getNextButton().setEnabled(true); } else { // inform the user that no file was selected! cellCoordController.showMessage("You have to select at least one file!", "no files selected", JOptionPane.WARNING_MESSAGE); } } else { // an import already took place: ask for user input Object[] options = { "Load other file(s)", "Cancel" }; int showOptionDialog = JOptionPane.showOptionDialog(loadTracksPanel, "It seems some files were already loaded.\nWhat do you want to do?", "", JOptionPane.CANCEL_OPTION, JOptionPane.WARNING_MESSAGE, null, options, options[1]); switch (showOptionDialog) { case 0: // load other files // clear the sample list samples.clear(); // clear the track spot list trackSpotsBindingList.clear(); // clear the selection in the JTree loadTracksPanel.getDirectoryTree().clearSelection(); isImported = false; // inform the user they need to select other files JOptionPane.showMessageDialog(loadTracksPanel, "Please select other files", "", JOptionPane.INFORMATION_MESSAGE); break; // cancel: do nothing } } } }); // add view to parent component cellCoordController.getCellCoordFrame().getLoadTracksParentPanel().add(loadTracksPanel, gridBagConstraints); }