From 6ec8efd703c3b5dd1bc7f423b6dabc41fcb1ee13 Mon Sep 17 00:00:00 2001 From: Mathias Kinzler Date: Mon, 26 Apr 2010 17:13:11 +0200 Subject: [PATCH] Cleanup: remove methods from Activator Some methods in the Activator were moved to the appropriate classes that need them or dropped altogether as they were not used anywhere. Change-Id: Ic7ec277e2dc66fbe4093a81a04a40c317807bc37 Signed-off-by: Mathias Kinzler --- .../src/org/eclipse/egit/ui/Activator.java | 50 ---------------------- .../src/org/eclipse/egit/ui/UIUtils.java | 40 +++++++++++++++++ .../egit/ui/internal/history/CommitGraphTable.java | 17 ++++---- .../ui/internal/history/CommitMessageViewer.java | 4 +- 4 files changed, 52 insertions(+), 59 deletions(-) create mode 100644 org.eclipse.egit.ui/src/org/eclipse/egit/ui/UIUtils.java diff --git a/org.eclipse.egit.ui/src/org/eclipse/egit/ui/Activator.java b/org.eclipse.egit.ui/src/org/eclipse/egit/ui/Activator.java index da6ec02d..4ea7b029 100644 --- a/org.eclipse.egit.ui/src/org/eclipse/egit/ui/Activator.java +++ b/org.eclipse.egit.ui/src/org/eclipse/egit/ui/Activator.java @@ -40,10 +40,7 @@ import org.eclipse.jgit.lib.RepositoryListener; import org.eclipse.jgit.transport.SshSessionFactory; import org.eclipse.jsch.core.IJSchService; import org.eclipse.osgi.service.debug.DebugOptions; -import org.eclipse.swt.graphics.Font; -import org.eclipse.swt.widgets.Display; import org.eclipse.ui.plugin.AbstractUIPlugin; -import org.eclipse.ui.themes.ITheme; import org.osgi.framework.BundleContext; import org.osgi.framework.ServiceReference; import org.osgi.util.tracker.ServiceTracker; @@ -83,20 +80,6 @@ public class Activator extends AbstractUIPlugin { return getDefault().getBundle().getSymbolicName(); } - /** - * Returns the standard display to be used. The method first checks, if the - * thread calling this method has an associated display. If so, this display - * is returned. Otherwise the method returns the default display. - * - * @return the display to use - */ - public static Display getStandardDisplay() { - Display display = Display.getCurrent(); - if (display == null) { - display = Display.getDefault(); - } - return display; - } /** * Instantiate an error status. @@ -123,39 +106,6 @@ public class Activator extends AbstractUIPlugin { new Status(IStatus.ERROR, getPluginId(), 0, message, thr)); } - /** - * Get the theme used by this plugin. - * - * @return our theme. - */ - public static ITheme getTheme() { - return plugin.getWorkbench().getThemeManager().getCurrentTheme(); - } - - /** - * Get a font known to this plugin. - * - * @param id - * one of our THEME_* font preference ids (see - * {@link UIPreferences}); - * @return the configured font, borrowed from the registry. - */ - public static Font getFont(final String id) { - return getTheme().getFontRegistry().get(id); - } - - /** - * Get a font known to this plugin, but with bold style applied over top. - * - * @param id - * one of our THEME_* font preference ids (see - * {@link UIPreferences}); - * @return the configured font, borrowed from the registry. - */ - public static Font getBoldFont(final String id) { - return getTheme().getFontRegistry().getBold(id); - } - private RCS rcs; private RIRefresh refreshJob; diff --git a/org.eclipse.egit.ui/src/org/eclipse/egit/ui/UIUtils.java b/org.eclipse.egit.ui/src/org/eclipse/egit/ui/UIUtils.java new file mode 100644 index 00000000..58e3672a --- /dev/null +++ b/org.eclipse.egit.ui/src/org/eclipse/egit/ui/UIUtils.java @@ -0,0 +1,40 @@ +/******************************************************************************* + * Copyright (c) 2010 SAP AG. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * Mathias Kinzler (SAP AG) - initial implementation + *******************************************************************************/ +package org.eclipse.egit.ui; + +import org.eclipse.jface.resource.FontRegistry; +import org.eclipse.swt.graphics.Font; +import org.eclipse.ui.PlatformUI; + +/** + * Some utilities for UI code + */ +public class UIUtils { + + /** + * @param id see {@link FontRegistry#get(String)} + * @return the font + */ + public static Font getFont(final String id) { + return PlatformUI.getWorkbench().getThemeManager().getCurrentTheme() + .getFontRegistry().get(id); + } + + /** + * @param id see {@link FontRegistry#getBold(String)} + * @return the font + */ + public static Font getBoldFont(final String id) { + return PlatformUI.getWorkbench().getThemeManager().getCurrentTheme() + .getFontRegistry().getBold(id); + } + +} diff --git a/org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/history/CommitGraphTable.java b/org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/history/CommitGraphTable.java index 60ee18b1..4c75187d 100644 --- a/org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/history/CommitGraphTable.java +++ b/org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/history/CommitGraphTable.java @@ -13,9 +13,9 @@ package org.eclipse.egit.ui.internal.history; import java.util.Iterator; -import org.eclipse.egit.ui.Activator; import org.eclipse.egit.ui.UIPreferences; import org.eclipse.egit.ui.UIText; +import org.eclipse.egit.ui.UIUtils; import org.eclipse.jface.viewers.ColumnWeightData; import org.eclipse.jface.viewers.ISelection; import org.eclipse.jface.viewers.ISelectionChangedListener; @@ -24,6 +24,9 @@ import org.eclipse.jface.viewers.ITableLabelProvider; import org.eclipse.jface.viewers.StructuredSelection; import org.eclipse.jface.viewers.TableLayout; import org.eclipse.jface.viewers.TableViewer; +import org.eclipse.jgit.revplot.PlotCommit; +import org.eclipse.jgit.revwalk.RevCommit; +import org.eclipse.jgit.revwalk.RevFlag; import org.eclipse.swt.SWT; import org.eclipse.swt.dnd.Clipboard; import org.eclipse.swt.dnd.DND; @@ -42,16 +45,13 @@ import org.eclipse.swt.widgets.Table; import org.eclipse.swt.widgets.TableColumn; import org.eclipse.swt.widgets.TableItem; import org.eclipse.swt.widgets.Widget; -import org.eclipse.jgit.revplot.PlotCommit; -import org.eclipse.jgit.revwalk.RevCommit; -import org.eclipse.jgit.revwalk.RevFlag; class CommitGraphTable { private static Font highlightFont() { final Font n, h; - n = Activator.getFont(UIPreferences.THEME_CommitGraphNormalFont); - h = Activator.getFont(UIPreferences.THEME_CommitGraphHighlightFont); + n = UIUtils.getFont(UIPreferences.THEME_CommitGraphNormalFont); + h = UIUtils.getFont(UIPreferences.THEME_CommitGraphHighlightFont); final FontData[] nData = n.getFontData(); final FontData[] hData = h.getFontData(); @@ -61,7 +61,7 @@ class CommitGraphTable { if (!nData[i].equals(hData[i])) return h; - return Activator.getBoldFont(UIPreferences.THEME_CommitGraphNormalFont); + return UIUtils.getBoldFont(UIPreferences.THEME_CommitGraphNormalFont); } private final TableViewer table; @@ -79,7 +79,7 @@ class CommitGraphTable { private RevFlag highlight; CommitGraphTable(final Composite parent) { - nFont = Activator.getFont(UIPreferences.THEME_CommitGraphNormalFont); + nFont = UIUtils.getFont(UIPreferences.THEME_CommitGraphNormalFont); hFont = highlightFont(); Table rawTable = new Table(parent, SWT.MULTI | SWT.H_SCROLL @@ -236,4 +236,5 @@ class CommitGraphTable { public TableViewer getTableView() { return table; } + } diff --git a/org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/history/CommitMessageViewer.java b/org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/history/CommitMessageViewer.java index f3b0ad0e..1c9c633f 100644 --- a/org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/history/CommitMessageViewer.java +++ b/org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/history/CommitMessageViewer.java @@ -21,6 +21,7 @@ import org.eclipse.core.runtime.ListenerList; import org.eclipse.egit.ui.Activator; import org.eclipse.egit.ui.UIPreferences; import org.eclipse.egit.ui.UIText; +import org.eclipse.egit.ui.UIUtils; import org.eclipse.jface.text.DefaultTextDoubleClickStrategy; import org.eclipse.jface.text.Document; import org.eclipse.jface.text.IDocument; @@ -86,7 +87,7 @@ class CommitMessageViewer extends TextViewer implements ISelectionChangedListene fmt = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); //$NON-NLS-1$ final StyledText t = getTextWidget(); - t.setFont(Activator.getFont(UIPreferences.THEME_CommitMessageFont)); + t.setFont(UIUtils.getFont(UIPreferences.THEME_CommitMessageFont)); sys_linkColor = t.getDisplay().getSystemColor(SWT.COLOR_BLUE); sys_darkgray = t.getDisplay().getSystemColor(SWT.COLOR_DARK_GRAY); @@ -392,4 +393,5 @@ class CommitMessageViewer extends TextViewer implements ISelectionChangedListene } } + } -- 2.11.4.GIT