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

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

Introduction

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

Prototype

boolean isDefault(String name);

Source Link

Document

Returns whether the current value of the preference with the given name has the default value.

Usage

From source file:org.eclipse.andmore.android.db.devices.model.DeviceDbNode.java

License:Apache License

/**
 * @return/*from w ww  .  j ava  2 s .c o  m*/
 * @throws IOException
 */
private File getLocalTempFile() throws IOException {
    IPreferenceStore preferenceStore = DbDevicesPlugin.getDefault().getPreferenceStore();
    File tempLocationFile = null;

    if (!preferenceStore.isDefault(DbDevicesPlugin.DB_TEMP_PATH_PREFERENCE)) {
        String tempLocation = preferenceStore.getString(DbDevicesPlugin.DB_TEMP_PATH_PREFERENCE);
        tempLocationFile = new File(tempLocation);

        if (!tempLocationFile.isDirectory() || !FileUtil.canWrite(tempLocationFile)) {
            EclipseUtils.showErrorDialog(DbDevicesNLS.ERR_DbUtils_Local_Db_Title,
                    NLS.bind(DbDevicesNLS.ERR_DbUtils_Local_Db_Msg, tempLocation));
            preferenceStore.setToDefault(DbDevicesPlugin.DB_TEMP_PATH_PREFERENCE);
        }

    }

    // If tempLocationFile is null the file will be created on system's
    // default temp dir.
    File tempFile = File.createTempFile(serialNumber + "_" + remoteDbPath.segment(1) + "_" + getName(), //$NON-NLS-1$ //$NON-NLS-2$
            "db", tempLocationFile); //$NON-NLS-1$
    tempFile.deleteOnExit();
    return tempFile;
}

From source file:org.eclipse.birt.report.designer.internal.ui.util.UIUtil.java

License:Open Source License

public static Color createColor(IPreferenceStore store, String key, Display display) {
    RGB rgb = null;// w ww . j a  v  a2  s  . c o  m
    if (store.contains(key)) {
        if (store.isDefault(key)) {
            rgb = PreferenceConverter.getDefaultColor(store, key);
        } else {
            rgb = PreferenceConverter.getColor(store, key);
        }
        if (rgb != null) {
            return new Color(display, rgb);
        }
    }
    return null;
}

From source file:org.eclipse.birt.report.designer.ui.preferences.OverlayPreferenceStore.java

License:Open Source License

private void propagateProperty(IPreferences orgin, OverlayKey key, IPreferenceStore target) {

    if (orgin.isDefault(key.fKey)) {
        if (!target.isDefault(key.fKey))
            target.setToDefault(key.fKey);
        return;/*from   w  ww .j  av a2 s . c o m*/
    }

    TypeDescriptor d = key.fDescriptor;
    if (BOOLEAN == d) {

        boolean originValue = orgin.getBoolean(key.fKey);
        boolean targetValue = target.getBoolean(key.fKey);
        if (targetValue != originValue)
            target.setValue(key.fKey, originValue);

    } else if (DOUBLE == d) {

        double originValue = orgin.getDouble(key.fKey);
        double targetValue = target.getDouble(key.fKey);
        if (targetValue != originValue)
            target.setValue(key.fKey, originValue);

    } else if (FLOAT == d) {

        float originValue = orgin.getFloat(key.fKey);
        float targetValue = target.getFloat(key.fKey);
        if (targetValue != originValue)
            target.setValue(key.fKey, originValue);

    } else if (INT == d) {

        int originValue = orgin.getInt(key.fKey);
        int targetValue = target.getInt(key.fKey);
        if (targetValue != originValue)
            target.setValue(key.fKey, originValue);

    } else if (LONG == d) {

        long originValue = orgin.getLong(key.fKey);
        long targetValue = target.getLong(key.fKey);
        if (targetValue != originValue)
            target.setValue(key.fKey, originValue);

    } else if (STRING == d) {

        String originValue = orgin.getString(key.fKey);
        String targetValue = target.getString(key.fKey);
        if (targetValue != null && originValue != null && !targetValue.equals(originValue))
            target.setValue(key.fKey, originValue);

    }
}

From source file:org.eclipse.birt.report.designer.ui.preferences.OverlayPreferenceStore.java

License:Open Source License

private void propagateProperty(IPreferenceStore orgin, OverlayKey key, IPreferences target) {

    if (orgin.isDefault(key.fKey)) {
        if (!target.isDefault(key.fKey))
            target.setToDefault(key.fKey);
        return;//from  w w  w . ja  va  2 s  . c  om
    }

    TypeDescriptor d = key.fDescriptor;
    if (BOOLEAN == d) {

        boolean originValue = orgin.getBoolean(key.fKey);
        boolean targetValue = target.getBoolean(key.fKey);
        if (targetValue != originValue)
            target.setValue(key.fKey, originValue);

    } else if (DOUBLE == d) {

        double originValue = orgin.getDouble(key.fKey);
        double targetValue = target.getDouble(key.fKey);
        if (targetValue != originValue)
            target.setValue(key.fKey, originValue);

    } else if (FLOAT == d) {

        float originValue = orgin.getFloat(key.fKey);
        float targetValue = target.getFloat(key.fKey);
        if (targetValue != originValue)
            target.setValue(key.fKey, originValue);

    } else if (INT == d) {

        int originValue = orgin.getInt(key.fKey);
        int targetValue = target.getInt(key.fKey);
        if (targetValue != originValue)
            target.setValue(key.fKey, originValue);

    } else if (LONG == d) {

        long originValue = orgin.getLong(key.fKey);
        long targetValue = target.getLong(key.fKey);
        if (targetValue != originValue)
            target.setValue(key.fKey, originValue);

    } else if (STRING == d) {

        String originValue = orgin.getString(key.fKey);
        String targetValue = target.getString(key.fKey);
        if (targetValue != null && originValue != null && !targetValue.equals(originValue))
            target.setValue(key.fKey, originValue);

    }
}

From source file:org.eclipse.cdt.codan.internal.ui.widgets.LaunchingTabComposite.java

License:Open Source License

/**
 * @param launchPref2/*from  w  w w  .ja v a  2 s  .co m*/
 * @param preferenceStore
 */
private void saveToPref(LaunchModeProblemPreference launchPref, IPreferenceStore preferenceStore) {
    CheckerLaunchMode[] values = CheckerLaunchMode.values();
    for (int i = 0; i < values.length; i++) {
        CheckerLaunchMode checkerLaunchMode = values[i];
        String name = checkerLaunchMode.name();
        if (!preferenceStore.isDefault(name)) {
            boolean value = preferenceStore.getBoolean(name);
            launchPref.setRunningMode(checkerLaunchMode, value);
        }
    }
}

From source file:org.eclipse.cdt.dsf.debug.internal.ui.disassembly.DisassemblyPart.java

License:Open Source License

/**
 * Initializes the given address ruler column from the preference store.
 *
 * @param rulerColumn the ruler column to be initialized
 *//*w w  w.  j av  a2  s.co  m*/
protected void initializeRulerColumn(DisassemblyRulerColumn rulerColumn, String colorPrefKey) {
    ISharedTextColors sharedColors = getSharedColors();
    IPreferenceStore store = getPreferenceStore();
    if (store != null) {

        RGB rgb = null;
        // foreground color
        if (store.contains(colorPrefKey)) {
            if (store.isDefault(colorPrefKey))
                rgb = PreferenceConverter.getDefaultColor(store, colorPrefKey);
            else
                rgb = PreferenceConverter.getColor(store, colorPrefKey);
        }
        if (rgb == null)
            rgb = new RGB(0, 0, 0);
        rulerColumn.setForeground(sharedColors.getColor(rgb));

        rgb = null;

        rulerColumn.redraw();
    }
}

From source file:org.eclipse.cdt.internal.autotools.ui.preferences.OverlayPreferenceStore.java

License:Open Source License

void propagateProperty(IPreferenceStore orgin, OverlayKey key, IPreferenceStore target) {

    if (orgin.isDefault(key.fKey)) {
        if (!target.isDefault(key.fKey))
            target.setToDefault(key.fKey);
        return;//from w  w  w.jav  a  2s . co  m
    }

    TypeDescriptor d = key.fDescriptor;
    if (BOOLEAN == d) {

        boolean originValue = orgin.getBoolean(key.fKey);
        boolean targetValue = target.getBoolean(key.fKey);
        if (targetValue != originValue)
            target.setValue(key.fKey, originValue);

    } else if (DOUBLE == d) {

        double originValue = orgin.getDouble(key.fKey);
        double targetValue = target.getDouble(key.fKey);
        if (targetValue != originValue)
            target.setValue(key.fKey, originValue);

    } else if (FLOAT == d) {

        float originValue = orgin.getFloat(key.fKey);
        float targetValue = target.getFloat(key.fKey);
        if (targetValue != originValue)
            target.setValue(key.fKey, originValue);

    } else if (INT == d) {

        int originValue = orgin.getInt(key.fKey);
        int targetValue = target.getInt(key.fKey);
        if (targetValue != originValue)
            target.setValue(key.fKey, originValue);

    } else if (LONG == d) {

        long originValue = orgin.getLong(key.fKey);
        long targetValue = target.getLong(key.fKey);
        if (targetValue != originValue)
            target.setValue(key.fKey, originValue);

    } else if (STRING == d) {

        String originValue = orgin.getString(key.fKey);
        String targetValue = target.getString(key.fKey);
        if (targetValue != null && originValue != null && !targetValue.equals(originValue))
            target.setValue(key.fKey, originValue);

    }
}

From source file:org.eclipse.cdt.internal.ui.compare.AbstractMergeViewer.java

License:Open Source License

/**
 * Creates a color from the information stored in the given preference store.
 * Returns <code>null</code> if there is no such information available.
 *///from  www. j  a  v  a 2  s.  c o  m
protected static RGB createColor(IPreferenceStore store, String key) {
    if (!store.contains(key))
        return null;
    if (store.isDefault(key))
        return PreferenceConverter.getDefaultColor(store, key);
    return PreferenceConverter.getColor(store, key);
}

From source file:org.eclipse.cdt.internal.ui.editor.CSourceViewer.java

License:Open Source License

/**
 * Creates a color from the information stored in the given preference store.
 * Returns <code>null</code> if there is no such information available.
 *
 * @param store the store to read from/*from   ww  w.  j ava 2s  .  c o m*/
 * @param key the key used for the lookup in the preference store
 * @param display the display used create the color
 * @return the created color according to the specification in the preference store
 */
private Color createColor(IPreferenceStore store, String key, Display display) {
    RGB rgb = null;

    if (store.contains(key)) {
        if (store.isDefault(key)) {
            rgb = PreferenceConverter.getDefaultColor(store, key);
        } else {
            rgb = PreferenceConverter.getColor(store, key);
        }

        if (rgb != null)
            return new Color(display, rgb);
    }

    return null;
}

From source file:org.eclipse.compare.internal.MergeSourceViewer.java

License:Open Source License

private RGB getColorFromStore(IPreferenceStore store, String key) {
    RGB rgb = null;/*w  ww.j  a  v a2  s. c  om*/
    if (store.contains(key)) {
        if (store.isDefault(key))
            rgb = PreferenceConverter.getDefaultColor(store, key);
        else
            rgb = PreferenceConverter.getColor(store, key);
    }
    return rgb;
}