Skip to main content
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorFrank Becker2015-02-02 13:33:13 +0000
committerGerrit Code Review @ Eclipse.org2015-02-03 19:05:06 +0000
commitd09b0012bb7d7665367fd51a0f1bb65c19c644c0 (patch)
tree2435bf4c4a2d1e588bccd88ca616e18e5652fee0 /org.eclipse.mylyn.bugzilla.ui
parente671ccca5330361bfd0026b86fc380ce8cea19bd (diff)
downloadorg.eclipse.mylyn.tasks-d09b0012bb7d7665367fd51a0f1bb65c19c644c0.tar.gz
org.eclipse.mylyn.tasks-d09b0012bb7d7665367fd51a0f1bb65c19c644c0.tar.xz
org.eclipse.mylyn.tasks-d09b0012bb7d7665367fd51a0f1bb65c19c644c0.zip
307729: [upstream] support reading and updating the See Also field
Change-Id: I5a85c736f1455314275524260f4d140178c9c4bd Task-Url: https://bugs.eclipse.org/bugs/show_bug.cgi?id=307729
Diffstat (limited to 'org.eclipse.mylyn.bugzilla.ui')
-rw-r--r--org.eclipse.mylyn.bugzilla.ui/icons/elcl16/gerrit.gifbin0 -> 211 bytes
-rw-r--r--org.eclipse.mylyn.bugzilla.ui/icons/elcl16/git.pngbin0 -> 617 bytes
-rw-r--r--org.eclipse.mylyn.bugzilla.ui/src/org/eclipse/mylyn/internal/bugzilla/ui/BugzillaImages.java4
-rw-r--r--org.eclipse.mylyn.bugzilla.ui/src/org/eclipse/mylyn/internal/bugzilla/ui/editor/BugzillaSeeAlsoAttributeEditor.java240
-rw-r--r--org.eclipse.mylyn.bugzilla.ui/src/org/eclipse/mylyn/internal/bugzilla/ui/editor/BugzillaTaskEditorPage.java40
-rw-r--r--org.eclipse.mylyn.bugzilla.ui/src/org/eclipse/mylyn/internal/bugzilla/ui/editor/Messages.java14
-rw-r--r--org.eclipse.mylyn.bugzilla.ui/src/org/eclipse/mylyn/internal/bugzilla/ui/editor/messages.properties7
7 files changed, 286 insertions, 19 deletions
diff --git a/org.eclipse.mylyn.bugzilla.ui/icons/elcl16/gerrit.gif b/org.eclipse.mylyn.bugzilla.ui/icons/elcl16/gerrit.gif
new file mode 100644
index 000000000..5c65e1fb5
--- /dev/null
+++ b/org.eclipse.mylyn.bugzilla.ui/icons/elcl16/gerrit.gif
Binary files differ
diff --git a/org.eclipse.mylyn.bugzilla.ui/icons/elcl16/git.png b/org.eclipse.mylyn.bugzilla.ui/icons/elcl16/git.png
new file mode 100644
index 000000000..d072d3cbe
--- /dev/null
+++ b/org.eclipse.mylyn.bugzilla.ui/icons/elcl16/git.png
Binary files differ
diff --git a/org.eclipse.mylyn.bugzilla.ui/src/org/eclipse/mylyn/internal/bugzilla/ui/BugzillaImages.java b/org.eclipse.mylyn.bugzilla.ui/src/org/eclipse/mylyn/internal/bugzilla/ui/BugzillaImages.java
index 930ef635f..1c539887d 100644
--- a/org.eclipse.mylyn.bugzilla.ui/src/org/eclipse/mylyn/internal/bugzilla/ui/BugzillaImages.java
+++ b/org.eclipse.mylyn.bugzilla.ui/src/org/eclipse/mylyn/internal/bugzilla/ui/BugzillaImages.java
@@ -38,6 +38,10 @@ public class BugzillaImages {
public static final ImageDescriptor BUG = create(T_ELCL, "bug.gif"); //$NON-NLS-1$
+ public static final ImageDescriptor GERRIT = create(T_ELCL, "gerrit.gif"); //$NON-NLS-1$
+
+ public static final ImageDescriptor GIT = create(T_ELCL, "git.png"); //$NON-NLS-1$
+
public static final ImageDescriptor BUG_COMMENT = create(T_ELCL, "bug-comment.gif"); //$NON-NLS-1$
public static final ImageDescriptor REMOVE_ALL = create("", "remove-all.gif"); //$NON-NLS-1$ //$NON-NLS-2$
diff --git a/org.eclipse.mylyn.bugzilla.ui/src/org/eclipse/mylyn/internal/bugzilla/ui/editor/BugzillaSeeAlsoAttributeEditor.java b/org.eclipse.mylyn.bugzilla.ui/src/org/eclipse/mylyn/internal/bugzilla/ui/editor/BugzillaSeeAlsoAttributeEditor.java
new file mode 100644
index 000000000..9c120522b
--- /dev/null
+++ b/org.eclipse.mylyn.bugzilla.ui/src/org/eclipse/mylyn/internal/bugzilla/ui/editor/BugzillaSeeAlsoAttributeEditor.java
@@ -0,0 +1,240 @@
+/*******************************************************************************
+ * Copyright (c) 2015 Frank Becker 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:
+ * Frank Becker - initial API and implementation
+ *******************************************************************************/
+
+package org.eclipse.mylyn.internal.bugzilla.ui.editor;
+
+import java.util.List;
+
+import org.eclipse.jface.action.Action;
+import org.eclipse.jface.action.IMenuListener;
+import org.eclipse.jface.action.IMenuManager;
+import org.eclipse.jface.action.MenuManager;
+import org.eclipse.jface.viewers.ArrayContentProvider;
+import org.eclipse.jface.viewers.ColumnLabelProvider;
+import org.eclipse.jface.viewers.ColumnViewerToolTipSupport;
+import org.eclipse.jface.viewers.IOpenListener;
+import org.eclipse.jface.viewers.OpenEvent;
+import org.eclipse.jface.viewers.StructuredSelection;
+import org.eclipse.jface.viewers.TableViewer;
+import org.eclipse.jface.viewers.ViewerCell;
+import org.eclipse.jface.window.ToolTip;
+import org.eclipse.mylyn.commons.ui.CommonImages;
+import org.eclipse.mylyn.commons.workbench.browser.BrowserUtil;
+import org.eclipse.mylyn.internal.bugzilla.core.BugzillaAttribute;
+import org.eclipse.mylyn.internal.bugzilla.core.BugzillaTaskDataHandler;
+import org.eclipse.mylyn.internal.bugzilla.ui.BugzillaImages;
+import org.eclipse.mylyn.tasks.core.data.TaskAttribute;
+import org.eclipse.mylyn.tasks.core.data.TaskDataModel;
+import org.eclipse.mylyn.tasks.ui.editors.AbstractAttributeEditor;
+import org.eclipse.mylyn.tasks.ui.editors.LayoutHint;
+import org.eclipse.mylyn.tasks.ui.editors.LayoutHint.ColumnSpan;
+import org.eclipse.mylyn.tasks.ui.editors.LayoutHint.RowSpan;
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.dnd.Clipboard;
+import org.eclipse.swt.dnd.TextTransfer;
+import org.eclipse.swt.dnd.Transfer;
+import org.eclipse.swt.graphics.GC;
+import org.eclipse.swt.graphics.Image;
+import org.eclipse.swt.graphics.Point;
+import org.eclipse.swt.layout.GridLayout;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.swt.widgets.Menu;
+import org.eclipse.swt.widgets.Table;
+import org.eclipse.swt.widgets.TableColumn;
+import org.eclipse.ui.PlatformUI;
+import org.eclipse.ui.forms.widgets.FormToolkit;
+
+public class BugzillaSeeAlsoAttributeEditor extends AbstractAttributeEditor {
+
+ private Table seeAlsoTable;
+
+ private TaskAttribute attrRemoveSeeAlso;
+
+ public BugzillaSeeAlsoAttributeEditor(TaskDataModel manager, TaskAttribute taskAttribute) {
+ super(manager, taskAttribute);
+ setLayoutHint(new LayoutHint(RowSpan.MULTIPLE, ColumnSpan.MULTIPLE));
+ }
+
+ @Override
+ public void createControl(Composite parent, FormToolkit toolkit) {
+ attrRemoveSeeAlso = getModel().getTaskData()
+ .getRoot()
+ .getMappedAttribute(BugzillaAttribute.REMOVE_SEE_ALSO.getKey());
+
+ if (attrRemoveSeeAlso == null) {
+ attrRemoveSeeAlso = BugzillaTaskDataHandler.createAttribute(getModel().getTaskData(),
+ BugzillaAttribute.REMOVE_SEE_ALSO);
+ }
+ createSeeAlsoTable(toolkit, parent);
+ setControl(seeAlsoTable);
+ }
+
+ private final String[] seeAlsoColumns = {
+ "", Messages.BugzillaSeeAlsoAttributeEditor_Remove, Messages.BugzillaSeeAlsoAttributeEditor_URL }; //$NON-NLS-1$
+
+ private final int[] seeAlsoColumnWidths = { 25, 60, 100 };
+
+ private TableViewer seeAlsoViewer;
+
+ private void createSeeAlsoTable(FormToolkit toolkit, final Composite seeAlsoComposite) {
+
+ seeAlsoTable = toolkit.createTable(seeAlsoComposite, SWT.MULTI | SWT.FULL_SELECTION);
+ seeAlsoTable.setLinesVisible(true);
+ seeAlsoTable.setHeaderVisible(true);
+ seeAlsoTable.setLayout(new GridLayout());
+ seeAlsoTable.setData(FormToolkit.KEY_DRAW_BORDER, FormToolkit.TREE_BORDER);
+
+ for (int i = 0; i < seeAlsoColumns.length; i++) {
+ TableColumn column = new TableColumn(seeAlsoTable, SWT.LEFT, i);
+ column.setText(seeAlsoColumns[i]);
+ column.setWidth(seeAlsoColumnWidths[i]);
+ column.setMoveable(true);
+ }
+
+ seeAlsoViewer = new TableViewer(seeAlsoTable);
+ seeAlsoViewer.setUseHashlookup(true);
+ seeAlsoViewer.setColumnProperties(seeAlsoColumns);
+ ColumnViewerToolTipSupport.enableFor(seeAlsoViewer, ToolTip.NO_RECREATE);
+
+ seeAlsoViewer.setContentProvider(new ArrayContentProvider());
+ seeAlsoViewer.addOpenListener(new IOpenListener() {
+ public void open(OpenEvent event) {
+ openseeAlso(event);
+ }
+
+ private void openseeAlso(OpenEvent event) {
+ StructuredSelection selection = (StructuredSelection) event.getSelection();
+ for (String item : (List<String>) selection.toList()) {
+ BrowserUtil.openUrl(item);
+ }
+
+ }
+ });
+ seeAlsoViewer.setLabelProvider(new ColumnLabelProvider() {
+
+ public Image getColumnImage(Object element, int columnIndex) {
+ String value = (String) element;
+ if (columnIndex == 0) {
+ if (value.contains("/r/#/c/")) { //$NON-NLS-1$
+ return CommonImages.getImage(BugzillaImages.GERRIT);
+ } else if (value.contains("/commit/?id=")) { //$NON-NLS-1$
+ return CommonImages.getImage(BugzillaImages.GIT);
+ } else {
+ return CommonImages.getImage(BugzillaImages.BUG);
+ }
+ }
+ return null;
+ }
+
+ public String getColumnText(Object element, int columnIndex) {
+ String value = (String) element;
+ switch (columnIndex) {
+ case 0:
+ return null;
+ case 1:
+ return attrRemoveSeeAlso.getValues().contains(value)
+ ? Messages.BugzillaSeeAlsoAttributeEditor_Yes
+ : Messages.BugzillaSeeAlsoAttributeEditor_No;
+ default:
+ return value;
+ }
+ }
+
+ @Override
+ public void update(ViewerCell cell) {
+ Object element = cell.getElement();
+ cell.setText(getColumnText(element, cell.getColumnIndex()));
+ Image image = getColumnImage(element, cell.getColumnIndex());
+ cell.setImage(image);
+ cell.setBackground(getBackground(element));
+ cell.setForeground(getForeground(element));
+ cell.setFont(getFont(element));
+ }
+
+ });
+ seeAlsoViewer.setInput(getTaskAttribute().getValues().toArray());
+ GC gc = new GC(seeAlsoComposite);
+ int maxSize = 0;
+ for (String string : getTaskAttribute().getValues()) {
+ Point size = gc.textExtent(string);
+ if (size.x > maxSize) {
+ maxSize = size.x;
+ }
+ }
+ if (maxSize == 0) {
+ maxSize = 100;
+ }
+ seeAlsoTable.getColumn(2).setWidth(maxSize);
+ MenuManager menuManager = new MenuManager();
+ menuManager.setRemoveAllWhenShown(true);
+ menuManager.addMenuListener(new IMenuListener() {
+ public void menuAboutToShow(IMenuManager manager) {
+ manager.add(openAction);
+ manager.add(copyURLToClipAction);
+ manager.add(toggelRemoveStateAction);
+ }
+ });
+ Menu menu = menuManager.createContextMenu(seeAlsoTable);
+ seeAlsoTable.setMenu(menu);
+ }
+
+ final Action copyURLToClipAction = new Action(Messages.BugzillaSeeAlsoAttributeEditor_CopyURL) {
+ @Override
+ public void run() {
+ StructuredSelection selection = ((StructuredSelection) seeAlsoViewer.getSelection());
+ if (selection != null) {
+ Object firstElement = selection.getFirstElement();
+ if (firstElement != null) {
+ Clipboard clip = new Clipboard(PlatformUI.getWorkbench().getDisplay());
+ clip.setContents(new Object[] { (String) firstElement },
+ new Transfer[] { TextTransfer.getInstance() });
+ clip.dispose();
+ }
+ }
+ }
+ };
+
+ final Action openAction = new Action(Messages.BugzillaSeeAlsoAttributeEditor_Open) {
+ @Override
+ public void run() {
+ StructuredSelection selection = ((StructuredSelection) seeAlsoViewer.getSelection());
+ if (selection != null) {
+ for (String url : (List<String>) selection.toList()) {
+ BrowserUtil.openUrl(url);
+ }
+ }
+ }
+ };
+
+ final Action toggelRemoveStateAction = new Action(Messages.BugzillaSeeAlsoAttributeEditor_ToggelRemoveState) {
+ @Override
+ public void run() {
+ StructuredSelection selection = ((StructuredSelection) seeAlsoViewer.getSelection());
+ boolean changed = false;
+ if (selection != null) {
+ for (String url : (List<String>) selection.toList()) {
+ if (attrRemoveSeeAlso.getValues().contains(url)) {
+ attrRemoveSeeAlso.removeValue(url);
+ } else {
+ attrRemoveSeeAlso.addValue(url);
+ }
+ changed = true;
+ }
+
+ if (changed) {
+ getModel().attributeChanged(attrRemoveSeeAlso);
+ seeAlsoViewer.refresh();
+ }
+ }
+ }
+ };
+
+}
diff --git a/org.eclipse.mylyn.bugzilla.ui/src/org/eclipse/mylyn/internal/bugzilla/ui/editor/BugzillaTaskEditorPage.java b/org.eclipse.mylyn.bugzilla.ui/src/org/eclipse/mylyn/internal/bugzilla/ui/editor/BugzillaTaskEditorPage.java
index b5f271100..be15206e6 100644
--- a/org.eclipse.mylyn.bugzilla.ui/src/org/eclipse/mylyn/internal/bugzilla/ui/editor/BugzillaTaskEditorPage.java
+++ b/org.eclipse.mylyn.bugzilla.ui/src/org/eclipse/mylyn/internal/bugzilla/ui/editor/BugzillaTaskEditorPage.java
@@ -103,7 +103,7 @@ public class BugzillaTaskEditorPage extends AbstractTaskEditorPage {
/**
* Call this constructor if extending the Bugzilla connector
- *
+ *
* @param editor
* @param connectorKind
*/
@@ -239,6 +239,8 @@ public class BugzillaTaskEditorPage extends AbstractTaskEditorPage {
editor = new BugzillaVotesEditor(getModel(), taskAttribute);
} else if (IBugzillaConstants.EDITOR_TYPE_FLAG.equals(type)) {
editor = new FlagAttributeEditor(getModel(), taskAttribute);
+ } else if (IBugzillaConstants.EDITOR_TYPE_SEEALSO.equals(type)) {
+ editor = new BugzillaSeeAlsoAttributeEditor(getModel(), taskAttribute);
} else {
editor = super.createEditor(type, taskAttribute);
if (TaskAttribute.TYPE_BOOLEAN.equals(type)) {
@@ -580,12 +582,12 @@ public class BugzillaTaskEditorPage extends AbstractTaskEditorPage {
if (bugzillaResponse.getResponseData().size() > 0) {
getTaskEditor().setMessage(Messages.BugzillaTaskEditorPage_Changes_Submitted_Message,
IMessageProvider.INFORMATION, new HyperlinkAdapter() {
- @Override
- public void linkActivated(HyperlinkEvent event) {
- showSubmitResponse(bugzillaResponse);
- }
+ @Override
+ public void linkActivated(HyperlinkEvent event) {
+ showSubmitResponse(bugzillaResponse);
+ }
- });
+ });
} else {
getTaskEditor().setMessage(Messages.BugzillaTaskEditorPage_Changes_Submitted_Message,
IMessageProvider.INFORMATION);
@@ -610,12 +612,12 @@ public class BugzillaTaskEditorPage extends AbstractTaskEditorPage {
public void run() {
getTaskEditor().setMessage(Messages.BugzillaTaskEditorPage_Anonymous_can_not_submit_Tasks, type,
new HyperlinkAdapter() {
- @Override
- public void linkActivated(HyperlinkEvent e) {
- TasksUiUtil.openEditRepositoryWizard(taskRepository);
- refresh();
- }
- });
+ @Override
+ public void linkActivated(HyperlinkEvent e) {
+ TasksUiUtil.openEditRepositoryWizard(taskRepository);
+ refresh();
+ }
+ });
}
});
return false;
@@ -629,12 +631,12 @@ public class BugzillaTaskEditorPage extends AbstractTaskEditorPage {
public void run() {
getTaskEditor().setMessage(Messages.BugzillaTaskEditorPage_submit_disabled_please_refresh,
type, new HyperlinkAdapter() {
- @Override
- public void linkActivated(HyperlinkEvent e) {
- TasksUiUtil.openEditRepositoryWizard(taskRepository);
- refresh();
- }
- });
+ @Override
+ public void linkActivated(HyperlinkEvent e) {
+ TasksUiUtil.openEditRepositoryWizard(taskRepository);
+ refresh();
+ }
+ });
}
});
return false;
@@ -787,7 +789,7 @@ public class BugzillaTaskEditorPage extends AbstractTaskEditorPage {
final ControlDecoration decoration = new ControlDecoration(control, SWT.LEFT | SWT.DOWN);
decoration.setImage(newPersonProposalMap.size() == 1
? fieldDecorationWarning.getImage()
- : fieldDecoration.getImage());
+ : fieldDecoration.getImage());
IBindingService bindingService = (IBindingService) PlatformUI.getWorkbench().getService(IBindingService.class);
if (message != null && !message.equals("")) { //$NON-NLS-1$
decoration.setDescriptionText(message);
diff --git a/org.eclipse.mylyn.bugzilla.ui/src/org/eclipse/mylyn/internal/bugzilla/ui/editor/Messages.java b/org.eclipse.mylyn.bugzilla.ui/src/org/eclipse/mylyn/internal/bugzilla/ui/editor/Messages.java
index 51882c182..a66305198 100644
--- a/org.eclipse.mylyn.bugzilla.ui/src/org/eclipse/mylyn/internal/bugzilla/ui/editor/Messages.java
+++ b/org.eclipse.mylyn.bugzilla.ui/src/org/eclipse/mylyn/internal/bugzilla/ui/editor/Messages.java
@@ -47,6 +47,20 @@ public class Messages extends NLS {
public static String BugzillaPlanningEditorPart_Team_Planning;
+ public static String BugzillaSeeAlsoAttributeEditor_CopyURL;
+
+ public static String BugzillaSeeAlsoAttributeEditor_No;
+
+ public static String BugzillaSeeAlsoAttributeEditor_Open;
+
+ public static String BugzillaSeeAlsoAttributeEditor_Remove;
+
+ public static String BugzillaSeeAlsoAttributeEditor_ToggelRemoveState;
+
+ public static String BugzillaSeeAlsoAttributeEditor_URL;
+
+ public static String BugzillaSeeAlsoAttributeEditor_Yes;
+
public static String BugzillaTaskEditorPage_Bug_Line;
public static String BugzillaTaskEditorPage_Action_Line;
diff --git a/org.eclipse.mylyn.bugzilla.ui/src/org/eclipse/mylyn/internal/bugzilla/ui/editor/messages.properties b/org.eclipse.mylyn.bugzilla.ui/src/org/eclipse/mylyn/internal/bugzilla/ui/editor/messages.properties
index b5838a009..fca1dec79 100644
--- a/org.eclipse.mylyn.bugzilla.ui/src/org/eclipse/mylyn/internal/bugzilla/ui/editor/messages.properties
+++ b/org.eclipse.mylyn.bugzilla.ui/src/org/eclipse/mylyn/internal/bugzilla/ui/editor/messages.properties
@@ -20,6 +20,13 @@ BugzillaFlagPart_used_flags=set flags
BugzillaPlanningEditorPart_Current_Estimate=Current Estimate:
BugzillaPlanningEditorPart_Team_Planning=Team Planning
+BugzillaSeeAlsoAttributeEditor_CopyURL=Copy &URL
+BugzillaSeeAlsoAttributeEditor_No=No
+BugzillaSeeAlsoAttributeEditor_Open=Open
+BugzillaSeeAlsoAttributeEditor_Remove=Remove
+BugzillaSeeAlsoAttributeEditor_ToggelRemoveState=Toggel Remove State
+BugzillaSeeAlsoAttributeEditor_URL=URL
+BugzillaSeeAlsoAttributeEditor_Yes=Yes
BugzillaTaskEditorPage_Bug_Line={0}\n
BugzillaTaskEditorPage_Action_Line=\ \ \ \ \ \ \ \ {0}\n

Back to the top