Example usage for org.eclipse.jface.resource JFaceResources getFontRegistry

List of usage examples for org.eclipse.jface.resource JFaceResources getFontRegistry

Introduction

In this page you can find the example usage for org.eclipse.jface.resource JFaceResources getFontRegistry.

Prototype

public static FontRegistry getFontRegistry() 

Source Link

Document

Returns the font registry for JFace itself.

Usage

From source file:ag.ion.noa4e.internal.ui.preferences.LocalOfficeApplicationPreferencesPage.java

License:Open Source License

/**
 * Creates and returns the SWT control for the customized body of this preference 
 * page under the given parent composite. 
 * /*w w  w .  j  a v a2 s  .c  o  m*/
 * @param parent the parent composite
 * 
 * @return constructed control
 * 
 * @author Andreas Brker
 * @author Markus Krger
 */
protected Control createContents(Composite parent) {
    System.out.println("LocalOfficeApplicationPreferencesPage: createContents");
    FormToolkit formToolkit = NOAUIPlugin.getFormToolkit();
    Composite composite = new Composite(parent, SWT.NULL);

    GridLayout gridLayout = new GridLayout();
    gridLayout.numColumns = 3;
    composite.setLayout(gridLayout);

    Label labelHome = formToolkit.createLabel(composite,
            Messages.LocalOfficeApplicationPreferencesPage_label_application_home);
    labelHome.setBackground(composite.getBackground());

    textHome = formToolkit.createText(composite, ""); //$NON-NLS-1$
    textHome.setEditable(false);
    textHome.setFont(composite.getFont());
    GridData gridData = new GridData(SWT.FILL, SWT.NONE, true, false);
    textHome.setLayoutData(gridData);

    final Link linkDefine = new Link(composite, SWT.NONE);
    linkDefine.setText("<a>" + Messages.LocalOfficeApplicationPreferencesPage_link_define_text + "</a>"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
    linkDefine.addSelectionListener(new SelectionAdapter() {
        public void widgetSelected(SelectionEvent selectionEvent) {
            System.out
                    .println("LocalOfficeApplicationPreferencesPage: createContents: widgetSelected: 1 start");
            LocalApplicationWizard localApplicationWizard = new LocalApplicationWizard();
            System.out.println("LocalOfficeApplicationPreferencesPage: createContents: widgetSelected: 2");
            String oldHome = textHome.getText();
            System.out.println("LocalOfficeApplicationPreferencesPage: createContents: widgetSelected: 3");
            if (oldHome.length() != 0)
                localApplicationWizard.setHomePath(oldHome);
            System.out.println("LocalOfficeApplicationPreferencesPage: createContents: widgetSelected: 4");
            WizardDialog wizardDialog = new WizardDialog(linkDefine.getShell(), localApplicationWizard);
            System.out.println("LocalOfficeApplicationPreferencesPage: createContents: widgetSelected: 5");
            if (wizardDialog.open() == Window.OK) {
                System.out.println("LocalOfficeApplicationPreferencesPage: createContents: widgetSelected: 6");
                String home = localApplicationWizard.getSelectedHomePath();
                System.out.println("LocalOfficeApplicationPreferencesPage: createContents: widgetSelected: 7");
                if (home != null)
                    textHome.setText(home);
                initApplicationProperties(tableApplicationProperties);
                System.out.println("LocalOfficeApplicationPreferencesPage: createContents: widgetSelected: 8");
            }
            System.out.println("LocalOfficeApplicationPreferencesPage: createContents: widgetSelected: 9 end");
        }
    });

    Label labelNull = formToolkit.createLabel(composite, ""); //$NON-NLS-1$
    gridData = new GridData();
    gridData.horizontalSpan = 3;
    labelNull.setLayoutData(gridData);

    Label labelProperties = formToolkit.createLabel(composite,
            Messages.LocalOfficeApplicationPreferencesPage_label_application_properties_text);
    labelProperties.setBackground(composite.getBackground());
    labelProperties.setFont(JFaceResources.getFontRegistry().getBold(labelProperties.getFont().toString()));
    gridData = new GridData(SWT.FILL, SWT.NONE, true, false);
    gridData.horizontalSpan = 3;
    labelProperties.setLayoutData(gridData);

    tableApplicationProperties = formToolkit.createTable(composite, SWT.READ_ONLY);
    gridData = new GridData(SWT.FILL, SWT.FILL, true, true);
    gridData.horizontalSpan = 3;
    int tableWidth = (int) (tableApplicationProperties.getDisplay().getClientArea().width * 0.3);
    gridData.widthHint = tableWidth;
    tableApplicationProperties.setLayoutData(gridData);

    TableLayout tableLayout = new TableLayout();
    tableApplicationProperties.setLayout(tableLayout);

    TableColumn columnProduct = new TableColumn(tableApplicationProperties, SWT.NONE);
    columnProduct.setText(Messages.LocalOfficeApplicationPreferencesPage_column_name_text);
    int columnProductWidth = (int) (tableWidth * 0.4);
    columnProduct.setWidth(columnProductWidth);

    TableColumn columnHome = new TableColumn(tableApplicationProperties, SWT.NONE);
    columnHome.setText(Messages.LocalOfficeApplicationPreferencesPage_column_value_text);
    columnHome.setWidth(tableWidth - columnProductWidth);

    tableApplicationProperties.setLinesVisible(true);
    tableApplicationProperties.setHeaderVisible(true);

    buttonPreventTermination = formToolkit.createButton(composite,
            Messages.LocalOfficeApplicationPreferencesPage_prevent_termination_lable, SWT.CHECK);
    buttonPreventTermination.setBackground(composite.getBackground());
    gridData = new GridData();
    gridData.horizontalSpan = 3;
    buttonPreventTermination.setLayoutData(gridData);

    //20130310js: Adding new text elements to specify timeout values begin
    //I tried to use an initial value for the text to get a certain minimum width of the input field.
    //but that hasn't worked out at all.
    //The text that can actually appear is clamped to numeric in the range of 0..500, or 0..60, respectively, by other code.

    Label labelTimeoutBootstrapConnect = formToolkit.createLabel(composite,
            Messages.LocalOfficeApplicationPreferencesPage_label_timeout_bootstrap_connect);
    labelTimeoutBootstrapConnect.setBackground(composite.getBackground());

    textTimeoutBootstrapConnect = formToolkit.createText(composite, "     "); //$NON-NLS-1$
    textTimeoutBootstrapConnect.setEditable(true);
    textTimeoutBootstrapConnect.setFont(composite.getFont());
    //GridData gridData = new GridData(SWT.LEFT, SWT.NONE, false, false);
    gridData = new GridData(SWT.LEFT, SWT.NONE, false, false);
    gridData.horizontalSpan = 2;
    textTimeoutBootstrapConnect.setLayoutData(gridData);

    Label labelTimeoutThreadedWatchdog = formToolkit.createLabel(composite,
            Messages.LocalOfficeApplicationPreferencesPage_label_timeout_threaded_watchdog);
    labelTimeoutThreadedWatchdog.setBackground(composite.getBackground());

    textTimeoutThreadedWatchdog = formToolkit.createText(composite, "     "); //$NON-NLS-1$
    textTimeoutThreadedWatchdog.setEditable(true);
    textTimeoutThreadedWatchdog.setFont(composite.getFont());
    gridData = new GridData(SWT.LEFT, SWT.NONE, false, false);
    gridData.horizontalSpan = 2;
    textTimeoutThreadedWatchdog.setLayoutData(gridData);
    //20130310js: Adding new text elements to specify timeout values end  

    //20130420js: noatext_jsl 1.4.9 -> 1.4.10: Adopt configurability of meaningful temporary filename from omnivore_js 1.4.4 begin
    //The following code was adopted in a simplified way from Omnivore_js...PreferencePage.java
    //Detailed coments and temporarily tried out code was not copied over here.
    //Note that elements of the preferences dialog are apparently constructed at a different level of abstraction here.

    Integer nCotfRules = PREFERENCE_cotf_elements.length;

    Group gCotfRules = new Group(parent, SWT.NONE);

    GridLayout gCotfRulesGridLayout = new GridLayout();
    gCotfRulesGridLayout.numColumns = nCotfRules; //at least this one is finally honoured...
    gCotfRules.setLayout(gCotfRulesGridLayout);

    GridData gCotfRulesGridLayoutData = new GridData();
    gCotfRulesGridLayoutData.grabExcessHorizontalSpace = true;
    gCotfRulesGridLayoutData.horizontalAlignment = GridData.FILL;
    gCotfRules.setLayoutData(gCotfRulesGridLayoutData);

    gCotfRules.setText(Messages.LocalOfficeApplicationPrefrencesPage_construction_of_temporary_filename);

    for (int i = 0; i < nCotfRules; i++) {

        Group gCotfRule = new Group(gCotfRules, SWT.NONE);

        //gCotfRule.setLayoutData(SWTHelper.getFillGridData(2,false,2,false));   //This would probably make groups-within-group completely disappear.

        gCotfRule.setLayout(new FillLayout());
        GridLayout gCotfRuleGridLayout = new GridLayout();
        gCotfRuleGridLayout.numColumns = nCotfRules;
        gCotfRule.setLayout(gCotfRuleGridLayout);

        GridData gCotfRuleGridLayoutData = new GridData();
        gCotfRuleGridLayoutData.grabExcessHorizontalSpace = true;
        gCotfRuleGridLayoutData.horizontalAlignment = GridData.FILL;
        //Sadly, even if I get the constant element to fill 3 lines - its heading will be at the top, and only its input field in the middle of the vertical space. So I don't do that.
        //gCotfRuleGridLayoutData.grabExcessVerticalSpace = true;         //so that the constant element with only one line occupies the same space as a fully configurable element
        //gCotfRuleGridLayoutData.verticalAlignment=GridData.FILL;         //so that the constant element with only one line occupies the same space as a fully configurable element
        gCotfRule.setLayoutData(gCotfRuleGridLayoutData);

        //System.out.println("Messages.LocalOfficeApplicationPrefrencesPage_cotf_"+PREFERENCE_cotf_elements[i]);

        gCotfRule.setText(PREFERENCE_cotf_elements_messages[i]);
        GridLayout gridDataLayout = new GridLayout();
        gridDataLayout.numColumns = 1;
        gCotfRule.setLayout(gridDataLayout);

        if (PREFERENCE_cotf_elements[i].contains("constant")) {
            //That's the way elements are added in omnivore_js....PreferencePage.java:
            //addField(new StringFieldEditor("","",10,gCotfRule));
            //addField(new StringFieldEditor(PREFERENCE_BRANCH+PREFERENCE_COTF+PREFERENCE_cotf_elements[i]+"_"+PREFERENCE_cotf_parameters[1],PREFERENCE_cotf_elements_messages[i],10,gCotfRule));
            //addField(new StringFieldEditor("","",10,gCotfRule));
            //But addField() is not known here. Instead, that's the way elements are added in LocalOfficeApplicationPreferencesPage.java - Sorry for the highly redundant ad-hoc code:
            //After all, this would enable me to avoid the two non-used text input fields for the constant element, by placing 2x2 labels containing nothing or just one space :-)
            //TODO: Moreover, I reviewed the code to obtain the desired output with fewer lines. Should be done above as well, and in omnivore_js as well.

            /*
            Label labelCotfRule = formToolkit.createLabel(gCotfRule," ");
             labelCotfRule.setBackground(gCotfRule.getBackground());
                    
             textCotfOption[i][0] = formToolkit.createText(gCotfRule, ""); //$NON-NLS-1$
                     
             textCotfOption[i][0].setEditable(true);
             textCotfOption[i][0].setFont(gCotfRule.getFont());
                     
             gridData = new GridData(SWT.LEFT, SWT.NONE, false, false);
             gridData.horizontalSpan = 1;
             textCotfOption[i][0].setLayoutData(gridData);
             */

            Label labelCotfRule = formToolkit.createLabel(gCotfRule, PREFERENCE_cotf_parameters_messages[1]);
            labelCotfRule.setBackground(gCotfRule.getBackground());

            textCotfOption[i][1] = formToolkit.createText(gCotfRule, ""); //$NON-NLS-1$
            textCotfOption[i][1].setEditable(true);

            gridData = new GridData(SWT.FILL, SWT.CENTER, true, true);
            gridData.horizontalSpan = 1;
            textCotfOption[i][1].setLayoutData(gridData);

            /*
            labelCotfRule = formToolkit.createLabel(gCotfRule,"n.a.");
            labelCotfRule.setBackground(gCotfRule.getBackground());
                    
            textCotfOption[i][2] = formToolkit.createText(gCotfRule, ""); //$NON-NLS-1$
            textCotfOption[i][2].setEditable(true);
            textCotfOption[i][2].setFont(gCotfRule.getFont());
                    
            textCotfOption[i][2].setLayoutData(gridData);
            */
        } else {
            //addField(new StringFieldEditor(PREFERENCE_BRANCH+PREFERENCE_COTF+PREFERENCE_cotf_elements[i]+"_"+PREFERENCE_cotf_parameters[0],PREFERENCE_cotf_parameters_messages[0],10,gCotfRule));
            //addField(new StringFieldEditor(PREFERENCE_BRANCH+PREFERENCE_COTF+PREFERENCE_cotf_elements[i]+"_"+PREFERENCE_cotf_parameters[1],PREFERENCE_cotf_parameters_messages[1],10,gCotfRule));
            //addField(new StringFieldEditor(PREFERENCE_BRANCH+PREFERENCE_COTF+PREFERENCE_cotf_elements[i]+"_"+PREFERENCE_cotf_parameters[2],PREFERENCE_cotf_parameters_messages[2],10,gCotfRule));

            Label labelCotfRule = formToolkit.createLabel(gCotfRule, PREFERENCE_cotf_parameters_messages[0]);
            labelCotfRule.setBackground(gCotfRule.getBackground());

            textCotfOption[i][0] = formToolkit.createText(gCotfRule, ""); //$NON-NLS-1$
            textCotfOption[i][0].setEditable(true);

            gridData = new GridData(SWT.FILL, SWT.CENTER, true, true);
            gridData.horizontalSpan = 1;
            textCotfOption[i][0].setLayoutData(gridData);

            labelCotfRule = formToolkit.createLabel(gCotfRule, PREFERENCE_cotf_parameters_messages[1]);
            labelCotfRule.setBackground(gCotfRule.getBackground());

            textCotfOption[i][1] = formToolkit.createText(gCotfRule, ""); //$NON-NLS-1$
            textCotfOption[i][1].setEditable(true);

            textCotfOption[i][1].setLayoutData(gridData);

            labelCotfRule = formToolkit.createLabel(gCotfRule, PREFERENCE_cotf_parameters_messages[2]);
            labelCotfRule.setBackground(gCotfRule.getBackground());

            textCotfOption[i][2] = formToolkit.createText(gCotfRule, ""); //$NON-NLS-1$
            textCotfOption[i][2].setEditable(true);

            textCotfOption[i][2].setLayoutData(gridData);
        }
    }

    //20130420js: noatext_jsl 1.4.9 -> 1.4.10: Adopt configurability of meaningful temporary filename from omnivore_js 1.4.4 end

    formToolkit.paintBordersFor(composite);
    initPreferenceValues();
    initApplicationProperties(tableApplicationProperties);
    return composite;
}

From source file:at.bestsolution.efxclipse.tooling.css.ui.hover.CssHoverProvider.java

License:Open Source License

protected String getStyleSheet() {
    String css = loadStyleSheet();

    if (css != null) {
        FontData fontData = JFaceResources.getFontRegistry().getFontData(fontSymbolicName)[0];
        css = HTMLPrinter.convertTopLevelFont(css, fontData);
    }/*w  w  w  . ja  v  a  2  s.c  o m*/
    return css;
}

From source file:au.gov.ansto.bragg.nbi.ui.widgets.HMImageDisplayWidget.java

License:Open Source License

protected Composite createImageArea() {
    GridLayoutFactory.swtDefaults().numColumns(9).margins(0, 0).applyTo(this);

    // Mode// ww  w . jav a  2  s.  c  o m
    Label label = getToolkit().createLabel(this, "Mode: ");
    label.setFont(JFaceResources.getFontRegistry().getBold(JFaceResources.DEFAULT_FONT));
    GridDataFactory.swtDefaults().align(SWT.END, SWT.CENTER).grab(true, false).applyTo(label);
    comboViewer = new ComboViewer(this, SWT.READ_ONLY);
    comboViewer.setContentProvider(new ArrayContentProvider());
    comboViewer.setLabelProvider(new LabelProvider());
    comboViewer.setInput(getImageMode().getValues());
    comboViewer.setSelection(new StructuredSelection(getImageMode()));
    comboViewer.addSelectionChangedListener(new ISelectionChangedListener() {
        public void selectionChanged(SelectionChangedEvent event) {
            // Change display mode
            setImageMode((HMImageMode) ((IStructuredSelection) event.getSelection()).getFirstElement());
            // Update NOW
            Job job = new Job(HMImageDisplayWidget.class.getName()) {
                protected IStatus run(IProgressMonitor monitor) {
                    try {
                        // Get data (one off)
                        pullData();
                    } catch (Exception e) {
                        return new Status(IStatus.ERROR, Activator.PLUGIN_ID, "Failed to fetch data.", e);
                    }
                    return Status.OK_STATUS;
                }
            };
            job.setSystem(true);
            job.schedule();
        }
    });

    // Separator
    label = getToolkit().createLabel(this, "");
    GridDataFactory.swtDefaults().hint(8, SWT.DEFAULT).applyTo(label);

    Label scaleLabel = getToolkit().createLabel(this, "Scale: ");
    scaleLabel.setFont(JFaceResources.getFontRegistry().getBold(JFaceResources.DEFAULT_FONT));
    GridDataFactory.swtDefaults().align(SWT.END, SWT.CENTER).grab(true, false).applyTo(scaleLabel);
    ComboViewer scaleViewer = new ComboViewer(this, SWT.READ_ONLY);
    scaleViewer.setContentProvider(new ArrayContentProvider());
    scaleViewer.setLabelProvider(new LabelProvider());
    scaleViewer.setInput(SCALE_INPUT);
    isScaleEnabled = true;
    try {
        isScaleEnabled = Boolean.valueOf(System.getProperty(IS_SCALE_ENABLED));
    } catch (Exception e) {
    }
    scaleViewer.setSelection(new StructuredSelection(SCALE_INPUT[isScaleEnabled ? 0 : 1]));
    scaleViewer.addSelectionChangedListener(new ISelectionChangedListener() {
        public void selectionChanged(SelectionChangedEvent event) {
            // Change display mode
            setScaleEnabled(
                    SCALE_INPUT[0].equals(((IStructuredSelection) event.getSelection()).getFirstElement()));
            // Update NOW
            Job job = new Job(HMImageDisplayWidget.class.getName()) {
                protected IStatus run(IProgressMonitor monitor) {
                    try {
                        // Get data (one off)
                        pullData();
                    } catch (Exception e) {
                        return new Status(IStatus.ERROR, Activator.PLUGIN_ID, "Failed to fetch data.", e);
                    }
                    return Status.OK_STATUS;
                }
            };
            job.setSystem(true);
            job.schedule();
        }
    });

    label = getToolkit().createLabel(this, "");
    GridDataFactory.swtDefaults().hint(8, SWT.DEFAULT).applyTo(label);

    // Refresh
    label = getToolkit().createLabel(this, "Refresh: ");
    label.setFont(JFaceResources.getFontRegistry().getBold(JFaceResources.DEFAULT_FONT));
    final Text refreshText = getToolkit().createText(this, "");
    Realm.runWithDefault(SWTObservables.getRealm(Display.getDefault()), new Runnable() {
        public void run() {
            DataBindingContext bindingContext = new DataBindingContext();
            bindingContext.bindValue(SWTObservables.observeText(refreshText, SWT.Modify),
                    BeansObservables.observeValue(HMImageDisplayWidget.this, "refreshDelay"),
                    new UpdateValueStrategy(), new UpdateValueStrategy());
        }
    });
    GridDataFactory.swtDefaults().hint(20, SWT.DEFAULT).applyTo(refreshText);
    label = getToolkit().createLabel(this, "sec ");
    label.setFont(JFaceResources.getFontRegistry().getBold(JFaceResources.DEFAULT_FONT));

    Composite imageArea = getToolkit().createComposite(this, SWT.NONE);
    GridLayoutFactory.fillDefaults().margins(0, 0).spacing(0, 0).applyTo(imageArea);
    GridDataFactory.fillDefaults().grab(true, true).span(9, 1).applyTo(imageArea);

    return imageArea;
}

From source file:au.gov.ansto.bragg.nbi.ui.widgets.ShutterStatusWidget.java

License:Open Source License

public void renderWidget() {
    setBackgroundMode(SWT.INHERIT_FORCE);
    GridLayoutFactory.swtDefaults().applyTo(this);

    Label label = getToolkit().createLabel(this, "Secondary\n--", SWT.CENTER | SWT.WRAP | SWT.BORDER);
    label.setFont(JFaceResources.getFontRegistry().getBold(JFaceResources.DEFAULT_FONT));
    GridDataFactory.swtDefaults().align(SWT.FILL, SWT.CENTER).grab(true, false).applyTo(label);
    Context context = new Context();
    context.path = "/instrument/status/secondary";
    context.label = label;//from   ww w. j  av  a2  s. c om
    context.originalForeground = label.getForeground();
    context.handler = new HdbEventHandler(context).activate();
    contexts.add(context);

    label = getToolkit().createLabel(this, "Sample\n--", SWT.CENTER | SWT.WRAP | SWT.BORDER);
    label.setFont(JFaceResources.getFontRegistry().getBold(JFaceResources.DEFAULT_FONT));
    GridDataFactory.swtDefaults().align(SWT.FILL, SWT.CENTER).grab(true, false).applyTo(label);
    context = new Context();
    context.path = "/instrument/status/tertiary";
    context.label = label;
    context.originalForeground = label.getForeground();
    context.handler = new HdbEventHandler(context).activate();
    contexts.add(context);

    // TODO: test this code
    // [GUMTREE-141] Blinking
    eventHandler = new EventHandler(IDirectoryService.EVENT_TOPIC_BIND) {
        @Override
        public void handleEvent(Event event) {
            // TODO: use topic to filter
            if (event.getProperty(IDirectoryService.EVENT_PROP_NAME).equals("shutterStatusCheckFailed")) {
                if ((Boolean) event.getProperty(IDirectoryService.EVENT_PROP_OBJECT)) {
                    final int[] counter = new int[] { 0 };
                    final Map<Label, Color> originalColourMap = new HashMap<Label, Color>();
                    Job job = new Job("") {
                        protected IStatus run(IProgressMonitor monitor) {
                            // Over 5 times ... exit
                            if (isDisposed() || counter[0] > 5) {
                                return Status.OK_STATUS;
                            }
                            SafeUIRunner.asyncExec(new SafeRunnable() {
                                public void run() throws Exception {
                                    for (Context context : contexts) {
                                        if (!context.isActivated) {
                                            continue;
                                        }
                                        // Initialise and finalise
                                        if (counter[0] == 0) {
                                            originalColourMap.put(context.label, context.label.getBackground());
                                        } else if (counter[0] >= 5) {
                                            context.label.setBackground(originalColourMap.get(context.label));
                                        }
                                        // Blinking
                                        if (counter[0] % 2 == 0) {
                                            context.label.setBackground(null);
                                        } else {
                                            context.label.setBackground(originalColourMap.get(context.label));
                                        }
                                    }
                                    counter[0]++;
                                }
                            });
                            // Repeat every 0.5 sec
                            schedule(500);
                            return Status.OK_STATUS;
                        }
                    };
                    // Run now
                    job.schedule();
                }
            }

        }
    };
}

From source file:au.gov.ga.earthsci.common.ui.color.ColorMapEditor.java

License:Apache License

/**
 * Build the options editing//  w  w w .  j  a  v a2 s.  c  o m
 */
private void addOptionsArea() {
    optionsContainer = new Composite(this, SWT.BORDER);
    optionsContainer.setLayoutData(
            new GridData(GridData.FILL_BOTH | GridData.GRAB_HORIZONTAL | GridData.GRAB_VERTICAL));

    optionsContainer.setLayout(new GridLayout(2, false));

    Label modeLabel = new Label(optionsContainer, SWT.NONE);
    modeLabel.setText(Messages.ColorMapEditor_ModeLabel);
    modeCombo = new ComboViewer(optionsContainer, SWT.DROP_DOWN);
    modeCombo.setContentProvider(ArrayContentProvider.getInstance());
    modeCombo.setInput(InterpolationMode.values());
    modeCombo.setLabelProvider(new NamedLabelProvider());
    modeCombo.setSelection(new StructuredSelection(map.getMode()));

    final Label modeDescription = new Label(optionsContainer, SWT.WRAP);
    GridData gd = new GridData(GridData.FILL_HORIZONTAL);
    gd.horizontalSpan = 2;
    gd.horizontalIndent = 10;
    modeDescription.setLayoutData(gd);
    modeDescription.setText(map.getMode().getDescription());
    modeDescription.setFont(JFaceResources.getFontRegistry().getItalic("default")); //$NON-NLS-1$

    modeCombo.addSelectionChangedListener(new ISelectionChangedListener() {
        @Override
        public void selectionChanged(SelectionChangedEvent event) {
            InterpolationMode newMode = (InterpolationMode) ((IStructuredSelection) event.getSelection())
                    .getFirstElement();
            if (newMode != map.getMode()) {
                map.setMode(newMode);
                modeDescription.setText(newMode.getDescription());
            }
        }
    });

    if (hasDataValues) {
        percentageBasedButton = new Button(optionsContainer, SWT.CHECK);
        percentageBasedButton.setText(Messages.ColorMapEditor_UsePercentagesLabel);
        percentageBasedButton.setSelection(map.isPercentageBased());
        gd = new GridData();
        gd.horizontalSpan = 2;
        percentageBasedButton.setLayoutData(gd);
        percentageBasedButton.addSelectionListener(new SelectionListener() {
            @Override
            public void widgetSelected(SelectionEvent e) {
                map.setValuesArePercentages(percentageBasedButton.getSelection(), minDataValue, maxDataValue);
            }

            @Override
            public void widgetDefaultSelected(SelectionEvent e) {
                map.setValuesArePercentages(percentageBasedButton.getSelection(), minDataValue, maxDataValue);
            }
        });
    }

    addEntryEditor(optionsContainer);
    addAddRemoveButtons(optionsContainer);
    addEntriesList(optionsContainer);
    addNodataEditor(optionsContainer);
}

From source file:au.gov.ga.earthsci.discovery.ui.DiscoveryResultInformationProvider.java

License:Apache License

/**
 * Load the named style sheet resource to a string.
 * //from  w w  w.  j a  va  2s .  co m
 * @param styleSheetName
 *            Style sheet filename to load
 * @return Style sheet content as a string
 */
public static String loadStyleSheet(String styleSheetName) {
    InputStream stream = DiscoveryResultInformationProvider.class.getResourceAsStream(styleSheetName);
    if (stream == null) {
        return null;
    }

    try {
        String sheet = Util.readStreamToString(stream, "UTF-8"); //$NON-NLS-1$
        FontData fontData = JFaceResources.getFontRegistry().getFontData(JFaceResources.DIALOG_FONT)[0];
        return HTMLPrinter.convertTopLevelFont(sheet, fontData);
    } catch (IOException ex) {
        return ""; //$NON-NLS-1$
    } finally {
        try {
            stream.close();
        } catch (IOException e) {
            //ignore
        }
    }
}

From source file:au.gov.ga.earthsci.jface.extras.information.html.BrowserInformationControl.java

License:Open Source License

/**
 * Creates and initializes the text layout used
 * to compute the size hint.//w w w . j a v  a 2s .c o m
 * 
 * @since 3.2
 */
private void createTextLayout() {
    fTextLayout = new TextLayout(fBrowser.getDisplay());

    // Initialize fonts
    String symbolicFontName = fSymbolicFontName == null ? JFaceResources.DIALOG_FONT : fSymbolicFontName;
    Font font = JFaceResources.getFont(symbolicFontName);
    fTextLayout.setFont(font);
    fTextLayout.setWidth(-1);
    font = JFaceResources.getFontRegistry().getBold(symbolicFontName);
    fBoldStyle = new TextStyle(font, null, null);

    // Compute and set tab width
    fTextLayout.setText("    "); //$NON-NLS-1$
    int tabWidth = fTextLayout.getBounds().width;
    fTextLayout.setTabs(new int[] { tabWidth });
    fTextLayout.setText(""); //$NON-NLS-1$
}

From source file:bndtools.utils.MessagesPopupDialog.java

License:Open Source License

@SuppressWarnings("unused")
@Override/*from   w  w  w .  ja v  a2 s . c  o  m*/
protected Control createDialogArea(Composite parent) {
    Composite composite = (Composite) super.createDialogArea(parent);
    composite.setLayout(new GridLayout(1, false));

    for (int i = 0; i < messages.length; i++) {
        if (i > 0) {
            Label separator = new Label(composite, SWT.SEPARATOR | SWT.HORIZONTAL);
            separator.setLayoutData(new GridData(SWT.FILL, SWT.TOP, false, false, 2, 1));
        }

        // Message Type Image Label
        Composite pnlTitle = new Composite(composite, SWT.NONE);
        pnlTitle.setLayout(new GridLayout(2, false));
        Label lblImage = new Label(pnlTitle, SWT.NONE);
        lblImage.setImage(getMessageImage(messages[i].getMessageType()));

        // Message Label
        StringBuilder builder = new StringBuilder();
        if (messages[i].getPrefix() != null) {
            builder.append(messages[i].getPrefix());
        }
        builder.append(messages[i].getMessage());
        Label lblText = new Label(pnlTitle, SWT.WRAP);
        lblText.setText(builder.toString());
        lblText.setFont(JFaceResources.getFontRegistry().getItalic(JFaceResources.DIALOG_FONT));
        lblText.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));

        // Fix actions, if present
        Object data = messages[i].getData();
        IAction[] fixes;
        if (data instanceof IAction) {
            fixes = new IAction[] { (IAction) data };
        } else if (data instanceof IAction[]) {
            fixes = (IAction[]) data;
        } else {
            fixes = null;
        }

        if (fixes != null) {
            // new Label(composite, SWT.SEPARATOR | SWT.HORIZONTAL);
            Composite pnlFixes = new Composite(composite, SWT.NONE);
            pnlFixes.setLayout(new GridLayout(3, false));

            Label lblFixes = new Label(pnlFixes, SWT.NONE);
            lblFixes.setText("Available Fixes:");
            lblFixes.setForeground(JFaceResources.getColorRegistry().get(JFacePreferences.QUALIFIER_COLOR));

            for (int j = 0; j < fixes.length; j++) {
                if (j > 0)
                    new Label(pnlFixes, SWT.NONE); // Spacer

                new Label(pnlFixes, SWT.NONE).setImage(bulletImg);

                final IAction fix = fixes[j];
                Hyperlink fixLink = new Hyperlink(pnlFixes, SWT.NONE);
                hyperlinkGroup.add(fixLink);
                fixLink.setText(fix.getText());
                fixLink.setHref(fix);
                fixLink.addHyperlinkListener(new HyperlinkAdapter() {
                    @Override
                    public void linkActivated(HyperlinkEvent e) {
                        fix.run();
                        close();
                        // part.getSite().getPage().activate(part);
                        part.setFocus();
                    }
                });
                fixLink.setLayoutData(new GridData(SWT.LEFT, SWT.TOP, false, false));
            }
        }
    }

    return composite;
}

From source file:ch.elexis.core.ui.UiDesk.java

License:Open Source License

public static void updateFont(String cfgName) {
    FontRegistry fr = JFaceResources.getFontRegistry();
    FontData[] fd = PreferenceConverter.getFontDataArray(new SettingsPreferenceStore(CoreHub.userCfg), cfgName);
    fr.put(cfgName, fd);/*from  ww  w.  j a  va2s.co m*/
}

From source file:ch.elexis.core.ui.UiDesk.java

License:Open Source License

public static Font getFont(String cfgName) {
    FontRegistry fr = JFaceResources.getFontRegistry();
    if (!fr.hasValueFor(cfgName)) {
        FontData[] fd = PreferenceConverter.getFontDataArray(new SettingsPreferenceStore(CoreHub.userCfg),
                cfgName);//ww w  . ja  v  a 2  s.c o  m
        fr.put(cfgName, fd);
    }
    return fr.get(cfgName);
}