List of usage examples for org.eclipse.jface.dialogs MessageDialog WARNING
int WARNING
To view the source code for org.eclipse.jface.dialogs MessageDialog WARNING.
Click Source Link
From source file:org.hibernate.eclipse.console.AbstractQueryEditor.java
License:Open Source License
/** * @see org.eclipse.ui.texteditor.AbstractDecoratedTextEditor#performSaveAs(IProgressMonitor) * the same method except line: "dialog.setOriginalName(getSaveAsFileExtension());" *//*ww w .j av a 2 s. c o m*/ protected void performSaveAs(IProgressMonitor progressMonitor) { Shell shell = getSite().getShell(); final IEditorInput input = getEditorInput(); IDocumentProvider provider = getDocumentProvider(); final IEditorInput newInput; if (input instanceof IURIEditorInput && !(input instanceof IFileEditorInput)) { FileDialog dialog = new FileDialog(shell, SWT.SAVE); IPath oldPath = URIUtil.toPath(((IURIEditorInput) input).getURI()); if (oldPath != null) { dialog.setFileName(oldPath.lastSegment()); dialog.setFilterPath(oldPath.toOSString()); } String path = dialog.open(); if (path == null) { if (progressMonitor != null) progressMonitor.setCanceled(true); return; } // Check whether file exists and if so, confirm overwrite final File localFile = new File(path); if (localFile.exists()) { MessageDialog overwriteDialog = new MessageDialog(shell, HibernateConsoleMessages.AbstractQueryEditor_save_as, null, MessageFormat.format( HibernateConsoleMessages.AbstractQueryEditor_already_exists_do_you_want_to_replace_it, path), MessageDialog.WARNING, new String[] { IDialogConstants.YES_LABEL, IDialogConstants.NO_LABEL }, 1); // 'No' is the default if (overwriteDialog.open() != Window.OK) { if (progressMonitor != null) { progressMonitor.setCanceled(true); return; } } } IFileStore fileStore; try { fileStore = EFS.getStore(localFile.toURI()); } catch (CoreException ex) { HibernateConsolePlugin.getDefault().log(ex.getStatus()); String title = HibernateConsoleMessages.AbstractQueryEditor_problems_during_save_as; String msg = MessageFormat.format( HibernateConsoleMessages.AbstractQueryEditor_save_could_not_be_completed, ex.getMessage()); MessageDialog.openError(shell, title, msg); return; } IFile file = getWorkspaceFile(fileStore); if (file != null) newInput = new FileEditorInput(file); else newInput = new FileStoreEditorInput(fileStore); } else { SaveAsDialog dialog = new SaveAsDialog(shell); IFile original = (input instanceof IFileEditorInput) ? ((IFileEditorInput) input).getFile() : null; if (original != null) { dialog.setOriginalFile(original); } else { dialog.setOriginalName(getSaveAsFileExtension()); } dialog.create(); if (provider.isDeleted(input) && original != null) { String message = MessageFormat.format( HibernateConsoleMessages.AbstractQueryEditor_the_original_file_has_been_deleted_or_is_not_accessible, original.getName()); dialog.setErrorMessage(null); dialog.setMessage(message, IMessageProvider.WARNING); } if (dialog.open() == Window.CANCEL) { if (progressMonitor != null) progressMonitor.setCanceled(true); return; } IPath filePath = dialog.getResult(); if (filePath == null) { if (progressMonitor != null) progressMonitor.setCanceled(true); return; } IWorkspace workspace = ResourcesPlugin.getWorkspace(); IFile file = workspace.getRoot().getFile(filePath); newInput = new FileEditorInput(file); } if (provider == null) { // editor has programmatically been closed while the dialog was open return; } boolean success = false; try { provider.aboutToChange(newInput); provider.saveDocument(progressMonitor, newInput, provider.getDocument(input), true); success = true; } catch (CoreException x) { final IStatus status = x.getStatus(); if (status == null || status.getSeverity() != IStatus.CANCEL) { String title = HibernateConsoleMessages.AbstractQueryEditor_problems_during_save_as; String msg = MessageFormat.format( HibernateConsoleMessages.AbstractQueryEditor_save_could_not_be_completed, x.getMessage()); MessageDialog.openError(shell, title, msg); } } finally { provider.changed(newInput); if (success) setInput(newInput); } if (progressMonitor != null) progressMonitor.setCanceled(!success); }
From source file:org.hibernate.eclipse.console.views.SchemaExportAction.java
License:Open Source License
/** * Convenience method to open a standard warning Yes/No dialog. * /*from w w w. j a v a 2s. co m*/ * @param parent the parent shell of the dialog, or <code>null</code> if none * @param title the dialog's title, or <code>null</code> if none * @param msg the message * @return <code>true</code> if the user presses the Yes button, * <code>false</code> otherwise */ public static boolean openWarningYesNoDlg(Shell parent, String title, String msg) { String[] dialogButtonLabels = new String[] { IDialogConstants.YES_LABEL, IDialogConstants.NO_LABEL }; MessageDialog dialog = new MessageDialog(parent, title, null, msg, MessageDialog.WARNING, dialogButtonLabels, 0); return dialog.open() == 0; }
From source file:org.inquidia.kettle.plugins.tokenreplacement.TokenReplacementDialog.java
License:Apache License
public void getFieldsFromPrevious(RowMetaInterface row, TableView tableView, int keyColumn, int[] nameColumn, int[] tokenNameColumn, TableItemInsertListener listener) { if (row == null || row.size() == 0) { return; // nothing to do }//from w w w . j a v a 2 s. c om Table table = tableView.table; // get a list of all the non-empty keys (names) // List<String> keys = new ArrayList<String>(); for (int i = 0; i < table.getItemCount(); i++) { TableItem tableItem = table.getItem(i); String key = tableItem.getText(keyColumn); if (!Const.isEmpty(key) && keys.indexOf(key) < 0) { keys.add(key); } } int choice = 0; if (keys.size() > 0) { // Ask what we should do with the existing data in the step. // MessageDialog md = new MessageDialog(tableView.getShell(), BaseMessages.getString(PKG, "BaseStepDialog.GetFieldsChoice.Title"), // "Warning!" null, BaseMessages.getString( PKG, "BaseStepDialog.GetFieldsChoice.Message", "" + keys.size(), "" + row.size()), MessageDialog.WARNING, new String[] { BaseMessages.getString(PKG, "BaseStepDialog.AddNew"), BaseMessages.getString(PKG, "BaseStepDialog.Add"), BaseMessages.getString(PKG, "BaseStepDialog.ClearAndAdd"), BaseMessages.getString(PKG, "BaseStepDialog.Cancel"), }, 0); MessageDialog.setDefaultImage(GUIResource.getInstance().getImageSpoon()); int idx = md.open(); choice = idx & 0xFF; } if (choice == 3 || choice == 255) { return; // Cancel clicked } if (choice == 2) { tableView.clearAll(false); } for (int i = 0; i < row.size(); i++) { ValueMetaInterface v = row.getValueMeta(i); boolean add = true; if (choice == 0) { // hang on, see if it's not yet in the table view if (keys.indexOf(v.getName()) >= 0) { add = false; } } if (add) { TableItem tableItem = new TableItem(table, SWT.NONE); for (int aNameColumn : nameColumn) { tableItem.setText(aNameColumn, Const.NVL(v.getName(), "")); } for (int aTokenNameColumn : tokenNameColumn) { tableItem.setText(aTokenNameColumn, Const.NVL(v.getName(), "")); } if (listener != null) { if (!listener.tableItemInserted(tableItem, v)) { tableItem.dispose(); // remove it again } } } } tableView.removeEmptyRows(); tableView.setRowNums(); tableView.optWidth(true); }
From source file:org.jboss.ide.eclipse.as.classpath.ui.ClasspathUIPlugin.java
License:Open Source License
public static void warn(String string) { MessageDialog dialog = new MessageDialog(PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell(), Messages.ClasspathUIPlugin_WARNING, Display.getDefault().getSystemImage(SWT.ICON_WARNING), string, MessageDialog.WARNING, new String[] { Messages.ClasspathUIPlugin_OK, }, 0); dialog.setBlockOnOpen(true);// ww w . ja v a 2 s .c o m dialog.open(); }
From source file:org.jboss.ide.eclipse.as.ui.wizards.JBossRuntimeWizardFragment.java
License:Open Source License
protected void configDeletePressed() { String homeDir = homeDirComposite.getHomeDirectory(); MessageDialog dialog = new MessageDialog(configBrowse.getShell(), Messages.JBossRuntimeWizardFragment_DeleteConfigTitle, null, Messages.JBossRuntimeWizardFragment_DeleteConfigConfirmation, MessageDialog.WARNING, new String[] { IDialogConstants.YES_LABEL, IDialogConstants.NO_LABEL }, 0); // yes is the default if (dialog.open() == 0) { String config = configurations.getCurrentlySelectedConfiguration(); String configDir = configDirText.getText(); File folder;//from ww w .ja v a 2s . c o m if (!new Path(configDir).isAbsolute()) folder = new Path(homeDir).append(configDir).append(config).toFile(); else folder = new Path(configDir).append(config).toFile(); FileUtil.completeDelete(folder); configurations.refresh(); updatePage(); } }
From source file:org.jboss.tools.arquillian.ui.internal.commands.ExportArchiveCommandHandler.java
License:Open Source License
@Override public Object execute(ExecutionEvent event) throws ExecutionException { ISelection selection = HandlerUtil.getCurrentSelectionChecked(event); if (selection instanceof IStructuredSelection) { Object object = ((IStructuredSelection) selection).getFirstElement(); if (object instanceof Archive) { Archive archive = (Archive) object; FileDialog dialog = new FileDialog(getShell(), SWT.SAVE); dialog.setFileName(archive.getInternalName()); String name = archive.getInternalName(); int index = name.indexOf('.'); if (index >= 0) { String extension = "*" + name.substring(index); String[] extensions = { extension }; dialog.setFilterExtensions(extensions); }//w w w .ja v a 2 s. c om String path = dialog.open(); if (path == null) { return null; } final File localFile = new File(path); if (localFile.exists()) { MessageDialog overwriteDialog = new MessageDialog(getShell(), "Export Archive", null, path + " already exists. Do you want to replace it?", MessageDialog.WARNING, new String[] { IDialogConstants.YES_LABEL, IDialogConstants.NO_LABEL }, 1); if (overwriteDialog.open() != Window.OK) { return null; } } createArchive(archive, localFile); } } return null; }
From source file:org.jboss.tools.common.jdt.ui.buildpath.dialog.MaterializeLibraryDialog.java
License:Open Source License
@Override protected void okPressed() { if (!validate()) { return;// w w w .j ava 2s.c o m } String dialogWarning = warningfactory.getDialogWarning(containerToMaterialize); if (dialogWarning != null) { String[] buttonLabels = new String[] { IDialogConstants.OK_LABEL, IDialogConstants.CANCEL_LABEL }; MessageDialog dialog = new MessageDialog(getShell(), getShell().getText(), null, dialogWarning, MessageDialog.WARNING, buttonLabels, 0); if (dialog.open() == CANCEL) { return; } } libFolder = getLibFolderFromText(libfolderText.getText()); keepSources = keepSourceBtn.getSelection(); super.okPressed(); }
From source file:org.jboss.tools.common.model.ui.wizards.one.ServiceDialogImpl.java
License:Open Source License
private int getEclipseType(int type) { if (type == ERROR) return MessageDialog.ERROR; if (type == MESSAGE) return MessageDialog.INFORMATION; if (type == WARNING) return MessageDialog.WARNING; if (type == QUESTION) return MessageDialog.QUESTION; return MessageDialog.NONE; }
From source file:org.jboss.tools.fuse.transformation.editor.internal.VariablesViewer.java
License:Open Source License
public VariablesViewer(final TransformationManager manager, Composite parent) { super(parent, SWT.NONE); setLayout(GridLayoutFactory.fillDefaults().create()); setBackground(parent.getParent().getParent().getBackground()); // Create tool bar ToolBar toolBar = new ToolBar(this, SWT.NONE); ToolItem addButton = new ToolItem(toolBar, SWT.PUSH); addButton.setImage(/* w ww . jav a 2s . c om*/ new DecorationOverlayIcon(Images.VARIABLE, Decorations.ADD, IDecoration.TOP_RIGHT).createImage()); addButton.setToolTipText(Messages.VariablesViewer_toolbarTooltip_addNewVariable); final ToolItem deleteButton = new ToolItem(toolBar, SWT.PUSH); deleteButton.setImage(PlatformUI.getWorkbench().getSharedImages().getImage(ISharedImages.IMG_ETOOL_DELETE)); deleteButton.setToolTipText(Messages.VariablesViewer_toolbarTooltip_DeleteVariable); deleteButton.setEnabled(false); // Create table tableViewer = new TableViewer(this); tableViewer.getTable().setHeaderVisible(true); tableViewer.getTable().setLayoutData(GridDataFactory.fillDefaults().grab(true, true).create()); tableViewer.setComparator(new ViewerComparator()); tableViewer.setContentProvider(ArrayContentProvider.getInstance()); // Create columns // TODO add support for changing variable names final TableViewerColumn nameColumn = new TableViewerColumn(tableViewer, SWT.NONE); nameColumn.getColumn().setText(Messages.VariablesViewer_columnName_name); nameColumn.getColumn().setImage(Images.VARIABLE); nameColumn.setLabelProvider(new ColumnLabelProvider() { @Override public Image getImage(Object element) { Image img = Images.VARIABLE; if (manager.mapped((Variable) element)) return new DecorationOverlayIcon(img, Decorations.MAPPED, IDecoration.BOTTOM_RIGHT) .createImage(); return img; } @Override public String getText(Object element) { return ((Variable) element).getName(); } }); final TableViewerColumn valueColumn = new TableViewerColumn(tableViewer, SWT.NONE); valueColumn.getColumn().setText(Messages.VariablesViewer_columnName_value); valueColumn.setLabelProvider(new ColumnLabelProvider() { @Override public String getText(final Object element) { return "\"" + ((Variable) element).getValue() + "\""; //$NON-NLS-1$ //$NON-NLS-2$ } }); valueColumn.setEditingSupport(new EditingSupport(tableViewer) { private final TextCellEditor cellEditor = new TextCellEditor(tableViewer.getTable()); @Override protected boolean canEdit(Object element) { return true; } @Override protected CellEditor getCellEditor(Object element) { return cellEditor; } @Override protected Object getValue(Object element) { return ((Variable) element).getValue(); } @Override protected void setValue(Object element, Object value) { Variable variable = (Variable) element; manager.setValue(variable, value.toString()); try { manager.save(); tableViewer.setInput(manager.variables()); } catch (final Exception e) { Activator.error(e); } } }); // Wire tableViewer.addDragSupport(DND.DROP_MOVE, new Transfer[] { LocalSelectionTransfer.getTransfer() }, new DragSourceAdapter() { @Override public void dragStart(final DragSourceEvent event) { LocalSelectionTransfer.getTransfer().setSelection(tableViewer.getSelection()); } }); addButton.addSelectionListener(new SelectionAdapter() { @Override public void widgetSelected(SelectionEvent event) { InputDialog dlg = new InputDialog(getShell(), Messages.VariablesViewer_addVariableDialogTitle, Messages.VariablesViewer_addVariableDialogDescription, null, new IInputValidator() { @Override public String isValid(String text) { for (final Variable variable : manager.variables()) { if (variable.getName().equals(text)) return Messages.VariablesViewer_addVariableDialog_validation_variablealreadyExists; } return null; } }); if (dlg.open() != Window.OK) return; manager.addVariable(dlg.getValue(), dlg.getValue()); try { manager.save(); tableViewer.setInput(manager.variables()); } catch (final Exception e) { Activator.error(e); } } }); tableViewer.addSelectionChangedListener(new ISelectionChangedListener() { @Override public void selectionChanged(SelectionChangedEvent event) { deleteButton.setEnabled(!event.getSelection().isEmpty()); } }); deleteButton.addSelectionListener(new SelectionAdapter() { @Override public void widgetSelected(SelectionEvent event) { boolean deleteAll = false; try { for (Iterator<?> iter = tableViewer.getStructuredSelection().iterator(); iter.hasNext();) { Variable variable = (Variable) iter.next(); if (manager.mapped(variable)) { if (!deleteAll) { MessageDialog dlg = new MessageDialog(getShell(), Messages.VariablesViewer_confirm, null, Messages.bind(Messages.VariablesViewer_deleteConfirmationMessage, variable.getName()), MessageDialog.WARNING, new String[] { IDialogConstants.CANCEL_LABEL, IDialogConstants.YES_LABEL, IDialogConstants.YES_TO_ALL_LABEL, IDialogConstants.NO_LABEL }, 3); int button = dlg.open(); if (button == 2) deleteAll = true; else if (button == 3) continue; else if (button < 1) return; } } manager.removeVariable(variable); tableViewer.remove(variable); } manager.save(); tableViewer.setInput(manager.variables()); } catch (final Exception e) { Activator.error(e); } } }); // Populate tableViewer.setInput(manager.variables()); // Expand name and value columns to fill initial width of table each time table is resized tableViewer.getTable().addControlListener(new ControlAdapter() { @Override public void controlResized(ControlEvent event) { int width = tableViewer.getTable().getSize().x / 2; nameColumn.getColumn().setWidth(width); valueColumn.getColumn().setWidth(width); } }); }
From source file:org.jboss.tools.openshift.cdk.server.core.internal.adapter.controllers.CDK3LaunchController.java
License:Open Source License
private void launchCheckSetupCDK(IServer s, CDKServer cdkServer, ControllableServerBehavior beh) throws CoreException { CDK3Server cdk3 = (CDK3Server) cdkServer; if (!cdk3.isCDKInitialized()) { int[] retmain = new int[1]; retmain[0] = -1;/*from ww w . j a va 2 s. c om*/ String home = cdk3.getMinishiftHome(); Display.getDefault().syncExec(() -> { Shell sh = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell(); String msgText = "Your CDK installation has not been properly initialized. Would you like us to run setup-cdk for you?"; String msg = NLS.bind(msgText, home); MessageDialog messageDialog = new MessageDialog(sh, "Warning: CDK has not been properly initialized!", null, msg, MessageDialog.WARNING, new String[] { IDialogConstants.OK_LABEL, IDialogConstants.CANCEL_LABEL }, 0); retmain[0] = messageDialog.open(); }); if (retmain[0] == IDialogConstants.OK_ID) { Job j = new SetupCDKJob(s, null, true); j.schedule(); try { j.join(); } catch (InterruptedException e) { // Ignore and finish up ASAP } } if (!cdk3.isCDKInitialized()) { beh.setServerStopped(); throw new CoreException(CDKCoreActivator.statusFactory() .errorStatus("The server cannot be started until the CDK has been initialized.")); } } }