Skip to main content
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSteffen Pingel2012-04-23 05:08:27 +0000
committerSteffen Pingel2012-04-23 05:08:27 +0000
commit1b09a3013c05323beee7774ff990337c9dc49caf (patch)
tree6b9302490a78fd417f8fbeb5843517c3e214348e /org.eclipse.mylyn.tasks.ui
parentc15becf2347c94ec1c5ed151b64549423521091d (diff)
downloadorg.eclipse.mylyn.tasks-1b09a3013c05323beee7774ff990337c9dc49caf.tar.gz
org.eclipse.mylyn.tasks-1b09a3013c05323beee7774ff990337c9dc49caf.tar.xz
org.eclipse.mylyn.tasks-1b09a3013c05323beee7774ff990337c9dc49caf.zip
NEW - bug 374673: use <visibleWhen/> for contained components
https://bugs.eclipse.org/bugs/show_bug.cgi?id=374673
Diffstat (limited to 'org.eclipse.mylyn.tasks.ui')
-rw-r--r--org.eclipse.mylyn.tasks.ui/plugin.xml27
-rw-r--r--org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/internal/tasks/ui/TaskTrimWidget.java55
-rw-r--r--org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/internal/tasks/ui/util/TaskPreferenceTester.java39
3 files changed, 60 insertions, 61 deletions
diff --git a/org.eclipse.mylyn.tasks.ui/plugin.xml b/org.eclipse.mylyn.tasks.ui/plugin.xml
index 035577ed4..ac6400fc3 100644
--- a/org.eclipse.mylyn.tasks.ui/plugin.xml
+++ b/org.eclipse.mylyn.tasks.ui/plugin.xml
@@ -1942,6 +1942,13 @@
properties="connectorKind,userManaged"
type="org.eclipse.mylyn.tasks.core.TaskRepository">
</propertyTester>
+ <propertyTester
+ class="org.eclipse.mylyn.internal.tasks.ui.util.TaskPreferenceTester"
+ id="org.eclipse.mylyn.tasks.ui.propertyTester.Preferences"
+ namespace="org.eclipse.mylyn.tasks.ui.preferences"
+ properties="showTrim"
+ type="java.lang.Object">
+ </propertyTester>
</extension>
<extension
point="org.eclipse.mylyn.tasks.ui.taskRepositoryPageContribution">
@@ -2101,18 +2108,26 @@
label="Previous Task"
icon="icons/etool16/navigate-previous.gif"
style="pulldown">
+ <visibleWhen checkEnabled="false">
+ <test
+ forcePluginActivation="true"
+ property="org.eclipse.mylyn.tasks.ui.preferences.showTrim"
+ value="true">
+ </test>
+ </visibleWhen>
</command>
<control
class="org.eclipse.mylyn.internal.tasks.ui.TaskTrimWidget"
- id="org.eclipse.mylyn.tasks.ui.trim.control"/>
- <!-- Bug 201589: this does not have any effect
+ id="org.eclipse.mylyn.tasks.ui.trim.control">
<visibleWhen checkEnabled="false">
- <test forcePluginActivation="true"
- property="org.eclipse.mylyn.tasks.ui.trimEnabled"/>
+ <test
+ forcePluginActivation="true"
+ property="org.eclipse.mylyn.tasks.ui.preferences.showTrim"
+ value="true">
+ </test>
</visibleWhen>
- <visibleWhen><not><systemTest property="os.name" value="Windows XP"/></not></visibleWhen>
- -->
+ </control>
</toolbar>
</menuContribution>
</extension>
diff --git a/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/internal/tasks/ui/TaskTrimWidget.java b/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/internal/tasks/ui/TaskTrimWidget.java
index 544612029..89fd48932 100644
--- a/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/internal/tasks/ui/TaskTrimWidget.java
+++ b/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/internal/tasks/ui/TaskTrimWidget.java
@@ -16,9 +16,6 @@ import java.util.Set;
import org.eclipse.jface.action.IMenuListener;
import org.eclipse.jface.action.IMenuManager;
import org.eclipse.jface.action.MenuManager;
-import org.eclipse.jface.preference.IPreferenceStore;
-import org.eclipse.jface.util.IPropertyChangeListener;
-import org.eclipse.jface.util.PropertyChangeEvent;
import org.eclipse.jface.viewers.StructuredSelection;
import org.eclipse.mylyn.commons.ui.SelectionProviderAdapter;
import org.eclipse.mylyn.internal.tasks.core.ITaskListChangeListener;
@@ -43,14 +40,9 @@ import org.eclipse.swt.widgets.Composite;
import org.eclipse.swt.widgets.Control;
import org.eclipse.swt.widgets.Display;
import org.eclipse.swt.widgets.Menu;
-import org.eclipse.swt.widgets.ToolBar;
-import org.eclipse.ui.IWorkbenchWindow;
-import org.eclipse.ui.PlatformUI;
import org.eclipse.ui.forms.events.HyperlinkAdapter;
import org.eclipse.ui.forms.events.HyperlinkEvent;
import org.eclipse.ui.internal.ObjectActionContributorManager;
-import org.eclipse.ui.internal.WorkbenchWindow;
-import org.eclipse.ui.internal.layout.IWindowTrim;
import org.eclipse.ui.menus.WorkbenchWindowControlContribution;
/**
@@ -111,22 +103,6 @@ public class TaskTrimWidget extends WorkbenchWindowControlContribution {
}
};
- private final IPropertyChangeListener preferencesListener = new IPropertyChangeListener() {
- public void propertyChange(PropertyChangeEvent event) {
- String property = event.getProperty();
- if (property.equals(ITasksUiPreferenceConstants.SHOW_TRIM)) {
- Object newValue = event.getNewValue();
- Boolean isVisible = false;
- if (newValue instanceof Boolean) {
- isVisible = (Boolean) newValue;
- } else if (newValue instanceof String) {
- isVisible = Boolean.parseBoolean((String) newValue);
- }
- setTrimVisible(isVisible);
- }
- }
- };
-
private SelectionProviderAdapter activeTaskSelectionProvider;
private RepositoryElementActionGroup actionGroup;
@@ -134,21 +110,9 @@ public class TaskTrimWidget extends WorkbenchWindowControlContribution {
public TaskTrimWidget() {
TasksUi.getTaskActivityManager().addActivationListener(taskActivationListener);
TasksUiPlugin.getTaskList().addChangeListener(taskListListener);
- TasksUiPlugin.getDefault().getPreferenceStore().addPropertyChangeListener(preferencesListener);
hookContextMenu();
}
- private void setTrimVisible(boolean visible) {
- IWorkbenchWindow window = PlatformUI.getWorkbench().getActiveWorkbenchWindow();
- if (window instanceof WorkbenchWindow) {
- IWindowTrim trim = ((WorkbenchWindow) window).getTrimManager().getTrim(ID_CONTAINER);
- if (trim != null) {
- ((WorkbenchWindow) window).getTrimManager().setTrimVisible(trim, visible);
- ((WorkbenchWindow) window).getTrimManager().forceLayout();
- }
- }
- }
-
@Override
public void dispose() {
if (composite != null && !composite.isDisposed()) {
@@ -171,7 +135,6 @@ public class TaskTrimWidget extends WorkbenchWindowControlContribution {
TasksUi.getTaskActivityManager().removeActivationListener(taskActivationListener);
TasksUiPlugin.getTaskList().removeChangeListener(taskListListener);
- TasksUiPlugin.getDefault().getPreferenceStore().removePropertyChangeListener(preferencesListener);
}
@Override
@@ -190,27 +153,9 @@ public class TaskTrimWidget extends WorkbenchWindowControlContribution {
createStatusComposite(composite);
- if (!shouldShowTrim()) {
- if (parent instanceof ToolBar) {
- // bug 201589: it's not possible to hide the contribution on startup, as a work-around the tool bar is hidden which avoids flickering of the layout
- parent.setVisible(false);
- }
- // needs to be invoked asynchronously since the trim contribution is just getting constructed when createControl() is invoked
- parent.getDisplay().asyncExec(new Runnable() {
- public void run() {
- setTrimVisible(shouldShowTrim());
- }
- });
- }
-
return composite;
}
- private boolean shouldShowTrim() {
- IPreferenceStore uiPreferenceStore = TasksUiPlugin.getDefault().getPreferenceStore();
- return uiPreferenceStore.getBoolean(ITasksUiPreferenceConstants.SHOW_TRIM);
- }
-
private Composite createStatusComposite(final Composite container) {
GC gc = new GC(container);
Point p = gc.textExtent("WWWWWWWWWWWWWWW"); //$NON-NLS-1$
diff --git a/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/internal/tasks/ui/util/TaskPreferenceTester.java b/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/internal/tasks/ui/util/TaskPreferenceTester.java
new file mode 100644
index 000000000..d3b4d448e
--- /dev/null
+++ b/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/internal/tasks/ui/util/TaskPreferenceTester.java
@@ -0,0 +1,39 @@
+/*******************************************************************************
+ * Copyright (c) 2012 Tasktop Technologies and others.
+ * 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:
+ * Tasktop Technologies - initial API and implementation
+ *******************************************************************************/
+
+package org.eclipse.mylyn.internal.tasks.ui.util;
+
+import org.eclipse.core.expressions.PropertyTester;
+import org.eclipse.jface.preference.IPreferenceStore;
+import org.eclipse.mylyn.commons.core.CoreUtil;
+import org.eclipse.mylyn.internal.tasks.ui.ITasksUiPreferenceConstants;
+import org.eclipse.mylyn.internal.tasks.ui.TasksUiPlugin;
+
+/**
+ * @author Steffen Pingel
+ */
+public class TaskPreferenceTester extends PropertyTester {
+
+ private static final String PROPERTY_SHOW_TRIM = "showTrim"; //$NON-NLS-1$
+
+ public boolean test(Object receiver, String property, Object[] args, Object expectedValue) {
+ if (PROPERTY_SHOW_TRIM.equals(property)) {
+ return CoreUtil.propertyEquals(shouldShowTrim(), expectedValue);
+ }
+ return false;
+ }
+
+ private boolean shouldShowTrim() {
+ IPreferenceStore uiPreferenceStore = TasksUiPlugin.getDefault().getPreferenceStore();
+ return uiPreferenceStore.getBoolean(ITasksUiPreferenceConstants.SHOW_TRIM);
+ }
+
+}

Back to the top