Example usage for org.eclipse.jface.preference PreferenceDialog open

List of usage examples for org.eclipse.jface.preference PreferenceDialog open

Introduction

In this page you can find the example usage for org.eclipse.jface.preference PreferenceDialog open.

Prototype

public int open() 

Source Link

Document

Opens this window, creating it first if it has not yet been created.

Usage

From source file:org.ebayopensource.vjet.eclipse.internal.ui.dialogs.UnknownContentTypeDialog.java

License:Open Source License

private void linkClicked() {
    String pageId = "org.eclipse.ui.preferencePages.ContentTypes"; //$NON-NLS-1$
    PreferenceDialog dialog = PreferencesUtil.createPreferenceDialogOn(getShell(), pageId,
            new String[] { pageId }, null);
    dialog.open();
}

From source file:org.ebayopensource.vjet.eclipse.internal.ui.wizards.VjoSourceModulePage.java

License:Open Source License

/**
 * create comment related controls/* w  w w .  j  a va  2s. c  om*/
 * 
 * @param composite
 * @param columns
 */
protected void createCommentControl(Composite composite, int columns) {
    Link link = new Link(composite, SWT.NONE);
    link.setText(VjetWizardMessages.NewTypeWizardPage_addcomment_description);
    link.addSelectionListener(new SelectionListener() {
        public void widgetDefaultSelected(SelectionEvent e) {
            widgetSelected(e);
        }

        public void widgetSelected(SelectionEvent e) {
            IProject project = getProjectFragment().getResource().getProject();
            if (project != null) {
                PreferenceDialog dialog = PreferencesUtil.createPropertyDialogOn(getShell(), null,
                        "code template id", null, null);
                dialog.open();
            } else {
                String title = VjetWizardMessages.NewTypeWizardPage_configure_templates_title;
                String message = VjetWizardMessages.NewTypeWizardPage_configure_templates_message;
                MessageDialog.openInformation(getShell(), title, message);
            }
        }
    });
    link.setLayoutData(new GridData(GridData.FILL, GridData.CENTER, false, false, columns, 1));

    fAddCommentButton = new SelectionButtonDialogField(SWT.CHECK);
    fAddCommentButton.setLabelText(VjetWizardMessages.NewTypeWizardPage_addcomment_label); //$NON-NLS-1$
    DialogField.createEmptySpace(composite);
    fAddCommentButton.doFillIntoGrid(composite, columns - 1);

    fUseAddCommentButtonValue = false; // only used when enabled
}

From source file:org.eclipse.acute.AcutePlugin.java

License:Open Source License

private static void openCommandErrorDialog(String title, String content) {
    Display.getDefault().asyncExec(() -> {
        Shell shell = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell();
        int dialogResponse = MessageDialog.open(MessageDialog.CONFIRM, shell, title, content, SWT.NONE,
                Messages.acutePlugin_openPreferences, Messages.acutePlugin_cancel);
        if (dialogResponse == 0) {
            PreferenceDialog preferenceDialog = PreferencesUtil.createPreferenceDialogOn(shell,
                    AcutePreferencePage.PAGE_ID, new String[] { AcutePreferencePage.PAGE_ID }, null);
            preferenceDialog.setBlockOnOpen(false);
            preferenceDialog.open();
        }//from   ww w  . java2s . c  o  m
    });
}

From source file:org.eclipse.acute.dotnetnew.DotnetNewWizardPage.java

License:Open Source License

@Override
public void createControl(Composite parent) {
    Composite container = new Composite(parent, SWT.NULL);
    setControl(container);//from w  w w  .  j a v  a  2s .c  o  m
    container.setLayout(new GridLayout(4, false));

    Label locationLabel = new Label(container, SWT.NONE);
    locationLabel.setLayoutData(new GridData(SWT.RIGHT, SWT.CENTER, false, false, 1, 1));
    locationLabel.setText(Messages.DotnetNewWizardPage_location);

    Image errorImage = FieldDecorationRegistry.getDefault()
            .getFieldDecoration(FieldDecorationRegistry.DEC_ERROR).getImage();

    locationText = new Text(container, SWT.BORDER);
    locationText.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false, 1, 1));
    locationControlDecoration = new ControlDecoration(locationText, SWT.TOP | SWT.LEFT);
    locationControlDecoration.setImage(errorImage);
    locationControlDecoration.setShowOnlyOnFocus(true);
    locationText.addModifyListener(e -> {
        updateDirectory(locationText.getText());
        setPageComplete(isPageComplete());
    });

    Button browseButton = new Button(container, SWT.NONE);
    browseButton.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, false, false, 1, 1));
    browseButton.setText(Messages.DotnetNewWizardPage_browse);
    browseButton.addSelectionListener(widgetSelectedAdapter(e -> {
        DirectoryDialog dialog = new DirectoryDialog(browseButton.getShell());
        String path = dialog.open();
        if (path != null) {
            updateDirectory(path);
        }
        setPageComplete(isPageComplete());
    }));
    Composite linesAboveLink = new Composite(container, SWT.NONE);
    GridData linesAboveLinkLayoutData = new GridData(SWT.FILL, SWT.FILL);
    linesAboveLinkLayoutData.heightHint = linesAboveLinkLayoutData.widthHint = 30;
    linesAboveLink.setLayoutData(linesAboveLinkLayoutData);
    linesAboveLink.addPaintListener(e -> {
        e.gc.setForeground(((Control) e.widget).getDisplay().getSystemColor(SWT.COLOR_DARK_GRAY));
        e.gc.drawLine(0, e.height / 2, e.width / 2, e.height / 2);
        e.gc.drawLine(e.width / 2, e.height / 2, e.width / 2, e.height);
    });

    new Label(container, SWT.NONE);
    new Label(container, SWT.NONE);
    new Label(container, SWT.NONE);

    linkButton = new Button(container, SWT.TOGGLE);
    linkButton.setToolTipText(Messages.DotnetNewWizardPage_linkNames);
    linkButton.setSelection(true);
    try (InputStream iconStream = getClass().getResourceAsStream("/icons/link_obj.png")) { //$NON-NLS-1$
        linkImage = new Image(linkButton.getDisplay(), iconStream);
        linkButton.setImage(linkImage);
    } catch (IOException e1) {
        AcutePlugin.logError(e1);
    }
    linkButton.addSelectionListener(widgetSelectedAdapter(s -> {
        isDirectoryAndProjectLinked = linkButton.getSelection();
        projectNameText.setEnabled(!linkButton.getSelection());
        updateProjectName();
    }));

    Label projectNameLabel = new Label(container, SWT.NONE);
    projectNameLabel.setLayoutData(new GridData(SWT.RIGHT, SWT.CENTER, false, false, 1, 1));
    projectNameLabel.setText(Messages.DotnetNewWizardPage_projectName);

    projectNameText = new Text(container, SWT.BORDER);
    projectNameText.setEnabled(false);
    projectNameText.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false, 2, 1));
    projectNameControlDecoration = new ControlDecoration(projectNameText, SWT.TOP | SWT.LEFT);
    projectNameControlDecoration.setImage(errorImage);
    projectNameControlDecoration.setShowOnlyOnFocus(true);
    projectNameText.addModifyListener(e -> {
        updateProjectName();
        setPageComplete(isPageComplete());
    });
    Composite linesBelowLink = new Composite(container, SWT.NONE);
    GridData linesBelowLinkLayoutData = new GridData(SWT.FILL, SWT.FILL);
    linesBelowLinkLayoutData.heightHint = linesBelowLinkLayoutData.widthHint = 30;
    linesBelowLink.setLayoutData(linesAboveLinkLayoutData);
    linesBelowLink.addPaintListener(e -> {
        e.gc.setForeground(((Control) e.widget).getDisplay().getSystemColor(SWT.COLOR_DARK_GRAY));
        e.gc.drawLine(0, e.height / 2, e.width / 2, e.height / 2);
        e.gc.drawLine(e.width / 2, e.height / 2, e.width / 2, 0);
    });
    new Label(container, SWT.NONE).setLayoutData(new GridData(SWT.FILL, SWT.DEFAULT, true, false, 4, 1));

    Label projectTemplateLabel = new Label(container, SWT.NONE);
    projectTemplateLabel.setText(Messages.DotnetNewWizardPage_projectTemplate);

    List list = new List(container, SWT.V_SCROLL | SWT.BORDER);
    GridData listBoxData = new GridData(SWT.FILL, SWT.CENTER, true, false, 2, 1);
    list.setLayoutData(listBoxData);
    templateViewer = new ListViewer(list);
    templateViewer.setContentProvider(new ArrayContentProvider());
    templateViewer.setComparator(new ViewerComparator()); // default uses getLabel()/toString()
    templateViewer.addSelectionChangedListener(e -> {
        setPageComplete(isPageComplete());
    });
    templateControlDecoration = new ControlDecoration(templateViewer.getControl(), SWT.TOP | SWT.LEFT);
    templateControlDecoration.setImage(errorImage);
    updateTemplateList();

    //Update Template List with preferences change
    IPreferenceStore store = AcutePlugin.getDefault().getPreferenceStore();
    updateTemplatesListener = new IPropertyChangeListener() {
        @Override
        public void propertyChange(PropertyChangeEvent event) {
            if (event.getProperty().equals(AcutePreferenceInitializer.explicitDotnetPathPreference)) {
                updateTemplateList();
            }
        }
    };
    store.addPropertyChangeListener(updateTemplatesListener);

    new Label(container, SWT.NONE);

    new Label(container, SWT.NONE);
    Link preferencesLink = new Link(container, SWT.NONE);
    preferencesLink.setText(Messages.DotnetNewWizardPage_dotnetPreferencesLink);
    preferencesLink.setLayoutData(new GridData(SWT.RIGHT, SWT.CENTER, false, false, 2, 1));
    preferencesLink.addSelectionListener(widgetSelectedAdapter(s -> Display.getDefault().asyncExec(() -> {
        PreferenceDialog preferenceDialog = PreferencesUtil.createPreferenceDialogOn(getShell(),
                AcutePreferencePage.PAGE_ID, new String[] { AcutePreferencePage.PAGE_ID }, null);
        preferenceDialog.setBlockOnOpen(false);
        preferenceDialog.open();
    })));
    new Label(container, SWT.NONE).setLayoutData(new GridData(SWT.FILL, SWT.DEFAULT, true, false, 4, 1));

    Composite workingSetComposite = new Composite(container, SWT.NONE);
    GridData layoutData = new GridData(SWT.FILL, SWT.FILL, true, false, 4, 1);
    workingSetComposite.setLayoutData(layoutData);
    workingSetComposite.setLayout(new GridLayout(1, false));
    String[] workingSetIds = new String[] { "org.eclipse.ui.resourceWorkingSetPage" }; //$NON-NLS-1$
    IStructuredSelection wsSel = null;
    if (this.workingSets != null) {
        wsSel = new StructuredSelection(this.workingSets.toArray());
    }
    this.workingSetsGroup = new WorkingSetGroup(workingSetComposite, wsSel, workingSetIds);

    if (directory != null) {
        updateDirectory(directory.getAbsolutePath());
    }
}

From source file:org.eclipse.andmore.android.common.utilities.EclipseUtils.java

License:Apache License

/**
 * Open the preference page with the specified ID
 * /*ww  w . j  a va  2 s .co m*/
 * @param nodeID
 *            the id of preference page to show
 */
@SuppressWarnings("unchecked")
public static void openPreference(Shell shell, String nodeID) {
    // Makes the network preferences dialog manager
    PreferenceManager manager = PlatformUI.getWorkbench().getPreferenceManager();
    IPreferenceNode networkNode = null;
    for (IPreferenceNode node : manager.getElements(PreferenceManager.PRE_ORDER)) {
        if (node.getId().equals(nodeID)) {
            networkNode = node;
            break;
        }
    }
    PreferenceManager prefMan = new PreferenceManager();
    if (networkNode != null) {
        prefMan.addToRoot(networkNode);
    }
    PreferenceDialog preferencesDialog = new WorkbenchPreferenceDialog(shell, prefMan);
    preferencesDialog.create();
    preferencesDialog.open();
}

From source file:org.eclipse.andmore.android.common.utilities.ui.WidgetsUtil.java

License:Apache License

/**
 * Opens the Eclipse preferences dialog and selects the page of the given
 * id.// www  .j a v  a  2 s  .  c o m
 * 
 * @param shell
 *            The shell.
 * @param selectedNode
 *            The preferences page to selec.
 * @return <code>true</code> if the Wizard dialog has constant OK,
 *         <code>false</code> otherwise .
 */
public static boolean runPreferencePage(Shell shell, String selectedNode) {
    PreferenceManager manager = PlatformUI.getWorkbench().getPreferenceManager();
    PreferenceDialog dialog = new PreferenceDialog(shell, manager);
    dialog.setSelectedNode(selectedNode);
    WidgetsUtil.centerDialog(shell);
    return dialog.open() == Window.OK;
}

From source file:org.eclipse.andmore.android.emulator.device.ui.PropertiesMainComposite.java

License:Apache License

@SuppressWarnings("unchecked")
protected void openNetworkPreferences() {
    // Makes the network preferences dialog manager
    PreferenceManager manager = PlatformUI.getWorkbench().getPreferenceManager();
    IPreferenceNode networkNode = null;//from  w w w  .ja v  a2 s .c  om
    for (IPreferenceNode node : manager.getElements(PreferenceManager.PRE_ORDER)) {
        if (node.getId().equals(ORG_ECLIPSE_UI_NET_NET_PREFERENCES)) {
            networkNode = node;
            break;
        }
    }
    PreferenceManager prefMan = new PreferenceManager();
    if (networkNode != null) {
        prefMan.addToRoot(networkNode);
    }
    PreferenceDialog networkPreferencesDialog = new WorkbenchPreferenceDialog(getShell(), prefMan);
    networkPreferencesDialog.create();
    networkPreferencesDialog.open();
}

From source file:org.eclipse.buckminster.ui.views.BuckminsterView.java

License:Open Source License

private void createActions() {
    openEditorAction = new Action(Messages.open) {
        @Override//  ww w . ja  va 2s  . c om
        public void run() {
            IResource resource = getResourceSelection();

            if (resource != null && resource instanceof IFile) {
                IFile file = (IFile) resource;
                IWorkbenchPage workbenchPage = getSite().getWorkbenchWindow().getActivePage();
                try {
                    IEditorRegistry editorRegistry = getViewSite().getWorkbenchWindow().getWorkbench()
                            .getEditorRegistry();

                    IEditorDescriptor editorDescriptor = editorRegistry.getDefaultEditor(file.getName());
                    String editorId = editorDescriptor.getId();
                    if (editorId != null) {
                        IDE.openEditor(workbenchPage, new FileEditorInput(file), editorId);
                    }
                } catch (PartInitException e) {
                    UiUtils.openError(getViewSite().getShell(), Messages.unable_to_open_editor, e);
                }
            }

        }
    };

    viewCSpecAction = new Action(Messages.view_the_cspec_of_a_component) {
        @Override
        public void run() {
            IWorkbenchWindowActionDelegate action = new ViewChosenCSpecAction();
            action.init(getWorkbenchWindow());
            action.selectionChanged(this, treeViewer.getSelection());
            action.run(this);
            action.dispose();
        }
    };
    viewCSpecAction.setImageDescriptor(UiPlugin.getImageDescriptor("icons/cspec.png")); //$NON-NLS-1$

    openCQueryAction = new Action(Messages.open_a_component_query) {
        @Override
        public void run() {
            IWorkbenchWindowActionDelegate action = new OpenQueryAction();
            action.init(getWorkbenchWindow());
            action.selectionChanged(this, treeViewer.getSelection());
            action.run(this);
            action.dispose();
        }
    };
    openCQueryAction.setImageDescriptor(UiPlugin.getImageDescriptor("icons/cquery.png")); //$NON-NLS-1$

    viewPreferencesAction = new Action(Messages.preferences) {
        @Override
        public void run() {
            PreferenceDialog dialog = PreferencesUtil.createPreferenceDialogOn(getWorkbenchWindow().getShell(),
                    null, BuckminsterPreferences.getIds(), null);
            dialog.open();
        }
    };

    viewAboutAction = new Action(Messages.about) {
        @Override
        public void run() {
            AboutDialog dialog = new AboutDialog(getWorkbenchWindow().getShell());
            dialog.open();
        }
    };

    invokeActionAction = new Action(Messages.invoke_action) {
        @Override
        public void run() {
            IObjectActionDelegate action = new InvokeAction();
            action.setActivePart(this, getWorkbenchWindow().getActivePage().getActivePart());
            action.selectionChanged(this, treeViewer.getSelection());
            action.run(this);
        }
    };

    viewCspecAction = new Action(Messages.view_cspec) {
        @Override
        public ImageDescriptor getImageDescriptor() {
            return UiPlugin.getImageDescriptor("icons/cspec.png"); //$NON-NLS-1$
        }

        @Override
        public void run() {
            IObjectActionDelegate action = new ViewCSpecAction();
            action.setActivePart(this, getWorkbenchWindow().getActivePage().getActivePart());
            action.selectionChanged(this, treeViewer.getSelection());
            action.run(this);
        }
    };

    publishAction = new Action(Messages.publish) {
        @Override
        public ImageDescriptor getImageDescriptor() {
            return UiPlugin.getImageDescriptor("icons/publish.png"); //$NON-NLS-1$
        }

        @Override
        public void run() {
            // TODO implement
        }
    };

    resolveToWizardAction = new Action(Messages.resolve_to_wizard) {
        @Override
        public ImageDescriptor getImageDescriptor() {
            return UiPlugin.getImageDescriptor("icons/resolve.png"); //$NON-NLS-1$
        }

        @Override
        public void run() {
            loadComponent(false);
        }
    };

    resolveAndMaterializeAction = new Action(Messages.resolve_and_materialize) {
        @Override
        public ImageDescriptor getImageDescriptor() {
            return UiPlugin.getImageDescriptor("icons/resolve.png"); //$NON-NLS-1$
        }

        @Override
        public void run() {
            loadComponent(true);
        }
    };
}

From source file:org.eclipse.cdt.codan.internal.ui.preferences.FieldEditorOverlayPage.java

License:Open Source License

/**
 * Show a single preference pages/*from ww  w.j  a  v a  2 s .  co m*/
 * 
 * @param id
 *        - the preference page identification
 * @param page
 *        - the preference page
 */
protected void showPreferencePage(String id, IPreferencePage page) {
    final IPreferenceNode targetNode = new PreferenceNode(id, page);
    PreferenceManager manager = new PreferenceManager();
    manager.addToRoot(targetNode);
    final PreferenceDialog dialog = new PreferenceDialog(getControl().getShell(), manager);
    BusyIndicator.showWhile(getControl().getDisplay(), new Runnable() {
        @Override
        public void run() {
            dialog.create();
            dialog.setMessage(targetNode.getLabelText());
            dialog.open();
        }
    });
}

From source file:org.eclipse.cdt.debug.ui.breakpoints.AbstractToggleBreakpointAdapter.java

License:Open Source License

/**
 * Opens the properties dialog for the given breakpoint. This method can be
 * used on an existing breakpoint or on a blank breakpoint which doesn't
 * have an associated marker yet.//from w w w .j  ava2  s  .  co m
 * 
 * @param bp
 *            The breakpoint to edit. This breakpoint may not have an
 *            associated marker yet.
 * @param part
 *            Workbench part where the action was invoked.
 * @param resource
 *            Workbench resource to create the breakpoint on.
 * @param attributes
 *            Breakpoint attributes to show in properties dialog. If the
 *            breakpoint already exists, this attribute map can be used to
 *            override the attributes currently in the breakpoint. Can be
 *            <code>null</code>.
 */
protected void openBreakpointPropertiesDialog(ICBreakpoint bp, IWorkbenchPart part, IResource resource,
        Map<String, Object> attributes) {
    ISelection debugContext = DebugUITools.getDebugContextManager()
            .getContextService(part.getSite().getWorkbenchWindow()).getActiveContext(part.getSite().getId());
    CBreakpointContext bpContext = new CBreakpointContext(bp, debugContext, resource, attributes);

    PreferenceDialog dialog = PreferencesUtil.createPropertyDialogOn(part.getSite().getShell(), bpContext, null,
            null, null);
    if (dialog != null) {
        dialog.open();
    }
}