List of usage examples for org.eclipse.jface.dialogs MessageDialog open
public int open()
From source file:com.vectrace.MercurialEclipse.menu.TransplantHandler.java
License:Open Source License
@Override protected void run(final HgRoot hgRoot) throws CoreException { if (HgStatusClient.isDirty(hgRoot)) { MessageDialog dialog = new MessageDialog(null, Messages.getString("TransplantHandler.dirtyTitle"), null, Messages.getString("TransplantHandler.dirtyMessage"), MessageDialog.QUESTION, new String[] { Messages.getString("TransplantHandler.cancel"), Messages.getString("TransplantHandler.continue") }, 0);/*from www . ja v a 2 s . c o m*/ if (dialog.open() == 1) { TransplantOperation op = TransplantOperation .createContinueOperation(MercurialEclipsePlugin.getActiveWindow(), hgRoot); try { op.run(); } catch (InvocationTargetException e) { MercurialEclipsePlugin.showError(e.getTargetException()); } catch (InterruptedException e) { MercurialEclipsePlugin.logError(e); } } } else { TransplantWizard transplantWizard = new TransplantWizard(hgRoot); WizardDialog transplantWizardDialog = new WizardDialog(getShell(), transplantWizard); transplantWizardDialog.open(); } }
From source file:com.vectrace.MercurialEclipse.menu.UpdateJob.java
License:Open Source License
/** * Call from the UI thread.//from www . j a v a 2s . c o m * @return True if loss was confirmed. */ private static boolean showConfirmDataLoss(Shell shell) { MessageDialog dialog = new MessageDialog(shell, Messages.getString("UpdateJob.uncommittedChanges1"), null, Messages.getString("UpdateJob.uncommittedChanges2"), MessageDialog.CONFIRM, new String[] { Messages.getString("UpdateJob.continueAndDiscard"), IDialogConstants.CANCEL_LABEL }, 1 // default index - cancel ); dialog.setBlockOnOpen(true); return dialog.open() == 0; }
From source file:com.vectrace.MercurialEclipse.wizards.ProjectsImportPage.java
License:Open Source License
/** * The <code>WizardDataTransfer</code> implementation of this * <code>IOverwriteQuery</code> method asks the user whether the existing * resource at the given path should be overwritten. * * @param pathString//from w ww . j a v a2 s .co m * @return the user's reply: one of <code>"YES"</code>, <code>"NO"</code>, * <code>"ALL"</code>, or <code>"CANCEL"</code> */ public String queryOverwrite(String pathString) { Path path = new Path(pathString); String messageString; // 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 = "'" + pathString + "' already exists. Would you like to overwrite it?"; } else { messageString = "Overwrite '" + path.lastSegment() + "' in folder '" + path.removeLastSegments(1).toOSString() + "'?"; } final MessageDialog dialog = new MessageDialog(getContainer().getShell(), "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() { // TODO add "| SWT.SHEET" flag as soon as we drop Eclipse 3.4 support 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. getControl().getDisplay().syncExec(new Runnable() { public void run() { dialog.open(); } }); return dialog.getReturnCode() < 0 ? CANCEL : response[dialog.getReturnCode()]; }
From source file:com.vmware.vfabric.ide.eclipse.tcserver.insight.internal.ui.TcServerInsightSection.java
License:Open Source License
@Override public void createSection(Composite parent) { super.createSection(parent); FormToolkit toolkit = getFormToolkit(parent.getDisplay()); Section section = toolkit.createSection(parent, ExpandableComposite.TWISTIE | ExpandableComposite.TITLE_BAR | Section.DESCRIPTION | ExpandableComposite.FOCUS_TITLE | ExpandableComposite.EXPANDED); section.setText("Overview"); section.setDescription("Enable collection of performance metrics for deployed applications."); section.setLayoutData(new GridData(GridData.FILL_HORIZONTAL | GridData.VERTICAL_ALIGN_FILL)); Composite composite = toolkit.createComposite(section); GridLayout layout = new GridLayout(2, false); layout.marginHeight = 8;//from ww w. ja v a 2 s . c om layout.marginWidth = 8; composite.setLayout(layout); toolkit.paintBordersFor(composite); section.setClient(composite); button = toolkit.createButton(composite, "Enable gathering of metrics", SWT.CHECK); button.addSelectionListener(new SelectionAdapter() { private boolean ignoreEvents; @Override public void widgetSelected(SelectionEvent e) { if (ignoreEvents) { return; } if (button.getSelection() && server.getOriginal() != null && !TcServerInsightUtil.isInsightCompatible(server.getOriginal())) { MessageDialog dialog = new MessageDialog(getShell(), "Enable Spring Insight", null, "This version of Spring Insight is not compatible with tc Server instances that are installed on a path that contains spaces. Enabling Spring Insight may cause tc Server to fail to startup.\n\n" + "Are you sure you want to enable Spring Insight?", MessageDialog.ERROR, new String[] { IDialogConstants.OK_LABEL, IDialogConstants.CANCEL_LABEL }, 1); if (dialog.open() != 0) { try { ignoreEvents = true; button.setSelection(false); } finally { ignoreEvents = false; } return; } } execute(new ModifyInsightVmArgsCommand(serverInstance, button.getSelection())); } }); GridDataFactory.fillDefaults().span(2, 1).applyTo(button); initialize(); }
From source file:com.wakatime.eclipse.plugin.WakaTime.java
@Override public void earlyStartup() { final IWorkbench workbench = PlatformUI.getWorkbench(); // listen for save file events ICommandService commandService = (ICommandService) workbench.getService(ICommandService.class); executionListener = new CustomExecutionListener(); commandService.addExecutionListener(executionListener); workbench.getDisplay().asyncExec(new Runnable() { public void run() { IWorkbenchWindow window = workbench.getActiveWorkbenchWindow(); if (window == null) return; // prompt for apiKey if not set MenuHandler handler = new MenuHandler(); DEBUG = handler.getDebug();/*w ww . j av a 2 s.com*/ String apiKey = handler.getApiKey(); if (apiKey == "") { handler.promptForApiKey(window); } Dependencies deps = new Dependencies(); if (!deps.isPythonInstalled()) { deps.installPython(); if (!deps.isPythonInstalled()) { MessageDialog dialog = new MessageDialog(window.getShell(), "Warning!", null, "WakaTime needs Python installed. Please install Python from python.org/downloads, then restart Eclipse.", MessageDialog.WARNING, new String[] { IDialogConstants.OK_LABEL }, 0); dialog.open(); } } if (!deps.isCLIInstalled()) { deps.installCLI(); } if (window.getPartService() == null) return; // listen for caret movement if (window.getPartService().getActivePartReference() != null && window.getPartService().getActivePartReference().getPage() != null && window.getPartService().getActivePartReference().getPage().getActiveEditor() != null) { IEditorPart part = window.getPartService().getActivePartReference().getPage().getActiveEditor(); if (!(part instanceof AbstractTextEditor)) return; ((StyledText) part.getAdapter(Control.class)).addCaretListener(new CustomCaretListener()); } // listen for change of active file window.getPartService().addPartListener(editorListener); if (window.getPartService().getActivePart() == null) return; if (window.getPartService().getActivePart().getSite() == null) return; if (window.getPartService().getActivePart().getSite().getPage() == null) return; if (window.getPartService().getActivePart().getSite().getPage().getActiveEditor() == null) return; if (window.getPartService().getActivePart().getSite().getPage().getActiveEditor() .getEditorInput() == null) return; // log file if one is opened by default IEditorInput input = window.getPartService().getActivePart().getSite().getPage().getActiveEditor() .getEditorInput(); if (input instanceof IURIEditorInput) { URI uri = ((IURIEditorInput) input).getURI(); if (uri != null && uri.getPath() != null) { String currentFile = uri.getPath(); long currentTime = System.currentTimeMillis() / 1000; if (!currentFile.equals(WakaTime.getDefault().lastFile) || WakaTime.getDefault().lastTime + WakaTime.FREQUENCY * 60 < currentTime) { WakaTime.logFile(currentFile, WakaTime.getActiveProject(), false); WakaTime.getDefault().lastFile = currentFile; WakaTime.getDefault().lastTime = currentTime; } } } WakaTime.log("Finished initializing WakaTime plugin (https://wakatime.com) v" + VERSION); } }); }
From source file:com.windowtester.eclipse.ui.target.NewTargetProvisionerPage.java
License:Open Source License
protected boolean queryYesNoQuestion(String message) { MessageDialog dialog = new MessageDialog(getContainer().getShell(), "Question", (Image) null, message, MessageDialog.NONE, new String[] { IDialogConstants.YES_LABEL, IDialogConstants.NO_LABEL }, 0); // ensure yes is the default return dialog.open() == 0; }
From source file:com.windowtester.test.eclipse.locator.DialogMessageLocatorSmokeTest.java
License:Open Source License
public void testInfoTextIdentification() throws WidgetSearchException { final Label[] label = new Label[1]; Display.getDefault().asyncExec(new Runnable() { public void run() { MessageDialog dialog = new MessageDialog(getShell(), "Info", null, "Something", MessageDialog.INFORMATION, new String[] { IDialogConstants.OK_LABEL }, 0) { public void create() { super.create(); label[0] = this.messageLabel; //cache label }/*from www .j av a 2 s . co m*/ }; dialog.open(); } }); IUIContext ui = getUI(); ui.wait(new ShellShowingCondition("Info")); assertIsMessageLocator(identify(label[0])); ui.assertThat(new DialogMessageLocator().hasText("Something")); ui.click(new ButtonLocator("OK")); ui.wait(new ShellDisposedCondition("Info")); }
From source file:cu.uci.abos.core.util.MessageDialogUtil.java
License:Open Source License
private static void open(int kind, Shell parent, String title, String message, final DialogCallback callback) { String[] buttonLabels = getButtonLabels(kind); MessageDialog dialog = new MessageDialog(parent, title, null, message, kind, buttonLabels, 0) { private static final long serialVersionUID = 1L; @Override//from w w w. j a v a2s . co m protected int getShellStyle() { return super.getShellStyle() | SWT.SHEET; } @Override public boolean close() { boolean result = super.close(); if (callback != null) { callback.dialogClosed(getReturnCode()); } return result; } }; dialog.setBlockOnOpen(false); dialog.open(); }
From source file:de.anbos.eclipse.easyshell.plugin.preferences.CommandPage.java
License:Open Source License
@Override public boolean performOk() { boolean save = true; if (!CommandDataStore.instance().isMigrated()) { String title = Activator.getResourceString("easyshell.command.page.dialog.migration.title"); String question = Activator.getResourceString("easyshell.command.page.dialog.migration.question"); MessageDialog dialog = new MessageDialog(null, title, null, question, MessageDialog.WARNING, new String[] { "Yes", "No" }, 1); // no is the default int result = dialog.open(); if (result == 0) { CommandDataStore.instance().setMigrated(true); } else {//from w w w . j ava 2 s. c o m save = false; } } if (save) { CommandDataStore.instance().save(); MenuDataStore.instance().save(); } return save; }
From source file:de.anbos.eclipse.easyshell.plugin.preferences.CommandPage.java
License:Open Source License
@Override protected void performDefaults() { // get the selected commands and referenced menus as lists CommandDataList commands = new CommandDataList(CommandDataStore.instance().getDataList()); List<MenuData> menus = new ArrayList<MenuData>(); for (CommandData command : commands) { if (command.getPresetType() == PresetType.presetUser) { List<MenuData> menusForOne = MenuDataStore.instance().getRefencedBy(command.getId()); menus.addAll(menusForOne);/*from ww w. j a v a 2 s.c o m*/ } } String title = Activator.getResourceString("easyshell.command.page.dialog.defaults.title"); String question = Activator.getResourceString("easyshell.command.page.dialog.defaults.question"); int dialogImageType = MessageDialog.QUESTION; if (menus.size() >= 0) { dialogImageType = MessageDialog.WARNING; String menuNames = ""; for (MenuData menu : menus) { menuNames += menu.getNameExpanded() + "\n"; } question = MessageFormat.format( Activator.getResourceString("easyshell.command.page.dialog.defaults.menu.question"), menuNames); } MessageDialog dialog = new MessageDialog(null, title, null, question, dialogImageType, new String[] { "Yes", "No" }, 1); // no is the default int result = dialog.open(); if (result == 0) { if (menus.size() >= 0) { for (MenuData menu : menus) { MenuDataStore.instance().delete(menu); } //MenuDataStore.instance().save(); } CommandDataStore.instance().loadDefaults(); tableViewer.refresh(); } }