List of usage examples for org.eclipse.jface.dialogs IDialogConstants CANCEL_LABEL
String CANCEL_LABEL
To view the source code for org.eclipse.jface.dialogs IDialogConstants CANCEL_LABEL.
Click Source Link
From source file:com.astra.ses.spell.gui.dialogs.PromptDialog.java
License:Open Source License
/*************************************************************************** * Create the button bar buttons./*from w w w. j a v a 2 s.co m*/ * * @param parent * The Button Bar. **************************************************************************/ protected void createButtonsForButtonBar(Composite parent) { if (m_type == OPT_OK) createButton(parent, IDialogConstants.OK_ID, IDialogConstants.OK_LABEL, true); else if (m_type == OPT_YES) createButton(parent, IDialogConstants.YES_ID, IDialogConstants.YES_LABEL, true); else if (m_type == OPT_NO) createButton(parent, IDialogConstants.NO_ID, IDialogConstants.NO_LABEL, false); else if (m_type == OPT_CANCEL) createButton(parent, IDialogConstants.CANCEL_ID, IDialogConstants.CANCEL_LABEL, false); else if (m_type == OPT_NUM || m_type == OPT_ALPHA || m_type == OPT_ANY) { createButton(parent, IDialogConstants.OK_ID, IDialogConstants.OK_LABEL, true); createButton(parent, IDialogConstants.CANCEL_ID, IDialogConstants.CANCEL_LABEL, false); } else if (m_type == OPT_YES_NO) { createButton(parent, IDialogConstants.YES_ID, IDialogConstants.YES_LABEL, true); createButton(parent, IDialogConstants.NO_ID, IDialogConstants.NO_LABEL, false); } else if (m_type == OPT_OK_CANCEL) { createButton(parent, IDialogConstants.OK_ID, IDialogConstants.OK_LABEL, true); createButton(parent, IDialogConstants.CANCEL_ID, IDialogConstants.CANCEL_LABEL, false); } }
From source file:com.astra.ses.spell.gui.dialogs.ServerFileSaveDialog.java
License:Open Source License
/*************************************************************************** * Create the button bar buttons./* w ww .j av a2 s .c o m*/ * * @param parent * The Button Bar. **************************************************************************/ @Override protected void createButtonsForButtonBar(Composite parent) { createButton(parent, IDialogConstants.OK_ID, IDialogConstants.OK_LABEL, false); getButton(IDialogConstants.OK_ID).setEnabled(false); createButton(parent, IDialogConstants.CANCEL_ID, IDialogConstants.CANCEL_LABEL, true); }
From source file:com.atlassian.connector.eclipse.internal.crucible.ui.dialogs.AbstractCrucibleReviewActionDialog.java
License:Open Source License
@Override protected void createButtonsForButtonBar(Composite parent) { Button summarizeButton = createButton(parent, IDialogConstants.CLIENT_ID + 1, actionText, false); summarizeButton.addSelectionListener(new SelectionAdapter() { @Override//from w w w .ja v a2 s. c om public void widgetSelected(SelectionEvent e) { doAction(); } }); Button cancelButton = createButton(parent, IDialogConstants.CANCEL_ID, IDialogConstants.CANCEL_LABEL, false); cancelButton.addSelectionListener(new SelectionAdapter() { @Override public void widgetSelected(SelectionEvent e) { cancelPressed(); } }); }
From source file:com.atlassian.connector.eclipse.internal.crucible.ui.dialogs.CrucibleAddCommentDialog.java
License:Open Source License
@Override protected void createButtonsForButtonBar(Composite parent) { saveButton = createButton(parent, IDialogConstants.CLIENT_ID + 2, SAVE_LABEL, false); saveButton.addSelectionListener(new SelectionAdapter() { @Override/*from w w w. j a va 2 s . co m*/ public void widgetSelected(SelectionEvent e) { addComment(); } }); saveButton.setEnabled(false); if (!edit) { // if it is a new reply, saving as draft is possible saveDraftButton = createButton(parent, IDialogConstants.CLIENT_ID + 2, DRAFT_LABEL, false); saveDraftButton.addSelectionListener(new SelectionAdapter() { @Override public void widgetSelected(SelectionEvent e) { draft = true; addComment(); } }); saveDraftButton.setEnabled(false); } createButton(parent, IDialogConstants.CANCEL_ID, IDialogConstants.CANCEL_LABEL, false) .addSelectionListener(new SelectionAdapter() { @Override public void widgetSelected(SelectionEvent e) { cancelPressed(); } }); }
From source file:com.atlassian.connector.eclipse.internal.crucible.ui.dialogs.CrucibleEditCommentDialog.java
License:Open Source License
@Override protected void createButtonsForButtonBar(Composite parent) { updateButton = createButton(parent, IDialogConstants.CLIENT_ID + 2, UPDATE_LABEL, false); updateButton.addSelectionListener(new SelectionAdapter() { @Override//from w w w.j av a2 s .co m public void widgetSelected(SelectionEvent e) { updateComment(false); } }); updateButton.setEnabled(false); if (CrucibleUtil.canPublishDraft(comment)) { saveDraftButton = createButton(parent, IDialogConstants.CLIENT_ID + 2, DRAFT_LABEL, false); saveDraftButton.addSelectionListener(new SelectionAdapter() { @Override public void widgetSelected(SelectionEvent e) { updateComment(true); } }); saveDraftButton.setEnabled(false); } createButton(parent, IDialogConstants.CANCEL_ID, IDialogConstants.CANCEL_LABEL, false) .addSelectionListener(new SelectionAdapter() { @Override public void widgetSelected(SelectionEvent e) { cancelPressed(); } }); }
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 www .j av a 2 s.c om 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;// w w w . j av a 2s . co 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;// www.j a v a 2s . com 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;// ww w .j a v a 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:com.bdaum.zoom.ui.dialogs.AcousticMessageDialog.java
License:Open Source License
/** * Convenience method to open a simple confirm (OK/Cancel) dialog. * * @param parent// w w w. jav a 2 s. c o m * the parent shell of the dialog, or <code>null</code> if none * @param title * the dialog's title, or <code>null</code> if none * @param message * the message * @return <code>true</code> if the user presses the OK button, * <code>false</code> otherwise */ public static boolean openConfirm(Shell parent, String title, String message) { return new AcousticMessageDialog(parent, title, null, message, QUESTION, new String[] { IDialogConstants.OK_LABEL, IDialogConstants.CANCEL_LABEL }, 0).open() == 0; }