List of usage examples for org.eclipse.jface.dialogs MessageDialog openConfirm
public static boolean openConfirm(Shell parent, String title, String message)
From source file:be.ibridge.kettle.trans.step.selectvalues.SelectValuesDialog.java
License:LGPL
/** * Reads in the fields from the previous steps and from the ONE next step and opens an * EnterMappingDialog with this information. After the user did the mapping, those information * is put into the Select/Rename table.//from www .j ava2 s. c om */ private void generateMappings() { if (!bPreviousFieldsLoaded) { MessageDialog.openError(shell, Messages.getString("SelectValuesDialog.ColumnInfo.Loading"), Messages.getString("SelectValuesDialog.ColumnInfo.Loading")); return; } if ((wRemove.getItemCount() > 0) || (wMeta.getItemCount() > 0)) { for (int i = 0; i < wRemove.getItemCount(); i++) { String[] columns = wRemove.getItem(i); for (int a = 0; a < columns.length; a++) { if (columns[a].length() > 0) { MessageDialog.openError(shell, Messages.getString("SelectValuesDialog.DoMapping.NoDeletOrMetaTitle"), Messages.getString("SelectValuesDialog.DoMapping.NoDeletOrMeta")); return; } } } for (int i = 0; i < wMeta.getItemCount(); i++) { String[] columns = wMeta.getItem(i); for (int a = 0; a < columns.length; a++) { String col = columns[a]; if (col.length() > 0) { MessageDialog.openError(shell, Messages.getString("SelectValuesDialog.DoMapping.NoDeletOrMetaTitle"), Messages.getString("SelectValuesDialog.DoMapping.NoDeletOrMeta")); return; } } } } Row nextStepRequiredFields = null; StepMeta stepMeta = new StepMeta(stepname, input); StepMeta[] nextSteps = transMeta.getNextSteps(stepMeta); if (nextSteps.length == 0 || nextSteps.length > 1) { MessageDialog.openError(shell, Messages.getString("SelectValuesDialog.DoMapping.NoNextStepTitle"), Messages.getString("SelectValuesDialog.DoMapping.NoNextStep")); return; } StepMeta outputStepMeta = nextSteps[0]; StepMetaInterface stepMetaInterface = outputStepMeta.getStepMetaInterface(); try { nextStepRequiredFields = stepMetaInterface.getRequiredFields(); } catch (KettleException e) { log.logError(toString(), Messages.getString("SelectValuesDialog.DoMapping.UnableToFindOutput")); nextStepRequiredFields = new Row(); } String[] inputNames = new String[prevFields.size()]; for (int i = 0; i < prevFields.size(); i++) { Value value = prevFields.getValue(i); inputNames[i] = value.getName() + EnterMappingDialog.STRING_ORIGIN_SEPARATOR + value.getOrigin() + ")"; } String[] outputNames = new String[nextStepRequiredFields.size()]; for (int i = 0; i < nextStepRequiredFields.size(); i++) { outputNames[i] = nextStepRequiredFields.getValue(i).getName(); } String[] selectName = new String[wFields.getItemCount()]; String[] selectRename = new String[wFields.getItemCount()]; for (int i = 0; i < wFields.getItemCount(); i++) { selectName[i] = wFields.getItem(i, 1); selectRename[i] = wFields.getItem(i, 2); } ArrayList mappings = new ArrayList(); StringBuffer missingFields = new StringBuffer(); for (int i = 0; i < selectName.length; i++) { String valueName = selectName[i]; String valueRename = selectRename[i]; int inIndex = prevFields.searchValueIndex(valueName); if (inIndex < 0) { missingFields.append(Const.CR + " " + valueName + " --> " + valueRename); continue; } if (null == valueRename || valueRename.equals("")) { valueRename = valueName; } int outIndex = nextStepRequiredFields.searchValueIndex(valueRename); if (outIndex < 0) { missingFields.append(Const.CR + " " + valueName + " --> " + valueRename); continue; } SourceToTargetMapping mapping = new SourceToTargetMapping(inIndex, outIndex); mappings.add(mapping); } // show a confirm dialog if some misconfiguration was found if (missingFields.length() > 0) { boolean goOn = MessageDialog.openConfirm(shell, Messages.getString("SelectValuesDialog.DoMapping.SomeFieldsNotFoundTitle"), Messages.getString( "SelectValuesDialog.DoMapping.SomeFieldsNotFound", missingFields.toString())); if (!goOn) { return; } } EnterMappingDialog d = new EnterMappingDialog(SelectValuesDialog.this.shell, inputNames, outputNames, mappings); mappings = d.open(); // mappings == null if the user pressed cancel if (null != mappings) { wFields.table.removeAll(); wFields.table.setItemCount(mappings.size()); for (int i = 0; i < mappings.size(); i++) { SourceToTargetMapping mapping = (SourceToTargetMapping) mappings.get(i); TableItem item = wFields.table.getItem(i); item.setText(1, prevFields.getValue(mapping.getSourcePosition()).getName()); item.setText(2, outputNames[mapping.getTargetPosition()]); item.setText(3, "-1"); item.setText(4, "-1"); } wFields.setRowNums(); wFields.optWidth(true); wTabFolder.setSelection(0); } }
From source file:bndtools.release.Activator.java
License:Open Source License
public static boolean confirmationMessage(final String msg) { final AtomicBoolean result = new AtomicBoolean(); sync(new Runnable() { @Override/*from w w w . j a v a 2 s .co m*/ public void run() { result.set(MessageDialog.openConfirm(null, Messages.releaseDialogTitle1, msg)); } }); return result.get(); }
From source file:bndtools.utils.EditorUtils.java
License:Open Source License
public static boolean saveEditorIfDirty(final IEditorPart editor, String dialogTitle, String message) { if (editor.isDirty()) { if (MessageDialog.openConfirm(editor.getEditorSite().getShell(), dialogTitle, message)) { IRunnableWithProgress saveRunnable = new IRunnableWithProgress() { @Override//from w w w.j av a 2 s. c om public void run(IProgressMonitor monitor) throws InvocationTargetException, InterruptedException { editor.doSave(monitor); } }; IWorkbenchWindow window = editor.getSite().getWorkbenchWindow(); try { window.run(false, false, saveRunnable); } catch (InvocationTargetException e1) { } catch (InterruptedException e1) { Thread.currentThread().interrupt(); } } } return !editor.isDirty(); }
From source file:br.com.mamom.handlers.QuitHandler.java
License:Open Source License
@Execute public void execute(IWorkbench workbench, Shell shell) { if (MessageDialog.openConfirm(shell, "Confirmation", "Do you want to exit?")) { workbench.close();// w w w . jav a2s .co m } }
From source file:brewery.ui.handlers.QuitHandler.java
License:Open Source License
/** * // w w w. j a v a2s . c om * @param workbench * @param shell */ @Execute public void execute(final IWorkbench workbench, final Shell shell) { if (MessageDialog.openConfirm(shell, "Confirmation", "Do you want to exit?")) { if (port != null) { final SerialPort serialPort = (SerialPort) port; serialPort.notifyOnDataAvailable(false); try { serialPort.getOutputStream().close(); serialPort.getInputStream().close(); } catch (final IOException e) { // TODO Auto-generated catch block e.printStackTrace(); } serialPort.removeEventListener(); port.close(); } workbench.close(); } }
From source file:ca.mcgill.cs.swevo.qualyzer.editors.pages.CodeEditorPage.java
License:Open Source License
/** * The action to take if remove code is selected (on the tree). * @return/* www . j a v a 2 s. com*/ */ private SelectionAdapter removeCodeSelected() { return new SelectionAdapter() { @Override public void widgetSelected(SelectionEvent e) { IStructuredSelection selection = (IStructuredSelection) fTreeViewer.getSelection(); Node node = (Node) selection.getFirstElement(); boolean check = true; if (!node.getChildren().isEmpty()) { check = MessageDialog.openConfirm(getSite().getShell(), Messages.getString("editors.pages.CodeEditorPage.removeCode"), //$NON-NLS-1$ Messages.getString("editors.pages.CodeEditorPage.removeConfirm")); //$NON-NLS-1$ } if (check) { fTreeModel.removeNode(node); fTreeModel.getRoot().computeFreq(); fTreeViewer.refresh(); if (fFilterButton.getSelection()) { fTableViewer.refresh(); } setDirty(); } } }; }
From source file:ca.mcgill.cs.swevo.qualyzer.editors.pages.CodeEditorPage.java
License:Open Source License
/** * Handles the selection of the Delete Code Action on the table. * Checks if there are any memos stopping the deletion. * Then finds all the fragments that contain the code. * Displays a warning/confirmation./*from w w w. j a v a2s.c o m*/ * Removes the code from all associated fragments and then deletes the code. * @return */ private SelectionAdapter deleteCodeSelected() { return new SelectionAdapter() { @Override public void widgetSelected(SelectionEvent e) { IStructuredSelection selection = (IStructuredSelection) fTableViewer.getSelection(); Code toDelete = ((CodeTableRow) selection.getFirstElement()).getCode(); List<Memo> hardConflicts = detectHardConflicts(toDelete); if (!hardConflicts.isEmpty()) { String message = buildErrorString(hardConflicts); MessageDialog.openError(getSite().getShell(), Messages.getString("editors.pages.CodeEditorPage.unableToDelete"), message); //$NON-NLS-1$ return; } List<Fragment> conflicts = detectConflicts(toDelete); boolean check = false; check = MessageDialog.openConfirm(getSite().getShell(), DELETE_CODE, getConfirmMessage(conflicts.size())); if (check && conflicts.size() > 0) { removeCodeFromFragments(toDelete, conflicts); } if (check) { Facade.getInstance().deleteCode(toDelete); CommonNavigator view = (CommonNavigator) PlatformUI.getWorkbench().getActiveWorkbenchWindow() .getActivePage().findView(QualyzerActivator.PROJECT_EXPLORER_VIEW_ID); view.getCommonViewer().refresh(); } } }; }
From source file:ca.mcgill.cs.swevo.qualyzer.editors.RemoveAllCodesAction.java
License:Open Source License
/** * Opens a confirmation dialog and then removes all the codes from the selected fragment. * @see org.eclipse.jface.action.Action#run() *///from w w w . jav a 2 s . co m @SuppressWarnings("unchecked") @Override public void run() { boolean check = MessageDialog.openConfirm(fEditor.getSite().getShell(), Messages.getString("editors.RemoveAllCodesAction.removeAllCodes"), //$NON-NLS-1$ Messages.getString("editors.RemoveAllCodesAction.confirm")); //$NON-NLS-1$ if (!check) { return; } Point selection = fSourceViewer.getSelectedRange(); RTFAnnotationModel model = (RTFAnnotationModel) fSourceViewer.getAnnotationModel(); Iterator<Annotation> iter = model.getAnnotationIterator(); while (iter.hasNext()) { Annotation annotation = iter.next(); if (annotation instanceof FragmentAnnotation) { Position pos = model.getPosition(annotation); if (pos.offset == selection.x && pos.length == selection.y) { model.removeAnnotationOnly(annotation); Fragment fragment = ((FragmentAnnotation) annotation).getFragment(); Facade.getInstance().deleteFragment(fragment); fEditor.setDirty(); break; } } } }
From source file:ca.mcgill.cs.swevo.qualyzer.handlers.DeleteInvestigatorHandler.java
License:Open Source License
/** * Opens a confirmation dialog and then proceeds to delete each investigator that was selected. * @param page/* www . ja va 2s . c om*/ * @param shell * @param toDelete */ private void proceedWithDeletion(IWorkbenchPage page, Shell shell, List<Investigator> toDelete) { String msg = ""; //$NON-NLS-1$ if (toDelete.size() == 1) { msg = Messages.getString("handlers.DeleteInvestigatorHandler.confirm"); //$NON-NLS-1$ } else { msg = Messages.getString("handlers.DeleteInvestigatorHandler.confirm2"); //$NON-NLS-1$ } boolean check = fTesting || MessageDialog.openConfirm(shell, Messages.getString("handlers.DeleteInvestigatorHandler.deleteInvestigator"), msg); //$NON-NLS-1$ if (check) { for (Investigator investigator : toDelete) { Facade.getInstance().deleteInvestigator(investigator); } CommonNavigator view; view = (CommonNavigator) page.findView(QualyzerActivator.PROJECT_EXPLORER_VIEW_ID); view.getCommonViewer().refresh(); } }
From source file:ca.mcgill.cs.swevo.qualyzer.handlers.DeleteParticipantHandler.java
License:Open Source License
/** * Asks for confirmation and then deletes all the participants in toDelete. * @param page//from w w w . java 2s. com * @param shell * @param toDelete */ private void proceedWithDeletion(IWorkbenchPage page, Shell shell, List<Participant> toDelete) { String message = ""; //$NON-NLS-1$ if (toDelete.size() == 1) { message = Messages.getString("handlers.DeleteParticipantHandler.confirm"); //$NON-NLS-1$ } else { message = Messages.getString("handlers.DeleteParticipantHandler.confirmMany"); //$NON-NLS-1$ } boolean check = fTesting || MessageDialog.openConfirm(shell, Messages.getString("handlers.DeleteParticipantHandler.deleteParticipant"), //$NON-NLS-1$ message); //$NON-NLS-1$ if (check) { CommonNavigator view; view = (CommonNavigator) page.findView(QualyzerActivator.PROJECT_EXPLORER_VIEW_ID); for (Participant participant : toDelete) { Facade.getInstance().deleteParticipant(participant); } view.getCommonViewer().refresh(); } }