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:org.eclipse.compare.contentmergeviewer.TextMergeViewer.java

License:Open Source License

/**
 * Creates a text merge viewer under the given parent control.
 *
 * @param parent the parent control// w  w  w .j  a v  a 2s. co m
 * @param style SWT style bits for top level composite of this viewer
 * @param configuration the configuration object
 */
public TextMergeViewer(Composite parent, int style, CompareConfiguration configuration) {
    super(style, ResourceBundle.getBundle(BUNDLE_NAME), configuration);

    operationHistoryListener = new IOperationHistoryListener() {
        public void historyNotification(OperationHistoryEvent event) {
            TextMergeViewer.this.historyNotification(event);
        }
    };
    OperationHistoryFactory.getOperationHistory().addOperationHistoryListener(operationHistoryListener);

    fMerger = new DocumentMerger(new IDocumentMergerInput() {
        public ITokenComparator createTokenComparator(String line) {
            return TextMergeViewer.this.createTokenComparator(line);
        }

        public CompareConfiguration getCompareConfiguration() {
            return TextMergeViewer.this.getCompareConfiguration();
        }

        public IDocument getDocument(char contributor) {
            switch (contributor) {
            case LEFT_CONTRIBUTOR:
                return fLeft.getSourceViewer().getDocument();
            case RIGHT_CONTRIBUTOR:
                return fRight.getSourceViewer().getDocument();
            case ANCESTOR_CONTRIBUTOR:
                return fAncestor.getSourceViewer().getDocument();
            }
            return null;
        }

        public int getHunkStart() {
            return TextMergeViewer.this.getHunkStart();
        }

        public Position getRegion(char contributor) {
            switch (contributor) {
            case LEFT_CONTRIBUTOR:
                return fLeft.getRegion();
            case RIGHT_CONTRIBUTOR:
                return fRight.getRegion();
            case ANCESTOR_CONTRIBUTOR:
                return fAncestor.getRegion();
            }
            return null;
        }

        public boolean isHunkOnLeft() {
            ITypedElement left = ((ICompareInput) getInput()).getRight();
            return left != null && Utilities.getAdapter(left, IHunk.class) != null;
        }

        public boolean isIgnoreAncestor() {
            return TextMergeViewer.this.isIgnoreAncestor();
        }

        public boolean isPatchHunk() {
            return TextMergeViewer.this.isPatchHunk();
        }

        public boolean isShowPseudoConflicts() {
            return fShowPseudoConflicts;
        }

        public boolean isThreeWay() {
            return TextMergeViewer.this.isThreeWay();
        }

        public boolean isPatchHunkOk() {
            return TextMergeViewer.this.isPatchHunkOk();
        }

    });

    int inheritedStyle = parent.getStyle();
    if ((inheritedStyle & SWT.LEFT_TO_RIGHT) != 0)
        fInheritedDirection = SWT.LEFT_TO_RIGHT;
    else if ((inheritedStyle & SWT.RIGHT_TO_LEFT) != 0)
        fInheritedDirection = SWT.RIGHT_TO_LEFT;
    else
        fInheritedDirection = SWT.NONE;

    if ((style & SWT.LEFT_TO_RIGHT) != 0)
        fTextDirection = SWT.LEFT_TO_RIGHT;
    else if ((style & SWT.RIGHT_TO_LEFT) != 0)
        fTextDirection = SWT.RIGHT_TO_LEFT;
    else
        fTextDirection = SWT.NONE;

    fSymbolicFontName = getSymbolicFontName();

    fIsMotif = Util.isMotif();
    fIsCarbon = Util.isCarbon();
    fIsMac = Util.isMac();

    if (fIsMotif)
        fMarginWidth = 0;

    fPreferenceChangeListener = new IPropertyChangeListener() {
        public void propertyChange(PropertyChangeEvent event) {
            TextMergeViewer.this.handlePropertyChangeEvent(event);
        }
    };

    fPreferenceStore = createChainedPreferenceStore();
    if (fPreferenceStore != null) {
        fPreferenceStore.addPropertyChangeListener(fPreferenceChangeListener);

        fLeftIsLocal = Utilities.getBoolean(getCompareConfiguration(), "LEFT_IS_LOCAL", false); //$NON-NLS-1$
        fSynchronizedScrolling = fPreferenceStore.getBoolean(ComparePreferencePage.SYNCHRONIZE_SCROLLING);
        fShowPseudoConflicts = fPreferenceStore.getBoolean(ComparePreferencePage.SHOW_PSEUDO_CONFLICTS);
        //fUseSplines= fPreferenceStore.getBoolean(ComparePreferencePage.USE_SPLINES);
        fUseSingleLine = fPreferenceStore.getBoolean(ComparePreferencePage.USE_SINGLE_LINE);
        fHighlightTokenChanges = fPreferenceStore.getBoolean(ComparePreferencePage.HIGHLIGHT_TOKEN_CHANGES);
        //fUseResolveUI= fPreferenceStore.getBoolean(ComparePreferencePage.USE_RESOLVE_UI);
    }

    buildControl(parent);

    setColors();

    INavigatable nav = new INavigatable() {
        public boolean selectChange(int flag) {
            if (flag == INavigatable.FIRST_CHANGE || flag == INavigatable.LAST_CHANGE) {
                selectFirstDiff(flag == INavigatable.FIRST_CHANGE);
                return false;
            }
            return navigate(flag == INavigatable.NEXT_CHANGE, false, false);
        }

        public Object getInput() {
            return TextMergeViewer.this.getInput();
        }

        public boolean openSelectedChange() {
            return false;
        }

        public boolean hasChange(int flag) {
            return getNextVisibleDiff(flag == INavigatable.NEXT_CHANGE, false) != null;
        }
    };
    fComposite.setData(INavigatable.NAVIGATOR_PROPERTY, nav);

    fBirdsEyeCursor = new Cursor(parent.getDisplay(), SWT.CURSOR_HAND);

    JFaceResources.getFontRegistry().addListener(fPreferenceChangeListener);
    JFaceResources.getColorRegistry().addListener(fPreferenceChangeListener);
    updateFont();
}

From source file:org.eclipse.compare.internal.patch.PreviewPatchPage2.java

License:Open Source License

private void buildPatchOptionsGroup(final Form form) {
    Composite parent = form.getBody();

    patchOptions = fToolkit.createExpandableComposite(parent,
            ExpandableComposite.TWISTIE | ExpandableComposite.CLIENT_INDENT);
    patchOptions.setText(PatchMessages.PreviewPatchPage_PatchOptions_title);
    patchOptions.setFont(JFaceResources.getFontRegistry().getBold(JFaceResources.DIALOG_FONT));
    patchOptions.setLayoutData(new GridData(GridData.FILL, GridData.FILL, true, false, 3, 1));
    patchOptions.addExpansionListener(new ExpansionAdapter() {
        public void expansionStateChanged(ExpansionEvent e) {
            form.layout();//  w ww . j a v  a2  s . c  o m
        }
    });

    Composite c = new Composite(patchOptions, SWT.NONE);
    patchOptions.setClient(c);
    patchOptions.setExpanded(true);
    GridLayout gl = new GridLayout();
    gl.numColumns = 3;
    c.setLayout(gl);
    c.setLayoutData(new GridData(GridData.HORIZONTAL_ALIGN_FILL | GridData.GRAB_HORIZONTAL));

    // 1st row
    createStripSegmentCombo(c);
    createShowMatchedToggle(c);
    createFuzzFactorChooser(c);

    // 2nd row
    createReversePatchToggle(c);
    createShowRemovedToggle(c);
    createGenerateRejectsToggle(c);

    // register listeners
    final WorkspacePatcher patcher = getPatcher();
    if (fStripPrefixSegments != null)
        fStripPrefixSegments.addSelectionListener(new SelectionAdapter() {
            public void widgetSelected(SelectionEvent e) {
                if (patcher.getStripPrefixSegments() != getStripPrefixSegments()) {
                    if (promptToRebuild(PatchMessages.PreviewPatchPage2_4)) {
                        if (patcher.setStripPrefixSegments(getStripPrefixSegments()))
                            rebuildTree();
                    }
                }
            }
        });

    fFuzzField.addModifyListener(new ModifyListener() {
        public void modifyText(ModifyEvent e) {
            if (patcher.getFuzz() != getFuzzFactor()) {
                if (promptToRebuild(PatchMessages.PreviewPatchPage2_5)) {
                    if (patcher.setFuzz(getFuzzFactor()))
                        rebuildTree();
                } else {
                    fFuzzField.setText(Integer.toString(patcher.getFuzz()));
                }
            }
        }
    });
}

From source file:org.eclipse.datatools.sqltools.sqlbuilder.views.source.SQLSourceViewer.java

License:Open Source License

private void initTextWidget() {

    setEditable(true);//from  w ww.  ja va2 s. c o m
    StyledText styledText = sourceViewer.getTextWidget();
    styledText.setFont(JFaceResources.getFontRegistry().get(JFaceResources.TEXT_FONT));
    JFaceResources.getFontRegistry().addListener(this);
    sourceViewer.getControl().addDisposeListener(this);

    styledText.addKeyListener(new KeyAdapter() {

        public void keyPressed(KeyEvent e) {
            // can only edit if root statement...
            if (isRootStatement()) {
                if (e.stateMask == SWT.CTRL && e.character == ' ' && contentAssistAction != null) {
                    contentAssistAction.run();
                }
                if (e.stateMask == (SWT.SHIFT | SWT.CTRL) && e.character == ' ' && contentTipAction != null) {
                    contentTipAction.run();
                }
            }
            setParseRequired(true);
        }

    });

    styledText.addFocusListener(new FocusAdapter() {

        public void focusLost(FocusEvent e) {
            //if contentassist is running, the ignore the focusLost event
            if (contentAssistAction.isActive()) {
                return;
            }

            // [wsdbu00055322] bgp 03May2006, [RATLC01118321] bgp 18Aug2006
            // Ignore the focus lost event if the content assist is active.
            if (configuration.getIsContentAssistActive() == true) {
                return;
            }

            if (isTextChanged() == true)
                reparse();

            // A call to validateEdit will cause a loss of focus, in that case, we
            // don't want to reparse

            // is context menu showing? if so - leave menu options active & do not reparse
            // on Linux extra focusLost gets called on right click
            boolean menuShowing = getControl().getMenu().isVisible();
            boolean sqlBuilderNotInValidate = (sqlbuilder != null)
                    && (sqlbuilder.inValidateEditCall() == false);

            if (!menuShowing && (sqlbuilder == null || sqlBuilderNotInValidate)) {
                reparse();
                Iterator aIterator = actions.values().iterator();
                while (aIterator.hasNext()) {
                    Object object = aIterator.next();
                    ((Action) object).setEnabled(false);
                }
            }
        }

        public void focusGained(FocusEvent e) {
            Iterator aIterator = actions.values().iterator();

            while (aIterator.hasNext()) {
                Object object = aIterator.next();
                if (object instanceof TextViewerOperationAction) {
                    TextViewerOperationAction textAction = (TextViewerOperationAction) object;
                    textAction.update();
                } else if (object instanceof SourceViewerAction) {
                    SourceViewerAction sourceAction = (SourceViewerAction) object;
                    sourceAction.setEnabled(true);
                }
            }
            contentAssistAction.setAsActive(false);
        }
    });

}

From source file:org.eclipse.datatools.sqltools.sqlbuilder.views.source.SQLSourceViewer.java

License:Open Source License

public void propertyChange(PropertyChangeEvent event) {
    if (event.getProperty() == JFaceResources.TEXT_FONT && sourceViewer != null) {
        sourceViewer.getTextWidget().setFont(JFaceResources.getFontRegistry().get(JFaceResources.TEXT_FONT));
    }//from w w w. j a v a2 s .co  m
}

From source file:org.eclipse.datatools.sqltools.sqlbuilder.views.source.SQLSourceViewer.java

License:Open Source License

/**
 * @see org.eclipse.swt.events.DisposeListener#widgetDisposed(DisposeEvent)
 *//*from   w ww.j ava 2  s.c  o  m*/
public void widgetDisposed(DisposeEvent arg0) {
    JFaceResources.getFontRegistry().removeListener(this);
}

From source file:org.eclipse.dd.dsf.debug.internal.provisional.ui.viewmodel.modules.detail.ModuleDetailPane.java

License:Open Source License

public Control createControl(Composite parent) {
    createSourceViewer(parent);//from w w w.  ja va2 s .c  o m

    if (isInView()) {
        createViewSpecificComponents();
        createActions();
        DsfDebugUIPlugin.getDefault().getPreferenceStore().addPropertyChangeListener(this);
        JFaceResources.getFontRegistry().addListener(this);
    }
    return fSourceViewer.getControl();
}

From source file:org.eclipse.dd.dsf.debug.internal.provisional.ui.viewmodel.modules.detail.ModuleDetailPane.java

License:Open Source License

@Override
public void dispose() {
    super.dispose();
    if (fDetailJob != null)
        fDetailJob.cancel();/*  w  ww. ja  v a 2  s.  com*/
    if (fSourceViewer != null && fSourceViewer.getControl() != null)
        fSourceViewer.getControl().dispose();

    if (isInView()) {
        DsfDebugUIPlugin.getDefault().getPreferenceStore().removePropertyChangeListener(this);
        JFaceResources.getFontRegistry().removeListener(this);
    }

}

From source file:org.eclipse.dd.dsf.debug.internal.ui.disassembly.DisassemblyPart.java

License:Open Source License

/**
 * This is a callback that will allow us to create the viewer and initialize
 * it.//  w ww .  ja  v a 2 s.  c  o  m
 */
@Override
public void createPartControl(Composite parent) {
    fComposite = parent;
    FillLayout layout = new FillLayout();
    layout.marginHeight = 2;
    parent.setLayout(layout);
    fVerticalRuler = createVerticalRuler();
    int styles = SWT.V_SCROLL | SWT.H_SCROLL | SWT.MULTI | SWT.BORDER | SWT.FULL_SELECTION;
    fViewer = new DisassemblyViewer(parent, fVerticalRuler, getOverviewRuler(), true, styles);
    SourceViewerConfiguration sourceViewerConfig = new DisassemblyViewerConfiguration(this);
    fViewer.addTextPresentationListener(this);
    fViewer.configure(sourceViewerConfig);
    fDecorationSupport = new SourceViewerDecorationSupport(fViewer, getOverviewRuler(), getAnnotationAccess(),
            getSharedColors());
    configureSourceViewerDecorationSupport(fDecorationSupport);
    fDecorationSupport.install(getPreferenceStore());
    if (fPCAnnotationColorKey != null) {
        fPCAnnotationRGB = PreferenceConverter.getColor(getPreferenceStore(), fPCAnnotationColorKey);
    } else {
        fPCAnnotationRGB = parent.getDisplay().getSystemColor(SWT.COLOR_LIST_SELECTION).getRGB();
    }

    initializeViewerFont(fViewer);
    createActions();
    hookRulerContextMenu();
    hookContextMenu();
    contributeToActionBars();

    fViewer.addSelectionChangedListener(new ISelectionChangedListener() {
        public void selectionChanged(SelectionChangedEvent event) {
            updateSelectionDependentActions();
        }
    });

    fDocument = createDocument();
    fViewer.setDocument(fDocument, new AnnotationModel());
    JFaceResources.getFontRegistry().addListener(fPropertyChangeListener);

    fErrorColor = getSharedColors().getColor(new RGB(96, 0, 0));
    fInstructionColor = getSharedColors().getColor(new RGB(0, 0, 96));
    fSourceColor = getSharedColors().getColor(new RGB(64, 0, 80));
    fLabelColor = getSharedColors().getColor(new RGB(0, 0, 96));

    if (isAddressRulerVisible()) {
        showAddressRuler();
    }
    if (isOpcodeRulerVisible()) {
        showOpcodeRuler();
    }
    initDragAndDrop();
    PlatformUI.getWorkbench().getHelpSystem().setHelp(fViewer.getControl(),
            IDisassemblyHelpContextIds.DISASSEMBLY_VIEW);
    updateTitle();
    updateStateDependentActions();

    if (fDebugSessionId != null) {
        debugContextChanged();
    } else {
        updateDebugContext();
    }
    DsfSession.addSessionEndedListener(this);
}

From source file:org.eclipse.dd.dsf.debug.internal.ui.viewmodel.numberformat.detail.NumberFormatDetailPane.java

License:Open Source License

public Control createControl(Composite parent) {

    createSourceViewer(parent);/*from   w  ww.j  a va2s. c om*/

    if (isInView()) {
        createViewSpecificComponents();
        createActions();
        DsfDebugUIPlugin.getDefault().getPreferenceStore().addPropertyChangeListener(this);
        JFaceResources.getFontRegistry().addListener(this);
    }

    return fSourceViewer.getControl();
}

From source file:org.eclipse.dd.dsf.debug.internal.ui.viewmodel.numberformat.detail.NumberFormatDetailPane.java

License:Open Source License

public void dispose() {
    fActionMap.clear();//from ww  w  . j a v  a  2  s  . com
    fSelectionActions.clear();

    if (fDetailJob != null)
        fDetailJob.cancel();
    fDebugModelIdentifier = null; // Setting this to null makes sure the source viewer is reconfigured with the model presentation after disposal
    if (fSourceViewer != null && fSourceViewer.getControl() != null)
        fSourceViewer.getControl().dispose();

    if (isInView()) {
        disposeUndoRedoAction(ITextEditorActionConstants.UNDO);
        disposeUndoRedoAction(ITextEditorActionConstants.REDO);

        getViewSite().getActionBars().getStatusLineManager().remove(fStatusLineItem);

        DsfDebugUIPlugin.getDefault().getPreferenceStore().removePropertyChangeListener(this);
        JFaceResources.getFontRegistry().removeListener(this);
    }
}