Example usage for org.eclipse.jface.preference IPreferenceNode getLabelText

List of usage examples for org.eclipse.jface.preference IPreferenceNode getLabelText

Introduction

In this page you can find the example usage for org.eclipse.jface.preference IPreferenceNode getLabelText.

Prototype

public String getLabelText();

Source Link

Document

Returns the text label used to present this node in a preference dialog.

Usage

From source file:at.spardat.xma.guidesign.preferences.AbstractPreferenceAndPropertyPage.java

License:Open Source License

/**
 * Show a single preference pages/* w  w 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() {
        public void run() {
            dialog.create();
            dialog.setMessage(targetNode.getLabelText());
            dialog.open();
        }
    });
}

From source file:com.aptana.formatter.ui.dialogs.PropertyLinkArea.java

License:Open Source License

public PropertyLinkArea(Composite parent, int style, final String pageId, IAdaptable element, String message,
        final IWorkbenchPreferenceContainer pageContainer) {
    this.element = element;
    pageLink = new Link(parent, style);

    IPreferenceNode node = getPreferenceNode(pageId);
    String text = null;//  www. j a v a2 s  . co m
    if (node == null) {
        text = NLS.bind(WorkbenchMessages.PreferenceNode_NotFound, pageId);
    } else {
        text = NLS.bind(message, node.getLabelText());
    }

    pageLink.addSelectionListener(new SelectionAdapter() {
        public void widgetSelected(SelectionEvent e) {
            pageContainer.openPage(pageId, null);
        }
    });

    pageLink.setText(text);
}

From source file:com.aptana.formatter.ui.dialogs.PropToPrefLinkArea.java

License:Open Source License

public PropToPrefLinkArea(Composite parent, int style, final String pageId, String message, final Shell shell,
        final Object pageData) {
    /*/*from w w w . ja  v  a2 s .co m*/
     * breaking new ground yet again - want to link between property and preference paes. ie: project specific debug
     * engine options to general debugging options
     */
    pageLink = new Link(parent, style);

    IPreferenceNode node = getPreferenceNode(pageId);
    String result;
    if (node == null) {
        result = NLS.bind(WorkbenchMessages.PreferenceNode_NotFound, pageId);
    } else {
        result = MessageFormat.format(message, node.getLabelText());

        // only add the selection listener if the node is found
        pageLink.addSelectionListener(new SelectionAdapter() {

            public void widgetSelected(SelectionEvent e) {
                PreferencesUtil.createPreferenceDialogOn(shell, pageId, new String[] { pageId }, pageData)
                        .open();
            }

        });
    }
    pageLink.setText(result);

}

From source file:com.aptana.formatter.ui.util.SWTUtil.java

License:Open Source License

/**
 * This method allows us to open the preference dialog on the specific page, in this case the perspective page
 * //from w ww.  j a  v  a 2 s. c  o  m
 * @param id
 *            the id of pref page to show
 * @param page
 *            the actual page to show Copied from org.eclipse.debug.internal.ui.SWTUtil
 */
public static 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(UIUtils.getActiveShell(), manager);
    BusyIndicator.showWhile(getStandardDisplay(), new Runnable() {
        public void run() {
            dialog.create();
            dialog.setMessage(targetNode.getLabelText());
            dialog.open();
        }
    });
}

From source file:com.aptana.ide.debug.internal.ui.actions.DetailOptionsActionDelegate.java

License:Open Source License

/**
 * @see org.eclipse.ui.IActionDelegate#run(org.eclipse.jface.action.IAction)
 *//*from  www .j  ava  2  s . co  m*/
public void run(IAction action) {
    final IPreferenceNode targetNode = new PreferenceNode(
            "com.aptana.ide.debug.ui.preferences.jsDetailFormatters", new JSDetailFormattersPreferencePage()); //$NON-NLS-1$

    PreferenceManager manager = new PreferenceManager();
    manager.addToRoot(targetNode);
    final PreferenceDialog dialog = new PreferenceDialog(DebugUiPlugin.getActiveWorkbenchShell(), manager);
    final boolean[] result = new boolean[] { false };
    BusyIndicator.showWhile(DebugUiPlugin.getStandardDisplay(), new Runnable() {
        public void run() {
            dialog.create();
            dialog.setMessage(targetNode.getLabelText());
            result[0] = (dialog.open() == Window.OK);
        }
    });
}

From source file:com.aptana.js.debug.ui.internal.actions.DetailOptionsActionDelegate.java

License:Open Source License

/**
 * @see org.eclipse.ui.IActionDelegate#run(org.eclipse.jface.action.IAction)
 *//*from w  w w  .j  a  va2  s .c  o m*/
public void run(IAction action) {
    final IPreferenceNode targetNode = new PreferenceNode("com.aptana.debug.ui.preferences.jsDetailFormatters", //$NON-NLS-1$
            new JSDetailFormattersPreferencePage());

    PreferenceManager manager = new PreferenceManager();
    manager.addToRoot(targetNode);
    final PreferenceDialog dialog = new PreferenceDialog(UIUtils.getActiveShell(), manager);
    final boolean[] result = new boolean[] { false };
    BusyIndicator.showWhile(DebugUiPlugin.getStandardDisplay(), new Runnable() {
        public void run() {
            dialog.create();
            dialog.setMessage(targetNode.getLabelText());
            result[0] = (dialog.open() == Window.OK);
        }
    });
}

From source file:com.aptana.ui.preferences.GenericRootPreferencePage.java

License:Open Source License

/**
 * Creates the links.//  w  w w. ja  v a 2  s .  c  o m
 */
@SuppressWarnings({ "unchecked" })
protected Control createContents(Composite parent) {
    // pageNameToId = null
    if (pageNameToId == null) {
        pageNameToId = new HashMap<String, String>();
        String pageId = getPageId();
        // Locate all the pages that are defined as this page children
        PreferenceManager manager = PlatformUI.getWorkbench().getPreferenceManager();
        List<IPreferenceNode> nodes = manager.getElements(PreferenceManager.POST_ORDER);
        for (Iterator<IPreferenceNode> i = nodes.iterator(); i.hasNext();) {
            IPreferenceNode node = i.next();
            if (node.getId().equals(pageId)) {
                // we found the node, so take its child nodes and add them to the cache
                IPreferenceNode[] subNodes = node.getSubNodes();
                for (IPreferenceNode child : subNodes) {
                    pageNameToId.put(child.getLabelText(), child.getId());
                }
                break;
            }
        }
    }
    Composite composite = new Composite(parent, SWT.NONE);
    composite.setLayout(new GridLayout(1, false));

    String contentsMessage = getContentsMessage();
    if (contentsMessage != null) {
        Label message = new Label(composite, SWT.WRAP);
        message.setText(contentsMessage);
    }
    Group group = new Group(composite, SWT.NONE);
    group.setLayout(new GridLayout(1, false));
    GridData gd = new GridData(GridData.FILL_HORIZONTAL);
    group.setLayoutData(gd);
    group.setText(EplMessages.GenericRootPage_preferences);
    List<String> pagesNames = new ArrayList<String>(pageNameToId.keySet());
    // In case there are no pages to link to, add a label that will indicate that there are no settings
    if (pagesNames.isEmpty()) {
        Label label = new Label(group, SWT.NONE);
        label.setText(EplMessages.GenericRootPage_noAvailablePages);
        label.setLayoutData(new GridData());
    } else {
        Collections.sort(pagesNames);
        for (String pageName : pagesNames) {
            String id = pageNameToId.get(pageName);
            final Link link = new Link(group, SWT.NONE);
            link.setText("<a>" + pageName + "</a>"); //$NON-NLS-1$ //$NON-NLS-2$
            link.addSelectionListener(new LinkSelectionListener(id));
            gd = new GridData();
            gd.horizontalIndent = 30;
            link.setLayoutData(gd);
        }
    }

    Group dialogsResetGroup = new Group(composite, SWT.NONE);
    dialogsResetGroup.setLayout(GridLayoutFactory.swtDefaults().numColumns(2).create());
    dialogsResetGroup.setLayoutData(GridDataFactory.fillDefaults().create());
    dialogsResetGroup.setText(EplMessages.GenericRootPreferencePage_dialogsGroup);

    Label label = new Label(dialogsResetGroup, SWT.WRAP);
    label.setText(EplMessages.GenericRootPreferencePage_clearMessagesLabelText);
    label.setLayoutData(GridDataFactory.fillDefaults().grab(true, false).align(SWT.FILL, SWT.CENTER)
            .hint(convertVerticalDLUsToPixels(50), SWT.DEFAULT).create());

    final Button clearBt = new Button(dialogsResetGroup, SWT.PUSH);
    clearBt.setText(EplMessages.GenericRootPreferencePage_clearMessagesButtonLabel);
    clearBt.setLayoutData(new GridData(GridData.FILL, GridData.BEGINNING, false, false));
    // enable the 'reset' button only if there are dialogs to reset.
    final IEclipsePreferences prefs = (EclipseUtil.instanceScope()).getNode(UIEplPlugin.PLUGIN_ID);
    String messages = prefs.get(IEplPreferenceConstants.HIDDEN_MESSAGES, null);
    clearBt.setEnabled(!StringUtil.isEmpty(messages));
    clearBt.addSelectionListener(new SelectionAdapter() {
        public void widgetSelected(SelectionEvent e) {
            try {
                prefs.remove(IEplPreferenceConstants.HIDDEN_MESSAGES);
                prefs.flush();
                clearBt.setEnabled(false);
            } catch (Exception ex) {
                IdeLog.logError(UIEplPlugin.getDefault(), ex);
            }
        }
    });

    Point point = composite.computeSize(SWT.DEFAULT, SWT.DEFAULT, true);
    gd = new GridData();
    composite.setLayoutData(gd);
    gd.heightHint = point.y;
    return composite;
}

From source file:com.astra.ses.spell.dev.advisor.ApplicationWorkbenchWindowAdvisor.java

License:Open Source License

public void postWindowOpen() {
    IPreferenceNode[] nodes = getWorkbench().getPreferenceManager().getRootSubNodes();
    for (IPreferenceNode node : nodes) {
        if (node.getLabelText().equals("General")) {
            node.remove("org.eclipse.ui.preferencePages.Perspectives");
            node.remove("org.eclipse.ui.preferencePages.Keys");
            node.remove("org.eclipse.ui.preferencePages.Startup");
            node.remove("org.eclipse.ui.preferencePages.ContentTypes");
            node.remove("org.eclipse.ui.preferencePages.Workspace");
        }//from  w w  w.  j  a va 2 s  . c o  m
    }
}

From source file:com.bdaum.overlayPages.FieldEditorOverlayPage.java

License:Open Source License

/**
 * Show a single preference pages/*from ww  w  .ja va  2  s.c o  m*/
 * 
 * @param id
 *            - the preference page identification
 * @param page
 *            - the preference page
 */
protected void showPreferencePage(final String id, final IPreferencePage page) {
    final IPreferenceNode targetNode = new PreferenceNode(id, page);
    final 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:com.iw.plugins.spindle.ui.util.UIUtils.java

License:Mozilla Public License

public static boolean showPreferencePage(Shell shell, String id, IPreferencePage page) {
    final IPreferenceNode targetNode = new PreferenceNode(id, page);

    PreferenceManager manager = new PreferenceManager();
    manager.addToRoot(targetNode);/*from  ww w.  jav  a  2 s.c om*/
    final PreferenceDialog dialog = new PreferenceDialog(shell, manager);
    final boolean[] result = new boolean[] { false };
    BusyIndicator.showWhile(shell.getDisplay(), new Runnable() {
        public void run() {
            dialog.create();
            dialog.setMessage(targetNode.getLabelText());
            result[0] = (dialog.open() == Window.OK);
        }
    });
    return result[0];
}