Download
Getting Started
Members
Projects
Community
Marketplace
Events
Planet Eclipse
Newsletter
Videos
Participate
Report a Bug
Forums
Mailing Lists
Wiki
IRC
How to Contribute
Working Groups
Automotive
Internet of Things
LocationTech
Long-Term Support
PolarSys
Science
OpenMDM
More
Community
Marketplace
Events
Planet Eclipse
Newsletter
Videos
Participate
Report a Bug
Forums
Mailing Lists
Wiki
IRC
How to Contribute
Working Groups
Automotive
Internet of Things
LocationTech
Long-Term Support
PolarSys
Science
OpenMDM
Toggle navigation
Bugzilla – Attachment 115335 Details for
Bug 244579
[api] move task editor extension out of the sandbox
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Requests
|
Help
|
Log In
[x]
|
Terms of Use
|
Copyright Agent
Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read
this important communication.
[patch]
patch
clipboard.txt (text/plain), 107.39 KB, created by
Steffen Pingel
on 2008-10-16 23:21:57 EDT
(
hide
)
Description:
patch
Filename:
MIME Type:
Creator:
Steffen Pingel
Created:
2008-10-16 23:21:57 EDT
Size:
107.39 KB
patch
obsolete
>### Eclipse Workspace Patch 1.0 >#P org.eclipse.mylyn.wikitext.confluence.ui >Index: plugin.xml >=================================================================== >RCS file: /cvsroot/tools/org.eclipse.mylyn/sandbox/org.eclipse.mylyn.wikitext.confluence.ui/plugin.xml,v >retrieving revision 1.3 >diff -u -r1.3 plugin.xml >--- plugin.xml 3 Oct 2008 15:49:36 -0000 1.3 >+++ plugin.xml 17 Oct 2008 03:20:33 -0000 >@@ -2,7 +2,7 @@ > <?eclipse version="3.2"?> > <plugin> > <extension >- point="org.eclipse.mylyn.sandbox.ui.taskEditorExtensions"> >+ point="org.eclipse.mylyn.tasks.ui.taskEditorExtensions"> > <taskEditorExtension > class="org.eclipse.mylyn.internal.wikitext.confluence.ui.editors.TaskEditorExtension" > id="org.eclipse.mylyn.wikitext.confluence.ui.taskEditorExtension" >#P org.eclipse.mylyn.jira.ui >Index: src/org/eclipse/mylyn/internal/jira/ui/editor/JiraTaskEditorPage.java >=================================================================== >RCS file: /cvsroot/tools/org.eclipse.mylyn/org.eclipse.mylyn.jira.ui/src/org/eclipse/mylyn/internal/jira/ui/editor/JiraTaskEditorPage.java,v >retrieving revision 1.11 >diff -u -r1.11 JiraTaskEditorPage.java >--- src/org/eclipse/mylyn/internal/jira/ui/editor/JiraTaskEditorPage.java 12 Sep 2008 04:17:11 -0000 1.11 >+++ src/org/eclipse/mylyn/internal/jira/ui/editor/JiraTaskEditorPage.java 17 Oct 2008 03:20:33 -0000 >@@ -1,5 +1,5 @@ > /******************************************************************************* >-* Copyright (c) 2004, 2008 Tasktop Technologies and others. >+ * 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 >@@ -33,7 +33,7 @@ > > @Override > protected AttributeEditorFactory createAttributeEditorFactory() { >- AttributeEditorFactory factory = new AttributeEditorFactory(getModel(), getTaskRepository()) { >+ AttributeEditorFactory factory = new AttributeEditorFactory(getModel(), getTaskRepository(), getEditorSite()) { > @Override > public AbstractAttributeEditor createEditor(String type, TaskAttribute taskAttribute) { > if (JiraTaskDataHandler.isTimeSpanAttribute(taskAttribute)) { >#P org.eclipse.mylyn.wikitext.twiki.ui >Index: plugin.xml >=================================================================== >RCS file: /cvsroot/tools/org.eclipse.mylyn/sandbox/org.eclipse.mylyn.wikitext.twiki.ui/plugin.xml,v >retrieving revision 1.4 >diff -u -r1.4 plugin.xml >--- plugin.xml 1 Oct 2008 15:26:25 -0000 1.4 >+++ plugin.xml 17 Oct 2008 03:20:34 -0000 >@@ -2,7 +2,7 @@ > <?eclipse version="3.2"?> > <plugin> > <extension >- point="org.eclipse.mylyn.sandbox.ui.taskEditorExtensions"> >+ point="org.eclipse.mylyn.tasks.ui.taskEditorExtensions"> > <taskEditorExtension > class="org.eclipse.mylyn.internal.wikitext.twiki.ui.TaskEditorExtension" > id="org.eclipse.mylyn.wikitext.twiki.ui.taskEditorExtension1" >#P org.eclipse.mylyn.bugzilla.ui >Index: src/org/eclipse/mylyn/internal/bugzilla/ui/editor/BugzillaTaskEditorPage.java >=================================================================== >RCS file: /cvsroot/tools/org.eclipse.mylyn/org.eclipse.mylyn.bugzilla.ui/src/org/eclipse/mylyn/internal/bugzilla/ui/editor/BugzillaTaskEditorPage.java,v >retrieving revision 1.15 >diff -u -r1.15 BugzillaTaskEditorPage.java >--- src/org/eclipse/mylyn/internal/bugzilla/ui/editor/BugzillaTaskEditorPage.java 23 Sep 2008 20:00:08 -0000 1.15 >+++ src/org/eclipse/mylyn/internal/bugzilla/ui/editor/BugzillaTaskEditorPage.java 17 Oct 2008 03:20:34 -0000 >@@ -94,7 +94,7 @@ > > @Override > protected AttributeEditorFactory createAttributeEditorFactory() { >- AttributeEditorFactory factory = new AttributeEditorFactory(getModel(), getTaskRepository()) { >+ AttributeEditorFactory factory = new AttributeEditorFactory(getModel(), getTaskRepository(), getEditorSite()) { > @Override > public AbstractAttributeEditor createEditor(String type, TaskAttribute taskAttribute) { > AbstractAttributeEditor editor; >#P org.eclipse.mylyn.wikitext.tracwiki.ui >Index: plugin.xml >=================================================================== >RCS file: /cvsroot/tools/org.eclipse.mylyn/sandbox/org.eclipse.mylyn.wikitext.tracwiki.ui/plugin.xml,v >retrieving revision 1.5 >diff -u -r1.5 plugin.xml >--- plugin.xml 9 Oct 2008 22:47:24 -0000 1.5 >+++ plugin.xml 17 Oct 2008 03:20:35 -0000 >@@ -2,7 +2,7 @@ > <?eclipse version="3.2"?> > <plugin> > <extension >- point="org.eclipse.mylyn.sandbox.ui.taskEditorExtensions"> >+ point="org.eclipse.mylyn.tasks.ui.taskEditorExtensions"> > <taskEditorExtension > class="org.eclipse.mylyn.internal.wikitext.tracwiki.ui.editors.TracWikiTaskEditorExtension" > id="org.eclipse.mylyn.wikitext.tracwiki.ui.taskEditorExtension" >#P org.eclipse.mylyn.wikitext.mediawiki.ui >Index: plugin.xml >=================================================================== >RCS file: /cvsroot/tools/org.eclipse.mylyn/sandbox/org.eclipse.mylyn.wikitext.mediawiki.ui/plugin.xml,v >retrieving revision 1.2 >diff -u -r1.2 plugin.xml >--- plugin.xml 7 Oct 2008 00:57:13 -0000 1.2 >+++ plugin.xml 17 Oct 2008 03:20:35 -0000 >@@ -35,7 +35,7 @@ > </templates> > </extension> > <extension >- point="org.eclipse.mylyn.sandbox.ui.taskEditorExtensions"> >+ point="org.eclipse.mylyn.tasks.ui.taskEditorExtensions"> > <taskEditorExtension > class="org.eclipse.mylyn.internal.wikitext.mediawiki.ui.editors.TaskEditorExtension" > id="org.eclipse.mylyn.internal.wikitext.mediawiki.ui.taskEditorExtension" >#P org.eclipse.mylyn.trac.ui >Index: src/org/eclipse/mylyn/internal/trac/ui/editor/TracTaskEditorPage.java >=================================================================== >RCS file: /cvsroot/tools/org.eclipse.mylyn/org.eclipse.mylyn.trac.ui/src/org/eclipse/mylyn/internal/trac/ui/editor/TracTaskEditorPage.java,v >retrieving revision 1.3 >diff -u -r1.3 TracTaskEditorPage.java >--- src/org/eclipse/mylyn/internal/trac/ui/editor/TracTaskEditorPage.java 13 Sep 2008 03:27:54 -0000 1.3 >+++ src/org/eclipse/mylyn/internal/trac/ui/editor/TracTaskEditorPage.java 17 Oct 2008 03:20:36 -0000 >@@ -1,5 +1,5 @@ > /******************************************************************************* >-* Copyright (c) 2006, 2008 Steffen Pingel and others. >+ * Copyright (c) 2006, 2008 Steffen Pingel 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 >@@ -65,7 +65,7 @@ > > @Override > protected AttributeEditorFactory createAttributeEditorFactory() { >- AttributeEditorFactory factory = new AttributeEditorFactory(getModel(), getTaskRepository()) { >+ AttributeEditorFactory factory = new AttributeEditorFactory(getModel(), getTaskRepository(), getEditorSite()) { > @Override > public AbstractAttributeEditor createEditor(String type, TaskAttribute taskAttribute) { > if (TracAttribute.CC.getTracKey().equals(taskAttribute.getId())) { >#P org.eclipse.mylyn.wikitext.ui >Index: src/org/eclipse/mylyn/wikitext/ui/editor/MarkupTaskEditorExtension.java >=================================================================== >RCS file: /cvsroot/tools/org.eclipse.mylyn/sandbox/org.eclipse.mylyn.wikitext.ui/src/org/eclipse/mylyn/wikitext/ui/editor/MarkupTaskEditorExtension.java,v >retrieving revision 1.7 >diff -u -r1.7 MarkupTaskEditorExtension.java >--- src/org/eclipse/mylyn/wikitext/ui/editor/MarkupTaskEditorExtension.java 9 Oct 2008 21:44:53 -0000 1.7 >+++ src/org/eclipse/mylyn/wikitext/ui/editor/MarkupTaskEditorExtension.java 17 Oct 2008 03:20:37 -0000 >@@ -28,7 +28,6 @@ > import org.eclipse.jface.text.source.IAnnotationModel; > import org.eclipse.jface.text.source.ISourceViewer; > import org.eclipse.jface.text.source.SourceViewer; >-import org.eclipse.mylyn.internal.sandbox.ui.editors.AbstractTaskEditorExtension; > import org.eclipse.mylyn.internal.tasks.ui.editors.RepositoryCompletionProcessor; > import org.eclipse.mylyn.internal.wikitext.ui.editor.MarkupEditor; > import org.eclipse.mylyn.internal.wikitext.ui.editor.MarkupSourceViewerConfiguration; >@@ -39,6 +38,7 @@ > import org.eclipse.mylyn.tasks.core.TaskRepository; > import org.eclipse.mylyn.tasks.ui.TaskHyperlink; > import org.eclipse.mylyn.tasks.ui.TasksUi; >+import org.eclipse.mylyn.tasks.ui.editors.AbstractTaskEditorExtension; > import org.eclipse.mylyn.wikitext.core.parser.markup.MarkupLanguage; > import org.eclipse.mylyn.wikitext.ui.viewer.MarkupViewer; > import org.eclipse.mylyn.wikitext.ui.viewer.MarkupViewerConfiguration; >#P org.eclipse.mylyn.sandbox.ui >Index: src/org/eclipse/mylyn/internal/sandbox/ui/editors/ExtensibleRichTextAttributeEditor.java >=================================================================== >RCS file: src/org/eclipse/mylyn/internal/sandbox/ui/editors/ExtensibleRichTextAttributeEditor.java >diff -N src/org/eclipse/mylyn/internal/sandbox/ui/editors/ExtensibleRichTextAttributeEditor.java >--- src/org/eclipse/mylyn/internal/sandbox/ui/editors/ExtensibleRichTextAttributeEditor.java 10 Oct 2008 01:43:22 -0000 1.12 >+++ /dev/null 1 Jan 1970 00:00:00 -0000 >@@ -1,378 +0,0 @@ >-/******************************************************************************* >- * Copyright (c) 2004, 2008 Jingwen Ou 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: >- * Jingwen Ou - initial API and implementation >- * Tasktop Technologies - improvements >- *******************************************************************************/ >- >-package org.eclipse.mylyn.internal.sandbox.ui.editors; >- >-import java.util.Iterator; >- >-import org.eclipse.jface.action.Action; >-import org.eclipse.jface.action.IAction; >-import org.eclipse.jface.resource.JFaceResources; >-import org.eclipse.jface.text.Document; >-import org.eclipse.jface.text.ITextListener; >-import org.eclipse.jface.text.TextEvent; >-import org.eclipse.jface.text.source.AnnotationModel; >-import org.eclipse.jface.text.source.IAnnotationAccess; >-import org.eclipse.jface.text.source.SourceViewer; >-import org.eclipse.mylyn.internal.provisional.commons.ui.CommonThemes; >-import org.eclipse.mylyn.internal.sandbox.ui.commands.ViewSourceHandler; >-import org.eclipse.mylyn.internal.tasks.ui.editors.AbstractHyperlinkTextPresentationManager; >-import org.eclipse.mylyn.internal.tasks.ui.editors.EditorUtil; >-import org.eclipse.mylyn.internal.tasks.ui.editors.HighlightingHyperlinkTextPresentationManager; >-import org.eclipse.mylyn.internal.tasks.ui.editors.RepositoryTextViewer; >-import org.eclipse.mylyn.internal.tasks.ui.editors.RepositoryTextViewerConfiguration; >-import org.eclipse.mylyn.internal.tasks.ui.editors.RichTextAttributeEditor; >-import org.eclipse.mylyn.internal.tasks.ui.editors.TaskHyperlinkTextPresentationManager; >-import org.eclipse.mylyn.internal.tasks.ui.editors.RepositoryTextViewerConfiguration.Mode; >-import org.eclipse.mylyn.internal.tasks.ui.util.TasksUiInternal; >-import org.eclipse.mylyn.tasks.core.TaskRepository; >-import org.eclipse.mylyn.tasks.core.data.TaskAttribute; >-import org.eclipse.mylyn.tasks.core.data.TaskDataModel; >-import org.eclipse.swt.SWT; >-import org.eclipse.swt.custom.StackLayout; >-import org.eclipse.swt.events.DisposeEvent; >-import org.eclipse.swt.events.DisposeListener; >-import org.eclipse.swt.events.FocusAdapter; >-import org.eclipse.swt.events.FocusEvent; >-import org.eclipse.swt.events.FocusListener; >-import org.eclipse.swt.graphics.Font; >-import org.eclipse.swt.graphics.Point; >-import org.eclipse.swt.widgets.Composite; >-import org.eclipse.swt.widgets.Control; >-import org.eclipse.swt.widgets.Menu; >-import org.eclipse.ui.PlatformUI; >-import org.eclipse.ui.contexts.IContextActivation; >-import org.eclipse.ui.contexts.IContextService; >-import org.eclipse.ui.editors.text.EditorsUI; >-import org.eclipse.ui.forms.widgets.FormToolkit; >-import org.eclipse.ui.texteditor.AnnotationPreference; >-import org.eclipse.ui.texteditor.DefaultMarkerAnnotationAccess; >-import org.eclipse.ui.texteditor.MarkerAnnotationPreferences; >-import org.eclipse.ui.texteditor.SourceViewerDecorationSupport; >-import org.eclipse.ui.themes.IThemeManager; >- >-/** >- * A text attribute that can switch between a source editor and a preview using StackLayout. >- * >- * @author Jingwen Ou >- * @author Steffen Pingel >- */ >-public class ExtensibleRichTextAttributeEditor extends RichTextAttributeEditor { >- >- private IContextActivation contextActivation; >- >- private final IContextService contextService; >- >- private SourceViewer defaultViewer; >- >- private Composite editorComposite; >- >- private StackLayout editorLayout; >- >- private final AbstractTaskEditorExtension extension; >- >- private SourceViewer editorViewer; >- >- private SourceViewer previewViewer; >- >- private int styles; >- >- private final TaskRepository taskRepository; >- >- private FormToolkit toolkit; >- >- public class ViewSourceAction extends Action { >- >- public ViewSourceAction() { >- super("Viewer Source", SWT.TOGGLE); >- setChecked(false); >- } >- >- @Override >- public void run() { >- if (isChecked()) { >- showDefault(); >- } else { >- showEditor(); >- } >- } >- >- } >- >- private final IAction viewSourceAction = new ViewSourceAction(); >- >- public ExtensibleRichTextAttributeEditor(IContextService contextService, TaskDataModel manager, >- TaskRepository taskRepository, AbstractTaskEditorExtension extension, TaskAttribute taskAttribute, >- int styles) { >- super(manager, taskRepository, taskAttribute, styles); >- this.contextService = contextService; >- this.taskRepository = taskRepository; >- this.extension = extension; >- this.styles = styles; >- } >- >- /** Configures annontation model for spell checking. */ >- private void configureAsTextEditor(SourceViewer viewer, Document document) { >- AnnotationModel annotationModel = new AnnotationModel(); >- viewer.showAnnotations(false); >- viewer.showAnnotationsOverview(false); >- IAnnotationAccess annotationAccess = new DefaultMarkerAnnotationAccess(); >- final SourceViewerDecorationSupport support = new SourceViewerDecorationSupport(viewer, null, annotationAccess, >- EditorsUI.getSharedTextColors()); >- Iterator<?> e = new MarkerAnnotationPreferences().getAnnotationPreferences().iterator(); >- while (e.hasNext()) { >- support.setAnnotationPreference((AnnotationPreference) e.next()); >- } >- support.install(EditorsUI.getPreferenceStore()); >- viewer.getTextWidget().addDisposeListener(new DisposeListener() { >- public void widgetDisposed(DisposeEvent e) { >- support.uninstall(); >- } >- }); >- viewer.getTextWidget().setIndent(2); >- viewer.setDocument(document, annotationModel); >- } >- >- private RepositoryTextViewerConfiguration configure(SourceViewer viewer) { >- RepositoryTextViewerConfiguration configuration = new RepositoryTextViewerConfiguration(taskRepository, false); >- configuration.setMode(getMode()); >- >- // do not configure viewer, this has already been done in extension >- >- AbstractHyperlinkTextPresentationManager manager; >- if (getMode() == Mode.DEFAULT) { >- manager = new HighlightingHyperlinkTextPresentationManager(); >- manager.setHyperlinkDetectors(configuration.getDefaultHyperlinkDetectors(viewer, null)); >- manager.install(viewer); >- >- manager = new TaskHyperlinkTextPresentationManager(); >- manager.setHyperlinkDetectors(configuration.getDefaultHyperlinkDetectors(viewer, Mode.TASK)); >- manager.install(viewer); >- } else if (getMode() == Mode.TASK_RELATION) { >- manager = new TaskHyperlinkTextPresentationManager(); >- manager.setHyperlinkDetectors(configuration.getDefaultHyperlinkDetectors(viewer, Mode.TASK_RELATION)); >- manager.install(viewer); >- } >- >- return configuration; >- } >- >- private SourceViewer configureEditor(final SourceViewer viewer, boolean readOnly) { >- configure(viewer); >- >- Document document = new Document(getValue()); >- if (readOnly) { >- viewer.setDocument(document); >- // setting view source action >- viewer.getControl().setData(ViewSourceHandler.VIEW_SOURCE_ACTION, viewSourceAction); >- viewer.getControl().addFocusListener(new FocusAdapter() { >- @Override >- public void focusGained(FocusEvent e) { >- ViewSourceHandler.setChecked(getViewer() == defaultViewer); >- } >- }); >- } else { >- configureAsTextEditor(viewer, document); >- viewer.addTextListener(new ITextListener() { >- public void textChanged(TextEvent event) { >- // filter out events caused by text presentation changes, e.g. annotation drawing >- String value = viewer.getTextWidget().getText(); >- if (!getValue().equals(value)) { >- setValue(value); >- EditorUtil.ensureVisible(viewer.getTextWidget()); >- } >- } >- }); >- >- viewer.getControl().setData(FormToolkit.KEY_DRAW_BORDER, FormToolkit.TEXT_BORDER); >- >- // drop & drag support, under review >- TaskEditorDropTarget.addDropTargetSupport(viewer); >- } >- >- // enable cut/copy/paste >- EditorUtil.setTextViewer(viewer.getTextWidget(), viewer); >- viewer.setEditable(!readOnly); >- viewer.getTextWidget().setFont(getFont()); >- toolkit.adapt(viewer.getControl(), false, false); >- >- RepositoryTextViewerConfiguration configuration = new RepositoryTextViewerConfiguration( >- getModel().getTaskRepository(), false); >- >- TaskHyperlinkTextPresentationManager hyperlinkTextPresentationManager = new TaskHyperlinkTextPresentationManager(); >- hyperlinkTextPresentationManager.setHyperlinkDetectors(configuration.getDefaultHyperlinkDetectors(viewer, >- Mode.TASK)); >- hyperlinkTextPresentationManager.install(viewer); >- >- HighlightingHyperlinkTextPresentationManager manager = new HighlightingHyperlinkTextPresentationManager(); >- manager.setHyperlinkDetectors(configuration.getDefaultHyperlinkDetectors(viewer, null)); >- manager.install(viewer); >- >- return viewer; >- } >- >- @Override >- public void createControl(Composite parent, FormToolkit toolkit) { >- this.toolkit = toolkit; >- >- editorComposite = new Composite(parent, SWT.NULL); >- editorLayout = new StackLayout() { >- @Override >- protected Point computeSize(Composite composite, int hint, int hint2, boolean flushCache) { >- return topControl.computeSize(hint, hint2, flushCache); >- } >- }; >- editorComposite.setLayout(editorLayout); >- setControl(editorComposite); >- >- if (!isReadOnly() && (styles & TasksUiInternal.SWT_NO_SCROLL) == 0) { >- styles |= SWT.V_SCROLL; >- } >- >- if (isReadOnly()) { >- editorViewer = extension.createViewer(taskRepository, editorComposite, styles); >- } else { >- editorViewer = extension.createEditor(taskRepository, editorComposite, styles); >- editorViewer.getTextWidget().addFocusListener(new FocusListener() { >- public void focusGained(FocusEvent e) { >- setContext(); >- } >- >- public void focusLost(FocusEvent e) { >- unsetContext(); >- } >- }); >- editorViewer.getTextWidget().addDisposeListener(new DisposeListener() { >- public void widgetDisposed(DisposeEvent e) { >- unsetContext(); >- } >- }); >- } >- configureEditor(editorViewer, isReadOnly()); >- >- show(editorViewer); >- } >- >- private SourceViewer createDefaultEditor(Composite parent, int styles) { >- SourceViewer defaultEditor = new RepositoryTextViewer(taskRepository, parent, styles | SWT.WRAP); >- >- RepositoryTextViewerConfiguration viewerConfig = new RepositoryTextViewerConfiguration(taskRepository, >- isSpellCheckingEnabled()); >- viewerConfig.setMode(getMode()); >- defaultEditor.configure(viewerConfig); >- >- return defaultEditor; >- } >- >- private SourceViewer getDefaultViewer() { >- if (defaultViewer == null) { >- defaultViewer = createDefaultEditor(editorComposite, styles); >- configureEditor(defaultViewer, isReadOnly()); >- >- // fixed font size >- defaultViewer.getTextWidget().setFont(JFaceResources.getFontRegistry().get(JFaceResources.TEXT_FONT)); >- // adapt maximize action >- defaultViewer.getControl().setData(EditorUtil.KEY_TOGGLE_TO_MAXIMIZE_ACTION, >- editorViewer.getControl().getData(EditorUtil.KEY_TOGGLE_TO_MAXIMIZE_ACTION)); >- // adapt menu to the new viewer >- installMenu(defaultViewer.getControl(), editorViewer.getControl().getMenu()); >- } >- return defaultViewer; >- } >- >- private void installMenu(final Control control, Menu menu) { >- if (menu != null) { >- control.setMenu(menu); >- control.addDisposeListener(new DisposeListener() { >- public void widgetDisposed(DisposeEvent e) { >- control.setMenu(null); >- } >- }); >- } >- } >- >- private Font getFont() { >- IThemeManager themeManager = PlatformUI.getWorkbench().getThemeManager(); >- Font font = themeManager.getCurrentTheme().getFontRegistry().get(CommonThemes.FONT_EDITOR_COMMENT); >- return font; >- } >- >- private SourceViewer getPreviewViewer() { >- // construct as needed >- if (previewViewer == null) { >- previewViewer = extension.createViewer(taskRepository, editorComposite, styles); >- configureEditor(previewViewer, true); >- // adapt maximize action >- previewViewer.getControl().setData(EditorUtil.KEY_TOGGLE_TO_MAXIMIZE_ACTION, >- editorViewer.getControl().getData(EditorUtil.KEY_TOGGLE_TO_MAXIMIZE_ACTION)); >- } >- Document document = new Document(editorViewer.getDocument().get()); >- previewViewer.setDocument(document); >- return previewViewer; >- } >- >- public SourceViewer getEditorViewer() { >- return editorViewer; >- } >- >- @Override >- public SourceViewer getViewer() { >- if (defaultViewer != null && editorLayout.topControl == defaultViewer.getControl()) { >- return defaultViewer; >- } else if (previewViewer != null && editorLayout.topControl == previewViewer.getControl()) { >- return previewViewer; >- } else { >- return editorViewer; >- } >- } >- >- private void setContext() { >- if (contextActivation != null) { >- contextService.deactivateContext(contextActivation); >- contextActivation = null; >- } >- if (contextService != null && extension.getEditorContextId() != null) { >- contextActivation = contextService.activateContext(extension.getEditorContextId()); >- } >- } >- >- /** >- * Brings <code>viewer</code> to top. >- */ >- private void show(SourceViewer viewer) { >- editorLayout.topControl = viewer.getControl(); >- editorComposite.layout(); >- viewer.getControl().setFocus(); >- } >- >- public void showDefault() { >- show(getDefaultViewer()); >- } >- >- public void showPreview() { >- if (!isReadOnly()) { >- show(getPreviewViewer()); >- } >- } >- >- public void showEditor() { >- show(getEditorViewer()); >- } >- >- private void unsetContext() { >- if (contextActivation != null) { >- contextService.deactivateContext(contextActivation); >- contextActivation = null; >- } >- } >- >-} >Index: src/org/eclipse/mylyn/internal/sandbox/ui/editors/ExtensibleTaskEditorNewCommentPart.java >=================================================================== >RCS file: /cvsroot/tools/org.eclipse.mylyn/sandbox/org.eclipse.mylyn.sandbox.ui/src/org/eclipse/mylyn/internal/sandbox/ui/editors/ExtensibleTaskEditorNewCommentPart.java,v >retrieving revision 1.8 >diff -u -r1.8 ExtensibleTaskEditorNewCommentPart.java >--- src/org/eclipse/mylyn/internal/sandbox/ui/editors/ExtensibleTaskEditorNewCommentPart.java 13 Sep 2008 03:38:54 -0000 1.8 >+++ src/org/eclipse/mylyn/internal/sandbox/ui/editors/ExtensibleTaskEditorNewCommentPart.java 17 Oct 2008 03:20:37 -0000 >@@ -11,14 +11,8 @@ > > package org.eclipse.mylyn.internal.sandbox.ui.editors; > >-import org.eclipse.jface.action.Action; >-import org.eclipse.jface.action.ToolBarManager; >-import org.eclipse.mylyn.internal.provisional.commons.ui.CommonImages; >-import org.eclipse.mylyn.internal.tasks.ui.editors.EditorUtil; > import org.eclipse.mylyn.internal.tasks.ui.editors.TaskEditorNewCommentPart; >-import org.eclipse.swt.SWT; > import org.eclipse.swt.widgets.Composite; >-import org.eclipse.swt.widgets.Control; > import org.eclipse.ui.forms.widgets.FormToolkit; > > /** >@@ -27,43 +21,10 @@ > public class ExtensibleTaskEditorNewCommentPart extends TaskEditorNewCommentPart { > > @Override >- protected void fillToolBar(ToolBarManager barManager) { >- Action toggleEditingAction = new Action("", SWT.TOGGLE) { >- @Override >- public void run() { >- toggleEditing(this); >- } >- }; >- toggleEditingAction.setImageDescriptor(CommonImages.PREVIEW_WEB); >- toggleEditingAction.setToolTipText("Preview"); >- toggleEditingAction.setChecked(false); >- >- barManager.add(toggleEditingAction); >- barManager.add(getMaximizePartAction()); >- super.fillToolBar(barManager); >- } >- >- private void toggleEditing(Action action) { >- if (getEditor() instanceof ExtensibleRichTextAttributeEditor) { >- ExtensibleRichTextAttributeEditor editor = (ExtensibleRichTextAttributeEditor) getEditor(); >- if (action.isChecked()) { >- editor.showPreview(); >- } else { >- editor.showEditor(); >- } >- } >- } >- >- @Override > public void createControl(Composite parent, FormToolkit toolkit) { > super.createControl(parent, toolkit); >- if (getControl() != null) { >- getEditor().getControl().setData(EditorUtil.KEY_TOGGLE_TO_MAXIMIZE_ACTION, getMaximizePartAction()); >- if (getEditor().getControl() instanceof Composite) { >- for (Control control : ((Composite) getEditor().getControl()).getChildren()) { >- control.setData(EditorUtil.KEY_TOGGLE_TO_MAXIMIZE_ACTION, getMaximizePartAction()); >- } >- } >+ if (getEditor() != null && !getEditor().isReadOnly() && getEditor().getViewer() != null) { >+ TaskEditorDropTarget.addDropTargetSupport(getEditor().getViewer()); > } > } > >Index: src/org/eclipse/mylyn/internal/sandbox/ui/editors/EditorStyleContributionItem.java >=================================================================== >RCS file: /cvsroot/tools/org.eclipse.mylyn/sandbox/org.eclipse.mylyn.sandbox.ui/src/org/eclipse/mylyn/internal/sandbox/ui/editors/EditorStyleContributionItem.java,v >retrieving revision 1.4 >diff -u -r1.4 EditorStyleContributionItem.java >--- src/org/eclipse/mylyn/internal/sandbox/ui/editors/EditorStyleContributionItem.java 13 Sep 2008 03:38:54 -0000 1.4 >+++ src/org/eclipse/mylyn/internal/sandbox/ui/editors/EditorStyleContributionItem.java 17 Oct 2008 03:20:37 -0000 >@@ -22,9 +22,11 @@ > import org.eclipse.jface.dialogs.IInputValidator; > import org.eclipse.jface.dialogs.InputDialog; > import org.eclipse.jface.window.Window; >-import org.eclipse.mylyn.internal.sandbox.ui.editors.TaskEditorExtensions.RegisteredTaskEditorExtension; >+import org.eclipse.mylyn.internal.tasks.ui.editors.TaskEditorExtensions; >+import org.eclipse.mylyn.internal.tasks.ui.editors.TaskEditorExtensions.RegisteredTaskEditorExtension; > import org.eclipse.mylyn.tasks.core.TaskRepository; > import org.eclipse.mylyn.tasks.ui.TasksUiUtil; >+import org.eclipse.mylyn.tasks.ui.editors.AbstractTaskEditorExtension; > import org.eclipse.ui.PlatformUI; > import org.eclipse.ui.actions.CompoundContributionItem; > >Index: src/org/eclipse/mylyn/internal/sandbox/ui/editors/TaskEditorExtensionReader.java >=================================================================== >RCS file: src/org/eclipse/mylyn/internal/sandbox/ui/editors/TaskEditorExtensionReader.java >diff -N src/org/eclipse/mylyn/internal/sandbox/ui/editors/TaskEditorExtensionReader.java >--- src/org/eclipse/mylyn/internal/sandbox/ui/editors/TaskEditorExtensionReader.java 13 Sep 2008 03:38:54 -0000 1.5 >+++ /dev/null 1 Jan 1970 00:00:00 -0000 >@@ -1,85 +0,0 @@ >-/******************************************************************************* >- * Copyright (c) 2004, 2008 David Green 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: >- * David Green - initial API and implementation >- *******************************************************************************/ >- >-package org.eclipse.mylyn.internal.sandbox.ui.editors; >- >-import org.eclipse.core.runtime.CoreException; >-import org.eclipse.core.runtime.IConfigurationElement; >-import org.eclipse.core.runtime.IExtension; >-import org.eclipse.core.runtime.IExtensionPoint; >-import org.eclipse.core.runtime.IExtensionRegistry; >-import org.eclipse.core.runtime.IStatus; >-import org.eclipse.core.runtime.Platform; >-import org.eclipse.core.runtime.Status; >-import org.eclipse.mylyn.commons.core.StatusHandler; >-import org.eclipse.mylyn.internal.tasks.ui.TasksUiPlugin; >- >-/** >- * @author David Green >- */ >-public class TaskEditorExtensionReader { >- >- private static final String CONNECTOR_KIND = "connectorKind"; >- >- public static final String ATTR_ID = "id"; >- >- public static final String ATTR_NAME = "name"; >- >- public static final String EXTENSION_TASK_EDITOR_EXTENSIONS = "org.eclipse.mylyn.sandbox.ui.taskEditorExtensions"; >- >- private static final String REPOSITORY_ASSOCIATION = "repositoryAssociation"; >- >- private static final String TASK_EDITOR_EXTENSION = "taskEditorExtension"; >- >- public static void initExtensions() { >- IExtensionRegistry registry = Platform.getExtensionRegistry(); >- >- IExtensionPoint editorExtensionPoint = registry.getExtensionPoint(EXTENSION_TASK_EDITOR_EXTENSIONS); >- IExtension[] editorExtensions = editorExtensionPoint.getExtensions(); >- for (IExtension extension : editorExtensions) { >- IConfigurationElement[] elements = extension.getConfigurationElements(); >- for (IConfigurationElement element : elements) { >- if (element.getName().equals(TASK_EDITOR_EXTENSION)) { >- readEditorExtension(element); >- } else if (element.getName().equals(REPOSITORY_ASSOCIATION)) { >- readEditorExtensionAssociation(element); >- } >- } >- } >- } >- >- private static void readEditorExtension(IConfigurationElement element) { >- try { >- String id = element.getAttribute(ATTR_ID); >- String name = element.getAttribute(ATTR_NAME); >- AbstractTaskEditorExtension extension = (AbstractTaskEditorExtension) element.createExecutableExtension("class"); >- TaskEditorExtensions.addTaskEditorExtension(id, name, extension); >- } catch (CoreException e) { >- StatusHandler.log(new Status(IStatus.ERROR, TasksUiPlugin.ID_PLUGIN, "Could not load taskEditorExtension", >- e)); >- } catch (Exception e) { >- StatusHandler.log(new Status(IStatus.ERROR, TasksUiPlugin.ID_PLUGIN, "Could not load taskEditorExtension", >- e)); >- } >- } >- >- private static void readEditorExtensionAssociation(IConfigurationElement element) { >- try { >- String repository = element.getAttribute(CONNECTOR_KIND); >- String taskEditorExtension = element.getAttribute(TASK_EDITOR_EXTENSION); >- TaskEditorExtensions.addRepositoryAssociation(repository, taskEditorExtension); >- } catch (Exception e) { >- StatusHandler.log(new Status(IStatus.ERROR, TasksUiPlugin.ID_PLUGIN, >- "Could not load repositoryAssociation", e)); >- } >- } >- >-} >Index: src/org/eclipse/mylyn/internal/sandbox/ui/editors/AbstractTaskEditorExtension.java >=================================================================== >RCS file: src/org/eclipse/mylyn/internal/sandbox/ui/editors/AbstractTaskEditorExtension.java >diff -N src/org/eclipse/mylyn/internal/sandbox/ui/editors/AbstractTaskEditorExtension.java >--- src/org/eclipse/mylyn/internal/sandbox/ui/editors/AbstractTaskEditorExtension.java 13 Sep 2008 03:38:54 -0000 1.4 >+++ /dev/null 1 Jan 1970 00:00:00 -0000 >@@ -1,63 +0,0 @@ >-/******************************************************************************* >- * Copyright (c) 2004, 2008 David Green 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: >- * David Green - initial API and implementation >- *******************************************************************************/ >- >-package org.eclipse.mylyn.internal.sandbox.ui.editors; >- >-import org.eclipse.jface.text.source.SourceViewer; >-import org.eclipse.mylyn.tasks.core.TaskRepository; >-import org.eclipse.swt.widgets.Composite; >-import org.eclipse.ui.contexts.IContextService; >- >-/** >- * An extension that provides task editor capabilities beyond the default, oriented towards providing markup-aware >- * editing and viewing >- * >- * @author David Green >- */ >-public abstract class AbstractTaskEditorExtension { >- >- /** >- * The key to access the {@link TaskRepository} property that stores the URL of an associated wiki. >- */ >- public static final String INTERNAL_WIKI_LINK_PATTERN = "wikiLinkPattern"; >- >- /** >- * Creates a source viewer that can be used to view content in the task editor. The source viewer should be >- * configured with a source viewer configuration prior to returning. >- * >- * @param taskRepository >- * the task repository for which the viewer is created >- * @param parent >- * the control parent of the source viewer >- * @param style >- * the styles to use >- */ >- public abstract SourceViewer createViewer(TaskRepository taskRepository, Composite parent, int style); >- >- /** >- * Creates a source viewer that can be used to edit content in the task editor. The source viewer should be >- * configured with a source viewer configuration prior to returning. >- * >- * @param taskRepository >- * the task repository for which the viewer is created >- * @param parent >- * the control parent of the source viewer >- * @param style >- * the styles to use >- */ >- public abstract SourceViewer createEditor(TaskRepository taskRepository, Composite parent, int style); >- >- /** >- * Returns the editor context id, to be passed to the {@link IContextService} when the editor is in focus. >- */ >- public abstract String getEditorContextId(); >- >-} >Index: src/org/eclipse/mylyn/internal/sandbox/ui/editors/ExtensibleBugzillaTaskEditorPage.java >=================================================================== >RCS file: /cvsroot/tools/org.eclipse.mylyn/sandbox/org.eclipse.mylyn.sandbox.ui/src/org/eclipse/mylyn/internal/sandbox/ui/editors/ExtensibleBugzillaTaskEditorPage.java,v >retrieving revision 1.7 >diff -u -r1.7 ExtensibleBugzillaTaskEditorPage.java >--- src/org/eclipse/mylyn/internal/sandbox/ui/editors/ExtensibleBugzillaTaskEditorPage.java 13 Sep 2008 03:38:54 -0000 1.7 >+++ src/org/eclipse/mylyn/internal/sandbox/ui/editors/ExtensibleBugzillaTaskEditorPage.java 17 Oct 2008 03:20:37 -0000 >@@ -26,11 +26,8 @@ > import org.eclipse.mylyn.internal.bugzilla.ui.editor.BugzillaTaskEditorPage; > import org.eclipse.mylyn.internal.provisional.commons.ui.CommonImages; > import org.eclipse.mylyn.internal.tasks.ui.editors.EditorUtil; >-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; > import org.eclipse.swt.SWT; >@@ -45,7 +42,6 @@ > import org.eclipse.swt.widgets.Display; > import org.eclipse.swt.widgets.Text; > import org.eclipse.ui.actions.ActionFactory; >-import org.eclipse.ui.contexts.IContextService; > import org.eclipse.ui.forms.IManagedForm; > import org.eclipse.ui.forms.editor.IFormPage; > import org.eclipse.ui.forms.widgets.ExpandableComposite; >@@ -137,27 +133,6 @@ > } > > @Override >- protected AttributeEditorFactory createAttributeEditorFactory() { >- final AttributeEditorFactory bugzillaFactory = super.createAttributeEditorFactory(); >- AttributeEditorFactory factory = new AttributeEditorFactory(getModel(), getTaskRepository()) { >- @Override >- public AbstractAttributeEditor createEditor(String type, TaskAttribute taskAttribute) { >- // replace description part and the comment part >- AbstractTaskEditorExtension extension = TaskEditorExtensions.getTaskEditorExtension(getTaskRepository()); >- if (extension != null) { >- if (TaskAttribute.TYPE_LONG_RICH_TEXT.equals(type)) { >- return new ExtensibleRichTextAttributeEditor((IContextService) getEditor().getEditorSite() >- .getService(IContextService.class), getModel(), getTaskRepository(), extension, >- taskAttribute, SWT.MULTI); >- } >- } >- return bugzillaFactory.createEditor(type, taskAttribute); >- } >- }; >- return factory; >- } >- >- @Override > protected Set<TaskEditorPartDescriptor> createPartDescriptors() { > Set<TaskEditorPartDescriptor> descriptors = super.createPartDescriptors(); > >Index: src/org/eclipse/mylyn/internal/sandbox/ui/editors/TaskEditorExtensions.java >=================================================================== >RCS file: src/org/eclipse/mylyn/internal/sandbox/ui/editors/TaskEditorExtensions.java >diff -N src/org/eclipse/mylyn/internal/sandbox/ui/editors/TaskEditorExtensions.java >--- src/org/eclipse/mylyn/internal/sandbox/ui/editors/TaskEditorExtensions.java 13 Sep 2008 03:38:54 -0000 1.4 >+++ /dev/null 1 Jan 1970 00:00:00 -0000 >@@ -1,165 +0,0 @@ >-/******************************************************************************* >- * Copyright (c) 2004, 2008 David Green 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: >- * David Green - initial API and implementation >- *******************************************************************************/ >- >-package org.eclipse.mylyn.internal.sandbox.ui.editors; >- >-import java.util.HashMap; >-import java.util.Map; >-import java.util.SortedSet; >-import java.util.TreeSet; >- >-import org.eclipse.core.runtime.Assert; >-import org.eclipse.core.runtime.IStatus; >-import org.eclipse.core.runtime.Status; >-import org.eclipse.mylyn.commons.core.StatusHandler; >-import org.eclipse.mylyn.internal.tasks.ui.TasksUiPlugin; >-import org.eclipse.mylyn.tasks.core.TaskRepository; >- >-/** >- * @author David Green >- */ >-public class TaskEditorExtensions { >- >- public static final String REPOSITORY_PROPERTY_EDITOR_EXTENSION = "editorExtension"; >- >- private static Map<String, RegisteredTaskEditorExtension> extensionsById = new HashMap<String, RegisteredTaskEditorExtension>(); >- >- private static Map<String, String> associationByConnectorKind = new HashMap<String, String>(); >- >- private static boolean initialized; >- >- public static SortedSet<RegisteredTaskEditorExtension> getTaskEditorExtensions() { >- init(); >- return new TreeSet<RegisteredTaskEditorExtension>(extensionsById.values()); >- } >- >- public static void addTaskEditorExtension(String id, String name, AbstractTaskEditorExtension extension) { >- Assert.isNotNull(id); >- RegisteredTaskEditorExtension previous = extensionsById.put(id, new RegisteredTaskEditorExtension(extension, >- id, name)); >- if (previous != null) { >- StatusHandler.log(new Status(IStatus.ERROR, TasksUiPlugin.ID_PLUGIN, "Duplicate taskEditorExtension id=" >- + id, null)); >- } >- } >- >- public static void addRepositoryAssociation(String connectorKind, String extensionId) { >- if (connectorKind == null || extensionId == null) { >- throw new IllegalArgumentException(); >- } >- String previous = associationByConnectorKind.put(connectorKind, extensionId); >- if (previous != null) { >- StatusHandler.log(new Status(IStatus.ERROR, TasksUiPlugin.ID_PLUGIN, String.format( >- "Duplicate association for repository %s: %s replaces %s", connectorKind, extensionId, previous), >- null)); >- } >- } >- >- /** >- * get a task editor extension for a specific repository >- * >- * @param taskRepository >- * @return the extension, or null if there is none >- * >- * @see #getDefaultTaskEditorExtension(TaskRepository) >- */ >- public static AbstractTaskEditorExtension getTaskEditorExtension(TaskRepository taskRepository) { >- init(); >- String extensionId = getTaskEditorExtensionId(taskRepository); >- if (extensionId != null) { >- RegisteredTaskEditorExtension taskEditorExtension = extensionsById.get(extensionId); >- return taskEditorExtension == null ? null : taskEditorExtension.getExtension(); >- } >- return null; >- } >- >- public static String getTaskEditorExtensionId(TaskRepository taskRepository) { >- init(); >- String id = taskRepository.getProperty(REPOSITORY_PROPERTY_EDITOR_EXTENSION); >- if (id == null) { >- id = getDefaultTaskEditorExtensionId(taskRepository); >- } >- return id; >- } >- >- public static void setTaskEditorExtensionId(TaskRepository repository, String editorExtensionId) { >- repository.setProperty(REPOSITORY_PROPERTY_EDITOR_EXTENSION, editorExtensionId); >- } >- >- public static String getDefaultTaskEditorExtensionId(TaskRepository taskRepository) { >- init(); >- return associationByConnectorKind.get(taskRepository.getConnectorKind()); >- } >- >- /** >- * get a default task editor extension for a specific repository >- * >- * @param taskRepository >- * @return the extension, or null if there is none >- * >- * @see #getTaskEditorExtension(TaskRepository) >- */ >- public static AbstractTaskEditorExtension getDefaultTaskEditorExtension(TaskRepository taskRepository) { >- init(); >- String extensionId = getDefaultTaskEditorExtensionId(taskRepository); >- if (extensionId != null) { >- RegisteredTaskEditorExtension taskEditorExtension = extensionsById.get(extensionId); >- return taskEditorExtension == null ? null : taskEditorExtension.getExtension(); >- } >- return null; >- } >- >- private static void init() { >- if (!initialized) { >- initialized = true; >- TaskEditorExtensionReader.initExtensions(); >- } >- } >- >- public static class RegisteredTaskEditorExtension implements Comparable<RegisteredTaskEditorExtension> { >- >- private final String id; >- >- private final String name; >- >- private final AbstractTaskEditorExtension extension; >- >- private RegisteredTaskEditorExtension(AbstractTaskEditorExtension extension, String id, String name) { >- this.extension = extension; >- this.id = id; >- this.name = name; >- } >- >- public String getId() { >- return id; >- } >- >- public String getName() { >- return name; >- } >- >- public AbstractTaskEditorExtension getExtension() { >- return extension; >- } >- >- public int compareTo(RegisteredTaskEditorExtension o) { >- if (o == this) { >- return 0; >- } >- int i = name.compareTo(o.name); >- if (i == 0) { >- i = id.compareTo(o.id); >- } >- return i; >- } >- } >- >-} >Index: src/org/eclipse/mylyn/internal/sandbox/ui/editors/ExtensibleBugzillaTaskEditorPageFactory.java >=================================================================== >RCS file: /cvsroot/tools/org.eclipse.mylyn/sandbox/org.eclipse.mylyn.sandbox.ui/src/org/eclipse/mylyn/internal/sandbox/ui/editors/ExtensibleBugzillaTaskEditorPageFactory.java,v >retrieving revision 1.3 >diff -u -r1.3 ExtensibleBugzillaTaskEditorPageFactory.java >--- src/org/eclipse/mylyn/internal/sandbox/ui/editors/ExtensibleBugzillaTaskEditorPageFactory.java 13 Sep 2008 03:38:54 -0000 1.3 >+++ src/org/eclipse/mylyn/internal/sandbox/ui/editors/ExtensibleBugzillaTaskEditorPageFactory.java 17 Oct 2008 03:20:37 -0000 >@@ -13,6 +13,7 @@ > package org.eclipse.mylyn.internal.sandbox.ui.editors; > > import org.eclipse.mylyn.internal.bugzilla.ui.editor.BugzillaTaskEditorPageFactory; >+import org.eclipse.mylyn.internal.tasks.ui.editors.TaskEditorExtensions; > import org.eclipse.mylyn.tasks.ui.editors.TaskEditor; > import org.eclipse.mylyn.tasks.ui.editors.TaskEditorInput; > import org.eclipse.ui.forms.editor.FormPage; >Index: schema/taskEditorExtensions.exsd >=================================================================== >RCS file: schema/taskEditorExtensions.exsd >diff -N schema/taskEditorExtensions.exsd >--- schema/taskEditorExtensions.exsd 12 Sep 2008 21:11:53 -0000 1.3 >+++ /dev/null 1 Jan 1970 00:00:00 -0000 >@@ -1,152 +0,0 @@ >-<?xml version='1.0' encoding='UTF-8'?> >-<!-- Schema file written by PDE --> >-<schema targetNamespace="org.eclipse.mylyn.sandbox.ui" xmlns="http://www.w3.org/2001/XMLSchema"> >-<annotation> >- <appInfo> >- <meta.schema plugin="org.eclipse.mylyn.sandbox.ui" id="taskEditorExtensions" name="Task Editor Extensions"/> >- </appInfo> >- <documentation> >- An extension to the Mylyn task editor that can provide viewing and editing controls that are markup-aware. >- </documentation> >- </annotation> >- >- <element name="extension"> >- <annotation> >- <appInfo> >- <meta.element internal="true" /> >- </appInfo> >- </annotation> >- <complexType> >- <sequence> >- <element ref="taskEditorExtension" minOccurs="0" maxOccurs="unbounded"/> >- <element ref="repositoryAssociation" minOccurs="0" maxOccurs="unbounded"/> >- </sequence> >- <attribute name="point" type="string" use="required"> >- <annotation> >- <documentation> >- >- </documentation> >- </annotation> >- </attribute> >- <attribute name="id" type="string"> >- <annotation> >- <documentation> >- >- </documentation> >- </annotation> >- </attribute> >- <attribute name="name" type="string"> >- <annotation> >- <documentation> >- >- </documentation> >- <appInfo> >- <meta.attribute translatable="true"/> >- </appInfo> >- </annotation> >- </attribute> >- </complexType> >- </element> >- >- <element name="taskEditorExtension"> >- <annotation> >- <documentation> >- Declare an extension to the Mylyn task editor. Extensions are typically capable of providing improved editing capabilities, such as markup-aware. >- </documentation> >- </annotation> >- <complexType> >- <attribute name="class" type="string" use="required"> >- <annotation> >- <documentation> >- the fully qualified class name of the class that extends org.eclipse.mylyn.internal.sandbox.ui.editors.AbstractTaskEditorExtension >- </documentation> >- <appInfo> >- <meta.attribute kind="java" basedOn="org.eclipse.mylyn.internal.sandbox.ui.editors.AbstractTaskEditorExtension:"/> >- </appInfo> >- </annotation> >- </attribute> >- <attribute name="id" type="string" use="required"> >- <annotation> >- <documentation> >- a unique identifier identifying the extension >- </documentation> >- <appInfo> >- <meta.attribute kind="identifier"/> >- </appInfo> >- </annotation> >- </attribute> >- <attribute name="name" type="string" use="required"> >- <annotation> >- <documentation> >- A human-readable name for the extension that is presented to the Eclipse user in the UI. Should be translated. Used in the UI to identify the type of extension, so the name should indicate what the extension is for, and it should be short so that it can be displayed on one line (for example as an option in a combo box.) Example: "TracWiki", or "Textile". >- </documentation> >- <appInfo> >- <meta.attribute translatable="true"/> >- </appInfo> >- </annotation> >- </attribute> >- </complexType> >- </element> >- >- <element name="repositoryAssociation"> >- <annotation> >- <documentation> >- Associate the task editor extension with a kind of repository. Making such an association causes the taskEditorExtension to become the default or preferred setting for a kind of repository. >- </documentation> >- </annotation> >- <complexType> >- <attribute name="connectorKind" type="string" use="required"> >- <annotation> >- <documentation> >- the kind of connector for that this task editor extension should be associated with. >- </documentation> >- </annotation> >- </attribute> >- <attribute name="taskEditorExtension" type="string" use="required"> >- <annotation> >- <documentation> >- the id of the taskEditorExtension to associate >- </documentation> >- </annotation> >- </attribute> >- </complexType> >- </element> >- >- <annotation> >- <appInfo> >- <meta.section type="since"/> >- </appInfo> >- <documentation> >- 3.0 >- </documentation> >- </annotation> >- >- <annotation> >- <appInfo> >- <meta.section type="examples"/> >- </appInfo> >- <documentation> >- [Enter extension point usage example here.] >- </documentation> >- </annotation> >- >- <annotation> >- <appInfo> >- <meta.section type="apiinfo"/> >- </appInfo> >- <documentation> >- [Enter API information here.] >- </documentation> >- </annotation> >- >- <annotation> >- <appInfo> >- <meta.section type="implementation"/> >- </appInfo> >- <documentation> >- [Enter information about supplied implementation of this extension point.] >- </documentation> >- </annotation> >- >- >-</schema> >Index: src/org/eclipse/mylyn/internal/sandbox/ui/commands/ViewSourceHandler.java >=================================================================== >RCS file: src/org/eclipse/mylyn/internal/sandbox/ui/commands/ViewSourceHandler.java >diff -N src/org/eclipse/mylyn/internal/sandbox/ui/commands/ViewSourceHandler.java >--- src/org/eclipse/mylyn/internal/sandbox/ui/commands/ViewSourceHandler.java 13 Sep 2008 03:38:54 -0000 1.4 >+++ /dev/null 1 Jan 1970 00:00:00 -0000 >@@ -1,103 +0,0 @@ >-/******************************************************************************* >- * Copyright (c) 2004, 2008 Jingwen Ou 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: >- * Jingwen Ou - initial API and implementation >- * Tasktop Technologies - improvements >- *******************************************************************************/ >- >-package org.eclipse.mylyn.internal.sandbox.ui.commands; >- >-import java.util.Map; >- >-import org.eclipse.core.commands.AbstractHandler; >-import org.eclipse.core.commands.ExecutionEvent; >-import org.eclipse.core.commands.ExecutionException; >-import org.eclipse.core.commands.HandlerEvent; >-import org.eclipse.jface.action.IAction; >-import org.eclipse.mylyn.internal.tasks.ui.editors.EditorUtil; >-import org.eclipse.swt.custom.StyledText; >-import org.eclipse.swt.widgets.Control; >-import org.eclipse.ui.IEditorSite; >-import org.eclipse.ui.IWorkbenchPart; >-import org.eclipse.ui.IWorkbenchSite; >-import org.eclipse.ui.PlatformUI; >-import org.eclipse.ui.commands.IElementUpdater; >-import org.eclipse.ui.forms.editor.FormEditor; >-import org.eclipse.ui.forms.editor.IFormPage; >-import org.eclipse.ui.handlers.HandlerUtil; >-import org.eclipse.ui.menus.UIElement; >- >-/** >- * @author Jingwen Ou >- * @author Steffen Pingel >- */ >-public class ViewSourceHandler extends AbstractHandler implements IElementUpdater { >- >- private static boolean checked; >- >- private static ViewSourceHandler instance; >- >- public ViewSourceHandler() { >- instance = this; >- } >- >- public boolean isChecked() { >- return checked; >- } >- >- public static void setChecked(boolean checked) { >- ViewSourceHandler.checked = checked; >- if (instance != null) { >- instance.fireHandlerChanged(new HandlerEvent(instance, true, false)); >- } >- } >- >- private Control getFocusControl() { >- return PlatformUI.getWorkbench().getDisplay().getFocusControl(); >- } >- >- @Override >- public boolean isEnabled() { >- Control focusControl = getFocusControl(); >- if (focusControl instanceof StyledText && focusControl.getData(VIEW_SOURCE_ACTION) instanceof IAction) { >- return true; >- } >- >- return false; >- } >- >- public static final String VIEW_SOURCE_ACTION = "viewSourceAction"; >- >- public Object execute(ExecutionEvent event) throws ExecutionException { >- IWorkbenchSite site = HandlerUtil.getActiveSite(event); >- if (site instanceof IEditorSite) { >- IWorkbenchPart part = ((IEditorSite) site).getPart(); >- if (part instanceof FormEditor) { >- IFormPage page = ((FormEditor) part).getActivePageInstance(); >- Control focusedControl = EditorUtil.getFocusControl(page); >- if (focusedControl != null) { >- Object data = focusedControl.getData(VIEW_SOURCE_ACTION); >- if (data instanceof IAction) { >- IAction action = (IAction) data; >- action.setChecked(!action.isChecked()); >- action.run(); >- setChecked(action.isChecked()); >- EditorUtil.reflow(focusedControl); >- } >- } >- } >- } >- return null; >- } >- >- @SuppressWarnings("unchecked") >- public void updateElement(UIElement element, Map parameters) { >- element.setChecked(checked); >- } >- >-} >Index: plugin.xml >=================================================================== >RCS file: /cvsroot/tools/org.eclipse.mylyn/sandbox/org.eclipse.mylyn.sandbox.ui/plugin.xml,v >retrieving revision 1.92 >diff -u -r1.92 plugin.xml >--- plugin.xml 22 Aug 2008 20:00:09 -0000 1.92 >+++ plugin.xml 17 Oct 2008 03:20:37 -0000 >@@ -1,7 +1,6 @@ > <?xml version="1.0" encoding="UTF-8"?> > <?eclipse version="3.0"?> > <plugin> >- <extension-point id="taskEditorExtensions" name="Task Editor Extension" schema="schema/taskEditorExtensions.exsd"/> > <extension-point id="resourceHyperlinkExtensions" name="Resource Hyperlink Extension" schema="schema/resourceHyperlinkExtensions.exsd"/> > > <extension point="org.eclipse.ui.views"> >@@ -382,13 +381,6 @@ > <count > value="1"> > </count> >- <iterate> >- <test >- forcePluginActivation="false" >- property="org.eclipse.mylyn.taskRepository.connectorKind" >- value="bugzilla"> >- </test> >- </iterate> > </and> > </visibleWhen> > </menu> >@@ -431,15 +423,6 @@ > </command> > </menuContribution> > </extension> >- <extension >- point="org.eclipse.ui.commands"> >- <command >- categoryId="org.eclipse.mylyn.tasks.ui.commands" >- defaultHandler="org.eclipse.mylyn.internal.sandbox.ui.commands.ViewSourceHandler" >- id="org.eclipse.mylyn.sandbox.ui.viewSource.command" >- name="View Source"> >- </command> >- </extension> > <!-- > <extension point="org.eclipse.mylyn.tasks.ui.presentations"> > <presentation >Index: .refactorings/2008/10/42/refactorings.history >=================================================================== >RCS file: .refactorings/2008/10/42/refactorings.history >diff -N .refactorings/2008/10/42/refactorings.history >--- /dev/null 1 Jan 1970 00:00:00 -0000 >+++ .refactorings/2008/10/42/refactorings.history 1 Jan 1970 00:00:00 -0000 >@@ -0,0 +1,3 @@ >+<?xml version="1.0" encoding="UTF-8"?> >+<session version="1.0">
<refactoring comment="Move 2 elements(s) to 'org.eclipse.mylyn.tasks.ui/src/org.eclipse.mylyn.internal.tasks.ui.editors'
- Original project: 'org.eclipse.mylyn.sandbox.ui'
- Destination element: 'org.eclipse.mylyn.tasks.ui/src/org.eclipse.mylyn.internal.tasks.ui.editors'
- Original elements:
 org.eclipse.mylyn.internal.sandbox.ui.editors.TaskEditorExtensionReader.java
 org.eclipse.mylyn.internal.sandbox.ui.editors.TaskEditorExtensions.java
- Update references to refactored element" description="Move compilation units" destination="=org.eclipse.mylyn.tasks.ui/src<org.eclipse.mylyn.internal.tasks.ui.editors" element1="/src<org.eclipse.mylyn.internal.sandbox.ui.editors{TaskEditorExtensionReader.java" element2="/src<org.eclipse.mylyn.internal.sandbox.ui.editors{TaskEditorExtensions.java" files="0" flags="589830" folders="0" id="org.eclipse.jdt.ui.move" patterns="*" policy="org.eclipse.jdt.ui.moveResources" qualified="false" references="true" stamp="1224204730606" units="2" version="1.0"/>
<refactoring comment="Move 1 elements(s) to 'org.eclipse.mylyn.tasks.ui/src/org.eclipse.mylyn.tasks.ui.editors'
- Original project: 'org.eclipse.mylyn.sandbox.ui'
- Destination element: 'org.eclipse.mylyn.tasks.ui/src/org.eclipse.mylyn.tasks.ui.editors'
- Original element: 'org.eclipse.mylyn.internal.sandbox.ui.editors.AbstractTaskEditorExtension.java'
- Update references to refactored element" description="Move compilation unit" destination="=org.eclipse.mylyn.tasks.ui/src<org.eclipse.mylyn.tasks.ui.editors" element1="/src<org.eclipse.mylyn.internal.sandbox.ui.editors{AbstractTaskEditorExtension.java" files="0" flags="589830" folders="0" id="org.eclipse.jdt.ui.move" patterns="*" policy="org.eclipse.jdt.ui.moveResources" qualified="false" references="true" stamp="1224204780085" units="1" version="1.0"/>
<refactoring comment="Move 1 elements(s) to 'org.eclipse.mylyn.tasks.ui/src/org.eclipse.mylyn.internal.tasks.ui.commands'
- Original project: 'org.eclipse.mylyn.sandbox.ui'
- Destination element: 'org.eclipse.mylyn.tasks.ui/src/org.eclipse.mylyn.internal.tasks.ui.commands'
- Original element: 'org.eclipse.mylyn.internal.sandbox.ui.commands.ViewSourceHandler.java'
- Update references to refactored element" description="Move compilation unit" destination="=org.eclipse.mylyn.tasks.ui/src<org.eclipse.mylyn.internal.tasks.ui.commands" element1="/src<org.eclipse.mylyn.internal.sandbox.ui.commands{ViewSourceHandler.java" files="0" flags="589830" folders="0" id="org.eclipse.jdt.ui.move" patterns="*" policy="org.eclipse.jdt.ui.moveResources" qualified="false" references="true" stamp="1224205970323" units="1" version="1.0"/>
<refactoring comment="Move 1 elements(s) to 'schema'
- Original project: 'org.eclipse.mylyn.sandbox.ui'
- Destination element: 'schema'
- Original element: 'taskEditorExtensions.exsd'" description="Move file" element1="schema/taskEditorExtensions.exsd" files="1" flags="589830" folders="0" id="org.eclipse.jdt.ui.move" policy="org.eclipse.jdt.ui.moveResources" qualified="false" references="true" stamp="1224206083822" target="/org.eclipse.mylyn.tasks.ui/schema" units="0" version="1.0"/>
<refactoring accessors="true" comment="Delete 1 element(s) from project 'org.eclipse.mylyn.sandbox.ui'
- Original project: 'org.eclipse.mylyn.sandbox.ui'
- Original element: 'org.eclipse.mylyn.internal.sandbox.ui.editors.ExtensibleRichTextAttributeEditor.java'" description="Delete element" element1="/src<org.eclipse.mylyn.internal.sandbox.ui.editors{ExtensibleRichTextAttributeEditor.java" elements="1" flags="589830" id="org.eclipse.jdt.ui.delete" resources="0" stamp="1224210228104" subPackages="false" version="1.0"/> >+</session> >Index: .refactorings/2008/10/42/refactorings.index >=================================================================== >RCS file: .refactorings/2008/10/42/refactorings.index >diff -N .refactorings/2008/10/42/refactorings.index >--- /dev/null 1 Jan 1970 00:00:00 -0000 >+++ .refactorings/2008/10/42/refactorings.index 1 Jan 1970 00:00:00 -0000 >@@ -0,0 +1,5 @@ >+1224204730606 Move compilation units >+1224204780085 Move compilation unit >+1224205970323 Move compilation unit >+1224206083822 Move file >+1224210228104 Delete element >#P org.eclipse.mylyn.wikitext.textile.ui >Index: plugin.xml >=================================================================== >RCS file: /cvsroot/tools/org.eclipse.mylyn/sandbox/org.eclipse.mylyn.wikitext.textile.ui/plugin.xml,v >retrieving revision 1.6 >diff -u -r1.6 plugin.xml >--- plugin.xml 6 Oct 2008 15:33:47 -0000 1.6 >+++ plugin.xml 17 Oct 2008 03:20:39 -0000 >@@ -61,7 +61,7 @@ > </templates> > </extension> > <extension >- point="org.eclipse.mylyn.sandbox.ui.taskEditorExtensions"> >+ point="org.eclipse.mylyn.tasks.ui.taskEditorExtensions"> > <taskEditorExtension > class="org.eclipse.mylyn.internal.wikitext.textile.ui.editors.TextileTaskEditorExtension" > id="org.eclipse.mylyn.wikitext.textile.core.ui.taskEditorExtension" >#P org.eclipse.mylyn.tasks.ui >Index: src/org/eclipse/mylyn/internal/tasks/ui/editors/RichTextAttributeEditor.java >=================================================================== >RCS file: /cvsroot/tools/org.eclipse.mylyn/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/internal/tasks/ui/editors/RichTextAttributeEditor.java,v >retrieving revision 1.26 >diff -u -r1.26 RichTextAttributeEditor.java >--- src/org/eclipse/mylyn/internal/tasks/ui/editors/RichTextAttributeEditor.java 10 Oct 2008 01:43:24 -0000 1.26 >+++ src/org/eclipse/mylyn/internal/tasks/ui/editors/RichTextAttributeEditor.java 17 Oct 2008 03:20:40 -0000 >@@ -6,8 +6,9 @@ > * http://www.eclipse.org/legal/epl-v10.html > * > * Contributors: >- * Raphael Ackermann - initial API and implementation >- * Tasktop Technologies - improvements >+ * Tasktop Technologies - initial API and implementation >+ * Raphael Ackermann - spell checking support on bug 195514 >+ * Jingwen Ou - extensibility improvements > *******************************************************************************/ > > package org.eclipse.mylyn.internal.tasks.ui.editors; >@@ -15,6 +16,9 @@ > import java.util.Iterator; > > import org.eclipse.core.runtime.Assert; >+import org.eclipse.jface.action.Action; >+import org.eclipse.jface.action.IAction; >+import org.eclipse.jface.resource.JFaceResources; > import org.eclipse.jface.text.Document; > import org.eclipse.jface.text.ITextListener; > import org.eclipse.jface.text.TextEvent; >@@ -22,23 +26,34 @@ > import org.eclipse.jface.text.source.IAnnotationAccess; > import org.eclipse.jface.text.source.SourceViewer; > import org.eclipse.mylyn.internal.provisional.commons.ui.CommonThemes; >+import org.eclipse.mylyn.internal.tasks.ui.commands.ViewSourceHandler; > import org.eclipse.mylyn.internal.tasks.ui.editors.RepositoryTextViewerConfiguration.Mode; > import org.eclipse.mylyn.internal.tasks.ui.util.TasksUiInternal; > import org.eclipse.mylyn.tasks.core.TaskRepository; > 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.AbstractTaskEditorExtension; > 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.custom.StackLayout; > import org.eclipse.swt.events.DisposeEvent; > import org.eclipse.swt.events.DisposeListener; >+import org.eclipse.swt.events.FocusAdapter; >+import org.eclipse.swt.events.FocusEvent; >+import org.eclipse.swt.events.FocusListener; > import org.eclipse.swt.graphics.Font; >+import org.eclipse.swt.graphics.Point; > import org.eclipse.swt.widgets.Composite; >+import org.eclipse.swt.widgets.Control; > import org.eclipse.swt.widgets.Event; > import org.eclipse.swt.widgets.Listener; >+import org.eclipse.swt.widgets.Menu; > import org.eclipse.ui.PlatformUI; >+import org.eclipse.ui.contexts.IContextActivation; >+import org.eclipse.ui.contexts.IContextService; > import org.eclipse.ui.editors.text.EditorsUI; > import org.eclipse.ui.forms.widgets.FormToolkit; > import org.eclipse.ui.texteditor.AnnotationPreference; >@@ -48,27 +63,58 @@ > import org.eclipse.ui.themes.IThemeManager; > > /** >- * FIXME comment is out dated >+ * A text attribute editor that can switch between a editor, preview and source view. > * >- * Text viewer generally used for displaying non-editable text. No annotation model or spell checking support. Supports >- * cut/copy/paste/etc.. >- * >- * For viewing and editing text. Spell checking w/ annotations supported One or two max per editor, any more and the >- * spell checker will bring the editor to a grinding halt. >- * >- * @author Raphael Ackermann (bug 195514) >+ * @author Raphael Ackermann > * @author Steffen Pingel >+ * @author Jingwen Ou > */ > public class RichTextAttributeEditor extends AbstractAttributeEditor { > >- private RepositoryTextViewer viewer; >+ private IContextActivation contextActivation; > >- private boolean spellCheckingEnabled; >+ private final IContextService contextService; > >- private final int style; >+ private SourceViewer defaultViewer; >+ >+ private Composite editorComposite; >+ >+ private StackLayout editorLayout; >+ >+ private final AbstractTaskEditorExtension extension; >+ >+ private SourceViewer editorViewer; >+ >+ private SourceViewer previewViewer; > > private final TaskRepository taskRepository; > >+ private FormToolkit toolkit; >+ >+ public class ViewSourceAction extends Action { >+ >+ public ViewSourceAction() { >+ super("Viewer Source", SWT.TOGGLE); >+ setChecked(false); >+ } >+ >+ @Override >+ public void run() { >+ if (isChecked()) { >+ showDefault(); >+ } else { >+ showEditor(); >+ } >+ } >+ >+ } >+ >+ private final IAction viewSourceAction = new ViewSourceAction(); >+ >+ private boolean spellCheckingEnabled; >+ >+ private final int style; >+ > private Mode mode; > > public RichTextAttributeEditor(TaskDataModel manager, TaskRepository taskRepository, TaskAttribute taskAttribute) { >@@ -77,9 +123,16 @@ > > public RichTextAttributeEditor(TaskDataModel manager, TaskRepository taskRepository, TaskAttribute taskAttribute, > int style) { >+ this(manager, taskRepository, taskAttribute, style, null, null); >+ } >+ >+ public RichTextAttributeEditor(TaskDataModel manager, TaskRepository taskRepository, TaskAttribute taskAttribute, >+ int style, IContextService contextService, AbstractTaskEditorExtension extension) { > super(manager, taskAttribute); > this.taskRepository = taskRepository; > this.style = style; >+ this.contextService = contextService; >+ this.extension = extension; > if ((style & SWT.MULTI) != 0) { > setLayoutHint(new LayoutHint(RowSpan.MULTIPLE, ColumnSpan.MULTIPLE)); > } else { >@@ -97,15 +150,58 @@ > this.mode = mode; > } > >- private void configureAsTextEditor(Document document) { >+ private void installListeners(final SourceViewer viewer) { >+ viewer.addTextListener(new ITextListener() { >+ public void textChanged(TextEvent event) { >+ // filter out events caused by text presentation changes, e.g. annotation drawing >+ String value = viewer.getTextWidget().getText(); >+ if (!getValue().equals(value)) { >+ setValue(value); >+ EditorUtil.ensureVisible(viewer.getTextWidget()); >+ } >+ } >+ }); >+ // ensure that tab traverses to next control instead of inserting a tab character unless editing multi-line text >+ if ((style & SWT.MULTI) != 0 && mode != Mode.DEFAULT) { >+ viewer.getTextWidget().addListener(SWT.Traverse, new Listener() { >+ public void handleEvent(Event event) { >+ switch (event.detail) { >+ case SWT.TRAVERSE_TAB_NEXT: >+ case SWT.TRAVERSE_TAB_PREVIOUS: >+ event.doit = true; >+ break; >+ } >+ } >+ }); >+ } >+ } >+ >+ public String getValue() { >+ return getAttributeMapper().getValue(getTaskAttribute()); >+ } >+ >+ public boolean isSpellCheckingEnabled() { >+ return spellCheckingEnabled; >+ } >+ >+ public void setSpellCheckingEnabled(boolean spellCheckingEnabled) { >+ this.spellCheckingEnabled = spellCheckingEnabled; >+ } >+ >+ public void setValue(String value) { >+ getAttributeMapper().setValue(getTaskAttribute(), value); >+ attributeChanged(); >+ } >+ >+ /** Configures annotation model for spell checking. */ >+ private void configureAsEditor(SourceViewer viewer, Document document) { > AnnotationModel annotationModel = new AnnotationModel(); > viewer.showAnnotations(false); > viewer.showAnnotationsOverview(false); > IAnnotationAccess annotationAccess = new DefaultMarkerAnnotationAccess(); > final SourceViewerDecorationSupport support = new SourceViewerDecorationSupport(viewer, null, annotationAccess, > EditorsUI.getSharedTextColors()); >- @SuppressWarnings("unchecked") >- Iterator e = new MarkerAnnotationPreferences().getAnnotationPreferences().iterator(); >+ Iterator<?> e = new MarkerAnnotationPreferences().getAnnotationPreferences().iterator(); > while (e.hasNext()) { > support.setAnnotationPreference((AnnotationPreference) e.next()); > } >@@ -115,46 +211,15 @@ > support.uninstall(); > } > }); >- viewer.getTextWidget().setIndent(2); >+ //viewer.getTextWidget().setIndent(2); > viewer.setDocument(document, annotationModel); > } > >- @Override >- public void createControl(Composite parent, FormToolkit toolkit) { >- int style = this.style; >- if (!isReadOnly() && (style & TasksUiInternal.SWT_NO_SCROLL) == 0) { >- style |= SWT.V_SCROLL; >- } >- viewer = new RepositoryTextViewer(taskRepository, parent, SWT.FLAT | SWT.WRAP | style); >- >- // NOTE: configuration must be applied before the document is set in order for >- // hyper link coloring to work, the Presenter requires the document object up front >- configure(); >- >- Document document = new Document(getValue()); >- if (isReadOnly()) { >- viewer.setEditable(false); >- viewer.setDocument(document); >- } else { >- viewer.setEditable(true); >- configureAsTextEditor(document); >- installListeners(viewer); >- viewer.getControl().setData(FormToolkit.KEY_DRAW_BORDER, FormToolkit.TEXT_BORDER); >- } >- >- IThemeManager themeManager = PlatformUI.getWorkbench().getThemeManager(); >- Font font = themeManager.getCurrentTheme().getFontRegistry().get(CommonThemes.FONT_EDITOR_COMMENT); >- viewer.getTextWidget().setFont(font); >- toolkit.adapt(viewer.getTextWidget(), false, false); >- >- setControl(viewer.getTextWidget()); >- } >- >- private RepositoryTextViewerConfiguration configure() { >- RepositoryTextViewerConfiguration configuration = new RepositoryTextViewerConfiguration(taskRepository, >- spellCheckingEnabled); >+ private RepositoryTextViewerConfiguration installHyperlinkPresenter(SourceViewer viewer) { >+ RepositoryTextViewerConfiguration configuration = new RepositoryTextViewerConfiguration(taskRepository, false); > configuration.setMode(getMode()); >- viewer.configure(configuration); >+ >+ // do not configure viewer, this has already been done in extension > > AbstractHyperlinkTextPresentationManager manager; > if (getMode() == Mode.DEFAULT) { >@@ -174,51 +239,218 @@ > return configuration; > } > >- private void installListeners(RepositoryTextViewer viewer2) { >- viewer.addTextListener(new ITextListener() { >- public void textChanged(TextEvent event) { >- // filter out events caused by text presentation changes, e.g. annotation drawing >- String value = viewer.getTextWidget().getText(); >- if (!getValue().equals(value)) { >- setValue(value); >- EditorUtil.ensureVisible(viewer.getTextWidget()); >- } >+ private SourceViewer configure(final SourceViewer viewer, boolean readOnly) { >+ // do this before setting the document to not require invalidating the presentation >+ installHyperlinkPresenter(viewer); >+ >+ Document document = new Document(getValue()); >+ if (readOnly) { >+ viewer.setDocument(document); >+ if (extension != null) { >+ // setting view source action >+ viewer.getControl().setData(ViewSourceHandler.VIEW_SOURCE_ACTION, viewSourceAction); >+ viewer.getControl().addFocusListener(new FocusAdapter() { >+ @Override >+ public void focusGained(FocusEvent e) { >+ ViewSourceHandler.setChecked(getViewer() == defaultViewer); >+ } >+ }); > } >- }); >- // ensure that tab traverses to next control instead of inserting a tab character unless editing multi-line text >- if ((style & SWT.MULTI) != 0 && mode != Mode.DEFAULT) { >- viewer.getTextWidget().addListener(SWT.Traverse, new Listener() { >- public void handleEvent(Event event) { >- switch (event.detail) { >- case SWT.TRAVERSE_TAB_NEXT: >- case SWT.TRAVERSE_TAB_PREVIOUS: >- event.doit = true; >- break; >+ } else { >+ configureAsEditor(viewer, document); >+ installListeners(viewer); >+ viewer.getControl().setData(FormToolkit.KEY_DRAW_BORDER, FormToolkit.TEXT_BORDER); >+ } >+ >+ // enable cut/copy/paste >+ EditorUtil.setTextViewer(viewer.getTextWidget(), viewer); >+ viewer.setEditable(!readOnly); >+ viewer.getTextWidget().setFont(getFont()); >+ toolkit.adapt(viewer.getControl(), false, false); >+ >+ return viewer; >+ } >+ >+ @Override >+ public void createControl(Composite parent, FormToolkit toolkit) { >+ this.toolkit = toolkit; >+ >+ int style = this.style; >+ if (!isReadOnly() && (style & TasksUiInternal.SWT_NO_SCROLL) == 0) { >+ style |= SWT.V_SCROLL; >+ } >+ >+ if (extension != null) { >+ editorComposite = new Composite(parent, SWT.NULL); >+ editorLayout = new StackLayout() { >+ @Override >+ protected Point computeSize(Composite composite, int hint, int hint2, boolean flushCache) { >+ return topControl.computeSize(hint, hint2, flushCache); >+ } >+ }; >+ editorComposite.setLayout(editorLayout); >+ setControl(editorComposite); >+ >+ if (isReadOnly()) { >+ editorViewer = extension.createViewer(taskRepository, editorComposite, style); >+ } else { >+ editorViewer = extension.createEditor(taskRepository, editorComposite, style); >+ editorViewer.getTextWidget().addFocusListener(new FocusListener() { >+ public void focusGained(FocusEvent e) { >+ setContext(); > } >+ >+ public void focusLost(FocusEvent e) { >+ unsetContext(); >+ } >+ }); >+ editorViewer.getTextWidget().addDisposeListener(new DisposeListener() { >+ public void widgetDisposed(DisposeEvent e) { >+ unsetContext(); >+ } >+ }); >+ } >+ configure(editorViewer, isReadOnly()); >+ show(editorViewer); >+ } else { >+ defaultViewer = createDefaultEditor(parent, style); >+ configure(defaultViewer, isReadOnly()); >+ setControl(defaultViewer.getControl()); >+ } >+ } >+ >+ private SourceViewer createDefaultEditor(Composite parent, int styles) { >+ SourceViewer defaultEditor = new RepositoryTextViewer(taskRepository, parent, styles | SWT.WRAP); >+ >+ RepositoryTextViewerConfiguration viewerConfig = new RepositoryTextViewerConfiguration(taskRepository, >+ isSpellCheckingEnabled()); >+ viewerConfig.setMode(getMode()); >+ defaultEditor.configure(viewerConfig); >+ >+ return defaultEditor; >+ } >+ >+ public SourceViewer getDefaultViewer() { >+ if (defaultViewer == null) { >+ defaultViewer = createDefaultEditor(editorComposite, style); >+ configure(defaultViewer, isReadOnly()); >+ >+ // fixed font size >+ defaultViewer.getTextWidget().setFont(JFaceResources.getFontRegistry().get(JFaceResources.TEXT_FONT)); >+ // adapt maximize action >+ defaultViewer.getControl().setData(EditorUtil.KEY_TOGGLE_TO_MAXIMIZE_ACTION, >+ editorViewer.getControl().getData(EditorUtil.KEY_TOGGLE_TO_MAXIMIZE_ACTION)); >+ // adapt menu to the new viewer >+ installMenu(defaultViewer.getControl(), editorViewer.getControl().getMenu()); >+ } >+ return defaultViewer; >+ } >+ >+ private void installMenu(final Control control, Menu menu) { >+ if (menu != null) { >+ control.setMenu(menu); >+ control.addDisposeListener(new DisposeListener() { >+ public void widgetDisposed(DisposeEvent e) { >+ control.setMenu(null); > } > }); > } > } > >- public String getValue() { >- return getAttributeMapper().getValue(getTaskAttribute()); >+ private Font getFont() { >+ IThemeManager themeManager = PlatformUI.getWorkbench().getThemeManager(); >+ Font font = themeManager.getCurrentTheme().getFontRegistry().get(CommonThemes.FONT_EDITOR_COMMENT); >+ return font; >+ } >+ >+ private SourceViewer getPreviewViewer() { >+ if (extension == null) { >+ return null; >+ } >+ >+ // construct as needed >+ if (previewViewer == null) { >+ previewViewer = extension.createViewer(taskRepository, editorComposite, style); >+ configure(previewViewer, true); >+ // adapt maximize action >+ previewViewer.getControl().setData(EditorUtil.KEY_TOGGLE_TO_MAXIMIZE_ACTION, >+ editorViewer.getControl().getData(EditorUtil.KEY_TOGGLE_TO_MAXIMIZE_ACTION)); >+ } >+ Document document = new Document(editorViewer.getDocument().get()); >+ previewViewer.setDocument(document); >+ return previewViewer; >+ } >+ >+ public SourceViewer getEditorViewer() { >+ return editorViewer; > } > > public SourceViewer getViewer() { >- return viewer; >+ if (editorLayout == null) { >+ return defaultViewer; >+ } >+ if (defaultViewer != null && editorLayout.topControl == defaultViewer.getControl()) { >+ return defaultViewer; >+ } else if (previewViewer != null && editorLayout.topControl == previewViewer.getControl()) { >+ return previewViewer; >+ } else { >+ return editorViewer; >+ } > } > >- public boolean isSpellCheckingEnabled() { >- return spellCheckingEnabled; >+ private void setContext() { >+ if (contextService == null) { >+ return; >+ } >+ if (contextActivation != null) { >+ contextService.deactivateContext(contextActivation); >+ contextActivation = null; >+ } >+ if (contextService != null && extension.getEditorContextId() != null) { >+ contextActivation = contextService.activateContext(extension.getEditorContextId()); >+ } > } > >- public void setSpellCheckingEnabled(boolean spellCheckingEnabled) { >- this.spellCheckingEnabled = spellCheckingEnabled; >+ /** >+ * Brings <code>viewer</code> to top. >+ */ >+ private void show(SourceViewer viewer) { >+ // no extension is available >+ if (editorComposite == null) { >+ return; >+ } >+ >+ editorLayout.topControl = viewer.getControl(); >+ editorComposite.layout(); >+ viewer.getControl().setFocus(); > } > >- public void setValue(String value) { >- getAttributeMapper().setValue(getTaskAttribute(), value); >- attributeChanged(); >+ public void showDefault() { >+ show(getDefaultViewer()); >+ } >+ >+ public void showPreview() { >+ if (!isReadOnly()) { >+ show(getPreviewViewer()); >+ } >+ } >+ >+ public void showEditor() { >+ show(getEditorViewer()); >+ } >+ >+ private void unsetContext() { >+ if (contextService == null) { >+ return; >+ } >+ if (contextActivation != null) { >+ contextService.deactivateContext(contextActivation); >+ contextActivation = null; >+ } >+ } >+ >+ public boolean hasPreview() { >+ return extension != null && !isReadOnly(); > } > > } >Index: src/org/eclipse/mylyn/internal/tasks/ui/editors/TaskEditorRichTextPart.java >=================================================================== >RCS file: /cvsroot/tools/org.eclipse.mylyn/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/internal/tasks/ui/editors/TaskEditorRichTextPart.java,v >retrieving revision 1.22 >diff -u -r1.22 TaskEditorRichTextPart.java >--- src/org/eclipse/mylyn/internal/tasks/ui/editors/TaskEditorRichTextPart.java 1 Oct 2008 06:06:48 -0000 1.22 >+++ src/org/eclipse/mylyn/internal/tasks/ui/editors/TaskEditorRichTextPart.java 17 Oct 2008 03:20:40 -0000 >@@ -14,6 +14,7 @@ > import org.eclipse.core.runtime.IStatus; > import org.eclipse.core.runtime.Status; > import org.eclipse.jface.action.Action; >+import org.eclipse.jface.action.ToolBarManager; > import org.eclipse.jface.layout.GridDataFactory; > import org.eclipse.mylyn.commons.core.StatusHandler; > import org.eclipse.mylyn.internal.provisional.commons.ui.CommonImages; >@@ -27,6 +28,7 @@ > import org.eclipse.swt.layout.GridData; > import org.eclipse.swt.layout.GridLayout; > import org.eclipse.swt.widgets.Composite; >+import org.eclipse.swt.widgets.Control; > import org.eclipse.ui.forms.widgets.ExpandableComposite; > import org.eclipse.ui.forms.widgets.FormToolkit; > import org.eclipse.ui.forms.widgets.Section; >@@ -158,6 +160,12 @@ > } > } > >+ getEditor().getControl().setData(EditorUtil.KEY_TOGGLE_TO_MAXIMIZE_ACTION, getMaximizePartAction()); >+ if (getEditor().getControl() instanceof Composite) { >+ for (Control control : ((Composite) getEditor().getControl()).getChildren()) { >+ control.setData(EditorUtil.KEY_TOGGLE_TO_MAXIMIZE_ACTION, getMaximizePartAction()); >+ } >+ } > getTaskEditorPage().getAttributeEditorToolkit().adapt(editor); > > toolkit.paintBordersFor(composite); >@@ -234,10 +242,6 @@ > > @Override > public void run() { >- toogleToMaximizePart(); >- } >- >- private void toogleToMaximizePart() { > if (!(getEditor().getControl().getLayoutData() instanceof GridData)) { > return; > } >@@ -273,4 +277,30 @@ > } > } > >+ @Override >+ protected void fillToolBar(ToolBarManager manager) { >+ if (getEditor().hasPreview()) { >+ Action toggleEditingAction = new Action("", SWT.TOGGLE) { >+ @Override >+ public void run() { >+ toggleEditing(this); >+ } >+ }; >+ toggleEditingAction.setImageDescriptor(CommonImages.PREVIEW_WEB); >+ toggleEditingAction.setToolTipText("Preview"); >+ toggleEditingAction.setChecked(false); >+ manager.add(toggleEditingAction); >+ } >+ manager.add(getMaximizePartAction()); >+ super.fillToolBar(manager); >+ } >+ >+ private void toggleEditing(Action action) { >+ if (action.isChecked()) { >+ editor.showPreview(); >+ } else { >+ editor.showEditor(); >+ } >+ } >+ > } >Index: src/org/eclipse/mylyn/tasks/ui/editors/AbstractTaskEditorPage.java >=================================================================== >RCS file: /cvsroot/tools/org.eclipse.mylyn/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/tasks/ui/editors/AbstractTaskEditorPage.java,v >retrieving revision 1.84 >diff -u -r1.84 AbstractTaskEditorPage.java >--- src/org/eclipse/mylyn/tasks/ui/editors/AbstractTaskEditorPage.java 11 Oct 2008 05:02:11 -0000 1.84 >+++ src/org/eclipse/mylyn/tasks/ui/editors/AbstractTaskEditorPage.java 17 Oct 2008 03:20:40 -0000 >@@ -487,7 +487,7 @@ > } > > protected AttributeEditorFactory createAttributeEditorFactory() { >- return new AttributeEditorFactory(getModel(), getTaskRepository()); >+ return new AttributeEditorFactory(getModel(), getTaskRepository(), getEditorSite()); > } > > AttributeEditorToolkit createAttributeEditorToolkit() { >Index: src/org/eclipse/mylyn/tasks/ui/editors/AttributeEditorFactory.java >=================================================================== >RCS file: /cvsroot/tools/org.eclipse.mylyn/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/tasks/ui/editors/AttributeEditorFactory.java,v >retrieving revision 1.8 >diff -u -r1.8 AttributeEditorFactory.java >--- src/org/eclipse/mylyn/tasks/ui/editors/AttributeEditorFactory.java 12 Sep 2008 04:19:26 -0000 1.8 >+++ src/org/eclipse/mylyn/tasks/ui/editors/AttributeEditorFactory.java 17 Oct 2008 03:20:40 -0000 >@@ -1,5 +1,5 @@ > /******************************************************************************* >-* Copyright (c) 2004, 2008 Tasktop Technologies and others. >+ * 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 >@@ -19,6 +19,7 @@ > import org.eclipse.mylyn.internal.tasks.ui.editors.PersonAttributeEditor; > import org.eclipse.mylyn.internal.tasks.ui.editors.RichTextAttributeEditor; > import org.eclipse.mylyn.internal.tasks.ui.editors.SingleSelectionAttributeEditor; >+import org.eclipse.mylyn.internal.tasks.ui.editors.TaskEditorExtensions; > import org.eclipse.mylyn.internal.tasks.ui.editors.TextAttributeEditor; > import org.eclipse.mylyn.internal.tasks.ui.editors.RepositoryTextViewerConfiguration.Mode; > import org.eclipse.mylyn.internal.tasks.ui.util.TasksUiInternal; >@@ -28,6 +29,8 @@ > 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.ui.contexts.IContextService; >+import org.eclipse.ui.services.IServiceLocator; > > /** > * @since 3.0 >@@ -39,9 +42,21 @@ > > private final TaskRepository taskRepository; > >+ private final IServiceLocator serviceLocator; >+ > public AttributeEditorFactory(TaskDataModel model, TaskRepository taskRepository) { >+ this(model, taskRepository, null); >+ } >+ >+ /** >+ * @since 3.1 >+ */ >+ public AttributeEditorFactory(TaskDataModel model, TaskRepository taskRepository, IServiceLocator serviceLocator) { >+ Assert.isNotNull(model); >+ Assert.isNotNull(taskRepository); > this.model = model; > this.taskRepository = taskRepository; >+ this.serviceLocator = serviceLocator; > } > > public AbstractAttributeEditor createEditor(String type, TaskAttribute taskAttribute) { >@@ -54,6 +69,16 @@ > } else if (TaskAttribute.TYPE_PERSON.equals(type)) { > return new PersonAttributeEditor(model, taskAttribute); > } else if (TaskAttribute.TYPE_LONG_RICH_TEXT.equals(type)) { >+ if (serviceLocator != null) { >+ IContextService contextService = (IContextService) serviceLocator.getService(IContextService.class); >+ if (contextService != null) { >+ AbstractTaskEditorExtension extension = TaskEditorExtensions.getTaskEditorExtension(model.getTaskRepository()); >+ if (extension != null) { >+ return new RichTextAttributeEditor(model, taskRepository, taskAttribute, SWT.MULTI, >+ contextService, extension); >+ } >+ } >+ } > return new RichTextAttributeEditor(model, taskRepository, taskAttribute); > } else if (TaskAttribute.TYPE_LONG_TEXT.equals(type)) { > return new LongTextAttributeEditor(model, taskAttribute); >Index: plugin.xml >=================================================================== >RCS file: /cvsroot/tools/org.eclipse.mylyn/org.eclipse.mylyn.tasks.ui/plugin.xml,v >retrieving revision 1.340 >diff -u -r1.340 plugin.xml >--- plugin.xml 12 Sep 2008 18:13:11 -0000 1.340 >+++ plugin.xml 17 Oct 2008 03:20:40 -0000 >@@ -7,6 +7,7 @@ > <extension-point id="projectLinkProviders" name="Linking Provider from Project to the Task Repository" schema="schema/projectLinkProviders.exsd"/> > <extension-point id="duplicateDetectors" name="duplicateDetectors" schema="schema/duplicateDetectors.exsd"/> > <extension-point id="presentations" name="presentations" schema="schema/presentations.exsd"/> >+ <extension-point id="taskEditorExtensions" name="Task Editor Extension" schema="schema/taskEditorExtensions.exsd"/> > > <extension > point="org.eclipse.mylyn.context.core.bridges"> >@@ -1745,6 +1746,12 @@ > id="org.eclipse.mylyn.tasks.ui.command.maximizePart" > name="Maximize Part"> > </command> >+ <command >+ categoryId="org.eclipse.mylyn.tasks.ui.commands" >+ defaultHandler="org.eclipse.mylyn.internal.tasks.ui.commands.ViewSourceHandler" >+ id="org.eclipse.mylyn.sandbox.ui.viewSource.command" >+ name="View Source"> >+ </command> > </extension> > <extension > point="org.eclipse.ui.bindings"> >Index: src/org/eclipse/mylyn/internal/tasks/ui/editors/TaskEditorExtensionReader.java >=================================================================== >RCS file: src/org/eclipse/mylyn/internal/tasks/ui/editors/TaskEditorExtensionReader.java >diff -N src/org/eclipse/mylyn/internal/tasks/ui/editors/TaskEditorExtensionReader.java >--- /dev/null 1 Jan 1970 00:00:00 -0000 >+++ src/org/eclipse/mylyn/internal/tasks/ui/editors/TaskEditorExtensionReader.java 1 Jan 1970 00:00:00 -0000 >@@ -0,0 +1,86 @@ >+/******************************************************************************* >+ * Copyright (c) 2004, 2008 David Green 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: >+ * David Green - initial API and implementation >+ *******************************************************************************/ >+ >+package org.eclipse.mylyn.internal.tasks.ui.editors; >+ >+import org.eclipse.core.runtime.CoreException; >+import org.eclipse.core.runtime.IConfigurationElement; >+import org.eclipse.core.runtime.IExtension; >+import org.eclipse.core.runtime.IExtensionPoint; >+import org.eclipse.core.runtime.IExtensionRegistry; >+import org.eclipse.core.runtime.IStatus; >+import org.eclipse.core.runtime.Platform; >+import org.eclipse.core.runtime.Status; >+import org.eclipse.mylyn.commons.core.StatusHandler; >+import org.eclipse.mylyn.internal.tasks.ui.TasksUiPlugin; >+import org.eclipse.mylyn.tasks.ui.editors.AbstractTaskEditorExtension; >+ >+/** >+ * @author David Green >+ */ >+public class TaskEditorExtensionReader { >+ >+ private static final String CONNECTOR_KIND = "connectorKind"; >+ >+ public static final String ATTR_ID = "id"; >+ >+ public static final String ATTR_NAME = "name"; >+ >+ public static final String EXTENSION_TASK_EDITOR_EXTENSIONS = "org.eclipse.mylyn.tasks.ui.taskEditorExtensions"; >+ >+ private static final String REPOSITORY_ASSOCIATION = "repositoryAssociation"; >+ >+ private static final String TASK_EDITOR_EXTENSION = "taskEditorExtension"; >+ >+ public static void initExtensions() { >+ IExtensionRegistry registry = Platform.getExtensionRegistry(); >+ >+ IExtensionPoint editorExtensionPoint = registry.getExtensionPoint(EXTENSION_TASK_EDITOR_EXTENSIONS); >+ IExtension[] editorExtensions = editorExtensionPoint.getExtensions(); >+ for (IExtension extension : editorExtensions) { >+ IConfigurationElement[] elements = extension.getConfigurationElements(); >+ for (IConfigurationElement element : elements) { >+ if (element.getName().equals(TASK_EDITOR_EXTENSION)) { >+ readEditorExtension(element); >+ } else if (element.getName().equals(REPOSITORY_ASSOCIATION)) { >+ readEditorExtensionAssociation(element); >+ } >+ } >+ } >+ } >+ >+ private static void readEditorExtension(IConfigurationElement element) { >+ try { >+ String id = element.getAttribute(ATTR_ID); >+ String name = element.getAttribute(ATTR_NAME); >+ AbstractTaskEditorExtension extension = (AbstractTaskEditorExtension) element.createExecutableExtension("class"); >+ TaskEditorExtensions.addTaskEditorExtension(id, name, extension); >+ } catch (CoreException e) { >+ StatusHandler.log(new Status(IStatus.ERROR, TasksUiPlugin.ID_PLUGIN, "Could not load taskEditorExtension", >+ e)); >+ } catch (Exception e) { >+ StatusHandler.log(new Status(IStatus.ERROR, TasksUiPlugin.ID_PLUGIN, "Could not load taskEditorExtension", >+ e)); >+ } >+ } >+ >+ private static void readEditorExtensionAssociation(IConfigurationElement element) { >+ try { >+ String repository = element.getAttribute(CONNECTOR_KIND); >+ String taskEditorExtension = element.getAttribute(TASK_EDITOR_EXTENSION); >+ TaskEditorExtensions.addRepositoryAssociation(repository, taskEditorExtension); >+ } catch (Exception e) { >+ StatusHandler.log(new Status(IStatus.ERROR, TasksUiPlugin.ID_PLUGIN, >+ "Could not load repositoryAssociation", e)); >+ } >+ } >+ >+} >Index: schema/taskEditorExtensions.exsd >=================================================================== >RCS file: schema/taskEditorExtensions.exsd >diff -N schema/taskEditorExtensions.exsd >--- /dev/null 1 Jan 1970 00:00:00 -0000 >+++ schema/taskEditorExtensions.exsd 1 Jan 1970 00:00:00 -0000 >@@ -0,0 +1,152 @@ >+<?xml version='1.0' encoding='UTF-8'?> >+<!-- Schema file written by PDE --> >+<schema targetNamespace="org.eclipse.mylyn.tasks.ui" xmlns="http://www.w3.org/2001/XMLSchema"> >+<annotation> >+ <appinfo> >+ <meta.schema plugin="org.eclipse.mylyn.tasks.ui" id="taskEditorExtensions" name="Task Editor Extensions"/> >+ </appinfo> >+ <documentation> >+ An extension to the Mylyn task editor that can provide viewing and editing controls that are markup-aware. >+ </documentation> >+ </annotation> >+ >+ <element name="extension"> >+ <annotation> >+ <appinfo> >+ <meta.element /> >+ </appinfo> >+ </annotation> >+ <complexType> >+ <sequence> >+ <element ref="taskEditorExtension" minOccurs="0" maxOccurs="unbounded"/> >+ <element ref="repositoryAssociation" minOccurs="0" maxOccurs="unbounded"/> >+ </sequence> >+ <attribute name="point" type="string" use="required"> >+ <annotation> >+ <documentation> >+ >+ </documentation> >+ </annotation> >+ </attribute> >+ <attribute name="id" type="string"> >+ <annotation> >+ <documentation> >+ >+ </documentation> >+ </annotation> >+ </attribute> >+ <attribute name="name" type="string"> >+ <annotation> >+ <documentation> >+ >+ </documentation> >+ <appinfo> >+ <meta.attribute translatable="true"/> >+ </appinfo> >+ </annotation> >+ </attribute> >+ </complexType> >+ </element> >+ >+ <element name="taskEditorExtension"> >+ <annotation> >+ <documentation> >+ Declare an extension to the Mylyn task editor. Extensions are typically capable of providing improved editing capabilities, such as markup-aware. >+ </documentation> >+ </annotation> >+ <complexType> >+ <attribute name="class" type="string" use="required"> >+ <annotation> >+ <documentation> >+ the fully qualified class name of the class that extends org.eclipse.mylyn.internal.sandbox.ui.editors.AbstractTaskEditorExtension >+ </documentation> >+ <appinfo> >+ <meta.attribute kind="java" basedOn="org.eclipse.mylyn.internal.sandbox.ui.editors.AbstractTaskEditorExtension:"/> >+ </appinfo> >+ </annotation> >+ </attribute> >+ <attribute name="id" type="string" use="required"> >+ <annotation> >+ <documentation> >+ a unique identifier identifying the extension >+ </documentation> >+ <appinfo> >+ <meta.attribute kind="identifier"/> >+ </appinfo> >+ </annotation> >+ </attribute> >+ <attribute name="name" type="string" use="required"> >+ <annotation> >+ <documentation> >+ A human-readable name for the extension that is presented to the Eclipse user in the UI. Should be translated. Used in the UI to identify the type of extension, so the name should indicate what the extension is for, and it should be short so that it can be displayed on one line (for example as an option in a combo box.) Example: "TracWiki", or "Textile". >+ </documentation> >+ <appinfo> >+ <meta.attribute translatable="true"/> >+ </appinfo> >+ </annotation> >+ </attribute> >+ </complexType> >+ </element> >+ >+ <element name="repositoryAssociation"> >+ <annotation> >+ <documentation> >+ Associate the task editor extension with a kind of repository. Making such an association causes the taskEditorExtension to become the default or preferred setting for a kind of repository. >+ </documentation> >+ </annotation> >+ <complexType> >+ <attribute name="connectorKind" type="string" use="required"> >+ <annotation> >+ <documentation> >+ the kind of connector for that this task editor extension should be associated with. >+ </documentation> >+ </annotation> >+ </attribute> >+ <attribute name="taskEditorExtension" type="string" use="required"> >+ <annotation> >+ <documentation> >+ the id of the taskEditorExtension to associate >+ </documentation> >+ </annotation> >+ </attribute> >+ </complexType> >+ </element> >+ >+ <annotation> >+ <appinfo> >+ <meta.section type="since"/> >+ </appinfo> >+ <documentation> >+ 3.0 >+ </documentation> >+ </annotation> >+ >+ <annotation> >+ <appinfo> >+ <meta.section type="examples"/> >+ </appinfo> >+ <documentation> >+ [Enter extension point usage example here.] >+ </documentation> >+ </annotation> >+ >+ <annotation> >+ <appinfo> >+ <meta.section type="apiinfo"/> >+ </appinfo> >+ <documentation> >+ [Enter API information here.] >+ </documentation> >+ </annotation> >+ >+ <annotation> >+ <appinfo> >+ <meta.section type="implementation"/> >+ </appinfo> >+ <documentation> >+ [Enter information about supplied implementation of this extension point.] >+ </documentation> >+ </annotation> >+ >+ >+</schema> >Index: src/org/eclipse/mylyn/tasks/ui/editors/AbstractTaskEditorExtension.java >=================================================================== >RCS file: src/org/eclipse/mylyn/tasks/ui/editors/AbstractTaskEditorExtension.java >diff -N src/org/eclipse/mylyn/tasks/ui/editors/AbstractTaskEditorExtension.java >--- /dev/null 1 Jan 1970 00:00:00 -0000 >+++ src/org/eclipse/mylyn/tasks/ui/editors/AbstractTaskEditorExtension.java 1 Jan 1970 00:00:00 -0000 >@@ -0,0 +1,64 @@ >+/******************************************************************************* >+ * Copyright (c) 2004, 2008 David Green 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: >+ * David Green - initial API and implementation >+ *******************************************************************************/ >+ >+package org.eclipse.mylyn.tasks.ui.editors; >+ >+import org.eclipse.jface.text.source.SourceViewer; >+import org.eclipse.mylyn.tasks.core.TaskRepository; >+import org.eclipse.swt.widgets.Composite; >+import org.eclipse.ui.contexts.IContextService; >+ >+/** >+ * An extension that provides task editor capabilities beyond the default, oriented towards providing markup-aware >+ * editing and viewing >+ * >+ * @author David Green >+ * @since 3.1 >+ */ >+public abstract class AbstractTaskEditorExtension { >+ >+ /** >+ * The key to access the {@link TaskRepository} property that stores the URL of an associated wiki. >+ */ >+ public static final String INTERNAL_WIKI_LINK_PATTERN = "wikiLinkPattern"; >+ >+ /** >+ * Creates a source viewer that can be used to view content in the task editor. The source viewer should be >+ * configured with a source viewer configuration prior to returning. >+ * >+ * @param taskRepository >+ * the task repository for which the viewer is created >+ * @param parent >+ * the control parent of the source viewer >+ * @param style >+ * the styles to use >+ */ >+ public abstract SourceViewer createViewer(TaskRepository taskRepository, Composite parent, int style); >+ >+ /** >+ * Creates a source viewer that can be used to edit content in the task editor. The source viewer should be >+ * configured with a source viewer configuration prior to returning. >+ * >+ * @param taskRepository >+ * the task repository for which the viewer is created >+ * @param parent >+ * the control parent of the source viewer >+ * @param style >+ * the styles to use >+ */ >+ public abstract SourceViewer createEditor(TaskRepository taskRepository, Composite parent, int style); >+ >+ /** >+ * Returns the editor context id, to be passed to the {@link IContextService} when the editor is in focus. >+ */ >+ public abstract String getEditorContextId(); >+ >+} >Index: src/org/eclipse/mylyn/internal/tasks/ui/commands/ViewSourceHandler.java >=================================================================== >RCS file: src/org/eclipse/mylyn/internal/tasks/ui/commands/ViewSourceHandler.java >diff -N src/org/eclipse/mylyn/internal/tasks/ui/commands/ViewSourceHandler.java >--- /dev/null 1 Jan 1970 00:00:00 -0000 >+++ src/org/eclipse/mylyn/internal/tasks/ui/commands/ViewSourceHandler.java 1 Jan 1970 00:00:00 -0000 >@@ -0,0 +1,103 @@ >+/******************************************************************************* >+ * Copyright (c) 2004, 2008 Jingwen Ou 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: >+ * Jingwen Ou - initial API and implementation >+ * Tasktop Technologies - improvements >+ *******************************************************************************/ >+ >+package org.eclipse.mylyn.internal.tasks.ui.commands; >+ >+import java.util.Map; >+ >+import org.eclipse.core.commands.AbstractHandler; >+import org.eclipse.core.commands.ExecutionEvent; >+import org.eclipse.core.commands.ExecutionException; >+import org.eclipse.core.commands.HandlerEvent; >+import org.eclipse.jface.action.IAction; >+import org.eclipse.mylyn.internal.tasks.ui.editors.EditorUtil; >+import org.eclipse.swt.custom.StyledText; >+import org.eclipse.swt.widgets.Control; >+import org.eclipse.ui.IEditorSite; >+import org.eclipse.ui.IWorkbenchPart; >+import org.eclipse.ui.IWorkbenchSite; >+import org.eclipse.ui.PlatformUI; >+import org.eclipse.ui.commands.IElementUpdater; >+import org.eclipse.ui.forms.editor.FormEditor; >+import org.eclipse.ui.forms.editor.IFormPage; >+import org.eclipse.ui.handlers.HandlerUtil; >+import org.eclipse.ui.menus.UIElement; >+ >+/** >+ * @author Jingwen Ou >+ * @author Steffen Pingel >+ */ >+public class ViewSourceHandler extends AbstractHandler implements IElementUpdater { >+ >+ private static boolean checked; >+ >+ private static ViewSourceHandler instance; >+ >+ public ViewSourceHandler() { >+ instance = this; >+ } >+ >+ public boolean isChecked() { >+ return checked; >+ } >+ >+ public static void setChecked(boolean checked) { >+ ViewSourceHandler.checked = checked; >+ if (instance != null) { >+ instance.fireHandlerChanged(new HandlerEvent(instance, true, false)); >+ } >+ } >+ >+ private Control getFocusControl() { >+ return PlatformUI.getWorkbench().getDisplay().getFocusControl(); >+ } >+ >+ @Override >+ public boolean isEnabled() { >+ Control focusControl = getFocusControl(); >+ if (focusControl instanceof StyledText && focusControl.getData(VIEW_SOURCE_ACTION) instanceof IAction) { >+ return true; >+ } >+ >+ return false; >+ } >+ >+ public static final String VIEW_SOURCE_ACTION = "viewSourceAction"; >+ >+ public Object execute(ExecutionEvent event) throws ExecutionException { >+ IWorkbenchSite site = HandlerUtil.getActiveSite(event); >+ if (site instanceof IEditorSite) { >+ IWorkbenchPart part = ((IEditorSite) site).getPart(); >+ if (part instanceof FormEditor) { >+ IFormPage page = ((FormEditor) part).getActivePageInstance(); >+ Control focusedControl = EditorUtil.getFocusControl(page); >+ if (focusedControl != null) { >+ Object data = focusedControl.getData(VIEW_SOURCE_ACTION); >+ if (data instanceof IAction) { >+ IAction action = (IAction) data; >+ action.setChecked(!action.isChecked()); >+ action.run(); >+ setChecked(action.isChecked()); >+ EditorUtil.reflow(focusedControl); >+ } >+ } >+ } >+ } >+ return null; >+ } >+ >+ @SuppressWarnings("unchecked") >+ public void updateElement(UIElement element, Map parameters) { >+ element.setChecked(checked); >+ } >+ >+} >Index: src/org/eclipse/mylyn/internal/tasks/ui/editors/TaskEditorExtensions.java >=================================================================== >RCS file: src/org/eclipse/mylyn/internal/tasks/ui/editors/TaskEditorExtensions.java >diff -N src/org/eclipse/mylyn/internal/tasks/ui/editors/TaskEditorExtensions.java >--- /dev/null 1 Jan 1970 00:00:00 -0000 >+++ src/org/eclipse/mylyn/internal/tasks/ui/editors/TaskEditorExtensions.java 1 Jan 1970 00:00:00 -0000 >@@ -0,0 +1,167 @@ >+/******************************************************************************* >+ * Copyright (c) 2004, 2008 David Green 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: >+ * David Green - initial API and implementation >+ *******************************************************************************/ >+ >+package org.eclipse.mylyn.internal.tasks.ui.editors; >+ >+import java.util.HashMap; >+import java.util.Map; >+import java.util.SortedSet; >+import java.util.TreeSet; >+ >+import org.eclipse.core.runtime.Assert; >+import org.eclipse.core.runtime.IStatus; >+import org.eclipse.core.runtime.Status; >+import org.eclipse.mylyn.commons.core.StatusHandler; >+import org.eclipse.mylyn.internal.tasks.ui.TasksUiPlugin; >+import org.eclipse.mylyn.tasks.core.TaskRepository; >+import org.eclipse.mylyn.tasks.ui.editors.AbstractTaskEditorExtension; >+ >+/** >+ * @author David Green >+ */ >+public class TaskEditorExtensions { >+ >+ public static final String REPOSITORY_PROPERTY_EDITOR_EXTENSION = "editorExtension"; >+ >+ private static Map<String, RegisteredTaskEditorExtension> extensionsById = new HashMap<String, RegisteredTaskEditorExtension>(); >+ >+ private static Map<String, String> associationByConnectorKind = new HashMap<String, String>(); >+ >+ private static boolean initialized; >+ >+ public static SortedSet<RegisteredTaskEditorExtension> getTaskEditorExtensions() { >+ init(); >+ return new TreeSet<RegisteredTaskEditorExtension>(extensionsById.values()); >+ } >+ >+ public static void addTaskEditorExtension(String id, String name, AbstractTaskEditorExtension extension) { >+ Assert.isNotNull(id); >+ RegisteredTaskEditorExtension previous = extensionsById.put(id, new RegisteredTaskEditorExtension(extension, >+ id, name)); >+ if (previous != null) { >+ StatusHandler.log(new Status(IStatus.ERROR, TasksUiPlugin.ID_PLUGIN, "Duplicate taskEditorExtension id=" >+ + id, null)); >+ } >+ } >+ >+ public static void addRepositoryAssociation(String connectorKind, String extensionId) { >+ if (connectorKind == null || extensionId == null) { >+ throw new IllegalArgumentException(); >+ } >+ String previous = associationByConnectorKind.put(connectorKind, extensionId); >+ if (previous != null) { >+ StatusHandler.log(new Status(IStatus.ERROR, TasksUiPlugin.ID_PLUGIN, String.format( >+ "Duplicate association for repository %s: %s replaces %s", connectorKind, extensionId, previous), >+ null)); >+ } >+ } >+ >+ /** >+ * get a task editor extension for a specific repository >+ * >+ * @param taskRepository >+ * @return the extension, or null if there is none >+ * >+ * @see #getDefaultTaskEditorExtension(TaskRepository) >+ */ >+ public static AbstractTaskEditorExtension getTaskEditorExtension(TaskRepository taskRepository) { >+ init(); >+ String extensionId = getTaskEditorExtensionId(taskRepository); >+ if (extensionId != null) { >+ RegisteredTaskEditorExtension taskEditorExtension = extensionsById.get(extensionId); >+ return taskEditorExtension == null ? null : taskEditorExtension.getExtension(); >+ } >+ return null; >+ } >+ >+ public static String getTaskEditorExtensionId(TaskRepository taskRepository) { >+ init(); >+ String id = taskRepository.getProperty(REPOSITORY_PROPERTY_EDITOR_EXTENSION); >+ if (id == null) { >+ // TODO 3.1 disabled until bug 244653 is resolved >+ //id = getDefaultTaskEditorExtensionId(taskRepository); >+ } >+ return id; >+ } >+ >+ public static void setTaskEditorExtensionId(TaskRepository repository, String editorExtensionId) { >+ repository.setProperty(REPOSITORY_PROPERTY_EDITOR_EXTENSION, editorExtensionId); >+ } >+ >+ public static String getDefaultTaskEditorExtensionId(TaskRepository taskRepository) { >+ init(); >+ return associationByConnectorKind.get(taskRepository.getConnectorKind()); >+ } >+ >+ /** >+ * get a default task editor extension for a specific repository >+ * >+ * @param taskRepository >+ * @return the extension, or null if there is none >+ * >+ * @see #getTaskEditorExtension(TaskRepository) >+ */ >+ public static AbstractTaskEditorExtension getDefaultTaskEditorExtension(TaskRepository taskRepository) { >+ init(); >+ String extensionId = getDefaultTaskEditorExtensionId(taskRepository); >+ if (extensionId != null) { >+ RegisteredTaskEditorExtension taskEditorExtension = extensionsById.get(extensionId); >+ return taskEditorExtension == null ? null : taskEditorExtension.getExtension(); >+ } >+ return null; >+ } >+ >+ private static void init() { >+ if (!initialized) { >+ initialized = true; >+ TaskEditorExtensionReader.initExtensions(); >+ } >+ } >+ >+ public static class RegisteredTaskEditorExtension implements Comparable<RegisteredTaskEditorExtension> { >+ >+ private final String id; >+ >+ private final String name; >+ >+ private final AbstractTaskEditorExtension extension; >+ >+ private RegisteredTaskEditorExtension(AbstractTaskEditorExtension extension, String id, String name) { >+ this.extension = extension; >+ this.id = id; >+ this.name = name; >+ } >+ >+ public String getId() { >+ return id; >+ } >+ >+ public String getName() { >+ return name; >+ } >+ >+ public AbstractTaskEditorExtension getExtension() { >+ return extension; >+ } >+ >+ public int compareTo(RegisteredTaskEditorExtension o) { >+ if (o == this) { >+ return 0; >+ } >+ int i = name.compareTo(o.name); >+ if (i == 0) { >+ i = id.compareTo(o.id); >+ } >+ return i; >+ } >+ } >+ >+}
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Diff
Attachments on
bug 244579
:
110874
|
110875
|
114322
|
114323
| 115335 |
115336