diff options
author | spingel | 2008-05-15 22:26:34 +0000 |
---|---|---|
committer | spingel | 2008-05-15 22:26:34 +0000 |
commit | 4fb831c7b19543c0358534f42c94c1cc8901ae40 (patch) | |
tree | dd222a0f0f275a380c504735ca937acd5a7ee772 | |
parent | 4ef2b6aa7db83c134a60da6f59cef6049783278b (diff) | |
download | org.eclipse.mylyn.tasks-4fb831c7b19543c0358534f42c94c1cc8901ae40.tar.gz org.eclipse.mylyn.tasks-4fb831c7b19543c0358534f42c94c1cc8901ae40.tar.xz org.eclipse.mylyn.tasks-4fb831c7b19543c0358534f42c94c1cc8901ae40.zip |
NEW - bug 232412: decouple JIRA from Mylyn internals
https://bugs.eclipse.org/bugs/show_bug.cgi?id=232412
4 files changed, 162 insertions, 41 deletions
diff --git a/org.eclipse.mylyn.help.ui/src/org/eclipse/mylyn/internal/help/ui/dialogs/UiLegendDialog.java b/org.eclipse.mylyn.help.ui/src/org/eclipse/mylyn/internal/help/ui/dialogs/UiLegendDialog.java index c7171e2b6..df9d1567f 100644 --- a/org.eclipse.mylyn.help.ui/src/org/eclipse/mylyn/internal/help/ui/dialogs/UiLegendDialog.java +++ b/org.eclipse.mylyn.help.ui/src/org/eclipse/mylyn/internal/help/ui/dialogs/UiLegendDialog.java @@ -8,6 +8,7 @@ package org.eclipse.mylyn.internal.help.ui.dialogs; +import java.util.ArrayList; import java.util.Collection; import java.util.List; @@ -17,7 +18,6 @@ import org.eclipse.jface.preference.PreferenceDialog; import org.eclipse.mylyn.internal.provisional.commons.ui.CommonFonts; import org.eclipse.mylyn.internal.provisional.commons.ui.CommonImages; import org.eclipse.mylyn.internal.provisional.commons.ui.CommonThemes; -import org.eclipse.mylyn.internal.tasks.ui.TasksUiPlugin; import org.eclipse.mylyn.internal.tasks.ui.views.TaskElementLabelProvider; import org.eclipse.mylyn.internal.tasks.ui.views.TaskListView; import org.eclipse.mylyn.tasks.core.AbstractRepositoryConnector; @@ -25,6 +25,7 @@ import org.eclipse.mylyn.tasks.core.ITask; import org.eclipse.mylyn.tasks.core.ITaskElement; import org.eclipse.mylyn.tasks.core.ITask.PriorityLevel; import org.eclipse.mylyn.tasks.ui.AbstractRepositoryConnectorUi; +import org.eclipse.mylyn.tasks.ui.LegendElement; import org.eclipse.mylyn.tasks.ui.TasksUi; import org.eclipse.mylyn.tasks.ui.TasksUiImages; import org.eclipse.mylyn.tasks.ui.TasksUiUtil; @@ -62,6 +63,8 @@ public class UiLegendDialog extends PopupDialog { private final IThemeManager themeManager = PlatformUI.getWorkbench().getThemeManager(); + private final ArrayList<LegendElement> legendElements = new ArrayList<LegendElement>(); + // TODO e3.4 move to new api @SuppressWarnings("deprecation") public UiLegendDialog(Shell parent) { @@ -84,6 +87,9 @@ public class UiLegendDialog extends PopupDialog { @Override public boolean close() { + for (LegendElement element : legendElements) { + element.dispose(); + } if (toolkit != null) { if (toolkit.getColors() != null) { toolkit.dispose(); @@ -384,6 +390,7 @@ public class UiLegendDialog extends PopupDialog { toolkit.createLabel(synchroClient, "Conflicting changes, need to synchronize"); } + @SuppressWarnings("deprecation") private void createConnectorsSection(Composite parent) { TableWrapLayout layout = new TableWrapLayout(); layout.numColumns = 3; @@ -399,49 +406,97 @@ public class UiLegendDialog extends PopupDialog { Collection<AbstractRepositoryConnector> connectors = TasksUi.getRepositoryManager().getRepositoryConnectors(); for (AbstractRepositoryConnector connector : connectors) { - AbstractRepositoryConnectorUi connectorUi = TasksUiPlugin.getConnectorUi(connector.getConnectorKind()); + AbstractRepositoryConnectorUi connectorUi = TasksUi.getConnectorUi(connector.getConnectorKind()); if (connectorUi != null) { - List<ITask> elements = connectorUi.getLegendItems(); - if (!elements.isEmpty()) { - Section connectorSection = toolkit.createSection(composite, ExpandableComposite.TITLE_BAR); - connectorSection.setLayout(new TableWrapLayout()); - connectorSection.setLayoutData(new TableWrapData(TableWrapData.FILL_GRAB)); - - String label = connector.getLabel(); - int parenIndex = label.indexOf('('); - if (parenIndex != -1) { - label = label.substring(0, parenIndex); - } - connectorSection.setText(label); - - TableWrapLayout clientLayout = new TableWrapLayout(); - clientLayout.numColumns = 2; - clientLayout.makeColumnsEqualWidth = false; - clientLayout.verticalSpacing = 1; - clientLayout.topMargin = 1; - clientLayout.bottomMargin = 1; - - Composite connectorClient = toolkit.createComposite(connectorSection); - connectorClient.setLayout(clientLayout); - connectorClient.setLayoutData(new TableWrapData(TableWrapData.FILL_GRAB)); - connectorSection.setClient(connectorClient); - - Label imageLabel; - for (ITaskElement taskListElement : elements) { - imageLabel = toolkit.createLabel(connectorClient, ""); - imageLabel.setImage(labelProvider.getImage(taskListElement)); - toolkit.createLabel(connectorClient, taskListElement.getSummary()); - } - - if (elements.size() < 4) { - imageLabel = toolkit.createLabel(connectorClient, ""); - toolkit.createLabel(connectorClient, ""); + List<LegendElement> elements = connectorUi.getLegendElements(); + if (elements != null && elements.size() > 0) { + legendElements.addAll(elements); + addLegendElements(composite, connector, elements); + } else { + List<ITask> items = connectorUi.getLegendItems(); + if (items != null && !items.isEmpty()) { + addLegacyLegendItems(composite, connector, items); } } } } } + private void addLegendElements(Composite composite, AbstractRepositoryConnector connector, + List<LegendElement> elements) { + Section connectorSection = toolkit.createSection(composite, ExpandableComposite.TITLE_BAR); + connectorSection.setLayout(new TableWrapLayout()); + connectorSection.setLayoutData(new TableWrapData(TableWrapData.FILL_GRAB)); + + String label = connector.getLabel(); + int parenIndex = label.indexOf('('); + if (parenIndex != -1) { + label = label.substring(0, parenIndex); + } + connectorSection.setText(label); + + TableWrapLayout clientLayout = new TableWrapLayout(); + clientLayout.numColumns = 2; + clientLayout.makeColumnsEqualWidth = false; + clientLayout.verticalSpacing = 1; + clientLayout.topMargin = 1; + clientLayout.bottomMargin = 1; + + Composite connectorClient = toolkit.createComposite(connectorSection); + connectorClient.setLayout(clientLayout); + connectorClient.setLayoutData(new TableWrapData(TableWrapData.FILL_GRAB)); + connectorSection.setClient(connectorClient); + + Label imageLabel; + for (LegendElement element : elements) { + imageLabel = toolkit.createLabel(connectorClient, ""); + imageLabel.setImage(element.getImage()); + toolkit.createLabel(connectorClient, element.getLabel()); + } + + if (elements.size() < 4) { + imageLabel = toolkit.createLabel(connectorClient, ""); + toolkit.createLabel(connectorClient, ""); + } + } + + private void addLegacyLegendItems(Composite composite, AbstractRepositoryConnector connector, List<ITask> elements) { + Section connectorSection = toolkit.createSection(composite, ExpandableComposite.TITLE_BAR); + connectorSection.setLayout(new TableWrapLayout()); + connectorSection.setLayoutData(new TableWrapData(TableWrapData.FILL_GRAB)); + + String label = connector.getLabel(); + int parenIndex = label.indexOf('('); + if (parenIndex != -1) { + label = label.substring(0, parenIndex); + } + connectorSection.setText(label); + + TableWrapLayout clientLayout = new TableWrapLayout(); + clientLayout.numColumns = 2; + clientLayout.makeColumnsEqualWidth = false; + clientLayout.verticalSpacing = 1; + clientLayout.topMargin = 1; + clientLayout.bottomMargin = 1; + + Composite connectorClient = toolkit.createComposite(connectorSection); + connectorClient.setLayout(clientLayout); + connectorClient.setLayoutData(new TableWrapData(TableWrapData.FILL_GRAB)); + connectorSection.setClient(connectorClient); + + Label imageLabel; + for (ITaskElement taskListElement : elements) { + imageLabel = toolkit.createLabel(connectorClient, ""); + imageLabel.setImage(labelProvider.getImage(taskListElement)); + toolkit.createLabel(connectorClient, taskListElement.getSummary()); + } + + if (elements.size() < 4) { + imageLabel = toolkit.createLabel(connectorClient, ""); + toolkit.createLabel(connectorClient, ""); + } + } + private void createGettingStartedSection(Composite parent) { TableWrapLayout layout = new TableWrapLayout(); layout.verticalSpacing = 0; diff --git a/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/tasks/ui/AbstractRepositoryConnectorUi.java b/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/tasks/ui/AbstractRepositoryConnectorUi.java index 4f42cef9f..21bfcbb37 100644 --- a/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/tasks/ui/AbstractRepositoryConnectorUi.java +++ b/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/tasks/ui/AbstractRepositoryConnectorUi.java @@ -89,12 +89,24 @@ public abstract class AbstractRepositoryConnectorUi { /** * Contributions to the UI legend. + * + * @deprecated use {@link #getLegendElements()} instead */ + @Deprecated public List<ITask> getLegendItems() { return Collections.emptyList(); } /** + * Contributions to the UI legend. + * + * @since 3.0 + */ + public List<LegendElement> getLegendElements() { + return Collections.emptyList(); + } + + /** * @param repositoryTask * can be null * @since 3.0 diff --git a/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/tasks/ui/LegendElement.java b/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/tasks/ui/LegendElement.java new file mode 100644 index 000000000..500748a7e --- /dev/null +++ b/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/tasks/ui/LegendElement.java @@ -0,0 +1,45 @@ +/******************************************************************************* + * Copyright (c) 2004, 2007 Mylyn project committers 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 + *******************************************************************************/ + +package org.eclipse.mylyn.tasks.ui; + +import org.eclipse.jface.resource.ImageDescriptor; +import org.eclipse.mylyn.internal.provisional.commons.ui.CommonImages; +import org.eclipse.swt.graphics.Image; + +/** + * @author Steffen Pingel + * @since 3.0 + */ +public class LegendElement { + + public static LegendElement createTask(String label, ImageDescriptor overlay) { + return new LegendElement(label, CommonImages.getCompositeTaskImage(TasksUiImages.TASK, overlay, false)); + } + + private final Image image; + + private final String label; + + private LegendElement(String label, Image image) { + this.label = label; + this.image = image; + } + + public void dispose() { + } + + public Image getImage() { + return image; + } + + public String getLabel() { + return label; + } + +} diff --git a/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/tasks/ui/TasksUi.java b/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/tasks/ui/TasksUi.java index fe8e9d01f..0160eee70 100644 --- a/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/tasks/ui/TasksUi.java +++ b/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/tasks/ui/TasksUi.java @@ -9,6 +9,7 @@ package org.eclipse.mylyn.tasks.ui; import org.eclipse.mylyn.internal.tasks.ui.TasksUiPlugin; +import org.eclipse.mylyn.tasks.core.AbstractRepositoryConnector; import org.eclipse.mylyn.tasks.core.ITaskActivityManager; import org.eclipse.mylyn.tasks.core.ITaskRepositoryManager; import org.eclipse.mylyn.tasks.core.ITasksModel; @@ -21,18 +22,26 @@ import org.eclipse.mylyn.tasks.core.data.ITaskDataManager; */ public class TasksUi { - public static ITaskActivityManager getTaskActivityManager() { - return TasksUiPlugin.getTaskActivityManager(); + public static AbstractRepositoryConnector getConnector(String kind) { + return TasksUiPlugin.getConnector(kind); } - public static ITaskDataManager getTaskDataManager() { - return TasksUiPlugin.getTaskDataManager(); + public static AbstractRepositoryConnectorUi getConnectorUi(String kind) { + return TasksUiPlugin.getConnectorUi(kind); } public static ITaskRepositoryManager getRepositoryManager() { return TasksUiPlugin.getRepositoryManager(); } + public static ITaskActivityManager getTaskActivityManager() { + return TasksUiPlugin.getTaskActivityManager(); + } + + public static ITaskDataManager getTaskDataManager() { + return TasksUiPlugin.getTaskDataManager(); + } + public static ITasksModel getTasksModel() { return TasksUiPlugin.getTasksModel(); } |