List of usage examples for org.eclipse.jface.dialogs MessageDialog open
public static boolean open(int kind, Shell parent, String title, String message, int style)
kind
flag. From source file:gov.nasa.ensemble.common.ui.wizard.AbstractEnsembleProjectExportWizardPage.java
License:Open Source License
private void carefullyDisplayErrorDialog(String message) { if (message == null) { message = "Unknown error."; }//from w w w .ja v a 2 s . co m int errorCode = MessageDialog.ERROR; IWizardContainer container = getContainer(); Shell shell = null; if (container != null) { shell = container.getShell(); } // get a shell if the current one is null, we need to show the error. if (shell == null) { shell = WidgetUtils.getShell(); } MessageDialog.open(errorCode, shell, getErrorDialogTitle(), "Error encountered while " + getExportingActionVerb() + " " + getOutputProductNameSingular() + ": " + message, SWT.SHEET); }
From source file:gov.va.isaac.mdht.otf.ui.properties.GenericRefexTableViewer.java
License:Apache License
protected ComponentVersionBI getMemberComponent(RefsetAttributeType memberKind) { ComponentVersionBI component = null; if (memberKind == RefsetAttributeType.Concept) { List<ConceptVersionBI> concepts = null; try {/*from ww w .j ava 2 s.com*/ ConceptSearchDialog searchDialog = new ConceptSearchDialog(getActivePart().getSite().getShell()); searchDialog.open(); concepts = searchDialog.getResults(); } catch (Exception e) { StatusManager.getManager().handle( new Status(IStatus.ERROR, Activator.PLUGIN_ID, "Error in Query Services", e), StatusManager.SHOW | StatusManager.LOG); } if (concepts != null && concepts.size() == 1) { component = concepts.get(0); } else { ConceptListDialog searchDialog = new ConceptListDialog(getActivePart().getSite().getShell()); searchDialog.setConceptList(concepts); int result = searchDialog.open(); if (Dialog.OK == result && searchDialog.getResult().length == 1) { component = (ConceptVersionBI) searchDialog.getResult()[0]; } } } else { // prompt for component UUID InputDialog inputDialog = new InputDialog(getActivePart().getSite().getShell(), "Component UUID", "Enter " + memberKind.name() + " UUID", "", null); if (inputDialog.open() == Window.OK) { String uuidString = inputDialog.getValue(); if (uuidString != null && uuidString.length() > 0) { component = queryService.getComponent(uuidString); } } } if (component != null) { if ((RefsetAttributeType.Concept == memberKind && !(component instanceof ConceptVersionBI)) || (RefsetAttributeType.Description == memberKind && !(component instanceof DescriptionVersionBI)) || (RefsetAttributeType.Relationship == memberKind && !(component instanceof RelationshipVersionBI)) || (RefsetAttributeType.RefsetMember == memberKind && !(component instanceof RefexVersionBI))) { component = null; MessageDialog.open(IStatus.ERROR, getActivePart().getSite().getShell(), "Invalid Member", "Member must be a " + memberKind.toString(), SWT.NONE); } } return component; }
From source file:gov.va.isaac.mdht.otf.ui.properties.GenericRefexTableViewer.java
License:Apache License
@Override protected void createColumns() { // this is called by superclass before subclass fields are initialized refexColumns = new ArrayList<TableViewerColumn>(); refexColumnEditors = new ArrayList<OTFTableEditingSupport>(); final String[] titles = getColumnTitles(); final int[] bounds = getColumnWidths(); final RefsetAttributeType[] columnTypes = getColumnTypes(); for (int i = 0; i < titles.length; i++) { final RefsetAttributeType columnType = columnTypes[i]; final int columnIndex = i; OTFTableEditingSupport refexEditor = new OTFTableEditingSupport(this, columnType) { private CellEditor cellEditor = null; @Override//from w ww . java 2 s.com protected String getOperationLabel() { return "Set refex field"; } @Override protected CellEditor getCellEditor(final Object element) { if (RefsetMember.isPrimitiveType(attributeType)) { cellEditor = new DialogCellEditor(tableViewer.getTable()) { @Override protected Object openDialogBox(Control cellEditorWindow) { Object value = getPrimitiveValue(attributeType); //change the column type if set in the dialog attributeType = primitiveInputDialog.getValueKind(); return value; } }; } else { cellEditor = new DialogCellEditor(tableViewer.getTable()) { @Override protected Object openDialogBox(Control cellEditorWindow) { ComponentVersionBI component = getMemberComponent(attributeType); return component; } }; } return cellEditor; } @Override protected IStatus doSetValue(Object element, Object value) { RefsetMember refsetMember = (RefsetMember) element; if (columnIndex == 0) { Object dialogValue = cellEditor.getValue(); if (dialogValue instanceof ComponentVersionBI) { ComponentVersionBI memberComponent = (ComponentVersionBI) dialogValue; refsetMember.setReferencedComponent(memberComponent); refresh(); } } else if (columnIndex == 1 && RefsetMember.isPrimitiveType(attributeType)) { Object cellValue = cellEditor.getValue(); if (!cellValue.equals(refsetMember.getExtensionValue())) { try { refsetMember.setExtensionValue(cellValue); } catch (NumberFormatException e) { MessageDialog.open(MessageDialog.ERROR, getActivePart().getSite().getShell(), "Invalid Value", "Value must be type: " + attributeType.name(), SWT.NONE); } } } else if (columnIndex > 1) { Object dialogValue = cellEditor.getValue(); if (dialogValue instanceof ComponentVersionBI) { ComponentVersionBI memberComponent = (ComponentVersionBI) dialogValue; refsetMember.getExtensionComponents()[columnIndex - 2] = memberComponent; refresh(); } } return Status.OK_STATUS; } @Override protected Object getValue(Object element) { RefsetMember refex = (RefsetMember) element; if (columnIndex == 0) { return getFirstColumnComponent(refex); } else if (columnIndex == 1 && RefsetMember.isPrimitiveType(attributeType)) { if (refex.getExtensionValue() != null) { return refex.getExtensionValue().toString(); } else { return ""; } } else if (columnIndex > 1) { return refex.getExtensionComponents()[columnIndex - 2]; } return null; } }; TableViewerColumn refexColumn = createTableViewerColumn(titles[columnIndex], bounds[columnIndex], columnIndex); refexColumns.add(columnIndex, refexColumn); refexColumn.setEditingSupport(refexEditor); refexColumnEditors.add(columnIndex, refexEditor); } }
From source file:gov.va.isaac.mdht.otf.ui.properties.RefsetMemberSection.java
License:Apache License
/** * Create blueprint and build chronicle//from w w w . j a va 2 s . c o m */ protected RefexVersionBI<?> buildAndCommit() { RefexVersionBI<?> refexVersion = null; List<RefsetMember> newMembersCopy = new ArrayList<RefsetMember>(newMembers); for (RefsetMember refsetMember : newMembersCopy) { try { refsetMember.validateRefex(); } catch (Exception e) { MessageDialog.open(MessageDialog.ERROR, getPart().getSite().getShell(), "Invalid Refex", e.getMessage(), SWT.NONE); continue; } try { RefexCAB refexCAB = refsetMember.createBlueprint(); refexCAB.recomputeUuid(); refexVersion = builderService.construct(refexCAB); newMembers.remove(refsetMember); } catch (IOException | ContradictionException | InvalidCAB e) { StatusManager.getManager().handle( new Status(IStatus.ERROR, Activator.PLUGIN_ID, "Cannot build Refex version", e), StatusManager.SHOW | StatusManager.LOG); } } try { // commit enclosing concept storeService.addUncommitted(conceptVersion); if (newMembers.isEmpty()) { dirty = false; } } catch (IOException e) { StatusManager.getManager().handle( new Status(IStatus.ERROR, Activator.PLUGIN_ID, "Cannot commit refset member(s)", e), StatusManager.SHOW | StatusManager.LOG); } return refexVersion; }
From source file:info.vancauwenberge.designer.enhtrace.editor.input.StaticTraceEditorInput.java
License:Mozilla Public License
/** * Rescan the list of logmessages to set the root to the latest message with the same 'signature' as the current root. *///from w ww .j a v a 2 s. co m public void rescan() { //Create the path System.out.println("StaticTraceEditorInput.rescan(): start"); List<ILogMessage> path = new ArrayList<ILogMessage>(); ILogMessage pathItem = detailRoot; while (pathItem != null) { path.add(pathItem); pathItem = pathItem.getParent(); } System.out.println("StaticTraceEditorInput.rescan(): Current path:" + path); //The last item in the pathList is the root. Get the latest root from the list corresponding to this ILogMessageList messageList = getActiveList(); if (messageList == null) { MessageDialog.open(MessageDialog.WARNING, null, "No active live trace", "No live trace editor could be found", SWT.NONE); return; } ILogMessage[] events = messageList.getMessages(); //Start with the last message if (events.length > 0) { int index = events.length - 1; while (index >= 0) { ILogMessage previous = events[index]; index--; if (previous.getParent() == null) { if (haveSameSignature(path, path.size() - 1, previous)) { System.out.println("StaticTraceEditorInput.rescan(): found :" + previous); System.out.println("StaticTraceEditorInput.rescan(): previous:" + detailRoot); if (detailRoot == previous) { System.out.println("StaticTraceEditorInput.rescan(): Last found is equal to current"); break; } System.out.println("StaticTraceEditorInput.rescan(): notifying listeners."); ILogMessage oldValue = detailRoot; detailRoot = previous; for (IStaticInputListener aListener : listeners) { aListener.notifyRootChanged(detailRoot, oldValue); } break; } } } } System.out.println("StaticTraceEditorInput.rescan(): end"); }
From source file:melnorme.lang.ide.ui.utils.UIOperationErrorHandlerImpl.java
License:Open Source License
protected void openMessageDialog(int kind, Shell shell, String title, String message) { MessageDialog.open(kind, shell, title, message, SWT.SHEET); }
From source file:melnorme.lang.ide.ui.utils.UIOperationExceptionHandler.java
License:Open Source License
public static void handleError(boolean logError, String message, Throwable exception) { assertNotNull(message);// ww w.j a v a 2s .c o m if (logError) { LangCore.logError(message, exception); } Shell shell = WorkbenchUtils.getActiveWorkbenchShell(); if (exception == null) { MessageDialog.open(SWT.ERROR, shell, "Error: ", message, SWT.SHEET); } else { String exceptionText = getExceptionText(exception); MessageDialog.open(SWT.ERROR, shell, "Error: " + message, exceptionText, SWT.SHEET); } }
From source file:melnorme.lang.ide.ui.utils.UIOperationExceptionHandler.java
License:Open Source License
public static void handleWithErrorDialog(boolean logError, String title, String message, Throwable exception) { if (logError) { LangCore.logError(message, exception); }//w w w . j av a2 s.c o m if (message == null) { message = "Error"; } Shell shell = WorkbenchUtils.getActiveWorkbenchShell(); if (exception == null) { // No point in using ErrorDialog, use simpler dialog MessageDialog.open(SWT.ERROR, shell, title, message, SWT.SHEET); return; } Status status = LangCore.createErrorStatus(getExceptionText(exception), exception); ErrorDialog.openError(shell, title, message, status); }
From source file:msi.gama.gui.swt.commands.ResetSimulationPerspective.java
License:Open Source License
@Override public Object execute(final ExecutionEvent event) throws ExecutionException { IWorkbenchWindow activeWorkbenchWindow = HandlerUtil.getActiveWorkbenchWindow(event); if (activeWorkbenchWindow != null) { WorkbenchPage page = (WorkbenchPage) activeWorkbenchWindow.getActivePage(); if (page != null) { IPerspectiveDescriptor descriptor = page.getPerspective(); if (descriptor != null) { String message = "Resetting the simulation perspective will close the current simulation. Do you want to proceed ?"; boolean result = MessageDialog.open(MessageDialog.QUESTION, activeWorkbenchWindow.getShell(), WorkbenchMessages.ResetPerspective_title, message, SWT.SHEET); if (result) { GAMA.controller.closeExperiment(); page.resetPerspective(); }/* w w w. j a va2 s . co m*/ } } } return null; }