org.eclipse.mylyn.tasks.ui_3.7.1.v20120425-0100

ge org.eclipse.mylyn.internal.tasks.ui.editors;

import org.eclipse.jface.action.IAction;
import org.eclipse.jface.text.source.SourceViewer;
import org.eclipse.mylyn.tasks.core.ITask;
import org.eclipse.mylyn.tasks.core.TaskRepository;
import org.eclipse.mylyn.tasks.core.data.TaskAttribute;
import org.eclipse.mylyn.tasks.core.data.TaskAttributeMapper;
import org.eclipse.mylyn.tasks.core.data.TaskDataModel;
import org.eclipse.mylyn.tasks.ui.editors.AbstractAttributeEditor;
import org.eclipse.mylyn.tasks.ui.editors.AbstractRenderingEngine;
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.custom.StyledText;
import org.eclipse.swt.graphics.Color;
import org.eclipse.swt.widgets.Composite;
import org.eclipse.ui.contexts.IContextService;
import org.eclipse.ui.forms.widgets.FormToolkit;

public class RichTextAttributeEditor
  extends AbstractAttributeEditor
{
  private final RichTextEditor editor;
  protected boolean ignoreNotification;
  protected boolean suppressRefresh;
  
  public RichTextAttributeEditor(TaskDataModel manager, TaskRepository taskRepository, TaskAttribute taskAttribute)
  {
    this(manager, taskRepository, taskAttribute, 2);
  }
  
  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);
    editor = new RichTextEditor(taskRepository, style, contextService, extension, getModel().getTask())
    {
      /* Error */
      public void valueChanged(String value)
      {
        // Byte code:
        //   0: aload_0
        //   1: getfield 41	org/eclipse/mylyn/internal/tasks/ui/editors/RichTextAttributeEditor$1:this$0	Lorg/eclipse/mylyn/internal/tasks/ui/editors/RichTextAttributeEditor;
        //   4: getfield 39	org/eclipse/mylyn/internal/tasks/ui/editors/RichTextAttributeEditor:ignoreNotification	Z
        //   7: ifne +41 -> 48
        //   10: aload_0
        //   11: getfield 41	org/eclipse/mylyn/internal/tasks/ui/editors/RichTextAttributeEditor$1:this$0	Lorg/eclipse/mylyn/internal/tasks/ui/editors/RichTextAttributeEditor;
        //   14: iconst_1
        //   15: putfield 40	org/eclipse/mylyn/internal/tasks/ui/editors/RichTextAttributeEditor:suppressRefresh	Z
        //   18: aload_0
        //   19: getfield 41	org/eclipse/mylyn/internal/tasks/ui/editors/RichTextAttributeEditor$1:this$0	Lorg/eclipse/mylyn/internal/tasks/ui/editors/RichTextAttributeEditor;
        //   22: aload_1
        //   23: invokevirtual 42	org/eclipse/mylyn/internal/tasks/ui/editors/RichTextAttributeEditor:setValue	(Ljava/lang/String;)V
        //   26: goto +14 -> 40
        //   29: astore_2
        //   30: aload_0
        //   31: getfield 41	org/eclipse/mylyn/internal/tasks/ui/editors/RichTextAttributeEditor$1:this$0	Lorg/eclipse/mylyn/internal/tasks/ui/editors/RichTextAttributeEditor;
        //   34: iconst_0
        //   35: putfield 40	org/eclipse/mylyn/internal/tasks/ui/editors/RichTextAttributeEditor:suppressRefresh	Z
        //   38: aload_2
        //   39: athrow
        //   40: aload_0
        //   41: getfield 41	org/eclipse/mylyn/internal/tasks/ui/editors/RichTextAttributeEditor$1:this$0	Lorg/eclipse/mylyn/internal/tasks/ui/editors/RichTextAttributeEditor;
        //   44: iconst_0
        //   45: putfield 40	org/eclipse/mylyn/internal/tasks/ui/editors/RichTextAttributeEditor:suppressRefresh	Z
        //   48: return
        // Line number table:
        //   Java source line #61	-> byte code offset #0
        //   Java source line #63	-> byte code offset #10
        //   Java source line #64	-> byte code offset #18
        //   Java source line #65	-> byte code offset #29
        //   Java source line #66	-> byte code offset #30
        //   Java source line #67	-> byte code offset #38
        //   Java source line #66	-> byte code offset #40
        //   Java source line #69	-> byte code offset #48
        // Local variable table:
        //   start	length	slot	name	signature
        //   0	49	0	this	1
        //   0	49	1	value	String
        //   29	10	2	localObject	Object
        // Exception table:
        //   from	to	target	type
        //   10	29	29	finally
      }
    };
    editor.setReadOnly(isReadOnly());
    if ((style & 0x2) != 0) {
      setLayoutHint(new LayoutHint(LayoutHint.RowSpan.MULTIPLE, LayoutHint.ColumnSpan.MULTIPLE));
    } else {
      setLayoutHint(new LayoutHint(LayoutHint.RowSpan.SINGLE, LayoutHint.ColumnSpan.MULTIPLE));
    }
    setMode(RepositoryTextViewerConfiguration.Mode.DEFAULT);
    refresh();
  }
  
  public void createControl(Composite parent, FormToolkit toolkit)
  {
    refresh();
    
    editor.createControl(parent, toolkit);
    editor.getViewer().getTextWidget().setToolTipText(getDescription());
    
    setControl(editor.getControl());
  }
  
  public RichTextEditor getEditor()
  {
    return editor;
  }
  
  public SourceViewer getEditorViewer()
  {
    return editor.getEditorViewer();
  }
  
  public RepositoryTextViewerConfiguration.Mode getMode()
  {
    return editor.getMode();
  }
  
  public AbstractRenderingEngine getRenderingEngine()
  {
    return editor.getRenderingEngine();
  }
  
  public String getValue()
  {
    return getAttributeMapper().getValue(getTaskAttribute());
  }
  
  public SourceViewer getViewer()
  {
    return editor.getViewer();
  }
  
  public IAction getViewSourceAction()
  {
    return editor.getViewSourceAction();
  }
  
  public boolean hasBrowser()
  {
    return editor.hasBrowser();
  }
  
  public boolean hasPreview()
  {
    return editor.hasPreview();
  }
  
  public boolean isSpellCheckingEnabled()
  {
    return editor.isSpellCheckingEnabled();
  }
  
  public void setMode(RepositoryTextViewerConfiguration.Mode mode)
  {
    editor.setMode(mode);
  }
  
  public void setRenderingEngine(AbstractRenderingEngine renderingEngine)
  {
    editor.setRenderingEngine(renderingEngine);
  }
  
  public void setSpellCheckingEnabled(boolean spellCheckingEnabled)
  {
    editor.setSpellCheckingEnabled(spellCheckingEnabled);
  }
  
  public void setValue(String value)
  {
    getAttributeMapper().setValue(getTaskAttribute(), value);
    attributeChanged();
  }
  
  public void showBrowser()
  {
    editor.showBrowser();
  }
  
  public void showDefault()
  {
    editor.showDefault();
  }
  
  public void showEditor()
  {
    editor.showEditor();
  }
  
  public void showPreview()
  {
    editor.showPreview();
  }
  
  public void setReadOnly(boolean readOnly)
  {
    super.setReadOnly(readOnly);
    if (editor != null) {
      editor.setReadOnly(readOnly);
    }
  }
  
  /* Error */
  public void refresh()
  {
    // Byte code:
    //   0: aload_0
    //   1: getfield 190	org/eclipse/mylyn/internal/tasks/ui/editors/RichTextAttributeEditor:editor	Lorg/eclipse/mylyn/internal/tasks/ui/editors/RichTextEditor;
    //   4: invokevirtual 228	org/eclipse/mylyn/internal/tasks/ui/editors/RichTextEditor:getControl	()Lorg/eclipse/swt/widgets/Control;
    //   7: ifnull +16 -> 23
    //   10: aload_0
    //   11: getfield 190	org/eclipse/mylyn/internal/tasks/ui/editors/RichTextAttributeEditor:editor	Lorg/eclipse/mylyn/internal/tasks/ui/editors/RichTextEditor;
    //   14: invokevirtual 228	org/eclipse/mylyn/internal/tasks/ui/editors/RichTextEditor:getControl	()Lorg/eclipse/swt/widgets/Control;
    //   17: invokevirtual 238	org/eclipse/swt/widgets/Control:isDisposed	()Z
    //   20: ifne +35 -> 55
    //   23: aload_0
    //   24: iconst_1
    //   25: putfield 188	org/eclipse/mylyn/internal/tasks/ui/editors/RichTextAttributeEditor:ignoreNotification	Z
    //   28: aload_0
    //   29: getfield 190	org/eclipse/mylyn/internal/tasks/ui/editors/RichTextAttributeEditor:editor	Lorg/eclipse/mylyn/internal/tasks/ui/editors/RichTextEditor;
    //   32: aload_0
    //   33: invokevirtual 199	org/eclipse/mylyn/internal/tasks/ui/editors/RichTextAttributeEditor:getValue	()Ljava/lang/String;
    //   36: invokevirtual 219	org/eclipse/mylyn/internal/tasks/ui/editors/RichTextEditor:setText	(Ljava/lang/String;)V
    //   39: goto +11 -> 50
    //   42: astore_1
    //   43: aload_0
    //   44: iconst_0
    //   45: putfield 188	org/eclipse/mylyn/internal/tasks/ui/editors/RichTextAttributeEditor:ignoreNotification	Z
    //   48: aload_1
    //   49: athrow
    //   50: aload_0
    //   51: iconst_0
    //   52: putfield 188	org/eclipse/mylyn/internal/tasks/ui/editors/RichTextAttributeEditor:ignoreNotification	Z
    //   55: return
    // Line number table:
    //   Java source line #177	-> byte code offset #0
    //   Java source line #179	-> byte code offset #23
    //   Java source line #180	-> byte code offset #28
    //   Java source line #181	-> byte code offset #42
    //   Java source line #182	-> byte code offset #43
    //   Java source line #183	-> byte code offset #48
    //   Java source line #182	-> byte code offset #50
    //   Java source line #185	-> byte code offset #55
    // Local variable table:
    //   start	length	slot	name	signature
    //   0	56	0	this	RichTextAttributeEditor
    //   42	7	1	localObject	Object
    // Exception table:
    //   from	to	target	type
    //   23	42	42	finally
  }
  
  public boolean shouldAutoRefresh()
  {
    return !suppressRefresh;
  }
  
  protected void decorateIncoming(Color color)
  {
    super.decorateIncoming(color);
    if (editor != null) {
      editor.setBackground(color);
    }
  }
  
  public void enableAutoTogglePreview()
  {
    editor.enableAutoTogglePreview();
  }
}

/* Location:
 * Qualified Name:     org.eclipse.mylyn.internal.tasks.ui.editors.RichTextAttributeEditor
 * Java Class Version: 5 (49.0)
 * JD-Core Version:    0.7.1
 */
package org.eclipse.mylyn.internal.tasks.ui.editors;

import org.eclipse.swt.widgets.Composite;
import org.eclipse.ui.forms.events.ExpansionAdapter;
import org.eclipse.ui.forms.events.ExpansionEvent;
import org.eclipse.ui.forms.widgets.FormToolkit;

class TaskEditorCommentPart$CommentViewer$1
  extends ExpansionAdapter
{
  TaskEditorCommentPart$CommentViewer$1(TaskEditorCommentPart.CommentViewer paramCommentViewer, FormToolkit paramFormToolkit, Composite paramComposite) {}
  
  public void expansionStateChanged(ExpansionEvent event)
  {
    TaskEditorCommentPart.CommentViewer.access$0(this$1, val$toolkit, val$commentTextComposite, event.getState());
  }
}

/* Location:
 * Qualified Name:     org.eclipse.mylyn.internal.tasks.ui.editors.TaskEditorCommentPart.CommentViewer.1
 * Java Class Version: 5 (49.0)
 * JD-Core Version:    0.7.1
 */
package org.eclipse.mylyn.internal.tasks.ui.editors;

import org.eclipse.jface.action.Action;

class TaskEditorRichTextPart$3
  extends Action
{
  TaskEditorRichTextPart$3(TaskEditorRichTextPart paramTaskEditorRichTextPart, String $anonymous0, int $anonymous1)
  {
    super($anonymous0, $anonymous1);
  }
  
  public void run()
  {
    if (TaskEditorRichTextPart.access$4(this$0)) {
      return;
    }
    if (isChecked()) {
      TaskEditorRichTextPart.access$0(this$0).showBrowser();
    } else {
      TaskEditorRichTextPart.access$0(this$0).showEditor();
    }
    if (TaskEditorRichTextPart.access$3(this$0) != null) {
      TaskEditorRichTextPart.access$3(this$0).setChecked(false);
    }
  }
}

/* Location:
 * Qualified Name:     org.eclipse.mylyn.internal.tasks.ui.editors.TaskEditorRichTextPart.3
 * Java Class Version: 5 (49.0)
 * JD-Core Version:    0.7.1
 */
package org.eclipse.mylyn.internal.tasks.ui.editors;

import org.eclipse.swt.events.SelectionEvent;
import org.eclipse.swt.events.SelectionListener;

class PlanningPart$11
  implements SelectionListener
{
  PlanningPart$11(PlanningPart paramPlanningPart) {}
  
  public void widgetDefaultSelected(SelectionEvent arg0) {}
  
  public void widgetSelected(SelectionEvent arg0)
  {
    this$0.markDirty();
  }
}

/* Location:
 * Qualified Name:     org.eclipse.mylyn.internal.tasks.ui.editors.PlanningPart.11
 * Java Class Version: 5 (49.0)
 * JD-Core Version:    0.7.1
 */
package org.eclipse.mylyn.internal.tasks.ui.editors;

import org.eclipse.mylyn.internal.tasks.ui.wizards.TaskAttachmentWizard.Mode;
import org.eclipse.swt.events.SelectionAdapter;
import org.eclipse.swt.events.SelectionEvent;

class TaskEditorAttachmentPart$3
  extends SelectionAdapter
{
  TaskEditorAttachmentPart$3(TaskEditorAttachmentPart paramTaskEditorAttachmentPart) {}
  
  public void widgetSelected(SelectionEvent e)
  {
    EditorUtil.openNewAttachmentWizard(this$0.getTaskEditorPage(), TaskAttachmentWizard.Mode.DEFAULT, null);
  }
}

/* Location:
 * Qualified Name:     org.eclipse.mylyn.internal.tasks.ui.editors.TaskEditorAttachmentPart.3
 * Java Class Version: 5 (49.0)
 * JD-Core Version:    0.7.1
 */
package org.eclipse.mylyn.internal.tasks.ui.editors;

import org.eclipse.mylyn.internal.tasks.ui.commands.ViewSourceHandler;
import org.eclipse.swt.events.FocusAdapter;
import org.eclipse.swt.events.FocusEvent;

class RichTextEditor$1
  extends FocusAdapter
{
  RichTextEditor$1(RichTextEditor paramRichTextEditor) {}
  
  public void focusGained(FocusEvent e)
  {
    ViewSourceHandler.setChecked(this$0.getViewer() == RichTextEditor.access$1(this$0));
  }
}

/* Location:
 * Qualified Name:     org.eclipse.mylyn.internal.tasks.ui.editors.RichTextEditor.1
 * Java Class Version: 5 (49.0)
 * JD-Core Version:    0.7.1
 */
package org.eclipse.mylyn.internal.tasks.ui.editors;

import org.eclipse.jface.viewers.ISelection;
import org.eclipse.mylyn.commons.workbench.WorkbenchActionSupport.WorkbenchActionCallback;
import org.eclipse.mylyn.tasks.ui.editors.AbstractTaskEditorPage;
import org.eclipse.swt.widgets.Control;
import org.eclipse.ui.forms.editor.IFormPage;

class TaskEditorActionContributor$EditorPageCallback
  extends WorkbenchActionSupport.WorkbenchActionCallback
{
  private TaskEditorActionContributor$EditorPageCallback(TaskEditorActionContributor paramTaskEditorActionContributor) {}
  
  public boolean canPerformAction(String actionId, Control control)
  {
    IFormPage activePage = TaskEditorActionContributor.access$1(this$0);
    if ((activePage instanceof AbstractTaskEditorPage))
    {
      AbstractTaskEditorPage page = (AbstractTaskEditorPage)activePage;
      return page.canPerformAction(actionId);
    }
    if (activePage != null)
    {
      WorkbenchActionSupport.WorkbenchActionCallback callback = (WorkbenchActionSupport.WorkbenchActionCallback)activePage.getAdapter(WorkbenchActionSupport.WorkbenchActionCallback.class);
      if (callback != null) {
        return callback.canPerformAction(actionId, control);
      }
    }
    return super.canPerformAction(actionId, control);
  }
  
  public void doAction(String actionId, Control control)
  {
    IFormPage activePage = TaskEditorActionContributor.access$1(this$0);
    if ((activePage instanceof AbstractTaskEditorPage))
    {
      AbstractTaskEditorPage page = (AbstractTaskEditorPage)activePage;
      page.doAction(actionId);
      return;
    }
    if (activePage != null)
    {
      WorkbenchActionSupport.WorkbenchActionCallback callback = (WorkbenchActionSupport.WorkbenchActionCallback)activePage.getAdapter(WorkbenchActionSupport.WorkbenchActionCallback.class);
      if (callback != null)
      {
        callback.doAction(actionId, control);
        return;
      }
    }
    super.doAction(actionId, control);
  }
  
  public Control getFocusControl()
  {
    IFormPage page = TaskEditorActionContributor.access$1(this$0);
    return page != null ? EditorUtil.getFocusControl(page) : null;
  }
  
  public ISelection getSelection()
  {
    return TaskEditorActionContributor.access$2(this$0).getSelection();
  }
}

/* Location:
 * Qualified Name:     org.eclipse.mylyn.internal.tasks.ui.editors.TaskEditorActionContributor.EditorPageCallback
 * Java Class Version: 5 (49.0)
 * JD-Core Version:    0.7.1
 */
package org.eclipse.mylyn.internal.tasks.ui.editors;

import java.util.Iterator;
import java.util.List;
import org.eclipse.core.runtime.Assert;
import org.eclipse.core.runtime.IAdaptable;
import org.eclipse.core.runtime.ListenerList;
import org.eclipse.jface.action.Action;
import org.eclipse.jface.action.IAction;
import org.eclipse.jface.resource.FontRegistry;
import org.eclipse.jface.resource.JFaceResources;
import org.eclipse.jface.text.Document;
import org.eclipse.jface.text.IDocument;
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.ISourceViewer;
import org.eclipse.jface.text.source.SourceViewer;
import org.eclipse.mylyn.commons.workbench.editors.CommonTextSupport;
import org.eclipse.mylyn.commons.workbench.forms.CommonFormUtil;
import org.eclipse.mylyn.internal.tasks.ui.commands.ViewSourceHandler;
import org.eclipse.mylyn.tasks.core.ITask;
import org.eclipse.mylyn.tasks.core.TaskRepository;
import org.eclipse.mylyn.tasks.ui.editors.AbstractRenderingEngine;
import org.eclipse.mylyn.tasks.ui.editors.AbstractTaskEditorExtension;
import org.eclipse.swt.custom.StackLayout;
import org.eclipse.swt.custom.StyledText;
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.events.MouseAdapter;
import org.eclipse.swt.events.MouseEvent;
import org.eclipse.swt.graphics.Color;
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.Display;
import org.eclipse.swt.widgets.Event;
import org.eclipse.swt.widgets.Listener;
import org.eclipse.swt.widgets.Menu;
import org.eclipse.ui.IWorkbench;
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.ITheme;
import org.eclipse.ui.themes.IThemeManager;

public class RichTextEditor
{
  private static final String KEY_TEXT_VERSION = "org.eclipse.mylyn.tasks.ui.textVersion";
  private BrowserPreviewViewer browserViewer;
  private IContextActivation contextActivation;
  private final IContextService contextService;
  private Control control;
  private SourceViewer defaultViewer;
  private Composite editorComposite;
  private StackLayout editorLayout;
  private SourceViewer editorViewer;
  private final AbstractTaskEditorExtension extension;
  private RepositoryTextViewerConfiguration.Mode mode;
  private SourceViewer previewViewer;
  boolean readOnly;
  private AbstractRenderingEngine renderingEngine;
  private final TaskRepository repository;
  private boolean spellCheckingEnabled;
  private final int style;
  private FormToolkit toolkit;
  private final IAction viewSourceAction;
  private String text;
  private int textVersion;
  
  public static enum State
  {
    DEFAULT,  BROWSER,  EDITOR,  PREVIEW;
  }
  
  public static class StateChangedEvent
  {
    public RichTextEditor.State state;
  }
  
  public static abstract interface StateChangedListener
  {
    public abstract void stateChanged(RichTextEditor.StateChangedEvent paramStateChangedEvent);
  }
  
  public class ViewSourceAction
    extends Action
  {
    public ViewSourceAction()
    {
      super(2);
      setChecked(false);
      setEnabled(false);
    }
    
    public void run()
    {
      if (isChecked()) {
        showDefault();
      } else {
        showEditor();
      }
      if (editorLayout != null) {
        EditorUtil.reflow(editorLayout.topControl);
      }
      ViewSourceHandler.setChecked(isChecked());
    }
  }
  
  private final ListenerList stateChangedListeners = new ListenerList(1);
  private final ITask task;
  
  @Deprecated
  public RichTextEditor(TaskRepository repository, int style)
  {
    this(repository, style, null, null, null);
  }
  
  @Deprecated
  public RichTextEditor(TaskRepository repository, int style, IContextService contextService, AbstractTaskEditorExtension extension)
  {
    this(repository, style, contextService, extension, null);
  }
  
  public RichTextEditor(TaskRepository repository, int style, IContextService contextService, AbstractTaskEditorExtension extension, ITask task)
  {
    this.repository = repository;
    this.style = style;
    this.contextService = contextService;
    this.extension = extension;
    text = "";
    viewSourceAction = new ViewSourceAction();
    setMode(RepositoryTextViewerConfiguration.Mode.DEFAULT);
    this.task = task;
  }
  
  private SourceViewer configure(SourceViewer viewer, Document document, boolean readOnly)
  {
    installHyperlinkPresenter(viewer, repository, task, getMode());
    
    updateDocument(viewer, document, readOnly);
    if (readOnly)
    {
      if (extension != null)
      {
        viewer.getControl().setData("viewSourceAction", viewSourceAction);
        viewer.getControl().addFocusListener(new FocusAdapter()
        {
          public void focusGained(FocusEvent e)
          {
            ViewSourceHandler.setChecked(getViewer() == defaultViewer);
          }
        });
      }
    }
    else
    {
      installListeners(viewer);
      viewer.getControl().setData("FormWidgetFactory.drawBorder", "treeBorder");
    }
    CommonTextSupport.setTextViewer(viewer.getTextWidget(), viewer);
    viewer.setEditable(!readOnly);
    viewer.getTextWidget().setFont(getFont());
    if (toolkit != null) {
      toolkit.adapt(viewer.getControl(), false, false);
    }
    EditorUtil.addScrollListener(viewer.getTextWidget());
    return viewer;
  }
  
  private void updateDocument(SourceViewer viewer, Document document, boolean readOnly)
  {
    if (new Integer(textVersion).equals(viewer.getData("org.eclipse.mylyn.tasks.ui.textVersion"))) {
      return;
    }
    if (readOnly)
    {
      viewer.setDocument(document);
    }
    else
    {
      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.setDocument(document, annotationModel);
    }
    viewer.setData("org.eclipse.mylyn.tasks.ui.textVersion", Integer.valueOf(textVersion));
  }
  
  public void createControl(Composite parent, FormToolkit toolkit)
  {
    this.toolkit = toolkit;
    
    int style = this.style;
    if ((!isReadOnly()) && ((style & 0x10) == 0)) {
      style |= 0x200;
    }
    if ((extension != null) || (renderingEngine != null))
    {
      editorComposite = new Composite(parent, 0);
      editorLayout = new StackLayout()
      {
        protected Point computeSize(Composite composite, int hint, int hint2, boolean flushCache)
        {
          return topControl.computeSize(hint, hint2, flushCache);
        }
      };
      editorComposite.setLayout(editorLayout);
      setControl(editorComposite);
      if (extension != null)
      {
        if (isReadOnly())
        {
          editorViewer = extension.createViewer(repository, editorComposite, style, 
            createHyperlinkDetectorContext());
        }
        else
        {
          editorViewer = extension.createEditor(repository, editorComposite, style, 
            createHyperlinkDetectorContext());
          editorViewer.getTextWidget().addFocusListener(new FocusListener()
          {
            public void focusGained(FocusEvent e)
            {
              RichTextEditor.this.setContext();
            }
            
            public void focusLost(FocusEvent e)
            {
              RichTextEditor.this.unsetContext();
            }
          });
          editorViewer.getTextWidget().addDisposeListener(new DisposeListener()
          {
            public void widgetDisposed(DisposeEvent e)
            {
              RichTextEditor.this.unsetContext();
            }
          });
        }
        configure(editorViewer, new Document(getText()), isReadOnly());
        show(editorViewer.getControl());
      }
      else
      {
        defaultViewer = createDefaultEditor(editorComposite, style);
        configure(defaultViewer, new Document(getText()), isReadOnly());
        show(defaultViewer.getControl());
      }
      if ((!isReadOnly()) && ((style & 0x10) == 0)) {
        editorComposite.setData("FormWidgetFactory.drawBorder", "treeBorder");
      }
      viewSourceAction.setEnabled(true);
    }
    else
    {
      defaultViewer = createDefaultEditor(parent, style);
      configure(defaultViewer, new Document(getText()), isReadOnly());
      setControl(defaultViewer.getControl());
      
      viewSourceAction.setEnabled(false);
    }
  }
  
  private IAdaptable createHyperlinkDetectorContext()
  {
    new IAdaptable()
    {
      public Object getAdapter(Class adapter)
      {
        if (adapter == TaskRepository.class) {
          return repository;
        }
        if (adapter == ITask.class) {
          return task;
        }
        return null;
      }
    };
  }
  
  private SourceViewer createDefaultEditor(Composite parent, int styles)
  {
    SourceViewer defaultEditor = new SourceViewer(parent, null, styles | 0x40);
    
    RepositoryTextViewerConfiguration viewerConfig = new RepositoryTextViewerConfiguration(repository, task, 
      (isSpellCheckingEnabled()) && (!isReadOnly()));
    viewerConfig.setMode(getMode());
    defaultEditor.configure(viewerConfig);
    
    return defaultEditor;
  }
  
  private BrowserPreviewViewer getBrowserViewer()
  {
    if ((editorComposite == null) || (renderingEngine == null)) {
      return null;
    }
    if (browserViewer == null)
    {
      browserViewer = new BrowserPreviewViewer(getRepository(), renderingEngine);
      browserViewer.createControl(editorComposite, toolkit);
    }
    return browserViewer;
  }
  
  public Control getControl()
  {
    return control;
  }
  
  public SourceViewer getDefaultViewer()
  {
    if (defaultViewer == null)
    {
      defaultViewer = createDefaultEditor(editorComposite, style);
      configure(defaultViewer, new Document(getText()), isReadOnly());
      
      defaultViewer.getTextWidget().setFont(JFaceResources.getFontRegistry().get("org.eclipse.jface.textfont"));
      
      defaultViewer.getControl().setData("maximizeAction", 
        editorViewer.getControl().getData("maximizeAction"));
      
      installMenu(defaultViewer.getControl(), editorViewer.getControl().getMenu());
    }
    return defaultViewer;
  }
  
  public SourceViewer getEditorViewer()
  {
    return editorViewer;
  }
  
  private Font getFont()
  {
    if (mode == RepositoryTextViewerConfiguration.Mode.DEFAULT)
    {
      IThemeManager themeManager = PlatformUI.getWorkbench().getThemeManager();
      Font font = themeManager.getCurrentTheme().getFontRegistry().get("org.eclipse.mylyn.tasks.ui.fonts.task.editor.comment");
      return font;
    }
    return EditorUtil.TEXT_FONT;
  }
  
  public RepositoryTextViewerConfiguration.Mode getMode()
  {
    return mode;
  }
  
  private SourceViewer getPreviewViewer()
  {
    if (extension == null) {
      return null;
    }
    if (previewViewer == null)
    {
      int previewViewerStyle = style;
      if (getEditorViewer() != null) {
        previewViewerStyle |= 0x200;
      }
      previewViewer = extension.createViewer(repository, editorComposite, previewViewerStyle, 
        createHyperlinkDetectorContext());
      configure(previewViewer, new Document(getText()), true);
      
      previewViewer.getControl().setData("maximizeAction", 
        editorViewer.getControl().getData("maximizeAction"));
      installMenu(previewViewer.getControl(), editorViewer.getControl().getMenu());
      
      previewViewer.getTextWidget().setBackground(editorComposite.getBackground());
    }
    return previewViewer;
  }
  
  public AbstractRenderingEngine getRenderingEngine()
  {
    return renderingEngine;
  }
  
  public TaskRepository getRepository()
  {
    return repository;
  }
  
  public String getText()
  {
    return text;
  }
  
  public SourceViewer getViewer()
  {
    if (editorLayout == null) {
      return defaultViewer;
    }
    if ((defaultViewer != null) && (editorLayout.topControl == defaultViewer.getControl())) {
      return defaultViewer;
    }
    if ((previewViewer != null) && (editorLayout.topControl == previewViewer.getControl())) {
      return previewViewer;
    }
    return editorViewer;
  }
  
  public IAction getViewSourceAction()
  {
    return viewSourceAction;
  }
  
  public boolean hasBrowser()
  {
    return renderingEngine != null;
  }
  
  public boolean hasPreview()
  {
    return (extension != null) && (!isReadOnly());
  }
  
  public static RepositoryTextViewerConfiguration installHyperlinkPresenter(ISourceViewer viewer, TaskRepository repository, ITask task, RepositoryTextViewerConfiguration.Mode mode)
  {
    RepositoryTextViewerConfiguration configuration = new RepositoryTextViewerConfiguration(repository, task, false);
    configuration.setMode(mode);
    if (mode == RepositoryTextViewerConfiguration.Mode.DEFAULT)
    {
      AbstractHyperlinkTextPresentationManager manager = new HighlightingHyperlinkTextPresentationManager();
      manager.setHyperlinkDetectors(configuration.getDefaultHyperlinkDetectors(viewer, null));
      manager.install(viewer);
      
      manager = new TaskHyperlinkTextPresentationManager();
      manager.setHyperlinkDetectors(configuration.getDefaultHyperlinkDetectors(viewer, RepositoryTextViewerConfiguration.Mode.TASK));
      manager.install(viewer);
    }
    else if (mode == RepositoryTextViewerConfiguration.Mode.TASK_RELATION)
    {
      AbstractHyperlinkTextPresentationManager manager = new TaskHyperlinkTextPresentationManager();
      manager.setHyperlinkDetectors(configuration.getDefaultHyperlinkDetectors(viewer, RepositoryTextViewerConfiguration.Mode.TASK_RELATION));
      manager.install(viewer);
    }
    return configuration;
  }
  
  private void installListeners(final SourceViewer viewer)
  {
    viewer.addTextListener(new ITextListener()
    {
      public void textChanged(TextEvent event)
      {
        String value = viewer.getTextWidget().getText();
        if (!text.equals(value))
        {
          text = value;
          textVersion += 1;
          viewer.setData("org.eclipse.mylyn.tasks.ui.textVersion", Integer.valueOf(textVersion));
          valueChanged(value);
          CommonFormUtil.ensureVisible(viewer.getTextWidget());
        }
      }
    });
    if (((style & 0x2) != 0) && (mode != RepositoryTextViewerConfiguration.Mode.DEFAULT)) {
      viewer.getTextWidget().addListener(31, new Listener()
      {
        public void handleEvent(Event event)
        {
          switch (detail)
          {
          case 8: 
          case 16: 
            doit = true;
          }
        }
      });
    }
  }
  
  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 boolean isReadOnly()
  {
    return readOnly;
  }
  
  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());
    }
  }
  
  private void setControl(Control control)
  {
    this.control = control;
  }
  
  public void setMode(RepositoryTextViewerConfiguration.Mode mode)
  {
    Assert.isNotNull(mode);
    this.mode = mode;
  }
  
  public void setReadOnly(boolean readOnly)
  {
    this.readOnly = readOnly;
  }
  
  public void setRenderingEngine(AbstractRenderingEngine renderingEngine)
  {
    this.renderingEngine = renderingEngine;
  }
  
  public void setSpellCheckingEnabled(boolean spellCheckingEnabled)
  {
    this.spellCheckingEnabled = spellCheckingEnabled;
  }
  
  public void setText(String value)
  {
    text = value;
    textVersion += 1;
    SourceViewer viewer = getViewer();
    if (viewer != null) {
      viewer.getDocument().set(value);
    }
  }
  
  private void show(Control control)
  {
    if (editorComposite == null) {
      return;
    }
    editorLayout.topControl = control;
    if ((editorComposite.getParent().getLayout() instanceof FillWidthLayout)) {
      ((FillWidthLayout)editorComposite.getParent().getLayout()).flush();
    }
    editorComposite.layout();
    control.setFocus();
    fireStateChangedEvent();
  }
  
  protected void fireStateChangedEvent()
  {
    if (stateChangedListeners.isEmpty()) {
      return;
    }
    StateChangedEvent event = new StateChangedEvent();
    if ((defaultViewer != null) && (defaultViewer.getControl() == editorLayout.topControl)) {
      state = State.DEFAULT;
    } else if ((editorViewer != null) && (editorViewer.getControl() == editorLayout.topControl)) {
      state = State.EDITOR;
    } else if ((previewViewer != null) && (previewViewer.getControl() == editorLayout.topControl)) {
      state = State.PREVIEW;
    } else if ((browserViewer != null) && (browserViewer.getControl() == editorLayout.topControl)) {
      state = State.BROWSER;
    }
    Object[] listeners = stateChangedListeners.getListeners();
    Object[] arrayOfObject1;
    int j = (arrayOfObject1 = listeners).length;
    for (int i = 0; i < j; i++)
    {
      Object listener = arrayOfObject1[i];
      ((StateChangedListener)listener).stateChanged(event);
    }
  }
  
  private void show(SourceViewer viewer)
  {
    updateDocument(viewer, new Document(getText()), !viewer.isEditable());
    show(viewer.getControl());
  }
  
  public void showBrowser()
  {
    BrowserPreviewViewer viewer = getBrowserViewer();
    viewer.update(getText());
    if (viewer != null) {
      show(viewer.getControl());
    }
  }
  
  public void showDefault()
  {
    show(getDefaultViewer());
  }
  
  public void showEditor()
  {
    if (getEditorViewer() != null) {
      show(getEditorViewer());
    } else {
      show(getDefaultViewer());
    }
  }
  
  private void showPreview(boolean sticky)
  {
    if ((!isReadOnly()) && (getPreviewViewer() != null)) {
      show(getPreviewViewer());
    }
  }
  
  public void showPreview()
  {
    showPreview(true);
  }
  
  private void unsetContext()
  {
    if (contextService == null) {
      return;
    }
    if (contextActivation != null)
    {
      contextService.deactivateContext(contextActivation);
      contextActivation = null;
    }
  }
  
  protected void valueChanged(String value) {}
  
  public void enableAutoTogglePreview()
  {
    if ((!isReadOnly()) && (getPreviewViewer() != null))
    {
      MouseAdapter listener = new MouseAdapter()
      {
        private boolean toggled;
        
        public void mouseUp(MouseEvent e)
        {
          if ((!toggled) && (count == 1)) {
            Display.getDefault().timerExec(Display.getDefault().getDoubleClickTime(), new Runnable()
            {
              public void run()
              {
                if ((previewViewer.getTextWidget() == null) || (previewViewer.getTextWidget().isDisposed())) {
                  return;
                }
                if (previewViewer.getTextWidget().getSelectionCount() == 0)
                {
                  int offset = previewViewer.getTextWidget().getCaretOffset();
                  showEditor();
                  editorViewer.getTextWidget().setCaretOffset(offset);
                  
                  toggled = true;
                }
              }
            });
          }
        }
      };
      previewViewer.getTextWidget().addMouseListener(listener);
    }
  }
  
  public void setBackground(Color color)
  {
    if ((editorComposite != null) && (!editorComposite.isDisposed()))
    {
      editorComposite.setBackground(color);
      Control[] arrayOfControl;
      int j = (arrayOfControl = editorComposite.getChildren()).length;
      for (int i = 0; i < j; i++)
      {
        Control child = arrayOfControl[i];
        child.setBackground(color);
      }
    }
  }
  
  public void addStateChangedListener(StateChangedListener listener)
  {
    stateChangedListeners.add(listener);
  }
  
  public void removeStateChangedListener(StateChangedListener listener)
  {
    stateChangedListeners.remove(listener);
  }
}

/* Location:
 * Qualified Name:     org.eclipse.mylyn.internal.tasks.ui.editors.RichTextEditor
 * Java Class Version: 5 (49.0)
 * JD-Core Version:    0.7.1
 */
package org.eclipse.mylyn.internal.tasks.ui.editors;

import org.eclipse.core.runtime.ISafeRunnable;
import org.eclipse.core.runtime.Status;
import org.eclipse.mylyn.commons.core.StatusHandler;
import org.eclipse.mylyn.tasks.core.AbstractRepositoryConnector;
import org.eclipse.mylyn.tasks.core.TaskMigrationEvent;

class TaskMigrator$1
  implements ISafeRunnable
{
  TaskMigrator$1(TaskMigrator paramTaskMigrator, AbstractRepositoryConnector paramAbstractRepositoryConnector, TaskMigrationEvent paramTaskMigrationEvent) {}
  
  public void handleException(Throwable e)
  {
    StatusHandler.log(new Status(4, "org.eclipse.mylyn.tasks.ui", 
      "Unexpected error in task migrator: " + 
      val$connector.getClass(), e));
  }
  
  public void run()
    throws Exception
  {
    val$connector.migrateTask(val$event);
  }
}

/* Location:
 * Qualified Name:     org.eclipse.mylyn.internal.tasks.ui.editors.TaskMigrator.1
 * Java Class Version: 5 (49.0)
 * JD-Core Version:    0.7.1
 */
package org.eclipse.mylyn.internal.tasks.ui.editors;

import org.apache.commons.lang.StringUtils;
import org.eclipse.jface.dialogs.IInputValidator;
import org.eclipse.mylyn.tasks.core.data.TaskAttribute;
import org.eclipse.mylyn.tasks.core.data.TaskDataModel;
import org.eclipse.mylyn.tasks.ui.editors.AttributeEditorToolkit;
import org.eclipse.swt.widgets.Composite;
import org.eclipse.swt.widgets.Text;
import org.eclipse.ui.forms.widgets.FormToolkit;

public class IntegerAttributeEditor
  extends TextAttributeEditor
{
  public IntegerAttributeEditor(TaskDataModel manager, TaskAttribute taskAttribute)
  {
    super(manager, taskAttribute);
  }
  
  public void createControl(Composite pa
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79

Further reading...

For more information on Java 1.5 Tiger, you may find Java 1.5 Tiger, A developer's Notebook by D. Flanagan and B. McLaughlin from O'Reilly of interest.

New!JAR listings


Copyright 2006-2019. Infinite Loop Ltd