List of usage examples for org.eclipse.jface.dialogs MessageDialog open
public int open()
From source file:com.arc.cdt.debug.seecode.ui.UISeeCodePlugin.java
License:Open Source License
/** * The constructor./*from ww w . ja v a 2 s . c o m*/ */ public UISeeCodePlugin() { super(); plugin = this; try { resourceBundle = ResourceBundle.getBundle("com.arc.cdt.debug.seecode.ui.SeeCode"); } catch (MissingResourceException x) { resourceBundle = null; } // // Create the object that intercepts "create-display" // // events from the core plugin so as to create // // the Custom seecode displays. // new DisplayCreatorDelegate(); // The core plugin doesn't "see" us to avoid // circular dependencies. But it needs to // instantiate the CustomDisplayCallback class // that is defined in this package. // We use a callback to do that: SeeCodePlugin.getDefault().setCustomDisplayCallbackCreator(new ICustomDisplayCallbackCreator() { @Override public ICustomDisplayCallback create(ICDITarget target) { return new CustomDisplayCallback(target); } }); SeeCodePlugin.getDefault().setLicenseExpirationChecker(new ILicenseExpirationChecker() { @Override public void checkLicenseExpiration(int days) { UISeeCodePlugin.this.checkLicensingAlert(days); } }); SeeCodePlugin.getDefault().setLicensingFailure(new ILicenseFailure() { @Override public void reportLicenseFailure(final String msg) { PlatformUI.getWorkbench().getDisplay().syncExec(new Runnable() { @Override public void run() { Shell shell = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell(); String fullMsg = "A valid license for " + UISeeCodePlugin.getTheDebuggerName() + " was not found.\n\n" + msg; IStatus status = makeErrorStatus(fullMsg); ErrorDialog.openError(shell, UISeeCodePlugin.getDebuggerName() + " Licensing Failure", null, status); } }); } }); SeeCodePlugin.getDefault().setStatusWriter(new IStatusWriter() { @Override public void setStatus(final String msg) { // We need to get to the status line manager, but we can only get // access to from a viewsite. Unfortunately, we have // no direct reference to such. Therefore, look for // the debug view whose ID is "org.eclipse.debug.ui.DebugView" PlatformUI.getWorkbench().getDisplay().asyncExec(new Runnable() { @Override public void run() { IWorkbenchWindow window = PlatformUI.getWorkbench().getActiveWorkbenchWindow(); if (window != null) { IWorkbenchPage page = window.getActivePage(); if (page != null) { IViewPart viewPart = page.findView(IDebugUIConstants.ID_DEBUG_VIEW); if (viewPart != null) { IStatusLineManager statusLine = viewPart.getViewSite().getActionBars() .getStatusLineManager(); statusLine.setMessage(msg); } } } } }); } }); SeeCodePlugin.getDefault().setTermSimInstantiator(new TermSimInstantiator()); SeeCodePlugin.getDefault().setDisplayError(new IDisplayMessage() { @Override public void displayError(final String title, final String msg) { PlatformUI.getWorkbench().getDisplay().syncExec(new Runnable() { @Override public void run() { showError(title, msg); } }); } @Override public void displayNote(final String title, final String msg) { PlatformUI.getWorkbench().getDisplay().syncExec(new Runnable() { @Override public void run() { showNote(title, msg); } }); } }); SeeCodePlugin.getDefault().setEngineVersionStrategyCallback(new IEngineResolver() { @Override public boolean useToolSetEngine(final int bundledEngineId, final int toolsetEngineId, final String toolsetPath) { switch (SeeCodePlugin.getDefault().getPreferences().getInt( ISeeCodeConstants.PREF_ENGINE_VERSION_MANAGEMENT, ISeeCodeConstants.ENGINE_VERSION_USE_TOOLSET)) { case ISeeCodeConstants.ENGINE_VERSION_PROMPT: if (bundledEngineId != toolsetEngineId) { final boolean results[] = new boolean[1]; PlatformUI.getWorkbench().getDisplay().syncExec(new Runnable() { @Override public void run() { results[0] = new PromptForEngineSelectionDialog( PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell(), bundledEngineId, toolsetEngineId, toolsetPath).open(); } }); return results[0]; } return false; case ISeeCodeConstants.ENGINE_VERSION_USE_BUNDLED: return false; case ISeeCodeConstants.ENGINE_VERSION_USE_TOOLSET: return true; case ISeeCodeConstants.ENGINE_VERSION_USE_LATEST: return toolsetEngineId > bundledEngineId; } return false; // shouldn't get here } }); /* SeeCodePlugin.getDefault().setProgramLoadTimeoutCallback(new IDiagnoseProgramLoadTimeout(){ public void diagnoseTimeout (final String exeName, final int timeout) { PlatformUI.getWorkbench().getDisplay().syncExec(new Runnable() { public void run () { Shell shell = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell(); String fullMsg = "The debugger engine timed out while loading\n\"" + exeName + "\".\n" + "The current timeout for loading a program is " + timeout + " milliseconds.\n" + "If you have a slow target connection, or if you are doing a long-running\n"+ "blast operation, you may need to increase the timeout value. Go to the\n" + "preference page: \"Windows->Preferences->C/C++->Debugger->MetaWare Debugger\".\n"; IStatus status = SeeCodePlugin.makeErrorStatus(fullMsg); ErrorDialog.openError(shell, "Program load timeout failure", null, status); } }); }});*/ SeeCodePlugin.getDefault().setLoadTimeoutCallback(new ITimeoutCallback() { private int _newTimeout = 0; @Override public int getNewTimeout(final int timeout) { PlatformUI.getWorkbench().getDisplay().syncExec(new Runnable() { @Override public void run() { Shell shell = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell(); String fullMsg = "The debugger engine is attempting to load a program and it has not\n" + "completed after \"" + (timeout + 500) / 1000 + "\" seconds (as specified in the " + "MetaWare Debugger\npreferences page).\n\n" + "If you are loading over a slow connnection, or if you are doing a blast\n" + "operation, the engine may need more time.\n\n" + "What do you want the IDE to do?\n"; MessageDialog dialog = new MessageDialog(shell, "Engine Timeout Alert", null, // accept fullMsg, MessageDialog.WARNING, new String[] { IDialogConstants.OK_LABEL }, 0) { @Override protected Control createCustomArea(Composite parent) { Composite container = new Group(parent, 0); container.setLayout(new GridLayout(4, false)); GridData gd = new GridData(); gd.horizontalSpan = 1; gd.grabExcessHorizontalSpace = false; final Button b1 = new Button(container, SWT.RADIO); b1.setLayoutData(gd); b1.setText("Wait no longer;"); // Label on button appears to be limited in size; add additional // as a label Label label1 = new Label(container, SWT.LEFT); label1.setText("abort if load is not yet complete."); GridData gd1 = new GridData(); gd1.horizontalSpan = 3; gd1.grabExcessHorizontalSpace = true; label1.setLayoutData(gd1); gd = new GridData(); gd.horizontalSpan = 4; gd.grabExcessHorizontalSpace = true; final Button b2 = new Button(container, SWT.RADIO); b2.setLayoutData(gd); b2.setText("Continue waiting indefinitely."); final Button b3 = new Button(container, SWT.RADIO); b3.setText("Wait for an additional number of seconds"); b3.setLayoutData(gd); final Label label = new Label(container, SWT.LEFT); label.setText(" Number of additional seconds to wait: "); gd = new GridData(); gd.horizontalSpan = 2; label.setLayoutData(gd); final Text field = new Text(container, SWT.SINGLE); field.setText("" + (timeout + 500) / 1000); gd = new GridData(); gd.horizontalSpan = 2; gd.grabExcessHorizontalSpace = true; gd.minimumWidth = 80; field.setLayoutData(gd); SelectionListener listener = new SelectionListener() { @Override public void widgetDefaultSelected(SelectionEvent e) { } @Override public void widgetSelected(SelectionEvent e) { if (e.widget == b1) { _newTimeout = 0; field.setEnabled(false); label.setEnabled(false); } else if (e.widget == b2) { _newTimeout = -1; field.setEnabled(false); label.setEnabled(false); } else { field.setEnabled(true); label.setEnabled(true); try { _newTimeout = Integer.parseInt(field.getText()) * 1000; } catch (NumberFormatException e1) { field.setText("0"); _newTimeout = 0; } } } }; b1.addSelectionListener(listener); b2.addSelectionListener(listener); b3.addSelectionListener(listener); field.addModifyListener(new ModifyListener() { @Override public void modifyText(ModifyEvent e) { try { if (b3.getSelection()) { _newTimeout = Integer.parseInt(field.getText()) * 1000; if (_newTimeout < 0) { field.setText("0"); _newTimeout = 0; } } } catch (NumberFormatException e1) { field.setText("0"); _newTimeout = 0; } } }); return container; } }; if (dialog.open() != Window.OK) { _newTimeout = 0; // terminate immediately. } } }); return _newTimeout; } }); /* * Set the Run wrapper for all engine callbacks so that they are in the UI thread. */ SeeCodePlugin.getDefault().setCallbackRunner(new IRunner() { @Override public void invoke(Runnable run, boolean async) throws Throwable { Display display = PlatformUI.getWorkbench().getDisplay(); try { // Run asynchronously to avoid deadlock of UI thread is // waiting for the engine to return. // display is null or disposed after workbench has shutdown, // but the engine may still be sending stuff... if (display != null && !display.isDisposed()) { if (async) { display.asyncExec(run); } else display.syncExec(run); } } catch (SWTException e) { if (e.throwable != null) { // If the display is disposed of after the above // check, but before the "run" is invoked, then // we can get an exception. Ignore such cases. if (display != null && !display.isDisposed()) throw e.throwable; } throw e; } } }); }
From source file:com.arc.cdt.debug.seecode.ui.UISeeCodePlugin.java
License:Open Source License
private void checkLicensingAlert(final int daysRemaining) { final int alertDays = SeeCodePlugin.getDefault().getPreferences().getInt( ISeeCodeConstants.PREF_LICENSE_EXPIRATION_DAYS, ISeeCodeConstants.DEF_PREF_LICENSE_EXPIRATION_DAYS); if (daysRemaining >= 0) { boolean alert = SeeCodePlugin.getDefault().getPreferences() .getBoolean(ISeeCodeConstants.PREF_LICENSE_EXPIRATION_ALERT, true); if (alertDays >= daysRemaining) { if (alert) { PlatformUI.getWorkbench().getDisplay().syncExec(new Runnable() { @Override/*from ww w .j a va 2 s.c om*/ public void run() { Shell shell = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell(); String s; if (daysRemaining == 0) s = "after today"; else if (daysRemaining == 1) s = "after tomorrow"; else s = "in " + daysRemaining + " days"; MessageDialog dialog = new MessageDialog(shell, "License Expiration Alert", null, // accept "Debugger license will expire " + s, MessageDialog.WARNING, new String[] { IDialogConstants.OK_LABEL }, 0) { @Override protected Control createCustomArea(Composite parent) { if (daysRemaining > 0 && daysRemaining <= 2) { Label label = new Label(parent, SWT.RIGHT); GridData data = new GridData(); data.horizontalAlignment = GridData.END; data.grabExcessHorizontalSpace = true; label.setLayoutData(data); label.setText("You will be reminded again tomorrow."); setAlertDays(daysRemaining - 1); return label; } if (daysRemaining > 0) { Composite container = new Composite(parent, 0); GridData data = new GridData(); data.horizontalAlignment = GridData.END; data.grabExcessHorizontalSpace = true; container.setLayoutData(data); container.setLayout(new GridLayout(3, false)); Label label1 = new Label(container, SWT.LEFT); label1.setText("Remind me again when "); final Combo combo = new Combo(container, SWT.DROP_DOWN | SWT.READ_ONLY); Label label2 = new Label(container, SWT.LEFT); label2.setText(" days remain."); label2.setLayoutData(data); for (int i = Math.min(15, daysRemaining - 1); i >= 0; i--) { combo.add("" + i); } combo.select(0); setAlertDays(Integer.parseInt(combo.getItem(0))); combo.addSelectionListener(new SelectionListener() { @Override public void widgetDefaultSelected(SelectionEvent e) { } @Override public void widgetSelected(SelectionEvent e) { setAlertDays(Integer.parseInt(combo.getText())); } }); return container; } return null; } }; if (dialog.open() == Window.OK) { SeeCodePlugin.getDefault().getPreferences() .putInt(ISeeCodeConstants.PREF_LICENSE_EXPIRATION_DAYS, mAlertDays); } } }); } } else if (daysRemaining > ISeeCodeConstants.DEF_PREF_LICENSE_EXPIRATION_DAYS && alertDays != ISeeCodeConstants.DEF_PREF_LICENSE_EXPIRATION_DAYS) { // License has been renewed. Reset things to default. restoreDefaultAlertDays(); } } else if (alertDays != ISeeCodeConstants.DEF_PREF_LICENSE_EXPIRATION_DAYS) { // Evidently a permanent license; make sure we reset alert if he previously // had an expired one. restoreDefaultAlertDays(); } }
From source file:com.arc.cdt.debug.seecode.ui.UISeeCodePlugin.java
License:Open Source License
/** * Show an note box./*from w ww . j av a 2s. com*/ * (We use JFace ErrorDialog instead of MessageBox. The latter is done outside * of Java and the WindowTester framework loses control). * @param title * @param message */ public static void showNote(String title, String message) { Shell shell = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell(); MessageDialog dialog = new MessageDialog(shell, title, null, // accept // the // default // window // icon message, MessageDialog.INFORMATION, new String[] { IDialogConstants.OK_LABEL }, 0); dialog.setBlockOnOpen(false); // we want to be able to make box expire // ok is the default dialog.open(); long expireTime = System.currentTimeMillis() + NOTE_TIME_OUT; Display display = shell.getDisplay(); try { while (dialog.getShell() != null && !dialog.getShell().isDisposed() && System.currentTimeMillis() < expireTime) { if (!display.readAndDispatch()) { display.sleep(); } } } finally { if (dialog.getShell() != null && !dialog.getShell().isDisposed()) { dialog.close(); } } }
From source file:com.archimatetool.editor.model.impl.EditorModelManager.java
License:Open Source License
/** * Show dialog to save modified model/*from w ww . j a v a2 s . c o m*/ * @param model * @return true if the user chose to save the model or chose not to save the model, false if cancelled * @throws IOException */ private boolean askSaveModel(IArchimateModel model) throws IOException { MessageDialog dialog = new MessageDialog(Display.getCurrent().getActiveShell(), Messages.EditorModelManager_6, null, NLS.bind(Messages.EditorModelManager_7, model.getName()), MessageDialog.QUESTION, new String[] { IDialogConstants.YES_LABEL, IDialogConstants.NO_LABEL, IDialogConstants.CANCEL_LABEL }, 0); int result = dialog.open(); // Yes if (result == 0) { return saveModel(model); } // No if (result == 1) { return true; } // Cancel return false; }
From source file:com.architexa.org.eclipse.gef.ui.palette.customize.PaletteCustomizerDialog.java
License:Open Source License
/** * This is the method that is called everytime the selection in the outline * (treeviewer) changes. //from w w w . j a v a2s.c om */ protected void handleOutlineSelectionChanged() { PaletteEntry entry = getSelectedPaletteEntry(); if (activeEntry == entry) { return; } if (errorMessage != null) { MessageDialog dialog = new MessageDialog(getShell(), PaletteMessages.ERROR, null, PaletteMessages.ABORT_PAGE_FLIPPING_MESSAGE + "\n" + errorMessage, //$NON-NLS-1$ MessageDialog.ERROR, new String[] { IDialogConstants.OK_LABEL }, 0); dialog.open(); treeviewer.addPostSelectionChangedListener(pageFlippingPreventer); } else { setActiveEntry(entry); } updateActions(); }
From source file:com.arm.cmsis.pack.installer.CpPackInstaller.java
License:Open Source License
protected int timeoutQuestion(String pdscUrl) { Display.getDefault().syncExec(() -> { MessageDialog dialog = new MessageDialog(null, Messages.CpPackInstaller_Timout, null, NLS.bind(Messages.CpPackInstaller_TimeoutMessage, pdscUrl, TIME_OUT / 1000), MessageDialog.QUESTION_WITH_CANCEL, new String[] { IDialogConstants.YES_LABEL, IDialogConstants.NO_LABEL, IDialogConstants.CANCEL_LABEL }, 0);//from w w w . j a va2 s . c om wait = dialog.open(); }); return wait; }
From source file:com.arm.cmsis.pack.installer.jobs.CpPackUnpackJob.java
License:Open Source License
private boolean myRun(IProgressMonitor monitor) { SubMonitor progress = SubMonitor.convert(monitor, 100); File sourceFile = new File(fSourceFilePath); monitor.setTaskName(Messages.CpPackUnpackJob_Unpacking + sourceFile.toString()); if (fDestPath.toFile().exists()) { final String messageString = NLS.bind(Messages.CpPackUnpackJob_PathAlreadyExists, fDestPath.toOSString()); Display.getDefault().syncExec(new Runnable() { @Override//www . j a v a2 s.c om public void run() { final MessageDialog dialog = new MessageDialog(Display.getDefault().getActiveShell(), Messages.CpPackUnpackJob_OverwriteQuery, null, messageString, MessageDialog.QUESTION, new String[] { IDialogConstants.YES_LABEL, IDialogConstants.NO_LABEL, IDialogConstants.CANCEL_LABEL }, 0); returnCode = dialog.open(); } }); if (returnCode == IDialogConstants.OK_ID) { Utils.deleteFolderRecursive(fDestPath.toFile()); } else { fResult.setSuccess(false); fResult.setErrorString(Messages.CpPackJob_CancelledByUser); return false; } } if (!sourceFile.exists()) { fResult.setSuccess(false); fResult.setErrorString(sourceFile.toString() + Messages.CpPackUnpackJob_SourceFileCannotBeFound); return true; } try { if (!fPackInstaller.unzip(sourceFile, fDestPath, progress.newChild(95))) { fResult.setSuccess(false); fResult.setErrorString(Messages.CpPackJob_CancelledByUser); Utils.deleteFolderRecursive(fDestPath.toFile()); return false; } if (fPack != null) { // unpack job fPack.setPackState(PackState.INSTALLED); fPack.setFileName(fDestPath.append(fPack.getPackFamilyId() + CmsisConstants.EXT_PDSC).toString()); fResult.setPack(fPack); fResult.setSuccess(true); return true; } Collection<String> files = new LinkedList<>(); Utils.findPdscFiles(fDestPath.toFile(), files, 1); if (files.isEmpty()) { Utils.deleteFolderRecursive(fDestPath.toFile()); fResult.setSuccess(false); fResult.setErrorString(Messages.CpPackUnpackJob_PdscFileNotFoundInFolder + fDestPath.toOSString()); return true; } String file = files.iterator().next(); ICpXmlParser parser = CpPlugIn.getPackManager().getParser(); fPack = (ICpPack) parser.parseFile(file); if (fPack != null) { ICpItem urlItem = fPack.getFirstChild(CmsisConstants.URL); if (urlItem == null || !Utils.isValidURL(urlItem.getText())) { fPack.setPackState(PackState.GENERATED); } else { fPack.setPackState(PackState.INSTALLED); } fResult.setPack(fPack); fResult.setSuccess(true); return true; } Utils.deleteFolderRecursive(fDestPath.toFile()); StringBuilder sb = new StringBuilder(Messages.CpPackUnpackJob_FailToParsePdscFile + file); for (String es : parser.getErrorStrings()) { sb.append(System.lineSeparator()); sb.append(es); } fResult.setErrorString(sb.toString()); fResult.setSuccess(false); return true; } catch (IOException e) { fResult.setSuccess(false); fResult.setErrorString(Messages.CpPackUnpackJob_FailedToUnzipFile + sourceFile.toString()); Utils.deleteFolderRecursive(fDestPath.toFile()); return true; } }
From source file:com.arm.cmsis.pack.installer.OverwriteQuery.java
License:Open Source License
@Override public String queryOverwrite(String pathString) { Path path = new Path(pathString); String messageString;//from www . j av a 2s . c om //Break the message up if there is a file name and a directory //and there are at least 2 segments. if (path.getFileExtension() == null || path.segmentCount() < 2) { messageString = NLS.bind(Messages.OverwriteQuery_ExistsQuestion, pathString); } else { messageString = NLS.bind(Messages.OverwriteQuery_OverwriteNameAndPathQuestion, path.lastSegment(), path.removeLastSegments(1).toOSString()); } final MessageDialog dialog = new MessageDialog(shell, Messages.OverwriteQuery_Question, null, messageString, MessageDialog.QUESTION, new String[] { IDialogConstants.YES_LABEL, IDialogConstants.YES_TO_ALL_LABEL, IDialogConstants.NO_LABEL, IDialogConstants.NO_TO_ALL_LABEL, IDialogConstants.CANCEL_LABEL }, 0) { @Override protected int getShellStyle() { return super.getShellStyle() | SWT.SHEET; } }; String[] response = new String[] { YES, ALL, NO, NO_ALL, CANCEL }; //run in syncExec because callback is from an operation, //which is probably not running in the UI thread. shell.getDisplay().syncExec(new Runnable() { @Override public void run() { dialog.open(); } }); return dialog.getReturnCode() < 0 ? CANCEL : response[dialog.getReturnCode()]; }
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;/* ww w . java 2 s . c o 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;/*from ww w . j av a 2 s . c om*/ 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(); }