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.microsoft.tfs.client.common.ui.helpers.WorkItemEditorHelper.java

License:Open Source License

/**
 * Retrieve the preferred editor ID from the preferences store and verify
 * the editor is still contributed. The internal work item editor ID is
 * returned as a fallback if there are any errors.
 *
 *
 * @return The editor ID of the preferred editor or the internal work item
 *         editor if the preferred editor is no longer contributed.
 *///www.  j a va2 s  .c o  m
private static String getPreferredWorkItemEditorID() {
    // Find the preferred work item editor.
    final IPreferenceStore preferences = TFSCommonUIClientPlugin.getDefault().getPreferenceStore();
    final String prefValue = preferences.getString(UIPreferenceConstants.WORK_ITEM_EDITOR_ID);

    // Check that the preferred work item editor still exists.
    final IExtensionRegistry registry = Platform.getExtensionRegistry();
    final IExtensionPoint extensionPoint = registry.getExtensionPoint(WORK_ITEM_EDITORS_EXTENSION_POINT_ID);
    final IConfigurationElement[] elements = extensionPoint.getConfigurationElements();

    // Check all contributed editors for the preference value.
    for (final IConfigurationElement element : elements) {
        final String id = element.getAttribute("id"); //$NON-NLS-1$
        if (id.equals(prefValue)) {
            // Use the preferred contributed editor.
            return id;
        }
    }

    // Default to embedded Web Access editor
    return EMBEDDED_WEB_ACCESS_EDITOR_ID;
}

From source file:com.microsoft.tfs.client.common.ui.prefs.SourceControlPreferencePage.java

License:Open Source License

private void initializeValues() {
    final IPreferenceStore store = getPreferenceStore();

    autoGetButton.setSelection(store.getBoolean(UIPreferenceConstants.GET_LATEST_ON_CHECKOUT));
    showDeletedItemsButton.setSelection(store.getBoolean(UIPreferenceConstants.SHOW_DELETED_ITEMS));
    autoResolveButton.setSelection(store.getBoolean(UIPreferenceConstants.AUTO_RESOLVE_CONFLICTS));

    if (UIPreferenceConstants.CHECKOUT_LOCK_LEVEL_CHECKOUT
            .equals(store.getString(UIPreferenceConstants.CHECKOUT_LOCK_LEVEL))) {
        lockLevelCheckOutButton.setSelection(true);
        lockLevelCheckInButton.setSelection(false);
        lockLevelUnchangedButton.setSelection(false);
    } else if (UIPreferenceConstants.CHECKOUT_LOCK_LEVEL_CHECKIN
            .equals(store.getString(UIPreferenceConstants.CHECKOUT_LOCK_LEVEL))) {
        lockLevelCheckOutButton.setSelection(false);
        lockLevelCheckInButton.setSelection(true);
        lockLevelUnchangedButton.setSelection(false);
    } else {//from  w  ww.  java  2 s  .  c  om
        lockLevelCheckOutButton.setSelection(false);
        lockLevelCheckInButton.setSelection(false);
        lockLevelUnchangedButton.setSelection(true);
    }

    notifyButton.setSelection(MessageDialogWithToggle.ALWAYS
            .equals(store.getString(UIPreferenceConstants.HIDE_ALL_FILES_UP_TO_DATE_MESSAGE)));
    checkinMessageButton.setSelection(!MessageDialogWithToggle.ALWAYS
            .equals(store.getString(UIPreferenceConstants.PROMPT_BEFORE_CHECKIN)));

    checkoutBackgroundButton.setSelection(!store.getBoolean(UIPreferenceConstants.CHECKOUT_FOREGROUND)
            && !store.getBoolean(UIPreferenceConstants.CHECKOUT_SYNCHRONOUS)
            && !store.getBoolean(UIPreferenceConstants.PROMPT_BEFORE_CHECKOUT));
    checkoutForegroundButton.setSelection(store.getBoolean(UIPreferenceConstants.CHECKOUT_FOREGROUND));
    checkoutPromptButton.setSelection(store.getBoolean(UIPreferenceConstants.PROMPT_BEFORE_CHECKOUT));
}

From source file:com.microsoft.tfs.client.eclipse.ui.egit.importwizard.CrossCollectionRepositorySelectControl.java

License:Open Source License

private String getDefaultRootFolderPreference() {
    String rootFolderPreference = null;

    // EGit 4.0 and earlier hosted default repository root directory
    // preference in the UI plugin.
    final IPreferenceStore uiPrefs = org.eclipse.egit.ui.Activator.getDefault().getPreferenceStore();
    if (uiPrefs != null) {
        rootFolderPreference = uiPrefs.getString(DEFAULT_REPOSITORY_DIR_UI_KEY);
        if (!StringUtil.isNullOrEmpty(rootFolderPreference)) {
            return rootFolderPreference;
        }/*from w  w  w .  j a  v  a2 s  .  c o m*/
    }

    // Since EGit 4.1 default repository root directory preference is hosted
    // in the Core plugin.
    final IEclipsePreferences corePrefs = org.eclipse.egit.core.Activator.getDefault().getRepositoryUtil()
            .getPreferences();
    if (corePrefs != null) {
        rootFolderPreference = corePrefs.get(DEFAULT_REPOSITORY_DIR_CORE_KEY, null);
        if (!StringUtil.isNullOrEmpty(rootFolderPreference)) {
            return rootFolderPreference;
        }
    }

    // If the preference is not set, then use the home environment variable
    rootFolderPreference = PlatformMiscUtils.getInstance().getEnvironmentVariable(EnvironmentVariables.HOME);
    if (!StringUtil.isNullOrEmpty(rootFolderPreference)) {
        return rootFolderPreference;
    }

    // If the home environment variable is not set, then use the user home
    // directory. (The same logic as in eGit.)
    rootFolderPreference = LocalPath.combine(FS.DETECTED.userHome().getPath(), "git"); //$NON-NLS-1$

    return rootFolderPreference;
}

From source file:com.mind_era.knime_rapidminer.knime.nodes.RapidMinerInit.java

License:Open Source License

/**
 * //from  w ww.j  a  v  a 2  s . c o m
 */
public static synchronized void setPreferences() {
    final IPreferenceStore store = RapidMinerNodePlugin.getDefault().getPreferenceStore();
    for (final String parameterKey : ParameterService.getParameterKeys()) {
        final ParameterType type = ParameterService.getParameterType(parameterKey);
        String storeKey = PreferenceInitializer.getRapidminerPreferenceKey(parameterKey);
        if (type instanceof ParameterTypeBoolean) {
            ParameterService.setParameterValue(parameterKey, Boolean.toString(store.getBoolean(storeKey)));
        } else if (type instanceof ParameterTypeInt) {
            ParameterService.setParameterValue(parameterKey, Integer.toString(store.getInt(storeKey)));
        } else if (type instanceof ParameterTypeStringCategory) {
            ParameterService.setParameterValue(parameterKey, Integer.toString(store.getInt(storeKey)));
        } else {
            if (type != null && type.getDefaultValueAsString() != null
                    && !type.getDefaultValueAsString().equals(store.getDefaultString(storeKey))) {
                store.setDefault(storeKey, type.getDefaultValueAsString());
            }
            ParameterService.setParameterValue(parameterKey, store.getString(storeKey));
        }
    }
}

From source file:com.mobilesorcery.sdk.builder.android.launch.ADB.java

License:Open Source License

public synchronized void startLogCat() throws CoreException {
    IPreferenceStore prefs = Activator.getDefault().getPreferenceStore();
    if (!logcatStarted) {
        logcatStarted = true;/* w  w  w .  j  a  va2 s .  c  o  m*/
        prefs.addPropertyChangeListener(logCatListener);
    }
    boolean silent = !prefs.getBoolean(PropertyInitializer.ADB_DEBUG_LOG);

    logcatProcessHandler.killProcess();
    if (!silent) {
        // Then restart!
        ArrayList<String> commandLine = new ArrayList<String>();
        commandLine.add(getToolPath().getAbsolutePath());
        commandLine.add("logcat");
        String[] args = CommandLineExecutor
                .parseCommandLine(prefs.getString(PropertyInitializer.ADB_LOGCAT_ARGS));
        commandLine.addAll(Arrays.asList(args));

        // We never have more than one logcat process.
        execute(commandLine.toArray(new String[0]), logcatProcessHandler, null, true);
    }
}

From source file:com.mobilesorcery.sdk.core.CoreMoSyncPlugin.java

License:Open Source License

/**
 * Returns the preferred launcher for a given packager.
 * @param packager/*from  www  .ja  v a 2s  . c  o  m*/
 * @return {@code null} if no preferred launcher
 */
public IEmulatorLauncher getPreferredLauncher(String packager) {
    IPreferenceStore store = getPreferenceStore();
    String launcherId = store.getString(PREFERRED_LAUNCER_PREF_PREFIX + packager);
    return getEmulatorLauncher(launcherId);
}

From source file:com.motorola.studio.android.adt.DDMSFacade.java

License:Apache License

/**
 * Must be called only once, during AndroidPlugin start-up.
 * This method configures all necessary device listeners. 
 *//*ww w .java  2  s.c  o  m*/
public static void setup() {
    AndroidPlugin.getDefault().addSDKLoaderListener(new Runnable() {

        public void run() {
            AndroidDebugBridge adb = AndroidDebugBridge.getBridge();
            if (adb == null) {
                AndroidDebugBridge.disconnectBridge();
                DdmsPlugin.setToolsLocation(AdtPlugin.getOsAbsoluteAdb(), true,
                        AdtPlugin.getOsAbsoluteHprofConv(), AdtPlugin.getOsAbsoluteTraceview());
            }

            if (adb != null) {
                IDevice[] x = adb.getDevices();
                IDevice[] newDevices = x;
                List<IDevice> oldDevList = new ArrayList<IDevice>(connectedDevices.values());

                for (IDevice newDev : newDevices) {
                    String serialNum = newDev.getSerialNumber();
                    if (connectedDevices.containsKey(serialNum)) {
                        IDevice oldDev = connectedDevices.get(serialNum);
                        oldDevList.remove(oldDev);
                        if (oldDev.getState().compareTo((newDev).getState()) != 0) {
                            if ((newDev).getState() == DeviceState.OFFLINE) {
                                deviceDisconnected(newDev);
                            } else if ((newDev).getState() == DeviceState.ONLINE) {
                                deviceConnected(newDev);
                            }
                        }
                    } else {
                        deviceConnected(newDev);
                    }
                }

                for (IDevice oldDev : oldDevList) {
                    deviceDisconnected(oldDev);
                }
            }

        }
    });

    // Adds listener for the HOME application. It adds the serial number of the 
    // device to a collection when it identifies that the HOME application has
    // loaded
    AndroidDebugBridge.addClientChangeListener(new IClientChangeListener() {

        public void clientChanged(Client client, int changeMask) {
            if ((changeMask & Client.CHANGE_NAME) == Client.CHANGE_NAME) {
                final Client finalClient = client;
                Thread t = new Thread() {

                    @Override
                    public void run() {
                        String applicationName = finalClient.getClientData().getClientDescription();
                        if (applicationName != null) {
                            IPreferenceStore store = AdtPlugin.getDefault().getPreferenceStore();
                            String home = store.getString(AdtPrefs.PREFS_HOME_PACKAGE);
                            if (home.equals(applicationName)) {
                                String serialNum = finalClient.getDevice().getSerialNumber();
                                synchronized (completelyUpDevices) {
                                    StudioLogger.debug("Completely Up Device: " + serialNum); //$NON-NLS-1$
                                    completelyUpDevices.add(serialNum);
                                }
                            }
                        }
                    }
                };
                t.start();
            }
        }
    });
}

From source file:com.motorola.studio.android.adt.DDMSFacade.java

License:Apache License

static void deviceStatusChanged(IDevice device) {
    StudioLogger.debug("Device changed: " + device.getSerialNumber()); //$NON-NLS-1$
    synchronized (connectedDevices) {
        connectedDevices.put(device.getSerialNumber(), device);
    }/*  w ww.  j  a va  2s  . c o  m*/
    if ((device).getState() == DeviceState.ONLINE) {
        IPreferenceStore store = AdtPlugin.getDefault().getPreferenceStore();
        String home = store.getString(AdtPrefs.PREFS_HOME_PACKAGE);
        if (device.getClient(home) != null) {
            synchronized (completelyUpDevices) {
                StudioLogger.debug("Completely Up Device: " + device.getSerialNumber()); //$NON-NLS-1$
                if (!completelyUpDevices.contains(device.getSerialNumber())) {
                    completelyUpDevices.add(device.getSerialNumber());
                }
            }
        }
    }
}

From source file:com.motorola.studio.android.adt.DDMSFacade.java

License:Apache License

/**
 * Registers a device as connected/*from   w w w .ja  v a  2 s  .c om*/
 * 
 * @param device
 */
static void deviceConnected(IDevice device) {
    final String serialNumber = device.getSerialNumber();
    StudioLogger.debug("Device connected: " + serialNumber); //$NON-NLS-1$
    synchronized (connectedDevices) {
        connectedDevices.put(serialNumber, device);
    }

    if (!device.isEmulator() && !device.hasClients()) {
        boolean timeout = false;
        long startTime = System.currentTimeMillis();
        int maxInterval = 10000;
        do {
            try {
                Thread.sleep(250);
            } catch (InterruptedException e) {
                //do nothing
            }
            long currentTime = System.currentTimeMillis();
            timeout = ((startTime + maxInterval) < currentTime);

        } while (!device.hasClients() && !timeout);
        if (timeout) {
            synchronized (completelyUpDevices) {
                //put the device up anyway.
                completelyUpDevices.add(serialNumber);
            }
        }
    }

    if (device.hasClients()) {
        // When a device is connected, look for the HOME application and add
        // the device serial number to a collection if it is already running.
        IPreferenceStore store = AdtPlugin.getDefault().getPreferenceStore();
        String home = store.getString(AdtPrefs.PREFS_HOME_PACKAGE);
        if (device.getClient(home) != null) {
            StudioLogger.debug("Completely Up Device: " + serialNumber); //$NON-NLS-1$
            synchronized (completelyUpDevices) {
                completelyUpDevices.add(serialNumber);
            }
        }
    }

    StudioAndroidEventManager.fireEvent(EventType.DEVICE_CONNECTED, serialNumber);
}

From source file:com.motorola.studio.android.adt.MotodevHProfDumpHandler.java

License:Apache License

private void extractRemoteHprof(final String remoteFilePath, final Client client) {
    progressMonitor.beginTask(AndroidNLS.DumpHprofFile_GeneratingMemoryAnalysisOutput, 100);
    final IDevice targetDevice = client.getDevice();
    try {/*from  w  ww  .  j av a  2s.c  o m*/
        // get the sync service to pull the HPROF file            
        final SyncService syncService = client.getDevice().getSyncService();
        if (syncService != null) {
            // get from the preference what action to take
            IPreferenceStore preferenceStore = DdmsPlugin.getDefault().getPreferenceStore();
            String actionValue = preferenceStore.getString(PreferenceInitializer.ATTR_HPROF_ACTION);

            if (SAVE_ACTION.equals(actionValue)) {
                warnAboutSaveHprofPreference();
            }

            actionValue = preferenceStore.getString(PreferenceInitializer.ATTR_HPROF_ACTION);

            if (OPEN_ACTION.equals(actionValue)) {
                progressMonitor.setTaskName(AndroidNLS.DumpHprofFile_CreatingTempFile);
                File hprofTempFile = File.createTempFile(selectedApp, HPROF_FILE_EXTENSION);
                progressMonitor.worked(25);

                String tempHprofFilePath = hprofTempFile.getAbsolutePath();

                progressMonitor.setTaskName(AndroidNLS.DumpHprofFile_GettingFileFromRemoteDevice);
                progressMonitor.worked(50);

                syncService.pullFile(remoteFilePath, tempHprofFilePath,
                        new SyncProgressMonitor(progressMonitor, "")); //$NON-NLS-1$

                openHprofFileInEditor(tempHprofFilePath);

            } else {
                progressMonitor.setTaskName(AndroidNLS.DumpHprofFile_SavingFile);
                try {
                    promptAndPull(syncService,
                            client.getClientData().getClientDescription() + HPROF_FILE_EXTENSION,
                            remoteFilePath, AndroidNLS.MotodevHProfDumpHandler_saveHProfFile);
                } catch (Exception e) {
                    displayErrorFromUiThread(
                            AndroidNLS.UI_Hprof_Handler_Dialog_Unable_to_download_Hprof
                                    + FORMATTED_ERROR_STRING,
                            targetDevice.getSerialNumber(), e.getLocalizedMessage());
                }
                progressMonitor.worked(100);
            }

        } else {
            displayErrorFromUiThread(
                    AndroidNLS.UI_Hprof_Handler_Dialog_Unable_to_download_Hprof + FORMATTED_ERROR_STRING_2,
                    targetDevice.getSerialNumber());
        }
    } catch (Exception e) {
        displayErrorFromUiThread(
                AndroidNLS.UI_Hprof_Handler_Dialog_Unable_to_download_Hprof + FORMATTED_ERROR_STRING_2,
                targetDevice.getSerialNumber());

    } finally {
        progressMonitor.done();
    }
}