From fab7fc72649fc9b970b6c73ef98aa922e73286b4 Mon Sep 17 00:00:00 2001 From: mkersten Date: Thu, 7 Sep 2006 17:43:34 +0000 Subject: Progress on: 152820: create visual design legend https://bugs.eclipse.org/bugs/show_bug.cgi?id=152820 --- org.eclipse.mylyn.help.ui/.classpath | 3 +- org.eclipse.mylyn.help.ui/.project | 6 + org.eclipse.mylyn.help.ui/META-INF/MANIFEST.MF | 6 + org.eclipse.mylyn.help.ui/build.properties | 11 +- .../icons/etool16/icons-legend.gif | Bin 0 -> 617 bytes org.eclipse.mylyn.help.ui/plugin.xml | 37 ++++++ .../internal/actions/ShowMylarLegendAction.java | 44 +++++++ .../mylyn/doc/internal/dialogs/UiLegendDialog.java | 139 +++++++++++++++++++++ 8 files changed, 243 insertions(+), 3 deletions(-) create mode 100644 org.eclipse.mylyn.help.ui/icons/etool16/icons-legend.gif create mode 100644 org.eclipse.mylyn.help.ui/src/org/eclipse/mylyn/doc/internal/actions/ShowMylarLegendAction.java create mode 100644 org.eclipse.mylyn.help.ui/src/org/eclipse/mylyn/doc/internal/dialogs/UiLegendDialog.java (limited to 'org.eclipse.mylyn.help.ui') diff --git a/org.eclipse.mylyn.help.ui/.classpath b/org.eclipse.mylyn.help.ui/.classpath index ddf0f401d..304e86186 100644 --- a/org.eclipse.mylyn.help.ui/.classpath +++ b/org.eclipse.mylyn.help.ui/.classpath @@ -1,6 +1,7 @@ + + - diff --git a/org.eclipse.mylyn.help.ui/.project b/org.eclipse.mylyn.help.ui/.project index 240934ada..cc9ad6c69 100644 --- a/org.eclipse.mylyn.help.ui/.project +++ b/org.eclipse.mylyn.help.ui/.project @@ -5,6 +5,11 @@ + + org.eclipse.jdt.core.javabuilder + + + org.eclipse.pde.ManifestBuilder @@ -18,5 +23,6 @@ org.eclipse.pde.PluginNature + org.eclipse.jdt.core.javanature diff --git a/org.eclipse.mylyn.help.ui/META-INF/MANIFEST.MF b/org.eclipse.mylyn.help.ui/META-INF/MANIFEST.MF index 5f002a797..a66f5fa93 100644 --- a/org.eclipse.mylyn.help.ui/META-INF/MANIFEST.MF +++ b/org.eclipse.mylyn.help.ui/META-INF/MANIFEST.MF @@ -6,3 +6,9 @@ Bundle-Version: 0.6.2.v20060828-1600 Bundle-Localization: plugin Eclipse-AutoStart: true Bundle-Vendor: Eclipse.org +Require-Bundle: org.eclipse.ui, + org.eclipse.ui.forms, + org.eclipse.mylar.tasks.ui +Export-Package: org.eclipse.mylar.doc.internal.actions, + org.eclipse.mylar.doc.internal.dialogs +Bundle-RequiredExecutionEnvironment: J2SE-1.5 diff --git a/org.eclipse.mylyn.help.ui/build.properties b/org.eclipse.mylyn.help.ui/build.properties index d5f13bafa..65c419a58 100644 --- a/org.eclipse.mylyn.help.ui/build.properties +++ b/org.eclipse.mylyn.help.ui/build.properties @@ -11,9 +11,16 @@ bin.includes = plugin.xml,\ META-INF/,\ doc/,\ - about.html + about.html,\ + .,\ + icons/ src.includes = META-INF/,\ plugin.xml,\ about.html,\ - doc/ + doc/,\ + src/,\ + icons/ +source.. = src/ +jars.compile.order = . +source.. = src/ diff --git a/org.eclipse.mylyn.help.ui/icons/etool16/icons-legend.gif b/org.eclipse.mylyn.help.ui/icons/etool16/icons-legend.gif new file mode 100644 index 000000000..f5d06ee86 Binary files /dev/null and b/org.eclipse.mylyn.help.ui/icons/etool16/icons-legend.gif differ diff --git a/org.eclipse.mylyn.help.ui/plugin.xml b/org.eclipse.mylyn.help.ui/plugin.xml index 20767a262..62be47ca0 100644 --- a/org.eclipse.mylyn.help.ui/plugin.xml +++ b/org.eclipse.mylyn.help.ui/plugin.xml @@ -11,4 +11,41 @@ primary="true"> + + + + + + + + + + + + + + + + + + diff --git a/org.eclipse.mylyn.help.ui/src/org/eclipse/mylyn/doc/internal/actions/ShowMylarLegendAction.java b/org.eclipse.mylyn.help.ui/src/org/eclipse/mylyn/doc/internal/actions/ShowMylarLegendAction.java new file mode 100644 index 000000000..b79443889 --- /dev/null +++ b/org.eclipse.mylyn.help.ui/src/org/eclipse/mylyn/doc/internal/actions/ShowMylarLegendAction.java @@ -0,0 +1,44 @@ +/******************************************************************************* + * Copyright (c) 2004 - 2006 University Of British Columbia 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: + * University Of British Columbia - initial API and implementation + *******************************************************************************/ + +package org.eclipse.mylar.doc.internal.actions; + +import org.eclipse.jface.action.IAction; +import org.eclipse.jface.viewers.ISelection; +import org.eclipse.mylar.doc.internal.dialogs.UiLegendDialog; +import org.eclipse.swt.widgets.Shell; +import org.eclipse.ui.IWorkbenchWindow; +import org.eclipse.ui.IWorkbenchWindowActionDelegate; +import org.eclipse.ui.PlatformUI; + +/** + * @author Mik Kersten + */ +public class ShowMylarLegendAction implements IWorkbenchWindowActionDelegate { + + public void dispose() { + // ignore + } + + public void init(IWorkbenchWindow window) { + // ignore + } + + public void run(IAction action) { + Shell parentShell = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell(); + UiLegendDialog uiLegendDialog = new UiLegendDialog(parentShell); + uiLegendDialog.open(); + } + + public void selectionChanged(IAction action, ISelection selection) { + // ignore + } +} diff --git a/org.eclipse.mylyn.help.ui/src/org/eclipse/mylyn/doc/internal/dialogs/UiLegendDialog.java b/org.eclipse.mylyn.help.ui/src/org/eclipse/mylyn/doc/internal/dialogs/UiLegendDialog.java new file mode 100644 index 000000000..fa72b0cba --- /dev/null +++ b/org.eclipse.mylyn.help.ui/src/org/eclipse/mylyn/doc/internal/dialogs/UiLegendDialog.java @@ -0,0 +1,139 @@ +/******************************************************************************* + * Copyright (c) 2004 - 2006 University Of British Columbia 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: + * University Of British Columbia - initial API and implementation + *******************************************************************************/ + +package org.eclipse.mylar.doc.internal.dialogs; + +import org.eclipse.jface.dialogs.PopupDialog; +import org.eclipse.jface.layout.GridDataFactory; +import org.eclipse.mylar.internal.tasks.ui.TaskListImages; +import org.eclipse.swt.SWT; +import org.eclipse.swt.graphics.Rectangle; +import org.eclipse.swt.layout.GridLayout; +import org.eclipse.swt.layout.RowLayout; +import org.eclipse.swt.widgets.Composite; +import org.eclipse.swt.widgets.Control; +import org.eclipse.swt.widgets.Display; +import org.eclipse.swt.widgets.Label; +import org.eclipse.swt.widgets.Shell; +import org.eclipse.ui.forms.events.HyperlinkAdapter; +import org.eclipse.ui.forms.events.HyperlinkEvent; +import org.eclipse.ui.forms.widgets.Form; +import org.eclipse.ui.forms.widgets.FormToolkit; +import org.eclipse.ui.forms.widgets.ImageHyperlink; +import org.eclipse.ui.forms.widgets.Section; + +/** + * @author Mik Kersten + */ +public class UiLegendDialog extends PopupDialog { + + private static final String LABEL = "Mylar UI Legend"; + + private FormToolkit toolkit; + + private Form form; + + private Rectangle bounds; + + private Composite sectionClient; + + public UiLegendDialog(Shell parent) { + super(parent, PopupDialog.INFOPOPUP_SHELLSTYLE | SWT.ON_TOP, false, false, false, false, null, null); + } + + protected Control createContents(Composite parent) { + getShell().setBackground(getShell().getDisplay().getSystemColor(SWT.COLOR_GRAY)); + return createDialogArea(parent); + } + + protected final Control createDialogArea(final Composite parent) { + + getShell().setText("Mylar UI Legend"); + + toolkit = new FormToolkit(parent.getDisplay()); + form = toolkit.createForm(parent); + form.getBody().setLayout(new GridLayout()); + + Section section = toolkit.createSection(form.getBody(), Section.TITLE_BAR); + + section.setText(LABEL); + section.setLayout(new GridLayout()); + + sectionClient = toolkit.createComposite(section); + sectionClient.setLayout(new GridLayout(2, false)); + + String descriptionText = "xxxxxxxxxxxxxxx"; + Label descriptionLabel = toolkit.createLabel(sectionClient, descriptionText); + GridDataFactory.fillDefaults().span(2, SWT.DEFAULT).applyTo(descriptionLabel); + + section.setClient(sectionClient); + + Composite buttonsComposite = toolkit.createComposite(section); + section.setTextClient(buttonsComposite); + buttonsComposite.setLayout(new RowLayout()); + buttonsComposite.setBackground(section.getTitleBarBackground()); + final ImageHyperlink closeHyperlink = toolkit.createImageHyperlink(buttonsComposite, SWT.NONE); + // closeHyperlink.setBackgroundMode(SWT.INHERIT_FORCE); + closeHyperlink.setBackground(section.getTitleBarBackground()); + closeHyperlink.setImage(TaskListImages.getImage(TaskListImages.NOTIFICATION_CLOSE)); + closeHyperlink.addHyperlinkListener(new HyperlinkAdapter() { + public void linkActivated(HyperlinkEvent e) { + close(); + } + }); + + form.pack(); + return parent; + } + + /** + * Initialize the shell's bounds. + */ + public void initializeBounds() { + getShell().setBounds(restoreBounds()); + } + + private Rectangle restoreBounds() { + bounds = form.getBounds(); + Rectangle maxBounds = null; + if (getShell() != null && !getShell().isDisposed()) + maxBounds = getShell().getDisplay().getClientArea(); + else { + // fallback + Display display = Display.getCurrent(); + if (display == null) + display = Display.getDefault(); + if (display != null && !display.isDisposed()) + maxBounds = display.getBounds(); + } + + if (bounds.width > -1 && bounds.height > -1) { + if (maxBounds != null) { + bounds.width = Math.min(bounds.width, maxBounds.width); + bounds.height = Math.min(bounds.height, maxBounds.height); + } + // Enforce an absolute minimal size + bounds.width = Math.max(bounds.width, 30); + bounds.height = Math.max(bounds.height, 30); + } + + if (bounds.x > -1 && bounds.y > -1 && maxBounds != null) { + bounds.x = Math.max(bounds.x, maxBounds.x); + bounds.y = Math.max(bounds.y, maxBounds.y); + + if (bounds.width > -1 && bounds.height > -1) { + bounds.x = maxBounds.width - bounds.width; + bounds.y = maxBounds.height - bounds.height; + } + } + return bounds; + } +} -- cgit v1.2.3