List of usage examples for javax.swing JOptionPane QUESTION_MESSAGE
int QUESTION_MESSAGE
To view the source code for javax.swing JOptionPane QUESTION_MESSAGE.
Click Source Link
From source file:client.welcome2.java
private void SupplierAddButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_SupplierAddButtonActionPerformed int f = 0;// ww w . java 2 s . co m int h = 0; sn = SupplierContracdIDText.getText(); int ans; try { String sql = "Insert into suppliers (supplier_id,supplier_name,supplier_address,supplier_phone,supplier_email,supplier_contract_id) values(?,?,?,?,?,?)"; pst = conn.prepareStatement(sql); pst.setString(1, SupplierIDText.getText()); pst.setString(2, SupplierNameText.getText()); pst.setString(3, SupplierAddressText.getText()); pst.setString(4, SupplierPhoneText.getText()); pst.setString(5, SupplierEmailText.getText()); pst.setString(6, SupplierContracdIDText.getText()); if (SupplierUploadText.getText().isEmpty()) { ans = JOptionPane.showConfirmDialog(null, "Are You Sure You Want To Add a Supplier Without a Contract?", "Warning!", JOptionPane.YES_NO_OPTION, JOptionPane.QUESTION_MESSAGE); if (ans == 0) pst.execute(); if (ans == 1) { } } else { Path dest = Paths.get("src/SupplierContracts/" + sn + ".pdf"); Path source = Paths.get(filename_supplier); Files.copy(source, dest, StandardCopyOption.REPLACE_EXISTING); pst.execute(); } JOptionPane.showMessageDialog(null, "Supplier Has Been Added"); } catch (Exception e) { h = 1; if (SupplierIDText.getText().isEmpty()) SupplierIDText.setBackground(Color.red); else SupplierIDText.setBackground(Color.white); if (SupplierNameText.getText().isEmpty()) SupplierNameText.setBackground(Color.red); else SupplierNameText.setBackground(Color.white); if (SupplierAddressText.getText().isEmpty()) SupplierAddressText.setBackground(Color.red); else SupplierAddressText.setBackground(Color.white); if (SupplierPhoneText.getText().isEmpty()) SupplierPhoneText.setBackground(Color.red); else SupplierPhoneText.setBackground(Color.white); if (SupplierEmailText.getText().isEmpty()) SupplierEmailText.setBackground(Color.red); else SupplierEmailText.setBackground(Color.white); if (SupplierContracdIDText.getText().isEmpty()) SupplierContracdIDText.setBackground(Color.red); else SupplierContracdIDText.setBackground(Color.white); if (f != 2) { JOptionPane.showMessageDialog(null, "The Marked Fields Are Empty\n Please Fill All Fields", "Attention!", JOptionPane.ERROR_MESSAGE); } else { JOptionPane.showMessageDialog(null, e); } } if (f == 0 && h == 0) { SupplierIDText.setText(""); SupplierNameText.setText(""); SupplierAddressText.setText(""); SupplierPhoneText.setText(""); SupplierEmailText.setText(""); SupplierContracdIDText.setText(""); SupplierUploadText.setText(""); } }
From source file:com.mirth.connect.client.ui.ChannelPanel.java
private boolean handleExportGroups(List<ChannelGroup> groups) { // Populate list of groups with full channels for (ChannelGroup group : groups) { List<Channel> channels = new ArrayList<Channel>(); for (Channel channel : group.getChannels()) { ChannelStatus channelStatus = this.channelStatuses.get(channel.getId()); if (channelStatus != null) { channels.add(channelStatus.getChannel()); }/*w w w . ja va 2s . c om*/ } group.setChannels(channels); } try { // Add code template libraries to channels if necessary if (groupHasLinkedCodeTemplates(groups)) { boolean addLibraries; String exportChannelCodeTemplateLibraries = Preferences.userNodeForPackage(Mirth.class) .get("exportChannelCodeTemplateLibraries", null); if (exportChannelCodeTemplateLibraries == null) { JCheckBox alwaysChooseCheckBox = new JCheckBox( "Always choose this option by default in the future (may be changed in the Administrator settings)"); Object[] params = new Object[] { "<html>One or more channels has code template libraries linked to them.<br/>Do you wish to include these libraries in each respective channel export?</html>", alwaysChooseCheckBox }; int result = JOptionPane.showConfirmDialog(this, params, "Select an Option", JOptionPane.YES_NO_CANCEL_OPTION, JOptionPane.QUESTION_MESSAGE); if (result == JOptionPane.YES_OPTION || result == JOptionPane.NO_OPTION) { addLibraries = result == JOptionPane.YES_OPTION; if (alwaysChooseCheckBox.isSelected()) { Preferences.userNodeForPackage(Mirth.class) .putBoolean("exportChannelCodeTemplateLibraries", addLibraries); } } else { return false; } } else { addLibraries = Boolean.parseBoolean(exportChannelCodeTemplateLibraries); } if (addLibraries) { for (ChannelGroup group : groups) { for (Channel channel : group.getChannels()) { addCodeTemplateLibrariesToChannel(channel); } } } } // Update resource names for (ChannelGroup group : groups) { for (Channel channel : group.getChannels()) { addDependenciesToChannel(channel); parent.updateResourceNames(channel); } } if (groups.size() == 1) { return exportGroup(groups.iterator().next()); } else { return exportGroups(groups); } } finally { // Reset the libraries on the cached channels for (ChannelGroup group : groups) { for (Channel channel : group.getChannels()) { channel.getCodeTemplateLibraries().clear(); channel.clearDependencies(); } } } }
From source file:com.lfv.lanzius.server.LanziusServer.java
public boolean menuChoiceGroupStop(int groupId, boolean confirm) { if (isSwapping) return false; log.info("Menu: Stop group"); boolean showConfirmDialog = (groupId != 0) && confirm; // Select dialog if no group id specified if (groupId == 0) { GroupSelectDialog dlg = new GroupSelectDialog(frame, doc, "Stop group..."); groupId = dlg.showDialog();/* w w w . j a v a 2s . c o m*/ } if (groupId > 0) { Element eg = null; if (showConfirmDialog) { String name = "G/" + groupId; synchronized (doc) { eg = DomTools.getElementFromSection(doc, "GroupDefs", "id", String.valueOf(groupId)); name = DomTools.getChildText(eg, "Name", "G/" + groupId, false); } int r = JOptionPane.showConfirmDialog(frame, "Are you sure you want to stop group " + name + "?", "Stop group?", JOptionPane.YES_NO_OPTION, JOptionPane.QUESTION_MESSAGE); if (r != JOptionPane.YES_OPTION) return false; } isaStop(groupId); synchronized (doc) { if (eg == null) eg = DomTools.getElementFromSection(doc, "GroupDefs", "id", String.valueOf(groupId)); String state = DomTools.getAttributeString(eg, "state", "stopped", false); if (state.equals("started") || state.equals("paused")) { eg.setAttribute("state", "stopped"); updateTerminals(ALL, groupId); updateView(); ServerLogger logger = loggerMap.get(groupId); if (logger != null) { logger.print("GROUP STOP id[" + groupId + "]"); loggerMap.remove(groupId); logger.close(); } return true; } else { if (confirm) { JOptionPane.showMessageDialog(frame, "Group is already stopped!", "Info!", JOptionPane.INFORMATION_MESSAGE); } } } } return false; }
From source file:fi.hoski.remote.ui.Admin.java
private AnyDataObject chooseMember(String title) { // search a member String[] columns = Member.MODEL.getProperties(); String lastName = JOptionPane.showInputDialog(panel, TextUtil.getText(Member.SUKUNIMI) + "?", title, JOptionPane.QUESTION_MESSAGE); if (lastName == null) { return null; }/* ww w. ja va2 s . co m*/ lastName = Utils.convertName(lastName); List<AnyDataObject> memberList = dss.retrieve(Member.KIND, Member.SUKUNIMI, lastName, columns); DataObjectChooser<AnyDataObject> ec = new DataObjectChooser<AnyDataObject>(Member.MODEL, memberList, title, "CHOOSE"); ec.setSelectionMode(ListSelectionModel.SINGLE_SELECTION); List<AnyDataObject> selected = ec.choose(); if (selected != null && selected.size() == 1) { return selected.get(0); } else { return null; } }
From source file:JNLPAppletLauncher.java
private void updateDeploymentPropertiesImpl() { String userHome = System.getProperty("user.home"); File dontAskFile = new File(userHome + File.separator + ".jnlp-applet" + File.separator + DONT_ASK); if (dontAskFile.exists()) return; // User asked us not to prompt again int option = 0; if (!getBooleanParameter("noddraw.check.silent")) { option = JOptionPane.showOptionDialog(null, "For best robustness of OpenGL applets on Windows,\n" + "we recommend disabling Java2D's use of DirectDraw.\n" + "This setting will affect all applets, but is unlikely\n" + "to slow other applets down significantly. May we update\n" + "your deployment.properties to turn off DirectDraw for\n" + "applets? You can change this back later if necessary\n" + "using the Java Control Panel, Java tab, under Java\n" + "Applet Runtime Settings.", "Update deployment.properties?", JOptionPane.YES_NO_CANCEL_OPTION, JOptionPane.QUESTION_MESSAGE, null, new Object[] { "Yes", "No", "No, Don't Ask Again" }, "Yes"); }/* w ww. ja v a2 s . co m*/ if (option < 0 || option == 1) return; // No if (option == 2) { try { dontAskFile.createNewFile(); } catch (IOException e) { } return; // No, Don't Ask Again } try { // Must update deployment.properties File propsDir = new File(getDeploymentPropsDir()); if (!propsDir.exists()) { // Don't know what's going on or how to set this permanently return; } File propsFile = new File(propsDir, "deployment.properties"); if (!propsFile.exists()) { // Don't know what's going on or how to set this permanently return; } Properties props = new Properties(); InputStream input = new BufferedInputStream(new FileInputStream(propsFile)); props.load(input); input.close(); // Search through the keys looking for JRE versions Set/*<String>*/ jreVersions = new HashSet/*<String>*/(); for (Iterator /*<String>*/ iter = props.keySet().iterator(); iter.hasNext();) { String key = (String) iter.next(); if (key.startsWith(JRE_PREFIX)) { int idx = key.lastIndexOf("."); if (idx >= 0 && idx > JRE_PREFIX.length()) { String jreVersion = key.substring(JRE_PREFIX.length(), idx); jreVersions.add(jreVersion); } } } // Make sure the currently-running JRE shows up in this set to // avoid repeated displays of the dialog. It might not in some // upgrade scenarios where there was a pre-existing // deployment.properties and the new Java Control Panel hasn't // been run yet. jreVersions.add(System.getProperty("java.version")); // OK, now that we know all JRE versions covered by the // deployment.properties, check out the args for each and update // them for (Iterator /*<String>*/ iter = jreVersions.iterator(); iter.hasNext();) { String version = (String) iter.next(); String argKey = JRE_PREFIX + version + ".args"; String argVal = props.getProperty(argKey); if (argVal == null) { argVal = NODDRAW_PROP; } else if (argVal.indexOf(NODDRAW_PROP) < 0) { argVal = argVal + " " + NODDRAW_PROP; } props.setProperty(argKey, argVal); } OutputStream output = new BufferedOutputStream(new FileOutputStream(propsFile)); props.store(output, null); output.close(); if (!getBooleanParameter("noddraw.check.silent")) { // Tell user we're done JOptionPane.showMessageDialog(null, "For best robustness, we recommend you now exit and\n" + "restart your web browser. (Note: clicking \"OK\" will\n" + "not exit your browser.)", "Browser Restart Recommended", JOptionPane.INFORMATION_MESSAGE); } } catch (IOException e) { e.printStackTrace(); } }
From source file:edu.ku.brc.specify.tasks.WorkbenchTask.java
/** * Deletes a workbench./*from w w w .ja v a 2s.c o m*/ * @param workbench the workbench to be deleted */ protected void deleteWorkbench(final RecordSetIFace recordSet) { final Workbench workbench = loadWorkbench(recordSet); if (workbench == null) { return; } if (!UIRegistry.displayConfirm(getResourceString("WB_DELET_DS_TITLE"), String.format(getResourceString("WB_DELET_DS_MSG"), new Object[] { workbench.getName() }), getResourceString("Delete"), getResourceString("CANCEL"), JOptionPane.QUESTION_MESSAGE)) { return; } UIRegistry.writeSimpleGlassPaneMsg( String.format(getResourceString("WB_DELETING_DATASET"), new Object[] { workbench.getName() }), GLASSPANE_FONT_SIZE); final SwingWorker worker = new SwingWorker() { String backupName; @SuppressWarnings("synthetic-access") @Override public Object construct() { DataProviderSessionIFace session = DataProviderFactory.getInstance().createSession(); session.attach(workbench); UIRegistry.getStatusBar().setProgressRange(workbench.getName(), 0, workbench.getWorkbenchRows().size() + 3); UIRegistry.getStatusBar().setIndeterminate(workbench.getName(), false); //force load the workbench here instead of calling workbench.forceLoad() because //is so time-consuming and needs progress bar. workbench.getWorkbenchTemplate().checkMappings(getDatabaseSchema()); UIRegistry.getStatusBar().incrementValue(workbench.getName()); SwingUtilities.invokeLater(new Runnable() { public void run() { UIRegistry.getStatusBar().setText(String .format(UIRegistry.getResourceString("WB_PREPARING_DELETE"), workbench.getName())); } }); for (WorkbenchRow row : workbench.getWorkbenchRows()) { row.forceLoad(); UIRegistry.getStatusBar().incrementValue(workbench.getName()); } backupName = WorkbenchBackupMgr.backupWorkbench(workbench); UIRegistry.getStatusBar().incrementValue(workbench.getName()); SwingUtilities.invokeLater(new Runnable() { public void run() { UIRegistry.getStatusBar().setText( String.format(UIRegistry.getResourceString("WB_DELETING"), workbench.getName())); } }); try { // Connection conn = DBConnection.getInstance().createConnection(); // try // { // conn.setAutoCommit(false); // Statement stmt = conn.createStatement(); // try // { // stmt.execute("delete from workbenchdataitem where workbenchtemplatemappingitemid in (select workbenchtemplatemappingitemid from workbenchtemplatemappingitem where workbenchtemplateid = " // + workbench.getWorkbenchTemplate().getId() + ")"); // stmt.execute("delete from workbenchtemplatemappingitem where workbenchtemplateid = " + workbench.getWorkbenchTemplate().getId()); //Assuming 1-1 between workbenchtemplate and workbench // stmt.execute("delete from workbenchrowexportedrelationship where workbenchrowid in (select workbenchrowid from workbenchrow where workbenchid = " + workbench.getId() + ")"); // stmt.execute("delete from workbenchrowimage where workbenchrowid in(select workbenchrowid from workbenchrow where workbenchid = " + workbench.getId() + ")"); // stmt.execute("delete from workbenchrow where workbenchid = " + workbench.getId()); // stmt.execute("delete from workbench where workbenchid = " + workbench.getId()); // stmt.execute("delete from workbenchtemplate where workbenchtemplateid = " + workbench.getWorkbenchTemplate().getId()); //Assuming 1-1 between workbenchtemplate and workbench // conn.commit(); // } finally // { // stmt.close(); // conn.close(); // } // } catch (Exception ex) // { // conn.rollback(); // UsageTracker.incrHandledUsageCount(); // edu.ku.brc.exceptions.ExceptionTracker.getInstance().capture(WorkbenchTask.class, ex); // //UIRegistry.getStatusBar().setErrorMessage(ex.getLocalizedMessage(), ex); // } session.beginTransaction(); session.delete(workbench); session.commit(); session.flush(); UIRegistry.getStatusBar().incrementValue(workbench.getName()); datasetNavBoxMgr.removeWorkbench(workbench); updateNavBoxUI(null); ((SGRTask) ContextMgr.getTaskByClass(SGRTask.class)).deleteResultsForWorkbench(workbench); } catch (Exception ex) { edu.ku.brc.af.core.UsageTracker.incrHandledUsageCount(); edu.ku.brc.exceptions.ExceptionTracker.getInstance().capture(WorkbenchTask.class, ex); ex.printStackTrace(); } finally { try { session.close(); } catch (Exception ex) { edu.ku.brc.af.core.UsageTracker.incrHandledUsageCount(); edu.ku.brc.exceptions.ExceptionTracker.getInstance().capture(WorkbenchTask.class, ex); log.error(ex); } } log.info("Deleted a Workbench [" + workbench.getName() + "]"); return null; } //Runs on the event-dispatching thread. @Override public void finished() { UIRegistry.clearSimpleGlassPaneMsg(); if (StringUtils.isNotEmpty(backupName)) { UIRegistry.getStatusBar().setText(String.format(getResourceString("WB_DEL_BACKED_UP"), new Object[] { workbench.getName(), backupName })); } AppPreferences.getLocalPrefs() .remove(WorkbenchPaneSS.wbAutoValidatePrefName + "." + workbench.getId()); AppPreferences.getLocalPrefs() .remove(WorkbenchPaneSS.wbAutoMatchPrefName + "." + workbench.getId()); } }; worker.start(); }
From source file:fi.hoski.remote.ui.Admin.java
private void swapPatrolShift(AnyDataObject user) { Long memberNumber = (Long) user.get(Member.JASENNO); PatrolShift selectedShift = choosePatrolShift(user); if (selectedShift != null) { SwapRequest req = new SwapRequest(); req.set(Repository.JASENNO, user.createKey()); req.set(Repository.VUOROID, selectedShift.createKey()); req.set(Repository.PAIVA, selectedShift.get(Repository.PAIVA)); List<Long> excluded = new ArrayList<Long>(); Day day = (Day) selectedShift.get(Repository.PAIVA); excluded.add(day.getValue());/* ww w. j a va 2s .c o m*/ req.set(SwapRequest.EXCLUDE, excluded); req.set(Repository.CREATOR, creator); Object[] options = { TextUtil.getText("SWAP SHIFT"), TextUtil.getText("EXCLUDE DATE"), TextUtil.getText("DELETE PREVIOUS SWAP"), TextUtil.getText("CANCEL") }; String msg = TextUtil.getText("SWAP OPTIONS"); try { msg = dss.getShiftString(selectedShift.getEntity(), msg); } catch (EntityNotFoundException ex) { Logger.getLogger(Admin.class.getName()).log(Level.SEVERE, null, ex); } while (true) { int choise = JOptionPane.showOptionDialog(frame, msg + dateList(excluded), "", JOptionPane.YES_NO_CANCEL_OPTION, JOptionPane.QUESTION_MESSAGE, null, options, options[0]); switch (choise) { case 0: try { msg = TextUtil.getText("SWAP CONFIRMATION"); msg = dss.getShiftString(selectedShift.getEntity(), msg) + dateList(excluded); int confirm = JOptionPane.showConfirmDialog(frame, msg, TextUtil.getText("SWAP SHIFT"), JOptionPane.OK_CANCEL_OPTION); if (JOptionPane.YES_OPTION == confirm) { boolean ok = dss.swapShift(req); if (ok) { JOptionPane.showMessageDialog(frame, TextUtil.getText("SwapOk")); } else { JOptionPane.showMessageDialog(frame, TextUtil.getText("SwapPending")); } } } catch (EntityNotFoundException | IOException | SMSException | AddressException ex) { ex.printStackTrace(); JOptionPane.showMessageDialog(null, ex.getMessage()); } return; case 1: Day d = DateChooser.chooseDate(TextUtil.getText("EXCLUDE DATE"), new Day(excluded.get(excluded.size() - 1))); excluded.add(d.getValue()); break; case 2: dss.deleteSwaps(memberNumber.intValue()); return; case 3: return; } } } else { JOptionPane.showMessageDialog(frame, TextUtil.getText("NO SELECTION"), TextUtil.getText("MESSAGE"), JOptionPane.INFORMATION_MESSAGE); } }
From source file:org.jets3t.apps.cockpit.Cockpit.java
/** * Performs the real work of downloading files by comparing the download candidates against * existing files, prompting the user whether to overwrite any pre-existing file versions, * and starting {@link S3ServiceMulti#downloadObjects} where the real work is done. * *//*from w ww . j a v a 2s . co m*/ private DownloadPackage[] buildDownloadPackageList(FileComparerResults comparisonResults, Map s3DownloadObjectsMap) throws Exception { // Determine which files to download, prompting user whether to over-write existing files List objectKeysForDownload = new ArrayList(); objectKeysForDownload.addAll(comparisonResults.onlyOnServerKeys); int newFiles = comparisonResults.onlyOnServerKeys.size(); int unchangedFiles = comparisonResults.alreadySynchronisedKeys.size(); int changedFiles = comparisonResults.updatedOnClientKeys.size() + comparisonResults.updatedOnServerKeys.size(); if (unchangedFiles > 0 || changedFiles > 0) { // Ask user whether to replace existing unchanged and/or existing changed files. log.debug( "Files for download clash with existing local files, prompting user to choose which files to replace"); List options = new ArrayList(); String message = "Of the " + (newFiles + unchangedFiles + changedFiles) + " objects being downloaded:\n\n"; if (newFiles > 0) { message += newFiles + " files are new.\n\n"; options.add(DOWNLOAD_NEW_FILES_ONLY); } if (changedFiles > 0) { message += changedFiles + " files have changed.\n\n"; options.add(DOWNLOAD_NEW_AND_CHANGED_FILES); } if (unchangedFiles > 0) { message += unchangedFiles + " files already exist and are unchanged.\n\n"; options.add(DOWNLOAD_ALL_FILES); } message += "Please choose which files you wish to download:"; Object response = JOptionPane.showInputDialog(ownerFrame, message, "Replace files?", JOptionPane.QUESTION_MESSAGE, null, options.toArray(), DOWNLOAD_NEW_AND_CHANGED_FILES); if (response == null) { return null; } if (DOWNLOAD_NEW_FILES_ONLY.equals(response)) { // No change required to default objectKeysForDownload list. } else if (DOWNLOAD_ALL_FILES.equals(response)) { objectKeysForDownload.addAll(comparisonResults.updatedOnClientKeys); objectKeysForDownload.addAll(comparisonResults.updatedOnServerKeys); objectKeysForDownload.addAll(comparisonResults.alreadySynchronisedKeys); } else if (DOWNLOAD_NEW_AND_CHANGED_FILES.equals(response)) { objectKeysForDownload.addAll(comparisonResults.updatedOnClientKeys); objectKeysForDownload.addAll(comparisonResults.updatedOnServerKeys); } else { // Download cancelled. return null; } } log.debug("Downloading " + objectKeysForDownload.size() + " objects"); if (objectKeysForDownload.size() == 0) { return null; } // Create array of objects for download. S3Object[] objects = new S3Object[objectKeysForDownload.size()]; int objectIndex = 0; for (Iterator iter = objectKeysForDownload.iterator(); iter.hasNext();) { objects[objectIndex++] = (S3Object) s3DownloadObjectsMap.get(iter.next()); } Map downloadObjectsToFileMap = new HashMap(); ArrayList downloadPackageList = new ArrayList(); // Setup files to write to, creating parent directories when necessary. for (int i = 0; i < objects.length; i++) { File file = new File(downloadDirectory, objects[i].getKey()); // Encryption password must be null if no password is set. String encryptionPassword = null; if (cockpitPreferences.isEncryptionPasswordSet()) { encryptionPassword = cockpitPreferences.getEncryptionPassword(); } // Create local directories corresponding to objects flagged as dirs. if (objects[i].isDirectoryPlaceholder()) { file = new File(downloadDirectory, ObjectUtils.convertDirPlaceholderKeyNameToDirName(objects[i].getKey())); file.mkdirs(); } DownloadPackage downloadPackage = ObjectUtils.createPackageForDownload(objects[i], file, true, true, encryptionPassword); if (downloadPackage != null) { downloadObjectsToFileMap.put(objects[i].getKey(), file); downloadPackageList.add(downloadPackage); } } return (DownloadPackage[]) downloadPackageList.toArray(new DownloadPackage[downloadPackageList.size()]); }
From source file:de.huxhorn.lilith.swing.MainFrame.java
public void exit() { if (applicationPreferences.isAskingBeforeQuit()) { // yes, I hate apps that ask this question... String dialogTitle = "Exit now?"; String message = "Are you really 100% sure that you want to quit?\nPlease do yourself a favour and think about it before you answer...\nExit now?"; int result = JOptionPane.showConfirmDialog(this, message, dialogTitle, JOptionPane.OK_CANCEL_OPTION, JOptionPane.QUESTION_MESSAGE); if (JOptionPane.OK_OPTION != result) { return; }//from w w w . j a va 2 s .c om } if (logger.isInfoEnabled()) logger.info("Exiting..."); // this probably isn't necessary since jmdns registers a shutdown hook. if (senderService != null) { senderService.stop(); // if(logger.isInfoEnabled()) logger.info("Unregistering services..."); // // this can't be done in the shutdown hook... // jmDns.unregisterAllServices(); } if (applicationPreferences.isCleaningLogsOnExit()) { deleteInactiveLogs(); } applicationPreferences.setPreviousImportPath(importFileChooser.getCurrentDirectory()); applicationPreferences.setPreviousExportPath(exportFileChooser.getCurrentDirectory()); applicationPreferences.setPreviousOpenPath(openFileChooser.getCurrentDirectory()); applicationPreferences.flush(); longTaskManager.shutDown(); System.exit(0); }
From source file:org.jets3t.apps.cockpit.Cockpit.java
private S3Object[] buildUploadObjectsList(FileComparerResults comparisonResults, Map<String, String> objectKeyToFilepathMap) throws Exception { // Determine which files to upload, prompting user whether to over-write existing files List fileKeysForUpload = new ArrayList(); fileKeysForUpload.addAll(comparisonResults.onlyOnClientKeys); int newFiles = comparisonResults.onlyOnClientKeys.size(); int unchangedFiles = comparisonResults.alreadySynchronisedKeys.size(); int changedFiles = comparisonResults.updatedOnClientKeys.size() + comparisonResults.updatedOnServerKeys.size(); if (unchangedFiles > 0 || changedFiles > 0) { // Ask user whether to replace existing unchanged and/or existing changed files. log.debug(/*from www . j a v a2s. com*/ "Files for upload clash with existing S3 objects, prompting user to choose which files to replace"); List options = new ArrayList(); String message = "Of the " + objectKeyToFilepathMap.size() + " files being uploaded:\n\n"; if (newFiles > 0) { message += newFiles + " files are new.\n\n"; options.add(UPLOAD_NEW_FILES_ONLY); } if (changedFiles > 0) { message += changedFiles + " files have changed.\n\n"; options.add(UPLOAD_NEW_AND_CHANGED_FILES); } if (unchangedFiles > 0) { message += unchangedFiles + " files already exist and are unchanged.\n\n"; options.add(UPLOAD_ALL_FILES); } message += "Please choose which files you wish to upload:"; Object response = JOptionPane.showInputDialog(ownerFrame, message, "Replace files?", JOptionPane.QUESTION_MESSAGE, null, options.toArray(), UPLOAD_NEW_AND_CHANGED_FILES); if (response == null) { return null; } if (UPLOAD_NEW_FILES_ONLY.equals(response)) { // No change required to default fileKeysForUpload list. } else if (UPLOAD_ALL_FILES.equals(response)) { fileKeysForUpload.addAll(comparisonResults.updatedOnClientKeys); fileKeysForUpload.addAll(comparisonResults.updatedOnServerKeys); fileKeysForUpload.addAll(comparisonResults.alreadySynchronisedKeys); } else if (UPLOAD_NEW_AND_CHANGED_FILES.equals(response)) { fileKeysForUpload.addAll(comparisonResults.updatedOnClientKeys); fileKeysForUpload.addAll(comparisonResults.updatedOnServerKeys); } else { // Upload cancelled. stopProgressDialog(); return null; } } if (fileKeysForUpload.size() == 0) { return null; } final String[] statusText = new String[1]; statusText[0] = "Prepared 0 of " + fileKeysForUpload.size() + " files for upload"; startProgressDialog(statusText[0], "", 0, 100, null, null); long bytesToProcess = 0; for (Iterator iter = fileKeysForUpload.iterator(); iter.hasNext();) { File file = new File(objectKeyToFilepathMap.get(iter.next().toString())); bytesToProcess += file.length() * (cockpitPreferences.isUploadEncryptionActive() || cockpitPreferences.isUploadCompressionActive() ? 3 : 1); } BytesProgressWatcher progressWatcher = new BytesProgressWatcher(bytesToProcess) { @Override public void updateBytesTransferred(long byteCount) { super.updateBytesTransferred(byteCount); String detailsText = formatBytesProgressWatcherDetails(this, false); int progressValue = (int) ((double) getBytesTransferred() * 100 / getBytesToTransfer()); updateProgressDialog(statusText[0], detailsText, progressValue); } }; // Populate S3Objects representing upload files with metadata etc. final S3Object[] objects = new S3Object[fileKeysForUpload.size()]; int objectIndex = 0; for (Iterator iter = fileKeysForUpload.iterator(); iter.hasNext();) { String fileKey = iter.next().toString(); File file = new File(objectKeyToFilepathMap.get(fileKey)); S3Object newObject = ObjectUtils.createObjectForUpload(fileKey, file, (cockpitPreferences.isUploadEncryptionActive() ? encryptionUtil : null), cockpitPreferences.isUploadCompressionActive(), progressWatcher); String aclPreferenceString = cockpitPreferences.getUploadACLPermission(); if (CockpitPreferences.UPLOAD_ACL_PERMISSION_PRIVATE.equals(aclPreferenceString)) { // Objects are private by default, nothing more to do. } else if (CockpitPreferences.UPLOAD_ACL_PERMISSION_PUBLIC_READ.equals(aclPreferenceString)) { newObject.setAcl(AccessControlList.REST_CANNED_PUBLIC_READ); } else if (CockpitPreferences.UPLOAD_ACL_PERMISSION_PUBLIC_READ_WRITE.equals(aclPreferenceString)) { newObject.setAcl(AccessControlList.REST_CANNED_PUBLIC_READ_WRITE); } else { log.warn("Ignoring unrecognised upload ACL permission setting: " + aclPreferenceString); } newObject.setStorageClass(cockpitPreferences.getUploadStorageClass()); statusText[0] = "Prepared " + (objectIndex + 1) + " of " + fileKeysForUpload.size() + " files for upload"; objects[objectIndex++] = newObject; } stopProgressDialog(); return objects; }