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:org.pentaho.di.ui.partition.dialog.PartitionSchemaDialog.java
License:Apache License
public void ok() { getInfo();/* w ww. j a v a 2 s .c o m*/ if (!partitionSchema.getName().equals(originalSchema.getName())) { if (DialogUtils.objectWithTheSameNameExists(partitionSchema, existingSchemas)) { String title = BaseMessages.getString(PKG, "PartitionSchemaDialog.PartitionSchemaNameExists.Title"); String message = BaseMessages.getString(PKG, "PartitionSchemaDialog.PartitionSchemaNameExists", partitionSchema.getName()); String okButton = BaseMessages.getString(PKG, "System.Button.OK"); MessageDialog dialog = new MessageDialog(shell, title, null, message, MessageDialog.ERROR, new String[] { okButton }, 0); dialog.open(); return; } } originalSchema.setName(partitionSchema.getName()); originalSchema.setPartitionIDs(partitionSchema.getPartitionIDs()); originalSchema.setDynamicallyDefined(wDynamic.getSelection()); originalSchema.setNumberOfPartitionsPerSlave(wNumber.getText()); originalSchema.setChanged(); ok = true; dispose(); }
From source file:org.pentaho.di.ui.spoon.dialog.CapabilityManagerDialog.java
License:Apache License
public void open() { final Display display = parent.getDisplay(); shell = new Shell(parent, SWT.DIALOG_TRIM | SWT.RESIZE | SWT.MAX | SWT.MIN); props.setLook(shell);//from ww w. j a v a2 s . com shell.setImage(GUIResource.getInstance().getImageSpoon()); FormLayout formLayout = new FormLayout(); formLayout.marginWidth = Const.FORM_MARGIN; formLayout.marginHeight = Const.FORM_MARGIN; shell.setLayout(formLayout); shell.setText(BaseMessages.getString(getClass(), "CapabilityManager.Dialog.Title")); int margin = Const.MARGIN; Button closeButton = new Button(shell, SWT.PUSH); closeButton.setText(BaseMessages.getString(getClass(), "System.Button.Close")); BaseStepDialog.positionBottomButtons(shell, new Button[] { closeButton, }, margin, null); // Add listeners closeButton.addListener(SWT.Selection, new Listener() { public void handleEvent(Event e) { shell.dispose(); } }); ScrolledComposite scrollpane = new ScrolledComposite(shell, SWT.BORDER | SWT.V_SCROLL); FormData treeFormData = new FormData(); treeFormData.left = new FormAttachment(0, 0); // To the right of the label treeFormData.top = new FormAttachment(0, 0); treeFormData.right = new FormAttachment(100, 0); Label label = new Label(shell, SWT.NONE); label.setText("Capabilities:"); label.setLayoutData(treeFormData); treeFormData = new FormData(); treeFormData.left = new FormAttachment(0, 0); // To the right of the label treeFormData.top = new FormAttachment(label, 0); treeFormData.right = new FormAttachment(100, 0); treeFormData.bottom = new FormAttachment(closeButton, -margin * 2); scrollpane.setLayoutData(treeFormData); scrollpane.setExpandVertical(true); scrollpane.setExpandHorizontal(true); scrollpane.setAlwaysShowScrollBars(true); Composite mainPanel = new Composite(scrollpane, SWT.NONE); scrollpane.setContent(mainPanel); scrollpane.setSize(250, 400); mainPanel.setLayout(new GridLayout(1, false)); Set<ICapability> allCapabilities = DefaultCapabilityManager.getInstance().getAllCapabilities(); SortedSet<ICapability> capabilitySortedSet = new TreeSet<ICapability>(allCapabilities); for (final ICapability capability : capabilitySortedSet) { final Button button = new Button(mainPanel, SWT.CHECK); button.setLayoutData(new GridData(GridData.FILL_BOTH, SWT.BEGINNING, false, false)); button.setSelection(capability.isInstalled()); button.setText(capability.getId()); buttons.add(button); button.addSelectionListener(new SelectionAdapter() { @Override public void widgetSelected(SelectionEvent selectionEvent) { final boolean selected = ((Button) selectionEvent.widget).getSelection(); new Thread(new Runnable() { @Override public void run() { final Future<Boolean> future = (selected) ? capability.install() : capability.uninstall(); try { final Boolean successful = future.get(); display.asyncExec(new Runnable() { @Override public void run() { button.setSelection(successful); if (!successful) { MessageDialog dialog = new MessageDialog(shell, "Capability Install Error", null, "Error Installing Capability:\n\n" + capability.getId(), MessageDialog.ERROR, new String[] { "OK" }, 0); dialog.open(); } else { MessageDialog dialog = new MessageDialog(shell, "Capability Install Success", null, capability.getId() + " " + ((!selected) ? "un" : "") + "installed successfully", MessageDialog.INFORMATION, new String[] { "OK" }, 0); dialog.open(); } updateAllCheckboxes(); } }); } catch (InterruptedException e) { e.printStackTrace(); } catch (ExecutionException e) { e.printStackTrace(); } } }).run(); } }); } mainPanel.setSize(mainPanel.computeSize(SWT.DEFAULT, SWT.DEFAULT)); scrollpane.setMinSize(mainPanel.computeSize(SWT.DEFAULT, SWT.DEFAULT)); BaseStepDialog.setSize(shell, 250, 400, false); shell.open(); while (!shell.isDisposed()) { if (!display.readAndDispatch()) { display.sleep(); } } }
From source file:org.pentaho.di.ui.spoon.dialog.SaveProgressDialog.java
License:Apache License
public boolean open() { boolean retval = true; IRunnableWithProgress op = new IRunnableWithProgress() { public void run(IProgressMonitor monitor) throws InvocationTargetException, InterruptedException { try { rep.save(meta, versionComment, new ProgressMonitorAdapter(monitor)); } catch (KettleException e) { throw new InvocationTargetException(e, BaseMessages.getString(PKG, "TransSaveProgressDialog.Exception.ErrorSavingTransformation") + e.toString()); }/* w ww . j ava 2s .com*/ } }; try { ProgressMonitorDialog pmd = new ProgressMonitorDialog(shell); pmd.run(true, true, op); } catch (InvocationTargetException e) { MessageDialog errorDialog = new MessageDialog(shell, BaseMessages.getString(PKG, "TransSaveProgressDialog.UnableToSave.DialogTitle"), null, BaseMessages.getString(PKG, "TransSaveProgressDialog.UnableToSave.DialogMessage"), MessageDialog.ERROR, new String[] { BaseMessages.getString(PKG, "TransSaveProgressDialog.UnableToSave.Close") }, 0); errorDialog.open(); retval = false; } catch (InterruptedException e) { new ErrorDialog(shell, BaseMessages.getString(PKG, "TransSaveProgressDialog.ErrorSavingTransformation.DialogTitle"), BaseMessages.getString(PKG, "TransSaveProgressDialog.ErrorSavingTransformation.DialogMessage"), e); retval = false; } return retval; }
From source file:org.pentaho.di.ui.spoon.Spoon.java
License:Apache License
public void openFile(String filename, boolean importfile) { // Open the XML and see what's in there. // We expect a single <transformation> or <job> root at this time... // does the file exist? If not, show an error dialog boolean fileExists = false; try {//from ww w .j a va 2s. c o m final FileObject file = KettleVFS.getFileObject(filename); fileExists = file.exists(); } catch (final KettleFileException | FileSystemException e) { // nothing to do, null fileObject will be handled below } if (StringUtils.isBlank(filename) || !fileExists) { final Dialog dlg = new SimpleMessageDialog(shell, BaseMessages.getString(PKG, "Spoon.Dialog.MissingRecentFile.Title"), BaseMessages.getString(PKG, "Spoon.Dialog.MissingRecentFile.Message", getFileType(filename).toLowerCase()), MessageDialog.ERROR, BaseMessages.getString(PKG, "System.Button.Close"), MISSING_RECENT_DLG_WIDTH, SimpleMessageDialog.BUTTON_WIDTH); dlg.open(); return; } boolean loaded = false; FileListener listener = null; Node root = null; // match by extension first int idx = filename.lastIndexOf('.'); if (idx != -1) { for (FileListener li : fileListeners) { if (li.accepts(filename)) { listener = li; break; } } } // Attempt to find a root XML node name. Fails gracefully for non-XML file // types. try { Document document = XMLHandler.loadXMLFile(filename); root = document.getDocumentElement(); } catch (KettleXMLException e) { if (log.isDetailed()) { log.logDetailed(BaseMessages.getString(PKG, "Spoon.File.Xml.Parse.Error")); } } // otherwise try by looking at the root node if we were able to parse file // as XML if (listener == null && root != null) { for (FileListener li : fileListeners) { if (li.acceptsXml(root.getNodeName())) { listener = li; break; } } } // You got to have a file name! // if (!Utils.isEmpty(filename)) { if (listener != null) { try { loaded = listener.open(root, filename, importfile); } catch (KettleMissingPluginsException e) { log.logError(e.getMessage(), e); } } if (!loaded) { // Give error back hideSplash(); MessageBox mb = new MessageBox(shell, SWT.OK | SWT.ICON_ERROR); mb.setMessage(BaseMessages.getString(PKG, "Spoon.UnknownFileType.Message", filename)); mb.setText(BaseMessages.getString(PKG, "Spoon.UnknownFileType.Title")); mb.open(); } else { applyVariables(); // set variables in the newly loaded // transformation(s) and job(s). } } }
From source file:org.pentaho.di.ui.spoon.Spoon.java
License:Apache License
private void loadLastUsedFile(LastUsedFile lastUsedFile, String repositoryName, boolean trackIt, boolean isStartup) throws KettleException { boolean useRepository = repositoryName != null; // Perhaps we need to connect to the repository? ////from www .j ava 2s . c o m if (lastUsedFile.isSourceRepository()) { if (!Utils.isEmpty(lastUsedFile.getRepositoryName())) { if (useRepository && !lastUsedFile.getRepositoryName().equalsIgnoreCase(repositoryName)) { // We just asked... useRepository = false; } } } if (useRepository && lastUsedFile.isSourceRepository()) { if (rep != null) { // load from this repository... if (rep.getName().equalsIgnoreCase(lastUsedFile.getRepositoryName())) { RepositoryDirectoryInterface rdi = rep.findDirectory(lastUsedFile.getDirectory()); if (rdi != null) { // does the file exist in the repo? final RepositoryObjectType fileType = lastUsedFile.isJob() ? RepositoryObjectType.JOB : RepositoryObjectType.TRANSFORMATION; if (!rep.exists(lastUsedFile.getFilename(), rdi, fileType)) { // open an warning dialog only if this file was explicitly selected to be opened; on startup, simply skip // opening this file if (isStartup) { if (log.isDetailed()) { log.logDetailed(BaseMessages.getString(PKG, "Spoon.log.openingMissingFile")); } } else { final Dialog dlg = new SimpleMessageDialog(shell, BaseMessages.getString(PKG, "Spoon.Dialog.MissingRecentFile.Title"), BaseMessages.getString(PKG, "Spoon.Dialog.MissingRecentFile.Message", lastUsedFile.getLongFileType().toLowerCase()), MessageDialog.ERROR, BaseMessages.getString(PKG, "System.Button.Close"), MISSING_RECENT_DLG_WIDTH, SimpleMessageDialog.BUTTON_WIDTH); dlg.open(); } } else { // Are we loading a transformation or a job? if (lastUsedFile.isTransformation()) { if (log.isDetailed()) { // "Auto loading transformation ["+lastfiles[0]+"] from repository directory ["+lastdirs[0]+"]" log.logDetailed( BaseMessages.getString(PKG, "Spoon.Log.AutoLoadingTransformation", lastUsedFile.getFilename(), lastUsedFile.getDirectory())); } TransLoadProgressDialog tlpd = new TransLoadProgressDialog(shell, rep, lastUsedFile.getFilename(), rdi, null); TransMeta transMeta = tlpd.open(); if (transMeta != null) { if (trackIt) { props.addLastFile(LastUsedFile.FILE_TYPE_TRANSFORMATION, lastUsedFile.getFilename(), rdi.getPath(), true, rep.getName(), getUsername(), null); } // transMeta.setFilename(lastUsedFile.getFilename()); transMeta.clearChanged(); addTransGraph(transMeta); refreshTree(); } } else if (lastUsedFile.isJob()) { JobLoadProgressDialog progressDialog = new JobLoadProgressDialog(shell, rep, lastUsedFile.getFilename(), rdi, null); JobMeta jobMeta = progressDialog.open(); if (jobMeta != null) { if (trackIt) { props.addLastFile(LastUsedFile.FILE_TYPE_JOB, lastUsedFile.getFilename(), rdi.getPath(), true, rep.getName(), getUsername(), null); } jobMeta.clearChanged(); addJobGraph(jobMeta); } } refreshTree(); } } } } } // open files stored locally, not in the repository if (!lastUsedFile.isSourceRepository() && !Utils.isEmpty(lastUsedFile.getFilename())) { if (lastUsedFile.isTransformation()) { openFile(lastUsedFile.getFilename(), rep != null); } if (lastUsedFile.isJob()) { openFile(lastUsedFile.getFilename(), false); } refreshTree(); } }
From source file:org.pentaho.di.ui.trans.step.common.GetFieldsSampleDataDialog.java
License:Apache License
protected void handleOk(final int samples) { if (samples >= 0) { String message = parentDialog.loadFields(parentDialog.getPopulatedMeta(), samples, reloadAllFields); if (wCheckbox != null && wCheckbox.getSelection()) { if (StringUtils.isNotBlank(message)) { final EnterTextDialog etd = new EnterTextDialog(parentDialog.getShell(), BaseMessages.getString(PKG, "System.GetFields.ScanResults.DialogTitle"), BaseMessages.getString(PKG, "System.GetFields.ScanResults.DialogMessage"), message, true);/*from ww w . j a v a 2 s . c o m*/ etd.setReadOnly(); etd.setModal(); etd.open(); } else { final Dialog errorDlg = new SimpleMessageDialog(parentDialog.getShell(), BaseMessages.getString(PKG, "System.Dialog.Error.Title"), BaseMessages.getString(PKG, "System.GetFields.ScanResults.Error.Message"), MessageDialog.ERROR); errorDlg.open(); } } } }
From source file:org.polymap.rhei.field.UploadFormField.java
License:Open Source License
public Control createControl(final Composite parent, IFormToolkit toolkit) { Composite fileSelectionArea = toolkit.createComposite(parent, SWT.NONE); FormLayout layout = new FormLayout(); layout.spacing = 5;/* w ww . j a va 2s.co m*/ fileSelectionArea.setLayout(layout); int style = Upload.SHOW_UPLOAD_BUTTON; if (showProgress) { style |= Upload.SHOW_PROGRESS; } upload = toolkit.createUpload(fileSelectionArea, SWT.BORDER, style); // upload.setBrowseButtonText( "Datei..." ); // upload.setUploadButtonText( "Laden" ); upload.setEnabled(enabled); // upload.setBackground( enabled ? FormEditorToolkit.textBackground // : FormEditorToolkit.textBackgroundDisabled ); FormData data = new FormData(); data.left = new FormAttachment(0); data.right = new FormAttachment(100); upload.setLayoutData(data); // viewImageButton = toolkit.createButton( fileSelectionArea, "Anzeigen", SWT.NONE ); // data = new FormData(); // data.left = new FormAttachment( 80 ); // data.right = new FormAttachment( 100 ); // viewImageButton.setLayoutData( data ); // enableViewButton( enabled ); final Shell shell = parent.getShell(); // viewImageButton.addSelectionListener( new SelectionListener() { // // @Override // public void widgetSelected( SelectionEvent e ) { // String url = DownloadService.registerContent( new ContentProvider() { // // @Override // public String getFilename() { // return uploadedValue.originalFileName(); // } // // // @Override // public String getContentType() { // return uploadedValue.contentType(); // } // // // @Override // public InputStream getInputStream() // throws Exception { // return new FileInputStream( new File( uploadDir, uploadedValue // .internalFileName() ) ); // } // // // @Override // public boolean done( boolean success ) { // return true; // } // } ); // ExternalBrowser.open( "download_window", url, ExternalBrowser.NAVIGATION_BAR // | ExternalBrowser.STATUS ); // // // Browser browser = new Browser( shell, SWT.NONE ); // // // create the image // // BufferedImage image = createImage(); // // // store the image in the SessionStore for the service handler // // RWT.getSessionStore().setAttribute( IMAGE_KEY, image ); // // create the HTML with a single <img> tag. // // browser.setText( "<img src=\"" + url + "\"/>" ); // // // // open a dialog with the image preview // // final MessageDialog dialog = new MessageDialog( PolymapWorkbench // // .getShellToParentOn(), uploadedValue.originalFileName(), null, "", // // MessageDialog.INFORMATION, new String[] { "Schlieen" }, 0 ); // // dialog.setBlockOnOpen( true ); // // dialog.open(); // } // // // @Override // public void widgetDefaultSelected( SelectionEvent e ) { // } // } ); // uploadlistener upload.setHandler(new IUploadHandler() { @Override public void uploadStarted(ClientFile clientFile, InputStream in) throws Exception { try { log.debug("Uploaded: " + clientFile.getName()); // check for images String contentType = clientFile.getType(); if (!("image/jpeg".equalsIgnoreCase(contentType) || "image/png".equalsIgnoreCase(contentType) || "image/gif".equalsIgnoreCase(contentType) || "image/pjpeg".equalsIgnoreCase(contentType))) { new MessageDialog(shell, "Fehler beim Upload der Daten", null, "Es knnen nur Bilder vom Typ JPG, GIF oder PNG hochgeladen werden.", MessageDialog.ERROR, new String[] { "Ok" }, 0).open(); return; } // dont use the filename here String fileName = clientFile.getName(); int index = fileName.lastIndexOf('.'); String extension = ".jpg"; if (index != -1) { extension = fileName.substring(index); } String id = System.currentTimeMillis() + ""; String internalFileName = id + extension; File dbFile = new File(uploadDir, internalFileName); try (FileOutputStream out = new FileOutputStream(dbFile); InputStream autoCloseIn = in;) { IOUtils.copy(in, out); log.info("### copied to: " + dbFile); } // create a thumbnail Image image = Graphics.getImage(internalFileName, new FileInputStream(dbFile)); int x = image.getBounds().width; int newX = x; int y = image.getBounds().height; int newY = y; if (x >= y && x > thumbnailSize) { newX = thumbnailSize; newY = y * thumbnailSize / x; } else if (y > x && y > thumbnailSize) { newY = thumbnailSize; newX = x * thumbnailSize / y; } // else no need to scale String thumbnailFileName = id + "_thumb" + extension; dbFile = new File(uploadDir, thumbnailFileName); FileOutputStream out = new FileOutputStream(dbFile); ImageLoader loader = new ImageLoader(); loader.data = new ImageData[] { image.getImageData().scaledTo(newX, newY) }; loader.save(out, SWT.IMAGE_COPY); log.info("### thumbnail copied to: " + dbFile); // image.dispose(); uploadedValue = new DefaultUploadedImage(fileName, contentType, internalFileName, thumbnailFileName, dbFile.length()); // enableViewButton( true ); } catch (IOException e) { StatusDispatcher.handleError(DataPlugin.PLUGIN_ID, UploadFormField.this, "Fehler beim Upload der Daten.", e); } site.fireEvent(UploadFormField.this, IFormFieldListener.VALUE_CHANGE, uploadedValue); } }); // focus listener upload.addFocusListener(new FocusListener() { @Override public void focusLost(FocusEvent event) { // upload.setBackground( FormEditorToolkit.textBackground ); site.fireEvent(UploadFormField.this, IFormFieldListener.FOCUS_LOST, null); } @Override public void focusGained(FocusEvent event) { // upload.setBackground( FormEditorToolkit.textBackgroundFocused ); site.fireEvent(UploadFormField.this, IFormFieldListener.FOCUS_GAINED, null); } }); return fileSelectionArea; }
From source file:org.python.pydev.ui.dialogs.PyDialogHelpers.java
License:Open Source License
/** * @return the index chosen or -1 if it was canceled. */// w w w. j a v a2 s. c om public static int openCriticalWithChoices(String title, String message, String[] choices) { Shell shell = EditorUtils.getShell(); MessageDialog dialog = new MessageDialog(shell, title, null, message, MessageDialog.ERROR, choices, 0); return dialog.open(); }
From source file:org.review_board.ereviewboard.ui.editor.ReviewboardDiffPart.java
License:Open Source License
private void installExtensions(Composite composite, Repository codeRepository, ReviewboardDiffMapper diffMapper, Integer diffRevisionId) { IConfigurationElement[] configurationElements = Platform.getExtensionRegistry() .getConfigurationElementsFor(EXTENSION_POINT_TASK_DIFF_ACTIONS); int reviewRequestId = Integer.parseInt(getTaskData().getTaskId()); Map<String, TaskDiffAction> taskDiffActions = new LinkedHashMap<String, TaskDiffAction>( configurationElements.length); for (IConfigurationElement element : configurationElements) { try {//w w w.j a v a2 s .co m final TaskDiffAction taskDiffAction = (TaskDiffAction) element.createExecutableExtension("class"); taskDiffAction.init(getTaskRepository(), reviewRequestId, codeRepository, diffMapper, diffRevisionId); if (!taskDiffAction.isEnabled()) continue; String label = element.getAttribute("label"); taskDiffActions.put(label, taskDiffAction); } catch (CoreException e) { ReviewboardUiPlugin.getDefault().getLog().log(e.getStatus()); } } if (taskDiffActions.isEmpty()) return; Composite extensionsComposite = new Composite(composite, SWT.NONE); RowLayoutFactory.fillDefaults().type(SWT.HORIZONTAL).applyTo(extensionsComposite); for (final Map.Entry<String, TaskDiffAction> taskDiffAction : taskDiffActions.entrySet()) { final String labelTest = taskDiffAction.getKey(); Button button = new Button(extensionsComposite, SWT.PUSH); button.setText(labelTest); button.addSelectionListener(new SelectionListener() { public void widgetSelected(SelectionEvent e) { IStatus status; try { status = taskDiffAction.getValue().execute(new NullProgressMonitor()); } catch (Exception e1) { status = new Status(IStatus.ERROR, ReviewboardUiPlugin.PLUGIN_ID, "Internal error while executing action '" + labelTest + "' : " + e1.getMessage(), e1); ReviewboardUiPlugin.getDefault().getLog().log(status); } if (!status.isOK()) { int kind = MessageDialog.ERROR; if (status.getSeverity() == IStatus.WARNING) kind = MessageDialog.WARNING; MessageDialog.open(kind, null, "Error performing action", status.getMessage(), SWT.SHEET); } if (status.getCode() == TaskDiffAction.STATUS_CODE_REFRESH_REVIEW_REQUEST) org.review_board.ereviewboard.ui.util.EditorUtil.refreshEditorPage(getTaskEditorPage()); } public void widgetDefaultSelected(SelectionEvent e) { } }); } }
From source file:org.robotframework.red.jface.dialogs.ErrorDialogWithLinkToPreferences.java
License:Apache License
public ErrorDialogWithLinkToPreferences(final Shell parentShell, final String dialogTitle, final String dialogMessage, final String preferenceId, final String preferenceName) { super(parentShell, dialogTitle, null, dialogMessage, MessageDialog.ERROR, new String[] { IDialogConstants.OK_LABEL }, 0); this.preferenceId = preferenceId; this.preferenceName = preferenceName; }