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

lipse.mylyn.tasks.core.data.TaskData;
import org.eclipse.mylyn.tasks.ui.TasksUi;
import org.eclipse.mylyn.tasks.ui.TasksUiImages;
import org.eclipse.swt.graphics.Image;
import org.eclipse.ui.ISharedImages;
import org.eclipse.ui.IWorkbench;
import org.eclipse.ui.PlatformUI;
import org.eclipse.ui.internal.WorkbenchImages;

public class TaskEditorOutlineNodeLabelProvider
  extends LabelProvider
{
  private static final String[] IMAGE_EXTENSIONS = { "jpg", "gif", "png", "tiff", "tif", "bmp" };
  
  public Image getImage(Object element)
  {
    if ((element instanceof TaskEditorOutlineNode))
    {
      TaskEditorOutlineNode node = (TaskEditorOutlineNode)element;
      if ((TaskEditorOutlineNode.LABEL_COMMENTS.equals(node.getLabel())) || 
        (TaskEditorOutlineNode.LABEL_NEW_COMMENT.equals(node.getLabel()))) {
        return CommonImages.getImage(TasksUiImages.COMMENT);
      }
      if (TaskEditorOutlineNode.LABEL_DESCRIPTION.equals(node.getLabel())) {
        return CommonImages.getImage(TasksUiImages.TASK_NOTES);
      }
      if (node.getTaskComment() != null)
      {
        IRepositoryPerson author = node.getTaskComment().getAuthor();
        TaskAttribute taskAttribute = node.getData();
        String repositoryUrl = taskAttribute.getTaskData().getRepositoryUrl();
        String connectorKind = null;
        TaskRepository taskRepository = null;
        if (repositoryUrl != null)
        {
          connectorKind = taskAttribute.getTaskData().getConnectorKind();
          if (connectorKind != null) {
            taskRepository = TasksUi.getRepositoryManager().getRepository(connectorKind, repositoryUrl);
          }
        }
        if ((taskRepository != null) && (author != null) && 
          (author.getPersonId().equals(taskRepository.getUserName()))) {
          return CommonImages.getImage(CommonImages.PERSON_ME);
        }
        return CommonImages.getImage(CommonImages.PERSON);
      }
      if (node.getTaskAttachment() != null)
      {
        ITaskAttachment attachment = node.getTaskAttachment();
        if (AttachmentUtil.isContext(attachment)) {
          return CommonImages.getImage(TasksUiImages.CONTEXT_TRANSFER);
        }
        if (attachment.isPatch()) {
          return CommonImages.getImage(TasksUiImages.TASK_ATTACHMENT_PATCH);
        }
        String filename = attachment.getFileName();
        if (filename != null)
        {
          int dotIndex = filename.lastIndexOf('.');
          if (dotIndex != -1)
          {
            String fileType = filename.substring(dotIndex + 1);
            String[] arrayOfString;
            int j = (arrayOfString = IMAGE_EXTENSIONS).length;
            for (int i = 0; i < j; i++)
            {
              String element2 = arrayOfString[i];
              if (element2.equalsIgnoreCase(fileType)) {
                return CommonImages.getImage(CommonImages.IMAGE_FILE);
              }
            }
          }
        }
        return WorkbenchImages.getImage("IMG_OBJ_FILE");
      }
      if (node.getParent() == null) {
        return CommonImages.getImage(TasksUiImages.TASK);
      }
      if ((TaskEditorOutlineNode.LABEL_RELATED_TASKS.equals(node.getLabel())) || 
        (TaskEditorOutlineNode.LABEL_ATTRIBUTES.equals(node.getLabel()))) {
        return PlatformUI.getWorkbench().getSharedImages().getImage("IMG_OBJ_FOLDER");
      }
      return CommonImages.getImage(TasksUiImages.TASK);
    }
    return null;
  }
  
  public String getText(Object element)
  {
    if ((element instanceof TaskEditorOutlineNode))
    {
      TaskEditorOutlineNode node = (TaskEditorOutlineNode)element;
      if ((TaskEditorOutlineNode.LABEL_COMMENTS.equals(node.getLabel())) || 
        (TaskEditorOutlineNode.LABEL_NEW_COMMENT.equals(node.getLabel())) || 
        (TaskEditorOutlineNode.LABEL_DESCRIPTION.equals(node.getLabel()))) {
        return node.getLabel();
      }
      if ((node.getData() != null) && (node.getTaskAttachment() == null) && (node.getTaskComment() == null))
      {
        TaskAttribute taskAttribute = node.getData();
        String label = taskAttribute.getTaskData().getAttributeMapper().getLabel(taskAttribute);
        if (!label.endsWith(":")) {
          label = label + ":";
        }
        return label + " " + taskAttribute.getTaskData().getAttributeMapper().getValueLabel(taskAttribute);
      }
      return node.getLabel();
    }
    return super.getText(element);
  }
}

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

import java.util.Calendar;
import java.util.Set;
import org.eclipse.core.runtime.Assert;
import org.eclipse.jface.action.ToolBarManager;
import org.eclipse.jface.dialogs.MessageDialog;
import org.eclipse.jface.layout.GridDataFactory;
import org.eclipse.jface.layout.GridLayoutFactory;
import org.eclipse.jface.preference.IPreferenceStore;
import org.eclipse.jface.text.ITextListener;
import org.eclipse.jface.text.TextEvent;
import org.eclipse.jface.text.source.SourceViewer;
import org.eclipse.jface.util.IPropertyChangeListener;
import org.eclipse.jface.util.PropertyChangeEvent;
import org.eclipse.mylyn.commons.core.DateUtil;
import org.eclipse.mylyn.commons.ui.CommonImages;
import org.eclipse.mylyn.commons.ui.CommonUiUtil;
import org.eclipse.mylyn.commons.ui.PlatformUiUtil;
import org.eclipse.mylyn.commons.workbench.editors.CommonTextSupport;
import org.eclipse.mylyn.commons.workbench.forms.DatePicker;
import org.eclipse.mylyn.internal.monitor.ui.MonitorUiPlugin;
import org.eclipse.mylyn.internal.tasks.core.AbstractTask;
import org.eclipse.mylyn.internal.tasks.core.DateRange;
import org.eclipse.mylyn.internal.tasks.core.DayDateRange;
import org.eclipse.mylyn.internal.tasks.core.ITaskList;
import org.eclipse.mylyn.internal.tasks.core.ITaskListChangeListener;
import org.eclipse.mylyn.internal.tasks.core.TaskActivityManager;
import org.eclipse.mylyn.internal.tasks.core.TaskActivityUtil;
import org.eclipse.mylyn.internal.tasks.core.TaskContainerDelta;
import org.eclipse.mylyn.internal.tasks.core.WeekDateRange;
import org.eclipse.mylyn.internal.tasks.ui.ScheduleDatePicker;
import org.eclipse.mylyn.internal.tasks.ui.TasksUiPlugin;
import org.eclipse.mylyn.internal.tasks.ui.util.TasksUiInternal;
import org.eclipse.mylyn.monitor.ui.IActivityContextManager;
import org.eclipse.mylyn.monitor.ui.MonitorUi;
import org.eclipse.mylyn.tasks.core.ITask;
import org.eclipse.mylyn.tasks.core.ITaskActivationListener;
import org.eclipse.mylyn.tasks.core.ITaskActivityListener;
import org.eclipse.mylyn.tasks.core.TaskActivationAdapter;
import org.eclipse.mylyn.tasks.core.TaskActivityAdapter;
import org.eclipse.mylyn.tasks.core.TaskRepository;
import org.eclipse.mylyn.tasks.ui.editors.AbstractTaskEditorExtension;
import org.eclipse.mylyn.tasks.ui.editors.AbstractTaskEditorPage;
import org.eclipse.mylyn.tasks.ui.editors.TaskFormPage;
import org.eclipse.osgi.util.NLS;
import org.eclipse.swt.custom.StyledText;
import org.eclipse.swt.events.FocusEvent;
import org.eclipse.swt.events.FocusListener;
import org.eclipse.swt.events.ModifyEvent;
import org.eclipse.swt.events.ModifyListener;
import org.eclipse.swt.events.SelectionAdapter;
import org.eclipse.swt.events.SelectionEvent;
import org.eclipse.swt.events.SelectionListener;
import org.eclipse.swt.layout.GridData;
import org.eclipse.swt.layout.GridLayout;
import org.eclipse.swt.layout.RowLayout;
import org.eclipse.swt.widgets.Composite;
import org.eclipse.swt.widgets.Control;
import org.eclipse.swt.widgets.Display;
import org.eclipse.swt.widgets.Label;
import org.eclipse.swt.widgets.Shell;
import org.eclipse.swt.widgets.Spinner;
import org.eclipse.swt.widgets.Text;
import org.eclipse.ui.IEditorSite;
import org.eclipse.ui.IWorkbench;
import org.eclipse.ui.PlatformUI;
import org.eclipse.ui.contexts.IContextService;
import org.eclipse.ui.forms.FormColors;
import org.eclipse.ui.forms.IManagedForm;
import org.eclipse.ui.forms.events.ExpansionAdapter;
import org.eclipse.ui.forms.events.ExpansionEvent;
import org.eclipse.ui.forms.events.HyperlinkAdapter;
import org.eclipse.ui.forms.events.HyperlinkEvent;
import org.eclipse.ui.forms.widgets.FormToolkit;
import org.eclipse.ui.forms.widgets.ImageHyperlink;
import org.eclipse.ui.forms.widgets.Section;

public class PlanningPart
  extends AbstractLocalEditorPart
{
  private boolean needsDueDate;
  private String notesString;
  private RichTextEditor noteEditor;
  private static final int CONTROL_WIDTH = 120;
  private DatePicker dueDatePicker;
  private Text activeTimeText;
  private Spinner estimatedTimeSpinner;
  private ScheduleDatePicker scheduleDatePicker;
  private static final String PERSONAL_NOTES = Messages.PlanningPart_Personal_Notes;
  private final ITaskListChangeListener TASK_LIST_LISTENER = 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) && (getTask() != null) && 
            (updateTask.getHandleIdentifier().equals(getTask().getHandleIdentifier())) && 
            (PlatformUI.getWorkbench() != null) && (!PlatformUI.getWorkbench().isClosing())) {
            PlatformUI.getWorkbench().getDisplay().asyncExec(new Runnable()
            {
              public void run()
              {
                refresh(false);
              }
            });
          }
        }
      }
    }
  };
  private final ITaskActivationListener activationListener = new TaskActivationAdapter()
  {
    public void taskActivated(ITask task)
    {
      if (task.equals(getTask())) {
        PlatformUI.getWorkbench().getDisplay().asyncExec(new Runnable()
        {
          public void run()
          {
            if ((activeTimeText != null) && (!activeTimeText.isDisposed())) {
              PlanningPart.this.updateActiveTime();
            }
          }
        });
      }
    }
    
    public void taskDeactivated(ITask task)
    {
      if (task.equals(getTask())) {
        PlatformUI.getWorkbench().getDisplay().asyncExec(new Runnable()
        {
          public void run()
          {
            if ((activeTimeText != null) && (!activeTimeText.isDisposed())) {
              PlanningPart.this.updateActiveTime();
            }
          }
        });
      }
    }
  };
  private final ITaskActivityListener timingListener = new TaskActivityAdapter()
  {
    public void elapsedTimeUpdated(ITask task, long newElapsedTime)
    {
      if (task.equals(getTask())) {
        PlatformUI.getWorkbench().getDisplay().asyncExec(new Runnable()
        {
          public void run()
          {
            if ((activeTimeText != null) && (!activeTimeText.isDisposed())) {
              PlanningPart.this.updateActiveTime();
            }
          }
        });
      }
    }
  };
  private final IPropertyChangeListener ACTIVITY_PROPERTY_LISTENER = new IPropertyChangeListener()
  {
    public void propertyChange(PropertyChangeEvent event)
    {
      if (event.getProperty().equals("org.eclipse.mylyn.monitor.activity.tracking.enabled")) {
        PlatformUI.getWorkbench().getDisplay().asyncExec(new Runnable()
        {
          public void run()
          {
            if ((activeTimeText != null) && (!activeTimeText.isDisposed())) {
              PlanningPart.this.updateActiveTime();
            }
          }
        });
      }
    }
  };
  private CommonTextSupport textSupport;
  private TaskFormPage page;
  private Composite activeTimeComposite;
  private ToolBarManager toolBarManager;
  private boolean needsNotes;
  private boolean alwaysExpand;
  private Composite sectionClient;
  private boolean activeTimeEnabled;
  private Label scheduledLabel;
  private Composite layoutControl;
  
  public PlanningPart(int sectionStyle)
  {
    super(sectionStyle, Messages.PersonalPart_Personal_Planning);
    activeTimeEnabled = true;
    needsNotes = true;
  }
  
  public void initialize(IManagedForm managedForm, TaskRepository taskRepository, AbstractTask task, boolean needsDueDate, TaskFormPage page, CommonTextSupport textSupport)
  {
    super.initialize(managedForm, taskRepository, task);
    this.needsDueDate = needsDueDate;
    this.page = page;
    this.textSupport = textSupport;
  }
  
  private boolean notesEqual()
  {
    if ((getTask().getNotes() == null) && (notesString == null)) {
      return true;
    }
    if ((getTask().getNotes() != null) && (notesString != null)) {
      return (getTask().getNotes().equals(notesString)) || (notesString.equals(PERSONAL_NOTES));
    }
    return false;
  }
  
  public void commit(boolean onSave)
  {
    Assert.isNotNull(getTask());
    if (!notesEqual()) {
      getTask().setNotes(notesString);
    }
    if ((scheduleDatePicker != null) && (scheduleDatePicker.getScheduledDate() != null))
    {
      if ((getTask().getScheduledForDate() == null) || 
        ((getTask().getScheduledForDate() != null) && (!scheduleDatePicker.getScheduledDate().equals(
        getTask().getScheduledForDate()))) || 
        ((getTask().getScheduledForDate() instanceof DayDateRange)))
      {
        TasksUiPlugin.getTaskActivityManager().setScheduledFor(getTask(), scheduleDatePicker.getScheduledDate());
        getTask().setReminded(false);
      }
    }
    else
    {
      TasksUiPlugin.getTaskActivityManager().setScheduledFor(getTask(), null);
      getTask().setReminded(false);
    }
    if (estimatedTimeSpinner != null) {
      getTask().setEstimatedTimeHours(estimatedTimeSpinner.getSelection());
    }
    if ((dueDatePicker != null) && (dueDatePicker.getDate() != null)) {
      TasksUiPlugin.getTaskActivityManager().setDueDate(getTask(), dueDatePicker.getDate().getTime());
    } else {
      TasksUiPlugin.getTaskActivityManager().setDueDate(getTask(), null);
    }
    super.commit(onSave);
  }
  
  public Control createControl(Composite parent, final FormToolkit toolkit)
  {
    notesString = getTask().getNotes();
    if (notesString == null) {
      notesString = "";
    }
    boolean expand = (isAlwaysExpand()) || (notesString.length() > 0);
    final Section section = createSection(parent, toolkit, expand);
    clientVerticalSpacing = 0;
    if (section.isExpanded()) {
      expandSection(toolkit, section);
    } else {
      section.addExpansionListener(new ExpansionAdapter()
      {
        public void expansionStateChanged(ExpansionEvent event)
        {
          if (sectionClient == null)
          {
            PlanningPart.this.expandSection(toolkit, section);
            if ((page instanceof AbstractTaskEditorPage)) {
              ((AbstractTaskEditorPage)page).reflow();
            }
          }
        }
      });
    }
    TasksUiInternal.getTaskList().addChangeListener(TASK_LIST_LISTENER);
    TasksUiPlugin.getTaskActivityManager().addActivityListener(timingListener);
    TasksUiPlugin.getTaskActivityManager().addActivationListener(activationListener);
    MonitorUiPlugin.getDefault().getPreferenceStore().addPropertyChangeListener(ACTIVITY_PROPERTY_LISTENER);
    
    setSection(toolkit, section);
    return section;
  }
  
  private void expandSection(FormToolkit toolkit, Section section)
  {
    sectionClient = toolkit.createComposite(section);
    GridLayoutFactory.fillDefaults().applyTo(sectionClient);
    
    layoutControl = toolkit.createComposite(sectionClient);
    GridDataFactory.fillDefaults().grab(true, true).applyTo(layoutControl);
    GridLayout layout = EditorUtil.createSectionClientLayout();
    numColumns = (needsDueDate ? 6 : 4);
    layoutControl.setLayout(layout);
    
    createScheduledDatePicker(toolkit, layoutControl);
    if (needsDueDate) {
      createDueDatePicker(toolkit, layoutControl);
    }
    createEstimatedTime(toolkit, layoutControl);
    if (needsNotes()) {
      createNotesArea(toolkit, layoutControl, numColumns);
    }
    createActiveTime(toolkit, layoutControl, numColumns);
    
    toolkit.paintBordersFor(sectionClient);
    section.setClient(sectionClient);
    CommonUiUtil.setMenu(sectionClient, section.getParent().getMenu());
  }
  
  private void createNotesArea(FormToolkit toolkit, Composite parent, int numColumns)
  {
    Composite composite = toolkit.createComposite(parent);
    GridLayout layout = new GridLayout();
    numColumns = 1;
    marginWidth = 1;
    composite.setLayout(layout);
    GridDataFactory.fillDefaults().span(numColumns, -1).grab(true, true).applyTo(composite);
    if (page != null)
    {
      IContextService contextService = (IContextService)page.getEditorSite().getService(IContextService.class);
      if (contextService != null)
      {
        AbstractTaskEditorExtension extension = TaskEditorExtensions.getTaskEditorExtension(getRepository());
        if (extension != null) {
          noteEditor = new RichTextEditor(getRepository(), 8389186, 
            contextService, extension, getTask());
        }
      }
    }
    if (noteEditor == null) {
      noteEditor = new RichTextEditor(getRepository(), 8389186, null, 
        null, getTask());
    }
    noteEditor.setSpellCheckingEnabled(true);
    noteEditor.createControl(composite, toolkit);
    
    noteEditor.setText(notesString);
    
    noteEditor.getControl().setLayoutData(
      EditorUtil.getTextControlLayoutData(page, noteEditor.getViewer().getControl(), true));
    noteEditor.getControl().setData("FormWidgetFactory.drawBorder", "treeBorder");
    noteEditor.setReadOnly(false);
    if (textSupport != null) {
      textSupport.install(noteEditor.getViewer(), true);
    }
    noteEditor.getViewer().addTextListener(new ITextListener()
    {
      public void textChanged(TextEvent event)
      {
        notesString = noteEditor.getText();
        if (!PlanningPart.this.notesEqual()) {
          markDirty();
        }
      }
    });
    addNotesLabelText(toolkit, composite);
    toolkit.paintBordersFor(composite);
  }
  
  private void addNotesLabelText(final FormToolkit toolkit, Composite composite)
  {
    if ((notesString.length() == 0) && (!noteEditor.getViewer().getTextWidget().isFocusControl()))
    {
      notesString = PERSONAL_NOTES;
      noteEditor.setText(notesString);
    }
    FocusListener removePersonalNotesFocusListener = new FocusListener()
    {
      public void focusGained(FocusEvent e)
      {
        if (noteEditor.getText().equals(PlanningPart.PERSONAL_NOTES))
        {
          noteEditor.setText("");
          if (noteEditor.getViewer() != null) {
            noteEditor.getViewer().getTextWidget().setForeground(toolkit.getColors().getForeground());
          }
        }
      }
      
      public void focusLost(FocusEvent e) {}
    };
    boolean changeColor = false;
    if (noteEditor.getText().equals(PERSONAL_NOTES)) {
      changeColor = true;
    }
    if (noteEditor.getViewer() != null)
    {
      noteEditor.getViewer().getTextWidget().addFocusListener(removePersonalNotesFocusListener);
      if (changeColor) {
        noteEditor.getViewer().getTextWidget().setForeground(composite.getShell().getDisplay().getSystemColor(15));
      }
    }
  }
  
  private void createActiveTime(FormToolkit toolkit, Composite toolbarComposite, int numColumns)
  {
    activeTimeComposite = toolkit.createComposite(toolbarComposite);
    GridDataFactory.fillDefaults().span(numColumns, -1).grab(false, false).applyTo(activeTimeComposite);
    activeTimeComposite.setBackground(null);
    activeTimeComposite.setBackgroundMode(2);
    RowLayout rowLayout = new RowLayout();
    center = true;
    marginTop = 0;
    marginBottom = 0;
    marginLeft = 0;
    marginRight = 0;
    activeTimeComposite.setLayout(rowLayout);
    String labelString;
    String labelString;
    if (MonitorUiPlugin.getDefault().isTrackingOsTime())
    {
      labelString = Messages.PlanningPart_Active_time_Label;
    }
    else
    {
      String productName = CommonUiUtil.getProductName(Messages.PlanningPart_Default_Product);
      labelString = NLS.bind(Messages.PlanningPart_Active_time_in_Product_Label, productName);
    }
    Label label = toolkit.createLabel(activeTimeComposite, labelString);
    label.setForeground(toolkit.getColors().getColor("org.eclipse.ui.forms.TITLE"));
    label.setToolTipText(Messages.TaskEditorPlanningPart_Time_working_on_this_task);
    label.setBackground(null);
    
    activeTimeText = new Text(activeTimeComposite, 8388616);
    activeTimeText.setText("00:00");
    activeTimeText.setFont(EditorUtil.TEXT_FONT);
    activeTimeText.setData("FormWidgetFactory.drawBorder", Boolean.FALSE);
    toolkit.adapt(activeTimeText, true, false);
    activeTimeText.setForeground(toolkit.getColors().getColor("org.eclipse.ui.forms.TITLE"));
    activeTimeText.setBackground(null);
    activeTimeText.setEditable(false);
    
    ImageHyperlink resetActivityTimeButton = toolkit.createImageHyperlink(activeTimeComposite, 0);
    resetActivityTimeButton.setBackground(null);
    resetActivityTimeButton.setImage(CommonImages.getImage(CommonImages.FIND_CLEAR_DISABLED));
    resetActivityTimeButton.setHoverImage(CommonImages.getImage(CommonImages.FIND_CLEAR));
    resetActivityTimeButton.setToolTipText(Messages.PlanningPart_Reset_Active_Time);
    resetActivityTimeButton.addHyperlinkListener(new HyperlinkAdapter()
    {
      public void linkActivated(HyperlinkEvent e)
      {
        if (MessageDialog.openConfirm(getControl().getShell(), 
          Messages.TaskEditorPlanningPart_Confirm_Activity_Time_Deletion, 
          Messages.TaskEditorPlanningPart_Do_you_wish_to_reset_your_activity_time_on_this_task_)) {
          MonitorUi.getActivityContextManager().removeActivityTime(getTask().getHandleIdentifier(), 0L, 
            System.currentTimeMillis());
        }
      }
    });
    updateActiveTime();
  }
  
  private void updateActiveTime()
  {
    boolean show = (TasksUiInternal.isActivityTrackingEnabled()) && (isActiveTimeEnabled());
    long elapsedTime = TasksUiInternal.getActiveTime(getTask());
    boolean visible = (activeTimeComposite != null) && (activeTimeComposite.isVisible());
    if ((show) && ((elapsedTime > 0L) || (getTask().isActive())))
    {
      if ((activeTimeComposite != null) && (!activeTimeComposite.isVisible()))
      {
        activeTimeComposite.setVisible(true);
        activeTimeComposite.getLayoutData()).exclude = false;
        activeTimeComposite.getParent().layout();
      }
      String elapsedTimeString = DateUtil.getFormattedDurationShort(elapsedTime);
      if (elapsedTimeString.equals("")) {
        elapsedTimeString = Messages.TaskEditorPlanningPart_0_SECOUNDS;
      }
      activeTimeText.setText(elapsedTimeString);
    }
    else if (activeTimeComposite != null)
    {
      activeTimeComposite.getLayoutData()).exclude = true;
      activeTimeComposite.getParent().layout();
      activeTimeComposite.setVisible(false);
    }
    if (!needsNotes()) {
      if (visible != ((activeTimeComposite != null) && (activeTimeComposite.isVisible()))) {
        if ((page instanceof AbstractTaskEditorPage)) {
          ((AbstractTaskEditorPage)page).reflow();
        }
      }
    }
  }
  
  private Composite createComposite(Composite parent, int col, FormToolkit toolkit)
  {
    Composite nameValueComp = toolkit.createComposite(parent);
    GridLayout layout = new GridLayout(3, false);
    marginHeight = 3;
    nameValueComp.setLayout(layout);
    return nameValueComp;
  }
  
  private void createDueDatePicker(FormToolkit toolkit, Composite parent)
  {
    Label label = toolkit.createLabel(parent, Messages.TaskEditorPlanningPart_Due);
    label.setForeground(toolkit.getColors().getColor("org.eclipse.ui.forms.TITLE"));
    
    Composite composite = createComposite(parent, 1, toolkit);
    
    dueDatePicker = new DatePicker(composite, 8388608, DatePicker.LABEL_CHOOSE, true, 0);
    GridDataFactory.fillDefaults().hint(120, -1).applyTo(dueDatePicker);
    dueDatePicker.setBackground(Display.getDefault().getSystemColor(1));
    dueDatePicker.setData("FormWidgetFactory.drawBorder", "treeBorder");
    if (getTask().getDueDate() != null)
    {
      Calendar calendar = TaskActivityUtil.getCalendar();
      calendar.setTime(getTask().getDueDate());
      dueDatePicker.setDate(calendar);
    }
    dueDatePicker.addPickerSelectionListener(new SelectionAdapter()
    {
      public void widgetSelected(SelectionEvent arg0)
      {
        markDirty();
      }
    });
    toolkit.adapt(dueDatePicker, false, false);
    toolkit.paintBordersFor(composite);
  }
  
  private void createEstimatedTime(FormToolkit toolkit, Composite parent)
  {
    Label label = toolkit.createLabel(parent, Messages.TaskEditorPlanningPart_Estimated);
    label.setForeground(toolkit.getColors().getColor("org.eclipse.ui.forms.TITLE"));
    
    Composite composite = createComposite(parent, 2, toolkit);
    
    estimatedTimeSpinner = new Spinner(composite, 8388608);
    estimatedTimeSpinner.setDigits(0);
    estimatedTimeSpinner.setMaximum(10000);
    estimatedTimeSpinner.setMinimum(0);
    estimatedTimeSpinner.setIncrement(1);
    estimatedTimeSpinner.setSelection(getTask().getEstimatedTimeHours());
    if (!PlatformUiUtil.spinnerHasNativeBorder()) {
      estimatedTimeSpinner.setData("FormWidgetFactory.drawBorder", "treeBorder");
    }
    estimatedTimeSpinner.addModifyListener(new ModifyListener()
    {
      public void modifyText(ModifyEvent e)
      {
        if (getTask().getEstimatedTimeHours() != estimatedTimeSpinner.getSelection()) {
          markDirty();
        }
      }
    });
    toolkit.paintBordersFor(composite);
  }
  
  private void createScheduledDatePicker(FormToolkit toolkit, Composite parent)
  {
    Label label = toolkit.createLabel(parent, Messages.TaskEditorPlanningPart_Scheduled);
    label.setForeground(toolkit.getColors().getColor("org.eclipse.ui.forms.TITLE"));
    
    Composite composite = createComposite(parent, 2, toolkit);
    
    scheduleDatePicker = new ScheduleDatePicker(composite, getTask(), 8388608);
    GridDataFactory.fillDefaults().hint(120, -1).applyTo(scheduleDatePicker);
    scheduleDatePicker.setData("FormWidgetFactory.drawBorder", "treeBorder");
    toolkit.adapt(scheduleDatePicker, false, false);
    toolkit.paintBordersFor(composite);
    
    scheduleDatePicker.setBackground(Display.getDefault().getSystemColor(1));
    scheduleDatePicker.addPickerSelectionListener(new SelectionListener()
    {
      public void widgetDefaultSelected(SelectionEvent arg0) {}
      
      public void widgetSelected(SelectionEvent arg0)
      {
        markDirty();
      }
    });
  }
  
  public void dispose()
  {
    TasksUiPlugin.getTaskActivityManager().removeActivationListener(activationListener);
    TasksUiPlugin.getTaskActivityManager().removeActivityListener(timingListener);
    TasksUiInternal.getTaskList().removeChangeListener(TASK_LIST_LISTENER);
    MonitorUiPlugin.getDefault().getPreferenceStore().removePropertyChangeListener(ACTIVITY_PROPERTY_LISTENER);
    if (toolBarManager != null) {
      toolBarManager.dispose();
    }
  }
  
  protected void setSection(FormToolkit toolkit, Section section)
  {
    super.setSection(toolkit, section);
    if (section.getTextClient() == null)
    {
      Composite toolbarComposite = toolkit.createComposite(section);
      toolbarComposite.setBackground(null);
      RowLayout rowLayout = new RowLayout();
      marginLeft = 0;
      marginRight = 0;
      marginTop = 0;
      marginBottom = 0;
      center = true;
      toolbarComposite.setLayout(rowLayout);
      
      createScheduledLabel(toolbarComposite, section, toolkit);
      
      ToolBarManager toolBarManager = new ToolBarManager(8388608);
      fillToolBar(toolBarManager);
      if (toolBarManager.getSize() > 0)
      {
        toolBarManager.createControl(toolbarComposite);
        clientVerticalSpacing = 0;
        descriptionVerticalSpacing = 0;
      }
      section.setTextClient(toolbarComposite);
    }
  }
  
  private void createScheduledLabel(Composite composite, Section section, FormToolkit toolkit)
  {
    scheduledLabel = toolkit.createLabel(composite, "");
    scheduledLabel.setForeground(toolkit.getColors().getColor("org.eclipse.ui.forms.TITLE"));
    scheduledLabel.setBackground(null);
    updateScheduledLabel(section.isExpanded());
    section.addExpansionListener(new ExpansionAdapter()
    {
      public void expansionStateChanging(ExpansionEvent event)
      {
        PlanningPart.this.updateScheduledLabel(event.getState());
      }
    });
  }
  
  private void updateScheduledLabel(boolean sectionIsExpanded)
  {
    if ((scheduledLabel != null) && (!scheduledLabel.isDisposed())) {
      if ((!sectionIsExpanded) && (!getTask().isCompleted()))
      {
        DateRange date = getTask().getScheduledForDate();
        if (date != null)
        {
          scheduledLabel.setText(getLabel(date));
          scheduledLabel.setToolTipText(NLS.bind(Messages.PlanningPart_Scheduled_for_X_Tooltip, 
            date.toString()));
        }
        else
        {
          scheduledLabel.setText("");
          scheduledLabel.setToolTipText(null);
        }
        if (!scheduledLabel.isVisible()) {
          scheduledLabel.setVisible(true);
        }
        scheduledLabel.getParent().getParent().layout(true);
      }
      else if (scheduledLabel.isVisible())
      {
        scheduledLabel.setVisible(false);
        scheduledLabel.getParent().getParent().layout(true);
      }
    }
  }
  
  public static String getLabel(DateRange dateRange)
  {
    if ((dateRange instanceof WeekDateRange))
    {
      if ((dateRange.isPast()) || (dateRange.isPresent())) {
        return Messages.PlanningPart_This_Week;
      }
      if (TaskActivityUtil.getNextWeek().compareTo(dateRange) == 0) {
        return Messages.PlanningPart_Next_Week;
      }
    }
    else
    {
      if ((dateRange.isPast()) || (dateRange.isPresent())) {
        return Messages.PlanningPart_Today;
      }
      if (TaskActivityUtil.getCurrentWeek().includes(dateRange)) {
        return Messages.PlanningPart_This_Week;
      }
      if (TaskActivityUtil.getNextWeek().includes(dateRange)) {
        return Messages.PlanningPart_Next_Week;
      }
    }
    return Messages.PlanningPart_Later;
  }
  
  protected void fillToolBar(ToolBarManager toolBarManager) {}
  
  public boolean needsNotes()
  {
    return needsNotes;
  }
  
  public void setNeedsNotes(boolean needsNotes)
  {
    this.needsNotes = needsNotes;
  }
  
  public boolean isAlwaysExpand()
  {
    return alwaysExpand;
  }
  
  public void setAlwaysExpand(boolean alwaysExpand)
  {
    this.alwaysExpand = alwaysExpand;
  }
  
  protected void refresh(boolean discardChanges)
  {
    if ((scheduleDatePicker != null) && (!scheduleDatePicker.isDisposed())) {
      if (getTask().getScheduledForDate() != null) {
        scheduleDatePicker.setScheduledDate(getTask().getScheduledForDate());
      } else {
        scheduleDatePicker.setScheduledDate(null);
      }
    }
    if ((scheduledLabel != null) && (!scheduledLabel.isDisposed())) {
      updateScheduledLabel(getSection().isExpanded());
    }
    if ((estimatedTimeSpinner != null) && (!estimatedTimeSpinner.isDisposed())) {
      estimatedTimeSpinner.setSelection(getTask().getEstimatedTimeHours());
    }
  }
  
  public boolean isActiveTimeEnabled()
  {
    return activeTimeEnabled;
  }
  
  public void setActiveTimeEnabled(boolean activeTimeEnabled)
  {
    this.activeTimeEnabled = activeTimeEnabled;
    if ((activeTimeComposite != null) && (!activeTimeComposite.isDisposed())) {
      updateActiveTime();
    }
  }
  
  public RichTextEditor getNoteEditor()
  {
    return noteEditor;
  }
  
  public Control getLayoutControl()
  {
    return layoutControl;
  }
}

/* Location:
 * Qualified Name:     org.eclipse.mylyn.internal.tasks.ui.editors.PlanningPart
 * 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.IConfigurationElement;

public class LocalTaskEditorContributionDescriptor
{
  private final IConfigurationElement element;
  private final String id;
  
  public LocalTaskEditorContributionDescriptor(IConfigurationElement element)
  {
    this.element = element;
    id = element.getAttribute("id");
  }
  
  public AbstractLocalEditorPart createPart()
  {
    try
    {
      return (AbstractLocalEditorPart)element.createExecutableExtension("class");
    }
    catch (Exception e)
    {
      throw new RuntimeException(e);
    }
  }
  
  public String getId()
  {
    return id;
  }
}

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

import java.util.Calendar;
import java.util.Date;
import org.eclipse.mylyn.commons.workbench.forms.DatePicker;
import org.eclipse.mylyn.internal.tasks.core.TaskActivityUtil;
import org.eclipse.swt.events.SelectionAdapter;
import org.eclipse.swt.events.SelectionEvent;

class DateAttributeEditor$1
  extends SelectionAdapter
{
  DateAttributeEditor$1(DateAttributeEditor paramDateAttributeEditor) {}
  
  public void widgetSelected(SelectionEvent e)
  {
    Calendar cal = DateAttributeEditor.access$0(this$0).getDate();
    if (cal != null)
    {
      if (!DateAttributeEditor.access$1(this$0)) {
        TaskActivityUtil.snapStartOfDay(cal);
      }
      Date value = cal.getTime();
      if (!value.equals(this$0.getValue())) {
        this$0.setValue(value);
      }
    }
    else
    {
      if (this$0.getValue() != null) {
        this$0.setValue(null);
      }
      DateAttributeEditor.access$0(this$0).setDate(null);
    }
  }
}

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

import java.util.ArrayList;
import java.util.Collection;
import java.util.List;
import java.util.Map;
import org.eclipse.mylyn.tasks.core.data.TaskAttribute;
import org.eclipse.mylyn.tasks.core.data.TaskAttributeMetaData;
import org.eclipse.mylyn.tasks.core.data.TaskData;
import org.eclipse.mylyn.tasks.core.data.TaskDataModel;

public class TaskEditorAttributePart
  extends AbstractTaskEditorAttributeSection
{
  public TaskEditorAttributePart()
  {
    setPartName(Messages.TaskEditorAttributePart_Attributes);
    setNeedsRefresh(true);
  }
  
  protected Collection<TaskAttribute> getAttributes()
  {
    Map<String, TaskAttribute> allAttributes = getTaskData().getRoot().getAttributes();
    List<TaskAttribute> attributes = new ArrayList(allAttributes.size());
    for (TaskAttribute attribute : allAttributes.values())
    {
      TaskAttributeMetaData properties = attribute.getMetaData();
      if ("task.common.kind.default".equals(properties.getKind())) {
        attributes.add(attribute);
      }
    }
    return attributes;
  }
  
  protected List<TaskAttribute> getOverlayAttributes()
  {
    TaskAttribute product = getModel().getTaskData().getRoot().getMappedAttribute("task.common.product");
    List<TaskAttribute> attributes = new ArrayList(2);
    if (product != null) {
      attributes.add(product);
    }
    TaskAttribute component = getModel().getTaskData().getRoot().getMappedAttribute("task.common.component");
    if (component != null) {
      attributes.add(component);
    }
    return attributes;
  }
}

/* Location:
 * Qualified Name:     org.eclipse.mylyn.internal.tasks.ui.editors.TaskEditorAttributePart
 * 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.ModifyListener;

class TextAttributeEditor$1
  implements ModifyListener
{
  TextAttributeEditor$1(TextAttributeEditor paramTextAttributeEditor) {}
  
  /* Error */
  public void modifyText(org.eclipse.swt.events.ModifyEvent e)
  {
    // Byte code:
    //   0: aload_0
    //   1: getfield 44	org/eclipse/mylyn/internal/tasks/ui/editors/TextAttributeEditor$1:this$0	Lorg/eclipse/mylyn/internal/tasks/ui/editors/TextAttributeEditor;
    //   4: iconst_1
    //   5: invokestatic 48	org/eclipse/mylyn/internal/tasks/ui/editors/TextAttributeEditor:access$0	(Lorg/eclipse/mylyn/internal/tasks/ui/editors/TextAttributeEditor;Z)V
    //   8: aload_0
    //   9: getfield 44	org/eclipse/mylyn/internal/tasks/ui/editors/TextAttributeEditor$1:this$0	Lorg/eclipse/mylyn/internal/tasks/ui/editors/TextAttributeEditor;
    //   12: aload_0
    //   13: getfield 44	org/eclipse/mylyn/internal/tasks/ui/editors/TextAttributeEditor$1:this$0	Lorg/eclipse/mylyn/internal/tasks/ui/editors/TextAttributeEditor;
    //   16: invokestatic 49	org/eclipse/mylyn/internal/tasks/ui/editors/TextAttributeEditor:access$1	(Lorg/eclipse/mylyn/internal/tasks/ui/editors/TextAttributeEditor;)Lorg/eclipse/swt/widgets/Text;
    //   19: invokevirtual 50	org/eclipse/swt/widgets/Text:getText	()Ljava/lang/String;
    //   22: invokevirtual 47	org/eclipse/mylyn/internal/tasks/ui/editors/TextAttributeEditor:setValue	(Ljava/lang/String;)V
    //   25: goto +14 -> 39
    //   28: astore_2
    //   29: aload_0
    //   30: getfield 44	org/eclipse/mylyn/internal/tasks/ui/editors/TextAttributeEditor$1:this$0	Lorg/eclipse/mylyn/internal/tasks/ui/editors/TextAttributeEditor;
    //   33: iconst_0
    //   34: invokestatic 48	org/eclipse/mylyn/internal/tasks/ui/editors/TextAttributeEditor:access$0	(Lorg/eclipse/mylyn/internal/tasks/ui/editors/TextAttributeEditor;Z)V
    //   37: aload_2
    //   38: athrow
    //   39: aload_0
    //   40: getfield 44	org/eclipse/mylyn/internal/tasks/ui/editors/TextAttributeEditor$1:this$0	Lorg/eclipse/mylyn/internal/tasks/ui/editors/TextAttributeEditor;
    //   43: iconst_0
    //   44: invokestatic 48	org/eclipse/mylyn/internal/tasks/ui/editors/TextAttributeEditor:access$0	(Lorg/eclipse/mylyn/internal/tasks/ui/editors/TextAttributeEditor;Z)V
    //   47: aload_0
    //   48: getfield 44	org/eclipse/mylyn/internal/tasks/ui/editors/TextAttributeEditor$1:this$0	Lorg/eclipse/mylyn/internal/tasks/ui/editors/TextAttributeEditor;
    //   51: invokestatic 49	org/eclipse/mylyn/internal/tasks/ui/editors/TextAttributeEditor:access$1	(Lorg/eclipse/mylyn/internal/tasks/ui/editors/TextAttributeEditor;)Lorg/eclipse/swt/widgets/Text;
    //   54: invokestatic 46	org/eclipse/mylyn/commons/workbench/forms/CommonFormUtil:ensureVisible	(Lorg/eclipse/swt/widgets/Control;)V
    //   57: return
    // Line number table:
    //   Java source line #62	-> byte code offset #0
    //   Java source line #63	-> byte code offset #8
    //   Java source line #64	-> byte code offset #28
    //   Java source line #65	-> byte code offset #29
    //   Java source line #66	-> byte code offset #37
    //   Java source line #65	-> byte code offset #39
    //   Java source line #67	-> byte code offset #47
    //   Java source line #68	-> byte code offset #57
    // Local variable table:
    //   start	length	slot	name	signature
    //   0	58	0	this	1
    //   0	58	1	e	org.eclipse.swt.events.ModifyEvent
    //   28	10	2	localObject	Object
    // Exception table:
    //   from	to	target	type
    //   0	28	28	finally
  }
}

/* Location:
 * Qualified Name:     org.eclipse.mylyn.internal.tasks.ui.editors.TextAttributeEditor.1
 * 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.TasksUiInternal;

class BrowserPreviewViewer$2$2
  implements Runnable
{
  BrowserPreviewViewer$2$2(BrowserPreviewViewer.2 param2, BrowserPreviewViewer.1PreviewWikiJob param1PreviewWikiJob) {}
  
  public void run()
  {
    TasksU
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