Skip to main content
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorspingel2007-06-20 01:49:17 -0400
committerspingel2007-06-20 01:49:17 -0400
commit323531a9c248315f400be577770b0fdb06c384a3 (patch)
treecd82def7e06cf2c32649c891e2e21abd77b5414b /org.eclipse.mylyn.trac.ui
parentcdd20207b2b9a97577deae2273125d65535a3db1 (diff)
downloadorg.eclipse.mylyn.tasks-323531a9c248315f400be577770b0fdb06c384a3.tar.gz
org.eclipse.mylyn.tasks-323531a9c248315f400be577770b0fdb06c384a3.tar.xz
org.eclipse.mylyn.tasks-323531a9c248315f400be577770b0fdb06c384a3.zip
NEW - bug 193430: Trac tasks accessed in web mode do not display browser tab anymore
https://bugs.eclipse.org/bugs/show_bug.cgi?id=193430
Diffstat (limited to 'org.eclipse.mylyn.trac.ui')
-rw-r--r--org.eclipse.mylyn.trac.ui/src/org/eclipse/mylyn/internal/trac/ui/editor/BrowserFormPage.java61
-rw-r--r--org.eclipse.mylyn.trac.ui/src/org/eclipse/mylyn/internal/trac/ui/editor/TracTaskEditorFactory.java49
2 files changed, 89 insertions, 21 deletions
diff --git a/org.eclipse.mylyn.trac.ui/src/org/eclipse/mylyn/internal/trac/ui/editor/BrowserFormPage.java b/org.eclipse.mylyn.trac.ui/src/org/eclipse/mylyn/internal/trac/ui/editor/BrowserFormPage.java
new file mode 100644
index 000000000..92a503873
--- /dev/null
+++ b/org.eclipse.mylyn.trac.ui/src/org/eclipse/mylyn/internal/trac/ui/editor/BrowserFormPage.java
@@ -0,0 +1,61 @@
+/*******************************************************************************
+ * Copyright (c) 2004 - 2006 Mylar 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.monitor.core.util.StatusManager;
+import org.eclipse.mylyn.tasks.core.AbstractTask;
+import org.eclipse.mylyn.tasks.ui.editors.TaskEditorInput;
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.SWTError;
+import org.eclipse.swt.browser.Browser;
+import org.eclipse.swt.layout.FillLayout;
+import org.eclipse.ui.forms.IManagedForm;
+import org.eclipse.ui.forms.editor.FormEditor;
+import org.eclipse.ui.forms.editor.FormPage;
+import org.eclipse.ui.forms.widgets.ScrolledForm;
+
+/**
+ * @author Mik Kersten
+ */
+// TODO need to generalize: copied from org.eclipse.mylyn.internal.web.tasks.BrowserFormPage
+public class BrowserFormPage extends FormPage {
+
+ public static final String ID_EDITOR = "org.eclipse.mylyn.trac.ui.editor";
+
+ private Browser browser;
+
+ public BrowserFormPage(FormEditor editor, String title) {
+ super(editor, ID_EDITOR, title);
+ }
+
+ @Override
+ protected void createFormContent(IManagedForm managedForm) {
+ super.createFormContent(managedForm);
+ try {
+ AbstractTask task = ((TaskEditorInput)getEditorInput()).getTask();
+ ScrolledForm form = managedForm.getForm();
+ form.getBody().setLayout(new FillLayout());
+ browser = new Browser(form.getBody(), SWT.NONE);
+ managedForm.getForm().setContent(browser);
+ browser.setUrl(task.getTaskUrl());
+ } catch (SWTError e) {
+ StatusManager.fail(e, "Could not create Browser page: " + e.getMessage(), true);
+ } catch (RuntimeException e) {
+ StatusManager.fail(e, "could not create issue report page", false);
+ }
+ }
+
+ @Override
+ public void dispose() {
+ if (browser != null && !browser.isDisposed()) {
+ browser.dispose();
+ }
+ super.dispose();
+ }
+}
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
index 1f7b33859..77fcb8546 100644
--- 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
@@ -7,7 +7,8 @@
*******************************************************************************/
package org.eclipse.mylyn.internal.trac.ui.editor;
-import org.eclipse.mylyn.internal.monitor.core.util.StatusManager;
+import org.eclipse.jface.resource.ImageDescriptor;
+import org.eclipse.mylyn.internal.tasks.ui.TasksUiImages;
import org.eclipse.mylyn.internal.trac.core.TracCorePlugin;
import org.eclipse.mylyn.internal.trac.core.TracRepositoryConnector;
import org.eclipse.mylyn.internal.trac.core.TracTask;
@@ -26,31 +27,26 @@ import org.eclipse.ui.IEditorPart;
*/
public class TracTaskEditorFactory extends AbstractTaskEditorFactory {
+ private static final String TITLE = "Browser";
+
public boolean canCreateEditorFor(AbstractTask task) {
- if (task instanceof TracTask) {
- TaskRepository repository = TasksUiPlugin.getRepositoryManager().getRepository(
- TracCorePlugin.REPOSITORY_KIND, ((TracTask) task).getRepositoryUrl());
- return TracRepositoryConnector.hasRichEditor(repository);
- }
- return task instanceof TracTask;
+ return (task instanceof TracTask);
}
public boolean canCreateEditorFor(IEditorInput input) {
if (input instanceof RepositoryTaskEditorInput) {
- RepositoryTaskEditorInput existingInput = (RepositoryTaskEditorInput) input;
- return existingInput.getTaskData() != null
- && TracCorePlugin.REPOSITORY_KIND.equals(existingInput.getRepository().getKind());
+ RepositoryTaskEditorInput taskInput = (RepositoryTaskEditorInput) input;
+ return taskInput.getTaskData() != null
+ && TracCorePlugin.REPOSITORY_KIND.equals(taskInput.getRepository().getKind());
+ } else if (input instanceof TaskEditorInput) {
+ TaskEditorInput taskInput = (TaskEditorInput) input;
+ return taskInput.getTask() instanceof TracTask;
}
-// else if (input instanceof NewTaskEditorInput) {
-// NewTaskEditorInput newInput = (NewTaskEditorInput) input;
-// return newInput.getTaskData() != null
-// && TracCorePlugin.REPOSITORY_KIND.equals(newInput.getRepository().getKind());
-// }
+
return false;
}
public IEditorPart createEditor(TaskEditor parentEditor, IEditorInput editorInput) {
-
if (editorInput instanceof RepositoryTaskEditorInput) {
RepositoryTaskEditorInput taskInput = (RepositoryTaskEditorInput) editorInput;
if (taskInput.getTaskData().isNew()) {
@@ -59,7 +55,14 @@ public class TracTaskEditorFactory extends AbstractTaskEditorFactory {
return new TracTaskEditor(parentEditor);
}
} else if (editorInput instanceof TaskEditorInput) {
- return new TracTaskEditor(parentEditor);
+ TaskRepository repository = TasksUiPlugin.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;
}
@@ -68,12 +71,16 @@ public class TracTaskEditorFactory extends AbstractTaskEditorFactory {
TracTask tracTask = (TracTask) task;
TaskRepository repository = TasksUiPlugin.getRepositoryManager().getRepository(TracCorePlugin.REPOSITORY_KIND,
tracTask.getRepositoryUrl());
- try {
+ if (TracRepositoryConnector.hasRichEditor(repository)) {
return new RepositoryTaskEditorInput(repository, tracTask.getTaskId(), tracTask.getTaskUrl());
- } catch (Exception e) {
- StatusManager.fail(e, "Could not create Trac editor input", true);
+ } else {
+ return new TaskEditorInput(task, false) {
+ @Override
+ public ImageDescriptor getImageDescriptor() {
+ return TasksUiImages.BROWSER_SMALL;
+ }
+ };
}
- return null;
}
public String getTitle() {

Back to the top