List of usage examples for javax.swing JOptionPane showInputDialog
@SuppressWarnings("deprecation") public static Object showInputDialog(Component parentComponent, Object message, String title, int messageType, Icon icon, Object[] selectionValues, Object initialSelectionValue) throws HeadlessException
From source file:ru.apertum.qsystem.client.forms.FAdmin.java
@Action public void checkClient() { final String num = (String) JOptionPane.showInputDialog(this, getLocaleMessage("admin.action.change_priority.num.message"), getLocaleMessage("admin.action.change_priority.num.title"), 3, null, null, ""); if (num != null) { JOptionPane.showMessageDialog(this, NetCommander.checkCustomerNumber(new ServerNetProperty(), num), getLocaleMessage("admin.action.change_priority.num.title"), JOptionPane.INFORMATION_MESSAGE); }//from www . java 2s.c o m }
From source file:ru.apertum.qsystem.client.forms.FAdmin.java
@Action public void addBreakToList() { // ? ? , String breaksName = getLocaleMessage("admin.add_breaks_dialog.info"); boolean flag = true; while (flag) { breaksName = (String) JOptionPane.showInputDialog(this, getLocaleMessage("admin.add_breaks_dialog.message"), getLocaleMessage("admin.add_breaks_dialog.title"), 3, null, null, breaksName); if (breaksName == null) { return; }/*from ww w. j a va2 s. c o m*/ for (QBreaks qb : QBreaksList.getInstance().getItems()) { if (qb.getName().equalsIgnoreCase(breaksName)) { JOptionPane.showConfirmDialog(this, getLocaleMessage("admin.enter_sute_mark.err2.title"), getLocaleMessage("admin.enter_sute_mark.err1.title"), JOptionPane.DEFAULT_OPTION, JOptionPane.ERROR_MESSAGE); return; } } if ("".equals(breaksName)) { JOptionPane.showConfirmDialog(this, getLocaleMessage("admin.add_breaks_dialog.err1.message"), getLocaleMessage("admin.add_work_plan_dialog.err1.title"), JOptionPane.DEFAULT_OPTION, JOptionPane.ERROR_MESSAGE); } else if (breaksName.indexOf('\"') != -1) { JOptionPane.showConfirmDialog(this, getLocaleMessage("admin.add_breaks_dialog.err2.message"), getLocaleMessage("admin.add_work_plan_dialog.err2.title"), JOptionPane.DEFAULT_OPTION, JOptionPane.ERROR_MESSAGE); } else if (breaksName.length() > 150) { JOptionPane.showConfirmDialog(this, getLocaleMessage("admin.add_breaks_dialog.err3.message"), getLocaleMessage("admin.add_work_plan_dialog.err3.title"), JOptionPane.DEFAULT_OPTION, JOptionPane.ERROR_MESSAGE); } else { flag = false; } } QLog.l().logger().debug("? \"" + breaksName + "\""); final QBreaks item = new QBreaks(); item.setName(breaksName); QBreaksList.getInstance().addElement(item); listBreaks.setSelectedValue(item, true); }
From source file:ru.apertum.qsystem.client.forms.FAdmin.java
@Action public void setDisableService() { final TreePath selectedPath = treeServices.getSelectionPath(); if (selectedPath != null) { final QService service = (QService) selectedPath.getLastPathComponent(); final String name = (String) JOptionPane.showInputDialog(this, getLocaleMessage("admin.select_ability.message") + " \"" + service.getName() + "\"", getLocaleMessage("admin.select_ability.title"), JOptionPane.QUESTION_MESSAGE, null, new String[] { getLocaleMessage("admin.service_ability.yes"), getLocaleMessage("admin.service_ability.no") }, null);/* w w w. j a v a 2 s .c om*/ //? , if (name != null) { if (name.equalsIgnoreCase(getLocaleMessage("admin.service_ability.yes"))) { NetCommander.changeTempAvailableService(new ServerNetProperty(), service.getId(), ""); } else { final String mess = (String) JOptionPane.showInputDialog(this, getLocaleMessage("admin.ability.enter_reason"), getLocaleMessage("admin.select_ability.title"), JOptionPane.QUESTION_MESSAGE); if (mess != null) { NetCommander.changeTempAvailableService(new ServerNetProperty(), service.getId(), mess); } else { return; } } JOptionPane.showMessageDialog(this, getLocaleMessage("admin.select_ability.message") + " " + service.getName() + " \"" + name + "\"", getLocaleMessage("admin.select_ability.title"), JOptionPane.INFORMATION_MESSAGE); } } }
From source file:org.apache.jackrabbit.oak.explorer.Explorer.java
private void createAndShowGUI(final File path, boolean skipSizeCheck) throws IOException { JTextArea log = new JTextArea(5, 20); log.setMargin(new Insets(5, 5, 5, 5)); log.setLineWrap(true);/*from www.j a va 2 s . co m*/ log.setEditable(false); final NodeStoreTree treePanel = new NodeStoreTree(backend, log, skipSizeCheck); final JFrame frame = new JFrame("Explore " + path + " @head"); frame.addWindowListener(new java.awt.event.WindowAdapter() { @Override public void windowClosing(java.awt.event.WindowEvent windowEvent) { IOUtils.closeQuietly(treePanel); System.exit(0); } }); JPanel content = new JPanel(new GridBagLayout()); GridBagConstraints c = new GridBagConstraints(); c.fill = GridBagConstraints.BOTH; c.weightx = 1; c.weighty = 1; JSplitPane splitPane = new JSplitPane(JSplitPane.HORIZONTAL_SPLIT, new JScrollPane(treePanel), new JScrollPane(log)); splitPane.setDividerLocation(0.3); content.add(new JScrollPane(splitPane), c); frame.getContentPane().add(content); JMenuBar menuBar = new JMenuBar(); menuBar.setMargin(new Insets(2, 2, 2, 2)); JMenuItem menuReopen = new JMenuItem("Reopen"); menuReopen.setMnemonic(KeyEvent.VK_R); menuReopen.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent ev) { try { treePanel.reopen(); } catch (IOException e) { throw new RuntimeException(e); } } }); JMenuItem menuCompaction = new JMenuItem("Time Machine"); menuCompaction.setMnemonic(KeyEvent.VK_T); menuCompaction.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent ev) { List<String> revs = backend.readRevisions(); String s = (String) JOptionPane.showInputDialog(frame, "Revert to a specified revision", "Time Machine", JOptionPane.PLAIN_MESSAGE, null, revs.toArray(), revs.get(0)); if (s != null && treePanel.revert(s)) { frame.setTitle("Explore " + path + " @" + s); } } }); JMenuItem menuRefs = new JMenuItem("Tar File Info"); menuRefs.setMnemonic(KeyEvent.VK_I); menuRefs.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent ev) { List<String> tarFiles = new ArrayList<String>(); for (File f : path.listFiles()) { if (f.getName().endsWith(".tar")) { tarFiles.add(f.getName()); } } String s = (String) JOptionPane.showInputDialog(frame, "Choose a tar file", "Tar File Info", JOptionPane.PLAIN_MESSAGE, null, tarFiles.toArray(), tarFiles.get(0)); if (s != null) { treePanel.printTarInfo(s); } } }); JMenuItem menuSCR = new JMenuItem("Segment Refs"); menuSCR.setMnemonic(KeyEvent.VK_R); menuSCR.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent ev) { String s = JOptionPane.showInputDialog(frame, "Segment References\nUsage: <segmentId>", "Segment References", JOptionPane.PLAIN_MESSAGE); if (s != null) { treePanel.printSegmentReferences(s); } } }); JMenuItem menuDiff = new JMenuItem("SegmentNodeState diff"); menuDiff.setMnemonic(KeyEvent.VK_D); menuDiff.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent ev) { String s = JOptionPane.showInputDialog(frame, "SegmentNodeState diff\nUsage: <recordId> <recordId> [<path>]", "SegmentNodeState diff", JOptionPane.PLAIN_MESSAGE); if (s != null) { treePanel.printDiff(s); } } }); JMenuItem menuPCM = new JMenuItem("Persisted Compaction Maps"); menuPCM.setMnemonic(KeyEvent.VK_P); menuPCM.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent ev) { treePanel.printPCMInfo(); } }); menuBar.add(menuReopen); menuBar.add(new JSeparator(JSeparator.VERTICAL)); menuBar.add(menuCompaction); menuBar.add(new JSeparator(JSeparator.VERTICAL)); menuBar.add(menuRefs); menuBar.add(new JSeparator(JSeparator.VERTICAL)); menuBar.add(menuSCR); menuBar.add(new JSeparator(JSeparator.VERTICAL)); menuBar.add(menuDiff); menuBar.add(new JSeparator(JSeparator.VERTICAL)); menuBar.add(menuPCM); menuBar.add(new JSeparator(JSeparator.VERTICAL)); frame.setJMenuBar(menuBar); frame.pack(); frame.setSize(960, 720); frame.setLocationRelativeTo(null); frame.setVisible(true); }
From source file:org.apache.syncope.ide.netbeans.view.ResourceExplorerTopComponent.java
private void openMailEditor(final String name) throws IOException { String formatStr = (String) JOptionPane.showInputDialog(null, "Select File Format", "File format", JOptionPane.QUESTION_MESSAGE, null, PluginConstants.MAIL_TEMPLATE_FORMATS, MailTemplateFormat.TEXT.name()); if (StringUtils.isNotBlank(formatStr)) { MailTemplateFormat format = MailTemplateFormat.valueOf(formatStr); String type = null;/* w w w .j a va 2s. c o m*/ InputStream is = null; try { switch (format) { case HTML: type = "html"; is = (InputStream) mailTemplateManagerService.getFormat(name, MailTemplateFormat.HTML); break; case TEXT: type = "txt"; is = (InputStream) mailTemplateManagerService.getFormat(name, MailTemplateFormat.TEXT); break; default: LOG.log(Level.SEVERE, String.format("Format [%s] not supported", format)); break; } } catch (SyncopeClientException e) { LOG.log(Level.SEVERE, String.format("Unable to get [%s] mail template in [%s] format", name, format), e); if (ClientExceptionType.NotFound.equals(e.getType())) { LOG.log(Level.SEVERE, String.format("Report template in [%s] format not found, create an empty one", format)); } else { JOptionPane.showMessageDialog(null, String.format("Unable to get [%s] report template in [%s] format", name, format), "Connection Error", JOptionPane.ERROR_MESSAGE); } } catch (Exception e) { LOG.log(Level.SEVERE, String.format("Unable to get [%s] mail template in [%s] format", name, format), e); JOptionPane.showMessageDialog(null, String.format("Unable to get [%s] mail template in [%s] format", name, format), "Error", JOptionPane.ERROR_MESSAGE); } String content = is == null ? StringUtils.EMPTY : IOUtils.toString(is, encodingPattern); String mailTemplatesDirName = System.getProperty("java.io.tmpdir") + "/Templates/Mail/"; File mailTemplatesDir = new File(mailTemplatesDirName); if (!mailTemplatesDir.exists()) { mailTemplatesDir.mkdirs(); } File file = new File(mailTemplatesDirName + name + "." + type); FileWriter fw = new FileWriter(file); fw.write(content); fw.flush(); FileObject fob = FileUtil.toFileObject(file.getAbsoluteFile()); fob.setAttribute("description", "TEXT"); DataObject data = DataObject.find(fob); data.getLookup().lookup(OpenCookie.class).open(); data.addPropertyChangeListener(new PropertyChangeListener() { @Override public void propertyChange(final PropertyChangeEvent evt) { if (DataObject.PROP_MODIFIED.equals(evt.getPropertyName())) { //save item remotely LOG.info(String.format("Saving Mail template [%s]", name)); saveContent(); } } }); } }
From source file:org.apache.syncope.ide.netbeans.view.ResourceExplorerTopComponent.java
private void openReportEditor(final String name) throws IOException { String formatStr = (String) JOptionPane.showInputDialog(null, "Select File Format", "File format", JOptionPane.QUESTION_MESSAGE, null, PluginConstants.REPORT_TEMPLATE_FORMATS, ReportTemplateFormat.FO.name()); if (StringUtils.isNotBlank(formatStr)) { ReportTemplateFormat format = ReportTemplateFormat.valueOf(formatStr); InputStream is = null;//from w w w . j ava2s . c om try { switch (format) { case HTML: is = (InputStream) reportTemplateManagerService.getFormat(name, ReportTemplateFormat.HTML); break; case CSV: is = (InputStream) reportTemplateManagerService.getFormat(name, ReportTemplateFormat.CSV); break; case FO: is = (InputStream) reportTemplateManagerService.getFormat(name, ReportTemplateFormat.FO); break; default: LOG.log(Level.SEVERE, String.format("Format [%s] not supported", format)); break; } } catch (SyncopeClientException e) { LOG.log(Level.SEVERE, String.format("Unable to get [%s] report template in [%s] format", name, format), e); if (ClientExceptionType.NotFound.equals(e.getType())) { LOG.log(Level.SEVERE, String.format("Report template [%s] not found, create an empty one", name)); } else { JOptionPane.showMessageDialog(null, String.format("Unable to get [%s] report template in [%s] format", name, format), "Connection Error", JOptionPane.ERROR_MESSAGE); } } catch (Exception e) { LOG.log(Level.SEVERE, String.format("Unable to get [%s] report template in [%s] format", name, format), e); JOptionPane.showMessageDialog(null, String.format("Unable to get [%s] report template in [%s] format", name, format), "Generic Error", JOptionPane.ERROR_MESSAGE); } String content = is == null ? StringUtils.EMPTY : IOUtils.toString(is, encodingPattern); String reportTemplatesDirName = System.getProperty("java.io.tmpdir") + "/Templates/Report/"; File reportTemplatesDir = new File(reportTemplatesDirName); if (!reportTemplatesDir.exists()) { reportTemplatesDir.mkdirs(); } File file = new File(reportTemplatesDirName + name + "." + format.name().toLowerCase()); FileWriter fw = new FileWriter(file); fw.write(content); fw.flush(); FileObject fob = FileUtil.toFileObject(file.getAbsoluteFile()); DataObject data = DataObject.find(fob); data.getLookup().lookup(OpenCookie.class).open(); data.addPropertyChangeListener(new PropertyChangeListener() { @Override public void propertyChange(final PropertyChangeEvent evt) { if (DataObject.PROP_MODIFIED.equals(evt.getPropertyName())) { //save item remotely LOG.info(String.format("Saving Report template [%s]", name)); saveContent(); } } }); } }
From source file:org.apache.tika.gui.TikaGUI.java
public void actionPerformed(ActionEvent e) { String command = e.getActionCommand(); if ("openfile".equals(command)) { int rv = chooser.showOpenDialog(this); if (rv == JFileChooser.APPROVE_OPTION) { openFile(chooser.getSelectedFile()); }// w ww . j a v a2 s . c o m } else if ("openurl".equals(command)) { Object rv = JOptionPane.showInputDialog(this, "Enter the URL of the resource to be parsed:", "Open URL", JOptionPane.PLAIN_MESSAGE, null, null, ""); if (rv != null && rv.toString().length() > 0) { try { openURL(new URL(rv.toString().trim())); } catch (MalformedURLException exception) { JOptionPane.showMessageDialog(this, "The given string is not a valid URL", "Invalid URL", JOptionPane.ERROR_MESSAGE); } } } else if ("html".equals(command)) { layout.show(cards, command); } else if ("text".equals(command)) { layout.show(cards, command); } else if ("main".equals(command)) { layout.show(cards, command); } else if ("xhtml".equals(command)) { layout.show(cards, command); } else if ("metadata".equals(command)) { layout.show(cards, command); } else if ("json".equals(command)) { layout.show(cards, command); } else if ("about".equals(command)) { textDialog("About Apache Tika", TikaGUI.class.getResource("about.html")); } else if ("exit".equals(command)) { Toolkit.getDefaultToolkit().getSystemEventQueue() .postEvent(new WindowEvent(this, WindowEvent.WINDOW_CLOSING)); } }
From source file:org.colombbus.tangara.ConfigurationWindow.java
/** * This method launches a password window allowing to display the ConfigurationWindow. *//*from w ww . j a va 2s . c o m*/ private void displayPasswordWindow() { String passwordWindow = Messages.getString("ConfigurationWindow.password.window"); String enterPassword = Messages.getString("ConfigurationWindow.password.passwordMessage"); String typedPassword = (String) JOptionPane.showInputDialog(parent, enterPassword, passwordWindow, JOptionPane.PLAIN_MESSAGE, null, null, null); if (typedPassword == null) { cancelWindow = true; try { SwingUtilities.invokeAndWait(new Runnable() { @Override public void run() { exit(); } }); } catch (InterruptedException e) { LOG.warn("displayPasswordWindow", e); } catch (InvocationTargetException e) { LOG.warn("displayPasswordWindow", e); } } else if (!typedPassword.equals(password)) { String wrongPasswordTitle = Messages.getString("ConfigurationWindow.password.wrongPasswordTitle"); String wrongPasswordMessage = Messages.getString("ConfigurationWindow.password.wrongPasswordMessage"); JOptionPane.showMessageDialog(null, wrongPasswordMessage, wrongPasswordTitle, JOptionPane.WARNING_MESSAGE); displayPasswordWindow(); } }
From source file:org.eurocarbdb.application.glycoworkbench.plugin.s3.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 w w . ja v a 2 s . c o 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 (Mimetypes.MIMETYPE_JETS3T_DIRECTORY.equals(objects[i].getContentType())) { 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:org.eurocarbdb.application.glycoworkbench.plugin.s3.Cockpit.java
private S3Object[] buildUploadObjectsList(FileComparerResults comparisonResults, Map uploadingFilesMap) 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(// w ww .j a va 2 s . co m "Files for upload clash with existing S3 objects, prompting user to choose which files to replace"); List options = new ArrayList(); String message = "Of the " + uploadingFilesMap.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 = (File) uploadingFilesMap.get(iter.next().toString()); bytesToProcess += file.length() * (cockpitPreferences.isUploadEncryptionActive() || cockpitPreferences.isUploadCompressionActive() ? 3 : 1); } BytesProgressWatcher progressWatcher = new BytesProgressWatcher(bytesToProcess) { 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 = (File) uploadingFilesMap.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); } statusText[0] = "Prepared " + (objectIndex + 1) + " of " + fileKeysForUpload.size() + " files for upload"; objects[objectIndex++] = newObject; } stopProgressDialog(); return objects; }