List of usage examples for org.eclipse.jface.dialogs MessageDialog ERROR
int ERROR
To view the source code for org.eclipse.jface.dialogs MessageDialog ERROR.
Click Source Link
From source file:ac.soton.multisim.ui.commands.SimulateCommandHandler.java
License:Open Source License
/** * Validates the editor content.// w w w . j ava 2s . c o m * Returns true if validation has found no problems, otherwise false. * * @param diagramEditor */ public static boolean validate(IEditorPart diagramEditor) { Action validateAction = new ValidateAction(diagramEditor.getSite().getPage()); validateAction.run(); // show error markers if added IResource resource = (IResource) diagramEditor.getEditorInput().getAdapter(IResource.class); if (resource == null) return false; IMarker[] problems = null; int depth = IResource.DEPTH_INFINITE; try { problems = resource.findMarkers(IMarker.PROBLEM, true, depth); if (problems.length > 0) { new MessageDialog(diagramEditor.getSite().getShell(), "Validation", null, "Fix the validation problems first.", MessageDialog.ERROR, new String[] { "OK" }, 0).open(); return false; } } catch (CoreException e) { return false; } return true; }
From source file:carisma.ui.eclipse.editors.AdfEditorMasterDetailsBlock.java
License:Open Source License
/** * Displays a message box which contains a list of problems. *///from w w w.j a v a2s .c om void showProblems() { StringBuffer message = new StringBuffer(""); for (String line : this.controller.getProblems()) { message.append(line + System.getProperty("line.separator")); } MessageDialog messageDialog = new MessageDialog(this.sashForm.getShell(), "Analysis problems", null, message.toString(), MessageDialog.ERROR, new String[] { "OK" }, 0); messageDialog.open(); }
From source file:carisma.ui.eclipse.editors.EditorTranslator.java
License:Open Source License
/** * Opens the editor, which is selected in the adf editor dropdown menu, or the * editors from the editor priority list. * @param defaultEditor Is true, when the Eclipse default editor for this file should be opened * @return An indicator for the success of the method */// w w w . j a va 2 s . c o m public final boolean openEditor(final boolean defaultEditor) { EditorRegistry editorRegistry = CarismaGUI.INSTANCE.getEditorRegistry(); String editorSelectionArt = CarismaGUI.INSTANCE.getPreferenceStore() .getString(Constants.EDITOR_SELECTION_ART); // Priority list if (editorSelectionArt.equals(Constants.AUTO)) { List<String> editorPriorityList = EditorPriorityList.getPriorityList(this.analysis.getModelType()); if (editorPriorityList == null || editorPriorityList.size() < 1) { MessageDialog mDialog = new MessageDialog(Display.getDefault().getActiveShell(), "Error", null, "The editor priority list is empty\n" + "Add editors to the list in the CARiSMA Preferences", MessageDialog.ERROR, new String[] { "OK" }, 0); mDialog.open(); return false; } for (String editorName : editorPriorityList) { EditorDescriptor editorDesc = editorRegistry.getEditorDescriptorByName(editorName); if (editorDesc.forceOpen(this.analysis.getIFile())) { return true; } } // Dropdown menu selection } else { EditorDescriptor editorDesc = null; if (defaultEditor) { // Find Eclipse default editor for this model type editorDesc = getDefaultEditor(); } else { // Find selected editor in the editor registry String selectedEditorId = this.analysis.getSelectedEditorId(); editorDesc = editorRegistry.getEditorDescriptorById(selectedEditorId); } if (editorDesc != null) { if (editorDesc.forceOpen(this.analysis.getIFile())) { return true; } MessageDialog mDialog = new MessageDialog(Display.getDefault().getActiveShell(), "Error", null, "The selected editor cannot be opened", MessageDialog.ERROR, new String[] { "OK" }, 0); mDialog.open(); return false; } MessageDialog mDialog = new MessageDialog(Display.getDefault().getActiveShell(), "Error", null, "The selected editor was not found", MessageDialog.ERROR, new String[] { "OK" }, 0); mDialog.open(); return false; } return false; }
From source file:carisma.ui.eclipse.popup.actions.RunAnalysisAction.java
License:Open Source License
/** * Show a message with name of checks, where the required parameters are not * filled, used to stop Run process if necessary. * @param checksWithUnsetRequiredParameters A list of checks, for those required parameter are not filled *///from w w w.j av a 2 s. c om private static void showUnsetRequiredParameters(final List<CheckReference> checksWithUnsetRequiredParameters) { StringBuffer message = new StringBuffer("Required parameters not set in: \n"); if (checksWithUnsetRequiredParameters.size() > 0) { for (CheckReference check : checksWithUnsetRequiredParameters) { message.append("\""); message.append(check.getCheckID()); message.append("\"\n"); } Display display = Display.getDefault(); Shell shell = new Shell(display); MessageDialog mDialog = new MessageDialog(shell, "Unset required parameter error", null, message.toString(), MessageDialog.ERROR, new String[] { "OK" }, 0); mDialog.open(); } }
From source file:carisma.ui.eclipse.rcp.ForgetEditorHandler.java
License:Open Source License
@Override public final Object execute(final ExecutionEvent event) throws ExecutionException { this.analysis = AnalysisUtil.readAnalysis(this.selectedFile.getLocation().toOSString()); if (this.analysis == null) { return null; } else if (this.analysis.getSelectedEditorId() == null || this.analysis.getSelectedEditorId().equals("")) { Display display = Display.getDefault(); Shell shell = new Shell(display); MessageDialog mDialog = new MessageDialog(shell, "Editor not set", null, "No editor set for this analysis", MessageDialog.ERROR, new String[] { "OK" }, 0); mDialog.open();//from ww w.j a v a2 s . co m return null; } this.analysis.setSelectedEditorId(null); fireHandlerChanged(new HandlerEvent(getHandler(), true, false)); saveChanges(); IWorkbenchPage[] pages = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getPages(); for (IWorkbenchPage page : pages) { for (IEditorReference editorRef : page.getEditorReferences()) { if (editorRef != null && this.selectedFile.getName().equals(editorRef.getName()) && editorRef.getEditor(false) instanceof AdfEditor) { IEditorInput editInput = ((AdfEditor) editorRef.getEditor(false)).getEditorInput(); if (editInput.getAdapter(IFile.class) != null) { IFile file = editInput.getAdapter(IFile.class); this.analysis = AnalysisUtil.readAnalysis(file.getLocation().toOSString()); } } } } return null; }
From source file:cn.dockerfoundry.ide.eclipse.server.ui.internal.DockerFoundryUiCallback.java
License:Open Source License
@Override public void handleError(final IStatus status) { if (status != null && status.getSeverity() == IStatus.ERROR) { UIJob job = new UIJob(Messages.DockerFoundryUiCallback_JOB_CF_ERROR) { public IStatus runInUIThread(IProgressMonitor monitor) { Shell shell = CloudUiUtil.getShell(); if (shell != null) { new MessageDialog(shell, Messages.DockerFoundryUiCallback_ERROR_CALLBACK_TITLE, null, status.getMessage(), MessageDialog.ERROR, new String[] { Messages.COMMONTXT_OK }, 0) .open(); }//www . j a va 2 s. co m return Status.OK_STATUS; } }; job.setSystem(true); job.schedule(); } }
From source file:com.amalto.workbench.dialogs.ImportExchangeOptionsDialog.java
License:Open Source License
private void unzipDownloadRes(boolean export) { JSONObject datum = dataContent[exchangeDwnTable.getSelectionIndex()]; InputStream stream = null;/*from w w w. j a v a 2 s . com*/ OutputStream out = null; try { String url = datum.getString(COLUMN_URL_NAME); stream = HttpClientUtil.getInstreamContentByHttpget(url); if (null == stream) { throw new RuntimeException("cannot get the content stream"); //$NON-NLS-1$ } String downloadFolder = System.getProperty("user.dir") + File.separator + (export ? "temp" : "xsdTemp");//$NON-NLS-1$//$NON-NLS-2$//$NON-NLS-3$ String subFolderForTmp = downloadFolder + File.separator + "tmp" + System.currentTimeMillis();//$NON-NLS-1$ File tempFile = new File(subFolderForTmp + File.separator + "tmp" + System.currentTimeMillis());//$NON-NLS-1$ File dir = new File(downloadFolder); if (!dir.exists()) { dir.mkdir(); } File subDir = new File(subFolderForTmp); if (!subDir.exists()) { subDir.mkdir(); } if (zipFileRepository.length() > 0) { zipFileRepository.delete(0, zipFileRepository.length()); } out = new FileOutputStream(tempFile); IOUtils.copy(stream, out); out.flush(); if (!export) { ZipToFile.unZipFile(tempFile.getAbsolutePath(), subFolderForTmp); boolean result = false; int tryCount = 0; while (!result && tryCount++ < 10) { System.gc(); result = tempFile.delete(); } zipFileRepository.append(subFolderForTmp); } else { zipFileRepository.append(tempFile.getAbsolutePath()); } } catch (Exception e1) { final MessageDialog dialog = new MessageDialog(this.getParentShell().getShell(), Messages.ImportExchangeOptionsDialog_ParsingError, null, e1.getMessage(), MessageDialog.ERROR, new String[] { IDialogConstants.OK_LABEL }, 0); dialog.open(); } finally { IOUtils.closeQuietly(out); IOUtils.closeQuietly(stream); } }
From source file:com.amazonaws.eclipse.ec2.ui.ShellCommandErrorDialog.java
License:Apache License
/** * Creates a new ShellCommandErrorDialog, ready to be opened and display * information the specified ShellCommandException. * /*from w w w . j a v a 2 s. co m*/ * @param sce * The ShellCommandException to display. */ public ShellCommandErrorDialog(ShellCommandException sce) { super(Display.getDefault().getShells()[0], "Error Executing Command", null, sce.getMessage(), MessageDialog.ERROR, new String[] { "Ok" }, 1); this.sce = sce; }
From source file:com.amazonaws.eclipse.explorer.dynamodb.CreateTableSecondPage.java
License:Apache License
public void createControl(Composite parent) { Composite comp = new Composite(parent, SWT.NONE); GridDataFactory.fillDefaults().grab(true, true).applyTo(comp); GridLayoutFactory.fillDefaults().numColumns(1).applyTo(comp); createLinkSection(comp);/* w ww . j av a 2 s. co m*/ // LSI Group lsiGroup = CreateTablePageUtil.newGroup(comp, "Local Secondary Index", 1); GridDataFactory.fillDefaults().grab(true, true).applyTo(lsiGroup); Button addLSIButton = new Button(lsiGroup, SWT.PUSH); addLSIButton.setText("Add Local Secondary Index"); addLSIButton.setImage(AwsToolkitCore.getDefault().getImageRegistry().get(AwsToolkitCore.IMAGE_ADD)); addLSIButton.addSelectionListener(new SelectionListener() { public void widgetSelected(SelectionEvent e) { if (localSecondaryIndexes.size() >= MAX_NUM_LSI) { new MessageDialog(getShell(), "Validation Error", null, "A table cannot have more than five local secondary indexes.", MessageDialog.ERROR, new String[] { "OK", "CANCEL" }, 0).open(); return; } AddLSIDialog addLSIDialog = new AddLSIDialog(Display.getCurrent().getActiveShell(), wizard.getDataModel()); if (addLSIDialog.open() == 0) { // Add the LSI schema object localSecondaryIndexes.add(addLSIDialog.getLocalSecondaryIndex()); // Add the key attribute definitions associated with this LSI localSecondaryIndexKeyAttributes.add(addLSIDialog.getIndexRangeKeyAttributeDefinition()); wizard.collectAllAttribtueDefinitions(); localSecondaryIndexesTable.refresh(); } } public void widgetDefaultSelected(SelectionEvent e) { } }); // LSI label provider IndexTable.IndexTableLabelProvider localSecondaryIndexTableLabelProvider = new IndexTable.IndexTableLabelProvider() { @Override public String getColumnText(Object element, int columnIndex) { if (element instanceof LocalSecondaryIndex == false) return ""; LocalSecondaryIndex index = (LocalSecondaryIndex) element; switch (columnIndex) { case 0: // index name return index.getIndexName(); case 1: // index range key String returnString = ""; returnString += index.getKeySchema().get(1).getAttributeName() + " ("; returnString += findAttributeType(index.getKeySchema().get(1).getAttributeName()) + ")"; return returnString; case 2: // index projection return IndexTable.getProjectionAttributes(index.getProjection(), index.getKeySchema(), wizard.getDataModel()); } return element.toString(); } }; localSecondaryIndexesTable = new IndexTable<LocalSecondaryIndex>(lsiGroup, localSecondaryIndexes, localSecondaryIndexTableLabelProvider) { @Override protected void createColumns(TableColumnLayout columnLayout, Table table) { createColumn(table, columnLayout, "Index Name"); createColumn(table, columnLayout, "Attribute To Index"); createColumn(table, columnLayout, "Projected Attributes"); } @Override protected void onRemoveItem(int removed) { localSecondaryIndexKeyAttributes.remove(removed); wizard.collectAllAttribtueDefinitions(); } }; GridDataFactory.fillDefaults().grab(true, true).applyTo(localSecondaryIndexesTable); // GSI Group gsiGroup = CreateTablePageUtil.newGroup(comp, "Global Secondary Index", 1); GridDataFactory.fillDefaults().grab(true, true).applyTo(gsiGroup); Button addGSIButton = new Button(gsiGroup, SWT.PUSH); addGSIButton.setText("Add Global Secondary Index"); addGSIButton.setImage(AwsToolkitCore.getDefault().getImageRegistry().get(AwsToolkitCore.IMAGE_ADD)); addGSIButton.addSelectionListener(new SelectionListener() { public void widgetSelected(SelectionEvent e) { if (globalSecondaryIndexes.size() >= MAX_NUM_GSI) { new MessageDialog(getShell(), "Validation Error", null, "A table cannot have more than five global secondary indexes.", MessageDialog.ERROR, new String[] { "OK", "CANCEL" }, 0).open(); return; } AddGSIDialog addGSIDialog = new AddGSIDialog(Display.getCurrent().getActiveShell(), wizard.getDataModel()); if (addGSIDialog.open() == 0) { globalSecondaryIndexes.add(addGSIDialog.getGlobalSecondaryIndex()); globalSecondaryIndexKeyAttributes.add(addGSIDialog.getIndexKeyAttributeDefinitions()); wizard.collectAllAttribtueDefinitions(); globalSecondaryIndexesTable.refresh(); } } public void widgetDefaultSelected(SelectionEvent e) { } }); // GSI label provider IndexTable.IndexTableLabelProvider globalSecondaryIndexTableLabelProvider = new IndexTable.IndexTableLabelProvider() { @Override public String getColumnText(Object element, int columnIndex) { if (element instanceof GlobalSecondaryIndex == false) return ""; GlobalSecondaryIndex index = (GlobalSecondaryIndex) element; switch (columnIndex) { case 0: // index name return index.getIndexName(); case 1: // index hash String returnString = ""; returnString += index.getKeySchema().get(0).getAttributeName() + " ("; returnString += findAttributeType(index.getKeySchema().get(0).getAttributeName()) + ")"; return returnString; case 2: // index range returnString = ""; if (index.getKeySchema().size() > 1) { returnString += index.getKeySchema().get(1).getAttributeName() + " ("; returnString += findAttributeType(index.getKeySchema().get(1).getAttributeName()) + ")"; } return returnString; case 3: // index projection return IndexTable.getProjectionAttributes(index.getProjection(), index.getKeySchema(), wizard.getDataModel()); case 4: // index throughput return "Read : " + index.getProvisionedThroughput().getReadCapacityUnits() + ", Write : " + index.getProvisionedThroughput().getWriteCapacityUnits(); default: return ""; } } }; globalSecondaryIndexesTable = new IndexTable<GlobalSecondaryIndex>(gsiGroup, globalSecondaryIndexes, globalSecondaryIndexTableLabelProvider) { @Override protected void createColumns(TableColumnLayout columnLayout, Table table) { createColumn(table, columnLayout, "Index Name"); createColumn(table, columnLayout, "Index Hash Key"); createColumn(table, columnLayout, "Index Range Key"); createColumn(table, columnLayout, "Projected Attributes"); createColumn(table, columnLayout, "Provisioned Throughput"); } @Override protected void onRemoveItem(int removed) { globalSecondaryIndexKeyAttributes.remove(removed); wizard.collectAllAttribtueDefinitions(); } }; GridDataFactory.fillDefaults().grab(true, true).applyTo(globalSecondaryIndexesTable); setControl(comp); }
From source file:com.amazonaws.eclipse.explorer.dynamodb.DynamoDBTableNode.java
License:Apache License
/** * Sets the status of the table that this node represents, and changes to * the corresponding open action.//w w w . ja va2s .c om */ public void setTableStatus(final TableStatus tableStatus) { this.tableStatus = tableStatus; if (tableStatus == null) { setOpenAction(new Action() { @Override public void run() { /* * Update the table status immediately when the node is * being opened, but has not been set with table status. */ AmazonDynamoDB dynamoDBClient = AwsToolkitCore.getClientFactory().getDynamoDBV2Client(); boolean describeTableError = false; TableStatus updatedStatus = null; try { updatedStatus = TableStatus.valueOf( dynamoDBClient.describeTable(new DescribeTableRequest().withTableName(tableName)) .getTable().getTableStatus()); } catch (AmazonServiceException ase) { if (ase.getErrorCode().equalsIgnoreCase("ResourceNotFoundException") == true) { /* Show warning that the table has already been deleted */ MessageDialog dialog = new MessageDialog(Display.getCurrent().getActiveShell(), "Cannot open this table", AwsToolkitCore.getDefault().getImageRegistry() .get(AwsToolkitCore.IMAGE_AWS_ICON), "Table has been deleted.", MessageDialog.ERROR, new String[] { "OK" }, 0); dialog.open(); /* * We need to explicitly refresh the tree view if a * table node has already been deleted in DynamoDB */ DynamoDBContentProvider.getInstance().refresh(); return; } else { describeTableError = true; } } catch (IllegalArgumentException iae) { /* Unrecognized table status */ describeTableError = true; } if (describeTableError) { /* * Still allow the user to open the table editor if we * cannot get the table status now. (But the background * job will still keep trying to update the table * status). */ setOpenAction(new OpenTableEditorAction(tableName)); return; } /* assert: updatedStatus != null */ setTableStatus(updatedStatus); DynamoDBTableNode.this.getOpenAction().run(); } }); } else if (tableStatus == TableStatus.ACTIVE) { /* * Open the table editor only when the node is in ACTIVE status. */ setOpenAction(new OpenTableEditorAction(tableName)); } else { /* * For CREATING/DELETING/UPDATING, suppress opening the table editor. * Show a warning on the table status instead. */ setOpenAction(new Action() { @Override public void run() { /* Show the warning that the table is CREATING/DELETING/UPDATING */ MessageDialog dialog = new MessageDialog(Display.getCurrent().getActiveShell(), "Cannot open this table", AwsToolkitCore.getDefault().getImageRegistry().get(AwsToolkitCore.IMAGE_AWS_ICON), "Cannot open this table(" + tableName + "), since it is in the status of " + tableStatus + ".", MessageDialog.ERROR, new String[] { "OK" }, 0); dialog.open(); } }); } }