Permalink
Browse files

Implement basic customizable label decorations with preferences

Currently the only binding available is the resource name, but
this commit enables a framework for adding more bindings.

Signed-off-by: Tor Arne Vestbø <torarnv@gmail.com>
Signed-off-by: Robin Rosenberg <robin.rosenberg@dewire.com>
  • Loading branch information...
1 parent 3d50319 commit 6e2161e6738594c9385f09fc21ded5606b177208 @torarnv torarnv committed with robinrosenberg Feb 11, 2009
@@ -64,3 +64,4 @@ Theme_CommitMessageFont_description=This font is used to show a commit message.
GitPreferences_name=Git
GitPreferences_HistoryPreferencePage_name=History
GitPreferences_WindowCachePreferencePage_name=Window Cache
+GitPreferences_DecoratorPreferencePage_name=Label Decorations
@@ -200,6 +200,14 @@
id="org.spearce.egit.ui.keyword.git">
</keywordReference>
</page>
+ <page name="%GitPreferences_DecoratorPreferencePage_name"
+ category="org.spearce.egit.ui.GitPreferences"
+ class="org.spearce.egit.ui.internal.preferences.GitDecoratorPreferencePage"
+ id="org.spearce.egit.ui.internal.preferences.GitDecoratorPreferencePage" >
+ <keywordReference
+ id="org.spearce.egit.ui.keyword.git">
+ </keywordReference>
+ </page>
</extension>
<extension point="org.eclipse.ui.propertyPages">
@@ -233,10 +241,10 @@
lightweight="true"
adaptable="true"
label="%Decorator_name"
- class="org.spearce.egit.ui.internal.decorators.GitResourceDecorator"
+ class="org.spearce.egit.ui.internal.decorators.GitLightweightDecorator"
state="true"
location="BOTTOM_RIGHT"
- id="org.spearce.egit.ui.internal.decorators.GitResourceDecorator">
+ id="org.spearce.egit.ui.internal.decorators.GitLightweightDecorator">
<enablement>
<objectClass name="org.eclipse.core.resources.IResource"/>
</enablement>
@@ -33,6 +33,7 @@
import org.eclipse.jface.util.PropertyChangeEvent;
import org.eclipse.jsch.core.IJSchService;
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;
@@ -80,6 +81,21 @@ public static String getPluginId() {
}
/**
+ * 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 exception.
*
* @param message
@@ -35,6 +35,14 @@ public void initializeDefaultPreferences() {
prefs.setDefault(UIPreferences.RESOURCEHISTORY_SHOW_REV_COMMENT, true);
prefs.setDefault(UIPreferences.RESOURCEHISTORY_SHOW_TOOLTIPS, false);
+ prefs.setDefault(UIPreferences.DECORATOR_FILETEXT_DECORATION,
+ UIText.DecoratorPreferencesPage_fileFormatDefault);
+ prefs.setDefault(UIPreferences.DECORATOR_FOLDERTEXT_DECORATION,
+ UIText.DecoratorPreferencesPage_folderFormatDefault);
+ prefs.setDefault(UIPreferences.DECORATOR_PROJECTTEXT_DECORATION,
+ UIText.DecoratorPreferencesPage_projectFormatDefault);
+ prefs.setDefault(UIPreferences.DECORATOR_CALCULATE_DIRTY, true);
+
w = new int[] { 500, 500 };
UIPreferences.setDefault(prefs,
UIPreferences.RESOURCEHISTORY_GRAPH_SPLIT, w);
@@ -52,6 +52,15 @@
/** */
public final static String THEME_CommitMessageFont = "org.spearce.egit.ui.CommitMessageFont";
+ /** */
+ public final static String DECORATOR_CALCULATE_DIRTY = "decorator_calculate_dirty";
+ /** */
+ public final static String DECORATOR_FILETEXT_DECORATION = "decorator_filetext_decoration";
+ /** */
+ public final static String DECORATOR_FOLDERTEXT_DECORATION = "decorator_foldertext_decoration";
+ /** */
+ public final static String DECORATOR_PROJECTTEXT_DECORATION = "decorator_projecttext_decoration";
+
/**
* Get the preference values associated with a fixed integer array.
*
@@ -446,9 +446,6 @@
public static String RefSpecPage_annotatedTagsNoTags;
/** */
- public static String Decorator_failedLazyLoading;
-
- /** */
public static String QuickDiff_failedLoading;
/** */
@@ -928,6 +925,66 @@
/** */
public static String HistoryPage_ShowAllVersionsForFolder;
+ /** */
+ public static String Decorator_exceptionMessage;
+
+ /** */
+ public static String DecoratorPreferencesPage_addVariablesTitle;
+
+ /** */
+ public static String DecoratorPreferencesPage_addVariablesAction;
+
+ /** */
+ public static String DecoratorPreferencesPage_computeDeep;
+
+ /** */
+ public static String DecoratorPreferencesPage_description;
+
+ /** */
+ public static String DecoratorPreferencesPage_decorationSettings;
+
+ /** */
+ public static String DecoratorPreferencesPage_preview;
+
+ /** */
+ public static String DecoratorPreferencesPage_fileFormatLabel;
+
+ /** */
+ public static String DecoratorPreferencesPage_folderFormatLabel;
+
+ /** */
+ public static String DecoratorPreferencesPage_projectFormatLabel;
+
+ /** */
+ public static String DecoratorPreferencesPage_fileFormatDefault;
+
+ /** */
+ public static String DecoratorPreferencesPage_projectFormatDefault;
+
+ /** */
+ public static String DecoratorPreferencesPage_folderFormatDefault;
+
+ /** */
+ public static String DecoratorPreferencesPage_generalTabFolder;
+
+ /** */
+ public static String DecoratorPreferencesPage_nameResourceVariable;
+
+ /** */
+ public static String DecoratorPreferencesPage_selectFormats;
+
+ /** */
+ public static String DecoratorPreferencesPage_selectVariablesToAdd;
+
+ /** */
+ public static String DecoratorPreferencesPage_textLabel;
+
+ /** */
+ public static String DecoratorPreferencesPage_iconLabel;
+
+ /** */
+ public static String DecoratorPreferencesPage_labelDecorationsLink;
+
static {
initializeMessages(UIText.class.getPackage().getName() + ".uitext",
UIText.class);
@@ -19,7 +19,7 @@
import org.eclipse.jface.operation.IRunnableWithProgress;
import org.eclipse.swt.widgets.Display;
import org.spearce.egit.core.op.BranchOperation;
-import org.spearce.egit.ui.internal.decorators.GitResourceDecorator;
+import org.spearce.egit.ui.internal.decorators.GitLightweightDecorator;
import org.spearce.egit.ui.internal.dialogs.BranchSelectionDialog;
import org.spearce.jgit.lib.Repository;
@@ -56,7 +56,7 @@ public void run(final IProgressMonitor monitor)
throws InvocationTargetException {
try {
new BranchOperation(repository, refName).run(monitor);
- GitResourceDecorator.refresh();
+ GitLightweightDecorator.refresh();
} catch (final CoreException ce) {
ce.printStackTrace();
Display.getDefault().asyncExec(new Runnable() {
@@ -13,7 +13,7 @@
import org.eclipse.core.resources.IWorkspaceRunnable;
import org.eclipse.jface.action.IAction;
import org.spearce.egit.core.op.DisconnectProviderOperation;
-import org.spearce.egit.ui.internal.decorators.GitResourceDecorator;
+import org.spearce.egit.ui.internal.decorators.GitLightweightDecorator;
/**
* Action to disassociate a project from its Git repository.
@@ -27,6 +27,6 @@ protected IWorkspaceRunnable createOperation(final IAction act,
}
protected void postOperation() {
- GitResourceDecorator.refresh();
+ GitLightweightDecorator.refresh();
}
}
@@ -19,7 +19,7 @@
import org.eclipse.jface.operation.IRunnableWithProgress;
import org.spearce.egit.core.op.ResetOperation;
import org.spearce.egit.core.op.ResetOperation.ResetType;
-import org.spearce.egit.ui.internal.decorators.GitResourceDecorator;
+import org.spearce.egit.ui.internal.decorators.GitLightweightDecorator;
import org.spearce.egit.ui.internal.dialogs.BranchSelectionDialog;
import org.spearce.jgit.lib.Repository;
@@ -55,7 +55,7 @@ public void run(final IProgressMonitor monitor)
throws InvocationTargetException {
try {
new ResetOperation(repository, refName, type).run(monitor);
- GitResourceDecorator.refresh();
+ GitLightweightDecorator.refresh();
} catch (CoreException ce) {
ce.printStackTrace();
throw new InvocationTargetException(ce);
Oops, something went wrong.

0 comments on commit 6e2161e

Please sign in to comment.