Skip to main content
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorspingel2008-06-13 10:27:07 +0000
committerspingel2008-06-13 10:27:07 +0000
commitb4996338b46ec9be20eddec644f74ccbc47bd42c (patch)
tree8a1b4007d8cd67d598802ec410a7b32215b22884 /org.eclipse.mylyn.trac.ui/src/org/eclipse/mylyn/internal/trac/ui/editor
parent6e6c278e32df5acf18d6c4636f8e0b86fe15a9ee (diff)
downloadorg.eclipse.mylyn.tasks-b4996338b46ec9be20eddec644f74ccbc47bd42c.tar.gz
org.eclipse.mylyn.tasks-b4996338b46ec9be20eddec644f74ccbc47bd42c.tar.xz
org.eclipse.mylyn.tasks-b4996338b46ec9be20eddec644f74ccbc47bd42c.zip
NEW - bug 235011: port Trac to Mylyn 3.0 APIs
https://bugs.eclipse.org/bugs/show_bug.cgi?id=235011
Diffstat (limited to 'org.eclipse.mylyn.trac.ui/src/org/eclipse/mylyn/internal/trac/ui/editor')
-rw-r--r--org.eclipse.mylyn.trac.ui/src/org/eclipse/mylyn/internal/trac/ui/editor/NewTracTaskEditor.java77
-rw-r--r--org.eclipse.mylyn.trac.ui/src/org/eclipse/mylyn/internal/trac/ui/editor/TracCcAttributeEditor.java87
-rw-r--r--org.eclipse.mylyn.trac.ui/src/org/eclipse/mylyn/internal/trac/ui/editor/TracDuplicateDetector.java46
-rw-r--r--org.eclipse.mylyn.trac.ui/src/org/eclipse/mylyn/internal/trac/ui/editor/TracPeoplePart.java106
-rw-r--r--org.eclipse.mylyn.trac.ui/src/org/eclipse/mylyn/internal/trac/ui/editor/TracTaskEditor.java54
-rw-r--r--org.eclipse.mylyn.trac.ui/src/org/eclipse/mylyn/internal/trac/ui/editor/TracTaskEditorFactory.java101
-rw-r--r--org.eclipse.mylyn.trac.ui/src/org/eclipse/mylyn/internal/trac/ui/editor/TracTaskEditorPage.java77
-rw-r--r--org.eclipse.mylyn.trac.ui/src/org/eclipse/mylyn/internal/trac/ui/editor/TracTaskEditorPageFactory.java74
8 files changed, 344 insertions, 278 deletions
diff --git a/org.eclipse.mylyn.trac.ui/src/org/eclipse/mylyn/internal/trac/ui/editor/NewTracTaskEditor.java b/org.eclipse.mylyn.trac.ui/src/org/eclipse/mylyn/internal/trac/ui/editor/NewTracTaskEditor.java
deleted file mode 100644
index 2c010b438..000000000
--- a/org.eclipse.mylyn.trac.ui/src/org/eclipse/mylyn/internal/trac/ui/editor/NewTracTaskEditor.java
+++ /dev/null
@@ -1,77 +0,0 @@
-/*******************************************************************************
- * 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.internal.trac.ui.editor;
-
-import org.eclipse.jface.fieldassist.ContentProposalAdapter;
-import org.eclipse.jface.layout.GridDataFactory;
-import org.eclipse.jface.viewers.ILabelProvider;
-import org.eclipse.mylyn.internal.tasks.core.deprecated.AbstractLegacyDuplicateDetector;
-import org.eclipse.mylyn.internal.tasks.core.deprecated.RepositoryTaskAttribute;
-import org.eclipse.mylyn.internal.tasks.ui.deprecated.AbstractNewRepositoryTaskEditor;
-import org.eclipse.swt.SWT;
-import org.eclipse.swt.layout.GridLayout;
-import org.eclipse.swt.widgets.Composite;
-import org.eclipse.swt.widgets.Label;
-import org.eclipse.swt.widgets.Text;
-import org.eclipse.ui.fieldassist.ContentAssistCommandAdapter;
-import org.eclipse.ui.forms.editor.FormEditor;
-import org.eclipse.ui.forms.widgets.FormToolkit;
-import org.eclipse.ui.forms.widgets.Section;
-
-/**
- * @author Steffen Pingel
- */
-public class NewTracTaskEditor extends AbstractNewRepositoryTaskEditor {
-
- public NewTracTaskEditor(FormEditor editor) {
- super(editor);
- }
-
- @Override
- public AbstractLegacyDuplicateDetector getDuplicateDetector(String name) {
- return new TracDuplicateDetector();
- }
-
- @Override
- protected void createPeopleLayout(Composite composite) {
- FormToolkit toolkit = getManagedForm().getToolkit();
- Section peopleSection = createSection(composite, getSectionLabel(SECTION_NAME.PEOPLE_SECTION));
- GridDataFactory.fillDefaults().align(SWT.FILL, SWT.FILL).grab(true, true).applyTo(peopleSection);
- Composite peopleComposite = toolkit.createComposite(peopleSection);
- GridLayout layout = new GridLayout(2, false);
- layout.marginRight = 5;
- peopleComposite.setLayout(layout);
- GridDataFactory.fillDefaults().align(SWT.FILL, SWT.FILL).grab(true, true).applyTo(peopleComposite);
-
- Label label = toolkit.createLabel(peopleComposite, "Assign to:");
- GridDataFactory.fillDefaults().align(SWT.RIGHT, SWT.CENTER).applyTo(label);
- Composite textFieldComposite = toolkit.createComposite(peopleComposite);
- GridDataFactory.fillDefaults().grab(true, false).applyTo(textFieldComposite);
- GridLayout textLayout = new GridLayout();
- textFieldComposite.setLayout(textLayout);
-
- RepositoryTaskAttribute attribute = taskData.getAttribute(RepositoryTaskAttribute.USER_ASSIGNED);
-
- Text textField = createTextField(textFieldComposite, attribute, SWT.FLAT);
- toolkit.paintBordersFor(textFieldComposite);
- GridDataFactory.fillDefaults().grab(true, false).applyTo(textField);
- peopleSection.setClient(peopleComposite);
-
- ContentAssistCommandAdapter adapter = applyContentAssist(textField, createContentProposalProvider(attribute));
-
- ILabelProvider propsalLabelProvider = createProposalLabelProvider(attribute);
- if (propsalLabelProvider != null) {
- adapter.setLabelProvider(propsalLabelProvider);
- }
- adapter.setProposalAcceptanceStyle(ContentProposalAdapter.PROPOSAL_REPLACE);
-
- toolkit.paintBordersFor(peopleComposite);
- }
-
-}
diff --git a/org.eclipse.mylyn.trac.ui/src/org/eclipse/mylyn/internal/trac/ui/editor/TracCcAttributeEditor.java b/org.eclipse.mylyn.trac.ui/src/org/eclipse/mylyn/internal/trac/ui/editor/TracCcAttributeEditor.java
new file mode 100644
index 000000000..94a0f7bb2
--- /dev/null
+++ b/org.eclipse.mylyn.trac.ui/src/org/eclipse/mylyn/internal/trac/ui/editor/TracCcAttributeEditor.java
@@ -0,0 +1,87 @@
+/*******************************************************************************
+ * 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.internal.trac.ui.editor;
+
+import org.eclipse.jface.layout.GridDataFactory;
+import org.eclipse.jface.resource.JFaceResources;
+import org.eclipse.mylyn.internal.trac.core.TracAttributeMapper;
+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.events.SelectionAdapter;
+import org.eclipse.swt.events.SelectionEvent;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.swt.widgets.List;
+import org.eclipse.ui.forms.widgets.FormToolkit;
+
+/**
+ * @author Rob Elves
+ */
+public class TracCcAttributeEditor extends AbstractAttributeEditor {
+
+ private List list;
+
+ private TaskAttribute attrRemoveCc;
+
+ public TracCcAttributeEditor(TaskDataModel manager, TaskAttribute taskAttribute) {
+ super(manager, taskAttribute);
+ setLayoutHint(new LayoutHint(RowSpan.MULTIPLE, ColumnSpan.SINGLE));
+ }
+
+ @Override
+ public void createControl(Composite parent, FormToolkit toolkit) {
+ list = new List(parent, SWT.FLAT | SWT.MULTI | SWT.V_SCROLL);
+ toolkit.adapt(list, true, true);
+ list.setData(FormToolkit.KEY_DRAW_BORDER, FormToolkit.TEXT_BORDER);
+ list.setFont(JFaceResources.getDefaultFont());
+ GridDataFactory.fillDefaults().grab(true, true).align(SWT.FILL, SWT.FILL).applyTo(list);
+
+ TaskAttribute attrUserCC = getTaskAttribute();
+ if (attrUserCC != null) {
+ for (String value : attrUserCC.getValues()) {
+ list.add(value);
+ }
+ }
+
+ attrRemoveCc = getModel().getTaskData().getRoot().getMappedAttribute(TracAttributeMapper.REMOVE_CC);
+ for (String item : attrRemoveCc.getValues()) {
+ int i = list.indexOf(item);
+ if (i != -1) {
+ list.select(i);
+ }
+ }
+
+ list.addSelectionListener(new SelectionAdapter() {
+
+ @Override
+ public void widgetSelected(SelectionEvent e) {
+ for (String cc : list.getItems()) {
+ int index = list.indexOf(cc);
+ if (list.isSelected(index)) {
+ java.util.List<String> remove = attrRemoveCc.getValues();
+ if (!remove.contains(cc)) {
+ attrRemoveCc.addValue(cc);
+ }
+ } else {
+ attrRemoveCc.removeValue(cc);
+ }
+ }
+ getModel().attributeChanged(attrRemoveCc);
+ }
+ });
+
+ list.showSelection();
+
+ setControl(list);
+ }
+}
diff --git a/org.eclipse.mylyn.trac.ui/src/org/eclipse/mylyn/internal/trac/ui/editor/TracDuplicateDetector.java b/org.eclipse.mylyn.trac.ui/src/org/eclipse/mylyn/internal/trac/ui/editor/TracDuplicateDetector.java
deleted file mode 100644
index 660f34e2d..000000000
--- a/org.eclipse.mylyn.trac.ui/src/org/eclipse/mylyn/internal/trac/ui/editor/TracDuplicateDetector.java
+++ /dev/null
@@ -1,46 +0,0 @@
-/*******************************************************************************
- * 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.internal.trac.ui.editor;
-
-import org.eclipse.mylyn.internal.tasks.core.RepositoryQuery;
-import org.eclipse.mylyn.internal.tasks.core.deprecated.AbstractLegacyDuplicateDetector;
-import org.eclipse.mylyn.internal.tasks.core.deprecated.RepositoryTaskData;
-import org.eclipse.mylyn.internal.trac.core.ITracClient;
-import org.eclipse.mylyn.internal.trac.core.TracRepositoryQuery;
-import org.eclipse.mylyn.internal.trac.core.model.TracSearch;
-import org.eclipse.mylyn.internal.trac.core.model.TracSearchFilter;
-import org.eclipse.mylyn.internal.trac.core.model.TracSearchFilter.CompareOperator;
-import org.eclipse.mylyn.tasks.core.TaskRepository;
-
-public class TracDuplicateDetector extends AbstractLegacyDuplicateDetector {
-
- @Override
- public RepositoryQuery getDuplicatesQuery(TaskRepository repository, RepositoryTaskData taskData) {
- TracSearchFilter filter = new TracSearchFilter("description");
- filter.setOperator(CompareOperator.CONTAINS);
-
- String searchString = AbstractLegacyDuplicateDetector.getStackTraceFromDescription(taskData.getDescription());
-
- filter.addValue(searchString);
-
- TracSearch search = new TracSearch();
- search.addFilter(filter);
-
- // TODO copied from TracCustomQueryPage.getQueryUrl()
- StringBuilder sb = new StringBuilder();
- sb.append(repository.getRepositoryUrl());
- sb.append(ITracClient.QUERY_URL);
- sb.append(search.toUrl());
-
- TracRepositoryQuery query = new TracRepositoryQuery(repository.getRepositoryUrl(), sb.toString(),
- "<Duplicate Search>");
- return query;
- }
-
-}
diff --git a/org.eclipse.mylyn.trac.ui/src/org/eclipse/mylyn/internal/trac/ui/editor/TracPeoplePart.java b/org.eclipse.mylyn.trac.ui/src/org/eclipse/mylyn/internal/trac/ui/editor/TracPeoplePart.java
new file mode 100644
index 000000000..491c0bfcc
--- /dev/null
+++ b/org.eclipse.mylyn.trac.ui/src/org/eclipse/mylyn/internal/trac/ui/editor/TracPeoplePart.java
@@ -0,0 +1,106 @@
+/*******************************************************************************
+ * 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.internal.trac.ui.editor;
+
+import org.eclipse.jface.layout.GridDataFactory;
+import org.eclipse.mylyn.internal.trac.core.TracAttribute;
+import org.eclipse.mylyn.internal.trac.core.TracAttributeMapper;
+import org.eclipse.mylyn.tasks.core.TaskRepository;
+import org.eclipse.mylyn.tasks.core.data.TaskAttribute;
+import org.eclipse.mylyn.tasks.ui.editors.AbstractAttributeEditor;
+import org.eclipse.mylyn.tasks.ui.editors.AbstractTaskEditorPart;
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.layout.GridLayout;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.swt.widgets.Label;
+import org.eclipse.ui.forms.widgets.FormToolkit;
+import org.eclipse.ui.forms.widgets.Section;
+
+/**
+ * @author Robert Elves
+ */
+public class TracPeoplePart extends AbstractTaskEditorPart {
+
+ private static final int COLUMN_MARGIN = 5;
+
+ public TracPeoplePart() {
+ setPartName("People");
+ }
+
+ private void addAttribute(Composite composite, FormToolkit toolkit, TaskAttribute attribute) {
+ AbstractAttributeEditor editor = createAttributeEditor(attribute);
+ if (editor != null) {
+ editor.createLabelControl(composite, toolkit);
+ GridDataFactory.defaultsFor(editor.getLabelControl()).indent(COLUMN_MARGIN, 0).applyTo(
+ editor.getLabelControl());
+ editor.createControl(composite, toolkit);
+ getTaskEditorPage().getAttributeEditorToolkit().adapt(editor);
+ if (editor instanceof TracCcAttributeEditor) {
+ GridDataFactory.fillDefaults().grab(true, true).align(SWT.FILL, SWT.FILL).hint(130, 95).applyTo(
+ editor.getControl());
+ } else {
+ GridDataFactory.fillDefaults().grab(true, false).align(SWT.FILL, SWT.TOP).applyTo(editor.getControl());
+ }
+ }
+ }
+
+ @Override
+ public void createControl(Composite parent, FormToolkit toolkit) {
+ Section section = createSection(parent, toolkit, true);
+ Composite peopleComposite = toolkit.createComposite(section);
+ GridLayout layout = new GridLayout(2, false);
+ layout.marginWidth = 5;
+ peopleComposite.setLayout(layout);
+
+ addAttribute(peopleComposite, toolkit, getTaskData().getRoot().getMappedAttribute(TaskAttribute.USER_ASSIGNED));
+ addAttribute(peopleComposite, toolkit, getTaskData().getRoot().getMappedAttribute(TaskAttribute.USER_REPORTER));
+ addAttribute(peopleComposite, toolkit, getTaskData().getRoot().getMappedAttribute(TracAttributeMapper.NEW_CC));
+ addSelfToCC(peopleComposite);
+ TaskAttribute cc = getTaskData().getRoot().getMappedAttribute(TracAttribute.CC.getTaskKey());
+ TaskAttribute removeCc = getTaskData().getRoot().getMappedAttribute(TracAttributeMapper.REMOVE_CC);
+ if (cc != null && removeCc != null) {
+ addAttribute(peopleComposite, toolkit, cc);
+ toolkit.createLabel(peopleComposite, "");
+ Label label = toolkit.createLabel(peopleComposite, "(Select to remove)");
+ GridDataFactory.fillDefaults().indent(0, 5).align(SWT.CENTER, SWT.CENTER).applyTo(label);
+ }
+
+ toolkit.paintBordersFor(peopleComposite);
+ section.setClient(peopleComposite);
+ setSection(toolkit, section);
+ }
+
+ /**
+ * Creates a check box for adding the repository user to the cc list. Does nothing if the repository does not have a
+ * valid username, the repository user is the assignee, reporter or already on the the cc list.
+ */
+ private void addSelfToCC(Composite composite) {
+ TaskRepository repository = this.getTaskEditorPage().getTaskRepository();
+ if (repository.getUserName() == null) {
+ return;
+ }
+
+ TaskAttribute root = getTaskData().getRoot();
+ TaskAttribute owner = root.getMappedAttribute(TaskAttribute.USER_ASSIGNED);
+ if (owner != null && owner.getValue().indexOf(repository.getUserName()) != -1) {
+ return;
+ }
+
+ TaskAttribute reporter = root.getMappedAttribute(TaskAttribute.USER_REPORTER);
+ if (reporter != null && reporter.getValue().indexOf(repository.getUserName()) != -1) {
+ return;
+ }
+
+ TaskAttribute ccAttribute = root.getMappedAttribute(TaskAttribute.USER_CC);
+ if (ccAttribute != null && ccAttribute.getValues().contains(repository.getUserName())) {
+ return;
+ }
+ }
+
+} \ No newline at end of file
diff --git a/org.eclipse.mylyn.trac.ui/src/org/eclipse/mylyn/internal/trac/ui/editor/TracTaskEditor.java b/org.eclipse.mylyn.trac.ui/src/org/eclipse/mylyn/internal/trac/ui/editor/TracTaskEditor.java
deleted file mode 100644
index b79d969f6..000000000
--- a/org.eclipse.mylyn.trac.ui/src/org/eclipse/mylyn/internal/trac/ui/editor/TracTaskEditor.java
+++ /dev/null
@@ -1,54 +0,0 @@
-/*******************************************************************************
- * 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.internal.trac.ui.editor;
-
-import org.eclipse.mylyn.internal.tasks.core.deprecated.RepositoryOperation;
-import org.eclipse.mylyn.internal.tasks.core.deprecated.RepositoryTaskAttribute;
-import org.eclipse.mylyn.internal.tasks.ui.deprecated.AbstractRepositoryTaskEditor;
-import org.eclipse.mylyn.internal.trac.core.TracAttributeFactory;
-import org.eclipse.mylyn.tasks.core.TaskRepository;
-import org.eclipse.mylyn.tasks.ui.editors.AbstractRenderingEngine;
-import org.eclipse.ui.forms.editor.FormEditor;
-
-/**
- * @author Steffen Pingel
- * @author Xiaoyang Guan (Wiki HTML preview)
- */
-public class TracTaskEditor extends AbstractRepositoryTaskEditor {
-
- private final TracRenderingEngine renderingEngine = new TracRenderingEngine();
-
- public TracTaskEditor(FormEditor editor) {
- super(editor);
- }
-
- @Override
- protected void validateInput() {
- }
-
- @Override
- protected AbstractRenderingEngine getRenderingEngine() {
- return renderingEngine;
- }
-
- public TaskRepository getRepository() {
- return repository;
- }
-
- @Override
- protected boolean hasContentAssist(RepositoryTaskAttribute attribute) {
- return TracAttributeFactory.Attribute.NEW_CC.getTaskKey().equals(attribute.getId());
- }
-
- @Override
- protected boolean hasContentAssist(RepositoryOperation repositoryOperation) {
- return "owner".equals(repositoryOperation.getInputName());
- }
-
-}
diff --git a/org.eclipse.mylyn.trac.ui/src/org/eclipse/mylyn/internal/trac/ui/editor/TracTaskEditorFactory.java b/org.eclipse.mylyn.trac.ui/src/org/eclipse/mylyn/internal/trac/ui/editor/TracTaskEditorFactory.java
deleted file mode 100644
index 3b8d899bf..000000000
--- a/org.eclipse.mylyn.trac.ui/src/org/eclipse/mylyn/internal/trac/ui/editor/TracTaskEditorFactory.java
+++ /dev/null
@@ -1,101 +0,0 @@
-/*******************************************************************************
- * 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.internal.trac.ui.editor;
-
-import org.eclipse.jface.resource.ImageDescriptor;
-import org.eclipse.mylyn.internal.provisional.commons.ui.CommonImages;
-import org.eclipse.mylyn.internal.tasks.ui.deprecated.AbstractTaskEditorFactory;
-import org.eclipse.mylyn.internal.tasks.ui.deprecated.RepositoryTaskEditorInput;
-import org.eclipse.mylyn.internal.trac.core.TracCorePlugin;
-import org.eclipse.mylyn.internal.trac.core.TracRepositoryConnector;
-import org.eclipse.mylyn.internal.trac.core.TracTask;
-import org.eclipse.mylyn.tasks.core.ITask;
-import org.eclipse.mylyn.tasks.core.TaskRepository;
-import org.eclipse.mylyn.tasks.ui.TasksUi;
-import org.eclipse.mylyn.tasks.ui.editors.BrowserFormPage;
-import org.eclipse.mylyn.tasks.ui.editors.TaskEditor;
-import org.eclipse.mylyn.tasks.ui.editors.TaskEditorInput;
-import org.eclipse.ui.IEditorInput;
-import org.eclipse.ui.IEditorPart;
-
-/**
- * @author Steffen Pingel
- */
-public class TracTaskEditorFactory extends AbstractTaskEditorFactory {
-
- private static final String TITLE = "Browser";
-
- @Override
- public boolean canCreateEditorFor(ITask task) {
- return (task instanceof TracTask);
- }
-
- @Override
- public boolean canCreateEditorFor(IEditorInput input) {
- if (input instanceof RepositoryTaskEditorInput) {
- RepositoryTaskEditorInput taskInput = (RepositoryTaskEditorInput) input;
- return taskInput.getTaskData() != null
- && TracCorePlugin.REPOSITORY_KIND.equals(taskInput.getRepository().getConnectorKind());
- } else if (input instanceof TaskEditorInput) {
- TaskEditorInput taskInput = (TaskEditorInput) input;
- return taskInput.getTask() instanceof TracTask;
- }
-
- return false;
- }
-
- @Override
- public IEditorPart createEditor(TaskEditor parentEditor, IEditorInput editorInput) {
- if (editorInput instanceof RepositoryTaskEditorInput) {
- RepositoryTaskEditorInput taskInput = (RepositoryTaskEditorInput) editorInput;
- if (taskInput.getTaskData().isNew()) {
- return new NewTracTaskEditor(parentEditor);
- } else {
- return new TracTaskEditor(parentEditor);
- }
- } else if (editorInput instanceof TaskEditorInput) {
- TaskRepository repository = TasksUi.getRepositoryManager().getRepository(TracCorePlugin.REPOSITORY_KIND,
- ((TaskEditorInput) editorInput).getTask().getRepositoryUrl());
- if (TracRepositoryConnector.hasRichEditor(repository)) {
- // the editor is actually initialized with a RepositoryTaskEditorInput, see bug 193430
- return new TracTaskEditor(parentEditor);
- } else {
- return new BrowserFormPage(parentEditor, TITLE);
- }
- }
- return null;
- }
-
- @Override
- public IEditorInput createEditorInput(ITask task) {
- TracTask tracTask = (TracTask) task;
- TaskRepository repository = TasksUi.getRepositoryManager().getRepository(TracCorePlugin.REPOSITORY_KIND,
- tracTask.getRepositoryUrl());
- if (TracRepositoryConnector.hasRichEditor(repository)) {
- return new RepositoryTaskEditorInput(repository, tracTask.getTaskId(), tracTask.getUrl());
- } else {
- return new TaskEditorInput(repository, task) {
- @Override
- public ImageDescriptor getImageDescriptor() {
- return CommonImages.BROWSER_SMALL;
- }
- };
- }
- }
-
- @Override
- public String getTitle() {
- return "Trac";
- }
-
- @Override
- public boolean providesOutline() {
- return true;
- }
-}
diff --git a/org.eclipse.mylyn.trac.ui/src/org/eclipse/mylyn/internal/trac/ui/editor/TracTaskEditorPage.java b/org.eclipse.mylyn.trac.ui/src/org/eclipse/mylyn/internal/trac/ui/editor/TracTaskEditorPage.java
new file mode 100644
index 000000000..30d8ecf0a
--- /dev/null
+++ b/org.eclipse.mylyn.trac.ui/src/org/eclipse/mylyn/internal/trac/ui/editor/TracTaskEditorPage.java
@@ -0,0 +1,77 @@
+/*******************************************************************************
+ * 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.internal.trac.ui.editor;
+
+import java.util.Iterator;
+import java.util.Set;
+
+import org.eclipse.mylyn.internal.trac.core.TracAttribute;
+import org.eclipse.mylyn.internal.trac.core.TracCorePlugin;
+import org.eclipse.mylyn.tasks.core.data.TaskAttribute;
+import org.eclipse.mylyn.tasks.ui.editors.AbstractAttributeEditor;
+import org.eclipse.mylyn.tasks.ui.editors.AbstractTaskEditorPage;
+import org.eclipse.mylyn.tasks.ui.editors.AbstractTaskEditorPart;
+import org.eclipse.mylyn.tasks.ui.editors.AttributeEditorFactory;
+import org.eclipse.mylyn.tasks.ui.editors.TaskEditor;
+import org.eclipse.mylyn.tasks.ui.editors.TaskEditorPartDescriptor;
+
+/**
+ * @author Steffen Pingel
+ */
+public class TracTaskEditorPage extends AbstractTaskEditorPage {
+
+ private TracRenderingEngine renderingEngine;
+
+ public TracTaskEditorPage(TaskEditor editor) {
+ super(editor, TracCorePlugin.CONNECTOR_KIND);
+ }
+
+ @Override
+ protected Set<TaskEditorPartDescriptor> createPartDescriptors() {
+ Set<TaskEditorPartDescriptor> descriptors = super.createPartDescriptors();
+ // remove unnecessary default editor parts
+ for (Iterator<TaskEditorPartDescriptor> it = descriptors.iterator(); it.hasNext();) {
+ TaskEditorPartDescriptor taskEditorPartDescriptor = it.next();
+ if (taskEditorPartDescriptor.getId().equals(ID_PART_PEOPLE)) {
+ it.remove();
+ }
+ }
+ descriptors.add(new TaskEditorPartDescriptor(ID_PART_PEOPLE) {
+ @Override
+ public AbstractTaskEditorPart createPart() {
+ return new TracPeoplePart();
+ }
+ }.setPath(PATH_PEOPLE));
+ return descriptors;
+ }
+
+ @Override
+ protected void createParts() {
+ if (renderingEngine == null) {
+ renderingEngine = new TracRenderingEngine();
+ }
+ getAttributeEditorToolkit().setRenderingEngine(renderingEngine);
+ super.createParts();
+ }
+
+ @Override
+ protected AttributeEditorFactory createAttributeEditorFactory() {
+ AttributeEditorFactory factory = new AttributeEditorFactory(getModel(), getTaskRepository()) {
+ @Override
+ public AbstractAttributeEditor createEditor(String type, TaskAttribute taskAttribute) {
+ if (TracAttribute.CC.getTracKey().equals(taskAttribute.getId())) {
+ return new TracCcAttributeEditor(getModel(), taskAttribute);
+ }
+ return super.createEditor(type, taskAttribute);
+ }
+ };
+ return factory;
+ }
+
+}
diff --git a/org.eclipse.mylyn.trac.ui/src/org/eclipse/mylyn/internal/trac/ui/editor/TracTaskEditorPageFactory.java b/org.eclipse.mylyn.trac.ui/src/org/eclipse/mylyn/internal/trac/ui/editor/TracTaskEditorPageFactory.java
new file mode 100644
index 000000000..ca760f35b
--- /dev/null
+++ b/org.eclipse.mylyn.trac.ui/src/org/eclipse/mylyn/internal/trac/ui/editor/TracTaskEditorPageFactory.java
@@ -0,0 +1,74 @@
+/*******************************************************************************
+ * 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.internal.trac.ui.editor;
+
+import org.eclipse.mylyn.internal.provisional.commons.ui.CommonImages;
+import org.eclipse.mylyn.internal.trac.core.TracCorePlugin;
+import org.eclipse.mylyn.internal.trac.core.TracRepositoryConnector;
+import org.eclipse.mylyn.tasks.ui.ITasksUiConstants;
+import org.eclipse.mylyn.tasks.ui.TasksUiImages;
+import org.eclipse.mylyn.tasks.ui.TasksUiUtil;
+import org.eclipse.mylyn.tasks.ui.editors.AbstractTaskEditorPageFactory;
+import org.eclipse.mylyn.tasks.ui.editors.BrowserFormPage;
+import org.eclipse.mylyn.tasks.ui.editors.TaskEditor;
+import org.eclipse.mylyn.tasks.ui.editors.TaskEditorInput;
+import org.eclipse.swt.graphics.Image;
+import org.eclipse.ui.forms.editor.FormPage;
+
+/**
+ * @author Steffen Pingel
+ */
+public class TracTaskEditorPageFactory extends AbstractTaskEditorPageFactory {
+
+ @Override
+ public boolean canCreatePageFor(TaskEditorInput input) {
+ if (input.getTask().getConnectorKind().equals(TracCorePlugin.CONNECTOR_KIND)) {
+ return true;
+ } else if (TasksUiUtil.isOutgoingNewTask(input.getTask(), TracCorePlugin.CONNECTOR_KIND)) {
+ return true;
+ }
+ return false;
+ }
+
+ @Override
+ public FormPage createPage(TaskEditor parentEditor) {
+ TaskEditorInput input = parentEditor.getTaskEditorInput();
+ if (TasksUiUtil.isOutgoingNewTask(input.getTask(), TracCorePlugin.CONNECTOR_KIND)) {
+ return new TracTaskEditorPage(parentEditor);
+ } else if (TracRepositoryConnector.hasRichEditor(input.getTaskRepository())) {
+ return new TracTaskEditorPage(parentEditor);
+ } else {
+ return new BrowserFormPage(parentEditor, "Browser");
+ }
+ }
+
+ @Override
+ public String[] getConflictingIds(TaskEditorInput input) {
+ if (!input.getTask().getConnectorKind().equals(TracCorePlugin.CONNECTOR_KIND)) {
+ return new String[] { ITasksUiConstants.ID_PAGE_PLANNING };
+ }
+ return null;
+ }
+
+ @Override
+ public Image getPageImage() {
+ return CommonImages.getImage(TasksUiImages.REPOSITORY);
+ }
+
+ @Override
+ public String getPageText() {
+ return "Trac";
+ }
+
+ @Override
+ public int getPriority() {
+ return PRIORITY_TASK;
+ }
+
+}

Back to the top