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:com.bluexml.side.Portal.modeler.diagram.edit.PortletInternalEditPart.java

License:Open Source License

/**
 * Set the name of the PortletInternal// ww w  . ja va2s .  com
 * 
 * @see org.topcased.modeler.edit.EMFGraphNodeEditPart#refreshHeaderLabel()
 */
protected void refreshHeaderLabel() {
    IFigure ifig = getFigure();
    if (ifig instanceof PortletInternalFigure) {
        PortletInternalFigure fig = (PortletInternalFigure) ifig;
        ILabel lbl = fig.getLabel();
        PortletInternal pi = (PortletInternal) Utils.getElement(getGraphNode());
        String textLabel = getPortletInternalLabel(pi);
        lbl.setText(textLabel);

        lbl.setFont(JFaceResources.getFontRegistry().get("BoldFont"));
    }
}

From source file:com.bluexml.side.Portal.modeler.diagram.edit.PortletTypeEditPart.java

License:Open Source License

/**
 * Set the name of the PortletType// www. j a va2 s. c o m
 * 
 * @see org.topcased.modeler.edit.EMFGraphNodeEditPart#refreshHeaderLabel()
 */
protected void refreshHeaderLabel() {
    IFigure ifig = getFigure();
    if (ifig instanceof PortletTypeFigure) {
        PortletTypeFigure fig = (PortletTypeFigure) ifig;
        ILabel lbl = fig.getLabel();
        PortletType po = (PortletType) Utils.getElement(getGraphNode());

        lbl.setText(po.getName());
        lbl.setFont(JFaceResources.getFontRegistry().get("BoldFont"));
    }
}

From source file:com.bluexml.side.Requirements.modeler.goalDiagram.edit.EntityEditPart.java

License:Open Source License

@Override
protected Font getDefaultFont() {
    FontData[] fData = Display.getDefault().getSystemFont().getFontData();
    fData[0].setStyle(SWT.BOLD);/* www.  j a  v  a 2 s  .c om*/
    fData[0].setHeight(18);
    JFaceResources.getFontRegistry().put("BoldFont", fData);
    return JFaceResources.getFontRegistry().get("BoldFont");
}

From source file:com.bluexml.side.Requirements.modeler.goalDiagram.edit.PrivilegeEditPart.java

License:Open Source License

@Override
protected void refreshTextAndFont() {
    super.refreshTextAndFont();
    Privilege p = (Privilege) Utils.getElement(getGraphNode());
    getLabel().setText(createLabel(p));//www.j  a v a2s.  c  om

    if (p.getElement() instanceof Entity) {
        FontData[] fData = Display.getDefault().getSystemFont().getFontData();
        fData[0].setStyle(SWT.BOLD);
        JFaceResources.getFontRegistry().put("font", fData);
        getLabel().setFont(JFaceResources.getFontRegistry().get("font"));
        ((Label) getLabel()).setAlignment(Label.LEFT);

        URL url = null;
        Image image;
        try {
            url = new URL(RequirementsPlugin.getDefault().getDescriptor().getInstallURL(),
                    "icons/EntityLittle.png");
            image = ImageDescriptor.createFromURL(url).createImage();
            ((Label) getLabel()).setIcon(image);
        } catch (MalformedURLException e) {
        }
    } else {
        FontData[] fData = Display.getDefault().getSystemFont().getFontData();
        fData[0].setStyle(SWT.ITALIC);
        JFaceResources.getFontRegistry().put("font", fData);
        getLabel().setFont(JFaceResources.getFontRegistry().get("font"));
        ((Label) getLabel()).setAlignment(Label.LEFT);

        URL url = null;
        Image image;
        try {
            url = new URL(RequirementsPlugin.getDefault().getDescriptor().getInstallURL(),
                    "icons/AttributeLittle.png");
            image = ImageDescriptor.createFromURL(url).createImage();
            ((Label) getLabel()).setIcon(image);
        } catch (MalformedURLException e) {
        }
    }
}

From source file:com.buildml.eclipse.utils.properties.SlotValuePropertyPage.java

License:Open Source License

/**
 * Create the widgets that appear within the properties dialog box. For this property
 * page, we list all of the slots, along with their associated values.
 *///  w w  w  . j  a va  2 s .c  o m
@Override
protected Control createContents(Composite parent) {

    IBuildStore buildStore = EclipsePartUtils.getActiveBuildStore();
    pkgMgr = buildStore.getPackageMgr();
    subPkgMgr = buildStore.getSubPackageMgr();
    fileMgr = buildStore.getFileMgr();

    /* 
     * Determine which "thing" (UISubPackage or UIAction) we're looking at, then
     * compute the corresponding pkgId or actionTypeId that this "thing" is an
     * instance of.
     */
    UISubPackage subPkg = (UISubPackage) GraphitiUtils.getBusinessObjectFromElement(getElement(),
            UISubPackage.class);
    if (subPkg == null) {
        return null;
    }
    subPkgId = subPkg.getId();
    int pkgId = subPkgMgr.getSubPackageType(subPkgId);
    if (pkgId < 0) {
        return null;
    }

    /* fetch the "parameter" slots, and sort them alphabetically */
    SlotDetails[] paramSlots = pkgMgr.getSlots(pkgId, ISlotTypes.SLOT_POS_PARAMETER);
    Arrays.sort(paramSlots, new Comparator<SlotDetails>() {
        @Override
        public int compare(SlotDetails arg0, SlotDetails arg1) {
            return arg0.slotName.compareTo(arg1.slotName);
        }
    });

    /* prepare the top-level Composite in which everything else is placed */
    setTitle("Sub-Package Properties:");

    /* put everything inside a scrolled composite, in case we have a very long list of slots */
    ScrolledComposite scrolledComposite = new ScrolledComposite(parent, SWT.BORDER | SWT.V_SCROLL);
    scrolledComposite.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true));
    scrolledComposite.setLayout(new GridLayout());
    scrolledComposite.setAlwaysShowScrollBars(true);

    /* create a sub-composite that contains all the slot details */
    Composite panel = new Composite(scrolledComposite, SWT.NONE);
    panel.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true));
    GridLayout layout = new GridLayout();
    layout.marginHeight = 0;
    layout.marginWidth = 0;
    panel.setLayout(layout);

    /*
     * For each slot, display a group box, the slot's name and description,
     * and then an appropriate set of controls to allow editing of the
     * field's value.
     */
    for (int i = 0; i < paramSlots.length; i++) {

        SlotDetails details = paramSlots[i];

        /* add group-box around each slot's information */
        Group group = new Group(panel, SWT.BORDER);
        group.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, false));
        group.setLayout(new GridLayout());

        /* display the slot title - centered and bolded */
        Label title = new Label(group, SWT.CENTER);
        title.setLayoutData(new GridData(SWT.CENTER, SWT.None, true, false));
        title.setText(details.slotName);
        title.setFont(JFaceResources.getFontRegistry().getBold(""));

        /* display the description - wrapped */
        Label descr = new Label(group, SWT.WRAP);
        GridData gd = new GridData(GridData.FILL_BOTH);
        gd.widthHint = EclipsePartUtils.getScreenWidth() / 3;
        descr.setLayoutData(gd);
        descr.setText(details.slotDescr);

        /* fetch the slot's current value */
        boolean isSlotSet = subPkgMgr.isSlotSet(subPkgId, details.slotId);
        Object slotValue = subPkgMgr.getSlotValue(subPkgId, details.slotId);

        /*
         * For each slot type, provide the ability to edit the current value.
         */
        switch (details.slotType) {

        /* Integer-typed slots */
        case ISlotTypes.SLOT_TYPE_INTEGER:
            createIntegerEditor(group, details, isSlotSet, (Integer) details.defaultValue, (Integer) slotValue);
            break;

        /* Text-typed slots */
        case ISlotTypes.SLOT_TYPE_TEXT:
            createTextEditor(group, details, isSlotSet, (String) details.defaultValue, (String) slotValue);
            break;

        /* Boolean-typed slots */
        case ISlotTypes.SLOT_TYPE_BOOLEAN:
            createBooleanEditor(group, details, isSlotSet, (Boolean) details.defaultValue, (Boolean) slotValue);
            break;

        /* File-typed slots */
        case ISlotTypes.SLOT_TYPE_FILE:
            createFileDirEditor(group, details, isSlotSet, (Integer) details.defaultValue, (Integer) slotValue,
                    true);
            break;

        /* Directory-typed slots */
        case ISlotTypes.SLOT_TYPE_DIRECTORY:
            createFileDirEditor(group, details, isSlotSet, (Integer) details.defaultValue, (Integer) slotValue,
                    false);
            break;

        default:
            /* do nothing */
        }
    }

    /* tell the ScrolledComposite what it's managing, and how big it should be. */
    scrolledComposite.setContent(panel);
    scrolledComposite.setExpandHorizontal(true);
    scrolledComposite.setMinWidth(0);
    panel.setSize(panel.computeSize(SWT.DEFAULT, SWT.DEFAULT));

    return scrolledComposite;
}

From source file:com.byterefinery.rmbench.export.ModelCompareEditor.java

License:Open Source License

public void createPartControl(Composite parent) {
    splitter = new Splitter(parent, SWT.VERTICAL);

    CompareViewerPane upperPane = new CompareViewerPane(splitter, SWT.BORDER | SWT.FLAT);
    diffViewer = new ModelDiffViewer(upperPane, compareConfig);

    upperPane.setContent(diffViewer.getControl());
    upperPane.setText(Messages.StructurePane_Title);
    upperPane.setImage(RMBenchPlugin.getImage(ImageConstants.MODEL));
    diffViewer.addSelectionChangedListener(diffSelectionChangedListener);
    diffViewer.addDoubleClickListener(new IDoubleClickListener() {

        public void doubleClick(DoubleClickEvent event) {
            IStructuredSelection selection = (IStructuredSelection) event.getSelection();
            DiffNode diffNode = (DiffNode) selection.getFirstElement();
            IModelComparisonNode modelNode = (IModelComparisonNode) diffNode.getLeft();
            if (modelNode != null && modelNode.getValue() != null) {
                IDBComparisonNode dbNode = (IDBComparisonNode) diffNode.getRight();
                if (dbNode != null && dbNode.getValue() != null) {
                    CompareValuesDialog dialog = new CompareValuesDialog(getSite().getShell(),
                            modelNode.getValue(), dbNode.getValue());
                    dialog.open();//from w w w  . j a  va 2 s.  c o  m
                }
            }
        }
    });
    diffViewer.addListener(new ModelDiffViewer.Listener() {

        public void nodesRemoved(DiffNode node) {
            ModelCompareEditorInput input = (ModelCompareEditorInput) getEditorInput();
            input.reset();
            try {
                documentProvider.resetDocument(input);
                annotationModel = (AnnotationModel) documentProvider.getAnnotationModel(input);
                sourceViewer.setDocument(documentProvider.getDocument(input), annotationModel);
                sourceViewer.invalidateTextPresentation();
            } catch (CoreException e) {
                RMBenchPlugin.logError(e);
            }
        }
    });
    ModelCompareEditorInput mceInput = (ModelCompareEditorInput) getEditorInput();
    diffViewer.setInput(mceInput.getCompareResult());
    diffViewer.setModel(mceInput.getModel());

    CompareViewerPane lowerPane = new CompareViewerPane(splitter, SWT.BORDER | SWT.FLAT);

    scriptUtil = new ScriptUtil(mceInput.getStatementTerminator());

    createSourceViewer(lowerPane, mceInput);
    createActions(lowerPane);

    //the first line below is only symbolic - script font is not configurable
    PreferenceHandler.addPreferenceChangeListener(preferenceListener);
    //for now, sync with JFace default text font
    JFaceResources.getFontRegistry().addListener(preferenceListener);

    splitter.setWeights(new int[] { 30, 70 });
    splitter.layout();
}

From source file:com.byterefinery.rmbench.export.ModelCompareEditor.java

License:Open Source License

public void dispose() {
    super.dispose();
    connectionListener.unregister();//w  ww  . ja  v a  2s  . co m
    annotationPainter.dispose();

    documentProvider.disconnect(getEditorInput());
    documentProvider.removeElementStateListener(elementStateListener);

    dbmodelContribution.closeExecutors();

    undoRedoGroup.dispose();

    PreferenceHandler.removePreferenceChangeListener(preferenceListener);
    JFaceResources.getFontRegistry().removeListener(preferenceListener);
}

From source file:com.cisco.yangide.editor.editors.text.help.HelpCompositionUtils.java

License:Open Source License

/**
 * Returns a stylesheet used among quick-help infopopups. 
 *//*  ww  w .  j  a  va 2s. c o m*/
private static String getStyleSheet() {
    if (styleSheet == null) {
        styleSheet = YangEditorPlugin.getDefault().getBundleFileContent("/resources/HoverStyleSheet.css");
    }
    String css = styleSheet;
    if (css != null) {
        FontData fontData = JFaceResources.getFontRegistry()
                .getFontData(PreferenceConstants.APPEARANCE_JAVADOC_FONT)[0];
        css = HTMLPrinter.convertTopLevelFont(css, fontData);
    }

    return css;
}

From source file:com.cisco.yangide.editor.preferences.AbstractConfigurationBlock.java

License:Open Source License

protected void updateSectionStyle(ExpandableComposite excomposite) {
    excomposite.setFont(JFaceResources.getFontRegistry().getBold(JFaceResources.DIALOG_FONT));
}

From source file:com.cisco.yangide.editor.preferences.YangPreviewerUpdater.java

License:Open Source License

/**
 * Creates a Java source preview updater for the given viewer, configuration and preference
 * store./*from   w  w w  .  j  a v a2s  .co  m*/
 *
 * @param viewer the viewer
 * @param configuration the configuration
 * @param preferenceStore the preference store
 */
public YangPreviewerUpdater(final SourceViewer viewer, final YangSourceViewerConfiguration configuration,
        final IPreferenceStore preferenceStore) {
    Assert.isNotNull(viewer);
    Assert.isNotNull(configuration);
    Assert.isNotNull(preferenceStore);
    final IPropertyChangeListener fontChangeListener = new IPropertyChangeListener() {
        /*
         * @see
         * org.eclipse.jface.util.IPropertyChangeListener#propertyChange(org.eclipse.jface.util
         * .PropertyChangeEvent)
         */
        public void propertyChange(PropertyChangeEvent event) {
            if (event.getProperty().equals(PreferenceConstants.EDITOR_TEXT_FONT)) {
                Font font = JFaceResources.getFont(PreferenceConstants.EDITOR_TEXT_FONT);
                viewer.getTextWidget().setFont(font);
            }
        }
    };
    final IPropertyChangeListener propertyChangeListener = new IPropertyChangeListener() {
        /*
         * @see
         * org.eclipse.jface.util.IPropertyChangeListener#propertyChange(org.eclipse.jface.util
         * .PropertyChangeEvent)
         */
        public void propertyChange(PropertyChangeEvent event) {
            if (configuration.affectsTextPresentation(event)) {
                configuration.handlePropertyChangeEvent(event);
                viewer.invalidateTextPresentation();
            }
        }
    };
    viewer.getTextWidget().addDisposeListener(new DisposeListener() {
        /*
         * @see
         * org.eclipse.swt.events.DisposeListener#widgetDisposed(org.eclipse.swt.events.DisposeEvent
         * )
         */
        public void widgetDisposed(DisposeEvent e) {
            preferenceStore.removePropertyChangeListener(propertyChangeListener);
            JFaceResources.getFontRegistry().removeListener(fontChangeListener);
        }
    });
    JFaceResources.getFontRegistry().addListener(fontChangeListener);
    preferenceStore.addPropertyChangeListener(propertyChangeListener);
}