List of usage examples for org.eclipse.jface.dialogs MessageDialog getReturnCode
public int getReturnCode()
From source file:org.eclipse.e4.demio.views.nav.NavigatorDropAdapter.java
License:Open Source License
public String queryOverwrite(String pathString) { if (alwaysOverwrite) { return ALL; }//w w w . j a v a 2s. c o m final String returnCode[] = { CANCEL }; final String msg = NLS.bind(ResourceNavigatorMessages.DropAdapter_overwriteQuery, pathString); final String[] options = { IDialogConstants.YES_LABEL, IDialogConstants.YES_TO_ALL_LABEL, IDialogConstants.NO_LABEL, IDialogConstants.CANCEL_LABEL }; getDisplay().syncExec(new Runnable() { public void run() { MessageDialog dialog = new MessageDialog(getShell(), ResourceNavigatorMessages.DropAdapter_question, null, msg, MessageDialog.QUESTION, options, 0); dialog.open(); int returnVal = dialog.getReturnCode(); String[] returnCodes = { YES, ALL, NO, CANCEL }; returnCode[0] = returnVal < 0 ? CANCEL : returnCodes[returnVal]; } }); if (returnCode[0] == ALL) { alwaysOverwrite = true; } return returnCode[0]; }
From source file:org.eclipse.e4.xwt.tools.ui.designer.wizards.ExternalizeStringsWizard.java
License:Open Source License
/** * Show a dialog to ask user whether to open the created files. * //from w w w.ja va2 s. co m * @throws returnWizardPage */ private void showOpenFileDialog() throws returnWizardPage { String dialogMessage = "Do you want to open " + externalizeStringsWizardPage.getInfo().getClassName() + ".java and " + externalizeStringsWizardPage.getInfo().getPropertyName() + ".properties after finish?"; String[] dialogButtonLabels = { "Open", "Cancel" }; MessageDialog messageDialog = new MessageDialog(getShell(), "Open created files", null, dialogMessage, MessageDialog.QUESTION, dialogButtonLabels, 1); messageDialog.open(); if (messageDialog.getReturnCode() == 0) { openFlag = true; } else if (messageDialog.getReturnCode() == -1) { throw new returnWizardPage(); } else { openFlag = false; } }
From source file:org.eclipse.jubula.client.ui.rcp.controllers.dnd.DropFileOperation.java
License:Open Source License
/** * Asks the user to confirm the import operation * @param files the list of file URLs/*from ww w.j ava 2s . co m*/ * @return whether the operation can proceed */ private static boolean canProceed(List<URL> files) { StringBuilder builder = new StringBuilder(); builder.append(Messages.ConfirmImportDialogText); File f; URI uri; for (URL url : files) { builder.append(StringConstants.SPACE); builder.append(StringConstants.SPACE); try { uri = url.toURI(); builder.append(Paths.get(uri).getFileName().toString()); f = new File(uri); builder.append(StringConstants.SPACE); builder.append(StringConstants.LEFT_PARENTHESES); builder.append(f.length()); builder.append(StringConstants.SPACE); builder.append(Messages.Bytes); builder.append(StringConstants.RIGHT_PARENTHESES); builder.append(StringConstants.NEWLINE); } catch (URISyntaxException e) { // nothing, we just don't list this 'file's } } MessageDialog dialog = new MessageDialog(null, Messages.ConfirmImportDialogTitle, null, builder.toString(), MessageDialog.QUESTION, new String[] { Messages.DialogMessageButton_YES, Messages.DialogMessageButton_NO }, 0); dialog.create(); DialogUtils.setWidgetNameForModalDialog(dialog); dialog.open(); return dialog.getReturnCode() == 0; }
From source file:org.eclipse.jubula.client.ui.rcp.controllers.dnd.objectmapping.OMEditorDndSupport.java
License:Open Source License
/** * Checks whether mapping the CNs to the Technical Name creates any problems * if yes, the user is notified and can cancel the action * @param compNamesToMove The Component Names to assign. * @param target The association to which the Component Names will be * assigned./* w w w . j av a 2 s . co m*/ * @param editor Editor in which the assignment is taking place. * @return whether the operation is cancelled by the user */ private static boolean checkProblemsAndStop(List<IComponentNamePO> compNamesToMove, IObjectMappingAssoziationPO target, ObjectMappingMultiPageEditor editor) { List<IComponentNamePO> problems = new ArrayList<>(); List<Component> availableComponents = ComponentBuilder.getInstance().getCompSystem() .getComponents(editor.getAut().getToolkit(), true); String type = null; if (target.getTechnicalName() != null) { type = CompSystem.getComponentType(target.getTechnicalName().getSupportedClassName(), availableComponents); } IComponentNamePO masterCN; for (IComponentNamePO cN : compNamesToMove) { masterCN = CompNameManager.getInstance().getResCompNamePOByGuid(cN.getGuid()); if (masterCN == null) { continue; } if (!masterCN.getUsageType().equals(ComponentNamesBP.UNKNOWN_COMPONENT_TYPE) && !CompNameTypeManager.doesFirstTypeRealizeSecond(type, masterCN.getUsageType())) { problems.add(masterCN); } } if (problems.isEmpty()) { return false; } StringBuilder list = new StringBuilder(); for (IComponentNamePO cN : problems) { list.append(StringConstants.SPACE); list.append(StringConstants.SPACE); list.append(StringConstants.SPACE); list.append(cN.getName()); list.append(StringConstants.SPACE); list.append(StringConstants.LEFT_BRACKET); list.append(CompSystemI18n.getString(cN.getUsageType())); list.append(StringConstants.RIGHT_BRACKET); list.append(StringConstants.NEWLINE); } String message = NLS.bind(Messages.IncompatibleMapDialogText, list.toString()); MessageDialog dialog = new MessageDialog(null, Messages.IncompatibleMapDialogTitle, null, message, MessageDialog.QUESTION, new String[] { Messages.DialogMessageButton_YES, Messages.DialogMessageButton_NO }, 0); dialog.create(); DialogUtils.setWidgetNameForModalDialog(dialog); dialog.open(); return dialog.getReturnCode() != 0; }
From source file:org.eclipse.jubula.client.ui.rcp.dialogs.CNTypeProblemDialog.java
License:Open Source License
/** * Presents the user with the Dialog and returns their decision * @param problems the CN Type problems//from www .j av a2 s . c o m * @return whether continue with the problem-causing action */ public boolean canCommence(Map<String, ProblemType> problems) { List<String> info; StringBuilder msg = new StringBuilder(); int num = 0; for (String guid : problems.keySet()) { info = m_calc.getProblemInfo(guid); IComponentNamePO cN = m_cache.getResCompNamePOByGuid(guid); if (cN == null) { continue; } msg.append(cN.getName()); msg.append(StringConstants.COLON); msg.append(StringConstants.SPACE); if (problems.get(guid).equals(ProblemType.REASON_INCOMPATIBLE_MAP_TYPE)) { msg.append(StringConstants.NEWLINE); msg.append("Mapped to: "); //$NON-NLS-1$ msg.append(StringConstants.QUOTE); msg.append(info.get(0)); msg.append(StringConstants.QUOTE); msg.append(StringConstants.COMMA); msg.append(StringConstants.SPACE); msg.append("used as: "); //$NON-NLS-1$ msg.append(StringConstants.QUOTE); msg.append(info.get(1)); msg.append(StringConstants.QUOTE); msg.append(StringConstants.NEWLINE); } else { msg.append(StringConstants.NEWLINE); for (int i = 0; i < 6; i++) { msg.append(StringConstants.SPACE); } msg.append("Used as "); //$NON-NLS-1$ msg.append(StringConstants.QUOTE); msg.append(info.get(0)); msg.append(StringConstants.QUOTE); msg.append(" and "); //$NON-NLS-1$ msg.append(StringConstants.QUOTE); msg.append(info.get(1)); msg.append(StringConstants.QUOTE); msg.append(StringConstants.NEWLINE); } num++; if (num > 10) { msg.append(StringConstants.DOT); msg.append(StringConstants.DOT); msg.append(StringConstants.DOT); msg.append(StringConstants.NEWLINE); break; } } String message = NLS.bind(Messages.IncompatiblePairChangeDialogText, msg.toString()); MessageDialog dialog = new MessageDialog(null, Messages.IncompatiblePairChangeDialogTitle, null, message, MessageDialog.QUESTION, new String[] { Messages.DialogMessageButton_YES, Messages.DialogMessageButton_NO }, 0); dialog.create(); DialogUtils.setWidgetNameForModalDialog(dialog); dialog.open(); return dialog.getReturnCode() == 0; }
From source file:org.eclipse.jubula.client.ui.rcp.editors.TestCaseEditor.java
License:Open Source License
/** * Shows information dialog that saving on observation mode is not allowed * @return returnCode of Dialog//from w ww . jav a 2 s . co m */ private int showSaveInObservModeDialog() { MessageDialog dialog = new MessageDialog(Plugin.getActiveWorkbenchWindowShell(), Messages.SaveInObservationModeDialogTitle, null, Messages.SaveInObservationModeDialogQuestion, MessageDialog.QUESTION, new String[] { Messages.DialogMessageButton_YES, Messages.DialogMessageButton_NO }, 0); dialog.create(); DialogUtils.setWidgetNameForModalDialog(dialog); dialog.open(); return dialog.getReturnCode(); }
From source file:org.eclipse.jubula.client.ui.rcp.handlers.AUTAgentDisconnectHandler.java
License:Open Source License
/** * {@inheritDoc}// ww w . j ava 2 s .c o m */ public Object executeImpl(ExecutionEvent event) { if (isJobRunning()) { MessageDialog dialog = getConfirmDialog(); if (dialog.getReturnCode() != Window.OK) { return null; } m_jobManager.cancel(m_jobFamily); } TestExecutionGUIController.disconnectFromServer(); return null; }
From source file:org.eclipse.jubula.client.ui.rcp.handlers.delete.AbstractDeleteTreeItemHandler.java
License:Open Source License
/** * Pops up a "confirmDelete" dialog./*from w w w.j a v a2 s. c o m*/ * * @param itemNames * The names of the items to be deleted. * @return <code>true</code>, if "yes" was clicked, * <code>false</code> otherwise. */ public boolean confirmDelete(Collection<String> itemNames) { String label = StringConstants.EMPTY; if (itemNames.size() == 1) { label = NLS.bind(Messages.DeleteTreeItemActionDeleteOneItem, itemNames.iterator().next()); } else if (itemNames.size() == 0) { return false; } else { label = NLS.bind(Messages.DeleteTreeItemActionDeleteMultipleItems, itemNames.size()); } MessageDialog dialog = new MessageDialog(getActiveShell(), Messages.DeleteTreeItemActionShellTitle, null, label, MessageDialog.QUESTION, new String[] { Messages.DialogMessageButton_YES, Messages.DialogMessageButton_NO }, 0); dialog.create(); DialogUtils.setWidgetNameForModalDialog(dialog); dialog.open(); return dialog.getReturnCode() == 0; }
From source file:org.eclipse.jubula.client.ui.rcp.handlers.DeleteTestresultsHandler.java
License:Open Source License
/** * Shows information dialog, that selected testresults will be deleted * @return returnCode of Dialog//from ww w .j a va 2 s . c om */ private int showDeleteTestresultsDialog() { MessageDialog dialog = new MessageDialog(getActiveShell(), Messages.TestresultSummaryDeleteTestrunDialogTitle, null, Messages.TestresultSummaryDeleteTestrunDialogMessage, MessageDialog.QUESTION, new String[] { Messages.DialogMessageButton_YES, Messages.DialogMessageButton_NO }, 0); dialog.create(); DialogUtils.setWidgetNameForModalDialog(dialog); dialog.open(); return dialog.getReturnCode(); }
From source file:org.eclipse.jubula.client.ui.rcp.handlers.RevertEditorChangesHandler.java
License:Open Source License
/** * {@inheritDoc}//from ww w. java2 s .c om */ public Object executeImpl(ExecutionEvent event) { final IWorkbenchPart activePart = Plugin.getActivePart(); if (activePart == null) { return null; } final IJBEditor editor = activePart.getAdapter(IJBEditor.class); if (editor != null) { MessageDialog dialog = showConfirmDialog(); if (dialog.getReturnCode() == Window.OK) { revertEditorChanges(editor); } } return null; }