Example usage for org.eclipse.jface.preference IPreferenceStore getString

List of usage examples for org.eclipse.jface.preference IPreferenceStore getString

Introduction

In this page you can find the example usage for org.eclipse.jface.preference IPreferenceStore getString.

Prototype

String getString(String name);

Source Link

Document

Returns the current value of the string-valued preference with the given name.

Usage

From source file:com.nokia.tools.theme.s60.cstore.ComponentPoolConfig.java

License:Open Source License

public static ComponentPoolConfig load() {

    IPreferenceStore iPreferenceStore = UtilsPlugin.getDefault().getPreferenceStore();
    ComponentPoolConfig cfg = new ComponentPoolConfig();

    iPreferenceStore.setDefault(PREF_ADD_EXAMPLES, true);
    cfg.addExampleThemes = iPreferenceStore.getBoolean(PREF_ADD_EXAMPLES);
    cfg.addOpenThemes = iPreferenceStore.getBoolean(PREF_ADD_OPEN_TH);
    cfg.addWorkspaceTheme = iPreferenceStore.getBoolean(PREF_ADD_WSPACE_TH);
    cfg.addCustomThemes = iPreferenceStore.getBoolean(PREF_ADD_CUSTOM_TH);
    int userCount = iPreferenceStore.getInt(PREF_ADD_USERTHEMECOUNT);
    cfg.userThemeList = new ArrayList<String>();
    for (int a = 0; a < userCount; a++) {
        String path = iPreferenceStore.getString(PREF_ADD_USERTHEME_BASE + (a));
        if (path.length() > 0 && new File(path).exists()) {
            cfg.userThemeList.add(path);
        }/*from w  w  w .j  a va 2  s .c  om*/
    }

    return cfg;

}

From source file:com.nokia.tools.theme.ui.dialogs.SVG2BitmapConversionConfirmationDialog.java

License:Open Source License

/**
 * @see org.eclipse.jface.dialogs.Dialog#
 *      createDialogArea(org.eclipse.swt.widgets.Composite) Here we fill the
 *      center area of the dialog/* w w  w  .  j  ava  2s  .  c  o  m*/
 */
protected Control createDialogArea(Composite parent) {
    PlatformUI.getWorkbench().getHelpSystem().setHelp(parent.getParent(),
            SVG2BitmapConversionConfirmationDialog.CONVERSION_CONFIRMATION_DIALOG_CONTEXT);

    Composite area = (Composite) super.createDialogArea(parent);
    Composite container = new Composite(area, SWT.NONE);
    container.setLayoutData(new GridData(GridData.FILL_BOTH));
    GridLayout layout = new GridLayout();
    container.setLayout(layout);
    layout.marginHeight = 13;
    layout.marginWidth = 13;
    layout.verticalSpacing = 7;

    setTitle(Messages.SVGConversionConfirmDialog_banner_title);
    setMessage(Messages.SVGConversionConfirmDialog_banner_message);

    IBrandingManager manager = BrandingExtensionManager.getBrandingManager();
    if (manager != null) {
        Image titleAreaImage = manager.getBannerImageDescriptor(
                Activator.imageDescriptorFromPlugin(Activator.PLUGIN_ID, "icons/wizban/convert_edit_bmp.png"))
                .createImage();
        setTitleImage(titleAreaImage);
        forDispose.add(titleAreaImage);
    }

    Composite spinners = new Composite(container, SWT.NONE);
    layout = new GridLayout(5, false);
    spinners.setLayout(layout);
    layout.marginHeight = 0;
    layout.marginWidth = 0;

    Label l = new Label(spinners, SWT.NONE);
    l.setText(Messages.SVGConversionConfirmDialog_text2);

    width = new Spinner(spinners, SWT.BORDER);
    width.setMinimum(1);
    width.setMaximum(999);
    GridData gd = new GridData();
    gd.widthHint = 30;
    width.setLayoutData(gd);
    width.setSelection(bounds.width);

    Label x = new Label(spinners, SWT.NONE);
    x.setText(" x ");

    height = new Spinner(spinners, SWT.BORDER);
    height.setMinimum(1);
    height.setMaximum(999);
    gd = new GridData();
    gd.widthHint = 30;
    height.setLayoutData(gd);
    height.setSelection(bounds.height);

    x = new Label(spinners, SWT.NONE);
    x.setText(Messages.SVGConversionConfirmDialog_pixelsLabel);

    // preserve mask check
    final Button maskCheck = new Button(container, SWT.CHECK);
    maskCheck.setText(Messages.SVGConversionConfirmDialog_maskCheckLabel);
    maskCheck.addSelectionListener(new SelectionListener() {
        public void widgetSelected(SelectionEvent e) {
            boolean state = maskCheck.getSelection();
            maskPreserve = state;
            IPreferenceStore iPreferenceStore = UtilsPlugin.getDefault().getPreferenceStore();
            iPreferenceStore.setValue(IMediaConstants.PREF_SVG_CONVERSION_PRESERVE_MASK, state + "");
        }

        public void widgetDefaultSelected(SelectionEvent e) {
        }
    });
    maskCheck.setToolTipText(Messages.SVGConversionConfirmDialog_maskCheckTooltip);
    // default
    IPreferenceStore iPreferenceStore = UtilsPlugin.getDefault().getPreferenceStore();
    if (StringUtils.isEmpty(iPreferenceStore.getString(IMediaConstants.PREF_SVG_CONVERSION_PRESERVE_MASK))) {
        maskCheck.setSelection(true);
    } else {
        maskCheck.setSelection(iPreferenceStore.getBoolean(IMediaConstants.PREF_SVG_CONVERSION_PRESERVE_MASK));
    }

    if (!supportMask) {
        maskCheck.setEnabled(false);
        maskCheck.setSelection(false);
    }

    maskPreserve = maskCheck.getSelection();

    // don't ask again check
    final Button check = new Button(container, SWT.CHECK);
    check.setText(Messages.SVGConversionConfirmDialog_dontAskAgain);
    check.addSelectionListener(new SelectionListener() {
        public void widgetSelected(SelectionEvent e) {

            boolean state = check.getSelection();
            if (state) {
                width.setEnabled(false);
                width.setSelection(bounds.width);
                height.setEnabled(false);
                height.setSelection(bounds.width);
            } else {
                width.setEnabled(true);
                height.setEnabled(true);
            }
            IPreferenceStore iPreferenceStore = UtilsPlugin.getDefault().getPreferenceStore();
            iPreferenceStore.setValue(IMediaConstants.PREF_SILENT_SVG_CONVERSION, state);
        }

        public void widgetDefaultSelected(SelectionEvent e) {
        }
    });
    check.setToolTipText(Messages.SVGConversionConfirmDialog_checkTooltip);
    check.setEnabled(rc);

    Composite container2 = new Composite(area, SWT.NONE);
    container2.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
    layout = new GridLayout();
    container2.setLayout(layout);
    layout.marginHeight = 0;
    layout.marginWidth = 0;
    layout.verticalSpacing = 0;

    final Label separator = new Label(container2, SWT.SEPARATOR | SWT.HORIZONTAL);
    separator.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));

    return area;
}

From source file:com.nokia.tools.theme.ui.dialogs.ThemeResourceSelectionPage.java

License:Open Source License

private void initSuggestionsAndHistory() {
    IPreferenceStore iPreferenceStore = UtilsPlugin.getDefault().getPreferenceStore();

    int historyCount = iPreferenceStore.getInt(IScreenConstants.PREF_FILTER_HISTORY_COUNT);
    for (int i = 0; i < historyCount; i++) {
        String history = iPreferenceStore.getString(IScreenConstants.PREF_ADD_FILTER_HISTORY + (i));
        suggestionsAndHistory.add(history);
    }/* w w w .j a va  2 s  .co m*/
}

From source file:com.nokia.tools.ui.dialog.ChooseProgramDialog.java

License:Open Source License

@Override
protected Control createDialogArea(final Composite parent) {
    prgmDesList = new ArrayList<ProgramDescriptor>(
            Arrays.asList(RegQueryUtil.getRecommendedPrograms(fileExtn)));
    final ProgramDescriptor initialPgm = addProgram(initialProgram);

    final Composite area = (Composite) super.createDialogArea(parent);
    setTitle(getTitle());/*  w w w .j  a  va  2 s .co  m*/
    if (bannerMessage != null) {
        setMessage(bannerMessage);
    } else {
        setMessage(Messages.Choose_Program_To_Open);
    }
    Composite rootArea = new Composite(area, SWT.NONE);
    GridData gd = new GridData(GridData.FILL, GridData.FILL, true, true);
    rootArea.setLayoutData(gd);
    GridLayout gl = new GridLayout(1, false);
    gl.marginHeight = 13;
    gl.marginWidth = 13;
    gl.verticalSpacing = 7;
    rootArea.setLayout(gl);

    groupArea = new Group(rootArea, SWT.NONE);
    groupArea.setText(Messages.Program);
    gd = new GridData(GridData.FILL, GridData.FILL, true, true);
    groupArea.setLayoutData(gd);
    gl = new GridLayout(2, false);
    gl.marginHeight = 9;
    gl.marginWidth = 9;
    gl.verticalSpacing = 7;
    groupArea.setLayout(gl);

    tableViewer = new TableViewer(groupArea, SWT.FULL_SELECTION | SWT.BORDER | SWT.V_SCROLL);

    final Table items = tableViewer.getTable();
    items.setLinesVisible(false);
    items.setHeaderVisible(false);
    gd = new GridData(SWT.FILL, SWT.FILL, true, true);
    gd.minimumHeight = 50;
    gd.minimumWidth = 100;
    gd.widthHint = 250;
    gd.heightHint = 100;
    gd.horizontalSpan = 2;
    items.setLayoutData(gd);

    tableViewer.setLabelProvider(new ProgramLabelProvider());
    tableViewer.setContentProvider(new ArrayContentProvider());
    IPreferenceStore oldStore = UIPreferences.getStore();
    String allEditors = oldStore.getString(fileExtn);
    if (!StringUtils.isEmpty(allEditors)) {
        String[] editors = allEditors.split(",");
        for (String editor : editors) {
            addProgram(editor);
        }
    }
    tableViewer.setInput(prgmDesList);

    if (initialPgm != null) {
        tableViewer.setSelection(new StructuredSelection(initialPgm));
    } else {
        tableViewer.setSelection(new StructuredSelection(tableViewer.getElementAt(0)));
    }

    if (showAlwaysUseMessage) {
        checkAlways = new Button(groupArea, SWT.CHECK);
        checkAlways.setText("Always use the selected program to open this kind of file");
        gd = new GridData(SWT.FILL, SWT.NONE, true, false);
        gd.horizontalSpan = 2;
        checkAlways.setLayoutData(gd);
    }

    btnBrowse = new Button(groupArea, SWT.NONE);
    btnBrowse.setText("&Browse...");
    initializeDialogUnits(btnBrowse);
    setButtonLayoutData(btnBrowse);
    gd = (GridData) btnBrowse.getLayoutData();
    gd.horizontalSpan = 2;
    gd.horizontalAlignment = SWT.RIGHT;
    btnBrowse.addSelectionListener(new SelectionAdapter() {
        @Override
        public void widgetSelected(final SelectionEvent se) {
            final FileDialog fd = new FileDialog(new Shell(), SWT.SYSTEM_MODAL | SWT.OPEN);
            fd.setFilterExtensions(externalToolFilter);
            if (initialProgram != "") {
                fd.setFileName(initialProgram);
            }
            final String text = fd.open();
            if (text != null) {
                final ProgramDescriptor des = addProgram(text);
                if (des != null) {
                    selectedProgram = des;
                    tableViewer.setInput(prgmDesList);
                    tableViewer.setSelection(new StructuredSelection(des));

                }
                IPreferenceStore store = UIPreferences.getStore();
                String temp = store.getString(fileExtn);
                if (!StringUtils.isEmpty(temp)) {
                    if (!temp.contains(des.getFullPath())) {
                        String allEditors = temp + ',' + des.getFullPath();
                        store.setValue(fileExtn, allEditors);
                    }
                } else {
                    store.setValue(fileExtn, des.getFullPath());
                }
            }
        }

    });

    Composite separatorComposite = new Composite(area, SWT.NONE);
    separatorComposite.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
    GridLayout layout3 = new GridLayout();
    separatorComposite.setLayout(layout3);
    layout3.numColumns = 1;
    layout3.marginHeight = 0;
    layout3.marginWidth = 0;
    layout3.verticalSpacing = 0;

    final Label separator = new Label(separatorComposite, SWT.SEPARATOR | SWT.HORIZONTAL);
    gd = new GridData(GridData.FILL_HORIZONTAL);
    separator.setLayoutData(gd);

    return area;

}

From source file:com.nokia.tools.ui.dialog.PathHandlingConfig.java

License:Open Source License

public static PathHandlingConfig load() {

    IPreferenceStore iPreferenceStore = Activator.getDefault().getPreferenceStore();
    PathHandlingConfig cfg = new PathHandlingConfig();

    // Defaults//from   w ww.j  a v a 2 s.  c  om
    iPreferenceStore.setDefault(PREF_USE_PREDEFINED, false);
    iPreferenceStore.setDefault(PREF_RECENT_COUNT, 5);

    cfg.usePredefined = iPreferenceStore.getBoolean(PREF_USE_PREDEFINED);
    cfg.recentCount = iPreferenceStore.getInt(PREF_RECENT_COUNT);

    int defCount = iPreferenceStore.getInt(PREF_PREDEFINED_COUNT);
    int recCount = iPreferenceStore.getInt(PREF_RECENT_COUNT);

    cfg.predefinedPathList = new ArrayList<String>();

    for (int i = 0; i < defCount; i++) {
        String path = iPreferenceStore.getString(PREF_ADD_PREDEFINED + (i));
        if (path.length() > 0 && new File(path).exists()) {
            cfg.predefinedPathList.add(path);
        }
    }

    cfg.recentPathList = new ArrayList<String>();

    for (int i = 0; i < recCount; i++) {
        String path = iPreferenceStore.getString(PREF_ADD_RECENTLY + (i));
        if (path.length() > 0 && new File(path).exists()) {
            cfg.recentPathList.add(path);
        }
    }
    return cfg;
}

From source file:com.nokia.tools.ui.dialog.ResourceSelectionDialog.java

License:Open Source License

/**
 * @return the initial page index./* w w  w . j ava2  s  .  c o m*/
 */
private int getInitialPageIndex() {
    IPreferenceStore store = UIPreferences.getStore();
    return getPageIndex(store.getString(UIPreferences.PREF_LAST_ACTIVE_RESOURCE_PAGE));
}

From source file:com.nokia.tools.ui.prefs.UIPreferencesUtil.java

License:Open Source License

public static String getStringValue(final String id) {
    final IPreferenceStore store = Activator.getDefault().getPreferenceStore();
    return store.getString(id);
}

From source file:com.nokia.traceviewer.action.ConnectAction.java

License:Open Source License

/**
 * Checks connection preferences/*from   w  ww.  j  a va2 s. c  om*/
 * 
 * @return true if connection is selected, false otherwise
 */
private boolean checkConnectionPreferences() {
    boolean connectionSettingsDefined = true;
    IPreferenceStore store = TraceViewerPlugin.getDefault().getPreferenceStore();

    // Open preferences page
    if (store.getString(PreferenceConstants.CONNECTION_TYPE).equals("") //$NON-NLS-1$
            || !preferencesMatchSelectedConnection(store)) {
        connectionSettingsDefined = TraceViewerGlobals.getTraceViewer().getDialogs()
                .openPreferencePage(TVPreferencePage.CONNECTION);

        // If user clicked OK, check that some connection is selected
        if (connectionSettingsDefined) {
            if (store.getString(PreferenceConstants.CONNECTION_TYPE).equals("")) { //$NON-NLS-1$
                connectionSettingsDefined = false;
            }
        }
    }
    return connectionSettingsDefined;
}

From source file:com.nokia.traceviewer.action.ConnectAction.java

License:Open Source License

/**
 * Checks that set preferences match selected connections preferences
 * /*from   www.j a  v  a2s. co m*/
 * @param store
 *            preference store
 * @return true if set preferences match the parameters in selected Remote
 *         Connection
 */
private boolean preferencesMatchSelectedConnection(IPreferenceStore store) {
    boolean matches = false;
    if (!checkPreferences || ConnectionHelper.isCurrentConnectionSelected) {
        matches = true;
    } else {
        String selectedIdentifier = store.getString(PreferenceConstants.SELECTED_CONNECTION_ID);

        // Get and compare the parameters from currently selected connection
        Iterator<IConnection> connections = RemoteConnectionsActivator.getConnectionsManager().getConnections()
                .iterator();
        while (connections.hasNext()) {
            IConnection conn = connections.next();

            // First find the right connection with the identifier
            if (conn.getIdentifier().equals(selectedIdentifier)) {
                String connectionTypeId = conn.getConnectionType().getIdentifier();
                String connectionType = store.getString(PreferenceConstants.CONNECTION_TYPE);
                boolean isMusti = connectionTypeId
                        .equals("com.nokia.carbide.trk.support.connection.TCPIPConnectionType"); //$NON-NLS-1$

                boolean isPlatsim = connectionTypeId
                        .equals("com.nokia.carbide.trk.support.connection.PlatSimConnectionType"); //$NON-NLS-1$

                // TCP / IP connection
                if (isMusti || isPlatsim) {
                    String address = conn.getSettings().get("ipAddress"); //$NON-NLS-1$
                    String port = conn.getSettings().get("port"); //$NON-NLS-1$

                    // Check that connection type, address and port match
                    if (connectionType.equals(PreferenceConstants.CONNECTION_TYPE_TCPIP)
                            && address.equals(store.getString(PreferenceConstants.IP_ADDRESS))
                            && port.equals(store.getString(PreferenceConstants.TCPIP_PORT))) {
                        matches = true;
                        break;
                    }

                    // USB connection
                } else if (connectionTypeId
                        .equals("com.nokia.carbide.trk.support.connection.USBConnectionType")) { //$NON-NLS-1$
                    String portNumStr = conn.getSettings().get("port"); //$NON-NLS-1$
                    if (connectionType.equals(PreferenceConstants.CONNECTION_TYPE_USB_SERIAL)
                            && portNumStr.equals(store.getString(PreferenceConstants.USB_SERIAL_COM_PORT))) {
                        matches = true;
                        break;
                    }
                }
            }
        }
    }
    return matches;
}

From source file:com.nokia.traceviewer.action.ConnectAction.java

License:Open Source License

/**
 * Checks used media protocol//  ww w  . ja  va 2  s  . c om
 * 
 * @return true if TraceViewer can still continue connecting. False if
 *         currently selected TraceProvider doesn't support connecting.
 */
private boolean checkUsedProtocol() {
    boolean canConnect = true;

    // First check there are more than one TraceProviders
    if (TraceViewerGlobals.getListOfTraceProviders().size() > 1 && showProtocolChangeDialog) {

        IPreferenceStore store = TraceViewerPlugin.getDefault().getPreferenceStore();
        String selectedConnectionType = store.getString(PreferenceConstants.CONNECTION_TYPE);

        // Check if current TraceProvider has selected connection type as
        // preferred
        String preferredConnectionType = TraceViewerGlobals.getTraceProvider().getPreferredConnectionType();

        // If current TraceProvider returns not supported as preferred
        // connection type,
        if (preferredConnectionType.equals(PreferenceConstants.CONNECTION_TYPE_NOT_SUPPORTED)) {
            canConnect = false;
        }

        // Connection type doesn't match, find other TraceProvider which has
        // the selected connection type as preferred
        if (!preferredConnectionType.equals(selectedConnectionType)) {
            List<TraceProvider> traceProviders = TraceViewerGlobals.getListOfTraceProviders();

            // Go through list of TraceProviders
            for (int i = 0; i < traceProviders.size(); i++) {
                TraceProvider newProvider = traceProviders.get(i);
                if (newProvider.getPreferredConnectionType().equals(selectedConnectionType)) {

                    // Create human readable change message
                    String selectedConnectionHuman = Messages.getString("ConnectAction.USBSerialMsg"); //$NON-NLS-1$
                    if (selectedConnectionType.equals(PreferenceConstants.CONNECTION_TYPE_TCPIP)) {
                        selectedConnectionHuman = Messages.getString("ConnectAction.TCPIPMsg"); //$NON-NLS-1$
                    }
                    String changeMsgStart = Messages.getString("ConnectAction.ChangeDataFormatMsg1"); //$NON-NLS-1$
                    String changeMsgEnd = Messages.getString("ConnectAction.ChangeDataFormatMsg2"); //$NON-NLS-1$

                    String confirmationMsg = selectedConnectionHuman + changeMsgStart + newProvider.getName()
                            + changeMsgEnd;

                    // Ask the user if the TraceProvider should be changed
                    boolean ret = TraceViewerGlobals.getTraceViewer().getDialogs()
                            .showConfirmationDialog(confirmationMsg);

                    // Change TraceProvider
                    if (ret) {
                        store.setValue(PreferenceConstants.DATA_FORMAT, newProvider.getName());
                        TraceViewerGlobals.getTraceViewer().clearAllData();
                        TraceViewerGlobals.setTraceProvider(newProvider, true);
                        canConnect = true;
                    } else {
                        showProtocolChangeDialog = false;
                    }
                    break;
                }
            }
        }
    }

    // Current TraceProvider doesn't support connecting
    if (!canConnect && showErrors) {
        TraceViewerGlobals.getTraceViewer().getDialogs().showErrorMessage(
                TraceViewerGlobals.getTraceProvider().getName() + CONNECTION_NOT_SUPPORTED_ERROR);
    }

    return canConnect;
}