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

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

Introduction

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

Prototype

boolean getBoolean(String name);

Source Link

Document

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

Usage

From source file:com.clustercontrol.monitor.preference.MonitorPreferencePage.java

License:Open Source License

/**
 * ?????//from ww  w  .ja  va 2 s.  c  o  m
 */
private void applySetting() {
    IPreferenceStore store = this.getPreferenceStore();

    // ?????

    IWorkbench workbench = ClusterControlPlugin.getDefault().getWorkbench();
    IWorkbenchWindow[] windows = workbench.getWorkbenchWindows();

    int windowCount = windows.length;

    for (int i = 0; i < windowCount; i++) {
        IWorkbenchPage[] pages = windows[i].getPages();
        int pageCount = pages.length;

        for (int j = 0; j < pageCount; j++) {
            ScopeView scopeView = (ScopeView) pages[j].findView(ScopeView.ID);
            if (scopeView != null) {
                int cycle = store.getInt(P_SCOPE_UPDATE_CYCLE);
                scopeView.setInterval(cycle);
                if (store.getBoolean(P_SCOPE_UPDATE_FLG)) {
                    scopeView.startAutoReload();
                } else {
                    scopeView.stopAutoReload();
                }
            }

            StatusView statusView = (StatusView) pages[j].findView(StatusView.ID);
            if (statusView != null) {
                int cycle = store.getInt(P_STATUS_UPDATE_CYCLE);
                statusView.setInterval(cycle);
                if (store.getBoolean(P_STATUS_UPDATE_FLG)) {
                    statusView.startAutoReload();
                } else {
                    statusView.stopAutoReload();
                }
            }

            EventView eventView = (EventView) pages[j].findView(EventView.ID);
            if (eventView != null) {
                int cycle = store.getInt(P_EVENT_UPDATE_CYCLE);
                eventView.setInterval(cycle);
                if (store.getBoolean(P_EVENT_UPDATE_FLG)) {
                    eventView.startAutoReload();
                } else {
                    eventView.stopAutoReload();
                }
            }
        }
    }
}

From source file:com.clustercontrol.monitor.view.EventView.java

License:Open Source License

/**
 * ????//from ww w  .  j a  v a 2 s  .  c o  m
 * <p>
 * <ol>
 * <li>????</li>
 * <li>??????</li>
 * <li>???</li>
 * <li>??[]??????????</li>
 * <li>??[]??????????</li>
 * <li>???</li>
 * </ol>
 *
 * @param parent ??
 * @return ?
 *
 * @see com.clustercontrol.monitor.composite.EventListComposite#EventListComposite(Composite, int)
 * @see #createContextMenu()
 * @see #update()
 */
@Override
protected Composite createListContents(Composite parent) {
    GridLayout layout = new GridLayout(1, true);
    parent.setLayout(layout);
    layout.marginHeight = 0;
    layout.marginWidth = 0;

    this.tableComposite = new EventListComposite(parent, SWT.NONE);
    WidgetTestUtil.setTestId(this, null, tableComposite);
    GridData gridData = new GridData();
    gridData.horizontalAlignment = GridData.FILL;
    gridData.verticalAlignment = GridData.FILL;
    gridData.grabExcessHorizontalSpace = true;
    gridData.grabExcessVerticalSpace = true;
    this.tableComposite.setLayoutData(gridData);

    //??
    createContextMenu();

    // ??
    IPreferenceStore store = ClusterControlPlugin.getDefault().getPreferenceStore();

    this.setInterval(store.getInt(MonitorPreferencePage.P_EVENT_UPDATE_CYCLE));

    if (store.getBoolean(MonitorPreferencePage.P_EVENT_UPDATE_FLG)) {
        this.startAutoReload();
    }
    // ?
    this.tableComposite.getTableViewer().addSelectionChangedListener(new EventListSelectionChangedListener());

    return this.tableComposite;
}

From source file:com.clustercontrol.monitor.view.ScopeView.java

License:Open Source License

/**
 * ????//from  www.  ja v  a2 s .  com
 * <p>
 * <ol>
 * <li>????</li>
 * <li>???</li>
 * <li>??[]??????????</li>
 * <li>??[]??????????</li>
 * <li>???</li>
 * </ol>
 *
 * @param parent ??
 * @return ?
 *
 * @see com.clustercontrol.monitor.composite.ScopeListComposite#ScopeListComposite(Composite, int)
 * @see #update()
 */
@Override
protected Composite createListContents(Composite parent) {
    GridLayout layout = new GridLayout(1, true);
    parent.setLayout(layout);
    layout.marginHeight = 0;
    layout.marginWidth = 0;

    this.tableComposite = new ScopeListComposite(parent, SWT.NONE);
    WidgetTestUtil.setTestId(this, null, tableComposite);
    GridData gridData = new GridData();
    gridData.horizontalAlignment = GridData.FILL;
    gridData.verticalAlignment = GridData.FILL;
    gridData.grabExcessHorizontalSpace = true;
    gridData.grabExcessVerticalSpace = true;
    this.tableComposite.setLayoutData(gridData);

    this.update(false);

    // ??
    IPreferenceStore store = ClusterControlPlugin.getDefault().getPreferenceStore();

    this.setInterval(store.getInt(MonitorPreferencePage.P_SCOPE_UPDATE_CYCLE));

    if (store.getBoolean(MonitorPreferencePage.P_SCOPE_UPDATE_FLG)) {
        this.startAutoReload();
    }

    return this.tableComposite;
}

From source file:com.clustercontrol.monitor.view.StatusView.java

License:Open Source License

/**
 * ????//  w ww  . j ava  2s  .  c o  m
 * <p>
 * <ol>
 * <li>????</li>
 * <li>??????</li>
 * <li>???</li>
 * <li>??[]??????????</li>
 * <li>??[]??????????</li>
 * <li>???</li>
 * </ol>
 *
 * @param parent ??
 * @return ?
 *
 * @see com.clustercontrol.monitor.composite.StatusListComposite#StatusListComposite(Composite, int)
 * @see #createContextMenu()
 * @see #update()
 */
@Override
protected Composite createListContents(Composite parent) {
    GridLayout layout = new GridLayout(1, true);
    parent.setLayout(layout);
    layout.marginHeight = 0;
    layout.marginWidth = 0;

    this.tableComposite = new StatusListComposite(parent, SWT.NONE);
    WidgetTestUtil.setTestId(this, null, tableComposite);
    GridData gridData = new GridData();
    gridData.horizontalAlignment = GridData.FILL;
    gridData.verticalAlignment = GridData.FILL;
    gridData.grabExcessHorizontalSpace = true;
    gridData.grabExcessVerticalSpace = true;
    this.tableComposite.setLayoutData(gridData);

    //??
    createContextMenu();

    // ??
    IPreferenceStore store = ClusterControlPlugin.getDefault().getPreferenceStore();

    this.setInterval(store.getInt(MonitorPreferencePage.P_STATUS_UPDATE_CYCLE));

    if (store.getBoolean(MonitorPreferencePage.P_STATUS_UPDATE_FLG)) {
        this.startAutoReload();
    }

    // ?
    this.tableComposite.getTableViewer().addSelectionChangedListener(new StatusListSelectionChangedListener());

    return this.tableComposite;
}

From source file:com.clustercontrol.util.LoginManager.java

License:Open Source License

public static void setup() {
    IPreferenceStore store = ClusterControlPlugin.getDefault().getPreferenceStore();

    // Timeout (ms)
    int httpRequestTimeout = store.getInt(KEY_HTTP_REQUEST_TIMEOUT);
    EndpointManager.setHttpRequestTimeout(httpRequestTimeout);
    m_log.info("request.timeout=" + httpRequestTimeout);

    // Proxy/*from  w w w .  ja v a  2 s  .  com*/
    if (store.getBoolean(KEY_PROXY_ENABLE) == true) {
        String proxyHost = store.getString(KEY_PROXY_HOST);
        int proxyPort = store.getInt(KEY_PROXY_PORT);
        String proxyUser = store.getString(KEY_PROXY_USER);
        String proxyPass = store.getString(KEY_PROXY_PASSWORD);
        EndpointManager.setProxy(proxyHost, proxyPort);
        EndpointManager.setAuthenticator(proxyUser, proxyPass);
    } else {
        EndpointManager.setProxy(null, 0);
        EndpointManager.setAuthenticator(null, null);
    }
}

From source file:com.dnw.depmap.Activator.java

License:Open Source License

/**
 * Loads preference settings from preference store.
 * //  w  w w. j  a v a2  s.co m
 * @author manbaum
 * @since Oct 24, 2014
 */
private void loadPreference() {
    // loads Neo4j database settings.
    IPreferenceStore store = super.getPreferenceStore();
    if (store.getBoolean(PrefKeys.P_USESTANDALONE)) {
        useEmbedded = false;
        DBURL = store.getString(PrefKeys.P_DBURL);
    } else if (store.getBoolean(PrefKeys.P_USEEMBEDDED)) {
        useEmbedded = true;
        DBPATH = store.getString(PrefKeys.P_DBDIR);
    } else {
        useEmbedded = false;
        DBURL = "http://localhost:7474/db/data";
        store.setValue(PrefKeys.P_USESTANDALONE, true);
        store.setValue(PrefKeys.P_DBURL, DBURL);
    }

    // loads class/package filter settings.
    filter.clearAllows();
    filter.clearBlocks();
    filter.setPreferWhite(store.getBoolean(PrefKeys.P_PREFERWHITE));
    String white = store.getString(PrefKeys.P_WHITELIST);
    if (white != null) {
        String[] list = white.split("\\s*\\n\\s*");
        for (String s : list) {
            s = s.trim();
            if (!s.isEmpty() && !s.startsWith("#")) {
                console.println("allow: \"" + s + "\"");
                if (s.startsWith("@"))
                    filter.addAllowMatcher(new StringMatcher(s.substring(1)));
                else
                    filter.addAllowMatcher(new RegexMatcher(s));
            }
        }
    }
    String black = store.getString(PrefKeys.P_BLACKLIST);
    if (black != null) {
        String[] list = black.split("\\s*\\n\\s*");
        for (String s : list) {
            s = s.trim();
            if (!s.isEmpty() && !s.startsWith("#")) {
                console.println("block: \"" + s + "\"");
                if (s.startsWith("@"))
                    filter.addBlockMatcher(new StringMatcher(s.substring(1)));
                else
                    filter.addBlockMatcher(new RegexMatcher(s));
            }
        }
    }

    // loads pre-executing Cypher statements setting.
    preExec = store.getBoolean(PrefKeys.P_USEPREEXEC);
    statements.clear();
    if (preExec) {
        String ss = store.getString(PrefKeys.P_PREEXEC);
        if (ss != null) {
            String[] array = ss.split("\\s*\\n\\s*");
            for (String s : array) {
                s = s.trim();
                if (!s.isEmpty() && !s.startsWith("#")) {
                    console.println("statement: \"" + s + "\"");
                    statements.add(s);
                }
            }
        } else {
            preExec = false;
        }
    }

    // re-creates something according to the new settings.
    accessor = useEmbedded ? new EmbeddedNeoAccessor(DBPATH) : new RestfulNeoAccessor(DBURL);
    neo = new NeoDao(new NeoWriter(accessor), filter);
}

From source file:com.drgarbage.asm.render.impl.AbstractClassFileDocument.java

License:Apache License

public AbstractClassFileDocument() {
    super(com.drgarbage.asm.Opcodes.ASM4);

    /* initialize preferences */
    if (BytecodeVisualizerPlugin.getDefault() != null) {
        /* jUnit tests work only if we test for null here */
        IPreferenceStore store = BytecodeVisualizerPlugin.getDefault().getPreferenceStore();
        showConstantPool = store.getBoolean(CLASS_FILE_ATTR_SHOW_CONSTANT_POOL);
        showLineNumberTable = store.getBoolean(CLASS_FILE_ATTR_SHOW_LINE_NUMBER_TABLE);
        showSourceLineNumbers = store.getBoolean(CLASS_FILE_ATTR_SHOW_SOURCE_LINE_NUMBERS);
        showLocalVariableTable = store.getBoolean(CLASS_FILE_ATTR_SHOW_VARIABLE_TABLE);
        showExceptionTable = store.getBoolean(CLASS_FILE_ATTR_SHOW_EXCEPTION_TABLE);
        showMaxs = store.getBoolean(CLASS_FILE_ATTR_SHOW_MAXS);
        renderTryCatchFinallyBlocks = store.getBoolean(CLASS_FILE_ATTR_RENDER_TRYCATCH_BLOCKS);

        if (BRANCH_TARGET_ADDRESS_ABSOLUTE.equals(store.getString(BRANCH_TARGET_ADDRESS_RENDERING))) {
            showRelativeBranchTargetOffsets = false;
        }//from  w  w w.  j av a2s.  c om
    }

}

From source file:com.drgarbage.visualgraphic.editparts.VertexBaseEditPart.java

License:Apache License

/**
 * Return a IFigure depending on the instance of the current model element.
 * This allows this EditPart to be used for all sublasses of VertexBase. 
 *///from  w  ww  .  j av  a  2  s . c  o m
protected IFigure createFigure() {

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

    boolean useGradientFillColor = store
            .getBoolean(ControlFlowFactoryPreferenceConstants.USE_GRADIENT_FILL_COLOR);

    Object o = getModel();

    if (o instanceof DecisionVertex) {
        return VertexBaseFigureFactory.createDecisionVertex((DecisionVertex) o, useGradientFillColor);
    } else if (o instanceof GetVertex) {
        return VertexBaseFigureFactory.createGetVertex((GetVertex) o, useGradientFillColor);
    } else if (o instanceof GotoJumpVertex) {
        return VertexBaseFigureFactory.createGotoJumpVertex((GotoJumpVertex) o, useGradientFillColor);
    } else if (o instanceof InvokeVertex) {
        return VertexBaseFigureFactory.createInvokeVertex((InvokeVertex) o, useGradientFillColor);
    } else if (o instanceof BasicBlockVertex) {
        return VertexBaseFigureFactory.createBasicBlockVertex((BasicBlockVertex) o, useGradientFillColor);
    } else if (o instanceof RectangularVertex) {
        return VertexBaseFigureFactory.createRectangularVertex((RectangularVertex) o, useGradientFillColor);
    } else if (o instanceof ReturnVertex) {
        return VertexBaseFigureFactory.createReturnVertex((ReturnVertex) o, useGradientFillColor);
    } else if (o instanceof StartVertex) {
        return VertexBaseFigureFactory.createStartVertex((StartVertex) o, useGradientFillColor);
    } else if (o instanceof ExitVertex) {
        return VertexBaseFigureFactory.createExitVertex((ExitVertex) o, useGradientFillColor);
    } else if (o instanceof SwitchVertex) {
        return VertexBaseFigureFactory.createSwitchVertex((SwitchVertex) o, useGradientFillColor);
    } else if (o instanceof CommentElement) {
        return VertexBaseFigureFactory.createComment((CommentElement) o, useGradientFillColor);
    } else {
        // if figure gets extended the conditions above must be updated
        throw new IllegalArgumentException();
    }
}

From source file:com.drgarbage.visualgraphic.model.ControlFlowGraphDiagramFactory.java

License:Apache License

/**
 * Build bytecode graph diagram./*  w  w  w.j a  va2  s  .  c  o  m*/
 * 
 * @param instruction
 *            list
 * @throws IOException
 * @throws ControlFlowGraphException
 */
public static ControlFlowGraphDiagram buildByteCodeControlFlowDiagram(List<AbstractInstruction> instructions)
        throws ControlFlowGraphException, IOException {
    /* get preferences */
    IPreferenceStore store = ControlFlowFactoryPlugin.getDefault().getPreferenceStore();
    boolean createStartNode = store.getBoolean(ControlFlowFactoryPreferenceConstants.GENERATE_START_NODE);
    boolean createExitNode = store.getBoolean(ControlFlowFactoryPreferenceConstants.GENERATE_EXIT_NODE);
    boolean createBackEdge = store.getBoolean(ControlFlowFactoryPreferenceConstants.GENERATE_BACK_EDGE);

    IDirectedGraphExt graph = ControlFlowGraphGenerator.generateControlFlowGraph(instructions, null,
            createStartNode, createExitNode, createBackEdge);
    return createControlFlowDiagram(graph);
}

From source file:com.drgarbage.visualgraphic.model.ControlFlowGraphDiagramFactory.java

License:Apache License

/**
 * Build bytecode graph diagram.// w  ww  .j  av a  2 s .  com
 * 
 * @param classPath
 *            , the class path
 * @param packageName
 *            , the name of the package
 * @param className
 *            , the name of the class
 * @param methodName
 *            , the name of the method
 * @param methodSig
 *            , the method signature
 * @throws ControlFlowGraphException
 *             , IOException, InvalidByteCodeException
 */
public static ControlFlowGraphDiagram buildByteCodeControlFlowDiagram(String[] classPath, String packageName,
        String className, String methodName, String methodSig) throws ControlFlowGraphException, IOException {
    /* get preferences */
    IPreferenceStore store = ControlFlowFactoryPlugin.getDefault().getPreferenceStore();
    boolean createStartNode = store.getBoolean(ControlFlowFactoryPreferenceConstants.GENERATE_START_NODE);
    boolean createExitNode = store.getBoolean(ControlFlowFactoryPreferenceConstants.GENERATE_EXIT_NODE);
    boolean createBackEdge = store.getBoolean(ControlFlowFactoryPreferenceConstants.GENERATE_BACK_EDGE);

    IDirectedGraphExt graph = ControlFlowGraphGenerator.generateControlFlowGraph(classPath, packageName,
            className, methodName, methodSig, createStartNode, createExitNode, createBackEdge);
    Map<String, Object> attr = graph.getUserObject();
    attr.put(ByteCodeConstants.NAME, className + "." + methodName + methodSig);
    return createControlFlowDiagram(graph);
}