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.rohanclan.afae.editor.AfaeEditor.java

License:Open Source License

/**
 * Turns on the word wrap if they have the preference set (mostly used when
 * opening a new document or changing the setting
 *//* w w w.  j av  a  2 s . co m*/
private void setWordWrap() {
    IPreferenceStore store = AfaePlugin.getDefault().getPreferenceStore();
    StyledText st = this.sourceViewer().getTextWidget();
    boolean textmode_on = store.getBoolean(P_USE_WORD_WRAP);
    st.setWordWrap(textmode_on);
}

From source file:com.rohanclan.afae.editor.AfaeSourceViewerConfiguration.java

License:Open Source License

/**
 * Loops over all the text styles FUNCTION, LABEL1, etc, and sets the
 * bold, italic, underline, strike, and highlighting background color.
 */// w  ww  .j  a  va 2 s.  c  o  m
public void refreshAllStyles() {
    String[] alltypes = IPreferenceConstants.ALL_TEXT_COLORS;

    boolean bold = false;
    boolean italic = false;
    boolean underline = false;
    boolean strike = false;
    String bgcolor = "";
    String colorName = "";
    Color newbgcolor = null;
    RGB rgb = null;

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

    for (byte z = 0; z < alltypes.length; z++) {
        //get the current base color name
        colorName = alltypes[z];
        //get the tokens
        Token token = (Token) tokenMap.get(colorName);
        LToken lToken = (LToken) tokenMap.get(colorName + MARK_SUFFIX);

        bold = store.getBoolean(colorName + IPreferenceConstants.BOLD_SUFFIX);
        italic = store.getBoolean(colorName + IPreferenceConstants.ITALIC_SUFFIX);
        underline = store.getBoolean(colorName + IPreferenceConstants.UNDERLINE_SUFFIX);
        strike = store.getBoolean(colorName + IPreferenceConstants.STRIKE_SUFFIX);
        bgcolor = store.getString(colorName + IPreferenceConstants.BACKGROUND_COLOR_SUFFIX);

        //System.err.println("All Types: " + colorName + " ( "+bgcolor+" ) " + bold + " " + italic +  " " + underline + " " + strike);

        Object data = token.getData();
        if (data instanceof TextAttribute) {
            int new_style = SWT.NORMAL;

            if (!"null".equals(bgcolor) && !"".equals(bgcolor)) {
                try {
                    rgb = StringConverter.asRGB(bgcolor);
                    newbgcolor = AfaePlugin.getDefault().getColorManager().newColor(rgb);
                } catch (org.eclipse.jface.resource.DataFormatException dfe) {
                    //we tried and the color was bunk.
                    System.err.println("Bunk background color: " + bgcolor + " for " + colorName);
                    dfe.printStackTrace();
                }
            } else {
                newbgcolor = null;
            }

            new_style = flipBit(new_style, SWT.BOLD, bold);
            new_style = flipBit(new_style, SWT.ITALIC, italic);
            new_style = flipBit(new_style, TextAttribute.UNDERLINE, underline);
            new_style = flipBit(new_style, TextAttribute.STRIKETHROUGH, strike);

            //the original color of the text doesn't seem to have a problem saving
            //so just reuse that
            TextAttribute newAttr = new TextAttribute(((TextAttribute) data).getForeground(), newbgcolor,
                    new_style);

            if (token != null)
                token.setData(newAttr);
            if (lToken != null)
                lToken.setData(newAttr);
        }
    }
}

From source file:com.sabre.tn.redapp.example.workflow.xtpointservices.BeforeShopHandler.java

License:Open Source License

/**
 * {@inheritDoc}// w w  w.  j  a v  a  2 s . c om
 */
@Override
public FlowExtPointCommand execute(FlowExtPointCommand extPointCommand) {
    IPreferenceStore st = Activator.getDefault().getPreferenceStore();

    boolean shouldListenBeforeShop = st.getBoolean(PreferenceConstants.P_BEF_SHOP_FLOW_EXT);

    if (shouldListenBeforeShop) {

        Optional<FlowExtPointRequestWrapper> rqWrapper = fetchRequestWrapper(extPointCommand,
                RedAppAirShoppingRq.class);

        if (rqWrapper.isPresent()) {
            RedAppAirShoppingRq airShoppingRq = (RedAppAirShoppingRq) rqWrapper.get().getRequest();

            String destFilter = st.getString(PreferenceConstants.P_DESTFILTER_SHOP_FLOW_EXT);
            String airlineFilter = st.getString(PreferenceConstants.P_AIRLINEFILTER_SHOP_FLOW_EXT);

            for (RedAppOriginDestinationInfo odInfo : airShoppingRq.getOriginDestinationInfo()) {
                if (odInfo.getDestination().equalsIgnoreCase(destFilter)) {
                    airShoppingRq.getAdvancedOptions().getPreferredCarriers().clear();
                    airShoppingRq.getAdvancedOptions().getPreferredCarriers()
                            .add(airlineFilter.isEmpty() ? "" : airlineFilter);
                    rqWrapper.get().setOperation(FlowExtPointDataOperation.MODIFY);
                    break;
                }
            }
        }

    }
    //extPointCommand.setFlowControlAction(FlowExtControlAction.CANCEL);
    return extPointCommand;
}

From source file:com.sabre.tn.redapp.example.workflow.xtpointservices.BeforeShopManualHandler.java

License:Open Source License

@Override
public FlowExtPointCommand execute(FlowExtPointCommand extPointCommand) {

    IPreferenceStore st = Activator.getDefault().getPreferenceStore();

    boolean shouldListenBeforeShop = st.getBoolean(PreferenceConstants.P_BEF_SHOP_FLOW_EXT);

    if (shouldListenBeforeShop) {

        ManualExtensionPointEventData dtaToSend = new ManualExtensionPointEventData();
        dtaToSend.setEventId("BeforeShoppingManual");
        FlowExtPointResponse rsFlow = new FlowExtPointResponse();
        rsFlow.setStructure(dtaToSend);//  w  w  w . j  a v a  2s.co m

        FlowExtPointResponseWrapper rsWrapper = new FlowExtPointResponseWrapper();
        rsWrapper.setOperation(FlowExtPointDataOperation.ADD);
        rsWrapper.setResponse(rsFlow);

        extPointCommand.getResponses().add(rsWrapper);
    }

    /*        Airline airline = new Airline();
            airline.setIataCode("");
                    
            boolean bypassManual = false;
                    
            Optional <RedAppAirShoppingRq> airShoppingRqOptional =
    fetchRequest(extPointCommand, RedAppAirShoppingRq.class);
            
            if (airShoppingRqOptional.isPresent())
            {
    List <String> airlinesList =
        airShoppingRqOptional.get().getAdvancedOptions().getPreferredCarriers();
               for (RedAppOriginDestinationInfo odInfo : airShoppingRqOptional.get().getOriginDestinationInfo()) {
      if(odInfo.getDestination().equalsIgnoreCase("LAS") || odInfo.getDestination().equalsIgnoreCase("NYC")){
         bypassManual = true;
      }
             };
    if (!airlinesList.isEmpty())
    {
        airline.setIataCode(airlinesList.get(0));
    }
            }
            
            if(!bypassManual){
               FlowExtPointResponse response = new FlowExtPointResponse();
               response.setStructure(airline);
               
               FlowExtPointResponseWrapper responseWrapper = new FlowExtPointResponseWrapper();
               responseWrapper.setOperation(FlowExtPointDataOperation.ADD);
               responseWrapper.setResponse(response);
               extPointCommand.getResponses().add(responseWrapper);
            }else{
               FlowExtPointError err = new FlowExtPointError();
               err.setCode("FLOW_EXT_POINT_ERROR");
               FlowExtPointCommandUtils.addError(extPointCommand, err); 
           }*/
    return extPointCommand;
}

From source file:com.safi.server.manager.SafiServerRemoteManager.java

public boolean notificationPreferencesChanged() {
    IPreferenceStore store = AsteriskDiagramEditorPlugin.getInstance().getPreferenceStore();
    observeError = store.getBoolean(PreferenceConstants.PREF_SERVER_ERROR_NOTIFICATION);
    observerInfo = store.getBoolean(PreferenceConstants.PREF_SERVER_INFO_NOTIFICATION);
    return true;/*from   w w  w. j  a v  a2s. c o  m*/
}

From source file:com.safi.workshop.sheet.SafiJavaScriptEditor.java

License:Open Source License

@Override
public void createPartControl(Composite parent) {
    super.createPartControl(parent);

    IPreferenceStore preferenceStore = getPreferenceStore();
    boolean closeBrackets = preferenceStore.getBoolean(CLOSE_BRACKETS);
    boolean closeStrings = preferenceStore.getBoolean(CLOSE_STRINGS);
    boolean closeAngularBrackets = false;

    fBracketInserter.setCloseBracketsEnabled(closeBrackets);
    fBracketInserter.setCloseStringsEnabled(closeStrings);
    fBracketInserter.setCloseAngularBracketsEnabled(closeAngularBrackets);

    ISourceViewer sourceViewer = getSourceViewer();
    if (sourceViewer instanceof ITextViewerExtension) {
        ((ITextViewerExtension) sourceViewer).prependVerifyKeyListener(fBracketInserter);
        // sourceViewer.setUndoManager(new TextViewerUndoManager(30));
    }//  ww  w . java2 s.  c  o  m
    // if (isMarkingOccurrences())
    // installOccurrencesFinder(false);
}

From source file:com.safi.workshop.sqlexplorer.dialogs.PasswordConnDlg.java

License:Open Source License

@Override
protected Control createDialogArea(Composite parent) {
    // top level composite
    Composite parentComposite = (Composite) super.createDialogArea(parent);

    // create a composite with standard margins and spacing
    Composite composite = new Composite(parentComposite, SWT.NONE);
    GridLayout layout = new GridLayout();
    layout.marginHeight = convertVerticalDLUsToPixels(IDialogConstants.VERTICAL_MARGIN);
    layout.marginWidth = convertHorizontalDLUsToPixels(IDialogConstants.HORIZONTAL_MARGIN);
    layout.verticalSpacing = convertVerticalDLUsToPixels(IDialogConstants.VERTICAL_SPACING);
    layout.horizontalSpacing = convertHorizontalDLUsToPixels(IDialogConstants.HORIZONTAL_SPACING);
    composite.setLayout(layout);/*from  ww  w .  ja  v  a  2 s.  co m*/
    composite.setLayoutData(new GridData(GridData.FILL_BOTH));
    composite.setFont(parentComposite.getFont());

    Composite nameGroup = new Composite(composite, SWT.NONE);
    layout = new GridLayout();
    layout.numColumns = 2;
    layout.marginWidth = 10;
    nameGroup.setLayout(layout);
    GridData data = new GridData(GridData.HORIZONTAL_ALIGN_FILL | GridData.GRAB_HORIZONTAL);
    nameGroup.setLayoutData(data);

    Label label = new Label(nameGroup, SWT.WRAP);
    label.setText(Messages.getString("Alias_1")); //$NON-NLS-1$
    Label aliasTxt = new Label(nameGroup, SWT.WRAP);
    aliasTxt.setText(alias.getName());
    Label label2 = new Label(nameGroup, SWT.WRAP);
    label2.setText(Messages.getString("Driver_2")); //$NON-NLS-1$
    Label driverTxt = new Label(nameGroup, SWT.WRAP);
    driverTxt.setText(alias.getDriver().getId());
    Label label3 = new Label(nameGroup, SWT.WRAP);
    label3.setText(Messages.getString("Url_3")); //$NON-NLS-1$
    Label urlTxt = new Label(nameGroup, SWT.WRAP);
    urlTxt.setText(alias.getUrl());
    Label label4 = new Label(nameGroup, SWT.WRAP);
    label4.setText(Messages.getString("User_4")); //$NON-NLS-1$
    userTxt = new Text(nameGroup, SWT.BORDER);
    if (user != null)
        userTxt.setText(user.getUserName());
    data = new GridData(GridData.HORIZONTAL_ALIGN_FILL | GridData.GRAB_HORIZONTAL);
    data.widthHint = SIZING_TEXT_FIELD_WIDTH;
    data.horizontalSpan = 1;
    userTxt.setLayoutData(data);

    Label label5 = new Label(nameGroup, SWT.WRAP);
    label5.setText(Messages.getString("Password_5")); //$NON-NLS-1$
    pswdTxt = new Text(nameGroup, SWT.BORDER);
    if (user != null)
        pswdTxt.setText(user.getPassword());
    pswdTxt.setEchoChar('*');

    data = new GridData(GridData.HORIZONTAL_ALIGN_FILL | GridData.GRAB_HORIZONTAL);
    data.widthHint = SIZING_TEXT_FIELD_WIDTH;
    data.horizontalSpan = 1;
    pswdTxt.setLayoutData(data);
    pswdTxt.setFocus();

    fAutoCommitBox = new Button(nameGroup, SWT.CHECK);
    fAutoCommitBox.setText(Messages.getString("PasswordConnDlg.AutoCommit_1")); //$NON-NLS-1$
    GridData gd = new GridData(GridData.FILL_HORIZONTAL);
    gd.horizontalAlignment = GridData.BEGINNING;
    gd.horizontalSpan = 1;
    fAutoCommitBox.setLayoutData(gd);

    fCommitOnCloseBox = new Button(nameGroup, SWT.CHECK);
    fCommitOnCloseBox.setText(Messages.getString("PasswordConnDlg.Commit_On_Close_2")); //$NON-NLS-1$
    gd = new GridData(GridData.FILL_HORIZONTAL);
    gd.horizontalAlignment = GridData.BEGINNING;
    gd.horizontalSpan = 2;
    fCommitOnCloseBox.setLayoutData(gd);

    fAutoCommitBox.addSelectionListener(new SelectionListener() {

        public void widgetDefaultSelected(SelectionEvent e) {
        }

        public void widgetSelected(SelectionEvent e) {
            if (fAutoCommitBox.getSelection()) {
                fCommitOnCloseBox.setEnabled(false);
            } else
                fCommitOnCloseBox.setEnabled(true);
        }
    });

    fAutoCommitBox.getDisplay().asyncExec(new Runnable() {

        public void run() {
            IPreferenceStore store = SQLExplorerPlugin.getDefault().getPreferenceStore();
            fCommitOnCloseBox.setSelection(store.getBoolean(IConstants.COMMIT_ON_CLOSE));
            fAutoCommitBox.setSelection(store.getBoolean(IConstants.AUTO_COMMIT));
            if (fAutoCommitBox.getSelection()) {
                fCommitOnCloseBox.setEnabled(false);
            } else
                fCommitOnCloseBox.setEnabled(true);
        }
    });

    return parentComposite;
}

From source file:com.safi.workshop.sqlexplorer.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;/*  ww w.  ja v  a 2 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:com.salesforce.ide.ui.editors.apex.ApexCodeEditor.java

License:Open Source License

@Override
public void createPartControl(Composite parent) {
    super.createPartControl(parent);

    ((ProjectionViewer) getSourceViewer()).enableProjection();

    editorSelectionChangedListener = new EditorSelectionChangedListener();
    editorSelectionChangedListener.install(getSelectionProvider());

    IPreferenceStore preferenceStore = getPreferenceStore();
    boolean closeBrackets = preferenceStore.getBoolean(PreferenceConstants.EDITOR_CLOSE_BRACKETS);
    boolean closeStrings = preferenceStore.getBoolean(PreferenceConstants.EDITOR_CLOSE_STRINGS);
    boolean closeAngularBrackets = "1.5"
            .compareTo(preferenceStore.getString(PreferenceConstants.COMPILER_SOURCE)) <= 0; // $NON-NLS-1$

    fBracketInserter.setCloseBracketsEnabled(closeBrackets);
    fBracketInserter.setCloseStringsEnabled(closeStrings);
    fBracketInserter.setCloseAngularBracketsEnabled(closeAngularBrackets);

    ISourceViewer sourceViewer = getSourceViewer();
    if (sourceViewer instanceof ITextViewerExtension)
        ((ITextViewerExtension) sourceViewer).prependVerifyKeyListener(fBracketInserter);
}

From source file:com.salesforce.ide.ui.editors.apex.ApexDocumentProvider.java

License:Open Source License

/**
 * Returns the preference whether handling temporary problems is enabled.
 * /* w w w .ja  v  a 2 s .  c  om*/
 * @return <code>true</code> if temporary problems are handled
 */
protected boolean isHandlingTemporaryProblems() {
    IPreferenceStore store = ForceIdeEditorsPlugin.getDefault().getPreferenceStore();
    return store.getBoolean(HANDLE_TEMPORARY_PROBLEMS);
}