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.traceviewer.action.ConnectAction.java

License:Open Source License

/**
 * Changes connect button tooltip if needed
 *///from w w w .j  av  a  2s  .c o m
public void changeConnectToolTip() {
    IPreferenceStore store = TraceViewerPlugin.getDefault().getPreferenceStore();

    boolean connected = (TraceViewerGlobals.getTraceViewer().getConnection() != null
            && TraceViewerGlobals.getTraceViewer().getConnection().isConnected());

    // Start with either connect or disconnect
    String toolTipText;
    if (!connected) {
        toolTipText = Messages.getString("ConnectAction.Tooltip"); //$NON-NLS-1$ 
    } else {
        toolTipText = Messages.getString("DisconnectAction.Tooltip"); //$NON-NLS-1$ 
    }

    // Construct the tooltip for connect action
    String connName = store.getString(PreferenceConstants.SELECTED_CONNECTION_NAME);

    // "Current connection" selected or already connected
    if (ConnectionHelper.isCurrentConnectionSelected || connected) {
        String curText = Messages.getString("ConnectAction.TooltipCurr"); //$NON-NLS-1$
        IConnection currentConnection = RemoteConnectionsActivator.getConnectionsManager()
                .getCurrentConnection();
        if (currentConnection != null) {
            curText = currentConnection.getDisplayName();
        } else if (connected) {
            curText = connName;
        }
        toolTipText = toolTipText + curText;
    }

    // No connection selected
    else if (connName.equals("")) { //$NON-NLS-1$
        toolTipText = toolTipText + Messages.getString("ConnectAction.Tooltip2"); //$NON-NLS-1$

        // Static connection selected
    } else {
        toolTipText = toolTipText + connName;
    }
    setToolTipText(toolTipText);
}

From source file:com.nokia.traceviewer.api.ConnectionHandler.java

License:Open Source License

/**
 * Changes Data Format/*from  w w w  .  j  a v a  2 s.c  o  m*/
 */
private void changeDataFormat() {

    // Get the TraceViewer preferenceStore
    IPreferenceStore store = TraceViewerPlugin.getDefault().getPreferenceStore();

    // If there are more than one TraceProvider
    if (TraceViewerGlobals.getListOfTraceProviders().size() > 1) {

        String selectedConnectionType = store.getString(PreferenceConstants.CONNECTION_TYPE);

        // If the currently selected TraceProvider doesn't has selected
        // connection as preferred, try to find one that does
        if (!TraceViewerGlobals.getTraceProvider().getPreferredConnectionType()
                .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)) {
                    store.setValue(PreferenceConstants.DATA_FORMAT, newProvider.getName());

                    // Set new Trace provider
                    TraceViewerGlobals.setTraceProvider(newProvider, true);
                    break;
                }
            }
        }
    }
}

From source file:com.nokia.traceviewer.api.ConnectionHandler.java

License:Open Source License

/**
 * Saves old connection preferences//w  w w . j av a  2  s  .  c  o m
 */
private void saveConnectionPreferences() {

    // Get the TraceViewer preferenceStore
    IPreferenceStore store = TraceViewerPlugin.getDefault().getPreferenceStore();

    oldConnectionMethod = store.getString(PreferenceConstants.CONNECTION_TYPE);

    oldSelectedConnectionID = store.getString(PreferenceConstants.SELECTED_CONNECTION_ID);

    // TCP / IP connection
    if (oldConnectionMethod.equals(PreferenceConstants.CONNECTION_TYPE_TCPIP)) {
        oldParameters = new String[2];
        oldParameters[0] = store.getString(PreferenceConstants.IP_ADDRESS);
        oldParameters[1] = store.getString(PreferenceConstants.TCPIP_PORT);

        // USB Serial connection
    } else if (oldConnectionMethod.equals(PreferenceConstants.CONNECTION_TYPE_USB_SERIAL)) {
        oldParameters = new String[1];
        oldParameters[0] = store.getString(PreferenceConstants.USB_SERIAL_COM_PORT);
    }
}

From source file:com.nokia.traceviewer.engine.ConnectionCreator.java

License:Open Source License

/**
 * Creates and returns a connection/*from   w w w  .ja v a 2  s . c om*/
 * 
 * @return created connection
 */
public Connection getConnection() {
    Connection connection = null;
    IPreferenceStore store = TraceViewerPlugin.getDefault().getPreferenceStore();

    // TCP connection
    if (store.getString(PreferenceConstants.CONNECTION_TYPE)
            .equals(PreferenceConstants.CONNECTION_TYPE_TCPIP)) {

        connection = createTcpConnection(store);

        // USB Serial connection
    } else if (store.getString(PreferenceConstants.CONNECTION_TYPE)
            .equals(PreferenceConstants.CONNECTION_TYPE_USB_SERIAL)) {
        connection = createUsbSerialConnection(store);
    }

    return connection;
}

From source file:com.nokia.traceviewer.engine.ConnectionCreator.java

License:Open Source License

/**
 * Creates TCP connection/*from  ww w .j  a v  a 2 s.co m*/
 * 
 * @param store
 *            preference store
 * @return created connection
 */
private Connection createTcpConnection(IPreferenceStore store) {
    Connection connection;

    // Close the old file from file handler
    TraceViewerGlobals.getTraceViewer().getFileHandler().closeFile();

    // Set parameters to array
    String[] parameters = new String[3];
    parameters[0] = store.getString(PreferenceConstants.IP_ADDRESS);
    parameters[1] = store.getString(PreferenceConstants.TCPIP_PORT);
    parameters[2] = store.getString(PreferenceConstants.TCPIP_CHANNEL);

    // Create connection
    connection = TraceViewerGlobals.getTraceProvider().getConnectionHandler();
    connection.createConnection(PreferenceConstants.CONNECTION_TYPE_TCPIP, parameters, traceFilePath);

    // Set TCF connection as file handler
    TraceViewerGlobals.getTraceViewer().setFileHandler((TraceFileHandler) connection);

    return connection;
}

From source file:com.nokia.traceviewer.engine.ConnectionCreator.java

License:Open Source License

/**
 * Creates Serial connection//from   ww w  .ja  v  a2  s  . c om
 * 
 * @param store
 *            preference store
 * @return created connection
 */
private Connection createUsbSerialConnection(IPreferenceStore store) {
    Connection connection = null;

    // Close the old file from file handler
    TraceViewerGlobals.getTraceViewer().getFileHandler().closeFile();

    // Set parameters to array
    String[] parameters = new String[1];
    parameters[0] = store.getString(PreferenceConstants.USB_SERIAL_COM_PORT);

    // Create connection
    connection = TraceViewerGlobals.getTraceProvider().getConnectionHandler();
    connection.createConnection(PreferenceConstants.CONNECTION_TYPE_USB_SERIAL, parameters, traceFilePath);

    // Set TCF connection as file handler
    TraceViewerGlobals.getTraceViewer().setFileHandler((TraceFileHandler) connection);

    return connection;
}

From source file:com.nokia.traceviewer.engine.ConnectionHelper.java

License:Open Source License

/**
 * Saves connection settings to preference store
 * /* w  w w  .ja  v  a2 s . c  om*/
 * @param ensureConnection
 *            if true, connection is ensured. It means that if the saved ID
 *            is not a ID of a "real" connection, we must find a real
 *            connection for this virtual ID
 * @return found IConnection object
 */
public static IConnection saveConnectionSettingsToPreferenceStore(boolean ensureConnection) {

    IPreferenceStore store = TraceViewerPlugin.getDefault().getPreferenceStore();

    IConnection conn = null;

    if (ensureConnection) {
        String selectedConnId = clientServiceUI.getSelectedConnection();
        if (selectedConnId == null && isCurrentConnectionSelected) {
            selectedConnId = CURRENT_CONNECTION_ID;
        } else if (selectedConnId == null) {
            selectedConnId = store.getString(PreferenceConstants.SELECTED_CONNECTION_ID);
        }

        try {
            ISelectedConnectionInfo ret = RemoteConnectionsActivator.getConnectionsManager()
                    .ensureConnection(selectedConnId, getTracingService());
            conn = ret.getConnection();
        } catch (CoreException e) {
            e.printStackTrace();
        }

    } else {
        conn = ConnectionHelper.getSelectedConnection();
    }

    // Save the currently ensured connection object
    currentEnsuredConnection = conn;

    if (conn != null && PlatformUI.getWorkbench().getDisplay().getActiveShell() != null
            && !PlatformUI.getWorkbench().getDisplay().getActiveShell().isDisposed()) {

        String connectionTypeId = conn.getConnectionType().getIdentifier();
        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$
            int channel = PreferenceConstants.TCPIP_DEFAULT_CHANNEL;
            if (isMusti) {
                try {
                    channel = Integer.parseInt(conn.getSettings().get("mustiChannel")); //$NON-NLS-1$
                } catch (NumberFormatException e) {
                    channel = 1;
                }
            }

            // Save Connection type, IP address, port number and channel
            store.setValue(PreferenceConstants.CONNECTION_TYPE, PreferenceConstants.CONNECTION_TYPE_TCPIP);
            store.setValue(PreferenceConstants.IP_ADDRESS, address);
            store.setValue(PreferenceConstants.TCPIP_PORT, port);
            store.setValue(PreferenceConstants.TCPIP_CHANNEL, channel);

            // 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$
            int portNum = Integer.parseInt(portNumStr);

            // Save Connection type and port number
            store.setValue(PreferenceConstants.CONNECTION_TYPE, PreferenceConstants.CONNECTION_TYPE_USB_SERIAL);
            store.setValue(PreferenceConstants.USB_SERIAL_COM_PORT, portNum);

        }

        // Save selected connection name. Only save the identifier if we
        // have not selected the "current connection"
        store.setValue(PreferenceConstants.SELECTED_CONNECTION_NAME, conn.getDisplayName());

        if (!isCurrentConnectionSelected) {
            store.setValue(PreferenceConstants.SELECTED_CONNECTION_ID, conn.getIdentifier());
        }

        // Current connection selected
    } else if (isCurrentConnectionSelected) {
        store.setValue(PreferenceConstants.CONNECTION_TYPE, CURRENT_CONNECTION_ID);
        store.setValue(PreferenceConstants.SELECTED_CONNECTION_ID, CURRENT_CONNECTION_ID);
        store.setValue(PreferenceConstants.SELECTED_CONNECTION_NAME, CURRENT_CONNECTION_ID);

        // Couldn't find connection
    } else {
        store.setValue(PreferenceConstants.CONNECTION_TYPE, ""); //$NON-NLS-1$

        // Resetting selected connection identifier
        store.setValue(PreferenceConstants.SELECTED_CONNECTION_ID, ""); //$NON-NLS-1$
        store.setValue(PreferenceConstants.SELECTED_CONNECTION_NAME, ""); //$NON-NLS-1$
    }

    // Change connection button tooltip
    ConnectAction action = (ConnectAction) TraceViewerGlobals.getTraceViewer().getView().getActionFactory()
            .getConnectAction();
    action.changeConnectToolTip();

    return conn;
}

From source file:com.nokia.traceviewer.engine.dataprocessor.TimestampParser.java

License:Open Source License

/**
 * Constructor//from ww  w .  j  a  va2s  . c o m
 */
public TimestampParser() {
    // Get variables from preference store
    IPreferenceStore store = TraceViewerPlugin.getDefault().getPreferenceStore();
    boolean millisec = false;
    if (store.getString(PreferenceConstants.TIMESTAMP_ACCURACY)
            .equals(PreferenceConstants.MILLISECOND_ACCURACY)) {
        millisec = true;
    }

    timestampAccuracyMilliSecs = millisec;
    showTimeFromPreviousTrace = store.getBoolean(PreferenceConstants.TIME_FROM_PREVIOUS_TRACE_CHECKBOX);

    // Start index of "time from previous trace" changes according to the
    // timestamp accuracy
    if (timestampAccuracyMilliSecs) {
        bracketStartIndex = BRACKET_START_INDEX_ACCURACY_MILLISECS;
    } else {
        bracketStartIndex = BRACKET_START_INDEX_ACCURACY_MICROSECS;
    }

}

From source file:com.palantir.typescript.preferences.ContentAssistPreferencePage.java

License:Apache License

private void synchronizeAutoActivation() {
    IPreferenceStore preferenceStore = TypeScriptPlugin.getDefault().getPreferenceStore();

    boolean autoActivationEnabled = preferenceStore
            .getBoolean(IPreferenceConstants.CONTENT_ASSIST_AUTO_ACTIVATION_ENABLED);
    this.autoActivationEnabledButton.setSelection(autoActivationEnabled);

    for (Control control : this.controls) {
        String preferenceName = (String) control.getData();

        if (preferenceName != null) {
            if (control instanceof Text) {
                String value = preferenceStore.getString(preferenceName);

                ((Text) control).setText(value);
            }/*  www .  ja  v  a2  s . c o  m*/
        }
    }

    this.synchronizeAutoActivationEnabled();
}

From source file:com.palantir.typescript.services.language.CompilerOptions.java

License:Apache License

public static CompilerOptions fromProject(IProject project) {
    checkNotNull(project);//from w w  w  . j av a2 s . com

    IPreferenceStore preferenceStore = new ProjectPreferenceStore(project);

    // create the compilation settings from the preferences
    CompilerOptions compilationSettings = new CompilerOptions();
    compilationSettings.declaration = preferenceStore.getBoolean(IPreferenceConstants.COMPILER_DECLARATION);
    compilationSettings.experimentalDecorators = preferenceStore
            .getBoolean(IPreferenceConstants.COMPILER_EXPERIMENTAL_DECORATORS);
    compilationSettings.inlineSourceMap = preferenceStore
            .getBoolean(IPreferenceConstants.COMPILER_INLINE_SOURCE_MAP);
    compilationSettings.inlineSources = preferenceStore
            .getBoolean(IPreferenceConstants.COMPILER_INLINE_SOURCES);
    compilationSettings.jsx = JsxEmit.valueOf(preferenceStore.getString(IPreferenceConstants.COMPILER_JSX));
    compilationSettings.module = ModuleKind
            .parse(preferenceStore.getString(IPreferenceConstants.COMPILER_MODULE));
    compilationSettings.moduleResolution = ModuleResolutionKind.CLASSIC;
    compilationSettings.noEmitOnError = preferenceStore
            .getBoolean(IPreferenceConstants.COMPILER_NO_EMIT_ON_ERROR);
    compilationSettings.noImplicitAny = preferenceStore
            .getBoolean(IPreferenceConstants.COMPILER_NO_IMPLICIT_ANY);
    compilationSettings.noLib = preferenceStore.getBoolean(IPreferenceConstants.COMPILER_NO_LIB);
    compilationSettings.removeComments = preferenceStore
            .getBoolean(IPreferenceConstants.COMPILER_REMOVE_COMMENTS);
    compilationSettings.sourceMap = preferenceStore.getBoolean(IPreferenceConstants.COMPILER_SOURCE_MAP);
    compilationSettings.suppressExcessPropertyErrors = preferenceStore
            .getBoolean(IPreferenceConstants.COMPILER_SUPPRESS_EXCESS_PROPERTY_ERRORS);
    compilationSettings.suppressImplicitAnyIndexErrors = preferenceStore
            .getBoolean(IPreferenceConstants.COMPILER_SUPPRESS_IMPLICIT_ANY_INDEX_ERRORS);
    compilationSettings.target = ScriptTarget
            .valueOf(preferenceStore.getString(IPreferenceConstants.COMPILER_TARGET));

    // set the output directory or file if it was specified
    String outDir = preferenceStore.getString(IPreferenceConstants.COMPILER_OUT_DIR);
    String outFile = preferenceStore.getString(IPreferenceConstants.COMPILER_OUT_FILE);

    // get the eclipse name for the output directory
    String outputFolderName = null;
    if (!Strings.isNullOrEmpty(outDir)) {
        IFolder outputFolder = project.getFolder(outDir);

        outputFolderName = EclipseResources.getContainerName(outputFolder);
    }

    if (!Strings.isNullOrEmpty(outFile)) {
        if (outputFolderName == null) {
            outputFolderName = EclipseResources.getContainerName(project);
        }

        compilationSettings.out = outputFolderName + outFile;
    } else if (outputFolderName != null) {
        compilationSettings.outDir = outputFolderName;
    }

    return compilationSettings;
}