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

    {
      super.createPartControl(parent);
    }
  }
  
  /* Error */
  protected void createFormContent(IManagedForm managedForm)
  {
    // Byte code:
    //   0: aload_0
    //   1: aload_1
    //   2: invokespecial 1673	org/eclipse/mylyn/tasks/ui/editors/TaskFormPage:createFormContent	(Lorg/eclipse/ui/forms/IManagedForm;)V
    //   5: aload_0
    //   6: aload_1
    //   7: invokeinterface 1758 1 0
    //   12: putfield 1414	org/eclipse/mylyn/tasks/ui/editors/AbstractTaskEditorPage:form	Lorg/eclipse/ui/forms/widgets/ScrolledForm;
    //   15: aload_0
    //   16: aload_1
    //   17: invokeinterface 1757 1 0
    //   22: putfield 1413	org/eclipse/mylyn/tasks/ui/editors/AbstractTaskEditorPage:toolkit	Lorg/eclipse/ui/forms/widgets/FormToolkit;
    //   25: aload_0
    //   26: aload_0
    //   27: getfield 1414	org/eclipse/mylyn/tasks/ui/editors/AbstractTaskEditorPage:form	Lorg/eclipse/ui/forms/widgets/ScrolledForm;
    //   30: invokevirtual 1594	org/eclipse/mylyn/tasks/ui/editors/AbstractTaskEditorPage:registerDefaultDropListener	(Lorg/eclipse/swt/widgets/Control;)V
    //   33: aload_0
    //   34: getfield 1414	org/eclipse/mylyn/tasks/ui/editors/AbstractTaskEditorPage:form	Lorg/eclipse/ui/forms/widgets/ScrolledForm;
    //   37: invokestatic 1480	org/eclipse/mylyn/commons/workbench/forms/CommonFormUtil:disableScrollingOnFocus	(Lorg/eclipse/ui/forms/widgets/ScrolledForm;)V
    //   40: aload_0
    //   41: iconst_0
    //   42: invokevirtual 1572	org/eclipse/mylyn/tasks/ui/editors/AbstractTaskEditorPage:setReflow	(Z)V
    //   45: aload_0
    //   46: aload_0
    //   47: getfield 1414	org/eclipse/mylyn/tasks/ui/editors/AbstractTaskEditorPage:form	Lorg/eclipse/ui/forms/widgets/ScrolledForm;
    //   50: invokevirtual 1712	org/eclipse/ui/forms/widgets/ScrolledForm:getBody	()Lorg/eclipse/swt/widgets/Composite;
    //   53: putfield 1411	org/eclipse/mylyn/tasks/ui/editors/AbstractTaskEditorPage:editorComposite	Lorg/eclipse/swt/widgets/Composite;
    //   56: new 755	org/eclipse/swt/layout/GridLayout
    //   59: dup
    //   60: invokespecial 1684	org/eclipse/swt/layout/GridLayout:<init>	()V
    //   63: astore_2
    //   64: aload_2
    //   65: iconst_0
    //   66: putfield 1423	org/eclipse/swt/layout/GridLayout:verticalSpacing	I
    //   69: aload_0
    //   70: getfield 1411	org/eclipse/mylyn/tasks/ui/editors/AbstractTaskEditorPage:editorComposite	Lorg/eclipse/swt/widgets/Composite;
    //   73: aload_2
    //   74: invokevirtual 1692	org/eclipse/swt/widgets/Composite:setLayout	(Lorg/eclipse/swt/widgets/Layout;)V
    //   77: aload_0
    //   78: getfield 1411	org/eclipse/mylyn/tasks/ui/editors/AbstractTaskEditorPage:editorComposite	Lorg/eclipse/swt/widgets/Composite;
    //   81: aload_0
    //   82: invokevirtual 1591	org/eclipse/mylyn/tasks/ui/editors/AbstractTaskEditorPage:getTaskEditor	()Lorg/eclipse/mylyn/tasks/ui/editors/TaskEditor;
    //   85: invokevirtual 1661	org/eclipse/mylyn/tasks/ui/editors/TaskEditor:getMenu	()Lorg/eclipse/swt/widgets/Menu;
    //   88: invokevirtual 1695	org/eclipse/swt/widgets/Composite:setMenu	(Lorg/eclipse/swt/widgets/Menu;)V
    //   91: aload_0
    //   92: invokevirtual 1576	org/eclipse/mylyn/tasks/ui/editors/AbstractTaskEditorPage:getConnectorKind	()Ljava/lang/String;
    //   95: invokestatic 1489	org/eclipse/mylyn/internal/tasks/ui/TasksUiPlugin:getConnectorUi	(Ljava/lang/String;)Lorg/eclipse/mylyn/tasks/ui/AbstractRepositoryConnectorUi;
    //   98: astore_3
    //   99: aload_3
    //   100: ifnonnull +22 -> 122
    //   103: invokestatic 1701	org/eclipse/ui/PlatformUI:getWorkbench	()Lorg/eclipse/ui/IWorkbench;
    //   106: invokeinterface 1743 1 0
    //   111: new 730	org/eclipse/mylyn/tasks/ui/editors/AbstractTaskEditorPage$4
    //   114: dup
    //   115: aload_0
    //   116: invokespecial 1629	org/eclipse/mylyn/tasks/ui/editors/AbstractTaskEditorPage$4:<init>	(Lorg/eclipse/mylyn/tasks/ui/editors/AbstractTaskEditorPage;)V
    //   119: invokevirtual 1697	org/eclipse/swt/widgets/Display:asyncExec	(Ljava/lang/Runnable;)V
    //   122: aload_0
    //   123: getfield 1406	org/eclipse/mylyn/tasks/ui/editors/AbstractTaskEditorPage:taskData	Lorg/eclipse/mylyn/tasks/core/data/TaskData;
    //   126: ifnull +7 -> 133
    //   129: aload_0
    //   130: invokespecial 1557	org/eclipse/mylyn/tasks/ui/editors/AbstractTaskEditorPage:createFormContentInternal	()V
    //   133: aload_0
    //   134: invokespecial 1563	org/eclipse/mylyn/tasks/ui/editors/AbstractTaskEditorPage:updateHeaderMessage	()V
    //   137: goto +42 -> 179
    //   140: astore 4
    //   142: aload_0
    //   143: iconst_1
    //   144: invokevirtual 1572	org/eclipse/mylyn/tasks/ui/editors/AbstractTaskEditorPage:setReflow	(Z)V
    //   147: aload_0
    //   148: aload_0
    //   149: getfield 1414	org/eclipse/mylyn/tasks/ui/editors/AbstractTaskEditorPage:form	Lorg/eclipse/ui/forms/widgets/ScrolledForm;
    //   152: invokespecial 1598	org/eclipse/mylyn/tasks/ui/editors/AbstractTaskEditorPage:calculateReflowRequired	(Lorg/eclipse/ui/forms/widgets/ScrolledForm;)Z
    //   155: istore 5
    //   157: iload 5
    //   159: ifeq +17 -> 176
    //   162: invokestatic 1698	org/eclipse/swt/widgets/Display:getCurrent	()Lorg/eclipse/swt/widgets/Display;
    //   165: new 729	org/eclipse/mylyn/tasks/ui/editors/AbstractTaskEditorPage$3
    //   168: dup
    //   169: aload_0
    //   170: invokespecial 1628	org/eclipse/mylyn/tasks/ui/editors/AbstractTaskEditorPage$3:<init>	(Lorg/eclipse/mylyn/tasks/ui/editors/AbstractTaskEditorPage;)V
    //   173: invokevirtual 1697	org/eclipse/swt/widgets/Display:asyncExec	(Ljava/lang/Runnable;)V
    //   176: aload 4
    //   178: athrow
    //   179: aload_0
    //   180: iconst_1
    //   181: invokevirtual 1572	org/eclipse/mylyn/tasks/ui/editors/AbstractTaskEditorPage:setReflow	(Z)V
    //   184: aload_0
    //   185: aload_0
    //   186: getfield 1414	org/eclipse/mylyn/tasks/ui/editors/AbstractTaskEditorPage:form	Lorg/eclipse/ui/forms/widgets/ScrolledForm;
    //   189: invokespecial 1598	org/eclipse/mylyn/tasks/ui/editors/AbstractTaskEditorPage:calculateReflowRequired	(Lorg/eclipse/ui/forms/widgets/ScrolledForm;)Z
    //   192: istore 5
    //   194: iload 5
    //   196: ifeq +17 -> 213
    //   199: invokestatic 1698	org/eclipse/swt/widgets/Display:getCurrent	()Lorg/eclipse/swt/widgets/Display;
    //   202: new 729	org/eclipse/mylyn/tasks/ui/editors/AbstractTaskEditorPage$3
    //   205: dup
    //   206: aload_0
    //   207: invokespecial 1628	org/eclipse/mylyn/tasks/ui/editors/AbstractTaskEditorPage$3:<init>	(Lorg/eclipse/mylyn/tasks/ui/editors/AbstractTaskEditorPage;)V
    //   210: invokevirtual 1697	org/eclipse/swt/widgets/Display:asyncExec	(Ljava/lang/Runnable;)V
    //   213: return
    // Line number table:
    //   Java source line #624	-> byte code offset #0
    //   Java source line #625	-> byte code offset #5
    //   Java source line #627	-> byte code offset #15
    //   Java source line #628	-> byte code offset #25
    //   Java source line #629	-> byte code offset #33
    //   Java source line #632	-> byte code offset #40
    //   Java source line #634	-> byte code offset #45
    //   Java source line #636	-> byte code offset #56
    //   Java source line #637	-> byte code offset #64
    //   Java source line #638	-> byte code offset #69
    //   Java source line #646	-> byte code offset #77
    //   Java source line #648	-> byte code offset #91
    //   Java source line #649	-> byte code offset #99
    //   Java source line #650	-> byte code offset #103
    //   Java source line #664	-> byte code offset #122
    //   Java source line #665	-> byte code offset #129
    //   Java source line #668	-> byte code offset #133
    //   Java source line #669	-> byte code offset #140
    //   Java source line #670	-> byte code offset #142
    //   Java source line #674	-> byte code offset #147
    //   Java source line #676	-> byte code offset #157
    //   Java source line #677	-> byte code offset #162
    //   Java source line #685	-> byte code offset #176
    //   Java source line #670	-> byte code offset #179
    //   Java source line #674	-> byte code offset #184
    //   Java source line #676	-> byte code offset #194
    //   Java source line #677	-> byte code offset #199
    //   Java source line #686	-> byte code offset #213
    // Local variable table:
    //   start	length	slot	name	signature
    //   0	214	0	this	AbstractTaskEditorPage
    //   0	214	1	managedForm	IManagedForm
    //   63	11	2	editorLayout	GridLayout
    //   98	2	3	connectorUi	AbstractRepositoryConnectorUi
    //   140	37	4	localObject	Object
    //   155	3	5	reflowRequired	boolean
    //   192	3	5	reflowRequired	boolean
    // Exception table:
    //   from	to	target	type
    //   40	140	140	finally
  }
  
  private boolean calculateReflowRequired(ScrolledForm form)
  {
    Composite stopComposite = getEditor().getEditorParent().getParent().getParent();
    Composite composite = form.getParent();
    while (composite != null)
    {
      Rectangle clientArea = composite.getClientArea();
      if (width > 1) {
        return false;
      }
      if (composite == stopComposite) {
        return true;
      }
      composite = composite.getParent();
    }
    return true;
  }
  
  private void createFormContentInternal()
  {
    if (attributeEditorToolkit != null) {
      attributeEditorToolkit.dispose();
    }
    if (attributeEditorFactory == null)
    {
      attributeEditorFactory = createAttributeEditorFactory();
      Assert.isNotNull(attributeEditorFactory);
    }
    attributeEditorToolkit = createAttributeEditorToolkit();
    Assert.isNotNull(attributeEditorToolkit);
    attributeEditorToolkit.setMenu(editorComposite.getMenu());
    attributeEditorFactory.setEditorToolkit(attributeEditorToolkit);
    
    createParts();
    
    focusTracker = new FocusTracker();
    focusTracker.track(editorComposite);
  }
  
  protected TaskDataModel createModel(TaskEditorInput input)
    throws CoreException
  {
    ITaskDataWorkingCopy taskDataState;
    try
    {
      taskDataState = TasksUi.getTaskDataManager().getWorkingCopy(task);
    }
    catch (OperationCanceledException localOperationCanceledException)
    {
      ITaskDataWorkingCopy taskDataState;
      taskDataState = TasksUi.getTaskDataManager().getWorkingCopy(task);
    }
    TaskRepository taskRepository = TasksUi.getRepositoryManager().getRepository(taskDataState.getConnectorKind(), 
      taskDataState.getRepositoryUrl());
    return new TaskDataModel(taskRepository, input.getTask(), taskDataState);
  }
  
  protected Set<TaskEditorPartDescriptor> createPartDescriptors()
  {
    Set<TaskEditorPartDescriptor> descriptors = new LinkedHashSet();
    descriptors.add(new TaskEditorPartDescriptor("org.eclipse.mylyn.tasks.ui.editors.parts.summary")
    {
      public AbstractTaskEditorPart createPart()
      {
        return new TaskEditorSummaryPart();
      }
    }.setPath("header"));
    descriptors.add(new TaskEditorPartDescriptor("org.eclipse.mylyn.tasks.ui.editors.parts.attributes")
    {
      public AbstractTaskEditorPart createPart()
      {
        return new TaskEditorAttributePart();
      }
    }.setPath("attributes"));
    if ((!taskData.isNew()) && (connector.getTaskAttachmentHandler() != null) && (
      (AttachmentUtil.canDownloadAttachment(task)) || (AttachmentUtil.canUploadAttachment(task)))) {
      descriptors.add(new TaskEditorPartDescriptor("org.eclipse.mylyn.tasks.ui.editors.parts.attachments")
      {
        public AbstractTaskEditorPart createPart()
        {
          return new TaskEditorAttachmentPart();
        }
      }.setPath("attachments"));
    }
    if ((needsPrivateSection()) || (taskData.isNew())) {
      descriptors.add(new TaskEditorPartDescriptor("org.eclipse.mylyn.tasks.ui.editors.parts.planning")
      {
        public AbstractTaskEditorPart createPart()
        {
          return new TaskEditorPlanningPart();
        }
      }.setPath("planning"));
    }
    descriptors.add(new TaskEditorPartDescriptor("org.eclipse.mylyn.tasks.ui.editors.parts.descriptions")
    {
      public AbstractTaskEditorPart createPart()
      {
        TaskEditorDescriptionPart part = new TaskEditorDescriptionPart();
        if (getModel().getTaskData().isNew())
        {
          part.setExpandVertically(true);
          part.setSectionStyle(320);
        }
        return part;
      }
    }.setPath("comments"));
    if (!taskData.isNew()) {
      descriptors.add(new TaskEditorPartDescriptor("org.eclipse.mylyn.tasks.ui.editors.parts.comments")
      {
        public AbstractTaskEditorPart createPart()
        {
          return new TaskEditorCommentPart();
        }
      }.setPath("comments"));
    }
    descriptors.add(new TaskEditorPartDescriptor("org.eclipse.mylyn.tasks.ui.editors.parts.newComment")
    {
      public AbstractTaskEditorPart createPart()
      {
        return new TaskEditorNewCommentPart();
      }
    }.setPath("comments"));
    descriptors.add(new TaskEditorPartDescriptor("org.eclipse.mylyn.tasks.ui.editors.parts.actions")
    {
      public AbstractTaskEditorPart createPart()
      {
        return new TaskEditorActionPart();
      }
    }.setPath("actions"));
    descriptors.add(new TaskEditorPartDescriptor("org.eclipse.mylyn.tasks.ui.editors.parts.people")
    {
      public AbstractTaskEditorPart createPart()
      {
        return new TaskEditorPeoplePart();
      }
    }.setPath("people"));
    
    descriptors.addAll(getContributionPartDescriptors());
    return descriptors;
  }
  
  private Collection<TaskEditorPartDescriptor> getContributionPartDescriptors()
  {
    return TaskEditorContributionExtensionReader.getRepositoryEditorContributions();
  }
  
  protected void createParts()
  {
    List<TaskEditorPartDescriptor> descriptors = new LinkedList(createPartDescriptors());
    
    createParts("header", editorComposite, descriptors);
    createParts("associations", editorComposite, descriptors);
    createParts("attributes", editorComposite, descriptors);
    createParts("attachments", editorComposite, descriptors);
    createParts("planning", editorComposite, descriptors);
    createParts("comments", editorComposite, descriptors);
    
    Composite bottomComposite = toolkit.createComposite(editorComposite);
    bottomComposite.setLayout(GridLayoutFactory.fillDefaults().numColumns(2).create());
    GridDataFactory.fillDefaults().grab(true, false).applyTo(bottomComposite);
    createParts("actions", bottomComposite, descriptors);
    createParts("people", bottomComposite, descriptors);
    bottomComposite.pack(true);
  }
  
  private void createParts(String path, final Composite parent, final Collection<TaskEditorPartDescriptor> descriptors)
  {
    for (Iterator<TaskEditorPartDescriptor> it = descriptors.iterator(); it.hasNext();)
    {
      final TaskEditorPartDescriptor descriptor = (TaskEditorPartDescriptor)it.next();
      if ((path == null) || (path.equals(descriptor.getPath())))
      {
        SafeRunner.run(new ISafeRunnable()
        {
          public void handleException(Throwable e)
          {
            StatusHandler.log(new Status(4, "org.eclipse.mylyn.tasks.ui", 
              "Error creating task editor part: \"" + descriptor.getId() + "\"", e));
          }
          
          public void run()
            throws Exception
          {
            AbstractTaskEditorPart part = descriptor.createPart();
            part.setPartId(descriptor.getId());
            AbstractTaskEditorPage.this.initializePart(parent, part, descriptors);
          }
        });
        it.remove();
      }
    }
  }
  
  private void createSubParts(final AbstractTaskEditorSection parentPart, Collection<TaskEditorPartDescriptor> descriptors)
  {
    for (final TaskEditorPartDescriptor descriptor : descriptors)
    {
      String path = descriptor.getPath();
      int i;
      if ((path != null) && ((i = path.indexOf("/")) != -1))
      {
        String parentId = path.substring(0, i);
        final String subPath = path.substring(i + 1);
        if (parentId.equals(parentPart.getPartId())) {
          SafeRunner.run(new ISafeRunnable()
          {
            public void handleException(Throwable e)
            {
              StatusHandler.log(new Status(4, "org.eclipse.mylyn.tasks.ui", 
                "Error creating task editor part: \"" + descriptor.getId() + "\"", e));
            }
            
            public void run()
              throws Exception
            {
              AbstractTaskEditorPart part = descriptor.createPart();
              part.setPartId(descriptor.getId());
              getManagedForm().addPart(part);
              part.initialize(AbstractTaskEditorPage.this);
              parentPart.addSubPart(subPath, part);
            }
          });
        }
      }
    }
  }
  
  public void dispose()
  {
    if (textSupport != null) {
      textSupport.dispose();
    }
    if (attributeEditorToolkit != null) {
      attributeEditorToolkit.dispose();
    }
    TasksUiPlugin.getTaskDataManager().removeListener(TASK_DATA_LISTENER);
    super.dispose();
  }
  
  public void doAction(String actionId)
  {
    CommonTextSupport.doAction(actionId, EditorUtil.getFocusControl(this));
  }
  
  public void doSave(IProgressMonitor monitor)
  {
    if (!isDirty()) {
      return;
    }
    getManagedForm().commit(true);
    if (model.isDirty()) {
      try
      {
        model.save(monitor);
      }
      catch (CoreException e)
      {
        StatusHandler.log(new Status(4, "org.eclipse.mylyn.tasks.ui", "Error saving task", e));
        getTaskEditor().setMessage(Messages.AbstractTaskEditorPage_Could_not_save_task, 3, 
          new HyperlinkAdapter()
          {
            public void linkActivated(HyperlinkEvent event)
            {
              TasksUiInternal.displayStatus(Messages.AbstractTaskEditorPage_Save_failed, 
                e.getStatus());
            }
          });
      }
    }
    if (getTask().getSynchronizationState() == ITask.SynchronizationState.OUTGOING_NEW)
    {
      final String summary = connector.getTaskMapping(model.getTaskData()).getSummary();
      try
      {
        TasksUiPlugin.getTaskList().run(new ITaskListRunnable()
        {
          public void execute(IProgressMonitor monitor)
            throws CoreException
          {
            task.setSummary(summary);
          }
        });
        TasksUiPlugin.getTaskList().notifyElementChanged(task);
      }
      catch (CoreException e)
      {
        StatusHandler.log(new Status(4, "org.eclipse.mylyn.tasks.ui", 
          "Failed to set summary for task \"" + task + "\"", e));
      }
    }
    TasksUiPlugin.getTaskList().addTaskIfAbsent(task);
    
    updateHeaderMessage();
    getManagedForm().dirtyStateChanged();
    getTaskEditor().updateHeaderToolBar();
  }
  
  public void doSaveAs()
  {
    throw new UnsupportedOperationException();
  }
  
  public void doSubmit()
  {
    if ((!submitEnabled) || (!needsSubmit())) {
      return;
    }
    try
    {
      showEditorBusy(true);
      
      doSave(new NullProgressMonitor());
      
      TaskAttribute newCommentAttribute = getModel().getTaskData()
        .getRoot()
        .getMappedAttribute("task.common.comment.new");
      boolean expandLastComment = (newCommentAttribute != null) && 
        (getModel().getChangedAttributes().contains(newCommentAttribute));
      
      SubmitJob submitJob = TasksUiInternal.getJobFactory().createSubmitTaskJob(connector, 
        getModel().getTaskRepository(), task, getModel().getTaskData(), 
        getModel().getChangedOldAttributes());
      submitJob.addSubmitJobListener(new SubmitTaskJobListener(getAttachContext(), expandLastComment));
      submitJob.schedule();
    }
    catch (RuntimeException e)
    {
      showEditorBusy(false);
      throw e;
    }
    TasksUiPlugin.getTaskList().addTaskIfAbsent(task);
  }
  
  public void fillToolBar(IToolBarManager toolBarManager)
  {
    TaskRepository taskRepository = model != null ? getModel().getTaskRepository() : null;
    if (taskData == null)
    {
      synchronizeEditorAction = new SynchronizeEditorAction();
      synchronizeEditorAction.selectionChanged(new StructuredSelection(getTaskEditor()));
      toolBarManager.appendToGroup("repository", synchronizeEditorAction);
    }
    else
    {
      if (taskData.isNew())
      {
        DeleteTaskEditorAction deleteAction = new DeleteTaskEditorAction(getTask());
        deleteAction.setImageDescriptor(CommonImages.CLEAR);
        toolBarManager.appendToGroup("new", deleteAction);
      }
      else if (taskRepository != null)
      {
        ClearOutgoingAction clearOutgoingAction = new ClearOutgoingAction(
          Collections.singletonList(task));
        clearOutgoingAction.setTaskEditorPage(this);
        if (clearOutgoingAction.isEnabled()) {
          toolBarManager.appendToGroup("new", clearOutgoingAction);
        }
        if (task.getSynchronizationState() != ITask.SynchronizationState.OUTGOING_NEW)
        {
          synchronizeEditorAction = new SynchronizeEditorAction();
          synchronizeEditorAction.selectionChanged(new StructuredSelection(getTaskEditor()));
          toolBarManager.appendToGroup("repository", synchronizeEditorAction);
        }
        NewSubTaskAction newSubTaskAction = new NewSubTaskAction();
        newSubTaskAction.selectionChanged(newSubTaskAction, new StructuredSelection(task));
        if (newSubTaskAction.isEnabled()) {
          toolBarManager.appendToGroup("new", newSubTaskAction);
        }
        AbstractRepositoryConnectorUi connectorUi = TasksUiPlugin.getConnectorUi(taskData.getConnectorKind());
        if (connectorUi != null)
        {
          final String historyUrl = connectorUi.getTaskHistoryUrl(taskRepository, task);
          if (historyUrl != null)
          {
            final Action historyAction = new Action()
            {
              public void run()
              {
                TasksUiUtil.openUrl(historyUrl);
              }
            };
            historyAction.setText(Messages.AbstractTaskEditorPage_History);
            historyAction.setImageDescriptor(TasksUiImages.TASK_REPOSITORY_HISTORY);
            historyAction.setToolTipText(Messages.AbstractTaskEditorPage_History);
            if (getEditoropenWithBrowserAction != null) {
              getEditoropenWithBrowserAction.setMenuCreator(new MenuCreator(historyAction)
              {
                protected void initialize(MenuManager menuManager)
                {
                  OpenWithBrowserAction openWithBrowserAction = new OpenWithBrowserAction();
                  openWithBrowserAction.selectionChanged(new StructuredSelection(task));
                  menuManager.add(openWithBrowserAction);
                  menuManager.add(new Separator());
                  menuManager.add(historyAction);
                }
              });
            } else {
              toolBarManager.prependToGroup("open", historyAction);
            }
          }
        }
      }
      if (needsSubmitButton())
      {
        ToolBarButtonContribution submitButtonContribution = new ToolBarButtonContribution(
          "org.eclipse.mylyn.tasks.toolbars.submit")
          {
            protected Control createButton(Composite composite)
            {
              submitButton = new Button(composite, 8388608);
              submitButton.setText(Messages.TaskEditorActionPart_Submit + " ");
              submitButton.setImage(CommonImages.getImage(TasksUiImages.REPOSITORY_SUBMIT));
              submitButton.setBackground(null);
              submitButton.addListener(13, new Listener()
              {
                public void handleEvent(Event e)
                {
                  doSubmit();
                }
              });
              return submitButton;
            }
          };
          marginLeft = 10;
          toolBarManager.add(submitButtonContribution);
        }
      }
    }
    
    protected void fireSelectionChanged(ISelection selection)
    {
      final SelectionChangedEvent event = new SelectionChangedEvent(this, selection);
      
      Object[] listeners = selectionChangedListeners.getListeners();
      Object[] arrayOfObject1;
      int j = (arrayOfObject1 = listeners).length;
      for (int i = 0; i < j; i++)
      {
        Object listener = arrayOfObject1[i];
        final ISelectionChangedListener l = (ISelectionChangedListener)listener;
        SafeRunner.run(new SafeRunnable()
        {
          public void run()
          {
            l.selectionChanged(event);
          }
        });
      }
    }
    
    public Object getAdapter(Class adapter)
    {
      if (adapter == IContentOutlinePage.class)
      {
        updateOutlinePage();
        return outlinePage;
      }
      if (adapter == CommonTextSupport.class) {
        return textSupport;
      }
      return super.getAdapter(adapter);
    }
    
    private void updateOutlinePage()
    {
      if (outlinePage == null)
      {
        outlinePage = new TaskEditorOutlinePage();
        outlinePage.addSelectionChangedListener(new ISelectionChangedListener()
        {
          public void selectionChanged(SelectionChangedEvent event)
          {
            ISelection selection = event.getSelection();
            if ((selection instanceof StructuredSelection))
            {
              Object select = ((StructuredSelection)selection).getFirstElement();
              selectReveal(select);
              getEditor().setActivePage(getId());
            }
          }
        });
      }
      if (getModel() != null)
      {
        TaskEditorOutlineNode node = TaskEditorOutlineNode.parse(getModel().getTaskData(), false);
        outlinePage.setInput(getTaskRepository(), node);
      }
      else
      {
        outlinePage.setInput(null, null);
      }
    }
    
    private boolean getAttachContext()
    {
      AbstractTaskEditorPart actionPart = getPart("org.eclipse.mylyn.tasks.ui.editors.parts.actions");
      if ((actionPart instanceof TaskEditorActionPart)) {
        return ((TaskEditorActionPart)actionPart).getAttachContext();
      }
      return false;
    }
    
    public AttributeEditorFactory getAttributeEditorFactory()
    {
      return attributeEditorFactory;
    }
    
    public AttributeEditorToolkit getAttributeEditorToolkit()
    {
      return attributeEditorToolkit;
    }
    
    public AbstractRepositoryConnector getConnector()
    {
      return connector;
    }
    
    public String getConnectorKind()
    {
      return connectorKind;
    }
    
    public Composite getEditorComposite()
    {
      return editorComposite;
    }
    
    public TaskDataModel getModel()
    {
      return model;
    }
    
    public AbstractTaskEditorPart getPart(String partId)
    {
      Assert.isNotNull(partId);
      if (getManagedForm() != null)
      {
        IFormPart[] arrayOfIFormPart;
        int j = (arrayOfIFormPart = getManagedForm().getParts()).length;
        for (int i = 0; i < j; i++)
        {
          IFormPart part = arrayOfIFormPart[i];
          if ((part instanceof AbstractTaskEditorPart))
          {
            AbstractTaskEditorPart taskEditorPart = (AbstractTaskEditorPart)part;
            if (partId.equals(taskEditorPart.getPartId())) {
              return taskEditorPart;
            }
          }
        }
      }
      return null;
    }
    
    public ISelection getSelection()
    {
      return lastSelection;
    }
    
    public ITask getTask()
    {
      return task;
    }
    
    public TaskEditor getTaskEditor()
    {
      return getEditor();
    }
    
    public TaskRepository getTaskRepository()
    {
      return getModel().getTaskRepository();
    }
    
    protected void handleTaskSubmitted(SubmitJobEvent event)
    {
      IStatus status = event.getJob().getStatus();
      if ((status != null) && (status.getSeverity() != 8)) {
        handleSubmitError(event.getJob());
      }
    }
    
    private void handleSubmitError(SubmitJob job)
    {
      if ((form != null) && (!form.isDisposed()))
      {
        final IStatus status = job.getStatus();
        if (status.getCode() == 9)
        {
          TasksUiInternal.displayStatus(Messages.AbstractTaskEditorPage_Comment_required, status);
          AbstractTaskEditorPart newCommentPart = getPart("org.eclipse.mylyn.tasks.ui.editors.parts.newComment");
          if (newCommentPart != null) {
            newCommentPart.setFocus();
          }
        }
        else if (status.getCode() == 3)
        {
          if (TasksUiUtil.openEditRepositoryWizard(getTaskRepository()) == 0)
          {
            submitEnabled = true;
            doSubmit();
          }
          else
          {
            String message;
            if (status.getMessage().length() > 0) {
              message = Messages.AbstractTaskEditorPage_Submit_failed_ + status.getMessage();
            } else {
              message = Messages.AbstractTaskEditorPage_Submit_failed;
            }
            String message = message.replaceAll("\n", " ");
            getTaskEditor().setMessage(message, 3, new HyperlinkAdapter()
            {
              public void linkActivated(HyperlinkEvent e)
              {
                TasksUiInternal.displayStatus(Messages.AbstractTaskEditorPage_Submit_failed, status);
              }
            });
          }
        }
        else
        {
          String message;
          String message;
          if (status.getCode() == 5)
          {
            message = ERROR_NOCONNECTIVITY;
          }
          else
          {
            String message;
            if (status.getMessage().length() > 0) {
              message = Messages.AbstractTaskEditorPage_Submit_failed_ + status.getMessage();
            } else {
              message = Messages.AbstractTaskEditorPage_Submit_failed;
            }
          }
          getTaskEditor().setMessage(message, 3, new HyperlinkAdapter()
          {
            public void linkActivated(HyperlinkEvent e)
            {
              TasksUiInternal.displayStatus(Messages.AbstractTaskEditorPage_Submit_failed, status);
            }
          });
        }
      }
    }
    
    public void init(IEditorSite site, IEditorInput input)
    {
      super.init(site, input);
      
      TaskEditorInput taskEditorInput = (TaskEditorInput)input;
      task = taskEditorInput.getTask();
      defaultSelection = new StructuredSelection(task);
      lastSelection = defaultSelection;
      IHandlerService handlerService = (IHandlerService)getSite().getService(IHandlerService.class);
      textSupport = new CommonTextSupport(handlerService);
      textSupport.setSelectionChangedListener(this);
      
      initModel(taskEditorInput);
      
      TasksUiPlugin.getTaskDataManager().addListener(TASK_DATA_LISTENER);
    }
    
    private void initModel(TaskEditorInput input)
    {
      Assert.isTrue(model == null);
      try
      {
        model = createModel(input);
        connector = TasksUi.getRepositoryManager().getRepositoryConnector(getConnectorKind());
        setTaskData(model.getTaskData());
        model.addModelListener(new TaskDataModelListener()
        {
          public void attributeChanged(TaskDataModelEvent event)
          {
            IManagedForm form = getManagedForm();
            if (form != null) {
              form.dirtyStateChanged();
            }
          }
        });
        setNeedsAddToCategory(model.getTaskData().isNew());
      }
      catch (CoreException e)
      {
        StatusHandler.log(new Status(4, "org.eclipse.mylyn.tasks.ui", "Error opening task", e));
        getTaskEditor().setStatus(Messages.AbstractTaskEditorPage_Error_opening_task, 
          Messages.AbstractTaskEditorPage_Open_failed, e.getStatus());
      }
    }
    
    private void initializePart(Composite parent, AbstractTaskEditorPart part, Collection<TaskEditorPartDescriptor> descriptors)
    {
      getManagedForm().addPart(part);
      part.initialize(this);
      if ((part instanceof AbstractTaskEditorSection)) {
        createSubParts((AbstractTaskEditorSection)part, descriptors);
      }
      if (parent != null)
      {
        part.createControl(parent, toolkit);
        if (part.getControl() != null)
        {
          if ("org.eclipse.mylyn.tasks.ui.editors.parts.actions".equals(part.getPartId())) {
            GridDataFactory.fillDefaults().align(4, 4).grab(false, false).applyTo(part.getControl());
          } else if (part.getExpandVertically()) {
            GridDataFactory.fillDefaults().align(4, 4).grab(true, true).applyTo(part.getControl());
          } else {
            GridDataFactory.fillDefaults().align(4, 128).grab(true, false).applyTo(part.getControl());
          }
          if ("org.eclipse.mylyn.tasks.ui.editors.parts.comments".equals(part.getPartId())) {
            EditorUtil.setMarker(part.getControl(), TaskEditorOutlineNode.LABEL_COMMENTS);
          } else if ("org.eclipse.mylyn.tasks.ui.editors.parts.attachments".equals(part.getPartId())) {
            EditorUtil.setMarker(part.getControl(), TaskEditorOutlineNode.LABEL_ATTACHMENTS);
          }
        }
      }
    }
    
    public boolean isDirty()
    {
      return ((getModel() != null) && (getModel().isDirty())) || ((getManagedForm() != null) && (getManagedForm().isDirty()));
    }
    
    public boolean isSaveAsAllowed()
    {
      return false;
    }
    
    public boolean needsAddToCategory()
    {
      return needsAddToCategory;
    }
    
    /* Error */
    public void reflow()
    {
      // Byte code:
      //   0: aload_0
      //   1: getfield 1389	org/eclipse/mylyn/tasks/ui/editors/AbstractTaskEditorPage:reflow	Z
      //   4: ifeq +126 -> 130
      //   7: aload_0
      //   8: getfield 1414	org/eclipse/mylyn/tasks/ui/editors/AbstractTaskEditorPage:form	Lorg/eclipse/ui/forms/widgets/ScrolledForm;
      //   11: iconst_0
      //   12: invokevirtual 1708	org/eclipse/ui/forms/widgets/ScrolledForm:setRedraw	(Z)V
      //   15: aload_0
      //   16: getfield 1414	org/eclipse/mylyn/tasks/ui/editors/AbstractTaskEditorPage:form	Lorg/eclipse/ui/forms/widgets/ScrolledForm;
      //   19: invokevirtual 1713	org/eclipse/ui/forms/widgets/ScrolledForm:getParent	()Lorg/eclipse/swt/widgets/Composite;
      //   22: invokevirtual 1689	org/eclipse/swt/widgets/Composite:getClientArea	()Lorg/eclipse/swt/graphics/Rectangle;
      //   25: astore_1
      //   26: aload_0
      //   27: getfield 1414	org/eclipse/mylyn/tasks/ui/editors/AbstractTaskEditorPage:form	Lorg/eclipse/ui/forms/widgets/ScrolledForm;
      //   30: invokevirtual 1711	org/eclipse/ui/forms/widgets/ScrolledForm:getSize	()Lorg/eclipse/swt/graphics/Point;
      //   33: astore_2
      //   34: aload_2
      //   35: getfield 1416	org/eclipse/swt/graphics/Point:x	I
      //   38: aload_1
      //   39: getfield 1418	org/eclipse/swt/graphics/Rectangle:width	I
      //   42: if_icmpeq +47 -> 89
      //   45: aload_0
      //   46: getfield 1414	org/eclipse/mylyn/tasks/ui/editors/AbstractTaskEditorPage:form	Lorg/eclipse/ui/forms/widgets/ScrolledForm;
      //   49: invokevirtual 1714	org/eclipse/ui/forms/widgets/ScrolledForm:getVerticalBar	()Lorg/eclipse/swt/widgets/ScrollBar;
      //   52: astore_3
      //   53: aload_3
      //   54: ifnull +13 -> 67
      //   57: aload_3
      //   58: invokevirtual 1699	org/eclipse/swt/widgets/ScrollBar:getSize	()Lorg/eclipse/swt/graphics/Point;
      //   61: getfield 1416	org/eclipse/swt/graphics/Point:x	I
      //   64: goto +5 -> 69
      //   67: bipush 15
      //   69: istore 4
      //   71: aload_0
      //   72: getfield 1414	org/eclipse/mylyn/tasks/ui/editors/AbstractTaskEditorPage:form	Lorg/eclipse/ui/forms/widgets/ScrolledForm;
      //   75: aload_1
      //   76: getfield 1418	org/eclipse/swt/graphics/Rectangle:width	I
      //   79: iload 4
      //   81: isub
      //   82: aload_2
      //   83: getfield 1417	org/eclipse/swt/graphics/Point:y	I
      //   86: invokevirtual 1706	org/eclipse/ui/forms/widgets/ScrolledForm:setSize	(II)V
      //   89: aload_0
      //   90: getfield 1414	org/eclipse/mylyn/tasks/ui/editors/AbstractTaskEditorPage:form	Lorg/eclipse/ui/forms/widgets/ScrolledForm;
      //   93: iconst_1
      //   94: iconst_0
      //   95: invokevirtual 1709	org/eclipse/ui/forms/widgets/ScrolledForm:layout	(ZZ)V
      //   98: aload_0
      //   99: getfield 1414	org/eclipse/mylyn/tasks/ui/editors/AbstractTaskEditorPage:form	Lorg/eclipse/ui/forms/widgets/ScrolledForm;
      //   102: iconst_1
      //   103: invokevirtual 1707	org/eclipse/ui/forms/widgets/ScrolledForm:reflow	(Z)V
      //   106: goto +16 -> 122
      //   109: astore 5
      //   111: aload_0
      //   112: getfield 1414	org/eclipse/mylyn/tasks/ui/editors/AbstractTaskEditorPage:form	Lorg/eclipse/ui/forms/widgets/ScrolledForm;
      //   115: iconst_1
      //   116: invokevirtual 1708	org/eclipse/ui/forms/widgets/ScrolledForm:setRedraw	(Z)V
      //   119: aload 5
      //   121: athrow
      //   122: aload_0
      //   123: getfield 1414	org/eclipse/mylyn/tasks/ui/editors/AbstractTaskEditorPage:form	Lorg/eclipse/ui/forms/widgets/ScrolledForm;
      //   126: iconst_1
      //   127: invokevirtual 1708	org/eclipse/ui/forms/widgets/ScrolledForm:setRedraw	(Z)V
      //   130: return
      // Line number table:
      //   Java source line #1357	-> byte code offset #0
      //   Java source line #1359	-> byte code offset #7
      //   Java source line #1362	-> byte code offset #15
      //   Java source line #1363	-> byte code offset #26
      //   Java source line #1364	-> byte code offset #34
      //   Java source line #1365	-> byte code offset #45
      //   Java source line #1366	-> byte code offset #53
      //   Java source line #1367	-> byte code offset #71
      //   Java source line #1370	-> byte code offset #89
      //   Java source line #1371	-> byte code offset #98
      //   Java source line #1372	-> byte code offset #109
      //   Java source line #1373	-> byte code offset #111
      //   Java source line #1374	-> byte code offset #119
      //   Java source line #1373	-> byte code offset #122
      //   Java source line #1376	-> byte code offset #130
      // Local variable table:
      //   start	length	slot	name	signature
      //   0	131	0	this	AbstractTaskEditorPage
      //   25	51	1	parentClientArea	Rectangle
      //   33	50	2	formSize	org.eclipse.swt.graphics.Point
      //   52	6	3	verticalBar	org.eclipse.swt.widgets.ScrollBar
      //   69	11	4	verticalBarWidth	int
      //   109	11	5	localObject	Object
      // Exception table:
      //   from	to	target	type
      //   7	109	109	finally
    }
    
    @Deprecated
    public void refreshFormContent()
    {
      refresh();
    }
    
    /* Error */
    public void refresh()
    {
      // Byte code:
      //   0: aload_0
      //   1: invokevirtual 1597	org/eclipse/mylyn/tasks/ui/editors/AbstractTaskEditorPage:getManagedForm	()Lorg/eclipse/ui/forms/IManagedForm;
      //   4: ifnull +18 -> 22
      //   7: aload_0
      //   8: invokevirtual 1597	org/eclipse/mylyn/tasks/ui/editors/AbstractTaskEditorPage:getManagedForm	()Lorg/eclipse/ui/forms/IManagedForm;
      //   11: invokeinterface 1758 1 0
      //   16: invokevirtual 1705	org/eclipse/ui/forms/widgets/ScrolledForm:isDisposed	()Z
      //   19: ifeq +4 -> 23
      //   22: return
      //   23: aload_0
      //   24: iconst_1
      //   25: invokevirtual 1574	org/eclipse/mylyn/tasks/ui/editors/AbstractTaskEditorPage:showEditorBusy	(Z)V
      //   28: iconst_0
      //   29: istore_1
      //   30: aload_0
      //   31: invokevirtual 1583	org/eclipse/mylyn/tasks/ui/editors/AbstractTaskEditorPage:getTask	()Lorg/eclipse/mylyn/tasks/core/ITask;
      //   34: ifnull +16 -> 50
      //   37: aload_0
      //   38: invokevirtual 1583	org/eclipse/mylyn/tasks/ui/editors/AbstractTaskEditorPage:getTask	()Lorg/eclip
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