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:name.schedenig.eclipse.grepconsole.view.items.ItemLabelProvider.java

License:Open Source License

/**
 * Returns the font to use for a specific element.
 * /*from  w  w w.  ja v a2s .  com*/
 * For groups, a bold version of the default font is returned. For all other
 * items, <code>null</code> is returned.
 * 
 * @param element Element.
 * 
 * @return Font, or <code>null</code>.
 */
public Font getFont(Object element) {
    if (element instanceof GrepExpressionFolder) {
        return JFaceResources.getFontRegistry().getBold(JFaceResources.DIALOG_FONT);
    } else {
        return JFaceResources.getDialogFont();
    }
}

From source file:name.schedenig.eclipse.grepconsole.view.styles.StylePanel.java

License:Open Source License

/**
 * Initialises the GUI.//from w  w  w . ja  va  2 s .  com
 */
private void init() {
    headerFont = JFaceResources.getFontRegistry().getBold(JFaceResources.DIALOG_FONT);
    colorRegistry = new ColorRegistry(Activator.getDefault().getColorRegistry());

    new GridLayoutBuilder(this, 3, false).apply();

    labelName = new Label(this, SWT.NONE);
    labelName.setText(Messages.StylePanel_name);
    labelName.setLayoutData(new GridData(SWT.BEGINNING, SWT.CENTER, false, false));

    textName = new Text(this, SWT.BORDER);
    textName.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false, 2, 1));

    panelCheckboxes = new Composite(this, SWT.NONE);
    RowLayout panelCheckboxesLayout = new RowLayout();
    panelCheckboxesLayout.marginWidth = panelCheckboxesLayout.marginHeight = 0;
    panelCheckboxesLayout.marginLeft = panelCheckboxesLayout.marginRight = 0;
    panelCheckboxesLayout.marginTop = panelCheckboxesLayout.marginBottom = 0;

    panelCheckboxes.setLayout(panelCheckboxesLayout);
    panelCheckboxes.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, false, false, 3, 1));

    cbBold = new Button(panelCheckboxes, SWT.CHECK);
    cbBold.setText(Messages.StylePanel_bold);
    cbBold.addSelectionListener(selectionListener);

    cbItalic = new Button(panelCheckboxes, SWT.CHECK);
    cbItalic.setText(Messages.StylePanel_italic);
    cbItalic.addSelectionListener(selectionListener);

    cpForeground = new ColorPickerLine(this);
    cpForeground.setText(Messages.StylePanel_foreground);
    cpForeground.setDialogTitle(Messages.StylePanel_title_foreground);
    cpForeground.addListener(colorChangeListener);

    cpBackground = new ColorPickerLine(this);
    cpBackground.setText(Messages.StylePanel_background);
    cpBackground.setDialogTitle(Messages.StylePanel_title_background);
    cpBackground.addListener(colorChangeListener);

    cpUnderline = new ColorPickerLine(this);
    cpUnderline.setText(Messages.StylePanel_underline);
    cpUnderline.setDialogTitle(Messages.StylePanel_title_underline);
    cpUnderline.setColorMandatory(false);
    cpUnderline.addListener(colorChangeListener);

    cpStrikethrough = new ColorPickerLine(this);
    cpStrikethrough.setText(Messages.StylePanel_strikethrough);
    cpStrikethrough.setDialogTitle(Messages.StylePanel_title_strikethrough);
    cpStrikethrough.setColorMandatory(false);
    cpStrikethrough.addListener(colorChangeListener);

    cpBorder = new ColorPickerLine(this);
    cpBorder.setText(Messages.StylePanel_border);
    cpBorder.setDialogTitle(Messages.StylePanel_title_border);
    cpBorder.setColorMandatory(false);
    cpBorder.addListener(colorChangeListener);

    labelPreview = new Label(this, SWT.NONE);
    labelPreview.setFont(headerFont);
    labelPreview.setText(Messages.StylePanel_preview);
    GridData gridData = new GridData(SWT.FILL, SWT.CENTER, true, false, 3, 1);
    gridData.verticalIndent = 10;
    labelPreview.setLayoutData(gridData);

    final String unstyledText = Messages.StylePanel_unstyled_preview;
    final String styledText = Messages.StylePanel_styled_preview;

    stPreview = new StyledText(this, SWT.BORDER);
    stPreview.setText(unstyledText + "\n" + styledText + "\n" + unstyledText); //$NON-NLS-1$ //$NON-NLS-2$
    stPreview.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, true, 3, 1));
    stPreview.setFont(JFaceResources.getTextFont());
    stPreview.setEditable(false);

    new PreviewColorHandler(stPreview);

    stPreview.addLineStyleListener(new LineStyleListener() {
        @Override
        public void lineGetStyle(LineStyleEvent event) {
            if (event.lineOffset == unstyledText.length() + 1) {
                StyleRange style = new StyleRange();
                style.start = event.lineOffset;
                style.length = event.lineText.length();
                fillStyleRange(style);
                event.styles = new StyleRange[] { style };
            }
        }
    });

    refresh();
}

From source file:net.certiv.fluentmark.preferences.PreviewSourceUpdater.java

License:Open Source License

/**
 * Creates a source preview updater for the given viewer, configuration and preference store.
 *
 * @param viewer the viewer//w ww  .  jav  a  2s. co  m
 * @param configuration the configuration
 * @param preferenceStore the preference store
 */
public PreviewSourceUpdater(final SourceViewer viewer, final FluentSourceViewerConfiguration configuration,
        final IPreferenceStore preferenceStore) {
    Assert.isNotNull(viewer);
    Assert.isNotNull(configuration);
    Assert.isNotNull(preferenceStore);
    final IPropertyChangeListener fontChangeListener = new IPropertyChangeListener() {

        @Override
        public void propertyChange(PropertyChangeEvent event) {
            if (event.getProperty().equals(Prefs.EDITOR_TEXT_FONT)) {
                Font font = JFaceResources.getFont(Prefs.EDITOR_TEXT_FONT);
                viewer.getTextWidget().setFont(font);
            }
        }
    };
    final IPropertyChangeListener propertyChangeListener = new IPropertyChangeListener() {

        @Override
        public void propertyChange(PropertyChangeEvent event) {
            if (configuration.affectsTextPresentation(event)) {
                configuration.handlePropertyChangeEvent(event);
                viewer.invalidateTextPresentation();
            }
        }
    };
    viewer.getTextWidget().addDisposeListener(new DisposeListener() {

        @Override
        public void widgetDisposed(DisposeEvent e) {
            preferenceStore.removePropertyChangeListener(propertyChangeListener);
            JFaceResources.getFontRegistry().removeListener(fontChangeListener);
        }
    });
    JFaceResources.getFontRegistry().addListener(fontChangeListener);
    preferenceStore.addPropertyChangeListener(propertyChangeListener);
}

From source file:net.enilink.komma.edit.ui.dialogs.FilteredTree.java

License:Open Source License

/**
 * Return a bold font if the given element matches the given pattern.
 * Clients can opt to call this method from a Viewer's label provider to get
 * a bold font for which to highlight the given element in the tree.
 * //from  www  .j  a va  2s . co m
 * @param element
 *            element for which a match should be determined
 * @param tree
 *            FilteredTree in which the element resides
 * @param filter
 *            PatternFilter which determines a match
 * 
 * @return bold font
 */
public static Font getBoldFont(Object element, FilteredTree tree, PatternFilter filter) {
    String filterText = tree.getFilterString();

    if (filterText == null) {
        return null;
    }

    // Do nothing if it's empty string
    String initialText = tree.getInitialText();
    if (!("".equals(filterText) || initialText.equals(filterText))) {//$NON-NLS-1$
        boolean initial = initialText != null && initialText.equals(filterText);
        if (initial) {
            filter.setPattern(null);
        } else if (filterText != null) {
            filter.setPattern(filterText);
        }

        if (filter.isElementVisible(tree.getViewer(), element)
                && filter.isLeafMatch(tree.getViewer(), element)) {
            return JFaceResources.getFontRegistry().getBold(JFaceResources.DIALOG_FONT);
        }
    }
    return null;
}

From source file:net.lopezbobeda.rap.examples.mail.views.MessageView.java

License:Open Source License

public MessageView(final Composite parent, final Email pEmail) {
    Composite top = new Composite(parent, SWT.NONE);
    GridLayout layout = new GridLayout();
    layout.marginHeight = 0;/*from  w  w w.  j a v  a2 s  .c  o  m*/
    layout.marginWidth = 0;
    top.setLayout(layout);

    GridData gd = new GridData();
    gd.verticalAlignment = SWT.TOP;
    top.setLayoutData(gd);

    // top banner
    Composite banner = new Composite(top, SWT.NONE);
    banner.setLayoutData(
            new GridData(GridData.HORIZONTAL_ALIGN_FILL, GridData.VERTICAL_ALIGN_BEGINNING, true, false));
    layout = new GridLayout();
    layout.marginHeight = 5;
    layout.marginWidth = 10;
    layout.numColumns = 2;
    banner.setLayout(layout);

    // setup bold font
    Font boldFont = JFaceResources.getFontRegistry().getBold(JFaceResources.DEFAULT_FONT);

    Label l = new Label(banner, SWT.WRAP);
    l.setText("Subject:");
    l.setFont(boldFont);
    l = new Label(banner, SWT.WRAP);
    l.setText(pEmail.getSubject());

    l = new Label(banner, SWT.WRAP);
    l.setText("From:");
    l.setFont(boldFont);

    final Link link = new Link(banner, SWT.NONE);
    link.setText("<a>" + pEmail.getSender() + "</a>");
    link.addSelectionListener(new SelectionAdapter() {
        /**
         * Serial id.
         */
        private static final long serialVersionUID = -2734992566910878564L;

        public void widgetSelected(SelectionEvent e) {
            MessageBox messageBox = new MessageBox(parent.getShell(), SWT.YES);
            messageBox.setMessage(
                    "Not Implemented\n" + "Imagine the address book or a new message being created now.");
            DialogUtil.open(messageBox, new DialogCallback() {
                /**
                 * Serial id.
                 */
                private static final long serialVersionUID = -8172492596304353383L;

                public void dialogClosed(int returnCode) {
                    System.out.println("Yessss!");
                }
            });
        }
    });

    l = new Label(banner, SWT.WRAP);
    l.setText("Date:");
    l.setFont(boldFont);
    l = new Label(banner, SWT.WRAP);
    l.setText("10:34 am");
    // message contents
    Text text = new Text(top, SWT.MULTI | SWT.WRAP);
    text.setText(pEmail.getMessage());
    text.setLayoutData(new GridData(GridData.FILL_BOTH));
    view = top;
}

From source file:net.refractions.udig.catalog.internal.wmt.ui.wizard.controls.CSControl.java

License:Open Source License

@Override
protected Control buildControl(Composite composite) {
    Composite control = new Composite(composite, SWT.NONE);
    control.setLayout(new RowLayout(SWT.VERTICAL));

    //region Description
    Link text = new Link(control, SWT.HORIZONTAL | SWT.WRAP);
    text.setLayoutData(new RowData(400, 110));
    text.setText(Messages.Wizard_CS_Description);
    text.addListener(SWT.Selection, new Listener() {
        public void handleEvent(Event event) {
            Program.launch(Messages.Wizard_CS_UrlTileNames);
        }//from  ww w .  j ava 2 s .  c om
    });
    //endregion

    //region URL
    Label lblUrl = new Label(control, SWT.HORIZONTAL | SWT.BOLD);
    lblUrl.setText(Messages.Wizard_CS_Url);

    Font boldFont = JFaceResources.getFontRegistry().getBold(JFaceResources.DEFAULT_FONT);
    lblUrl.setFont(boldFont);

    txtUrl = new Text(control, SWT.BORDER);
    txtUrl.setLayoutData(new RowData(380, 20));
    txtUrl.setText(Messages.Wizard_CS_UrlDefault);
    //endregion

    // type
    typeButton = new Button(control, SWT.CHECK);
    typeButton.setLayoutData(new RowData(380, 20));
    typeButton.setText("Handle as TMS as opposed to Google tile schema.");
    // end type

    //region Zoom-Range
    Composite compositeRow = new Composite(control, SWT.NONE);
    compositeRow.setLayout(new RowLayout(SWT.HORIZONTAL));

    Composite compositeZoom = new Composite(compositeRow, SWT.NONE);
    compositeZoom.setLayout(new RowLayout(SWT.VERTICAL));
    compositeZoom.setLayoutData(new RowData(200, 100));

    Label lblZoom = new Label(compositeZoom, SWT.HORIZONTAL | SWT.BOLD);
    lblZoom.setText(Messages.Wizard_CS_ZoomLevel);
    lblZoom.setFont(boldFont);

    //region Zoom-Min
    Composite compositeRowZoom = new Composite(compositeZoom, SWT.NONE);
    compositeRowZoom.setLayout(new GridLayout(2, true));
    Label lblZoomMin = new Label(compositeRowZoom, SWT.HORIZONTAL | SWT.BOLD);
    lblZoomMin.setText(Messages.Wizard_CS_Min);

    spZoomMin = new Spinner(compositeRowZoom, SWT.BORDER | SWT.READ_ONLY);
    spZoomMin.setMinimum(0);
    spZoomMin.setMaximum(22);
    spZoomMin.setSelection(2);
    spZoomMin.setIncrement(1);
    spZoomMin.pack();
    //endregion

    //region Zoom-Max
    Label lblZoomMax = new Label(compositeRowZoom, SWT.HORIZONTAL | SWT.BOLD);
    lblZoomMax.setText(Messages.Wizard_CS_Max);

    spZoomMax = new Spinner(compositeRowZoom, SWT.BORDER | SWT.READ_ONLY);
    spZoomMax.setMinimum(0);
    spZoomMax.setMaximum(22);
    spZoomMax.setSelection(18);
    spZoomMax.setIncrement(1);
    spZoomMax.pack();
    //endregion
    //endregion

    //region Tags
    Composite compositeTags = new Composite(compositeRow, SWT.NONE);
    compositeTags.setLayout(new RowLayout(SWT.VERTICAL));

    Label lblTags = new Label(compositeTags, SWT.HORIZONTAL | SWT.BOLD);
    lblTags.setText(Messages.Wizard_CS_AvailableTags);
    lblTags.setFont(boldFont);

    Label lblTagZ = new Label(compositeTags, SWT.HORIZONTAL | SWT.BOLD);
    lblTagZ.setText(Messages.Wizard_CS_TagZoom);

    Label lblTagX = new Label(compositeTags, SWT.HORIZONTAL | SWT.BOLD);
    lblTagX.setText(Messages.Wizard_CS_TagX);

    Label lblTagY = new Label(compositeTags, SWT.HORIZONTAL | SWT.BOLD);
    lblTagY.setText(Messages.Wizard_CS_TagY);
    //endregion

    serviceExtension = new WMTServiceExtension();
    this.control = control;

    return control;
}

From source file:net.refractions.udig.catalog.internal.wmt.ui.wizard.controls.JGrasstoolsTmsFolderControl.java

License:Open Source License

@Override
protected Control buildControl(Composite composite) {
    final Composite control = new Composite(composite, SWT.NONE);
    control.setLayout(new GridLayout(2, false));

    // region Description
    Link text = new Link(control, SWT.HORIZONTAL | SWT.WRAP);
    GridData textGD = new GridData(SWT.FILL, SWT.FILL, true, false);
    textGD.horizontalSpan = 2;/*  w w w .j  a  v  a2 s.  c o m*/
    text.setLayoutData(textGD);
    text.setText(
            "Here you can load a TMS tiles folder that was exported with the Spatial Toolbox and the JGrasstools tiler.");
    // endregion

    Label lblUrl = new Label(control, SWT.HORIZONTAL | SWT.BOLD);
    lblUrl.setText("Select the tiles file definition (*.mapurl)");
    Font boldFont = JFaceResources.getFontRegistry().getBold(JFaceResources.DEFAULT_FONT);
    lblUrl.setFont(boldFont);
    GridData lblUrlGD = new GridData(SWT.FILL, SWT.FILL, true, false);
    lblUrlGD.horizontalSpan = 2;
    lblUrl.setLayoutData(lblUrlGD);

    txtUrl = new Text(control, SWT.BORDER);
    txtUrl.setLayoutData(new RowData(380, 20));
    GridData txtUrlGD = new GridData(SWT.FILL, SWT.FILL, true, false);
    txtUrl.setLayoutData(txtUrlGD);
    Button browseButton = new Button(control, SWT.PUSH);
    browseButton.setLayoutData(new GridData(SWT.END, SWT.FILL, false, false));
    browseButton.setText("...");
    browseButton.addSelectionListener(new org.eclipse.swt.events.SelectionAdapter() {
        public void widgetSelected(org.eclipse.swt.events.SelectionEvent e) {
            FileDialog fileDialog = new FileDialog(control.getShell(), SWT.OPEN);
            String path = fileDialog.open();
            if (path == null || path.length() < 1) {
                txtUrl.setText("");
            } else {
                txtUrl.setText(path);
            }
        }
    });

    serviceExtension = new WMTServiceExtension();
    this.control = control;
    return control;
}

From source file:net.refractions.udig.catalog.internal.wmt.ui.wizard.controls.OSMCloudMadeControl.java

License:Open Source License

@Override
protected Control buildControl(Composite infoBox) {
    display = infoBox.getDisplay();//from   w w w  .j  a va 2s .  com
    Composite composite = new Composite(infoBox, SWT.NONE);
    composite.setLayout(new RowLayout(SWT.VERTICAL));

    //region Get Style From Groups
    btnStyleGroups = new Button(composite, SWT.RADIO);
    btnStyleGroups.setSelection(true);
    btnStyleGroups.setText(Messages.Wizard_CloudMade_StyleFromGroup);
    btnStyleGroups.addSelectionListener(radioSelectionListener);

    Composite compositeGroups = new Composite(composite, SWT.NONE);
    compositeGroups.setLayout(new RowLayout(SWT.HORIZONTAL));

    gBCloudMade = new Group(compositeGroups, SWT.BORDER);
    gBCloudMade.setLayout(new RowLayout(SWT.VERTICAL));
    gBCloudMade.setText(Messages.Wizard_CloudMade_GroupCloudMade);

    lvCloudMade = new ListViewer(gBCloudMade);
    lvCloudMade.getList().setLayoutData(new RowData(180, 80));
    lvCloudMade.setContentProvider(new ArrayContentProvider());
    lvCloudMade.setLabelProvider(new LabelProvider());

    gBCloudMade.pack();

    gBFeatured = new Group(compositeGroups, SWT.BORDER);
    gBFeatured.setLayout(new RowLayout(SWT.VERTICAL));
    gBFeatured.setText(Messages.Wizard_CloudMade_GroupFeatured);

    lvFeatured = new ListViewer(gBFeatured);
    lvFeatured.getList().setLayoutData(new RowData(180, 80));
    lvFeatured.setContentProvider(new ArrayContentProvider());
    lvFeatured.setLabelProvider(new LabelProvider());

    gBFeatured.pack();
    //endregion

    //region Get Style From Id
    Button btnOwnStyle = new Button(composite, SWT.RADIO);
    btnOwnStyle.setText(Messages.Wizard_CloudMade_StyleFromId);

    Composite compositeStyleId = new Composite(composite, SWT.NONE);
    compositeStyleId.setLayout(new RowLayout(SWT.HORIZONTAL));

    lblStyleIdField = new Label(compositeStyleId, SWT.HORIZONTAL);
    lblStyleIdField.setText(Messages.Wizard_CloudMade_StyleId);

    txtStyleId = new Text(compositeStyleId, SWT.BORDER);
    txtStyleId.setBounds(10, 10, 200, 200);
    txtStyleId.setText(Messages.Wizard_CloudMade_DefaultStyleId);

    txtStyleId.addKeyListener(new KeyListener() {
        public void keyPressed(KeyEvent event) {
            if ((event.keyCode == SWT.CR) || (event.keyCode == SWT.KEYPAD_CR)) {
                updatePreview();
            }
        }

        public void keyReleased(KeyEvent arg0) {
        }
    });

    txtStyleId.addListener(SWT.Verify, new Listener() {
        public void handleEvent(Event e) {
            String input = e.text;
            for (int i = 0; i < input.length(); i++) {
                if (!('0' <= input.charAt(i) && input.charAt(i) <= '9')) {
                    e.doit = false;
                    return;
                }
            }
        }
    });

    btnRefresh = new Button(compositeStyleId, SWT.PUSH);
    btnRefresh.setText(Messages.Wizard_CloudMade_RefreshPreview);
    btnRefresh.addSelectionListener(new SelectionAdapter() {
        public void widgetSelected(SelectionEvent e) {
            updatePreview();
        }
    });

    link = new Link(composite, SWT.BORDER);
    link.setText(Messages.Wizard_CloudMade_StyleEditorInfo);
    link.setLayoutData(new RowData(400, 50));
    link.addListener(SWT.Selection, new Listener() {
        public void handleEvent(Event event) {
            Program.launch("http://maps.cloudmade.com/editor"); //$NON-NLS-1$
        }
    });
    //endregion

    //region Preview
    Group gBPreview = new Group(composite, SWT.BORDER);
    gBPreview.setLayout(new RowLayout(SWT.HORIZONTAL));
    gBPreview.setText(Messages.Wizard_CloudMade_Preview);

    Composite compositeStyleInfo = new Composite(gBPreview, SWT.NONE);
    compositeStyleInfo.setLayout(new RowLayout(SWT.VERTICAL));
    compositeStyleInfo.setLayoutData(new RowData(180, 160));

    Label lblStyleName = new Label(compositeStyleInfo, SWT.HORIZONTAL | SWT.BOLD);
    lblStyleName.setText(Messages.Wizard_CloudMade_PreviewName);
    Font boldFont = JFaceResources.getFontRegistry().getBold(JFaceResources.DEFAULT_FONT);
    lblStyleName.setFont(boldFont);

    lblStyleNameValue = new Label(compositeStyleInfo, SWT.HORIZONTAL);
    lblStyleNameValue.setText(""); //$NON-NLS-1$

    Label lblStyleId = new Label(compositeStyleInfo, SWT.HORIZONTAL);
    lblStyleId.setText(Messages.Wizard_CloudMade_PreviewId);
    lblStyleId.setFont(boldFont);

    lblStyleIdValue = new Label(compositeStyleInfo, SWT.HORIZONTAL);
    lblStyleIdValue.setText(""); //$NON-NLS-1$

    Label lblStyleAuthor = new Label(compositeStyleInfo, SWT.HORIZONTAL);
    lblStyleAuthor.setText(Messages.Wizard_CloudMade_PreviewAuthor);
    lblStyleAuthor.setFont(boldFont);

    lblStyleAuthorValue = new Label(compositeStyleInfo, SWT.HORIZONTAL);
    lblStyleAuthorValue.setText(""); //$NON-NLS-1$

    previewImage = new Composite(gBPreview, SWT.NONE);
    previewImage.setLayoutData(new RowData(233, 160));
    previewImage.setCursor(new Cursor(display, SWT.CURSOR_HAND));
    previewImage.setToolTipText(Messages.Wizard_CloudMade_PreviewGetFullMap);
    previewImage.addMouseListener(new MouseListener() {

        public void mouseDoubleClick(MouseEvent arg0) {
        }

        public void mouseUp(MouseEvent arg0) {
        }

        public void mouseDown(MouseEvent arg0) {
            if (!previewStyleId.equals(OSMCloudMadeStylesManager.CloudMadeStyle.EMPTY_STYLE_ID)) {
                Program.launch("http://maps.cloudmade.com/?lat=51.508315&lng=-0.124712&zoom=14&styleId=" //$NON-NLS-1$
                        + previewStyleId);
            }
        }
    });

    gBPreview.pack();
    //endregion

    //region Load group styles
    stylesManager = new OSMCloudMadeStylesManager();

    // Group CloudMade
    styleGroupCloudMade = stylesManager.getGroupCloudMade();
    lvCloudMade.setInput(styleGroupCloudMade.getStyles());

    // Group Featured
    styleGroupFeatured = stylesManager.getGroupFeatured();
    lvFeatured.setInput(styleGroupFeatured.getStyles());

    // Select default style
    if (styleGroupCloudMade.getStyles().size() > 0) {
        lvCloudMade.getList().setSelection(0);
    }
    //endregion

    //region Set up image cache
    imageCache = new ImageRegistry(display);

    // load default image
    ImageDescriptor descDefault = ImageDescriptor.createFromFile(getClass(),
            OSMCloudMadeStylesManager.IMG_DEFAULT);
    imageCache.put(OSMCloudMadeStylesManager.CloudMadeStyle.EMPTY_STYLE_ID, descDefault);

    // load loading image
    ImageDescriptor descLoading = ImageDescriptor.createFromFile(getClass(),
            OSMCloudMadeStylesManager.IMG_LOADING);
    imageCache.put(OSMCloudMadeStylesManager.IMG_LOADING, descLoading);
    //endregion

    //region Set up listeners
    lvCloudMade.getList().addSelectionListener(listSelectionListener);
    lvFeatured.getList().addSelectionListener(listSelectionListener);
    radioSelectionListener.widgetSelected(null);
    //endregion

    serviceExtension = new WMTServiceExtension();

    control = composite;

    return composite;
}

From source file:net.refractions.udig.feature.panel.FeaturePanelList.java

License:Open Source License

/**
 * Get the dimensions of the provided string.
 * /*from ww w.  ja va  2 s .  co m*/
 * @param text
 *            the string.
 * @return the dimensions of the provided string.
 */
private Point getTextDimension(String text) {
    GC gc = new GC(this);
    gc.setFont(JFaceResources.getFontRegistry().getBold(JFaceResources.DEFAULT_FONT));
    Point point = gc.textExtent(text);
    point.x++;
    gc.dispose();
    return point;
}

From source file:net.refractions.udig.feature.panel.FeaturePanelTitle.java

License:Open Source License

/**
 * Constructor for TabbedPropertyTitle.//from   w  w w  .  j a  v a2  s. co m
 * 
 * @param parent the parent composite.
 * @param factory2 the widget factory for the tabbed property sheet
 */
public FeaturePanelTitle(Composite parent, FeaturePanelWidgetFactory factory) {
    super(parent, SWT.NO_FOCUS);
    this.factory = factory;

    this.addPaintListener(new PaintListener() {

        public void paintControl(PaintEvent e) {
            if (image == null && (text == null || text.equals(BLANK))) {
                label.setVisible(false);
            } else {
                label.setVisible(true);
                drawTitleBackground(e);
            }
        }
    });

    factory.getColors().initializeSectionToolBarColors();
    setBackground(factory.getColors().getBackground());
    setForeground(factory.getColors().getForeground());

    FormLayout layout = new FormLayout();
    layout.marginWidth = 1;
    layout.marginHeight = 2;
    setLayout(layout);

    Font font;
    if (!JFaceResources.getFontRegistry().hasValueFor(TITLE_FONT)) {
        FontData[] fontData = JFaceResources.getFontRegistry().getBold(JFaceResources.DEFAULT_FONT)
                .getFontData();
        /* title font is 2pt larger than that used in the tabs. */
        fontData[0].setHeight(fontData[0].getHeight() + 2);
        JFaceResources.getFontRegistry().put(TITLE_FONT, fontData);
    }
    font = JFaceResources.getFont(TITLE_FONT);

    label = factory.createCLabel(this, BLANK);
    label.setBackground(new Color[] { factory.getColors().getColor(IFormColors.H_GRADIENT_END),
            factory.getColors().getColor(IFormColors.H_GRADIENT_START) }, new int[] { 100 }, true);
    label.setFont(font);
    label.setForeground(factory.getColors().getColor(IFormColors.TITLE));
    FormData data = new FormData();
    data.left = new FormAttachment(0, 0);
    data.top = new FormAttachment(0, 0);
    data.right = new FormAttachment(100, 0);
    data.bottom = new FormAttachment(100, 0);
    label.setLayoutData(data);

    /*
     * setImage(PlatformUI.getWorkbench().getSharedImages().getImage(
     * ISharedImages.IMG_OBJ_ELEMENT));
     */
}