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

.layout.GridLayout;
import org.eclipse.swt.widgets.Button;
import org.eclipse.swt.widgets.Composite;
import org.eclipse.swt.widgets.Control;
import org.eclipse.swt.widgets.Label;
import org.eclipse.swt.widgets.Text;
import org.eclipse.ui.forms.FormColors;
import org.eclipse.ui.forms.widgets.FormToolkit;

public class SummaryPart
  extends AbstractLocalEditorPart
{
  private Composite headerComposite;
  private CommonTextSupport textSupport;
  private RichTextEditor summaryEditor;
  private Button statusCompleteButton;
  private Button statusIncompleteButton;
  private Text creationDateText;
  private Text completionDateText;
  private PriorityEditor priorityEditor;
  private boolean initialized;
  
  public SummaryPart()
  {
    super(Messages.SummaryPart_Section_Title);
  }
  
  private Label createLabel(Composite composite, FormToolkit toolkit, String label, int indent)
  {
    Label labelControl = toolkit.createLabel(composite, label);
    labelControl.setForeground(toolkit.getColors().getColor("org.eclipse.ui.forms.TITLE"));
    GridDataFactory.defaultsFor(labelControl).indent(indent, 0).applyTo(labelControl);
    return labelControl;
  }
  
  private void createSummaryControl(Composite composite, FormToolkit toolkit)
  {
    Composite borderComposite = EditorUtil.createBorder(composite, toolkit);
    GridDataFactory.fillDefaults()
      .align(4, 16777216)
      .hint(300, -1)
      .grab(true, false)
      .applyTo(borderComposite);
    
    summaryEditor = new RichTextEditor(getRepository(), 4, null, null, getTask());
    summaryEditor.setSpellCheckingEnabled(true);
    summaryEditor.setReadOnly(!isSummaryEditable());
    summaryEditor.createControl(borderComposite, toolkit);
    if (textSupport != null) {
      textSupport.install(summaryEditor.getViewer(), true);
    }
    summaryEditor.getViewer().addTextListener(new ITextListener()
    {
      public void textChanged(TextEvent event)
      {
        if (!getTask().getSummary().equals(summaryEditor.getText())) {
          markDirty(summaryEditor.getControl());
        }
      }
    });
    summaryEditor.getViewer().getControl().setMenu(composite.getMenu());
    EditorUtil.setHeaderFontSizeAndStyle(summaryEditor.getControl());
  }
  
  public Control createControl(Composite parent, FormToolkit toolkit)
  {
    Composite composite = toolkit.createComposite(parent);
    GridLayout layout = EditorUtil.createSectionClientLayout();
    numColumns = 2;
    marginTop = 0;
    marginHeight = 0;
    marginWidth = 0;
    verticalSpacing = 3;
    composite.setLayout(layout);
    
    priorityEditor = new PriorityEditor()
    {
      protected void valueChanged(String value)
      {
        priorityEditor.select(value, ITask.PriorityLevel.fromString(value));
        priorityEditor.setToolTipText(value);
        markDirty(priorityEditor.getControl());
      }
    };
    Map<String, String> labelByValue = new LinkedHashMap();
    ITask.PriorityLevel[] arrayOfPriorityLevel;
    int j = (arrayOfPriorityLevel = ITask.PriorityLevel.values()).length;
    for (int i = 0; i < j; i++)
    {
      ITask.PriorityLevel level = arrayOfPriorityLevel[i];
      labelByValue.put(level.toString(), level.getDescription());
    }
    priorityEditor.setLabelByValue(labelByValue);
    priorityEditor.createControl(composite, toolkit);
    GridDataFactory.fillDefaults().align(16777216, 16777216).span(1, 2).applyTo(priorityEditor.getControl());
    
    createSummaryControl(composite, toolkit);
    
    createHeaderControls(composite, toolkit);
    GridDataFactory.fillDefaults().grab(true, false).applyTo(headerComposite);
    
    toolkit.paintBordersFor(composite);
    return composite;
  }
  
  protected Composite createHeaderControls(Composite composite, FormToolkit toolkit)
  {
    headerComposite = toolkit.createComposite(composite);
    GridLayout layout = new GridLayout(1, false);
    marginHeight = 0;
    marginWidth = 0;
    headerComposite.setLayout(layout);
    
    createLabel(headerComposite, toolkit, Messages.TaskPlanningEditor_Status, 0);
    statusIncompleteButton = toolkit.createButton(headerComposite, Messages.TaskPlanningEditor_Incomplete, 
      16);
    statusIncompleteButton.addSelectionListener(new SelectionAdapter()
    {
      public void widgetSelected(SelectionEvent e)
      {
        if (statusIncompleteButton.getSelection())
        {
          statusCompleteButton.setSelection(false);
          markDirty(statusCompleteButton);
        }
      }
    });
    statusCompleteButton = toolkit.createButton(headerComposite, Messages.TaskPlanningEditor_Complete, 16);
    statusCompleteButton.addSelectionListener(new SelectionAdapter()
    {
      public void widgetSelected(SelectionEvent e)
      {
        if (statusCompleteButton.getSelection())
        {
          statusIncompleteButton.setSelection(false);
          markDirty(statusCompleteButton);
        }
      }
    });
    createLabel(headerComposite, toolkit, getCreatedDateLabel(), 6);
    
    creationDateText = new Text(headerComposite, 8388616);
    toolkit.adapt(creationDateText, false, false);
    creationDateText.setData("FormWidgetFactory.drawBorder", Boolean.FALSE);
    
    createLabel(headerComposite, toolkit, Messages.TaskPlanningEditor_Completed, 6);
    
    completionDateText = new Text(headerComposite, 8388616);
    toolkit.adapt(completionDateText, false, false);
    completionDateText.setData("FormWidgetFactory.drawBorder", Boolean.FALSE);
    
    numColumns = headerComposite.getChildren().length;
    toolkit.paintBordersFor(headerComposite);
    return headerComposite;
  }
  
  public void setFocus()
  {
    if (summaryEditor != null) {
      summaryEditor.getControl().setFocus();
    }
  }
  
  private String getDateString(Date date)
  {
    if (date == null) {
      return "-";
    }
    return EditorUtil.getDateFormat().format(date);
  }
  
  private String getDateTimeString(Date date)
  {
    if (date == null) {
      return "-";
    }
    return EditorUtil.getDateTimeFormat().format(date);
  }
  
  public void refresh(boolean discardChanges)
  {
    if (shouldRefresh(priorityEditor.getControl(), discardChanges))
    {
      ITask.PriorityLevel level = ITask.PriorityLevel.fromString(getTask().getPriority());
      priorityEditor.select(level.toString(), level);
    }
    if (shouldRefresh(statusCompleteButton, discardChanges))
    {
      statusIncompleteButton.setSelection(!getTask().isCompleted());
      statusCompleteButton.setSelection(getTask().isCompleted());
    }
    if (shouldRefresh(summaryEditor.getControl(), discardChanges))
    {
      summaryEditor.setText(getTask().getSummary());
      if (!initialized)
      {
        initialized = true;
        if (LocalRepositoryConnector.DEFAULT_SUMMARY.equals(getTask().getSummary())) {
          summaryEditor.getViewer().setSelectedRange(0, summaryEditor.getText().length());
        }
      }
    }
    creationDateText.setText(getDateString(getTask().getCreationDate()));
    updateToolTip(creationDateText, getTask().getCreationDate());
    completionDateText.setText(getDateString(getTask().getCompletionDate()));
    updateToolTip(completionDateText, getTask().getCompletionDate());
    
    headerComposite.layout(true);
  }
  
  private void updateToolTip(Text text, Date date)
  {
    if (date != null) {
      text.setToolTipText(getDateTimeString(date));
    } else {
      text.setToolTipText(null);
    }
  }
  
  public void commit(boolean onSave)
  {
    ITask.PriorityLevel level = ITask.PriorityLevel.fromString(priorityEditor.getValue());
    if (level != null) {
      getTask().setPriority(level.toString());
    }
    clearState(priorityEditor.getControl());
    getTask().setSummary(summaryEditor.getText());
    clearState(summaryEditor.getControl());
    if (statusCompleteButton.getSelection())
    {
      if (!getTask().isCompleted()) {
        getTask().setCompletionDate(new Date());
      }
    }
    else if (getTask().isCompleted()) {
      getTask().setCompletionDate(null);
    }
    clearState(statusCompleteButton);
    super.commit(onSave);
  }
  
  public void setTextSupport(CommonTextSupport textSupport)
  {
    this.textSupport = textSupport;
  }
  
  public CommonTextSupport getTextSupport()
  {
    return textSupport;
  }
  
  public void setSummary(String value)
  {
    if (!summaryEditor.getControl().isDisposed()) {
      summaryEditor.setText(value);
    }
  }
  
  protected String getCreatedDateLabel()
  {
    return Messages.TaskPlanningEditor_Created;
  }
  
  protected boolean isSummaryEditable()
  {
    return getTask() instanceof LocalTask;
  }
}

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

import org.eclipse.jface.resource.ColorRegistry;
import org.eclipse.jface.viewers.ColumnLabelProvider;
import org.eclipse.jface.viewers.ILabelProviderListener;
import org.eclipse.jface.viewers.ViewerCell;
import org.eclipse.mylyn.commons.ui.CommonImages;
import org.eclipse.mylyn.commons.workbench.CommonImageManger;
import org.eclipse.mylyn.internal.tasks.ui.util.AttachmentUtil;
import org.eclipse.mylyn.tasks.core.IRepositoryPerson;
import org.eclipse.mylyn.tasks.core.ITaskAttachment;
import org.eclipse.mylyn.tasks.core.TaskRepository;
import org.eclipse.mylyn.tasks.core.data.TaskDataModel;
import org.eclipse.mylyn.tasks.ui.TasksUiImages;
import org.eclipse.mylyn.tasks.ui.editors.AttributeEditorToolkit;
import org.eclipse.swt.graphics.Color;
import org.eclipse.swt.graphics.Image;
import org.eclipse.swt.graphics.Point;
import org.eclipse.ui.IWorkbench;
import org.eclipse.ui.PlatformUI;
import org.eclipse.ui.themes.ITheme;
import org.eclipse.ui.themes.IThemeManager;

public class AttachmentTableLabelProvider
  extends ColumnLabelProvider
{
  private final AttachmentSizeFormatter sizeFormatter = AttachmentSizeFormatter.getInstance();
  private final TaskDataModel model;
  private final AttributeEditorToolkit attributeEditorToolkit;
  private final CommonImageManger imageManager;
  
  public AttachmentTableLabelProvider(TaskDataModel model, AttributeEditorToolkit attributeEditorToolkit)
  {
    this.model = model;
    this.attributeEditorToolkit = attributeEditorToolkit;
    imageManager = new CommonImageManger();
  }
  
  public Image getColumnImage(Object element, int columnIndex)
  {
    ITaskAttachment attachment = (ITaskAttachment)element;
    if (columnIndex == 0)
    {
      if (AttachmentUtil.isContext(attachment)) {
        return imageManager.getImage(TasksUiImages.CONTEXT_TRANSFER);
      }
      if (attachment.isPatch()) {
        return imageManager.getImage(TasksUiImages.TASK_ATTACHMENT_PATCH);
      }
      return imageManager.getFileImage(attachment.getFileName());
    }
    if ((columnIndex == 3) && (attachment.getAuthor() != null)) {
      return getAuthorImage(attachment.getAuthor(), attachment.getTaskRepository());
    }
    return null;
  }
  
  protected Image getAuthorImage(IRepositoryPerson person, TaskRepository repository)
  {
    if ((repository != null) && (person != null) && (person.getPersonId().equals(repository.getUserName()))) {
      return imageManager.getImage(CommonImages.PERSON_ME);
    }
    return imageManager.getImage(CommonImages.PERSON);
  }
  
  public String getColumnText(Object element, int columnIndex)
  {
    ITaskAttachment attachment = (ITaskAttachment)element;
    switch (columnIndex)
    {
    case 0: 
      if (AttachmentUtil.isContext(attachment)) {
        return Messages.AttachmentTableLabelProvider_Task_Context;
      }
      if (attachment.isPatch()) {
        return Messages.AttachmentTableLabelProvider_Patch;
      }
      return " " + attachment.getFileName();
    case 1: 
      return attachment.getDescription();
    case 2: 
      Long length = Long.valueOf(attachment.getLength());
      if (length.longValue() < 0L) {
        return "-";
      }
      return sizeFormatter.format(length.longValue());
    case 3: 
      return attachment.getAuthor() != null ? attachment.getAuthor().toString() : "";
    case 4: 
      return attachment.getCreationDate() != null ? 
        EditorUtil.formatDateTime(attachment.getCreationDate()) : 
        "";
    case 5: 
      return getAttachmentId(attachment);
    }
    return "unrecognized column";
  }
  
  static String getAttachmentId(ITaskAttachment attachment)
  {
    String a = attachment.getUrl();
    if (a != null)
    {
      int i = a.indexOf("?id=");
      if (i != -1) {
        return a.substring(i + 4);
      }
    }
    return "";
  }
  
  public void addListener(ILabelProviderListener listener) {}
  
  public void dispose()
  {
    imageManager.dispose();
  }
  
  public boolean isLabelProperty(Object element, String property)
  {
    return false;
  }
  
  public void removeListener(ILabelProviderListener listener) {}
  
  public Color getForeground(Object element)
  {
    ITaskAttachment att = (ITaskAttachment)element;
    if (att.isDeprecated())
    {
      IThemeManager themeManager = PlatformUI.getWorkbench().getThemeManager();
      return themeManager.getCurrentTheme().getColorRegistry().get("org.eclipse.mylyn.tasks.ui.colors.foreground.completed");
    }
    return super.getForeground(element);
  }
  
  public String getToolTipText(Object element)
  {
    ITaskAttachment attachment = (ITaskAttachment)element;
    StringBuilder sb = new StringBuilder();
    sb.append(Messages.AttachmentTableLabelProvider_File_);
    sb.append(attachment.getFileName());
    if (attachment.getContentType() != null)
    {
      sb.append("\n");
      sb.append(Messages.AttachmentTableLabelProvider_Type_);
      sb.append(attachment.getContentType());
    }
    return sb.toString();
  }
  
  public Point getToolTipShift(Object object)
  {
    return new Point(5, 5);
  }
  
  public int getToolTipDisplayDelayTime(Object object)
  {
    return 200;
  }
  
  public int getToolTipTimeDisplayed(Object object)
  {
    return 5000;
  }
  
  public void update(ViewerCell cell)
  {
    Object element = cell.getElement();
    cell.setText(getColumnText(element, cell.getColumnIndex()));
    Image image = getColumnImage(element, cell.getColumnIndex());
    cell.setImage(image);
    cell.setBackground(getBackground(element));
    cell.setForeground(getForeground(element));
    cell.setFont(getFont(element));
  }
  
  public Color getBackground(Object element)
  {
    if ((model != null) && (attributeEditorToolkit != null))
    {
      ITaskAttachment attachment = (ITaskAttachment)element;
      if (model.hasIncomingChanges(attachment.getTaskAttribute())) {
        return attributeEditorToolkit.getColorIncoming();
      }
    }
    return null;
  }
}

/* Location:
 * Qualified Name:     org.eclipse.mylyn.internal.tasks.ui.editors.AttachmentTableLabelProvider
 * 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.util.AbstractRetrieveTitleFromUrlJob;
import org.eclipse.ui.forms.IFormPart;
import org.eclipse.ui.forms.IManagedForm;

class AttributePart$4
  extends AbstractRetrieveTitleFromUrlJob
{
  AttributePart$4(AttributePart paramAttributePart, String $anonymous0)
  {
    super($anonymous0);
  }
  
  protected void titleRetrieved(String pageTitle)
  {
    IFormPart[] parts = this$0.getManagedForm().getParts();
    IFormPart[] arrayOfIFormPart1;
    int j = (arrayOfIFormPart1 = parts).length;
    for (int i = 0; i < j; i++)
    {
      IFormPart part = arrayOfIFormPart1[i];
      if ((part instanceof SummaryPart)) {
        ((SummaryPart)part).setSummary(pageTitle);
      }
    }
  }
}

/* Location:
 * Qualified Name:     org.eclipse.mylyn.internal.tasks.ui.editors.AttributePart.4
 * 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.TreeViewer;
import org.eclipse.mylyn.tasks.core.TaskRepository;
import org.eclipse.swt.widgets.Composite;
import org.eclipse.swt.widgets.Control;
import org.eclipse.ui.views.contentoutline.ContentOutlinePage;

public class TaskEditorOutlinePage
  extends ContentOutlinePage
{
  private TaskEditorOutlineModel model;
  private TreeViewer viewer;
  
  public void setInput(TaskRepository taskRepository, TaskEditorOutlineNode rootNode)
  {
    if (rootNode != null) {
      model = new TaskEditorOutlineModel(rootNode);
    } else {
      model = null;
    }
    if ((viewer != null) && (viewer.getControl() != null) && (!viewer.getControl().isDisposed()))
    {
      viewer.setInput(model);
      viewer.expandAll();
      viewer.refresh(true);
    }
  }
  
  public void createControl(Composite parent)
  {
    super.createControl(parent);
    viewer = getTreeViewer();
    viewer.setContentProvider(new TaskEditorOutlineContentProvider());
    viewer.setLabelProvider(new TaskEditorOutlineNodeLabelProvider());
    viewer.setInput(model);
    viewer.expandAll();
  }
}

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

import java.util.Collection;
import java.util.Set;
import org.eclipse.core.runtime.CoreException;
import org.eclipse.core.runtime.IProgressMonitor;
import org.eclipse.core.runtime.ISafeRunnable;
import org.eclipse.core.runtime.NullProgressMonitor;
import org.eclipse.core.runtime.SafeRunner;
import org.eclipse.core.runtime.Status;
import org.eclipse.jface.action.ControlContribution;
import org.eclipse.jface.action.IToolBarManager;
import org.eclipse.jface.layout.GridDataFactory;
import org.eclipse.jface.viewers.StructuredSelection;
import org.eclipse.mylyn.commons.core.StatusHandler;
import org.eclipse.mylyn.commons.ui.CommonImages;
import org.eclipse.mylyn.commons.ui.SelectionProviderAdapter;
import org.eclipse.mylyn.commons.workbench.editors.CommonTextSupport;
import org.eclipse.mylyn.internal.tasks.core.AbstractTask;
import org.eclipse.mylyn.internal.tasks.core.ITaskList;
import org.eclipse.mylyn.internal.tasks.core.ITaskListChangeListener;
import org.eclipse.mylyn.internal.tasks.core.LocalTask;
import org.eclipse.mylyn.internal.tasks.core.TaskActivityManager;
import org.eclipse.mylyn.internal.tasks.core.TaskContainerDelta;
import org.eclipse.mylyn.internal.tasks.ui.TasksUiPlugin;
import org.eclipse.mylyn.internal.tasks.ui.actions.NewSubTaskAction;
import org.eclipse.mylyn.internal.tasks.ui.util.TasksUiInternal;
import org.eclipse.mylyn.tasks.core.AbstractRepositoryConnector;
import org.eclipse.mylyn.tasks.core.IRepositoryManager;
import org.eclipse.mylyn.tasks.core.ITask;
import org.eclipse.mylyn.tasks.core.ITaskActivityListener;
import org.eclipse.mylyn.tasks.core.TaskRepository;
import org.eclipse.mylyn.tasks.core.data.ITaskDataManager;
import org.eclipse.mylyn.tasks.core.data.TaskData;
import org.eclipse.mylyn.tasks.ui.TasksUi;
import org.eclipse.mylyn.tasks.ui.editors.TaskEditor;
import org.eclipse.mylyn.tasks.ui.editors.TaskEditorInput;
import org.eclipse.mylyn.tasks.ui.editors.TaskFormPage;
import org.eclipse.swt.layout.GridData;
import org.eclipse.swt.layout.GridLayout;
import org.eclipse.swt.widgets.Button;
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.ui.IEditorInput;
import org.eclipse.ui.IEditorSite;
import org.eclipse.ui.IPropertyListener;
import org.eclipse.ui.IWorkbench;
import org.eclipse.ui.IWorkbenchPartSite;
import org.eclipse.ui.PlatformUI;
import org.eclipse.ui.forms.IFormPart;
import org.eclipse.ui.forms.IManagedForm;
import org.eclipse.ui.forms.widgets.FormToolkit;
import org.eclipse.ui.forms.widgets.ScrolledForm;
import org.eclipse.ui.forms.widgets.Section;
import org.eclipse.ui.handlers.IHandlerService;

public class TaskPlanningEditor
  extends TaskFormPage
{
  private Composite editorComposite;
  private TaskRepository repository;
  private AbstractTask task;
  private Button saveButton;
  private final IPropertyListener dirtyStateListener = new IPropertyListener()
  {
    public void propertyChanged(Object source, int propId)
    {
      if ((propId == 257) && (saveButton != null)) {
        saveButton.setEnabled(getEditor().isDirty());
      }
    }
  };
  private final ITaskListChangeListener taskListChangeListener = new TaskListChangeAdapter()
  {
    public void containersChanged(Set<TaskContainerDelta> containers)
    {
      for (TaskContainerDelta taskContainerDelta : containers) {
        if ((taskContainerDelta.getElement() instanceof ITask))
        {
          AbstractTask updateTask = (AbstractTask)taskContainerDelta.getElement();
          if ((updateTask != null) && (task != null) && 
            (updateTask.getHandleIdentifier().equals(task.getHandleIdentifier())))
          {
            if ((PlatformUI.getWorkbench() == null) || (PlatformUI.getWorkbench().isClosing())) {
              break;
            }
            PlatformUI.getWorkbench().getDisplay().asyncExec(new Runnable()
            {
              public void run()
              {
                refresh();
              }
            });
            break;
          }
        }
      }
    }
  };
  private CommonTextSupport textSupport;
  private ITaskActivityListener timingListener;
  private FormToolkit toolkit;
  private FocusTracker focusTracker;
  
  public TaskPlanningEditor(TaskEditor editor)
  {
    super(editor, "org.eclipse.mylyn.tasks.ui.pageFactory.Planning", Messages.TaskPlanningEditor_Planning);
    TasksUiInternal.getTaskList().addChangeListener(taskListChangeListener);
  }
  
  private void createContributions(final Composite editorComposite)
  {
    Collection<LocalTaskEditorContributionDescriptor> localEditorContributions = TaskEditorContributionExtensionReader.getLocalEditorContributions();
    for (final LocalTaskEditorContributionDescriptor descriptor : localEditorContributions) {
      SafeRunner.run(new ISafeRunnable()
      {
        public void handleException(Throwable e)
        {
          StatusHandler.log(new Status(4, "org.eclipse.mylyn.tasks.ui", 
            "Error creating task editor contribution: \"" + descriptor.getId() + "\"", e));
        }
        
        public void run()
          throws Exception
        {
          AbstractLocalEditorPart part = descriptor.createPart();
          TaskPlanningEditor.this.initializePart(editorComposite, part);
        }
      });
    }
  }
  
  protected void createFormContent(IManagedForm managedForm)
  {
    super.createFormContent(managedForm);
    
    TaskEditorInput taskEditorInput = (TaskEditorInput)getEditorInput();
    task = ((AbstractTask)taskEditorInput.getTask());
    repository = TasksUi.getRepositoryManager().getRepository(task.getConnectorKind(), task.getRepositoryUrl());
    
    toolkit = managedForm.getToolkit();
    
    editorComposite = managedForm.getForm().getBody();
    GridLayout layout = new GridLayout();
    verticalSpacing = 0;
    editorComposite.setLayout(layout);
    if ((task instanceof LocalTask))
    {
      SummaryPart part = new SummaryPart();
      part.setTextSupport(textSupport);
      initializePart(editorComposite, part);
      initializePart(editorComposite, new AttributePart());
      
      createContributions(editorComposite);
    }
    PlanningPart planningPart = new PlanningPart(0);
    
    boolean needsDueDate = true;
    if (task != null) {
      try
      {
        TaskData taskData = TasksUi.getTaskDataManager().getTaskData(task);
        if (taskData != null)
        {
          AbstractRepositoryConnector connector = TasksUi.getRepositoryConnector(taskData.getConnectorKind());
          TaskRepository taskRepository = TasksUi.getRepositoryManager().getRepository(
            taskData.getConnectorKind(), taskData.getRepositoryUrl());
          if ((connector != null) && (taskRepository != null) && 
            (connector.hasRepositoryDueDate(taskRepository, task, taskData))) {
            needsDueDate = false;
          }
        }
      }
      catch (CoreException localCoreException) {}
    }
    planningPart.initialize(getManagedForm(), repository, task, needsDueDate, this, textSupport);
    planningPart.createControl(editorComposite, toolkit);
    planningPart.getSection().setLayoutData(new GridData(1808));
    getManagedForm().addPart(planningPart);
    
    focusTracker = new FocusTracker();
    focusTracker.track(editorComposite);
  }
  
  public void dispose()
  {
    getEditor().removePropertyListener(dirtyStateListener);
    if (timingListener != null) {
      TasksUiPlugin.getTaskActivityManager().removeActivityListener(timingListener);
    }
    TasksUiInternal.getTaskList().removeChangeListener(taskListChangeListener);
    super.dispose();
  }
  
  public void doSave(IProgressMonitor monitor)
  {
    super.doSave(monitor);
    
    TasksUiInternal.getTaskList().notifyElementChanged(task);
  }
  
  public void doSaveAs() {}
  
  public void fillToolBar(IToolBarManager toolBarManager)
  {
    TaskEditorInput taskEditorInput = (TaskEditorInput)getEditorInput();
    ITask task = taskEditorInput.getTask();
    if (((task instanceof LocalTask)) && 
      (task.getAttribute("outgoingNewConnectorKind") == null))
    {
      NewSubTaskAction newSubTaskAction = new NewSubTaskAction();
      newSubTaskAction.selectionChanged(newSubTaskAction, new StructuredSelection(task));
      if (newSubTaskAction.isEnabled()) {
        toolBarManager.add(newSubTaskAction);
      }
    }
  }
  
  public TaskEditor getEditor()
  {
    return (TaskEditor)super.getEditor();
  }
  
  public void init(IEditorSite site, IEditorInput input)
  {
    super.init(site, input);
    textSupport = new CommonTextSupport((IHandlerService)getSite().getService(IHandlerService.class));
    textSupport.setSelectionChangedListener((TaskEditorActionContributor)getEditorSite().getActionBarContributor());
    
    site.setSelectionProvider(new SelectionProviderAdapter(new StructuredSelection(
      ((TaskEditorInput)input).getTask())));
  }
  
  private void initializePart(Composite editorComposite, AbstractLocalEditorPart part)
  {
    part.initialize(getManagedForm(), repository, task);
    Control control = part.createControl(editorComposite, toolkit);
    part.setControl(control);
    GridDataFactory.fillDefaults().grab(true, false).applyTo(control);
    getManagedForm().addPart(part);
  }
  
  public boolean isSaveAsAllowed()
  {
    return false;
  }
  
  public void refresh()
  {
    if ((getManagedForm() == null) || (getManagedForm().getForm().isDisposed())) {
      return;
    }
    getEditor().updateHeaderToolBar();
    IFormPart[] parts = getManagedForm().getParts();
    IFormPart[] arrayOfIFormPart1;
    int j = (arrayOfIFormPart1 = parts).length;
    for (int i = 0; i < j; i++)
    {
      IFormPart part = arrayOfIFormPart1[i];
      if ((part instanceof AbstractLocalEditorPart)) {
        ((AbstractLocalEditorPart)part).refresh(false);
      } else {
        part.refresh();
      }
    }
    getManagedForm().reflow(true);
  }
  
  public void fillLeftHeaderToolBar(IToolBarManager toolBarManager)
  {
    if (((getEditorInput() instanceof TaskEditorInput)) && 
      ((((TaskEditorInput)getEditorInput()).getTask() instanceof LocalTask)))
    {
      ControlContribution submitButtonContribution = new ControlContribution(
        "org.eclipse.mylyn.tasks.toolbars.save")
        {
          protected Control createControl(Composite parent)
          {
            saveButton = new Button(parent, 8388608);
            saveButton.setText(Messages.TaskPlanningEditor_Save);
            saveButton.setImage(CommonImages.getImage(CommonImages.SAVE));
            saveButton.setBackground(null);
            saveButton.addListener(13, new Listener()
            {
              public void handleEvent(Event e)
              {
                doSave(new NullProgressMonitor());
              }
            });
            saveButton.setEnabled(getEditor().isDirty());
            
            return saveButton;
          }
        };
        getEditor().addPropertyListener(dirtyStateListener);
        toolBarManager.add(submitButtonContribution);
      }
    }
    
    public void setFocus()
    {
      if (focusTracker.setFocus()) {
        return;
      }
      IFormPart[] parts = getManagedForm().getParts();
      if (parts.length > 0)
      {
        parts[0].setFocus();
        return;
      }
      super.setFocus();
    }
  }

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

import java.util.HashMap;
import java.util.Map;
import org.eclipse.core.runtime.Assert;
import org.eclipse.core.runtime.IAdaptable;
import org.eclipse.jface.text.TextAttribute;
import org.eclipse.jface.text.contentassist.ContentAssistant;
import org.eclipse.jface.text.contentassist.IContentAssistant;
import org.eclipse.jface.text.hyperlink.AbstractHyperlinkDetector;
import org.eclipse.jface.text.hyperlink.IHyperlinkDetector;
import org.eclipse.jface.text.hyperlink.IHyperlinkPresenter;
import org.eclipse.jface.text.presentation.IPresentationReconciler;
import org.eclipse.jface.text.presentation.PresentationReconciler;
import org.eclipse.jface.text.reconciler.IReconciler;
import org.eclipse.jface.text.rules.DefaultDamagerRepairer;
import org.eclipse.jface.text.rules.IRule;
import org.eclipse.jface.text.rules.IToken;
import org.eclipse.jface.text.rules.RuleBasedScanner;
import org.eclipse.jface.text.rules.SingleLineRule;
import org.eclipse.jface.text.rules.Token;
import org.eclipse.jface.text.source.ISourceViewer;
import org.eclipse.mylyn.commons.ui.compatibility.CommonColors;
import org.eclipse.mylyn.tasks.core.ITask;
import org.eclipse.mylyn.tasks.core.TaskRepository;
import org.eclipse.mylyn.tasks.ui.TaskHyperlinkPresenter;
import org.eclipse.swt.graphics.RGB;
import org.eclipse.ui.editors.text.EditorsUI;
import org.eclipse.ui.editors.text.TextSourceViewerConfiguration;

public class RepositoryTextViewerConfiguration
  extends TextSourceViewerConfiguration
{
  private static final String ID_CONTEXT_EDITOR_TASK = "org.eclipse.mylyn.tasks.ui.TaskEditor";
  private static final String ID_CONTEXT_EDITOR_TEXT = "org.eclipse.ui.DefaultTextEditor";
  private RepositoryTextScanner scanner;
  private final boolean spellCheck;
  private final TaskRepository taskRepository;
  private Mode mode;
  private final ITask task;
  
  public static enum Mode
  {
    URL,  TASK,  TASK_RELATION,  DEFAULT;
  }
  
  @Deprecated
  public RepositoryTextViewerConfiguration(TaskRepository taskRepository, boolean spellCheck)
  {
    this(taskRepository, null, spellCheck);
  }
  
  public RepositoryTextViewerConfiguration(TaskRepository taskRepository, ITask task, boolean spellCheck)
  {
    super(EditorsUI.getPreferenceStore());
    this.taskRepository = taskRepository;
    this.spellCheck = spellCheck;
    mode = Mode.DEFAULT;
    this.task = task;
  }
  
  public Mode getMode()
  {
    return mode;
  }
  
  public void setMode(Mode mode)
  {
    Assert.isNotNull(mode);
    this.mode = mode;
  }
  
  public IPresentationReconciler getPresentationReconciler(ISourceViewer sourceViewer)
  {
    if (getMode() == Mode.DEFAULT)
    {
      PresentationReconciler reconciler = new PresentationReconciler();
      reconciler.setDocumentPartitioning(getConfiguredDocumentPartitioning(sourceViewer));
      DefaultDamagerRepairer dr = new DefaultDamagerRepairer(getDefaultScanner());
      reconciler.setDamager(dr, "__dftl_partition_content_type");
      reconciler.setRepairer(dr, "__dftl_partition_content_type");
      return reconciler;
    }
    return super.getPresentationReconciler(sourceViewer);
  }
  
  private RepositoryTextScanner getDefaultScanner()
  {
    if (scanner == null) {
      scanner = new RepositoryTextScanner(getMode());
    }
    return scanner;
  }
  
  public IHyperlinkDetector[] getHyperlinkDetectors(ISourceViewer sourceViewer)
  {
    if ((mode == Mode.URL) || (mode == Mode.TASK_RELATION)) {
      return getDefaultHyperlinkDetectors(sourceViewer, mode);
    }
    return super.getHyperlinkDetectors(sourceViewer);
  }
  
  public IHyperlinkDetector[] getDefaultHyperlinkDetectors(ISourceViewer sourceViewer, Mode mode)
  {
    IHyperlinkDetector[] detectors;
    IHyperlinkDetector[] detectors;
    if (mode == Mode.URL)
    {
      detectors = new IHyperlinkDetector[] { new TaskUrlHyperlinkDetector() };
    }
    else
    {
      IHyperlinkDetector[] detectors;
      if (mode == Mode.TASK)
      {
        detectors = new IHyperlinkDetector[] { new TaskHyperlinkDetector() };
      }
      else
      {
        IHyperlinkDetector[] detectors;
        if (mode == Mode.TASK_RELATION) {
          detectors = new IHyperlinkDetector[] { new TaskRelationHyperlinkDetector() };
        } else {
          detectors = super.getHyperlinkDetectors(sourceViewer);
        }
      }
    }
    if (detectors != null)
    {
      IAdaptable target = getDefaultHyperlinkTarget();
      IHyperlinkDetector[] arrayOfIHyperlinkDetector1;
      int j = (arrayOfIHyperlinkDetector1 = detectors).length;
      for (int i = 0; i < j; i++)
      {
        IHyperlinkDetector hyperlinkDetector = arrayOfIHyperlinkDetector1[i];
        if ((hyperlinkDetector instanceof AbstractHyperlinkDetector)) {
          ((AbstractHyperlinkDetector)hyperlinkDetector).setContext(target);
        }
      }
    }
    return detectors;
  }
  
  protected Map getHyperlinkDetectorTargets(ISourceViewer sourceViewer)
  {
    IAdaptable context = getDefaultHyperlinkTarget();
    
    Map<String, IAdaptable> targets = new HashMap();
    targets.put("org.eclipse.ui.DefaultTextEditor", context);
    targets.put("org.eclipse.mylyn.tasks.ui.TaskEditor", context);
    return targets;
  }
  
  private IAdaptable getDefaultHyperlinkTarget()
  {
    IAdaptable context = new IAdaptable()
    {
      public Object getAdapter(Class adapter)
      {
        if (adapter == TaskRepository.class) {
          return getTaskRepository();
        }
        if (adapter == ITask.class) {
          return getTask();
        }
        return null;
      }
    };
    return context;
  }
  
  public TaskRepository getTaskRepository()
  {
    return taskRepository;
  }
  
  public IHyperlinkPresenter getHyperlinkPresenter(ISourceViewer sourceViewer)
  {
    if (fPreferenceStore == null) {
      return new TaskHyperlinkPresenter(new RGB(0, 0, 255));
    }
    return new TaskHyperlinkPresenter(fPreferenceStore);
  }
  
  public int getHyperlinkStateMask(ISourceViewer sourceViewer)
  {
    return 0;
  }
  
  public IReconciler getReconciler(ISourceViewer sourceViewer)
  {
    if (spellCheck) {
      return super.getReconciler(sourceViewer);
    }
    return null;
  }
  
  private static class RepositoryTextScanner
    extends RuleBasedScanner
  {
    public RepositoryTextScanner(RepositoryTextViewerConfiguration.Mode mode)
    {
      IToken quoteToken = new Token(new TextAttribute(CommonColors.TEXT_QUOTED));
      IRule[] rules = new IRule[1];
      SingleLineRule quoteRule = new SingleLineRule(">", null, quoteToken, '\000', true);
      quoteRule.setColumnConstraint(0);
      rules[0] = quoteRule;
      setRules(rules);
    }
  }
  
  public IContentAssistant getContentAssistant(ISourceViewer sourceViewer)
  {
    if (mode == Mode.URL) {
      return null;
    }
    ContentAssistant assistant = new ContentAssistant();
    RepositoryCompletionProcessor processor = new RepositoryCompletionProcessor(taskRepository);
    if (mode == Mode.TASK_RELATION) {
      processor.setNeverIncludePrefix(true);
    }
    assistant.setContentAssistProcessor(processor, "__dftl_partition_content_type");
    return assistant;
  }
  
  public ITask getTask()
  {
    return task;
  }
}

/* Location:
 * Qualified Name:     org.eclipse.mylyn.internal.tasks.ui.editors.RepositoryTextViewerConfiguration
 * 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$1
  extends Action
{
  TaskEditorRichTextPart$1(TaskEditorRichTextPart paramTaskEditorRichTextPart, String $anonymous0, int $anonymous1)
  {
    super($anonymous0, $anonymous1);
  }
  
  public void run()
  {
    if (isChecked()) {
      TaskEditorRichTextPart.access$0(this$0).showEditor();
    } else {
      TaskEditorRichTextPart.access$0(this$0).showPreview();
    }
    if (TaskEditorRichTextPart.access$1(this$0) != null) {
      TaskEditorRichTextPart.access$1(this$0).setChecked(false);
    }
  }
}

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

import java.util.Comparator;
import org.eclipse.jface.text.IRegion;

public class AbstractHyperlinkTextPresentationManager$RegionComparator
  implements Comparator<IRegion>
{
  public int compare(IRegion o1, IRegion o2)
  {
    if (o1 == o2) {
      return 0;
    }
    if (o1.getOffset() < o2.getOffset()) {
      return -1;
    }
    if (o1.getOffset() > o2.getOffset()) {
      return 1;
    }
    if (o1.getLength() < o2.getLength()) {
      return -1;
    }
    if (o1.getLength() > o2.getLength()) {
      return 1;
    }
    return 0;
  }
}

/* Location:
 * Qualified Name:     org.eclipse.mylyn.internal.tasks.ui.editors.AbstractHyperlinkTextPresentationManager.RegionComparator
 * 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.SelectionAdapter;
import org.eclipse.swt.events.SelectionEvent;
import org.eclipse.swt.widgets.Widget;

class TaskEditorExtensionSettingsContribution$1
  extends SelectionAdapter
{
  TaskEditorExtensionSettingsContribution$1(TaskEditorExtensionSettingsContribution paramTaskEditorExtensionSettingsContribution) {}
  
  public void widgetSelected(SelectionEvent e)
  {
    TaskEditorExtensionSettingsContribution.access$0(this$0, (String)((Widget)e.getSource()).getData("editorExtension"));
    TaskEditorExtensionSettingsContribution.access$1(this$0);
  }
}

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

import java.util.Date;
import org.eclipse.core.runtime.CoreException;
import org.eclipse.core.runtime.ISafeRunnable;
import org.eclipse.core.runtime.Status;
import org.eclipse.mylyn.commons.core.StatusHandler;
import org.eclipse.mylyn.internal.tasks.core.AbstractTask;
import org.eclipse.mylyn.internal.tasks.core.DateRange;
import org.eclipse.mylyn.internal.tasks.core.ITaskList;
import org.eclipse.mylyn.internal.tasks.core.TaskActivityManager;
import org.eclipse.mylyn.internal.tasks.core.data.TaskDataManager;
import org.eclipse.mylyn.internal.tasks.ui.TasksUiPlugin;
import org.eclipse.mylyn.internal.tasks.ui.util.TasksUiInternal;
import org.eclipse.mylyn.tasks.core.AbstractRepositoryConnector;
import org.eclipse.mylyn.tasks.core.ITask;
import org.eclipse.mylyn.tasks.core.TaskMigrationEvent;
import org.eclipse.mylyn.tasks.core.context.AbstractTaskContextStore;
import org.eclipse.mylyn.tasks.ui.editors.TaskEditor;
import org.eclipse.ui.IWorkbench;
import org.eclipse.ui.IWorkbenchPage;
import org.eclipse.ui.IWorkbenchWindow;
import org.eclipse.ui.PlatformUI;

public class TaskMigrator
{
  private static boolean active;
  private final ITask oldTask;
  private boolean delete;
  private boolean openEditors;
  pr
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