List of usage examples for org.eclipse.jface.dialogs IDialogConstants YES_LABEL
String YES_LABEL
To view the source code for org.eclipse.jface.dialogs IDialogConstants YES_LABEL.
Click Source Link
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 w w w . j av a2 s . co 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); }/*from w w w . j a v a 2 s. c o m*/ 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.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 w w . j a va 2s. c o m*/ 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.express.internal.core.behaviour.ExpressPublishMethod.java
License:Open Source License
private boolean openQuestion(Shell shell, String title, String message, boolean defaultAnswer) { String[] labels = new String[] { IDialogConstants.YES_LABEL, IDialogConstants.NO_LABEL }; int defaultValue = defaultAnswer ? 0 : 1; MessageDialog dialog = new MessageDialog(shell, title, null, message, MessageDialog.QUESTION, labels, defaultValue);//from www . j ava2 s. co m return dialog.open() == 0; }
From source file:org.jboss.tools.openshift.express.internal.ui.QuestionHandler.java
License:Open Source License
@Override public boolean openQuestion(final String title, final String message, final boolean defaultAnswer) { final boolean[] answer = new boolean[1]; Display.getDefault().syncExec(new Runnable() { @Override/* www. j a va 2 s . c o m*/ public void run() { Shell shell = Display.getCurrent().getActiveShell(); String[] labels = new String[] { IDialogConstants.YES_LABEL, IDialogConstants.NO_LABEL }; int defaultValue = defaultAnswer ? 0 : 1; MessageDialog dialog = new MessageDialog(shell, title, null, message, MessageDialog.QUESTION, labels, defaultValue); answer[0] = dialog.open() == 0; } }); return answer[0]; }
From source file:org.jboss.tools.openshift.internal.ui.handler.ScaleDeploymentHandler.java
License:Open Source License
private boolean showStopDeploymentWarning(String name, Shell shell) { MessageDialog dialog = new MessageDialog(shell, "Stop all deployments?", OpenShiftCommonImages.OPENSHIFT_LOGO_WHITE_ICON_IMG, NLS.bind(/*from w w w. j a v a 2 s . c om*/ "Are you sure you want to scale {0} to 0 replicas?\nThis will stop all pods for the deployment.", name), MessageDialog.WARNING, 1, new String[] { IDialogConstants.YES_LABEL, IDialogConstants.NO_LABEL }); return dialog.open() == Dialog.OK; }
From source file:org.jboss.tools.runtime.ui.internal.wizard.DownloadRuntimeOperationUIUtility.java
License:Open Source License
public static IOverwrite createOverwriteFileQuery() { IOverwrite overwriteQuery = new IOverwrite() { public int overwrite(File file) { final String msg = NLS.bind(Messages.DownloadRuntimesSecondPage_The_file_already_exists, file.getAbsolutePath()); final String[] options = { IDialogConstants.YES_LABEL, IDialogConstants.YES_TO_ALL_LABEL, IDialogConstants.NO_LABEL, IDialogConstants.NO_TO_ALL_LABEL, IDialogConstants.CANCEL_LABEL }; final int[] retVal = new int[1]; Display.getDefault().syncExec(new Runnable() { public void run() { Shell shell = PlatformUI.getWorkbench().getModalDialogShellProvider().getShell(); MessageDialog dialog = new MessageDialog(shell, Messages.DownloadRuntimesSecondPage_Question, null, msg, MessageDialog.QUESTION, options, 0) { protected int getShellStyle() { return super.getShellStyle() | SWT.SHEET; }/*from w w w. j a v a 2 s .co m*/ }; dialog.open(); retVal[0] = dialog.getReturnCode(); } }); return retVal[0]; } }; return overwriteQuery; }
From source file:org.jboss.tools.runtime.ui.internal.wizard.DownloadRuntimeOperationUtility.java
License:Open Source License
private static IOverwrite createOverwriteFileQuery() { IOverwrite overwriteQuery = new IOverwrite() { public int overwrite(File file) { final String msg = NLS.bind(Messages.DownloadRuntimesSecondPage_The_file_already_exists, file.getAbsolutePath()); final String[] options = { IDialogConstants.YES_LABEL, IDialogConstants.YES_TO_ALL_LABEL, IDialogConstants.NO_LABEL, IDialogConstants.NO_TO_ALL_LABEL, IDialogConstants.CANCEL_LABEL }; final int[] retVal = new int[1]; Display.getDefault().syncExec(new Runnable() { public void run() { Shell shell = PlatformUI.getWorkbench().getModalDialogShellProvider().getShell(); MessageDialog dialog = new MessageDialog(shell, Messages.DownloadRuntimesSecondPage_Question, null, msg, MessageDialog.QUESTION, options, 0) { protected int getShellStyle() { return super.getShellStyle() | SWT.SHEET; }/* w w w.j a v a 2 s. c o m*/ }; dialog.open(); retVal[0] = dialog.getReturnCode(); } }); return retVal[0]; } }; return overwriteQuery; }
From source file:org.jboss.tools.usage.internal.reporting.UsageReportEnablementDialog.java
License:Open Source License
protected void createButtonsForButtonBar(Composite parent) { createButton(parent, IDialogConstants.OK_ID, IDialogConstants.YES_LABEL, false); createButton(parent, IDialogConstants.NO_ID, IDialogConstants.NO_LABEL, false); }
From source file:org.jboss.tools.windup.ui.internal.wizards.WindupReportExportWizardPage1.java
License:Open Source License
/** * The <code>WizardDataTransfer</code> implementation of this <code>IOverwriteQuery</code> method asks the user whether the existing resource at * the given path should be overwritten. * //ww w. java2 s . c o m * @param pathString * @return the user's reply: one of <code>"YES"</code>, <code>"NO"</code>, <code>"ALL"</code>, or <code>"CANCEL"</code> */ public String queryOverwrite(String pathString) { Path path = new Path(pathString); String messageString; // Break the message up if there is a file name and a directory // and there are at least 2 segments. if (path.getFileExtension() == null || path.segmentCount() < 2) { messageString = NLS.bind(Messages.WindupReportExport_question_fileExists, pathString); } else { messageString = NLS.bind(Messages.WindupReportExport_question_overwriteNameAndPath, path.lastSegment(), path.removeLastSegments(1).toOSString()); } final MessageDialog dialog = new MessageDialog(getContainer().getShell(), Messages.Question, null, messageString, MessageDialog.QUESTION, new String[] { IDialogConstants.YES_LABEL, IDialogConstants.YES_TO_ALL_LABEL, IDialogConstants.NO_LABEL, IDialogConstants.NO_TO_ALL_LABEL, IDialogConstants.CANCEL_LABEL }, 0) { protected int getShellStyle() { return super.getShellStyle() | SWT.SHEET; } }; String[] response = new String[] { YES, ALL, NO, NO_ALL, CANCEL }; // run in syncExec because callback is from an operation, // which is probably not running in the UI thread. getControl().getDisplay().syncExec(new Runnable() { public void run() { dialog.open(); } }); return dialog.getReturnCode() < 0 ? CANCEL : response[dialog.getReturnCode()]; }