List of usage examples for org.eclipse.jface.dialogs IDialogConstants SKIP_LABEL
String SKIP_LABEL
To view the source code for org.eclipse.jface.dialogs IDialogConstants SKIP_LABEL.
Click Source Link
From source file:com.aptana.syncing.ui.wizards.ImportConnectionsWizard.java
License:Open Source License
private int promptConflictDialog(String name, final int[] applyToAllAction) { MessageDialog dialog = new MessageDialog(getShell(), Messages.ImportConnectionsWizard_Conflict_Title, null, MessageFormat.format(Messages.ImportConnectionsWizard_Conflict_Message, name), 0, new String[] { com.aptana.ui.IDialogConstants.OVERWRITE_LABEL, IDialogConstants.SKIP_LABEL, com.aptana.ui.IDialogConstants.RENAME_LABEL }, 0) {/*from w w w . j a v a2 s. co m*/ @Override protected Control createCustomArea(Composite parent) { final Button applyToAll = new Button(parent, SWT.CHECK); GridData data = new GridData(SWT.FILL, SWT.FILL, true, true); applyToAll.setLayoutData(data); applyToAll.setText(Messages.ImportConnectionsWizard_Conflict_LBL_Apply); applyToAll.addSelectionListener(new SelectionListener() { public void widgetSelected(SelectionEvent e) { if (applyToAll.getSelection()) { applyToAllAction[0] = 0; } } public void widgetDefaultSelected(SelectionEvent e) { } }); return applyToAll; } }; int action = dialog.open(); if (applyToAllAction[0] == -1) { applyToAllAction[0] = action; } return action; }
From source file:com.bdaum.zoom.net.communities.jobs.ExportToCommunityJob.java
License:Open Source License
@SuppressWarnings("fallthrough") private void upload(ImageAttributes imageAttributes, final IProgressMonitor monitor, boolean deleteAfterTransfer) { boolean replace = false; final Shell shell = adaptable.getAdapter(Shell.class); String name = imageAttributes.getAsset().getName(); boolean single = assets.size() <= 1; String imagePath = imageAttributes.getImagePath(); File imageFile = new File(imagePath); long filesize = imageFile.length(); if (filesize > session.getAccount().getMaxFilesize()) { if (skipalloversized) return; String[] buttons = single ? new String[] { IDialogConstants.CANCEL_LABEL } : new String[] { Messages.ExportToCommunityJob_skip_all, IDialogConstants.SKIP_LABEL, IDialogConstants.CANCEL_LABEL }; final AcousticMessageDialog dialog = new AcousticMessageDialog(shell, Messages.ExportToCommunityJob_image_too_large, null, NLS.bind(Messages.ExportToCommunityJob_image_is_larger_than, name, session.getAccount().getMaxFilesize() / (1024 * 1024)), MessageDialog.QUESTION, buttons, 1); shell.getDisplay().syncExec(() -> dialog.open()); int ret = dialog.getReturnCode(); if (single) { monitor.setCanceled(true);//from w ww .j a va 2 s . c o m return; } switch (ret) { case 0: skipalloversized = true; case 1: return; case 2: monitor.setCanceled(true); return; } } else if (filesize > (session.getAccount().getTrafficLimit() - session.getAccount().getCurrentUploadUsed())) { shell.getDisplay().syncExec(new Runnable() { public void run() { AcousticMessageDialog.openWarning(shell, Messages.ExportToCommunityJob_traffic_limit_exceeded, NLS.bind(Messages.ExportToCommunityJob_the_traffic_limit_of, new Object[] { session.getAccount().getTrafficLimit() / (1024 * 1024), communityName, session.getAccount().getName() })); } }); monitor.setCanceled(true); } else { if (!uploadall) { final Date date = getUploadDate(imageAttributes); if (date != null) { if (skipall) return; if (replaceall) replace = true; else { String[] buttons = session.getAccount().isCanReplace() ? (single ? new String[] { Messages.ExportToCommunityJob_replace, Messages.ExportToCommunityJob_upload, Messages.ExportToCommunityJob_cancel } : new String[] { Messages.ExportToCommunityJob_replace_all, Messages.ExportToCommunityJob_replace, Messages.ExportToCommunityJob_upload_all, Messages.ExportToCommunityJob_upload, Messages.ExportToCommunityJob_skip_all, Messages.ExportToCommunityJob_skp, Messages.ExportToCommunityJob_cancel }) : (single ? new String[] { Messages.ExportToCommunityJob_upload, Messages.ExportToCommunityJob_cancel } : new String[] { Messages.ExportToCommunityJob_upload_all, Messages.ExportToCommunityJob_upload, Messages.ExportToCommunityJob_skip_all, Messages.ExportToCommunityJob_skp, Messages.ExportToCommunityJob_cancel }); SimpleDateFormat df = new SimpleDateFormat( Messages.ExportToCommunityJob_tracik_date_format); final AcousticMessageDialog dialog = new AcousticMessageDialog(shell, Messages.ExportToCommunityJob_image_already_uploaded, null, NLS.bind(Messages.ExportToCommunityJob_image_uploaded_at, new Object[] { name, df.format(date), communityName, session.getAccount().getName() }), MessageDialog.QUESTION, buttons, 1); shell.getDisplay().syncExec(new Runnable() { public void run() { dialog.open(); } }); int ret = dialog.getReturnCode(); if (session.getAccount().isCanReplace()) { if (single) { switch (ret) { case 0: replace = true; break; case 2: monitor.setCanceled(true); return; } } else { switch (ret) { case 0: replaceall = true; break; case 1: replace = true; break; case 2: uploadall = true; break; case 4: skipall = true; case 5: return; case 6: monitor.setCanceled(true); return; } } } else { if (single) { switch (ret) { case 1: monitor.setCanceled(true); return; } } else { switch (ret) { case 0: uploadall = true; break; case 2: skipall = true; case 3: return; case 4: monitor.setCanceled(true); return; } } } } } } if (!replace && !uploadallunsafe) { PhotoSet photoset = session.matchAlbum(imageAttributes); if (photoset != null && photoset.isUnsafe(imageAttributes)) { if (skipallunsafe) return; String[] buttons = (single ? new String[] { Messages.ExportToCommunityJob_upload, Messages.ExportToCommunityJob_cancel } : new String[] { Messages.ExportToCommunityJob_upload_all, Messages.ExportToCommunityJob_upload, Messages.ExportToCommunityJob_skip_all, Messages.ExportToCommunityJob_skp, Messages.ExportToCommunityJob_cancel }); final AcousticMessageDialog dialog = new AcousticMessageDialog(shell, Messages.ExportToCommunityJob_privacy_violated, null, NLS.bind(Messages.ExportToCommunityJob_image_classified_as_unsafe, new Object[] { name, photoset.getTitle(), communityName, session.getAccount().getName() }), MessageDialog.QUESTION, buttons, 1); shell.getDisplay().syncExec(new Runnable() { public void run() { dialog.open(); } }); int ret = dialog.getReturnCode(); if (single) { switch (ret) { case 1: monitor.setCanceled(true); return; } } else { switch (ret) { case 0: uploadallunsafe = true; break; case 2: skipallunsafe = true; case 3: return; case 4: monitor.setCanceled(true); return; } } } } new UploadJob(this, imageAttributes, replace, deleteAfterTransfer).schedule(); } }
From source file:com.bdaum.zoom.net.core.ftp.FtpAccount.java
License:Apache License
@SuppressWarnings("fallthrough") private int transferFiles(FTPClient ftp, File[] files, IProgressMonitor monitor, IAdaptable adaptable, boolean deleteTransferred) throws IOException { if (monitor.isCanceled()) return -1; FTPFile[] oldfiles = ftp.listFiles(); if (monitor.isCanceled()) return -1; Map<String, FTPFile> names = new HashMap<String, FTPFile>(); for (FTPFile file : oldfiles) names.put(file.getName(), file); int n = 0;//from w w w . j av a2 s.c o m for (File file : files) { final String filename = file.getName(); FTPFile ftpFile = names.get(filename); if (file.isDirectory()) { if (ftpFile != null) { if (!ftpFile.isDirectory()) throw new IOException( NLS.bind(Messages.FtpAccount_cannot_replace_file_with_subdir, filename)); boolean result = ftp.changeWorkingDirectory(Core.encodeUrlSegment(filename)); if (!result) throw new IOException(NLS.bind(Messages.FtpAccount_cannot_change_to_working_dir, filename)); // System.out.println(filename + " is new directory"); //$NON-NLS-1$ } else { ftp.makeDirectory(filename); boolean result = ftp.changeWorkingDirectory(Core.encodeUrlSegment(filename)); if (!result) throw new IOException(Messages.FtpAccount_creation_of_subdir_failed); // System.out.println(filename + " is new directory"); //$NON-NLS-1$ } if (monitor.isCanceled()) return -1; int c = transferFiles(ftp, file.listFiles(), monitor, adaptable, deleteTransferred); if (c < 0) return -1; n += c; ftp.changeToParentDirectory(); // System.out.println("Returned to parent directory"); //$NON-NLS-1$ } else { if (ftpFile != null) { if (ftpFile.isDirectory()) throw new IOException( NLS.bind(Messages.FtpAccount_cannot_replace_subdir_with_file, filename)); if (skipAll) { if (deleteTransferred) file.delete(); continue; } if (!replaceAll) { if (monitor.isCanceled()) return -1; int ret = 4; IDbErrorHandler errorHandler = Core.getCore().getErrorHandler(); if (errorHandler != null) { String[] buttons = (filecount > 1) ? new String[] { Messages.FtpAccount_overwrite, Messages.FtpAccount_overwrite_all, IDialogConstants.SKIP_LABEL, Messages.FtpAccount_skip_all, IDialogConstants.CANCEL_LABEL } : new String[] { Messages.FtpAccount_overwrite, IDialogConstants.SKIP_LABEL, IDialogConstants.CANCEL_LABEL }; ret = errorHandler.showMessageDialog(Messages.FtpAccount_file_already_exists, null, NLS.bind(Messages.FtpAccount_file_exists_overwrite, filename), MessageDialog.QUESTION, buttons, 0, adaptable); } if (filecount > 1) { switch (ret) { case 0: break; case 1: replaceAll = true; break; case 3: skipAll = true; /* FALL-THROUGH */ case 2: if (deleteTransferred) file.delete(); continue; default: return -1; } } else { switch (ret) { case 0: break; case 1: if (deleteTransferred) file.delete(); continue; default: return -1; } } } ftp.deleteFile(Core.encodeUrlSegment(filename)); // System.out.println(filename + " deleted"); //$NON-NLS-1$ } try (BufferedInputStream in = new BufferedInputStream(new FileInputStream(file))) { ftp.storeFile(Core.encodeUrlSegment(filename), in); // System.out.println(filename + " stored"); //$NON-NLS-1$ n++; } finally { if (deleteTransferred) file.delete(); monitor.worked(1); } } } return n; }
From source file:com.bdaum.zoom.operations.internal.ExportMetadataOperation.java
License:Open Source License
@SuppressWarnings("fallthrough") private void export(Asset asset, IProgressMonitor aMonitor, boolean multiple, IAdaptable info, List<String> errands, Set<String> volumes) { URI uri = Core.getCore().getVolumeManager().findFile(asset); if (uri != null) { boolean conflict = false; boolean saveOriginal = false; File xmpFile = null;/*from w w w . j ava 2s. c om*/ File[] sidecars = Core.getSidecarFiles(uri, false); if (sidecars.length > 0) { xmpFile = sidecars[sidecars.length - 1]; if (xmpFile.exists()) { long lastModified = xmpFile.lastModified(); Date xmpModifiedAt = asset.getXmpModifiedAt(); conflict = xmpModifiedAt != null && lastModified > xmpModifiedAt.getTime(); saveOriginal = xmpModifiedAt == null || xmpModifiedAt.getTime() < asset.getImportDate().getTime(); if (conflict) { if (ignoreAll) return; if (!overwriteAll) { int ret = 4; IDbErrorHandler errorHandler = Core.getCore().getErrorHandler(); if (errorHandler != null) ret = errorHandler.showMessageDialog( Messages.getString("ExportMetadataOperation.XMP_conflict"), //$NON-NLS-1$ null, NLS.bind(Messages.getString("ExportMetadataOperation.XMP_out_of_sync"), //$NON-NLS-1$ xmpFile), MessageDialog.QUESTION, (multiple) ? new String[] { Messages.getString("ExportMetadataOperation.Overwrite"), //$NON-NLS-1$ Messages.getString("ExportMetadataOperation.Overwrite_all"), //$NON-NLS-1$ IDialogConstants.SKIP_LABEL, Messages.getString("ExportMetadataOperation.Skip_all"), //$NON-NLS-1$ Messages.getString("ExportMetadataOperation.Cancel") } //$NON-NLS-1$ : new String[] { Messages.getString("ExportMetadataOperation.Overwrite"), //$NON-NLS-1$ IDialogConstants.CANCEL_LABEL }, 0, info); if (multiple) { switch (ret) { case 1: overwriteAll = true; /* FALL-THROUGH */ case 0: break; case 3: ignoreAll = true; /* FALL-THROUGH */ case 2: return; default: aMonitor.setCanceled(true); return; } } else { switch (ret) { case 0: break; default: aMonitor.setCanceled(true); return; } } } } } } for (int i = 0; i < sidecars.length; i++) { xmpFile = sidecars[i]; if (xmpFile.exists() || i == sidecars.length - 1) { File newFile = new File(xmpFile.getAbsoluteFile() + ".new"); //$NON-NLS-1$ fileWatcher.ignore(newFile, opId); fileWatcher.ignore(xmpFile, opId); newFile.delete(); try { XMPUtilities.configureXMPFactory(); XMPMeta xmpMeta; if (xmpFile.exists()) try (BufferedInputStream in = new BufferedInputStream(new FileInputStream(xmpFile))) { xmpMeta = XMPMetaFactory.parse(in); } catch (XMPException e) { addError(NLS.bind(Messages.getString("ExportMetadataOperation.invalid_xmp"), //$NON-NLS-1$ xmpFile), e); xmpMeta = XMPMetaFactory.create(); } else xmpMeta = XMPMetaFactory.create(); try (BufferedOutputStream out = new BufferedOutputStream(new FileOutputStream(newFile))) { XMPUtilities.writeProperties(xmpMeta, asset, xmpFilter, false); XMPMetaFactory.serialize(xmpMeta, out); if (jpeg && ImageConstants.isJpeg(Core.getFileExtension(uri.toString()))) { File imageFile = new File(uri); try (BufferedInputStream in1 = new BufferedInputStream( new FileInputStream(imageFile))) { byte[] bytes = new byte[(int) imageFile.length()]; if (in1.read(bytes) > 0) try { byte[] oldXmp = XMPUtilities.getXmpFromJPEG(bytes); if (oldXmp != null) try (BufferedInputStream in = new BufferedInputStream( new ByteArrayInputStream(oldXmp))) { xmpMeta = XMPMetaFactory.parse(in); } catch (XMPException e) { addError(NLS.bind( Messages.getString( "ExportMetadataOperation.invalid_inline_xmp"), //$NON-NLS-1$ imageFile), e); xmpMeta = XMPMetaFactory.create(); } else xmpMeta = XMPMetaFactory.create(); ByteArrayOutputStream mout = new ByteArrayOutputStream(); XMPUtilities.writeProperties(xmpMeta, asset, xmpFilter, false); XMPMetaFactory.serialize(xmpMeta, mout); bytes = XMPUtilities.insertXmpIntoJPEG(bytes, mout.toByteArray()); } catch (XMPException e) { addError(NLS.bind( Messages.getString("ExportMetadataOperation.unable_to_export"), //$NON-NLS-1$ imageFile), e); } fileWatcher.ignore(imageFile, opId); try (BufferedOutputStream out1 = new BufferedOutputStream( new FileOutputStream(imageFile))) { out1.write(bytes); } } } } } catch (IOException e) { addError(Messages.getString("ExportMetadataOperation.IO_error_creating_XMP"), e); //$NON-NLS-1$ } catch (XMPException e) { addError(Messages.getString("ExportMetadataOperation.XMP_parsing_error"), //$NON-NLS-1$ e); } if (newFile.exists()) { try { if (saveOriginal) { File backupFile = new File(xmpFile.getAbsolutePath() + ".original"); //$NON-NLS-1$ if (!backupFile.exists()) { fileWatcher.ignore(backupFile, opId); BatchUtilities.moveFile(xmpFile, backupFile, aMonitor); } } BatchUtilities.moveFile(newFile, xmpFile, aMonitor); asset.setXmpModifiedAt(new Date(xmpFile.lastModified())); storeSafely(null, 1, asset); } catch (IOException e) { Core.getCore().logError( Messages.getString("ExportMetadataOperation.IO_error_exporting_metadata"), e); //$NON-NLS-1$ } catch (DiskFullException e) { Core.getCore().logError( Messages.getString("ExportMetadataOperation.IO_error_exporting_metadata"), e); //$NON-NLS-1$ } if (firstExport == null) firstExport = xmpFile; } } } } else { String volume = asset.getVolume(); if (volume != null && !volume.isEmpty()) volumes.add(volume); errands.add(asset.getUri()); } }
From source file:com.bdaum.zoom.operations.internal.MoveOperation.java
License:Open Source License
private int promptForOverwrite(File newFile, IAdaptable info) { if (ignoreAll) return IGNORE; if (renameAll) return RENAME; if (overwriteAll) return OVERWRITE; int ret = 6;/*from w ww . ja va 2s . co m*/ IDbErrorHandler errorHandler = Core.getCore().getErrorHandler(); if (errorHandler != null) ret = errorHandler.showMessageDialog(Messages.getString("MoveOperation.Same_file_exists"), //$NON-NLS-1$ null, NLS.bind(Messages.getString("MoveOperation.File_already_exists"), //$NON-NLS-1$ newFile.getName()), MessageDialog.QUESTION, new String[] { Messages.getString("MoveOperation.Overwrite"), //$NON-NLS-1$ Messages.getString("MoveOperation.Overwrite_all"), IDialogConstants.SKIP_LABEL, //$NON-NLS-1$ Messages.getString("MoveOperation.Skip_all"), //$NON-NLS-1$ Messages.getString("MoveOperation.Rename"), //$NON-NLS-1$ Messages.getString("MoveOperation.Rename_all"), //$NON-NLS-1$ IDialogConstants.CANCEL_LABEL }, 0, info); switch (ret) { case 1: overwriteAll = true; //$FALL-THROUGH$ case 0: return OVERWRITE; case 3: ignoreAll = true; //$FALL-THROUGH$ case 2: return IGNORE; case 5: renameAll = true; //$FALL-THROUGH$ case 4: return RENAME; default: return CANCEL; } }
From source file:org.eclipse.sirius.common.ui.tools.api.dialog.SiriusMessageDialogWithToggle.java
License:Open Source License
/** * Attempt to find a standard JFace button id that matches the specified * button label. If no match can be found, use the default id provided. * /* www.ja v a 2 s. c om*/ * Overridden to investigate the provided buttons. * * @param buttonLabel * the button label whose id is sought * @param defaultId * the id to use for the button if there is no standard id * @return the id for the specified button label */ // CHECKSTYLE:OFF private int mapButtonLabelToButtonID(String buttonLabel, int defaultId) { // CHECKSTYLE:OON // Not pretty but does the job... if (IDialogConstants.OK_LABEL.equals(buttonLabel)) { return IDialogConstants.OK_ID; } if (IDialogConstants.YES_LABEL.equals(buttonLabel)) { return IDialogConstants.YES_ID; } if (IDialogConstants.NO_LABEL.equals(buttonLabel)) { return IDialogConstants.NO_ID; } if (IDialogConstants.CANCEL_LABEL.equals(buttonLabel)) { return IDialogConstants.CANCEL_ID; } if (IDialogConstants.YES_TO_ALL_LABEL.equals(buttonLabel)) { return IDialogConstants.YES_TO_ALL_ID; } if (IDialogConstants.SKIP_LABEL.equals(buttonLabel)) { return IDialogConstants.SKIP_ID; } if (IDialogConstants.STOP_LABEL.equals(buttonLabel)) { return IDialogConstants.STOP_ID; } if (IDialogConstants.ABORT_LABEL.equals(buttonLabel)) { return IDialogConstants.ABORT_ID; } if (IDialogConstants.RETRY_LABEL.equals(buttonLabel)) { return IDialogConstants.RETRY_ID; } if (IDialogConstants.IGNORE_LABEL.equals(buttonLabel)) { return IDialogConstants.IGNORE_ID; } if (IDialogConstants.PROCEED_LABEL.equals(buttonLabel)) { return IDialogConstants.PROCEED_ID; } if (IDialogConstants.OPEN_LABEL.equals(buttonLabel)) { return IDialogConstants.OPEN_ID; } if (IDialogConstants.CLOSE_LABEL.equals(buttonLabel)) { return IDialogConstants.CLOSE_ID; } if (IDialogConstants.BACK_LABEL.equals(buttonLabel)) { return IDialogConstants.BACK_ID; } if (IDialogConstants.NEXT_LABEL.equals(buttonLabel)) { return IDialogConstants.NEXT_ID; } if (IDialogConstants.FINISH_LABEL.equals(buttonLabel)) { return IDialogConstants.FINISH_ID; } if (IDialogConstants.HELP_LABEL.equals(buttonLabel)) { return IDialogConstants.HELP_ID; } if (IDialogConstants.NO_TO_ALL_LABEL.equals(buttonLabel)) { return IDialogConstants.NO_TO_ALL_ID; } if (IDialogConstants.SHOW_DETAILS_LABEL.equals(buttonLabel)) { return IDialogConstants.DETAILS_ID; } if (IDialogConstants.HIDE_DETAILS_LABEL.equals(buttonLabel)) { return IDialogConstants.DETAILS_ID; } for (String providedButton : buttonsMap.keySet()) { if (providedButton.equals(buttonLabel)) { return buttonsMap.get(providedButton); } } // No XXX_LABEL in IDialogConstants for these. Unlikely // they would be used in a message dialog though. // public int SELECT_ALL_ID = 18; // public int DESELECT_ALL_ID = 19; // public int SELECT_TYPES_ID = 20; return defaultId; }
From source file:org.jkiss.dbeaver.ui.dialogs.exec.ExecutionQueueErrorDialog.java
License:Open Source License
@Override protected void createButtonsForButtonBar(Composite parent) { // create OK and Details buttons createButton(parent, IDialogConstants.STOP_ID, IDialogConstants.STOP_LABEL, true); createButton(parent, IDialogConstants.RETRY_ID, IDialogConstants.RETRY_LABEL, false); if (script) { createButton(parent, IDialogConstants.SKIP_ID, IDialogConstants.SKIP_LABEL, false); createButton(parent, IDialogConstants.IGNORE_ID, IDialogConstants.IGNORE_LABEL, false); }//from w w w . j a v a 2s . co m createDetailsButton(parent); }