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.s60tools.imaker.internal.preferences.ImageFlasherPreferencePage.java

License:Open Source License

private void initializeValues() {
    IPreferenceStore store = doGetPreferenceStore();
    String str = store.getString(PreferenceConstants.PREFERENCES_DIRECTORY);
    textPreferencesDirectory.setText(str);
    boolean show = store.getBoolean(PreferenceConstants.CONFML_SELECTION_DIALOG);
    checkConfml.setSelection(show);//from w  w w.j a  v  a  2 s . c om
}

From source file:com.nokia.s60tools.memspy.preferences.MemSpyPreferences.java

License:Open Source License

/**
 * Gets SWMT category settings for this session.
 * @return SWMT HeapNameFilter setting for this session.
 *///from  ww w . j  a  va 2 s. c o  m
public static String getSWMTHeapNameFilter() {
    IPreferenceStore store = MemSpyPlugin.getPrefsStore();
    String filter = store.getString(MemSpyPreferenceConstants.SWMT_HEAPFILTER_SETTING);
    return filter;
}

From source file:com.nokia.s60tools.remotecontrol.ftp.ui.view.PathHistory.java

License:Open Source License

/**
 * Return path history.//from ww w  . j av  a2s  . co m
 */
private ArrayList<IPath> getPathHistory() {
    // If path history is requested for the first time.
    if (pathHistory == null) {
        IPreferenceStore prefStore = RemoteControlActivator.getPrefsStore();
        String[] pathStringArray = prefStore.getString(CACHE_NAME).split(",");
        pathHistory = new ArrayList<IPath>();
        for (String pathString : pathStringArray) {
            pathHistory.add(new Path(pathString));
        }
    }
    return pathHistory;
}

From source file:com.nokia.s60tools.testdrop.ui.preferences.TestDropPreferences.java

License:Open Source License

/**
 * Gets data which is saved to the preference store
 *//*from w  w  w  .j  ava2s .c  o  m*/
private void getPrefStoreValues() {
    IPreferenceStore prefStore = TestDropPlugin.getPrefStore();

    boolean enableHardware = false;
    enableHardware = prefStore.getBoolean(TestDropPreferenceConstants.TEST_DROP_ENABLE_HARDWARE);
    enableHardwareTestDropCheck.setSelection(enableHardware);
    hostText.setEnabled(enableHardware);
    portText.setEnabled(enableHardware);
    usernameText.setEnabled(enableHardware);
    passwordText.setEnabled(enableHardware);
    confirmPasswordText.setEnabled(enableHardware);
    testServerConnectionButton.setEnabled(enableHardware);
    testDropImportButton.setEnabled(enableHardware);
    testDropPathText.setEnabled(enableHardware && !testDropImportButton.getSelection());
    testDropPathBrowseButton.setEnabled(enableHardware && !testDropImportButton.getSelection());

    hostText.setText(prefStore.getString(TestDropPreferenceConstants.TEST_DROP_CONNECTION_HOST));
    int port = prefStore.getInt(TestDropPreferenceConstants.TEST_DROP_CONNECTION_PORT);
    if (port != 0) {
        portText.setText(String.valueOf(port));
    }

    usernameText.setText(prefStore.getString(TestDropPreferenceConstants.TEST_DROP_CONNECTION_USERNAME));
    passwordText.setText(prefStore.getString(TestDropPreferenceConstants.TEST_DROP_CONNECTION_PASSWORD));
    confirmPasswordText.setText(prefStore.getString(TestDropPreferenceConstants.TEST_DROP_CONNECTION_PASSWORD));

    String path = prefStore.getString(TestDropPreferenceConstants.TEST_DROP_PATH);
    boolean importUsed = prefStore.getBoolean(TestDropPreferenceConstants.TEST_DROP_IMPORT);
    if (path.length() == 0 && !importUsed) {
        testDropImportButton.setSelection(true);
    } else if (path.length() > 0 && !importUsed) {
        testDropImportButton.setSelection(false);
        testDropPathText.setEnabled(true);
        testDropPathText.setText(path);
        testDropPathBrowseButton.setEnabled(true);
    } else if (path.length() > 0 && importUsed) {
        testDropPathText.setText(path);
    } else if (!importUsed) {
        testDropPathText.setText(path);
        testDropPathText.setEnabled(true);
        testDropPathBrowseButton.setEnabled(true);
        testDropImportButton.setSelection(false);
    }
    String stored = prefStore.getString(TestDropPreferenceConstants.TEST_DROP_SHOW_TEST_RESULT);
    int count = testResultViewCombo.getItemCount();
    boolean found = false;
    for (int i = 0; i < count; i++) {
        if (testResultViewCombo.getItem(i).equals(stored)) {
            testResultViewCombo.select(i);
            found = true;
            break;
        }
    }

    if (!found) {
        testResultViewCombo.select(0);
    }
    testResultPathText.setText(prefStore.getString(TestDropPreferenceConstants.TEST_DROP_TEST_RESULT_PATH));

    String mode = prefStore.getString(TestDropPreferenceConstants.TEST_DROP_DIALOG_SHOW_MODE);
    if (mode.equals(DIALOG_SHOW_MODE_ALWAYS)) {
        alwaysButton.setSelection(true);
        String cache = prefStore.getString(TestDropPreferenceConstants.TEST_DROP_TARGET_DEVICE_CACHE);

        int itemCount = targetDeviceListCacheCombo.getItemCount();
        for (int i = 0; i < itemCount; i++) {
            if (targetDeviceListCacheCombo.getItem(i).equals(cache)) {
                targetDeviceListCacheCombo.select(i);
                break;
            }
        }

    } else if (mode.equals(DIALOG_SHOW_MODE_DEFAULT)) {
        alwaysButton.setSelection(false);
        defaultButton.setSelection(true);
        setImage.setEnabled(true);
        targetDeviceListCombo.setEnabled(true);
        try {
            getTargetDeviceList();
        } catch (Exception ex) {
            ex.printStackTrace();
        }
        String selectedTagetDevice = prefStore
                .getString(TestDropPreferenceConstants.TEST_DROP_SELECTED_TARGET_DEVICE);
        int itemCount = targetDeviceListCombo.getItemCount();
        boolean targetDeviceFound = false;
        for (int i = 0; i < itemCount; i++) {
            if (targetDeviceListCombo.getItem(i).equals(selectedTagetDevice)) {
                targetDeviceListCombo.select(i);
                targetDeviceFound = true;
                dialogModel.setSelectedMasterDeviceIndex(i);
                break;
            }
        }
        if (!targetDeviceFound) {
            targetDeviceListCombo.select(0);
            LogExceptionHandler.showErrorDialog(
                    Messages.getString("TestDropPreferences.cannotResolveSelectedTargetDeviceException"));
        }
        String imageList = prefStore
                .getString(TestDropPreferenceConstants.TEST_DROP_TARGET_DEVICE_FLASH_IMAGE_LIST);
        List<File> images = new ArrayList<File>();
        if (imageList.length() > 0) {
            while (imageList.indexOf(";") != -1) {
                String image = imageList.substring(0, imageList.indexOf(";"));
                imageList = imageList.substring(image.length() + 1);
                images.add(new File(image));
            }
            if (imageList.length() > 0) {
                images.add(new File(imageList));
            }
        }
        if (images.size() > 0) {
            dialogModel.getSelectedMasterDevice().setImages(images);
            StartUp.setDialogModel(dialogModel);
        }

    }

}

From source file:com.nokia.s60tools.testdrop.util.StartUp.java

License:Open Source License

/**
 * Checks validity in connection properties
 * //from ww  w.j  av a 2s  .  co m
 * @return true if connection property is valid otherwise false
 */
private static boolean isValidConnectionProperties() {
    IPreferenceStore prefStore = TestDropPlugin.getPrefStore();

    String host = prefStore.getString(TestDropPreferenceConstants.TEST_DROP_CONNECTION_HOST);
    int port = prefStore.getInt(TestDropPreferenceConstants.TEST_DROP_CONNECTION_PORT);
    if (port == 0) {
        return false;
    }

    String username = prefStore.getString(TestDropPreferenceConstants.TEST_DROP_CONNECTION_USERNAME);
    String password = prefStore.getString(TestDropPreferenceConstants.TEST_DROP_CONNECTION_PASSWORD);

    String method = null;
    Path dropPath = null;
    String path = prefStore.getString(TestDropPreferenceConstants.TEST_DROP_PATH);
    boolean importUsed = prefStore.getBoolean(TestDropPreferenceConstants.TEST_DROP_IMPORT);

    if (importUsed) {
        method = HttpConnection.POST_METHOD;
    } else {
        method = HttpConnection.GET_METHOD;
        dropPath = new Path(path);
    }
    if (host.length() == 0 || username.length() == 0) {
        return false;
    } else {
        connectionProperty = new ConnectionPropertyValue(host, port, username, password, null, method,
                dropPath);
        return true;
    }

}

From source file:com.nokia.s60tools.testdrop.util.StartUp.java

License:Open Source License

/**
 * Creates testResultProperty instance from preference store
 * //from   w ww .jav  a  2s.  c  o m
 * @return instance of the TestResultPropertyValue
 */
private static TestResultPropertyValue createTestResultPropertyValue() {
    IPreferenceStore prefStore = TestDropPlugin.getPrefStore();

    String resultPath = prefStore.getString(TestDropPreferenceConstants.TEST_DROP_TEST_RESULT_PATH);

    File file = null;
    if (resultPath.length() > 0) {
        file = new File(resultPath);
    }
    TestResultPropertyValue testResultPropertyValue = new TestResultPropertyValue(file);
    return testResultPropertyValue;
}

From source file:com.nokia.s60tools.testdrop.util.StartUp.java

License:Open Source License

/**
 * Starts target dialog//from   w ww  .j a  v  a2 s .  co m
 * 
 * @param action
 *            action
 * @param dialogModel
 *            model for constructs the dialog
 */
public static void startTargetDialog(IAction action, DialogModel dialogModel) {
    IPreferenceStore prefStore = TestDropPlugin.getPrefStore();

    String mode = prefStore.getString(TestDropPreferenceConstants.TEST_DROP_DIALOG_SHOW_MODE);

    if (mode.equals(TestDropPreferences.DIALOG_SHOW_MODE_ALWAYS)) {
        Shell sh = Display.getCurrent().getActiveShell();
        if (StartUp.dialogModel == null) {
            if (dialogModel == null) {
                StartUp.dialogModel = new DialogModel(null, null, -1);
            } else {
                StartUp.dialogModel = dialogModel;
            }
        }
        if (selectedProject != null) {
            StartUp.dialogModel.setSelectedProject(selectedProject);
        } else if (selectedCfgFiles != null) {
            StartUp.dialogModel.setSelectedCfgFiles(selectedCfgFiles);
        }

        dlgTarget = new TestDropTargetDialog(sh, TARGET_DIALOG_TITLE, StartUp.dialogModel, false, // not resizable
                DIALOG_WIDTH, DIALOG_HEIGHT);
        dlgTarget.create();
        dlgTarget.open();
    } else if (mode.equals(TestDropPreferences.DIALOG_SHOW_MODE_DEFAULT)) {
        String selectedDevice = prefStore
                .getString(TestDropPreferenceConstants.TEST_DROP_SELECTED_TARGET_DEVICE);
        if (!selectedDevice.contains("emulator")) {
            if (StartUp.dialogModel == null) { //hardware
                if (selectedDevice.length() == 0) {
                    LogExceptionHandler.showErrorDialog(Messages.getString("StartUp.SendingFailsException"));
                    return;
                }

                StartUp.dialogModel = new DialogModel(null, null, -1);
                if (selectedProject != null) {
                    StartUp.dialogModel.setSelectedProject(selectedProject);
                } else if (selectedCfgFiles != null) {
                    StartUp.dialogModel.setSelectedCfgFiles(selectedCfgFiles);
                }

                DialogContentFactory dialogContentFactory = new DialogContentFactory();
                try {
                    StartUp.dialogModel
                            .setTargetDeviceList(dialogContentFactory.getTargetDevices(StartUp.dialogModel, 0));

                    Iterator<TargetDeviceValue> iterator = StartUp.dialogModel.getTargetDeviceList().iterator();
                    List<String> tagets = new ArrayList<String>();
                    while (iterator.hasNext()) {
                        TargetDeviceValue targetDeviceValue = (TargetDeviceValue) iterator.next();

                        String hostname = dialogContentFactory
                                .makeHostPartForComboControl(targetDeviceValue.getProperties());
                        tagets.add(targetDeviceValue.getAlias() + hostname);
                    }
                    int count = tagets.size();
                    boolean found = false;
                    for (int i = 0; i < count; i++) {
                        if (tagets.get(i).equals(selectedDevice)) {
                            if (selectedDevice.indexOf(
                                    StartUp.dialogModel.getTargetDeviceList().get(i).getAlias()) != -1) {
                                StartUp.dialogModel.setSelectedMasterDeviceIndex(i);
                                StartUp.addImagesToDialogModel();
                                found = true;
                                break;
                            }
                        }
                    }
                    if (!found) {
                        StartUp.dialogModel = null;
                    } else {
                        StartUp.dialogModel.getSelectedMasterDevice().setRank(RANK_MASTER);
                    }

                } catch (Exception e) {
                    StartUp.dialogModel = null;
                    LogExceptionHandler.showErrorDialog(e.getMessage());
                    return;
                }
            }

            if (selectedProject != null) {
                StartUp.dialogModel.setSelectedProject(selectedProject);
            } else if (selectedCfgFiles != null) {
                StartUp.dialogModel.setSelectedCfgFiles(selectedCfgFiles);
            }

            TargetDeviceValue targetDeviceValue = StartUp.dialogModel.getSelectedMasterDevice();
            List<File> images = null;
            if (targetDeviceValue != null) {
                images = targetDeviceValue.getImages();
            }
            if (images != null && images.size() > 0) {
                sendTestDrop(images, true);
            } else {
                sendTestDrop(null, false);
            }
        } else {
            if (StartUp.dialogModel == null) { // emulator
                if (dialogModel == null) {
                    StartUp.dialogModel = new DialogModel(null, null, -1);
                } else {
                    StartUp.dialogModel = dialogModel;
                }
            }
            if (selectedProject != null) {
                StartUp.dialogModel.setSelectedProject(selectedProject);
            } else if (selectedCfgFiles != null) {
                StartUp.dialogModel.setSelectedCfgFiles(selectedCfgFiles);
            }
            runTestDrop();
        }
    } else {
        LogExceptionHandler.showErrorDialog(Messages.getString("StartUp.PreferencesNotSet"));
        return;
    }

}

From source file:com.nokia.s60tools.testdrop.util.StartUp.java

License:Open Source License

/**
 * Add images to target devices in DialogModel object
 * This is needed to be able to run TestDrop without visiting preferences page
 * and the target dialog/*from   w  ww  .j  a  va 2  s. co m*/
 */
private static void addImagesToDialogModel() {
    IPreferenceStore prefStore = TestDropPlugin.getPrefStore();
    String imageList = prefStore
            .getString(TestDropPreferenceConstants.TEST_DROP_TARGET_DEVICE_FLASH_IMAGE_LIST);
    List<File> images = new ArrayList<File>();
    if (imageList.length() > 0) {
        while (imageList.indexOf(";") != -1) {
            String image = imageList.substring(0, imageList.indexOf(";"));
            imageList = imageList.substring(image.length() + 1);
            images.add(new File(image));
        }
        if (imageList.length() > 0) {
            images.add(new File(imageList));
        }
    }
    if (images.size() > 0) {
        StartUp.dialogModel.getSelectedMasterDevice().setImages(images);
    }
}

From source file:com.nokia.s60tools.testdrop.util.StartUp.java

License:Open Source License

/**
 * Returns show mode of the test result view
 * //from w  w w  . ja va2  s  .  c o m
 * @return show mode of the test result view
 */
public static String getTestResultViewShowMode() {
    IPreferenceStore prefStore = TestDropPlugin.getPrefStore();

    return prefStore.getString(TestDropPreferenceConstants.TEST_DROP_SHOW_TEST_RESULT);

}

From source file:com.nokia.s60tools.testdrop.util.StartUp.java

License:Open Source License

/**
 * Resolves target dialog cache value//from  w w w. j  ava2 s.co  m
 * 
 * @return target dialog cache value
 */
public static int getTargetDialogCache() {
    IPreferenceStore prefStore = TestDropPlugin.getPrefStore();
    String cache = prefStore.getString(TestDropPreferenceConstants.TEST_DROP_TARGET_DEVICE_CACHE);
    int ret = -1;
    if (cache.equals(TestDropPreferences.TARGET_DEVICE_LIST_CACHE_NONE)) {
        ret = 0;
    } else {
        ret = Integer.valueOf(cache.substring(0, cache.indexOf(" ")));
    }
    return ret;
}