Skip to main content
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorspingel2009-05-31 08:22:08 +0000
committerspingel2009-05-31 08:22:08 +0000
commita319d688511de795e20265278ed12354ee4d4b9e (patch)
tree630a6343d802465446b6fdc98e485f7ba14dec8f /org.eclipse.mylyn.tasks.bugs
parent3a94dc4e9d049cf7ca1dc64f2f9935f51b6e05c3 (diff)
downloadorg.eclipse.mylyn.tasks-a319d688511de795e20265278ed12354ee4d4b9e.tar.gz
org.eclipse.mylyn.tasks-a319d688511de795e20265278ed12354ee4d4b9e.tar.xz
org.eclipse.mylyn.tasks-a319d688511de795e20265278ed12354ee4d4b9e.zip
NEW - bug 277279: fix bug reporting wizard nits
https://bugs.eclipse.org/bugs/show_bug.cgi?id=277279
Diffstat (limited to 'org.eclipse.mylyn.tasks.bugs')
-rw-r--r--org.eclipse.mylyn.tasks.bugs/src/org/eclipse/mylyn/internal/tasks/bugs/wizards/BundleGroupContainer.java47
-rw-r--r--org.eclipse.mylyn.tasks.bugs/src/org/eclipse/mylyn/internal/tasks/bugs/wizards/FeatureGroup.java91
-rw-r--r--org.eclipse.mylyn.tasks.bugs/src/org/eclipse/mylyn/internal/tasks/bugs/wizards/SelectFeaturePage.java165
-rw-r--r--org.eclipse.mylyn.tasks.bugs/src/org/eclipse/mylyn/internal/tasks/bugs/wizards/SelectProductPage.java270
-rw-r--r--org.eclipse.mylyn.tasks.bugs/src/org/eclipse/mylyn/internal/tasks/bugs/wizards/SelectSupportElementPage.java178
5 files changed, 100 insertions, 651 deletions
diff --git a/org.eclipse.mylyn.tasks.bugs/src/org/eclipse/mylyn/internal/tasks/bugs/wizards/BundleGroupContainer.java b/org.eclipse.mylyn.tasks.bugs/src/org/eclipse/mylyn/internal/tasks/bugs/wizards/BundleGroupContainer.java
deleted file mode 100644
index 823bbe117..000000000
--- a/org.eclipse.mylyn.tasks.bugs/src/org/eclipse/mylyn/internal/tasks/bugs/wizards/BundleGroupContainer.java
+++ /dev/null
@@ -1,47 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2004, 2008 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.bugs.wizards;
-
-import java.util.ArrayList;
-import java.util.List;
-
-import org.eclipse.core.runtime.IBundleGroup;
-
-/**
- * A container for features that map to the same name.
- *
- * @author Steffen Pingel
- */
-public class BundleGroupContainer {
-
- private final List<IBundleGroup> groups;
-
- private final String name;
-
- public BundleGroupContainer(String name) {
- this.name = name;
- this.groups = new ArrayList<IBundleGroup>();
- }
-
- public void addBundleGroup(IBundleGroup bundleGroup) {
- groups.add(bundleGroup);
- }
-
- public List<IBundleGroup> getGroups() {
- return groups;
- }
-
- public String getName() {
- return name;
- }
-
-} \ No newline at end of file
diff --git a/org.eclipse.mylyn.tasks.bugs/src/org/eclipse/mylyn/internal/tasks/bugs/wizards/FeatureGroup.java b/org.eclipse.mylyn.tasks.bugs/src/org/eclipse/mylyn/internal/tasks/bugs/wizards/FeatureGroup.java
deleted file mode 100644
index c53d68ea8..000000000
--- a/org.eclipse.mylyn.tasks.bugs/src/org/eclipse/mylyn/internal/tasks/bugs/wizards/FeatureGroup.java
+++ /dev/null
@@ -1,91 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2004, 2008 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.bugs.wizards;
-
-import java.util.ArrayList;
-import java.util.Collection;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
-
-import org.eclipse.core.runtime.Assert;
-import org.eclipse.core.runtime.IBundleGroup;
-
-/**
- * @author Steffen Pingel
- */
-public class FeatureGroup {
-
- private final Map<String, BundleGroupContainer> containerByName;
-
- private final List<IBundleGroup> bundleGroups;
-
- private final String name;
-
- private final String description;
-
- private final String title;
-
- private final String category;
-
- public FeatureGroup(String name, String description, String title, String category) {
- Assert.isNotNull(name);
- Assert.isNotNull(category);
- this.name = name;
- this.description = description;
- this.title = title;
- this.category = category;
- this.containerByName = new HashMap<String, BundleGroupContainer>();
- this.bundleGroups = new ArrayList<IBundleGroup>();
- }
-
- public void addBundleGroup(IBundleGroup bundleGroup, String featureName) {
- BundleGroupContainer container = containerByName.get(featureName);
- if (container == null) {
- container = new BundleGroupContainer(featureName);
- container.addBundleGroup(bundleGroup);
- containerByName.put(featureName, container);
- } else {
- container.addBundleGroup(bundleGroup);
- }
- bundleGroups.add(bundleGroup);
- }
-
- public Collection<BundleGroupContainer> getContainers() {
- return containerByName.values();
- }
-
- public List<IBundleGroup> getBundleGroups() {
- return bundleGroups;
- }
-
- public String getCategory() {
- return category;
- }
-
- public String getDescription() {
- return description;
- }
-
- public String getName() {
- return name;
- }
-
- public String getTitle() {
- return title;
- }
-
- public boolean requiresSelection() {
- return containerByName.size() > 1;
- }
-
-}
diff --git a/org.eclipse.mylyn.tasks.bugs/src/org/eclipse/mylyn/internal/tasks/bugs/wizards/SelectFeaturePage.java b/org.eclipse.mylyn.tasks.bugs/src/org/eclipse/mylyn/internal/tasks/bugs/wizards/SelectFeaturePage.java
deleted file mode 100644
index a723d11da..000000000
--- a/org.eclipse.mylyn.tasks.bugs/src/org/eclipse/mylyn/internal/tasks/bugs/wizards/SelectFeaturePage.java
+++ /dev/null
@@ -1,165 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2004, 2008 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.bugs.wizards;
-
-import java.net.MalformedURLException;
-import java.net.URL;
-
-import org.eclipse.core.runtime.IBundleGroup;
-import org.eclipse.jface.dialogs.Dialog;
-import org.eclipse.jface.layout.GridDataFactory;
-import org.eclipse.jface.resource.ImageDescriptor;
-import org.eclipse.jface.resource.ImageRegistry;
-import org.eclipse.jface.viewers.IOpenListener;
-import org.eclipse.jface.viewers.ISelectionChangedListener;
-import org.eclipse.jface.viewers.IStructuredContentProvider;
-import org.eclipse.jface.viewers.IStructuredSelection;
-import org.eclipse.jface.viewers.LabelProvider;
-import org.eclipse.jface.viewers.OpenEvent;
-import org.eclipse.jface.viewers.SelectionChangedEvent;
-import org.eclipse.jface.viewers.TableViewer;
-import org.eclipse.jface.viewers.Viewer;
-import org.eclipse.jface.viewers.ViewerSorter;
-import org.eclipse.jface.wizard.WizardDialog;
-import org.eclipse.jface.wizard.WizardPage;
-import org.eclipse.mylyn.internal.tasks.ui.TasksUiPlugin;
-import org.eclipse.swt.SWT;
-import org.eclipse.swt.graphics.Image;
-import org.eclipse.swt.layout.GridLayout;
-import org.eclipse.swt.widgets.Composite;
-import org.eclipse.ui.branding.IBundleGroupConstants;
-
-/**
- * @author Steffen Pingel
- */
-public class SelectFeaturePage extends WizardPage {
-
- private static final int TABLE_HEIGHT = 200;
-
- private IBundleGroup selectedBundleGroup;
-
- private final IBundleGroup[] bundleGroups;
-
- private ImageRegistry imageRegistry;
-
- public SelectFeaturePage(String pageName, IBundleGroup[] bundleGroups) {
- super(pageName);
- this.bundleGroups = bundleGroups;
- setTitle(Messages.SelectFeaturePage_SELECT_FEATURE);
- }
-
- public void createControl(Composite parent) {
- Composite container = new Composite(parent, SWT.NULL);
- GridLayout layout = new GridLayout(1, true);
- container.setLayout(layout);
-
- imageRegistry = new ImageRegistry(getShell().getDisplay());
-
- for (IBundleGroup bundleGroup : bundleGroups) {
- String imageUrl = bundleGroup.getProperty(IBundleGroupConstants.FEATURE_IMAGE);
- if (imageUrl != null) {
- try {
- ImageDescriptor imageDescriptor = ImageDescriptor.createFromURL(new URL(imageUrl));
- imageRegistry.put(bundleGroup.getIdentifier(), imageDescriptor);
- } catch (MalformedURLException e) {
- // ignore
- }
- }
- }
-
- TableViewer viewer = new TableViewer(container, SWT.SINGLE | SWT.BORDER | SWT.H_SCROLL | SWT.V_SCROLL);
- GridDataFactory.fillDefaults()
- .align(SWT.FILL, SWT.FILL)
- .grab(true, true)
- .hint(SWT.DEFAULT, TABLE_HEIGHT)
- .applyTo(viewer.getControl());
- viewer.setContentProvider(new IStructuredContentProvider() {
-
- public Object[] getElements(Object inputElement) {
- return bundleGroups;
- }
-
- public void dispose() {
- }
-
- public void inputChanged(Viewer viewer, Object oldInput, Object newInput) {
- }
-
- });
- viewer.setLabelProvider(new LabelProvider() {
-
- @Override
- public Image getImage(Object element) {
- if (element instanceof IBundleGroup) {
- IBundleGroup bundleGroup = (IBundleGroup) element;
- return imageRegistry.get(bundleGroup.getIdentifier());
- }
- return null;
- }
-
- @Override
- public String getText(Object element) {
- if (element instanceof IBundleGroup) {
- IBundleGroup bundleGroup = (IBundleGroup) element;
- return bundleGroup.getName();
- }
- return ""; //$NON-NLS-1$
- }
-
- });
- viewer.setInput(TasksUiPlugin.getRepositoryManager().getRepositoryConnectors());
-
- viewer.addSelectionChangedListener(new ISelectionChangedListener() {
- public void selectionChanged(SelectionChangedEvent event) {
- IStructuredSelection selection = (IStructuredSelection) event.getSelection();
- if (selection.getFirstElement() instanceof IBundleGroup) {
- selectedBundleGroup = (IBundleGroup) selection.getFirstElement();
- setMessage(selectedBundleGroup.getDescription());
- setPageComplete(true);
- } else {
- setMessage(null);
- setPageComplete(false);
- }
- }
- });
-
- viewer.addOpenListener(new IOpenListener() {
-
- public void open(OpenEvent event) {
- if (getWizard().performFinish()) {
- ((WizardDialog) getContainer()).close();
- }
- }
- });
-
- viewer.getTable().showSelection();
- viewer.getTable().setFocus();
-
- viewer.setSorter(new ViewerSorter());
-
- setControl(container);
- Dialog.applyDialogFont(container);
- }
-
- @Override
- public void dispose() {
- if (imageRegistry != null) {
- imageRegistry.dispose();
- }
- super.dispose();
- }
-
- public IBundleGroup[] getSelectedBundleGroups() {
- return new IBundleGroup[] { selectedBundleGroup };
- }
-
-} \ No newline at end of file
diff --git a/org.eclipse.mylyn.tasks.bugs/src/org/eclipse/mylyn/internal/tasks/bugs/wizards/SelectProductPage.java b/org.eclipse.mylyn.tasks.bugs/src/org/eclipse/mylyn/internal/tasks/bugs/wizards/SelectProductPage.java
deleted file mode 100644
index db435db7a..000000000
--- a/org.eclipse.mylyn.tasks.bugs/src/org/eclipse/mylyn/internal/tasks/bugs/wizards/SelectProductPage.java
+++ /dev/null
@@ -1,270 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2004, 2008 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.bugs.wizards;
-
-import java.net.MalformedURLException;
-import java.net.URL;
-import java.util.HashMap;
-import java.util.Map;
-
-import org.eclipse.core.runtime.IBundleGroup;
-import org.eclipse.core.runtime.IBundleGroupProvider;
-import org.eclipse.core.runtime.Platform;
-import org.eclipse.jface.dialogs.Dialog;
-import org.eclipse.jface.layout.GridDataFactory;
-import org.eclipse.jface.resource.ImageDescriptor;
-import org.eclipse.jface.resource.ImageRegistry;
-import org.eclipse.jface.viewers.IOpenListener;
-import org.eclipse.jface.viewers.ISelectionChangedListener;
-import org.eclipse.jface.viewers.IStructuredContentProvider;
-import org.eclipse.jface.viewers.IStructuredSelection;
-import org.eclipse.jface.viewers.LabelProvider;
-import org.eclipse.jface.viewers.OpenEvent;
-import org.eclipse.jface.viewers.SelectionChangedEvent;
-import org.eclipse.jface.viewers.TableViewer;
-import org.eclipse.jface.viewers.Viewer;
-import org.eclipse.jface.viewers.ViewerSorter;
-import org.eclipse.jface.wizard.IWizardPage;
-import org.eclipse.jface.wizard.WizardDialog;
-import org.eclipse.jface.wizard.WizardPage;
-import org.eclipse.mylyn.internal.tasks.bugs.IRepositoryConstants;
-import org.eclipse.mylyn.internal.tasks.bugs.PluginRepositoryMappingManager;
-import org.eclipse.mylyn.internal.tasks.ui.TasksUiPlugin;
-import org.eclipse.swt.SWT;
-import org.eclipse.swt.graphics.Image;
-import org.eclipse.swt.layout.GridLayout;
-import org.eclipse.swt.widgets.Composite;
-import org.eclipse.ui.branding.IBundleGroupConstants;
-
-/**
- * @author Steffen Pingel
- */
-public class SelectProductPage extends WizardPage {
-
- private static final int TABLE_HEIGHT = 200;
-
- private static final String DEFAULT_CATEGORY = Messages.SelectProductPage_Other;
-
- private ImageRegistry imageRegistry;
-
- private final PluginRepositoryMappingManager manager;
-
- private FeatureGroup selectedFeatureGroup;
-
- public SelectProductPage(String pageName, PluginRepositoryMappingManager manager) {
- super(pageName);
- this.manager = manager;
- setTitle(Messages.SelectProductPage_SELECT_PRODUCT);
- }
-
- @Override
- public boolean canFlipToNextPage() {
- return selectedFeatureGroup != null && selectedFeatureGroup.requiresSelection();
- }
-
- public void createControl(Composite parent) {
- Composite composite = new Composite(parent, SWT.NONE);
- GridLayout layout = new GridLayout(1, true);
- composite.setLayout(layout);
-
- imageRegistry = new ImageRegistry(getShell().getDisplay());
-
- final Map<String, FeatureGroup> containerByName = getProducts();
-
- TableViewer viewer = new TableViewer(composite, SWT.SINGLE | SWT.BORDER | SWT.H_SCROLL | SWT.V_SCROLL);
- GridDataFactory.fillDefaults()
- .align(SWT.FILL, SWT.FILL)
- .grab(true, true)
- .hint(SWT.DEFAULT, TABLE_HEIGHT)
- .applyTo(viewer.getControl());
- viewer.setContentProvider(new IStructuredContentProvider() {
-
- public void dispose() {
- }
-
- public Object[] getElements(Object inputElement) {
- return containerByName.values().toArray();
- }
-
- public void inputChanged(Viewer viewer, Object oldInput, Object newInput) {
- }
-
- });
- viewer.setLabelProvider(new LabelProvider() {
-
- @Override
- public Image getImage(Object element) {
- if (element instanceof FeatureGroup) {
- FeatureGroup product = (FeatureGroup) element;
- return imageRegistry.get(product.getName());
- }
- return null;
- }
-
- @Override
- public String getText(Object element) {
- if (element instanceof FeatureGroup) {
- FeatureGroup product = (FeatureGroup) element;
- if (product.getTitle() != null) {
- return product.getName() + "\n " + product.getTitle(); //$NON-NLS-1$
- }
- return product.getName();
- }
- return ""; //$NON-NLS-1$
- }
-
- });
- viewer.setInput(TasksUiPlugin.getRepositoryManager().getRepositoryConnectors());
-
- viewer.addSelectionChangedListener(new ISelectionChangedListener() {
- public void selectionChanged(SelectionChangedEvent event) {
- IStructuredSelection selection = (IStructuredSelection) event.getSelection();
- if (selection.getFirstElement() instanceof FeatureGroup) {
- selectedFeatureGroup = (FeatureGroup) selection.getFirstElement();
- if (selectedFeatureGroup.requiresSelection()) {
- setMessage(null);
- } else {
- setMessage(selectedFeatureGroup.getDescription());
- }
- setPageComplete(true);
- } else {
- setMessage(null);
- setPageComplete(false);
- }
- }
- });
-
- viewer.addOpenListener(new IOpenListener() {
-
- public void open(OpenEvent event) {
- if (canFlipToNextPage()) {
- getContainer().showPage(getNextPage());
- } else if (isPageComplete()) {
- if (getWizard().performFinish()) {
- ((WizardDialog) getContainer()).close();
- }
- }
- }
- });
-
- viewer.getTable().showSelection();
- viewer.getTable().setFocus();
-
- viewer.setSorter(new ViewerSorter() {
- @Override
- public int compare(Viewer viewer, Object o1, Object o2) {
- FeatureGroup g1 = (FeatureGroup) o1;
- FeatureGroup g2 = (FeatureGroup) o2;
- int i = g1.getCategory().compareTo(g2.getCategory());
- if (i != 0) {
- return i;
- }
- return g1.getName().compareTo(g2.getName());
- }
- });
-
- setControl(composite);
- Dialog.applyDialogFont(composite);
- }
-
- @Override
- public void dispose() {
- if (imageRegistry != null) {
- imageRegistry.dispose();
- }
- super.dispose();
- }
-
- @Override
- public IWizardPage getNextPage() {
- if (canFlipToNextPage()) {
- SelectFeaturePage page = new SelectFeaturePage("selectBundle", getSelectedBundleGroups()); //$NON-NLS-1$
- page.setWizard(getWizard());
- return page;
- }
- return null;
- }
-
- private Map<String, FeatureGroup> getProducts() {
- final Map<String, FeatureGroup> containerByName = new HashMap<String, FeatureGroup>();
- IBundleGroupProvider[] providers = Platform.getBundleGroupProviders();
- if (providers != null) {
- for (IBundleGroupProvider provider : providers) {
- for (IBundleGroup bundleGroup : provider.getBundleGroups()) {
- addProduct(containerByName, bundleGroup);
- }
- }
- }
- return containerByName;
- }
-
- private void addProduct(Map<String, FeatureGroup> featureGroupByName, IBundleGroup bundleGroup) {
- Map<String, String> attributes = manager.getAllAttributes(bundleGroup.getIdentifier());
-
-// AttributeTaskMapper mapper = new AttributeTaskMapper(attributes);
-// if (!mapper.isMappingComplete()) {
-// return;
-// }
-
- String imageUrl = bundleGroup.getProperty(IBundleGroupConstants.FEATURE_IMAGE);
- if (imageUrl == null) {
- return;
- }
-
- String productDescription = attributes.get(IRepositoryConstants.PRODUCT_DESCRIPTION);
- if (productDescription == null) {
- productDescription = bundleGroup.getDescription();
- }
-
- String productName = attributes.get(IRepositoryConstants.PRODUCT_NAME);
- if (productName == null) {
- productName = bundleGroup.getName();
- }
-
- String productTitle = attributes.get(IRepositoryConstants.PRODUCT_TITLE);
-
- String productCategory = attributes.get(IRepositoryConstants.PRODUCT_CATEGORY);
- if (productCategory == null) {
- productCategory = DEFAULT_CATEGORY;
- }
-
- String branding = attributes.get(IRepositoryConstants.BRANDING);
- if (branding == null) {
- branding = bundleGroup.getName();
- }
-
- try {
- ImageDescriptor imageDescriptor = ImageDescriptor.createFromURL(new URL(imageUrl));
- imageRegistry.put(productName, imageDescriptor);
- } catch (MalformedURLException e) {
- // ignore bundles that do not have a feature image
- return;
- }
-
- FeatureGroup container = featureGroupByName.get(productName);
- if (container == null) {
- container = new FeatureGroup(productName, productDescription, productTitle, productCategory);
- container.addBundleGroup(bundleGroup, branding);
- featureGroupByName.put(productName, container);
- } else {
- container.addBundleGroup(bundleGroup, branding);
- }
- }
-
- public IBundleGroup[] getSelectedBundleGroups() {
- if (selectedFeatureGroup != null) {
- return selectedFeatureGroup.getBundleGroups().toArray(new IBundleGroup[0]);
- }
- return null;
- }
-
-}
diff --git a/org.eclipse.mylyn.tasks.bugs/src/org/eclipse/mylyn/internal/tasks/bugs/wizards/SelectSupportElementPage.java b/org.eclipse.mylyn.tasks.bugs/src/org/eclipse/mylyn/internal/tasks/bugs/wizards/SelectSupportElementPage.java
index 4fb935fa1..a0e7d6378 100644
--- a/org.eclipse.mylyn.tasks.bugs/src/org/eclipse/mylyn/internal/tasks/bugs/wizards/SelectSupportElementPage.java
+++ b/org.eclipse.mylyn.tasks.bugs/src/org/eclipse/mylyn/internal/tasks/bugs/wizards/SelectSupportElementPage.java
@@ -30,9 +30,8 @@ import org.eclipse.jface.wizard.WizardDialog;
import org.eclipse.jface.wizard.WizardPage;
import org.eclipse.mylyn.internal.commons.ui.ControlListItem;
import org.eclipse.mylyn.internal.commons.ui.ControlListViewer;
-import org.eclipse.mylyn.internal.commons.ui.NotificationPopupColors;
-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.provisional.commons.ui.GradientCanvas;
import org.eclipse.mylyn.internal.provisional.commons.ui.WorkbenchUtil;
import org.eclipse.mylyn.internal.provisional.tasks.bugs.IProvider;
@@ -51,7 +50,9 @@ import org.eclipse.swt.layout.GridLayout;
import org.eclipse.swt.widgets.Composite;
import org.eclipse.swt.widgets.Label;
import org.eclipse.swt.widgets.ToolBar;
+import org.eclipse.ui.PlatformUI;
import org.eclipse.ui.browser.IWorkbenchBrowserSupport;
+import org.eclipse.ui.themes.IThemeManager;
/**
* @author Steffen Pingel
@@ -59,111 +60,86 @@ import org.eclipse.ui.browser.IWorkbenchBrowserSupport;
@SuppressWarnings("restriction")
public class SelectSupportElementPage extends WizardPage {
- public class SupportElementViewer extends ControlListViewer {
-
- public SupportElementViewer(Composite parent, int style) {
- super(parent, style);
- // ignore
- }
-
- @Override
- protected ControlListItem doCreateItem(Composite parent, Object element) {
- if (element instanceof SupportCategory) {
- return new CategoryItem(parent, SWT.NONE, element);
- }
- return new SupportElementItem(parent, SWT.NONE, element);
- }
-
- }
-
- private class CategoryItem extends ControlListItem {
+ private class SupportElementItem extends ControlListItem {
- private Label label;
+ private static final int ICON_GAP = 10;
- public CategoryItem(Composite parent, int style, Object element) {
- super(parent, style, element);
- }
+ private ToolBar toolBar;
- @Override
- protected void createContent() {
- FillLayout layout = new FillLayout();
- setLayout(layout);
+ private Label titleLabel;
- GradientCanvas canvas = new GradientCanvas(this, SWT.NONE);
- NotificationPopupColors color = new NotificationPopupColors(getDisplay(), JFaceResources.getResources());
- canvas.setBackgroundGradient(new Color[] { color.getGradientBegin(), color.getGradientEnd() },
- new int[] { 100 }, true);
- canvas.setLayout(new GridLayout(1, false));
+ private Label iconLabel;
- label = new Label(canvas, SWT.NONE);
- label.setFont(JFaceResources.getHeaderFont());
- label.setBackground(null);
+ private Label descriptionLabel;
- canvas.setSize(canvas.computeSize(SWT.DEFAULT, SWT.DEFAULT));
+ private ToolBarManager toolBarManager;
- refresh();
- }
+ private boolean gradientBackground;
- @Override
- protected void refresh() {
- AbstractSupportElement data = (AbstractSupportElement) getData();
- label.setText(data.getName());
- }
+ private GradientCanvas canvas;
- @Override
- public void setForeground(Color color) {
- // ignore
+ public SupportElementItem(Composite parent, int style, Object element) {
+ super(parent, style, element);
+ registerChild(titleLabel);
+ registerChild(iconLabel);
+ registerChild(descriptionLabel);
+ registerChild(toolBar);
}
- @Override
- public void setBackground(Color color) {
- // ignore
- }
+ public void setGradientBackground(boolean gradientBackground) {
+ this.gradientBackground = gradientBackground;
- }
+ if (gradientBackground) {
+ IThemeManager themeManager = PlatformUI.getWorkbench().getThemeManager();
+ Color colorCategoryGradientStart = themeManager.getCurrentTheme().getColorRegistry().get(
+ CommonThemes.COLOR_CATEGORY_GRADIENT_START);
+ Color colorCategoryGradientEnd = themeManager.getCurrentTheme().getColorRegistry().get(
+ CommonThemes.COLOR_CATEGORY_GRADIENT_END);
- private class SupportElementItem extends ControlListItem {
+ canvas.setSeparatorVisible(true);
+ canvas.setSeparatorAlignment(SWT.TOP);
+ canvas.setBackgroundGradient(new Color[] { colorCategoryGradientStart, colorCategoryGradientEnd },
+ new int[] { 100 }, true);
+ canvas.putColor(GradientCanvas.H_BOTTOM_KEYLINE1, colorCategoryGradientStart);
+ canvas.putColor(GradientCanvas.H_BOTTOM_KEYLINE2, colorCategoryGradientEnd);
- private ToolBar toolBar;
-
- private Label titleLabel;
-
- private Label iconLabel;
-
- private Label descriptionLabel;
-
- private ToolBarManager toolBarManager;
+ }
+ }
- public SupportElementItem(Composite parent, int style, Object element) {
- super(parent, style, element);
+ public boolean isGradientBackground() {
+ return gradientBackground;
}
@Override
protected void createContent() {
+ setLayout(new FillLayout());
+
+ canvas = new GradientCanvas(this, SWT.NONE);
+
FormLayout layout = new FormLayout();
layout.marginHeight = 3;
layout.marginWidth = 3;
- setLayout(layout);
+ canvas.setLayout(layout);
- iconLabel = new Label(this, SWT.NONE);
+ iconLabel = new Label(canvas, SWT.NONE);
FormData fd = new FormData();
fd.left = new FormAttachment(0);
iconLabel.setLayoutData(fd);
- titleLabel = new Label(this, SWT.NONE);
- titleLabel.setFont(CommonFonts.BOLD);
+ titleLabel = new Label(canvas, SWT.NONE);
+ titleLabel.setFont(JFaceResources.getBannerFont());
fd = new FormData();
- fd.left = new FormAttachment(iconLabel, 5);
+ fd.left = new FormAttachment(iconLabel, ICON_GAP);
titleLabel.setLayoutData(fd);
- descriptionLabel = new Label(this, SWT.WRAP);
+ descriptionLabel = new Label(canvas, SWT.WRAP);
toolBarManager = new ToolBarManager(SWT.FLAT);
- toolBar = toolBarManager.createControl(this);
+ toolBar = toolBarManager.createControl(canvas);
fd = new FormData();
fd.top = new FormAttachment(titleLabel, 5);
- fd.left = new FormAttachment(iconLabel, 5);
+ fd.left = new FormAttachment(iconLabel, 10);
fd.right = new FormAttachment(toolBar, -5);
descriptionLabel.setLayoutData(fd);
@@ -181,20 +157,43 @@ public class SelectSupportElementPage extends WizardPage {
}
@Override
+ public void setBackground(Color color) {
+ if (isGradientBackground()) {
+ return;
+ }
+ super.setBackground(color);
+ }
+
+ @Override
public void setForeground(Color color) {
+ if (isGradientBackground()) {
+ // ignore
+ return;
+ }
super.setForeground(color);
if (isSelected()) {
- descriptionLabel.setForeground(getDisplay().getSystemColor(SWT.COLOR_WIDGET_LIGHT_SHADOW));
+ titleLabel.setForeground(color);
+ descriptionLabel.setForeground(color);
} else {
- descriptionLabel.setForeground(getDisplay().getSystemColor(SWT.COLOR_WIDGET_NORMAL_SHADOW));
+ titleLabel.setForeground(color);
+ descriptionLabel.setForeground(getDisplay().getSystemColor(SWT.COLOR_DARK_GRAY));
}
-
}
@Override
protected void refresh() {
AbstractSupportElement data = (AbstractSupportElement) getData();
- iconLabel.setImage(getImage(data));
+ Image image = getImage(data);
+ if (image == null) {
+ // left align with column
+ ((FormData) titleLabel.getLayoutData()).left = new FormAttachment(0);
+ ((FormData) descriptionLabel.getLayoutData()).left = new FormAttachment(0);
+ } else {
+ // leave space between icon and text
+ ((FormData) titleLabel.getLayoutData()).left = new FormAttachment(iconLabel, ICON_GAP);
+ ((FormData) descriptionLabel.getLayoutData()).left = new FormAttachment(iconLabel, ICON_GAP);
+ }
+ iconLabel.setImage(image);
titleLabel.setText(data.getName());
descriptionLabel.setText(data.getDescription());
@@ -207,7 +206,7 @@ public class SelectSupportElementPage extends WizardPage {
WorkbenchUtil.openUrl(url, IWorkbenchBrowserSupport.AS_EXTERNAL);
}
};
- action.setImageDescriptor(CommonImages.QUESTION);
+ action.setImageDescriptor(CommonImages.INFORMATION);
toolBarManager.add(action);
}
toolBarManager.update(false);
@@ -223,6 +222,7 @@ public class SelectSupportElementPage extends WizardPage {
public void setSelected(boolean select) {
super.setSelected(select);
updateToolBar();
+ canvas.redraw();
}
private void updateToolBar() {
@@ -233,6 +233,25 @@ public class SelectSupportElementPage extends WizardPage {
}
+ public class SupportElementViewer extends ControlListViewer {
+
+ public SupportElementViewer(Composite parent, int style) {
+ super(parent, style);
+ // ignore
+ }
+
+ @Override
+ protected ControlListItem doCreateItem(Composite parent, Object element) {
+ if (element instanceof SupportCategory) {
+ SupportElementItem item = new SupportElementItem(parent, SWT.NONE, element);
+ item.setGradientBackground(true);
+ return item;
+ }
+ return new SupportElementItem(parent, SWT.NONE, element);
+ }
+
+ }
+
private static final int TABLE_HEIGHT = 200;
private AbstractSupportElement selectedElement;
@@ -278,7 +297,7 @@ public class SelectSupportElementPage extends WizardPage {
container.setLayout(layout);
ControlListViewer viewer = new SupportElementViewer(container, SWT.SINGLE | SWT.BORDER | SWT.V_SCROLL);
- GridDataFactory.fillDefaults().grab(true, true).hint(600, TABLE_HEIGHT).applyTo(viewer.getControl());
+ GridDataFactory.fillDefaults().grab(true, true).hint(500, TABLE_HEIGHT).applyTo(viewer.getControl());
viewer.setContentProvider(contentProvider);
viewer.addSelectionChangedListener(new ISelectionChangedListener() {
public void selectionChanged(SelectionChangedEvent event) {
@@ -358,6 +377,9 @@ public class SelectSupportElementPage extends WizardPage {
} else if (selectedElement instanceof SupportProduct) {
setErrorMessage(null);
setPageComplete(true);
+ } else {
+ setErrorMessage(null);
+ setPageComplete(false);
}
}

Back to the top