Example usage for org.eclipse.jface.dialogs IDialogConstants NO_LABEL

List of usage examples for org.eclipse.jface.dialogs IDialogConstants NO_LABEL

Introduction

In this page you can find the example usage for org.eclipse.jface.dialogs IDialogConstants NO_LABEL.

Prototype

String NO_LABEL

To view the source code for org.eclipse.jface.dialogs IDialogConstants NO_LABEL.

Click Source Link

Document

The label for no buttons.

Usage

From source file:org.jboss.ide.eclipse.as.classpath.ui.containers.custom.CustomClasspathPreferencePage.java

License:Open Source License

public boolean performOk() {
    String[] changed2 = rootComp.getChanged();
    ArrayList<Object> list;
    IRuntimePathProvider[] arr;/*from  ww w.j ava  2  s .  c om*/
    final ArrayList<IProject> projectsNeedRefresh = new ArrayList<IProject>();
    for (int i = 0; i < changed2.length; i++) {
        String runtimeId = changed2[i];
        IRuntimeType rt = ServerCore.findRuntimeType(runtimeId);
        list = rootComp.getDataForComboSelection(changed2[i]);
        arr = (IRuntimePathProvider[]) list.toArray(new IRuntimePathProvider[list.size()]);
        CustomRuntimeClasspathModel.getInstance().savePathProviders(rt, arr);
        IProject[] projectsTargeting = findProjectsTargeting(rt);
        projectsNeedRefresh.addAll(Arrays.asList(projectsTargeting));
    }

    // Save the recently selected
    String lastSelected = rootComp.getCurrentId();
    IEclipsePreferences prefs = InstanceScope.INSTANCE.getNode(JBossServerUIPlugin.PLUGIN_ID);
    prefs.put(LAST_SELECTED_RUNTIME_TYPE, lastSelected);
    try {
        prefs.flush();
    } catch (BackingStoreException e) {
        // IGNORE this since it is only a setting to remember what was the last selected
        // runtime. This is extremely not necessary to log or inform the user about. 
    }

    MessageDialog dialog = new MessageDialog(getShell(), Messages.CustomClasspathsSettingsChanged, null,
            Messages.CustomClasspathsRequiresRebuild, MessageDialog.QUESTION, new String[] {
                    IDialogConstants.YES_LABEL, IDialogConstants.NO_LABEL, IDialogConstants.CANCEL_LABEL },
            2);

    int res = dialog.open();
    if (res == 0) {
        Job j = new WorkspaceJob(Messages.CustomClasspathsWorkspaceJob) {
            public IStatus runInWorkspace(IProgressMonitor monitor) {
                Iterator<IProject> i = projectsNeedRefresh.iterator();
                monitor.beginTask(Messages.CustomClasspathsWorkspaceJob, projectsNeedRefresh.size());
                while (i.hasNext()) {
                    IJavaProject jp = JavaCore.create(i.next());
                    try {
                        // Must reset the classpath to actually force both views and models to refresh
                        // A full build is not enough
                        jp.setRawClasspath(jp.getRawClasspath(), new NullProgressMonitor());
                    } catch (JavaModelException jme) {
                        return jme.getStatus();
                    }
                    CoreUtility.getBuildJob(jp.getProject()).schedule();
                }
                monitor.done();
                return Status.OK_STATUS;
            }
        };
        j.setRule(ResourcesPlugin.getWorkspace().getRoot());
        j.schedule();
    }
    rootComp.clearChanged();
    return true;
}

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 . j a v  a  2  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);
            }/*w w w.j a  va2  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(//from  w  ww.  java  2 s .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);//  w ww . j  av  a 2 s .c o  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// w  ww. j  av a  2  s  . c  om
        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(//www .j  a v  a2 s .com
                    "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  . jav a 2s  .  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;
                        }/*from  w ww .  j  a va2s. 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);
}