List of usage examples for org.eclipse.jface.dialogs MessageDialog QUESTION
int QUESTION
To view the source code for org.eclipse.jface.dialogs MessageDialog QUESTION.
Click Source Link
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 ww w. j av a 2 s . co 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. ja va 2s.com*/ 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 ww. j av a2s.co m 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 w w.j a v a 2 s.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.internal.actions.DeleteAction.java
License:Open Source License
@Override public void run() { SmartCollectionImpl selectedCollection = Ui.getUi() .getNavigationHistory(adaptable.getAdapter(IWorkbenchWindow.class)).getSelectedCollection(); boolean inAlbum = false; SmartCollection sm = selectedCollection; while (sm != null) { if (sm.getAlbum() && !sm.getSystem()) { inAlbum = true;//from w w w .ja v a 2s. co m break; } sm = sm.getSmartCollection_subSelection_parent(); } AssetSelection selection = adaptable.getAdapter(AssetSelection.class); List<SlideImpl> slides = null; List<ExhibitImpl> exhibits = null; List<WebExhibitImpl> webexhibits = null; if (selection != null) { List<Asset> localAssets = selection.getLocalAssets(); if (localAssets != null && !localAssets.isEmpty()) { ICore core = Core.getCore(); IVolumeManager volumeManager = core.getVolumeManager(); IDbManager dbManager = core.getDbManager(); if (localAssets.size() == 1) { Asset asset = localAssets.get(0); String assetId = asset.getStringId(); // Check XRef slides = dbManager.obtainObjects(SlideImpl.class, "asset", assetId, QueryField.EQUALS); //$NON-NLS-1$ exhibits = dbManager.obtainObjects(ExhibitImpl.class, "asset", assetId, QueryField.EQUALS); //$NON-NLS-1$ webexhibits = dbManager.obtainObjects(WebExhibitImpl.class, "asset", assetId, //$NON-NLS-1$ QueryField.EQUALS); if (!slides.isEmpty() || !exhibits.isEmpty() || !webexhibits.isEmpty()) { Set<String> presentationIds = new HashSet<String>(7); for (SlideImpl slide : slides) { presentationIds.add(slide.getSlideShow_entry_parent()); if (presentationIds.size() > 4) break; } for (ExhibitImpl exhibit : exhibits) { if (presentationIds.size() > 4) break; WallImpl wall = dbManager.obtainById(WallImpl.class, exhibit.getWall_exhibit_parent()); if (wall != null) { Exhibition exhibition = wall.getExhibition_wall_parent(); if (exhibition != null) presentationIds.add(exhibition.toString()); } } for (WebExhibitImpl webexhibit : webexhibits) { if (presentationIds.size() > 4) break; StoryboardImpl story = dbManager.obtainById(StoryboardImpl.class, webexhibit.getStoryboard_exhibit_parent()); if (story != null) { WebGallery gallery = story.getWebGallery_storyboard_parent(); if (gallery != null) presentationIds.add(gallery.toString()); } } StringBuilder sb = new StringBuilder(); int i = 0; for (String id : presentationIds) { if (++i > 3) { sb.append(",... "); //$NON-NLS-1$ break; } IdentifiableObject obj = dbManager.obtainById(IdentifiableObject.class, id); if (obj instanceof SlideShowImpl) { if (i > 1) sb.append(", "); //$NON-NLS-1$ sb.append(NLS.bind(Messages.DeleteAction_Slide_show, ((SlideShowImpl) obj).getName())); } else if (obj instanceof ExhibitionImpl) { if (i > 1) sb.append(", "); //$NON-NLS-1$ sb.append(NLS.bind(Messages.DeleteAction_Exhibition, ((ExhibitionImpl) obj).getName())); } else if (obj instanceof WebGalleryImpl) { if (i > 1) sb.append(", "); //$NON-NLS-1$ sb.append(NLS.bind(Messages.DeleteAction_Web_gallery, ((WebGalleryImpl) obj).getName())); } } StringBuilder message = new StringBuilder(); message.append(NLS.bind(Messages.DeleteAction_image_used_in, sb)) .append(i == 1 ? Messages.DeleteAction_remove_image_singular : Messages.DeleteAction_remove_image_plural) .append(Messages.DeleteAction_operation_cannot_be_undome); if (!AcousticMessageDialog.openConfirm(shell, Messages.DeleteAction_used_in_artifacts, message.toString())) return; } URI fileUri = volumeManager.findExistingFile(asset, true); if (fileUri == null) { // Image file does not exist if (!volumeManager.isOffline(asset.getVolume())) { if (inAlbum) { MessageDialog dialog = new AcousticMessageDialog(shell, Messages.DeleteAction_deleting_images, null, Messages.DeleteAction_delete_remote_entries, MessageDialog.QUESTION, new String[] { Messages.DeleteAction_remove_from_album, Messages.DeleteAction_delete_only_cat, IDialogConstants.CANCEL_LABEL }, 0); if (dialog.open() != 2) launchOperation(selectedCollection, false, Collections.singletonList(asset), slides, exhibits, webexhibits); } else if (AcousticMessageDialog.openConfirm(shell, Messages.DeleteAction_deleting_images, NLS.bind(Messages.DeleteAction_delete_cat_entry, asset.getName()))) launchOperation(null, false, Collections.singletonList(asset), slides, exhibits, webexhibits); return; } } else { File file = new File(fileUri); if (!file.canWrite()) { if (inAlbum) { MessageDialog dialog = new AcousticMessageDialog(shell, Messages.DeleteAction_deleting_images, null, Messages.DeleteAction_delete_write_protected, MessageDialog.QUESTION, new String[] { Messages.DeleteAction_remove_from_album, Messages.DeleteAction_delete_only_cat, IDialogConstants.CANCEL_LABEL }, 0); if (dialog.open() != 2) launchOperation(selectedCollection, false, Collections.singletonList(asset), slides, exhibits, webexhibits); } else if (AcousticMessageDialog.openConfirm(shell, Messages.DeleteAction_deleting_images, NLS.bind(Messages.DeleteAction_delete_cat_entry_write_protected, asset.getName()))) launchOperation(null, false, Collections.singletonList(asset), slides, exhibits, webexhibits); return; } } } else { String[] assetIds = selection.getLocalAssetIds(); slides = dbManager.obtainObjects(SlideImpl.class, "asset", assetIds); //$NON-NLS-1$ exhibits = dbManager.obtainObjects(ExhibitImpl.class, "asset", assetIds); //$NON-NLS-1$ webexhibits = dbManager.obtainObjects(WebExhibitImpl.class, "asset", assetIds); //$NON-NLS-1$ if ((!slides.isEmpty() || !exhibits.isEmpty() || !webexhibits.isEmpty()) && !AcousticMessageDialog.openConfirm(shell, Messages.DeleteAction_used_in_artifacts, Messages.DeleteAction_images_used_in_presentations)) return; } boolean fileOnDisc = false; for (Asset asset : localAssets) { URI uri = volumeManager.findExistingFile(asset, true); if (uri != null && !volumeManager.isOffline(asset.getVolume()) && new File(uri).canWrite()) { fileOnDisc = true; break; } } int esc = 1; List<String> buttons = new ArrayList<String>(); if (inAlbum) { buttons.add(Messages.DeleteAction_remove_from_album); ++esc; } buttons.add(Messages.DeleteAction_delete_only_cat); if (fileOnDisc) { buttons.add(Messages.DeleteAction_delete_on_disc_too); ++esc; } buttons.add(IDialogConstants.CANCEL_LABEL); MessageDialog dialog = new AcousticMessageDialog(shell, Messages.DeleteAction_deleting_images, null, (fileOnDisc) ? Messages.DeleteAction_delete_images + Messages.DeleteAction_delete_on_disk : Messages.DeleteAction_delete_images, MessageDialog.QUESTION, buttons.toArray(new String[buttons.size()]), 0); int ret = dialog.open(); if (ret < esc) launchOperation(ret == 0 && inAlbum ? selectedCollection : null, inAlbum ? (ret > 1) : (ret > 0), localAssets, slides, exhibits, webexhibits); } } }
From source file:com.bdaum.zoom.ui.internal.commands.ImportDeviceCommand.java
License:Open Source License
public void doRun() { StorageObject[] dcims;/*ww w .j a va 2 s . c o m*/ while (true) { dcims = Core.getCore().getVolumeManager().findDCIMs(); if (dcims.length > 0) break; MessageDialog dialog = new AcousticMessageDialog(getShell(), Messages.ImportFromDeviceAction_Import_from_device, null, Messages.ImportFromDeviceAction_there_seems_no_suitable_device, MessageDialog.QUESTION, new String[] { IDialogConstants.RETRY_LABEL, IDialogConstants.CANCEL_LABEL }, 1); if (dialog.open() > 0) return; } ImportFromDeviceWizard wizard = new ImportFromDeviceWizard(null, dcims, true, true, true, null, false); WizardDialog wizardDialog = new WizardDialog(getShell(), wizard); wizard.init(null, null); wizardDialog.open(); }
From source file:com.bdaum.zoom.ui.internal.job.UpdateJob.java
License:Open Source License
@Override protected IStatus runJob(IProgressMonitor monitor) { monitor.beginTask(Messages.Updater_updating, IProgressMonitor.UNKNOWN); if (downloadFile == null) for (String pack : packages) { if (monitor.isCanceled()) break; downloadFile = download(pack, monitor); if (downloadFile != null) break; }/*from www . j a va 2 s . c o m*/ if (monitor.isCanceled()) return Status.CANCEL_STATUS; Display display = Display.getDefault(); if (display.isDisposed()) return Status.CANCEL_STATUS; if (downloadFile == null) { display.syncExec(() -> MessageDialog.openError(null, Constants.APPNAME + UPDATE, Messages.Updater_download_of_new_version_failed)); return Status.CANCEL_STATUS; } if (monitor.isCanceled()) return Status.CANCEL_STATUS; display.syncExec(() -> { AcousticMessageDialog dialog = new AcousticMessageDialog(null, Constants.APPNAME + UPDATE, null, NLS.bind(Messages.Updater_installer_package_successfully_downloaded, downloadFile.getName()), MessageDialog.QUESTION, new String[] { Messages.Updater_yes, Messages.Updater_no }, 0); result = dialog.open(); }); if (monitor.isCanceled()) return Status.CANCEL_STATUS; switch (result) { case 0: Location installLocation = Platform.getInstallLocation(); URL url = installLocation == null ? null : installLocation.getURL(); URI uri = null; if (url != null) try { uri = url.toURI(); } catch (URISyntaxException e) { // ignore } if (monitor.isCanceled()) return Status.CANCEL_STATUS; String[] cmdarray = null; if (url != null) { String instancepath = Platform.getInstanceLocation().getURL().getPath(); String installpath = Platform.getInstallLocation().getURL().getPath(); String installType = (instancepath.startsWith(installpath)) ? "install" : "user"; //$NON-NLS-1$ //$NON-NLS-2$ Properties props = new Properties(); props.put("INSTALL_PATH", new File(uri).getParentFile().getPath()); //$NON-NLS-1$ props.put("configuration.installFor", installType); //$NON-NLS-1$ try { File propertyFile = File.createTempFile(Constants.APPNAME + "Installer.Properties", //$NON-NLS-1$ ".properties"); //$NON-NLS-1$ try (FileOutputStream out = new FileOutputStream(propertyFile)) { props.store(out, null); } cmdarray = new String[] { downloadFile.getAbsolutePath(), "-options", propertyFile.getPath() };//$NON-NLS-1$ } catch (IOException e) { // do nothing } } if (cmdarray == null) cmdarray = new String[] { downloadFile.getAbsolutePath() }; UiActivator.getDefault().setUpdaterCommand(cmdarray); return Status.OK_STATUS; default: return Status.CANCEL_STATUS; } }
From source file:com.bdaum.zoom.ui.internal.UiActivator.java
License:Open Source License
public void restart() { final Display display = PlatformUI.getWorkbench().getDisplay(); if (!display.isDisposed()) { display.timerExec(300, () -> { if (!display.isDisposed()) { AcousticMessageDialog dialog = new AcousticMessageDialog(null, NLS.bind(Messages.UiActivator_restart_required, Constants.APPLICATION_NAME), null, Messages.UiActivator_restart_msg, MessageDialog.QUESTION, new String[] { Messages.UiActivator_restart_now, Messages.UiActivator_restart_later }, 0);// w w w.j a v a 2 s.c o m if (dialog.open() == 0 && preCatClose(CatalogListener.SHUTDOWN, Messages.UiActivator_restart, Messages.UiActivator_restart_question, false)) PlatformUI.getWorkbench().restart(); } }); } }
From source file:com.bdaum.zoom.ui.internal.views.ExhibitionView.java
License:Open Source License
private void generate() { ExhibitionImpl show = getExhibition(); if (show == null) return;//from www .j a v a2s .c om if (offlineImages != null && !offlineImages.isEmpty()) { String[] volumes = offlineImages.toArray(new String[offlineImages.size()]); Arrays.sort(volumes); AcousticMessageDialog.openInformation(getSite().getShell(), Messages.getString("ExhibitionView.images_offline"), //$NON-NLS-1$ volumes.length > 1 ? NLS.bind(Messages.getString("ExhibitionView.volumes_offline"), //$NON-NLS-1$ Core.toStringList(volumes, ", ")) //$NON-NLS-1$ : NLS.bind(Messages.getString("ExhibitionView.volume_offline"), //$NON-NLS-1$ volumes[0])); return; } String s = exhibition.getStringId(); StringBuilder sb = new StringBuilder(); for (int i = 0; i < s.length(); i++) { char c = s.charAt(i); if (Character.isLetterOrDigit(c)) sb.append(c); } String exhibitionId = sb.toString(); boolean isFtp = show.getIsFtp(); String outputFolder = (isFtp) ? show.getFtpDir() : show.getOutputFolder(); while (outputFolder == null || outputFolder.isEmpty()) { show = ExhibitionEditDialog.open(getSite().getShell(), null, show, show.getName(), false, Messages.getString("ExhibitionView.please_specify_target")); //$NON-NLS-1$ if (show == null) return; isFtp = show.getIsFtp(); outputFolder = (isFtp) ? show.getFtpDir() : show.getOutputFolder(); } boolean makeDefault = false; boolean askForDefault = false; final File file = new File(outputFolder); if (!isFtp && file.exists() && file.listFiles().length > 0) { AcousticMessageDialog dialog; File resFile = new File(file, "res"); //$NON-NLS-1$ File[] rooms = resFile.listFiles(new FileFilter() { public boolean accept(File f) { return f.getName().startsWith("room_"); //$NON-NLS-1$ } }); if (rooms.length > 0) { File roomFile = new File(resFile, "room_" //$NON-NLS-1$ + exhibitionId); if (roomFile.exists()) { askForDefault = rooms.length > 1; dialog = new AcousticMessageDialog(getSite().getShell(), Messages.getString("ExhibitionView.overwriteTitle"), //$NON-NLS-1$ null, NLS.bind(Messages.getString("ExhibitionView.exhibition_exists"), file), //$NON-NLS-1$ MessageDialog.QUESTION, new String[] { Messages.getString("ExhibitionView.overwrite"), //$NON-NLS-1$ Messages.getString("ExhibitionView.clear_folder"), //$NON-NLS-1$ IDialogConstants.CANCEL_LABEL }, 0); } else { askForDefault = true; dialog = new AcousticMessageDialog(getSite().getShell(), Messages.getString("ExhibitionView.add"), //$NON-NLS-1$ null, NLS.bind(Messages.getString("ExhibitionView.other_exhibitions"), file), //$NON-NLS-1$ MessageDialog.QUESTION, new String[] { Messages.getString("ExhibitionView.add_room"), //$NON-NLS-1$ Messages.getString("ExhibitionView.clear_folder"), //$NON-NLS-1$ IDialogConstants.CANCEL_LABEL }, 0); } } else dialog = new AcousticMessageDialog(getSite().getShell(), Messages.getString("ExhibitionView.overwriteTitle"), //$NON-NLS-1$ null, NLS.bind(Messages.getString("ExhibitionView.not_empty"), file), //$NON-NLS-1$ MessageDialog.QUESTION, new String[] { Messages.getString("ExhibitionView.overwrite"), //$NON-NLS-1$ Messages.getString("ExhibitionView.clear_folder"), //$NON-NLS-1$ IDialogConstants.CANCEL_LABEL }, 0); int ret = dialog.open(); switch (ret) { case 2: return; case 1: Core.deleteFileOrFolder(file); break; } } if (askForDefault) makeDefault = AcousticMessageDialog.openQuestion(getSite().getShell(), Messages.getString("ExhibitionView.exhibition_start"), //$NON-NLS-1$ Messages.getString("ExhibitionView.start_viewing")); //$NON-NLS-1$ String page = show.getPageName(); final boolean ftp = isFtp; final File start = new File(file, (page == null || page.isEmpty()) ? "index.html" //$NON-NLS-1$ : page); final ExhibitionJob job = new ExhibitionJob(show, exhibitionId, ExhibitionView.this, makeDefault); final FtpAccount account; if (ftp) { account = FtpAccount.findAccount(outputFolder); if (account == null) { AcousticMessageDialog.openError(getSite().getShell(), Messages.getString("ExhibitionView.account_not_existing"), //$NON-NLS-1$ NLS.bind(Messages.getString("ExhibitionView.account_not_defined"), //$NON-NLS-1$ outputFolder)); return; } } else account = null; job.addJobChangeListener(new JobChangeAdapter() { @Override public void done(IJobChangeEvent event) { if (!job.wasAborted()) { if (ftp) new TransferJob(job.getTargetFolder().listFiles(), account, true).schedule(0); else showExhibition(start); } } }); job.schedule(); }
From source file:com.bdaum.zoom.ui.internal.views.SlideShowPlayer.java
License:Open Source License
private int showClosePrompt(Shell shell) { boolean changes = false; for (SlideRequest request : requestList) { if (request.isSelected() || request.isDeleted() || request.isRemoveFromShow()) { changes = true;//www. jav a 2 s . c om break; } Asset asset = request.getAsset(); if (asset != null) { int rating = request.getRating(); if (rating != RatingDialog.ABORT && rating != asset.getRating()) { changes = true; break; } if ((request.getRotation() - asset.getRotation()) % 360 != 0) { changes = true; break; } } SmartCollectionImpl[] albums = request.getAlbums(); if (albums != null && albums.length > 0) { changes = true; break; } if (request.annotationChanged()) { changes = true; break; } } AcousticMessageDialog dialog = new AcousticMessageDialog(shell, Messages.getString("SlideShowPlayer.close"), //$NON-NLS-1$ null, Messages.getString("SlideShowPlayer.really_close"), //$NON-NLS-1$ MessageDialog.QUESTION, changes ? new String[] { Messages.getString("SlideShowPlayer.close_close"), //$NON-NLS-1$ Messages.getString("SlideShowPlayer.close_ignore"), //$NON-NLS-1$ Messages.getString("SlideShowPlayer.close_cancel") } //$NON-NLS-1$ : new String[] { Messages.getString("SlideShowPlayer.close_close"), //$NON-NLS-1$ Messages.getString("SlideShowPlayer.close_cancel") }, //$NON-NLS-1$ CLOSE_CLOSE); dialog.create(); int ret = dialog.open(); return ret == (changes ? 2 : 1) ? CLOSE_CANCEL : ret; }