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.axmor.eclipse.typescript.editor.hover.TypeScriptTextHover.java

License:Open Source License

protected String getCSSStyles() {
    if (cssStyle == null) {
        Bundle bundle = Platform.getBundle(Activator.PLUGIN_ID);
        URL url = bundle.getEntry("/css/JavadocHoverStyleSheet.css"); //$NON-NLS-1$
        if (url != null) {
            BufferedReader reader = null;
            try {
                url = FileLocator.toFileURL(url);
                reader = new BufferedReader(new InputStreamReader(url.openStream()));
                StringBuffer buffer = new StringBuffer(200);
                String line = reader.readLine();
                while (line != null) {
                    buffer.append(line);
                    buffer.append('\n');
                    line = reader.readLine();
                }//from   w w w  .  j a  v  a  2 s.c om
                cssStyle = buffer.toString();
            } catch (IOException ex) {
            } finally {
                try {
                    if (reader != null)
                        reader.close();
                } catch (IOException e) {
                }
            }

        }
    }
    String css = cssStyle;
    if (css != null) {
        FontData fontData = JFaceResources.getFontRegistry()
                .getFontData(PreferenceConstants.APPEARANCE_JAVADOC_FONT)[0];
        css = HTMLPrinter.convertTopLevelFont(css, fontData);
    }
    return css;
}

From source file:com.axmor.eclipse.typescript.editor.preferences.ColorEditor.java

License:Open Source License

protected Point computeImageSize(Control window) {
    GC gc = new GC(window);
    Font f = JFaceResources.getFontRegistry().get(JFaceResources.DEFAULT_FONT);
    gc.setFont(f);/*from ww w .  j  av  a  2  s .c o m*/
    int height = gc.getFontMetrics().getHeight();
    gc.dispose();
    Point p = new Point(height * 3 - 6, height);
    return p;
}

From source file:com.bdaum.zoom.css.ZColumnLabelProvider.java

License:Open Source License

protected void paint(Event event, Object element) {
    GC gc = event.gc;/*from  w w  w .j  a va 2s .  c  o  m*/
    tooltip = null;
    Rectangle iconSize = getIconBounds();
    Image image = getImage(element);
    int iconWidth = iconSize != null ? iconSize.width : -1;
    int iconHeight = iconSize != null ? iconSize.height : -1;
    int rowHeight = Math.max(iconHeight, event.height);
    double fac = 1d;
    if (image != null) {
        if (iconSize == null) {
            iconSize = image.getBounds();
            iconWidth = iconSize.width;
            iconHeight = iconSize.height;
            rowHeight = Math.max(iconHeight, event.height);
        } else {
            Rectangle bounds = image.getBounds();
            fac = Math.min(((double) iconWidth) / bounds.width, ((double) iconHeight) / bounds.height);
            iconSize = bounds;
            iconWidth = iconSize.width;
            iconHeight = iconSize.height;
            rowHeight = Math.max(iconHeight, event.height);
        }
    }
    String text = getText(element);
    if (text != null) {
        Font customFont;
        Color foreground, background;
        if ((event.detail & SWT.SELECTED) != 0) {
            customFont = getSelectionFont(element);
            foreground = getSelectedForeground(element);
            background = getSelectedBackground(element);
        } else {
            customFont = getFont(element);
            foreground = getForeground(element);
            background = getBackground(element);
        }
        if (customFont != null)
            gc.setFont(customFont);
        else if ((event.detail & SWT.SELECTED) != 0)
            gc.setFont(JFaceResources.getFontRegistry().get("com.bdaum.zoom.selectionFont")); //$NON-NLS-1$
        else
            gc.setFont(JFaceResources.getDefaultFont());
        gc.setForeground(foreground);
        gc.setBackground(background);
        Point textExtent = gc.textExtent(text);
        if (iconHeight < 0)
            iconHeight = event.height;
        int x = (int) (event.x + iconWidth * fac + 4);
        int mxWidth = getColumnWidth() - x + getColumnXOrigin();
        String shortened = shortenText(element, text, textExtent.x, gc, mxWidth);
        if (shortened.length() < text.length())
            tooltip = text;
        int ty = event.y + (rowHeight - textExtent.y) / 2;
        if (element instanceof ITitle) {
            Point tx = gc.stringExtent(shortened);
            int len = tx.x;
            if (len < mxWidth)
                x += (mxWidth - len) / 2;
            int th = ty + tx.y / 2;
            gc.drawLine(0, th, mxWidth, th);
            gc.drawLine(0, th + 2, mxWidth, th + 2);
        }
        gc.drawText(shortened, x, ty, (event.detail & SWT.SELECTED) != 0);
    }
    if (image != null) {
        if (iconSize == null)
            gc.drawImage(image, event.x, (rowHeight - iconHeight) / 2);
        else {
            int w = (int) (iconWidth * fac);
            int h = (int) (iconHeight * fac);
            gc.drawImage(image, 0, 0, iconWidth, iconHeight, event.x + (iconWidth - w) / 2,
                    event.y + (rowHeight - h) / 2, w, h);
        }
    }
    viewerControl.setToolTipText(tooltip);
}

From source file:com.bdaum.zoom.rcp.internal.ApplicationWorkbenchAdvisor.java

License:Open Source License

private static void createApplicationFonts() {
    FontRegistry fontRegistry = JFaceResources.getFontRegistry();
    FontData fontData = fontRegistry.defaultFontDescriptor().getFontData()[0];
    fontRegistry.put(UiConstants.MESSAGEFONT,
            new FontData[] { new FontData(fontData.getName(), fontData.getHeight() + 4, fontData.getStyle()) });
    fontRegistry.put(UiConstants.SELECTIONFONT,
            new FontData[] { new FontData(fontData.getName(), fontData.getHeight(), SWT.BOLD) });
    fontRegistry.put(UiConstants.ITALICFONT,
            new FontData[] { new FontData(fontData.getName(), fontData.getHeight(), SWT.ITALIC) });
    fontRegistry.put(UiConstants.VIEWERFONT,
            new FontData[] { new FontData(fontData.getName(), 18, fontData.getStyle()) });
    fontRegistry.put(UiConstants.VIEWERTITLEFONT,
            new FontData[] { new FontData(fontData.getName(), 24, SWT.BOLD) });
    fontRegistry.put(UiConstants.VIEWERBANNERFONT,
            new FontData[] { new FontData(fontData.getName(), 36, SWT.BOLD) });
    fontData = fontRegistry.getDescriptor(JFaceResources.HEADER_FONT).getFontData()[0];
    fontRegistry.put(UiConstants.MESSAGETITLEFONT,
            new FontData[] { new FontData(fontData.getName(), fontData.getHeight() + 4, fontData.getStyle()) });
}

From source file:com.bdaum.zoom.ui.internal.dialogs.EditMetaDialog.java

License:Open Source License

@SuppressWarnings("unused")
private void createKeywordsGroup(final CTabFolder folder) {
    final Composite kwComp = createTabPage(folder, Messages.EditMetaDialog_keywords,
            Messages.EditMetaDialog_keyword_tooltip, 2, 0);
    CGroup kwGroup = new CGroup(kwComp, SWT.NONE);
    kwGroup.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true));
    kwGroup.setLayout(new GridLayout(2, false));
    kwGroup.setText(Messages.EditMetaDialog_cat_keywords);
    Label catKwLabel = new Label(kwGroup, SWT.NONE);
    catKwLabel.setLayoutData(new GridData(SWT.BEGINNING, SWT.CENTER, false, false));
    catKwLabel.setFont(JFaceResources.getFontRegistry().get(UiConstants.SELECTIONFONT));
    flatKeywordGroup = new FlatGroup(kwGroup, SWT.NONE, settings, "hierarchicalKeywords"); //$NON-NLS-1$
    flatKeywordGroup.setLayoutData(new GridData(SWT.END, SWT.BEGINNING, false, false));
    flatKeywordGroup.addListener(new Listener() {
        @Override/*  w  w  w .  ja  v  a2 s  . com*/
        public void handleEvent(Event event) {
            keywordViewer.setInput(keywords);
            keywordViewer.expandAll();
            keywordExpandCollapseGroup.setVisible(!flatKeywordGroup.isFlat());
        }
    });
    Composite viewerGroup = new Composite(kwGroup, SWT.NONE);
    viewerGroup.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true));
    GridLayout layout = new GridLayout(2, false);
    layout.marginHeight = layout.marginWidth = 0;
    viewerGroup.setLayout(layout);
    final FilterField filterField = new FilterField(viewerGroup);
    filterField.addModifyListener(new ModifyListener() {
        public void modifyText(ModifyEvent e) {
            keywordViewer.setInput(keywords);
            keywordViewer.expandAll();
        }
    });
    final CheckboxButton excludeButton = WidgetFactory.createCheckButton(viewerGroup,
            Messages.KeywordGroup_exclude_geographic, new GridData(SWT.END, SWT.CENTER, true, false));
    excludeButton.addListener(new Listener() {

        @Override
        public void handleEvent(Event event) {
            excludeGeographic = excludeButton.getSelection();
            Object[] expandedElements = keywordViewer.getExpandedElements();
            keywordViewer.setInput(keywords);
            keywordViewer.setExpandedElements(expandedElements);
        }
    });
    keywordExpandCollapseGroup = new ExpandCollapseGroup(viewerGroup, SWT.NONE,
            new GridData(SWT.END, SWT.BEGINNING, true, false, 2, 1));
    keywordViewer = new TreeViewer(viewerGroup, SWT.V_SCROLL | SWT.BORDER);
    keywordExpandCollapseGroup.setViewer(keywordViewer);
    keywordExpandCollapseGroup.setVisible(!flatKeywordGroup.isFlat());
    setViewerLayout(keywordViewer, 220, 2);
    keywordViewer.setContentProvider(new KeywordContentProvider());
    keywordViewer.setLabelProvider(new KeywordLabelProvider(getVocabManager(), null));
    ZColumnViewerToolTipSupport.enableFor(keywordViewer);
    keywordViewer.setComparator(ZViewerComparator.INSTANCE);
    UiUtilities.installDoubleClickExpansion(keywordViewer);
    keywordViewer.setFilters(new ViewerFilter[] { new ViewerFilter() {
        @Override
        public boolean select(Viewer aViewer, Object parentElement, Object element) {
            WildCardFilter filter = filterField.getFilter();
            return filter == null || element instanceof Character || filter.accept((String) element);
        }
    } });
    keywordViewer.addSelectionChangedListener(new ISelectionChangedListener() {
        public void selectionChanged(SelectionChangedEvent event) {
            updateButtons();
        }
    });
    configureKeywordLink = new CLink(viewerGroup, SWT.NONE);
    configureKeywordLink.setText(Messages.EditMetaDialog_configure_keyword_filter);
    configureKeywordLink.addListener(new Listener() {
        @Override
        public void handleEvent(Event event) {
            PreferencesUtil.createPreferenceDialogOn(getShell(), KeyPreferencePage.ID, new String[0], null)
                    .open();
        }
    });
    final Composite buttonGroup = new Composite(kwGroup, SWT.NONE);
    buttonGroup.setLayoutData(new GridData(SWT.LEFT, SWT.CENTER, false, false));
    buttonGroup.setLayout(new GridLayout());

    keywordAddButton = createPushButton(buttonGroup, Messages.EditMetaDialog_add,
            Messages.EditMetaDialog_add_keyword_tooltip);
    keywordAddButton.addSelectionListener(new SelectionAdapter() {
        @Override
        public void widgetSelected(SelectionEvent e) {
            ZInputDialog dialog = createKeywordDialog(Messages.EditMetaDialog_add_keyword,
                    Messages.EditMetaDialog_enter_a_new_keyword, ""); //$NON-NLS-1$
            if (dialog.open() == Window.OK)
                addKeywordToViewer(keywordViewer, dialog.getValue(), true);
        }
    });
    keywordModifyButton = createPushButton(buttonGroup, Messages.EditMetaDialog_edit,
            Messages.EditMetaDialog_modify_keyword_tooltip);
    keywordModifyButton.addSelectionListener(new SelectionAdapter() {
        @Override
        public void widgetSelected(SelectionEvent e) {
            editKeyword();
        }
    });
    keywordViewer.getControl().addKeyListener(keyListener);
    keywordViewer.addSelectionChangedListener(new ISelectionChangedListener() {
        public void selectionChanged(final SelectionChangedEvent event) {
            updateButtons();
            if (cntrlDwn) {
                if (keywordModifyButton.isEnabled())
                    editKeyword();
                cntrlDwn = false;
            }
        }
    });
    keywordReplaceButton = createPushButton(buttonGroup, Messages.EditMetaDialog_replace,
            Messages.EditMetaDialog_replace_tooltip);
    keywordReplaceButton.addSelectionListener(new SelectionAdapter() {
        @Override
        public void widgetSelected(SelectionEvent e) {
            String kw = (String) ((IStructuredSelection) keywordViewer.getSelection()).getFirstElement();
            if (kw != null) {
                KeywordDialog dialog = new KeywordDialog(getShell(),
                        NLS.bind(Messages.EditMetaDialog_replace_keyword, kw), null, keywords, null);
                if (dialog.open() == Window.OK) {
                    BagChange<String> result = dialog.getResult();
                    boolean found = false;
                    Set<String> added = result.getAdded();
                    if (added != null)
                        for (String s : added)
                            if (kw.equals(s)) {
                                found = true;
                                break;
                            }
                    if (!found)
                        removeKeywordFromViewer(keywordViewer, kw);
                    Set<String> addedKeywords = result.getAdded();
                    String[] replacement = addedKeywords.toArray(new String[addedKeywords.size()]);
                    int i = 0;
                    for (String k : replacement)
                        addKeywordToViewer(keywordViewer, k, i++ == 0);
                    todo.add(new ReplaceKeywordOperation(kw, replacement));
                }
            }
        }
    });
    keywordDeleteButton = createPushButton(buttonGroup, Messages.EditMetaDialog_delete_keyword,
            Messages.EditMetaDialog_delete_keyword_tooltip);
    keywordDeleteButton.addSelectionListener(new SelectionAdapter() {
        @Override
        public void widgetSelected(SelectionEvent e) {
            BusyIndicator.showWhile(keywordDeleteButton.getDisplay(), () -> {
                IStructuredSelection selection = (IStructuredSelection) keywordViewer.getSelection();
                String kw = (String) selection.getFirstElement();
                if (kw != null) {
                    List<AssetImpl> set = dbManager.obtainObjects(AssetImpl.class,
                            QueryField.IPTC_KEYWORDS.getKey(), kw, QueryField.EQUALS);
                    removeKeywordFromViewer(keywordViewer, kw);
                    if (!set.isEmpty()) {
                        KeywordDeleteDialog dialog = new KeywordDeleteDialog(getShell(), kw, set);
                        if (dialog.open() != Window.OK) {
                            keywords.add(kw);
                            return;
                        }
                        if (dialog.getPolicy() == KeywordDeleteDialog.REMOVE)
                            todo.add(new ManageKeywordsOperation(
                                    new BagChange<String>(null, null, Collections.singleton(kw), null), set));
                    }
                }
            });
        }
    });
    keywordShowButton = createPushButton(buttonGroup, Messages.EditMetaDialog_show_images,
            Messages.EditMetaDialog_show_keyword_tooltip);
    keywordShowButton.addSelectionListener(new SelectionAdapter() {
        @Override
        public void widgetSelected(SelectionEvent e) {
            IStructuredSelection selection = (IStructuredSelection) keywordViewer.getSelection();
            String kw = (String) selection.getFirstElement();
            if (kw != null) {
                SmartCollectionImpl sm = new SmartCollectionImpl(kw, false, false, true, false, null, 0, null,
                        0, null, Constants.INHERIT_LABEL, null, 0, null);
                sm.addCriterion(new CriterionImpl(QueryField.IPTC_KEYWORDS.getKey(), null, kw,
                        QueryField.EQUALS, false));
                sm.addSortCriterion(new SortCriterionImpl(QueryField.IPTC_DATECREATED.getKey(), null, true));
                Ui.getUi().getNavigationHistory(workbenchPage.getWorkbenchWindow())
                        .postSelection(new StructuredSelection(sm));
                close();
            }
        }
    });
    new Label(buttonGroup, SWT.SEPARATOR | SWT.HORIZONTAL);

    keywordCollectButton = createPushButton(buttonGroup, Messages.EditMetaDialog_collect,
            Messages.EditMetaDialog_collect_keyword_tooltip);
    keywordCollectButton.addSelectionListener(new SelectionAdapter() {
        @Override
        public void widgetSelected(SelectionEvent e) {
            KeywordCollectDialog dialog = new KeywordCollectDialog(getShell(), keywords);
            if (dialog.open() == Window.OK) {
                int i = 0;
                for (String kw : dialog.getToAdd())
                    addKeywordToViewer(keywordViewer, kw, i++ == 0);
                for (String kw : dialog.getToRemove())
                    removeKeywordFromViewer(keywordViewer, kw);
            }
        }
    });

    keywordLoadButton = createPushButton(buttonGroup, Messages.EditMetaDialog_load,
            NLS.bind(Messages.EditMetaDialog_load_keyword_tooltip, Constants.KEYWORDFILEEXTENSION));
    keywordLoadButton.addSelectionListener(new SelectionAdapter() {
        @Override
        public void widgetSelected(SelectionEvent ev) {
            FileDialog dialog = new FileDialog(getShell(), SWT.OPEN);
            dialog.setFilterExtensions(KEYWORDEXTENSIONS);
            dialog.setFilterNames(
                    new String[] {
                            Constants.APPNAME + Messages.EditMetaDialog_zoom_keyword_file
                                    + Constants.KEYWORDFILEEXTENSION + ')',
                            Messages.EditMetaDialog_all_files });
            String filename = dialog.open();
            if (filename != null) {
                try (InputStream in = new BufferedInputStream(new FileInputStream(filename))) {
                    List<String> list = Utilities.loadKeywords(in);
                    keywords.clear();
                    keywords.addAll(list);
                } catch (IOException e) {
                    // ignore
                }
                keywordViewer.setInput(keywords);
                keywordViewer.expandAll();
            }
        }
    });
    keywordSaveButton = createPushButton(buttonGroup, Messages.EditMetaDialog_save,
            NLS.bind(Messages.EditMetaDialog_save_keyword_tooltip, Constants.KEYWORDFILEEXTENSION));
    keywordSaveButton.addSelectionListener(new SelectionAdapter() {
        @Override
        public void widgetSelected(SelectionEvent e) {
            FileDialog dialog = new FileDialog(getShell(), SWT.SAVE);
            dialog.setFilterExtensions(KEYWORDEXTENSIONS);
            dialog.setFilterNames(
                    new String[] {
                            Constants.APPNAME + Messages.EditMetaDialog_zoom_keyword_file
                                    + Constants.KEYWORDFILEEXTENSION + ")", //$NON-NLS-1$
                            Messages.EditMetaDialog_all_files });
            dialog.setFileName("*" + Constants.KEYWORDFILEEXTENSION); //$NON-NLS-1$
            dialog.setOverwrite(true);
            String filename = dialog.open();
            if (filename != null)
                Utilities.saveKeywords(keywords, new File(filename));
        }
    });
    addToKeywordsButton = WidgetFactory.createCheckButton(kwGroup, Messages.EditMetaDialog_add_to_keywords,
            new GridData(SWT.BEGINNING, SWT.END, true, false, 2, 1));
    CGroup vocabGroup = new CGroup(kwComp, SWT.NONE);
    vocabGroup.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true));
    vocabGroup.setLayout(new GridLayout(2, false));
    vocabGroup.setText(Messages.EditMetaDialog_controlled_vocabs);
    Composite vocabViewerGroup = new Composite(vocabGroup, SWT.NONE);
    GridData layoutData = new GridData(SWT.FILL, SWT.FILL, true, true);
    layoutData.verticalIndent = 20;
    vocabViewerGroup.setLayoutData(layoutData);
    vocabViewerGroup.setLayout(new GridLayout(2, false));

    vocabViewer = new TableViewer(vocabViewerGroup, SWT.MULTI | SWT.H_SCROLL | SWT.V_SCROLL | SWT.BORDER);
    setViewerLayout(vocabViewer, 150, 1);
    TableViewerColumn col1 = new TableViewerColumn(vocabViewer, SWT.NONE);
    col1.getColumn().setWidth(300);
    col1.setLabelProvider(new ZColumnLabelProvider() {
        @Override
        public String getText(Object element) {
            return element.toString();
        }

        @Override
        public Image getImage(Object element) {
            if (element instanceof String && !new File((String) element).exists())
                return Icons.error.getImage();
            return null;
        }

        @Override
        public String getToolTipText(Object element) {
            if (element instanceof String && UiActivator.getDefault().getShowHover()) {
                File file = new File((String) element);
                if (!file.exists())
                    return Messages.EditMetaDialog_file_does_not_exist;
            }
            return super.getToolTipText(element);
        }

        @Override
        public Image getToolTipImage(Object element) {
            return getImage(element);
        }
    });
    vocabViewer.setContentProvider(ArrayContentProvider.getInstance());
    vocabViewer.addSelectionChangedListener(new ISelectionChangedListener() {
        @Override
        public void selectionChanged(SelectionChangedEvent event) {
            updateButtons();
        }
    });
    vocabViewer.addDoubleClickListener(new IDoubleClickListener() {
        @Override
        public void doubleClick(DoubleClickEvent event) {
            viewVocab();
        }
    });
    ColumnViewerToolTipSupport.enableFor(vocabViewer);
    Composite vocabButtonGroup = new Composite(vocabViewerGroup, SWT.NONE);
    vocabButtonGroup.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true));
    vocabButtonGroup.setLayout(new GridLayout());
    vocabAddButton = createPushButton(vocabButtonGroup, Messages.EditMetaDialog_add,
            Messages.EditMetaDialog_add_vocab);
    vocabAddButton.addSelectionListener(new SelectionAdapter() {
        @Override
        public void widgetSelected(SelectionEvent e) {
            FileDialog dialog = new FileDialog(getShell(), SWT.OPEN);
            dialog.setText(Messages.EditMetaDialog_select_vocab);
            dialog.setFilterExtensions(KEYWORDEXTENSIONS);
            dialog.setFilterNames(
                    new String[] {
                            Constants.APPNAME + Messages.EditMetaDialog_zoom_keyword_file
                                    + Constants.KEYWORDFILEEXTENSION + ')',
                            Messages.EditMetaDialog_all_files });
            String file = dialog.open();
            if (file != null) {
                boolean found = false;
                for (String s : vocabularies)
                    if (s.equals(file)) {
                        found = true;
                        break;
                    }
                if (!found) {
                    vocabularies.add(file);
                    vocabViewer.add(file);
                }
                vocabViewer.setSelection(new StructuredSelection(file), true);
                if (vocabManager != null)
                    vocabManager.reset(vocabularies);
                updateKeywordViewer();
            }
        }
    });
    vocabRemoveButton = createPushButton(vocabButtonGroup, Messages.EditMetaDialog_remove,
            Messages.EditMetaDialog_remove_vocab);
    vocabRemoveButton.addSelectionListener(new SelectionAdapter() {
        @Override
        public void widgetSelected(SelectionEvent e) {
            @SuppressWarnings("unchecked")
            Iterator<Object> it = vocabViewer.getStructuredSelection().iterator();
            while (it.hasNext()) {
                Object file = it.next();
                vocabularies.remove(file);
                vocabViewer.remove(file);
            }
            if (vocabManager != null)
                vocabManager.reset(vocabularies);
            updateKeywordViewer();
        }
    });
    vocabViewButton = createPushButton(vocabButtonGroup, Messages.EditMetaDialog_view_vocab,
            Messages.EditMetaDialog_view_vocab_tooltip);
    vocabViewButton.addSelectionListener(new SelectionAdapter() {
        @Override
        public void widgetSelected(SelectionEvent e) {
            viewVocab();
        }
    });
    new Label(vocabButtonGroup, SWT.SEPARATOR | SWT.HORIZONTAL);
    vocabEnforceButton = createPushButton(vocabButtonGroup, Messages.EditMetaDialog_enforce,
            Messages.EditMetaDialog_enforce_tooltip);
    vocabEnforceButton.addSelectionListener(new SelectionAdapter() {
        @Override
        public void widgetSelected(SelectionEvent e) {
            List<String[]> changes = new ArrayList<>();
            VocabManager vManager = getVocabManager();
            for (String kw : keywords) {
                String mapped = vManager.getVocab(kw);
                if (!kw.equals(mapped))
                    changes.add(new String[] { kw, mapped });
            }
            VocabEnforceDialog dialog = new VocabEnforceDialog(getShell(), changes);
            if (dialog.open() == VocabEnforceDialog.OK) {
                BusyIndicator.showWhile(getShell().getDisplay(), () -> {
                    int policy = dialog.getPolicy();
                    for (String[] change : dialog.getChanges()) {
                        String kw = change[0];
                        keywords.remove(kw);
                        if (change[1] != null) {
                            keywords.add(change[1]);
                            if (policy == KeywordDeleteDialog.REMOVE)
                                todo.add(new ReplaceKeywordOperation(kw, new String[] { change[1] }));
                        } else if (policy == KeywordDeleteDialog.REMOVE)
                            todo.add(new ManageKeywordsOperation(
                                    new BagChange<String>(null, null, Collections.singleton(kw), change),
                                    null));
                        updateKeywordViewer();
                    }

                });
            }
        }
    });
}

From source file:com.bluexml.side.Class.modeler.diagram.edit.AttributeEditPart.java

License:Open Source License

@Override
protected Font getDefaultFont() {
    FontData[] fData = Display.getDefault().getSystemFont().getFontData();
    fData[0].setStyle(SWT.ITALIC);//from  ww w  .  j a va2  s.c  o m
    JFaceResources.getFontRegistry().put("ItalicFont", fData);
    return JFaceResources.getFontRegistry().get("ItalicFont");
}

From source file:com.bluexml.side.Class.modeler.diagram.edit.ClazzEditPart.java

License:Open Source License

@Override
protected Font getDefaultFont() {
    Clazz clazz = (Clazz) Utils.getElement(getGraphNode());

    FontData[] fData = Display.getDefault().getSystemFont().getFontData();

    if (clazz != null) {
        if (clazz.isAbstract()) {
            fData[0].setStyle(SWT.ITALIC | SWT.BOLD);
        } else {// w w w  . j  av a  2  s .c o  m
            fData[0].setStyle(SWT.BOLD);
        }
    } else {
        fData[0].setStyle(SWT.BOLD);
    }

    JFaceResources.getFontRegistry().put("ItalicFont", fData);
    return JFaceResources.getFontRegistry().get("ItalicFont");
}

From source file:com.bluexml.side.Class.modeler.diagram.edit.EnumerationEditPart.java

License:Open Source License

@Override
protected Font getDefaultFont() {
    FontData[] fData = Display.getDefault().getSystemFont().getFontData();
    fData[0].setStyle(SWT.BOLD);/*from ww w  .j  a  va2  s.com*/
    JFaceResources.getFontRegistry().put("ItalicFont", fData);
    return JFaceResources.getFontRegistry().get("ItalicFont");
}

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

License:Open Source License

/**
 * Set the name of the Layout//from   w ww.  ja v a  2  s.c  om
 * 
 * @see org.topcased.modeler.edit.EMFGraphNodeEditPart#refreshHeaderLabel()
 */
@Override
protected void refreshHeaderLabel() {
    IFigure ifig = getFigure();
    if (ifig instanceof PortalLayoutFigure) {
        PortalLayoutFigure fig = (PortalLayoutFigure) ifig;
        org.topcased.draw2d.figures.ILabel lbl = fig.getLabel();
        PortalLayout pl = (PortalLayout) Utils.getElement(getGraphNode());

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

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

License:Open Source License

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

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