List of usage examples for org.eclipse.jface.resource JFaceResources getFontRegistry
public static FontRegistry getFontRegistry()
From source file:com.imperial.fiksen.codesimilarity.compare.ParseTreeMergeViewer.java
License:Open Source License
/** * Called on the viewer disposal. Unregisters from the compare * configuration. Clients may extend if they have to do additional cleanup. * //from w ww.ja v a 2s . com * @param event */ protected void handleDispose(DisposeEvent event) { OperationHistoryFactory.getOperationHistory().removeOperationHistoryListener(operationHistoryListener); if (fHandlerService != null) fHandlerService.dispose(); Object input = getInput(); removeFromDocumentManager(ANCESTOR_CONTRIBUTOR, input); removeFromDocumentManager(LEFT_CONTRIBUTOR, input); removeFromDocumentManager(RIGHT_CONTRIBUTOR, input); if (DEBUG) DocumentManager.dump(); if (fPreferenceChangeListener != null) { JFaceResources.getFontRegistry().removeListener(fPreferenceChangeListener); JFaceResources.getColorRegistry().removeListener(fPreferenceChangeListener); if (fPreferenceStore != null) fPreferenceStore.removePropertyChangeListener(fPreferenceChangeListener); fPreferenceChangeListener = null; } fLeftCanvas = null; fRightCanvas = null; fVScrollBar = null; fBirdsEyeCanvas = null; fSummaryHeader = null; fAncestorContributor.unsetDocument(fAncestor); fLeftContributor.unsetDocument(fLeft); fRightContributor.unsetDocument(fRight); disconnect(fLeftContributor); disconnect(fRightContributor); disconnect(fAncestorContributor); if (fBirdsEyeCursor != null) { fBirdsEyeCursor.dispose(); fBirdsEyeCursor = null; } if (showWhitespaceAction != null) showWhitespaceAction.dispose(); if (toggleLineNumbersAction != null) toggleLineNumbersAction.dispose(); if (fIgnoreWhitespace != null) fIgnoreWhitespace.dispose(); getCompareConfiguration().setProperty(ChangeCompareFilterPropertyAction.COMPARE_FILTERS_INITIALIZING, Boolean.TRUE); disposeCompareFilterActions(false); if (fSourceViewerDecorationSupport != null) { for (Iterator iterator = fSourceViewerDecorationSupport.iterator(); iterator.hasNext();) { ((SourceViewerDecorationSupport) iterator.next()).dispose(); } fSourceViewerDecorationSupport = null; } if (fAncestor != null) fAncestor.dispose(); fAncestor = null; if (fLeft != null) fLeft.dispose(); fLeft = null; if (fRight != null) fRight.dispose(); fRight = null; if (fColors != null) { Iterator i = fColors.values().iterator(); while (i.hasNext()) { Color color = (Color) i.next(); if (!color.isDisposed()) color.dispose(); } fColors = null; } // don't add anything here, disposing colors should be done last super.handleDispose(event); }
From source file:com.iw.plugins.spindle.ui.SectionWidget.java
License:Mozilla Public License
public SectionWidget() { JFaceResources.getFontRegistry().addListener(this); }
From source file:com.iw.plugins.spindle.ui.SectionWidget.java
License:Mozilla Public License
public final Control createControl(Composite parent) { Composite section = new Composite(parent, SWT.NULL); SectionLayout slayout = new SectionLayout(); section.setLayout(slayout);// www .j a va 2 s.c o m section.setData(this); if (headerPainted) { header = new Label(section, SWT.WRAP); header.setText(getHeaderText()); header.setFont(JFaceResources.getFontRegistry().get(JFaceResources.BANNER_FONT)); } if (addSeparator) { separator = new Composite(section, SWT.NONE); separator.setBackground(Display.getDefault().getSystemColor(SWT.COLOR_BLACK)); } if (descriptionPainted && description != null) { descriptionLabel = new Label(section, SWT.WRAP); descriptionLabel.setText(description); } client = createClient(section); section.setData(this); control = section; return section; }
From source file:com.iw.plugins.spindle.ui.SectionWidget.java
License:Mozilla Public License
public void dispose() { JFaceResources.getFontRegistry().removeListener(this); }
From source file:com.javadude.antxr.eclipse.ui.editor.AntxrOverview.java
License:Open Source License
/** * Create an instance of AntxrOverview./*from w w w . ja v a2 s .c o m*/ * @param aParent */ public AntxrOverview(Composite aParent) { super(aParent, null, SWT.V_SCROLL | SWT.H_SCROLL); EditorEnvironment.connect(); // Configure source viewer configure(new AntxrConfiguration(null)); getTextWidget().setEditable(false); getTextWidget().setFont(JFaceResources.getFontRegistry().get(JFaceResources.TEXT_FONT)); // Create document with attached partitioner IDocument document = new Document(); IDocumentPartitioner partitioner = new FastPartitioner(new PartitionScanner(), PartitionScanner.PARTITION_TYPES); partitioner.connect(document); document.setDocumentPartitioner(partitioner); // Attach document to source viewer AFTER configuring source viewer // Otherwise syntax highlighting will not work setDocument(document); }
From source file:com.joeysoft.kc868.ui.BorderStyler.java
License:Open Source License
/** * shell/*from www. jav a2 s .c om*/ * * @param shell * @return * */ public Composite decorateShell(Shell s) { shell = s; shell.setData(STYLER, this); // layout GridLayout layout = new GridLayout(3, false); layout.marginHeight = layout.marginWidth = layout.verticalSpacing = layout.horizontalSpacing = 0; shell.setLayout(layout); Composite leftTop = new Composite(shell, SWT.NONE | SWT.NO_BACKGROUND); if (resizable) leftTop.setCursor(display.getSystemCursor(SWT.CURSOR_SIZENWSE)); GridData gd = new GridData(); gd.widthHint = gd.heightHint = 5; leftTop.setLayoutData(gd); leftTop.addPaintListener(new PaintListener() { public void paintControl(PaintEvent e) { Rectangle bound = ((Control) e.getSource()).getBounds(); int i = 0; for (Color c : Colors.MAINSHELL_BORDERS) { e.gc.setForeground(c); e.gc.drawLine(i, i, bound.width, i); e.gc.drawLine(i, i, i, bound.height); i++; } } }); if (resizable) { leftTop.addMouseListener(new MouseAdapter() { @Override public void mouseDown(MouseEvent e) { Control control = (Control) e.getSource(); Point loc = control.toDisplay(e.x, e.y); downX = loc.x; downY = loc.y; } @Override public void mouseUp(MouseEvent e) { Control control = (Control) e.getSource(); Point loc = control.toDisplay(e.x, e.y); int dx = downX - loc.x; int dy = downY - loc.y; if (dx == 0 && dy == 0) return; Rectangle bound = shell.getBounds(); bound.x -= dx; bound.y -= dy; bound.width += dx; bound.height += dy; setShellBound(bound); } }); } top = new Label(shell, SWT.LEFT); if (resizable) top.setCursor(display.getSystemCursor(SWT.CURSOR_SIZENS)); gd = new GridData(GridData.FILL_HORIZONTAL); gd.heightHint = 5; top.setLayoutData(gd); top.addPaintListener(new PaintListener() { public void paintControl(PaintEvent e) { Rectangle bound = ((Control) e.getSource()).getBounds(); int i = 0; for (Color c : Colors.MAINSHELL_BORDERS) { e.gc.setForeground(c); e.gc.drawLine(0, i, bound.width, i); i++; } } }); if (resizable) { top.addMouseListener(new MouseAdapter() { @Override public void mouseDown(MouseEvent e) { Control control = (Control) e.getSource(); downY = control.toDisplay(e.x, e.y).y; } @Override public void mouseUp(MouseEvent e) { Control control = (Control) e.getSource(); int newY = control.toDisplay(e.x, e.y).y; int dy = downY - newY; if (dy == 0) return; Rectangle bound = shell.getBounds(); bound.y -= dy; bound.height += dy; setShellBound(bound); } }); } Composite rightTop = new Composite(shell, SWT.NONE | SWT.NO_BACKGROUND); if (resizable) rightTop.setCursor(display.getSystemCursor(SWT.CURSOR_SIZENESW)); gd = new GridData(); gd.widthHint = gd.heightHint = 5; rightTop.setLayoutData(gd); rightTop.addPaintListener(new PaintListener() { public void paintControl(PaintEvent e) { Rectangle bound = ((Control) e.getSource()).getBounds(); int i = 0; for (Color c : Colors.MAINSHELL_BORDERS) { e.gc.setForeground(c); e.gc.drawLine(bound.width - i - 1, i, 0, i); e.gc.drawLine(bound.width - i - 1, i, bound.width - i - 1, bound.height); i++; } } }); if (resizable) { rightTop.addMouseListener(new MouseAdapter() { @Override public void mouseDown(MouseEvent e) { Control control = (Control) e.getSource(); Point loc = control.toDisplay(e.x, e.y); downX = loc.x; downY = loc.y; } @Override public void mouseUp(MouseEvent e) { Control control = (Control) e.getSource(); Point loc = control.toDisplay(e.x, e.y); int dx = loc.x - downX; int dy = downY - loc.y; if (dx == 0 && dy == 0) return; Rectangle bound = shell.getBounds(); bound.y -= dy; bound.width += dx; bound.height += dy; setShellBound(bound); } }); } left = new Label(shell, SWT.LEFT); gd = new GridData(GridData.FILL_VERTICAL); gd.widthHint = 5; gd.verticalSpan = 2; left.setLayoutData(gd); if (resizable) left.setCursor(display.getSystemCursor(SWT.CURSOR_SIZEWE)); left.addPaintListener(new PaintListener() { public void paintControl(PaintEvent e) { Rectangle bound = ((Control) e.getSource()).getBounds(); int i = 0; for (Color c : Colors.MAINSHELL_BORDERS) { e.gc.setForeground(c); e.gc.drawLine(i, 0, i, bound.height); i++; } } }); if (resizable) { left.addMouseListener(new MouseAdapter() { @Override public void mouseDown(MouseEvent e) { Control control = (Control) e.getSource(); downX = control.toDisplay(e.x, e.y).x; } @Override public void mouseUp(MouseEvent e) { Control control = (Control) e.getSource(); int newX = control.toDisplay(e.x, e.y).x; int dx = downX - newX; if (dx == 0) return; Rectangle bound = shell.getBounds(); bound.x -= dx; bound.width += dx; setShellBound(bound); } }); } topDown = new Composite(shell, SWT.LEFT); gd = new GridData(GridData.FILL_HORIZONTAL); gd.heightHint = 23; topDown.setLayoutData(gd); topDown.addPaintListener(new PaintListener() { public void paintControl(PaintEvent e) { Rectangle bound = ((Control) e.getSource()).getBounds(); e.gc.setForeground(Colors.MAINSHELL_TITLE_TOP); e.gc.setBackground(Colors.MAINSHELL_TITLE_BOTTOM); e.gc.fillGradientRectangle(0, 0, bound.width, bound.height, true); e.gc.setForeground(Colors.MAINSHELL_TITLE_SEPARATOR_TOP); e.gc.drawLine(2, 19, bound.width - 2, 19); e.gc.setForeground(Colors.MAINSHELL_TITLE_SEPARATOR_BOTTOM); e.gc.drawLine(2, 20, bound.width - 2, 20); Image image = shell.getImage(); Rectangle imgBound = (image == null) ? new Rectangle(0, 0, 16, 16) : image.getBounds(); if (image != null) { e.gc.drawImage(image, 2, (18 - imgBound.height) >> 1); } String text = shell.getText(); if (text != null) { String name = JFaceResources.getDefaultFont().getFontData()[0].getName(); e.gc.setForeground(Colors.WHITE); e.gc.setFont(JFaceResources.getFontRegistry().getBold(name)); Point extent = e.gc.textExtent(text); e.gc.drawString(text, imgBound.width + 7, (18 - extent.y) >> 1, true); } } }); topDown.setLayout(new FormLayout()); topDown.addMouseListener(new MouseListener() { public void mouseDown(MouseEvent e) { downX = e.x; downY = e.y; isMove = true; fireMouseDownEvent(e); } public void mouseUp(MouseEvent e) { isMove = false; fireMouseUpEvent(e); } public void mouseDoubleClick(MouseEvent e) { if (maximizeWhenDoubleClick && showMaxButton) doMaximize(); } }); topDown.addMouseMoveListener(new MouseMoveListener() { public void mouseMove(MouseEvent e) { if (isMove) { Point loc = shell.getLocation(); int x = loc.x + e.x - downX; int y = loc.y + e.y - downY; shell.setLocation(x, y); } } }); Label referenceLabel = null; // if (showButton) { Label lblClose = new Label(topDown, SWT.CENTER); lblClose.setImage(icons.getImage(IconHolder.bmpCloseNormal)); FormData fd = new FormData(); fd.top = new FormAttachment(0, 0); fd.bottom = new FormAttachment(0, 16); fd.right = new FormAttachment(100, -2); fd.left = new FormAttachment(100, -19); lblClose.setLayoutData(fd); lblClose.addMouseTrackListener(new MouseTrackAdapter() { @Override public void mouseEnter(MouseEvent e) { Label lbl = (Label) e.getSource(); lbl.setImage(icons.getImage(IconHolder.bmpCloseHover)); } @Override public void mouseExit(MouseEvent e) { Label lbl = (Label) e.getSource(); lbl.setImage(icons.getImage(IconHolder.bmpCloseNormal)); } }); lblClose.addMouseListener(new MouseAdapter() { @Override public void mouseDown(MouseEvent e) { Label lbl = (Label) e.getSource(); lbl.setImage(icons.getImage(IconHolder.bmpCloseDown)); } @Override public void mouseUp(MouseEvent e) { if (checkMinimizeWhenClose && main != null) { shell.close(); } else shell.close(); } }); referenceLabel = lblClose; } // if (showMaxButton) { lblMax = new Label(topDown, SWT.CENTER); lblMax.setImage(icons.getImage(IconHolder.bmpMaxNormal)); FormData fd = new FormData(); fd.top = new FormAttachment(0, 0); fd.bottom = new FormAttachment(0, 16); fd.right = new FormAttachment(referenceLabel, 0, SWT.LEFT); fd.left = new FormAttachment(referenceLabel, -17, SWT.LEFT); lblMax.setLayoutData(fd); lblMax.addMouseTrackListener(new MouseTrackAdapter() { @Override public void mouseEnter(MouseEvent e) { Label lbl = (Label) e.getSource(); lbl.setImage(shell.getMaximized() ? icons.getImage(IconHolder.bmpRestoreHover) : icons.getImage(IconHolder.bmpMaxHover)); } @Override public void mouseExit(MouseEvent e) { Label lbl = (Label) e.getSource(); lbl.setImage(shell.getMaximized() ? icons.getImage(IconHolder.bmpRestoreNormal) : icons.getImage(IconHolder.bmpMaxNormal)); } }); lblMax.addMouseListener(new MouseAdapter() { @Override public void mouseDown(MouseEvent e) { Label lbl = (Label) e.getSource(); lbl.setImage(shell.getMaximized() ? icons.getImage(IconHolder.bmpRestoreDown) : icons.getImage(IconHolder.bmpMaxDown)); } @Override public void mouseUp(MouseEvent e) { doMaximize(); } }); referenceLabel = lblMax; } if (showButton) { // ? Label lblMin = new Label(topDown, SWT.CENTER); lblMin.setImage(icons.getImage(IconHolder.bmpMinNormal)); FormData fd = new FormData(); fd.top = new FormAttachment(0, 0); fd.bottom = new FormAttachment(0, 16); fd.right = new FormAttachment(referenceLabel, 0, SWT.LEFT); fd.left = new FormAttachment(referenceLabel, -16, SWT.LEFT); lblMin.setLayoutData(fd); lblMin.addMouseTrackListener(new MouseTrackAdapter() { @Override public void mouseEnter(MouseEvent e) { Label lbl = (Label) e.getSource(); lbl.setImage(icons.getImage(IconHolder.bmpMinHover)); } @Override public void mouseExit(MouseEvent e) { Label lbl = (Label) e.getSource(); lbl.setImage(icons.getImage(IconHolder.bmpMinNormal)); } }); lblMin.addMouseListener(new MouseAdapter() { @Override public void mouseDown(MouseEvent e) { Label lbl = (Label) e.getSource(); lbl.setImage(icons.getImage(IconHolder.bmpMinDown)); } @Override public void mouseUp(MouseEvent e) { Label lbl = (Label) e.getSource(); lbl.setImage(icons.getImage(IconHolder.bmpMinHover)); shell.setMinimized(true); if (hideWhenMinimize) shell.setVisible(false); } }); } right = new Label(shell, SWT.LEFT); gd = new GridData(GridData.FILL_VERTICAL); gd.widthHint = 5; gd.verticalSpan = 2; right.setLayoutData(gd); if (resizable) right.setCursor(display.getSystemCursor(SWT.CURSOR_SIZEWE)); right.addPaintListener(new PaintListener() { public void paintControl(PaintEvent e) { Rectangle bound = ((Control) e.getSource()).getBounds(); int i = 4; for (Color c : Colors.MAINSHELL_BORDERS) { e.gc.setForeground(c); e.gc.drawLine(i, 0, i, bound.height); i--; } } }); if (resizable) { right.addMouseListener(new MouseAdapter() { @Override public void mouseDown(MouseEvent e) { Control control = (Control) e.getSource(); downX = control.toDisplay(e.x, e.y).x; } @Override public void mouseUp(MouseEvent e) { Control control = (Control) e.getSource(); int newX = control.toDisplay(e.x, e.y).x; int dx = newX - downX; if (dx == 0) return; Point size = shell.getSize(); size.x += dx; setShellSize(size); } }); } center = new Composite(shell, SWT.NONE); center.setLayoutData(new GridData(GridData.FILL_BOTH)); //layout = new GridLayout(); //layout.marginHeight = layout.marginWidth = layout.horizontalSpacing = layout.verticalSpacing = 0; //center.setLayout(layout); Composite leftBottom = new Composite(shell, SWT.NONE | SWT.NO_BACKGROUND); if (resizable) leftBottom.setCursor(display.getSystemCursor(SWT.CURSOR_SIZENESW)); gd = new GridData(); gd.widthHint = gd.heightHint = 5; leftBottom.setLayoutData(gd); leftBottom.addPaintListener(new PaintListener() { public void paintControl(PaintEvent e) { Rectangle bound = ((Control) e.getSource()).getBounds(); int i = 0; for (Color c : Colors.MAINSHELL_BORDERS) { e.gc.setForeground(c); e.gc.drawLine(i, bound.height - i - 1, i, 0); e.gc.drawLine(i, bound.height - i - 1, bound.width, bound.height - i - 1); i++; } } }); if (resizable) { leftBottom.addMouseListener(new MouseAdapter() { @Override public void mouseDown(MouseEvent e) { Control control = (Control) e.getSource(); Point loc = control.toDisplay(e.x, e.y); downX = loc.x; downY = loc.y; } @Override public void mouseUp(MouseEvent e) { Control control = (Control) e.getSource(); Point loc = control.toDisplay(e.x, e.y); int dx = downX - loc.x; int dy = loc.y - downY; if (dx == 0 && dy == 0) return; Rectangle bound = shell.getBounds(); bound.x -= dx; bound.width += dx; bound.height += dy; setShellBound(bound); } }); } bottom = new Label(shell, SWT.LEFT); if (resizable) bottom.setCursor(display.getSystemCursor(SWT.CURSOR_SIZENS)); gd = new GridData(GridData.FILL_HORIZONTAL); gd.heightHint = 5; bottom.setLayoutData(gd); bottom.addPaintListener(new PaintListener() { public void paintControl(PaintEvent e) { Rectangle bound = ((Control) e.getSource()).getBounds(); int i = 0; for (Color c : Colors.MAINSHELL_BORDERS) { e.gc.setForeground(c); e.gc.drawLine(0, 5 - i - 1, bound.width, 5 - i - 1); i++; } } }); if (resizable) { bottom.addMouseListener(new MouseAdapter() { @Override public void mouseDown(MouseEvent e) { Control control = (Control) e.getSource(); downY = control.toDisplay(e.x, e.y).y; } @Override public void mouseUp(MouseEvent e) { Control control = (Control) e.getSource(); int newY = control.toDisplay(e.x, e.y).y; int dy = newY - downY; if (dy == 0) return; Point size = shell.getSize(); size.y += dy; setShellSize(size); } }); } Composite rightBottom = new Composite(shell, SWT.NONE | SWT.NO_BACKGROUND); if (resizable) rightBottom.setCursor(display.getSystemCursor(SWT.CURSOR_SIZENWSE)); gd = new GridData(); gd.widthHint = gd.heightHint = 5; rightBottom.setLayoutData(gd); rightBottom.addPaintListener(new PaintListener() { public void paintControl(PaintEvent e) { Rectangle bound = ((Control) e.getSource()).getBounds(); int i = 0; for (Color c : Colors.MAINSHELL_BORDERS) { e.gc.setForeground(c); e.gc.drawLine(bound.width - i - 1, bound.height - i - 1, bound.width - i - 1, 0); e.gc.drawLine(bound.width - i - 1, bound.height - i - 1, 0, bound.height - i - 1); i++; } } }); if (resizable) { rightBottom.addMouseListener(new MouseAdapter() { @Override public void mouseDown(MouseEvent e) { Control control = (Control) e.getSource(); Point loc = control.toDisplay(e.x, e.y); downX = loc.x; downY = loc.y; } @Override public void mouseUp(MouseEvent e) { Control control = (Control) e.getSource(); Point loc = control.toDisplay(e.x, e.y); int dx = loc.x - downX; int dy = loc.y - downY; if (dx == 0 && dy == 0) return; Point size = shell.getSize(); size.x += dx; size.y += dy; setShellSize(size); } }); } return center; }
From source file:com.kdmanalytics.toif.report.internal.providers.ReportLabelProvider.java
License:Open Source License
@Override public Font getFont(final Object element) { if (element instanceof IFileGroup) { return JFaceResources.getFontRegistry().getBold(JFaceResources.DIALOG_FONT); }// w w w. j a va 2s. co m return null; }
From source file:com.liferay.ide.project.ui.pref.AbstractValidationSettingsPage.java
License:Open Source License
protected ExpandableComposite createTwistie(Composite parent, String label, int nColumns) { ExpandableComposite excomposite = new ExpandableComposite(parent, SWT.NONE, ExpandableComposite.TWISTIE | ExpandableComposite.CLIENT_INDENT); excomposite.setText(label);//from w ww.j a v a 2 s . c om excomposite.setExpanded(false); excomposite.setFont(JFaceResources.getFontRegistry().getBold(JFaceResources.DIALOG_FONT)); excomposite.setLayoutData(new GridData(GridData.FILL, GridData.FILL, true, false, nColumns, 1)); excomposite.addExpansionListener(new ExpansionAdapter() { @Override public void expansionStateChanged(ExpansionEvent e) { expandedStateChanged((ExpandableComposite) e.getSource()); } }); fExpandables.add(excomposite); makeScrollableCompositeAware(excomposite); return excomposite; }
From source file:com.mentor.nucleus.bp.ui.graphics.editor.GraphicalEditor.java
License:Open Source License
@Override protected void initializeGraphicalViewer() { super.initializeGraphicalViewer(); if (fModel != null) { getGraphicalViewer().setContents(fModel); }//from ww w .j ava 2 s . c om configureGridOptions(); // add self to font property change listener list JFaceResources.getFontRegistry().addListener(this); }
From source file:com.mentor.nucleus.bp.ui.graphics.editor.GraphicalEditor.java
License:Open Source License
@Override public void dispose() { getEditorSite().getPage().removePartListener(this); super.dispose(); Ooaofooa.getDefaultInstance().removeModelChangeListener(fEditorListener); Ooaofgraphics.getDefaultInstance().removeModelChangeListener(fEditorListener); if (getTransactionManager() != null) getTransactionManager().removeTransactionListener(fEditorListener); fInstances.remove(this); if (fInstances.isEmpty()) { // if we are the last diagram editor, then dispose // the font used if (diagramFont != null && diagramFont != PlatformUI.getWorkbench().getDisplay().getSystemFont()) { diagramFont.dispose();//from w ww.j ava2 s . com diagramFont = null; } } Collection<BPToolTipHelper> helpers = tooltipMap.values(); for (BPToolTipHelper helper : helpers) { helper.dispose(); } JFaceResources.getFontRegistry().removeListener(this); }