List of usage examples for org.eclipse.jface.resource JFaceResources getColorRegistry
public static ColorRegistry getColorRegistry()
From source file:net.tourbook.ui.views.tagging.TaggingView.java
License:Open Source License
private void setCellColor(final ViewerCell cell, final Object element) { // set color/*from ww w.ja v a 2 s . c om*/ if (element instanceof TVITagViewTag) { cell.setForeground(JFaceResources.getColorRegistry().get(UI.VIEW_COLOR_TITLE)); } else if (element instanceof TVITagViewYear) { cell.setForeground(JFaceResources.getColorRegistry().get(UI.VIEW_COLOR_SUB)); } else if (element instanceof TVITagViewMonth) { cell.setForeground(JFaceResources.getColorRegistry().get(UI.VIEW_COLOR_SUB_SUB)); // } else if (element instanceof TVITagViewTour) { // cell.setForeground(JFaceResources.getColorRegistry().get(UI.VIEW_COLOR_TOUR)); } }
From source file:net.tourbook.ui.views.tourBook.TourBookView.java
License:Open Source License
/** * tree column: date//ww w .j a v a 2s.com */ private void defineColumn_1stColumn_Date() { final TreeColumnDefinition colDef = TreeColumnFactory.TIME_DATE.createColumn(_columnManager, _pc); colDef.setIsDefaultColumn(); colDef.setCanModifyVisibility(false); colDef.setLabelProvider(new TourInfoToolTipStyledCellLabelProvider() { @Override public Long getTourId(final ViewerCell cell) { if (_isToolTipInDate == false) { return null; } final Object element = cell.getElement(); if ((element instanceof TVITourBookTour)) { return ((TVITourBookItem) element).getTourId(); } return null; } @Override public void update(final ViewerCell cell) { final Object element = cell.getElement(); final TVITourBookItem tourItem = (TVITourBookItem) element; if (element instanceof TVITourBookTour) { // tour item cell.setText(tourItem.treeColumn); } else { // year/month or week item final StyledString styledString = new StyledString(); styledString.append(tourItem.treeColumn); styledString.append(UI.SPACE3); styledString.append(Long.toString(tourItem.colCounter), StyledString.QUALIFIER_STYLER); if (tourItem instanceof TVITourBookYearSub) { cell.setForeground(// JFaceResources.getColorRegistry().get(net.tourbook.ui.UI.VIEW_COLOR_SUB_SUB)); } else { cell.setForeground(// JFaceResources.getColorRegistry().get(net.tourbook.ui.UI.VIEW_COLOR_SUB)); } cell.setText(styledString.getString()); cell.setStyleRanges(styledString.getStyleRanges()); } setCellColor(cell, element); } }); }
From source file:net.tourbook.ui.views.tourBook.TourBookView.java
License:Open Source License
private void setCellColor(final ViewerCell cell, final Object element) { if (element instanceof TVITourBookYear) { cell.setForeground(JFaceResources.getColorRegistry().get(net.tourbook.ui.UI.VIEW_COLOR_SUB)); } else if (element instanceof TVITourBookYearSub) { cell.setForeground(JFaceResources.getColorRegistry().get(net.tourbook.ui.UI.VIEW_COLOR_SUB_SUB)); // } else if (element instanceof TVITourBookTour) { // cell.setForeground(JFaceResources.getColorRegistry().get(UI.VIEW_COLOR_TOUR)); }/*from ww w. j a v a2s. c om*/ }
From source file:net.tourbook.ui.views.tourCatalog.TourCompareResultView.java
License:Open Source License
private void setCellColor(final ViewerCell cell, final Object element) { if (element instanceof TVICompareResultReferenceTour) { cell.setForeground(JFaceResources.getColorRegistry().get(net.tourbook.ui.UI.VIEW_COLOR_TITLE)); } else if (element instanceof TVICompareResultComparedTour) { // show the saved tours in a different color if (((TVICompareResultComparedTour) (element)).isSaved()) { cell.setForeground(Display.getDefault().getSystemColor(SWT.COLOR_GRAY)); } else {/*from w w w. ja va 2s . co m*/ // show the text with tour color cell.setForeground(JFaceResources.getColorRegistry().get(net.tourbook.ui.UI.VIEW_COLOR_TOUR)); // cell.setForeground(Display.getDefault().getSystemColor(SWT.COLOR_WIDGET_FOREGROUND)); } } }
From source file:net.tourbook.ui.views.TourSegmenterView.java
License:Open Source License
private void setCellColor(final ViewerCell cell, final int altiDiff) { if (altiDiff == 0) { cell.setBackground(Display.getCurrent().getSystemColor(SWT.COLOR_LIST_BACKGROUND)); } else if (altiDiff > 0) { cell.setBackground(JFaceResources.getColorRegistry().get(UI.VIEW_COLOR_BG_SEGMENTER_UP)); } else if (altiDiff < 0) { cell.setBackground(JFaceResources.getColorRegistry().get(UI.VIEW_COLOR_BG_SEGMENTER_DOWN)); }/*from ww w.j a v a2 s .co m*/ }
From source file:no.resheim.elibrarium.epub.ui.reader.EpubReader.java
License:Open Source License
@Override public void createPartControl(Composite parent) { Composite c = new Composite(parent, SWT.NONE); c.setBackground(JFaceResources.getColorRegistry().get(JFacePreferences.ERROR_COLOR)); GridLayout layout = new GridLayout(); layout.numColumns = 2;//from www .j a va2 s. c o m layout.marginTop = 0; c.setLayout(layout); c.setBackground(Display.getDefault().getSystemColor(SWT.COLOR_WHITE)); GridData gdHeader = new GridData(SWT.CENTER, SWT.TOP, true, false); gdHeader.minimumWidth = 500; headerLabel = new Label(c, SWT.CENTER); headerLabel.setLayoutData(gdHeader); headerLabel.setText(" "); headerLabel.setForeground(JFaceResources.getColorRegistry().get(JFacePreferences.QUALIFIER_COLOR)); GridData gdBookmark = new GridData(SWT.CENTER, SWT.BEGINNING, false, false); gdBookmark.minimumWidth = 32; gdBookmark.widthHint = 32; gdBookmark.verticalSpan = 3; bookmarkLabel = new Label(c, SWT.CENTER); bookmarkLabel .setImage(EpubUiPlugin.getDefault().getImageRegistry().get(EpubUiPlugin.IMG_BOOKMARK_INACTIVE)); bookmarkLabel.setLayoutData(gdBookmark); bookmarkLabel.addMouseListener(new MouseListener() { @Override public void mouseUp(MouseEvent e) { } @Override public void mouseDown(MouseEvent e) { toggleBookmark(); } @Override public void mouseDoubleClick(MouseEvent e) { } }); // We rely on having a WebKit based browser GridData gdBrowser = new GridData(SWT.FILL, SWT.FILL, true, true); browser = new Browser(c, SWT.WEBKIT); browser.setLayoutData(gdBrowser); browser.setBackground(JFaceResources.getColorRegistry().get(JFacePreferences.ERROR_COLOR)); GridData gdFooter = new GridData(SWT.CENTER, SWT.BOTTOM, true, false); gdFooter.minimumWidth = 500; footerLabel = new Label(c, SWT.CENTER); gdFooter.horizontalSpan = 2; footerLabel.setLayoutData(gdFooter); footerLabel.setText(" "); footerLabel.setForeground(JFaceResources.getColorRegistry().get(JFacePreferences.QUALIFIER_COLOR)); // Install listener to figure out when we need to re-paginate resizeListener = new ResizeListener(); browser.addControlListener(resizeListener); browser.getDisplay().addFilter(SWT.MouseDown, resizeListener); browser.getDisplay().addFilter(SWT.MouseUp, resizeListener); // Various javascript installInjector(); // Handle key-presses installKeyListener(); // These events are triggered when the location of the browser has // changed, that is when the URL has changed. It may or may not be // within the document currently open. It does normally not change when // browsing between pages unless the chapter has been changed. // browser.addLocationListener(new LocationListener() { // // @Override // public void changed(LocationEvent event) { // updateLocation(); // } // // @Override // public void changing(LocationEvent event) { // } // }); browser.setCapture(false); if (browser != null) { if (initialURL != null) { browser.setUrl(initialURL); } } new MarkTextHandler(browser); // Create a new menu for the browser. We want this dynamically populated // so all items are removed when the menu is shown and it will be // re-populated. menu = new Menu(browser); browser.setMenu(menu); menu.addListener(SWT.Show, new Listener() { public void handleEvent(Event event) { MenuItem[] menuItems = menu.getItems(); for (MenuItem menuItem : menuItems) { menuItem.dispose(); } populateMenu(); } }); }
From source file:no.resheim.elibrarium.epub.ui.reader.TOCOutlinePage.java
License:Open Source License
private void installLabelProvider(final TableViewerColumn column) { final PrettyTime pt = new PrettyTime(); column.setLabelProvider(new OwnerDrawLabelProvider() { @Override//from w w w.ja v a 2s . c om protected void paint(Event event, Object element) { GC gc = event.gc; Display display = column.getViewer().getControl().getDisplay(); Bookmark bookmark = (Bookmark) element; String date = pt.format(bookmark.getTimestamp()); int width = column.getColumn().getWidth(); // Calculate the size of the date string Point size = event.gc.textExtent(date, SWT.DRAW_DELIMITER | SWT.DRAW_TAB); int halfHeight = size.y / 2; int height = size.y; // if ((event.detail & SWT.SELECTED) != 0) { // Region region = new Region(); // gc.getClipping(region); // region.translate(10, 10); // // region.add(event.x, event.y - halfHeight, width, // // event.height - halfHeight); // gc.setClipping(region); // region.dispose(); // // Rectangle rect = event.getBounds(); // Color foreground = gc.getForeground(); // Color background = gc.getBackground(); // gc.setForeground(display.getSystemColor(SWT.COLOR_LIST_SELECTION)); // gc.setBackground(display.getSystemColor(SWT.COLOR_LIST_BACKGROUND)); // gc.fillGradientRectangle(0, rect.y, 500, rect.height, false); // // restore colors for subsequent drawing // gc.setForeground(foreground); // gc.setBackground(background); // event.detail &= ~SWT.SELECTED; // } // Draw the date gc.setFont(getFont(DATE_FONT)); gc.setForeground(JFaceResources.getColorRegistry().get(JFacePreferences.QUALIFIER_COLOR)); gc.drawText(date, width - size.x, event.y + size.y, true); // Paint the page number of the bookmark int pageNumber = bookmark.getPage(); String page = Integer.toString(pageNumber); Point pageSize = event.gc.textExtent(page, SWT.DRAW_DELIMITER | SWT.DRAW_TAB); gc.drawText(page, width - 16 - pageSize.x, event.y, true); // Draw icon if (bookmark instanceof TextAnnotation) { } else { int x = width - 9; gc.drawImage(EpubUiPlugin.getDefault().getImageRegistry().get(EpubUiPlugin.IMG_BOOKMARK), x, event.y + 1); } // Draw title gc.setFont(getFont(TITLE_FONT)); gc.setForeground(display.getSystemColor(SWT.COLOR_LIST_FOREGROUND)); // Make sure text does not span to far Region region = new Region(); gc.getClipping(region); region.subtract(width - 32 - pageSize.x, event.y, width, height); gc.setClipping(region); region.dispose(); String text = bookmark.getText(); if (text == null) { text = "<missing text>"; } if (bookmark instanceof TextAnnotation) { if ((event.detail & SWT.SELECTED) == 0) { gc.setBackground(display.getSystemColor(SWT.COLOR_YELLOW)); gc.drawText(text, event.x + 1, event.y, false); } else { gc.drawText(text, event.x + 1, event.y, true); } } else { gc.drawText(text, event.x + 1, event.y, true); } // Draw separator drawUnderline(event, gc, width, size, halfHeight); } public Font getFont(String fontName) { IThemeManager themeManager = PlatformUI.getWorkbench().getThemeManager(); ITheme currentTheme = themeManager.getCurrentTheme(); FontRegistry fontRegistry = currentTheme.getFontRegistry(); Font font = fontRegistry.get(fontName); return font; } /** * Draws a separator between the rows. */ public void drawUnderline(Event event, GC gc, int width, Point size, int halfHeight) { int y = (event.y + size.y * 2) + halfHeight - 2; int center = (width / 2); gc.setForeground(JFaceResources.getColorRegistry().get(JFacePreferences.QUALIFIER_COLOR)); gc.setBackground(Display.getCurrent().getSystemColor(SWT.COLOR_LIST_BACKGROUND)); gc.fillGradientRectangle(center, y, center, 1, false); gc.setBackground(JFaceResources.getColorRegistry().get(JFacePreferences.QUALIFIER_COLOR)); gc.setForeground(Display.getCurrent().getSystemColor(SWT.COLOR_LIST_BACKGROUND)); gc.fillGradientRectangle(0, y, center, 1, false); } @Override protected void measure(Event event, Object element) { String text = "A"; Point size = event.gc.textExtent(text, SWT.DRAW_DELIMITER | SWT.DRAW_TAB); event.width = bookmarks.getTable().getColumn(event.index).getWidth(); // we need two lines of text and some space int halfHeight = size.y / 2; event.height = size.y * 2 + halfHeight; } }); }
From source file:org.absmodels.abs.plugin.Activator.java
License:Open Source License
public static void initializeColors() { ColorRegistry colorRegistry = JFaceResources.getColorRegistry(); colorRegistry.put(STYLER_COLOR_BLACK, STYLER_COLOR_BLACK_RGB); colorRegistry.put(STYLER_COLOR_GREY, STYLER_COLOR_GREY_RGB); colorRegistry.put(STYLER_COLOR_TYPES, STYLER_COLOR_TYPES_RGB); }
From source file:org.bbaw.pdr.ae.view.control.customSWTWidges.AspectPresentationTooltip.java
License:Open Source License
@Override protected final Composite createToolTipContentArea(final Event event, final Composite parent) { Composite comp = new Composite(parent, SWT.NONE); GridLayout gl = new GridLayout(1, false); gl.marginBottom = 0;//www . java 2 s.c o m gl.marginTop = 0; gl.marginHeight = 0; gl.marginWidth = 0; gl.marginLeft = 0; gl.marginRight = 0; gl.verticalSpacing = 1; comp.setLayout(gl); Composite topArea = new Composite(comp, SWT.NONE); GridData data = new GridData(SWT.FILL, SWT.FILL, true, false); data.widthHint = 200; topArea.setLayoutData(data); topArea.setBackground(JFaceResources.getColorRegistry().get(HEADER_BG_COLOR)); gl = new GridLayout(2, false); gl.marginBottom = 2; gl.marginTop = 2; gl.marginHeight = 0; gl.marginWidth = 0; gl.marginLeft = 5; gl.marginRight = 2; topArea.setLayout(gl); Label l = new Label(topArea, SWT.NONE); l.setText(_aspect.getDisplayNameWithID()); l.setBackground(JFaceResources.getColorRegistry().get(HEADER_BG_COLOR)); l.setFont(JFaceResources.getFontRegistry().get(HEADER_FONT)); l.setForeground(JFaceResources.getColorRegistry().get(HEADER_FG_COLOR)); l.setLayoutData(new GridData(GridData.FILL_BOTH)); Composite iconComp = new Composite(topArea, SWT.NONE); iconComp.setLayoutData(new GridData()); iconComp.setLayout(new GridLayout(2, false)); iconComp.setBackground(JFaceResources.getColorRegistry().get(HEADER_BG_COLOR)); gl = new GridLayout(2, false); gl.marginBottom = 0; gl.marginTop = 0; gl.marginHeight = 0; gl.marginWidth = 0; gl.marginLeft = 0; gl.marginRight = 0; iconComp.setLayout(gl); Label helpIcon = new Label(iconComp, SWT.NONE); helpIcon.setBackground(JFaceResources.getColorRegistry().get(HEADER_BG_COLOR)); helpIcon.setImage(_imageReg.get(IconsInternal.CANCEL)); helpIcon.addMouseListener(new MouseAdapter() { @Override public void mouseDown(final MouseEvent e) { hide(); // MarkupTooltip.this.dispose(); openHelp(); } }); Label closeIcon = new Label(iconComp, SWT.NONE); closeIcon.setBackground(JFaceResources.getColorRegistry().get(HEADER_BG_COLOR)); closeIcon.setImage(JFaceResources.getImage(HEADER_CLOSE_ICON)); closeIcon.addMouseListener(new MouseAdapter() { @Override public void mouseDown(final MouseEvent e) { _parentShell.setFocus(); hide(); // MarkupTooltip.this.dispose(); } }); createContentArea(comp).setLayoutData(new GridData(GridData.FILL_BOTH)); return comp; }
From source file:org.bbaw.pdr.ae.view.control.customSWTWidges.MarkupTooltip.java
License:Open Source License
@Override protected final Composite createToolTipContentArea(final Event event, final Composite parent) { Composite comp = new Composite(parent, SWT.NONE); GridLayout gl = new GridLayout(1, false); gl.marginBottom = 0;/*from w ww .j ava 2 s . c o m*/ gl.marginTop = 0; gl.marginHeight = 0; gl.marginWidth = 0; gl.marginLeft = 0; gl.marginRight = 0; gl.verticalSpacing = 1; comp.setLayout(gl); Composite topArea = new Composite(comp, SWT.NONE); GridData data = new GridData(SWT.FILL, SWT.FILL, true, false); data.widthHint = 200; topArea.setLayoutData(data); topArea.setBackground(JFaceResources.getColorRegistry().get(HEADER_BG_COLOR)); gl = new GridLayout(2, false); gl.marginBottom = 2; gl.marginTop = 2; gl.marginHeight = 0; gl.marginWidth = 0; gl.marginLeft = 5; gl.marginRight = 2; topArea.setLayout(gl); Label l = new Label(topArea, SWT.NONE); l.setText(_headerText); l.setBackground(JFaceResources.getColorRegistry().get(HEADER_BG_COLOR)); l.setFont(JFaceResources.getFontRegistry().get(HEADER_FONT)); l.setForeground(JFaceResources.getColorRegistry().get(HEADER_FG_COLOR)); l.setLayoutData(new GridData(GridData.FILL_BOTH)); Composite iconComp = new Composite(topArea, SWT.NONE); iconComp.setLayoutData(new GridData()); iconComp.setLayout(new GridLayout(2, false)); iconComp.setBackground(JFaceResources.getColorRegistry().get(HEADER_BG_COLOR)); gl = new GridLayout(2, false); gl.marginBottom = 0; gl.marginTop = 0; gl.marginHeight = 0; gl.marginWidth = 0; gl.marginLeft = 0; gl.marginRight = 0; iconComp.setLayout(gl); Label helpIcon = new Label(iconComp, SWT.NONE); helpIcon.setBackground(JFaceResources.getColorRegistry().get(HEADER_BG_COLOR)); helpIcon.setImage(_imageReg.get(IconsInternal.MARKUP)); helpIcon.addMouseListener(new MouseAdapter() { @Override public void mouseDown(final MouseEvent e) { hide(); // MarkupTooltip.this.dispose(); openHelp(); } }); Label closeIcon = new Label(iconComp, SWT.NONE); closeIcon.setBackground(JFaceResources.getColorRegistry().get(HEADER_BG_COLOR)); closeIcon.setImage(JFaceResources.getImage(HEADER_CLOSE_ICON)); closeIcon.addMouseListener(new MouseAdapter() { @Override public void mouseDown(final MouseEvent e) { _parentShell.setFocus(); hide(); // MarkupTooltip.this.dispose(); } }); createContentArea(comp).setLayoutData(new GridData(GridData.FILL_BOTH)); return comp; }