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

pository repository;
  private final ITask task;
  private Text commentText;
  
  protected ContextAttachWizardPage(TaskRepository repository, ITask task)
  {
    super(Messages.ContextAttachWizardPage_Enter_comment);
    this.repository = repository;
    this.task = task;
    setTitle(Messages.ContextAttachWizardPage_Enter_comment);
    setDescription(Messages.ContextAttachWizardPage_Attaches_local_context_to_repository_task);
  }
  
  public void createControl(Composite parent)
  {
    Composite composite = new Composite(parent, 0);
    composite.setLayout(new GridLayout());
    
    Text summary = new Text(composite, 0);
    summary.setText(NLS.bind(Messages.ContextAttachWizardPage_Task, task.getSummary()));
    summary.setEditable(false);
    Text repositoryText = new Text(composite, 0);
    repositoryText.setText(Messages.ContextAttachWizardPage_Repository_ + repository.getRepositoryUrl());
    repositoryText.setEditable(false);
    
    new Label(composite, 0).setText(Messages.ContextAttachWizardPage_Comment_);
    commentText = new Text(composite, 2626);
    commentText.setLayoutData(new GridData(4, 4, true, true));
    
    commentText.addKeyListener(new KeyListener()
    {
      public void keyPressed(KeyEvent e)
      {
        getWizard().getContainer().updateButtons();
      }
      
      public void keyReleased(KeyEvent e)
      {
        getWizard().getContainer().updateButtons();
      }
    });
    setControl(composite);
    commentText.setFocus();
    Dialog.applyDialogFont(composite);
  }
  
  public String getComment()
  {
    return commentText.getText();
  }
}

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

import com.ibm.icu.text.DateFormat;
import java.util.Collections;
import java.util.Date;
import java.util.List;
import java.util.Map;
import org.eclipse.jface.dialogs.IDialogConstants;
import org.eclipse.jface.dialogs.MessageDialog;
import org.eclipse.jface.layout.GridDataFactory;
import org.eclipse.jface.layout.GridLayoutFactory;
import org.eclipse.jface.wizard.ProgressMonitorPart;
import org.eclipse.jface.wizard.WizardDialog;
import org.eclipse.mylyn.commons.workbench.WorkbenchUtil;
import org.eclipse.mylyn.internal.tasks.ui.util.AttachmentUtil;
import org.eclipse.mylyn.tasks.core.IRepositoryManager;
import org.eclipse.mylyn.tasks.core.IRepositoryPerson;
import org.eclipse.mylyn.tasks.core.ITask;
import org.eclipse.mylyn.tasks.core.ITaskAttachment;
import org.eclipse.mylyn.tasks.core.TaskRepository;
import org.eclipse.mylyn.tasks.ui.TasksUi;
import org.eclipse.osgi.util.NLS;
import org.eclipse.swt.events.SelectionAdapter;
import org.eclipse.swt.events.SelectionEvent;
import org.eclipse.swt.graphics.Image;
import org.eclipse.swt.widgets.Button;
import org.eclipse.swt.widgets.Composite;
import org.eclipse.swt.widgets.Control;
import org.eclipse.swt.widgets.Link;
import org.eclipse.swt.widgets.Shell;

public class RetrieveLatestContextDialog
  extends MessageDialog
{
  private final ITaskAttachment attachment;
  private Link link;
  private ProgressContainer progressContainer;
  private ProgressMonitorPart progressMonitorPart;
  private final ITask task;
  
  public static boolean openQuestion(Shell shell, ITask task)
  {
    TaskRepository repository = TasksUi.getRepositoryManager().getRepository(task.getConnectorKind(), 
      task.getRepositoryUrl());
    List<ITaskAttachment> contextAttachments = AttachmentUtil.getContextAttachments(repository, task);
    Collections.sort(contextAttachments, new TaskAttachmentComparator());
    if (contextAttachments.size() > 0)
    {
      ITaskAttachment attachment = (ITaskAttachment)contextAttachments.get(0);
      String author = null;
      if (attachment.getAuthor() != null) {
        author = attachment.getAuthor().getName() != null ? 
          attachment.getAuthor().getName() : 
          attachment.getAuthor().getPersonId();
      }
      if (author == null) {
        author = Messages.RetrieveLatestContextDialog_Unknown;
      }
      Date date = attachment.getCreationDate();
      String dateString = null;
      if (date != null) {
        dateString = DateFormat.getDateInstance(1).format(date);
      }
      if (dateString == null) {
        dateString = Messages.RetrieveLatestContextDialog_Unknown;
      }
      String message = NLS.bind(Messages.RetrieveLatestContextDialog_No_local_context_exists, author, dateString);
      int kind = 3;
      int style = 0;
      
      RetrieveLatestContextDialog dialog = new RetrieveLatestContextDialog(shell, 
        Messages.RetrieveLatestContextDialog_Dialog_Title, null, message, kind, new String[] {
        IDialogConstants.OK_LABEL, IDialogConstants.CANCEL_LABEL }, 0, task, attachment);
      style &= 0x10000000;
      dialog.setShellStyle(dialog.getShellStyle() | style);
      return dialog.open() == 0;
    }
    return false;
  }
  
  public RetrieveLatestContextDialog(Shell parentShell, String dialogTitle, Image dialogTitleImage, String dialogMessage, int dialogImageType, String[] dialogButtonLabels, int defaultIndex, ITask task, ITaskAttachment attachment)
  {
    super(parentShell, dialogTitle, dialogTitleImage, dialogMessage, dialogImageType, dialogButtonLabels, defaultIndex);
    this.task = task;
    this.attachment = attachment;
  }
  
  protected void buttonPressed(int buttonId)
  {
    if (progressContainer.isActive()) {
      return;
    }
    if ((buttonId == 0) && 
      (!AttachmentUtil.downloadContext(task, attachment, progressContainer))) {
      return;
    }
    super.buttonPressed(buttonId);
  }
  
  protected Control createButtonBar(Composite parent)
  {
    Composite composite = new Composite(parent, 0);
    composite.setLayout(GridLayoutFactory.fillDefaults().numColumns(3).create());
    GridDataFactory.fillDefaults().grab(true, false).span(2, 1).applyTo(composite);
    Control control = createLink(composite);
    GridDataFactory.fillDefaults().grab(true, false).applyTo(control);
    super.createButtonBar(composite);
    return composite;
  }
  
  protected Control createContents(Composite parent)
  {
    Control control = super.createContents(parent);
    progressContainer.setCancelButton(getButton(1));
    getButton(0).setFocus();
    return control;
  }
  
  protected Control createCustomArea(Composite parent)
  {
    progressMonitorPart = new ProgressMonitorPart(parent, null);
    GridDataFactory.fillDefaults().grab(true, false).applyTo(progressMonitorPart);
    progressContainer = new ProgressContainer(getShell(), progressMonitorPart)
    {
      protected void restoreUiState(Map<Object, Object> state)
      {
        link.setEnabled(true);
        getButton(0).setEnabled(true);
        getButton(1).setEnabled(true);
      }
      
      protected void saveUiState(Map<Object, Object> savedState)
      {
        link.setEnabled(false);
        getButton(0).setEnabled(false);
      }
    };
    return progressMonitorPart;
  }
  
  protected Control createLink(Composite parent)
  {
    link = new Link(parent, 0);
    link.setText(Messages.RetrieveLatestContextDialog_Show_All_Contexts_Label);
    link.addSelectionListener(new SelectionAdapter()
    {
      public void widgetSelected(SelectionEvent e)
      {
        close();
        
        ContextRetrieveWizard wizard = new ContextRetrieveWizard(task);
        WizardDialog dialog = new WizardDialog(WorkbenchUtil.getShell(), wizard);
        dialog.create();
        dialog.setBlockOnOpen(true);
        setReturnCode(dialog.open());
      }
    });
    return link;
  }
}

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

import org.eclipse.jface.wizard.IWizard;
import org.eclipse.jface.wizard.IWizardContainer;
import org.eclipse.mylyn.tasks.core.ITaskAttachment;
import org.eclipse.swt.events.SelectionAdapter;
import org.eclipse.swt.events.SelectionEvent;
import org.eclipse.swt.widgets.Table;
import org.eclipse.swt.widgets.TableItem;

class ContextRetrieveWizardPage$1
  extends SelectionAdapter
{
  ContextRetrieveWizardPage$1(ContextRetrieveWizardPage paramContextRetrieveWizardPage, Table paramTable) {}
  
  public void widgetSelected(SelectionEvent event)
  {
    if (val$contextTable.getSelectionIndex() > -1)
    {
      ContextRetrieveWizardPage.access$0(this$0, 
        (ITaskAttachment)val$contextTable.getItem(val$contextTable.getSelectionIndex()).getData());
      this$0.getWizard().getContainer().updateButtons();
    }
  }
}

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

import org.eclipse.core.commands.ExecutionEvent;
import org.eclipse.core.commands.ExecutionException;
import org.eclipse.jface.dialogs.MessageDialog;
import org.eclipse.mylyn.internal.tasks.core.ITaskList;
import org.eclipse.mylyn.internal.tasks.ui.TasksUiPlugin;
import org.eclipse.mylyn.internal.tasks.ui.commands.AbstractTaskHandler;
import org.eclipse.mylyn.internal.tasks.ui.util.TasksUiInternal;
import org.eclipse.mylyn.tasks.core.ITask;
import org.eclipse.mylyn.tasks.core.context.AbstractTaskContextStore;
import org.eclipse.ui.IWorkbench;
import org.eclipse.ui.IWorkbenchWindow;
import org.eclipse.ui.PlatformUI;

public class ClearContextHandler
  extends AbstractTaskHandler
{
  protected void execute(ExecutionEvent event, ITask task)
    throws ExecutionException
  {
    run(task);
  }
  
  public static void run(ITask task)
  {
    boolean deleteConfirmed = MessageDialog.openQuestion(PlatformUI.getWorkbench()
      .getActiveWorkbenchWindow()
      .getShell(), Messages.ClearContextHandler_Confirm_clear_context, 
      Messages.ClearContextHandler_CLEAR_THE_CONTEXT_THE_FOR_SELECTED_TASK);
    if (!deleteConfirmed) {
      return;
    }
    TasksUiPlugin.getContextStore().clearContext(task);
    TasksUiInternal.getTaskList().notifyElementChanged(task);
  }
}

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

import org.eclipse.osgi.util.NLS;

public class Messages
  extends NLS
{
  private static final String BUNDLE_NAME = "org.eclipse.mylyn.internal.tasks.ui.context.messages";
  public static String ContextAttachWizard_Attach_Context;
  public static String ContextAttachWizardPage_Enter_comment;
  public static String ContextAttachWizardPage_Attaches_local_context_to_repository_task;
  public static String ContextAttachWizardPage_Comment_;
  public static String ContextAttachWizardPage_Repository_;
  public static String ContextAttachWizardPage_Task;
  public static String ContextRetrieveWizard_Retrieve_Context;
  public static String ContextRetrieveWizardPage_Author;
  public static String ContextRetrieveWizardPage_Date;
  public static String ContextRetrieveWizardPage_Description;
  public static String ContextRetrieveWizardPage_Select_context;
  public static String ContextRetrieveWizardPage_SELECT_A_CONTEXT_TO_RETTRIEVE_FROM_TABLE_BELOW;
  public static String ContextRetrieveWizardPage_Task;
  public static String RetrieveLatestContextDialog_Dialog_Title;
  public static String RetrieveLatestContextDialog_No_local_context_exists;
  public static String RetrieveLatestContextDialog_Show_All_Contexts_Label;
  public static String RetrieveLatestContextDialog_Unknown;
  public static String ClearContextHandler_CLEAR_THE_CONTEXT_THE_FOR_SELECTED_TASK;
  public static String ClearContextHandler_Confirm_clear_context;
  public static String CopyContextHandler_Merge;
  public static String CopyContextHandler_Copy_Context;
  public static String CopyContextHandler_No_source_task_selected;
  public static String CopyContextHandler_No_target_task_selected;
  public static String CopyContextHandler_Replace;
  public static String CopyContextHandler_Select_Target_Task;
  public static String CopyContextHandler_Select_the_target_task__;
  public static String CopyContextHandler_SELECTED_TASK_ALREADY_HAS_CONTEXT;
  public static String CopyContextHandler_SOURCE_TASK_DOES_HAVE_A_CONTEXT;
  public static String CopyContextHandler_TARGET_TASK_CON_NOT_BE_THE_SAME_AS_SOURCE_TASK;
  
  static {}
  
  public static void reloadMessages()
  {
    NLS.initializeMessages("org.eclipse.mylyn.internal.tasks.ui.context.messages", Messages.class);
  }
}

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

import java.util.ArrayList;
import java.util.LinkedList;
import java.util.List;
import org.eclipse.jface.action.MenuManager;
import org.eclipse.mylyn.commons.ui.CommonImages;
import org.eclipse.mylyn.commons.workbench.forms.DatePicker;
import org.eclipse.mylyn.internal.tasks.core.AbstractTask;
import org.eclipse.mylyn.internal.tasks.core.DateRange;
import org.eclipse.mylyn.tasks.core.IRepositoryElement;
import org.eclipse.swt.events.SelectionAdapter;
import org.eclipse.swt.events.SelectionEvent;
import org.eclipse.swt.events.SelectionListener;
import org.eclipse.swt.graphics.Color;
import org.eclipse.swt.graphics.Point;
import org.eclipse.swt.graphics.Rectangle;
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.Display;
import org.eclipse.swt.widgets.Menu;
import org.eclipse.swt.widgets.Text;
import org.eclipse.ui.forms.events.HyperlinkAdapter;
import org.eclipse.ui.forms.events.HyperlinkEvent;
import org.eclipse.ui.forms.widgets.ImageHyperlink;

public class ScheduleDatePicker
  extends Composite
{
  private Text scheduledDateText;
  private Button pickButton;
  private final List<SelectionListener> pickerListeners = new LinkedList();
  private final String initialText = DatePicker.LABEL_CHOOSE;
  private final List<IRepositoryElement> tasks;
  private final ScheduleTaskMenuContributor contributor;
  private DateRange scheduledDate;
  private final boolean isFloating = false;
  private ImageHyperlink clearControl;
  
  public ScheduleDatePicker(Composite parent, AbstractTask task, int style)
  {
    super(parent, style);
    if ((task != null) && 
      (task.getScheduledForDate() != null)) {
      scheduledDate = task.getScheduledForDate();
    }
    initialize((style & 0x800000) > 0 ? 8388608 : 0);
    contributor = new ScheduleTaskMenuContributor()
    {
      protected DateRange getScheduledForDate(AbstractTask singleTaskSelection)
      {
        return scheduledDate;
      }
      
      protected void setScheduledDate(DateRange dateRange)
      {
        if (dateRange != null) {
          scheduledDate = dateRange;
        } else {
          scheduledDate = null;
        }
        ScheduleDatePicker.this.updateDateText();
        ScheduleDatePicker.this.notifyPickerListeners();
      }
    };
    tasks = new ArrayList();
    tasks.add(task);
  }
  
  private void initialize(int style)
  {
    GridLayout gridLayout = new GridLayout(3, false);
    horizontalSpacing = 0;
    verticalSpacing = 0;
    marginWidth = 0;
    marginHeight = 0;
    setLayout(gridLayout);
    
    scheduledDateText = new Text(this, style);
    scheduledDateText.setEditable(false);
    GridData dateTextGridData = new GridData(4, 4, false, false);
    heightHint = 5;
    grabExcessHorizontalSpace = true;
    verticalAlignment = 4;
    
    scheduledDateText.setLayoutData(dateTextGridData);
    scheduledDateText.setText(initialText);
    
    clearControl = new ImageHyperlink(this, 0);
    clearControl.setImage(CommonImages.getImage(CommonImages.FIND_CLEAR_DISABLED));
    clearControl.setHoverImage(CommonImages.getImage(CommonImages.FIND_CLEAR));
    clearControl.setToolTipText(Messages.ScheduleDatePicker_Clear);
    clearControl.addHyperlinkListener(new HyperlinkAdapter()
    {
      public void linkActivated(HyperlinkEvent e)
      {
        setScheduledDate(null);
        for (IRepositoryElement task : tasks) {
          if ((task instanceof AbstractTask)) {
            ((AbstractTask)task).setReminded(false);
          }
        }
        ScheduleDatePicker.this.notifyPickerListeners();
      }
    });
    clearControl.setBackground(clearControl.getDisplay().getSystemColor(1));
    GridData clearButtonGridData = new GridData();
    horizontalIndent = 3;
    clearControl.setLayoutData(clearButtonGridData);
    
    pickButton = new Button(this, style | 0x4 | 0x400);
    GridData pickButtonGridData = new GridData(131072, 4, false, true);
    verticalIndent = 0;
    horizontalIndent = 3;
    pickButton.setLayoutData(pickButtonGridData);
    pickButton.addSelectionListener(new SelectionAdapter()
    {
      public void widgetSelected(SelectionEvent arg0)
      {
        MenuManager menuManager = contributor.getSubMenuManager(tasks);
        Menu menu = menuManager.createContextMenu(pickButton);
        pickButton.setMenu(menu);
        menu.setVisible(true);
        Point location = pickButton.toDisplay(pickButton.getLocation());
        Rectangle bounds = pickButton.getBounds();
        
        menu.setLocation(x - pickButton.getBounds().x, y + height + 2);
      }
    });
    updateDateText();
    pack();
  }
  
  private void updateClearControlVisibility()
  {
    if ((clearControl != null) && ((clearControl.getLayoutData() instanceof GridData)))
    {
      GridData gd = (GridData)clearControl.getLayoutData();
      exclude = (scheduledDate == null);
      clearControl.getParent().layout();
    }
  }
  
  public void addPickerSelectionListener(SelectionListener listener)
  {
    pickerListeners.add(listener);
  }
  
  public void setForeground(Color color)
  {
    pickButton.setForeground(color);
    scheduledDateText.setForeground(color);
    super.setForeground(color);
  }
  
  public void setBackground(Color backgroundColor)
  {
    pickButton.setBackground(backgroundColor);
    scheduledDateText.setBackground(backgroundColor);
    super.setBackground(backgroundColor);
  }
  
  private void notifyPickerListeners()
  {
    for (SelectionListener listener : pickerListeners) {
      listener.widgetSelected(null);
    }
  }
  
  private void updateDateText()
  {
    if (scheduledDate != null)
    {
      scheduledDateText.setText(scheduledDate.toString());
    }
    else
    {
      scheduledDateText.setEnabled(false);
      scheduledDateText.setText(DatePicker.LABEL_CHOOSE);
      scheduledDateText.setEnabled(true);
    }
    updateClearControlVisibility();
  }
  
  public void setEnabled(boolean enabled)
  {
    scheduledDateText.setEnabled(enabled);
    pickButton.setEnabled(enabled);
    clearControl.setEnabled(enabled);
    super.setEnabled(enabled);
  }
  
  public DateRange getScheduledDate()
  {
    return scheduledDate;
  }
  
  public void setScheduledDate(DateRange date)
  {
    scheduledDate = date;
    updateDateText();
  }
  
  public boolean isFloatingDate()
  {
    return false;
  }
}

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

import java.io.File;
import java.io.FileOutputStream;
import java.io.IOException;
import java.text.MessageFormat;
import java.util.concurrent.atomic.AtomicReference;
import org.eclipse.core.runtime.CoreException;
import org.eclipse.core.runtime.IProgressMonitor;
import org.eclipse.core.runtime.IStatus;
import org.eclipse.core.runtime.OperationCanceledException;
import org.eclipse.core.runtime.Status;
import org.eclipse.core.runtime.SubProgressMonitor;
import org.eclipse.mylyn.commons.core.ICoreRunnable;
import org.eclipse.mylyn.internal.tasks.ui.util.AttachmentUtil;
import org.eclipse.mylyn.tasks.core.IRepositoryManager;
import org.eclipse.mylyn.tasks.core.ITask;
import org.eclipse.mylyn.tasks.core.ITaskAttachment;
import org.eclipse.mylyn.tasks.core.TaskRepository;
import org.eclipse.mylyn.tasks.ui.AbstractRepositoryConnectorUi;
import org.eclipse.mylyn.tasks.ui.TasksUi;
import org.eclipse.swt.widgets.Display;
import org.eclipse.ui.IWorkbench;
import org.eclipse.ui.IWorkbenchPage;
import org.eclipse.ui.IWorkbenchWindow;
import org.eclipse.ui.PartInitException;

class DownloadAndOpenTaskAttachmentJob
  implements ICoreRunnable
{
  private final ITaskAttachment attachment;
  private final IWorkbenchPage page;
  private final String editorID;
  private final String jobName;
  
  DownloadAndOpenTaskAttachmentJob(String jobName, ITaskAttachment attachment, IWorkbenchPage page, String editorID)
  {
    this.jobName = jobName;
    this.attachment = attachment;
    this.page = page;
    this.editorID = editorID;
  }
  
  public void run(IProgressMonitor monitor)
    throws CoreException
  {
    monitor.beginTask(jobName, -1);
    try
    {
      IStatus result = execute(new SubProgressMonitor(monitor, 100));
      if ((result != null) && (!result.isOK())) {
        throw new CoreException(result);
      }
    }
    finally
    {
      monitor.done();
    }
    monitor.done();
  }
  
  protected IStatus execute(IProgressMonitor monitor)
  {
    final String attachmentFilename = AttachmentUtil.getAttachmentFilename(attachment);
    
    File file = null;
    try
    {
      file = File.createTempFile("tmpattach-", "-" + attachmentFilename);
    }
    catch (IOException e)
    {
      return new Status(4, "org.eclipse.mylyn.tasks.ui", 
        Messages.DownloadAndOpenTaskAttachmentJob_failedToDownloadAttachment, e);
    }
    file.deleteOnExit();
    
    boolean ok = false;
    FileOutputStream fos = null;
    try
    {
      fos = new FileOutputStream(file);
      AttachmentUtil.downloadAttachment(attachment, fos, monitor);
      ok = true;
    }
    catch (IOException e)
    {
      return new Status(4, "org.eclipse.mylyn.tasks.ui", 
        Messages.DownloadAndOpenTaskAttachmentJob_failedToDownloadAttachment, e);
    }
    catch (CoreException e)
    {
      Status localStatus;
      int s = 4;
      if ((e.getStatus() != null) && (e.getStatus().getCode() == 8)) {
        throw new OperationCanceledException();
      }
      return new Status(s, "org.eclipse.mylyn.tasks.ui", 
        Messages.DownloadAndOpenTaskAttachmentJob_failedToDownloadAttachment, e);
    }
    finally
    {
      if (fos != null) {
        try
        {
          fos.close();
        }
        catch (IOException e)
        {
          if (ok)
          {
            file.delete();
            return new Status(4, "org.eclipse.mylyn.tasks.ui", 
              Messages.DownloadAndOpenTaskAttachmentJob_failedToDownloadAttachment, e);
          }
        }
      }
      if (!ok) {
        file.delete();
      }
    }
    if (fos != null) {
      try
      {
        fos.close();
      }
      catch (IOException e)
      {
        if (ok)
        {
          file.delete();
          return new Status(4, "org.eclipse.mylyn.tasks.ui", 
            Messages.DownloadAndOpenTaskAttachmentJob_failedToDownloadAttachment, e);
        }
      }
    }
    if (!ok) {
      file.delete();
    }
    file.setReadOnly();
    
    Display disp = page.getWorkbenchWindow().getWorkbench().getDisplay();
    if (disp.isDisposed()) {
      return new Status(2, "org.eclipse.mylyn.tasks.ui", 
        Messages.DownloadAndOpenTaskAttachmentJob_cannotOpenEditor);
    }
    if (disp.getThread() == Thread.currentThread()) {
      return openEditor(file, attachmentFilename);
    }
    final AtomicReference<IStatus> status = new AtomicReference();
    final File tmpFile = file;
    
    disp.syncExec(new Runnable()
    {
      public void run()
      {
        status.set(openEditor(tmpFile, attachmentFilename));
      }
    });
    if (status.get() == null) {
      return new Status(4, "org.eclipse.mylyn.tasks.ui", 
        Messages.DownloadAndOpenTaskAttachmentJob_cannotOpenEditor);
    }
    return (IStatus)status.get();
  }
  
  IStatus openEditor(File file, String attachmentName)
  {
    try
    {
      String taskLabel = getTaskLabel(attachment.getTask());
      String repoLabel = getRepositoryLabel(attachment.getTask());
      
      String tooltip = MessageFormat.format(Messages.DownloadAndOpenTaskAttachmentJob_editorTooltip, new Object[] { taskLabel, 
        repoLabel });
      
      page.openEditor(new AttachmentFileEditorInput(file, attachmentName, tooltip), editorID);
      return Status.OK_STATUS;
    }
    catch (PartInitException e)
    {
      return new Status(4, "org.eclipse.mylyn.tasks.ui", 
        Messages.DownloadAndOpenTaskAttachmentJob_cannotOpenEditor, e);
    }
  }
  
  private String getTaskLabel(ITask task)
  {
    AbstractRepositoryConnectorUi connectorUi = TasksUiPlugin.getConnectorUi(task.getConnectorKind());
    StringBuilder taskLabel = new StringBuilder();
    if (connectorUi != null) {
      taskLabel.append(connectorUi.getTaskKindLabel(task));
    }
    String key = task.getTaskKey();
    if (key != null)
    {
      if (taskLabel.length() > 0) {
        taskLabel.append(" ");
      }
      taskLabel.append(key);
    }
    return taskLabel.toString();
  }
  
  private String getRepositoryLabel(ITask task)
  {
    String repositoryKind = task.getConnectorKind();
    String repositoryUrl = task.getRepositoryUrl();
    
    TaskRepository repository = TasksUi.getRepositoryManager().getRepository(repositoryKind, repositoryUrl);
    if (repository != null)
    {
      String label = repository.getRepositoryLabel();
      if (label.indexOf("//") != -1) {
        return label.substring(repository.getRepositoryUrl().indexOf("//") + 2);
      }
      return label;
    }
    return "";
  }
}

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

import java.io.File;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.InputStream;
import org.eclipse.core.resources.IStorage;
import org.eclipse.core.runtime.CoreException;
import org.eclipse.core.runtime.IPath;
import org.eclipse.core.runtime.Path;
import org.eclipse.core.runtime.PlatformObject;
import org.eclipse.core.runtime.Status;

public class AttachmentFileStorage
  extends PlatformObject
  implements IStorage
{
  private final File file;
  private final String name;
  
  public AttachmentFileStorage(File file, String name)
  {
    this.file = file;
    this.name = name;
  }
  
  public InputStream getContents()
    throws CoreException
  {
    try
    {
      return new FileInputStream(file);
    }
    catch (FileNotFoundException e)
    {
      throw new CoreException(new Status(4, "org.eclipse.mylyn.tasks.ui", 
        Messages.FileStorage_unableToReadAttachmentFile, e));
    }
  }
  
  public IPath getFullPath()
  {
    return Path.fromOSString(file.getAbsolutePath());
  }
  
  public String getName()
  {
    return name;
  }
  
  public boolean isReadOnly()
  {
    return true;
  }
}

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

import java.util.Set;
import org.eclipse.jface.action.IMenuListener;
import org.eclipse.jface.action.IMenuManager;
import org.eclipse.jface.action.MenuManager;
import org.eclipse.jface.preference.IPreferenceStore;
import org.eclipse.jface.util.IPropertyChangeListener;
import org.eclipse.jface.util.PropertyChangeEvent;
import org.eclipse.jface.viewers.StructuredSelection;
import org.eclipse.mylyn.commons.ui.SelectionProviderAdapter;
import org.eclipse.mylyn.internal.tasks.core.ITaskListChangeListener;
import org.eclipse.mylyn.internal.tasks.core.TaskContainerDelta;
import org.eclipse.mylyn.internal.tasks.core.TaskContainerDelta.Kind;
import org.eclipse.mylyn.internal.tasks.core.TaskList;
import org.eclipse.mylyn.internal.tasks.ui.actions.RepositoryElementActionGroup;
import org.eclipse.mylyn.internal.tasks.ui.util.TasksUiInternal;
import org.eclipse.mylyn.internal.tasks.ui.views.TaskListView;
import org.eclipse.mylyn.tasks.core.ITask;
import org.eclipse.mylyn.tasks.core.ITaskActivationListener;
import org.eclipse.mylyn.tasks.core.ITaskActivityManager;
import org.eclipse.mylyn.tasks.core.TaskActivationAdapter;
import org.eclipse.mylyn.tasks.ui.TasksUi;
import org.eclipse.swt.events.MenuDetectEvent;
import org.eclipse.swt.events.MenuDetectListener;
import org.eclipse.swt.events.MouseAdapter;
import org.eclipse.swt.events.MouseEvent;
import org.eclipse.swt.graphics.GC;
import org.eclipse.swt.graphics.Point;
import org.eclipse.swt.layout.GridData;
import org.eclipse.swt.layout.GridLayout;
import org.eclipse.swt.widgets.Composite;
import org.eclipse.swt.widgets.Control;
import org.eclipse.swt.widgets.Display;
import org.eclipse.swt.widgets.Menu;
import org.eclipse.swt.widgets.ToolBar;
import org.eclipse.ui.IWorkbench;
import org.eclipse.ui.IWorkbenchWindow;
import org.eclipse.ui.PlatformUI;
import org.eclipse.ui.forms.events.HyperlinkAdapter;
import org.eclipse.ui.forms.events.HyperlinkEvent;
import org.eclipse.ui.internal.ObjectActionContributorManager;
import org.eclipse.ui.internal.WorkbenchWindow;
import org.eclipse.ui.internal.layout.ITrimManager;
import org.eclipse.ui.internal.layout.IWindowTrim;
import org.eclipse.ui.menus.WorkbenchWindowControlContribution;

public class TaskTrimWidget
  extends WorkbenchWindowControlContribution
{
  public static String ID_CONTAINER = "org.eclipse.mylyn.tasks.ui.trim.container";
  public static String ID_CONTROL = "org.eclipse.mylyn.tasks.ui.trim.control";
  private Composite composite;
  private ITask activeTask;
  private MenuManager menuManager;
  private Menu menu;
  private TaskScalingHyperlink activeTaskLabel;
  private final ITaskActivationListener taskActivationListener = new TaskActivationAdapter()
  {
    public void taskActivated(ITask task)
    {
      activeTask = task;
      indicateActiveTask();
    }
    
    public void taskDeactivated(ITask task)
    {
      activeTask = null;
      indicateNoActiveTask();
    }
  };
  private final ITaskListChangeListener taskListListener = new ITaskListChangeListener()
  {
    public void containersChanged(Set<TaskContainerDelta> containers)
    {
      if (activeTask != null) {
        for (TaskContainerDelta taskContainerDelta : containers) {
          if ((activeTask.equals(taskContainerDelta.getElement())) && 
            (taskContainerDelta.getKind().equals(TaskContainerDelta.Kind.CONTENT)))
          {
            Display.getDefault().asyncExec(new Runnable()
            {
              public void run()
              {
                if ((activeTask != null) && (activeTask.isActive())) {
                  indicateActiveTask();
                }
              }
            });
            return;
          }
        }
      }
    }
  };
  private final IPropertyChangeListener preferencesListener = new IPropertyChangeListener()
  {
    public void propertyChange(PropertyChangeEvent event)
    {
      String property = event.getProperty();
      if (property.equals("org.eclipse.mylyn.tasks.ui.show.trim"))
      {
        Object newValue = event.getNewValue();
        Boolean isVisible = Boolean.valueOf(false);
        if ((newValue instanceof Boolean)) {
          isVisible = (Boolean)newValue;
        } else if ((newValue instanceof String)) {
          isVisible = Boolean.valueOf(Boolean.parseBoolean((String)newValue));
        }
        TaskTrimWidget.this.setTrimVisible(isVisible.booleanValue());
      }
    }
  };
  private SelectionProviderAdapter activeTaskSelectionProvider;
  private RepositoryElementActionGroup actionGroup;
  
  public TaskTrimWidget()
  {
    TasksUi.getTaskActivityManager().addActivationListener(taskActivationListener);
    TasksUiPlugin.getTaskList().addChangeListener(taskListListener);
    TasksUiPlugin.getDefault().getPreferenceStore().addPropertyChangeListener(preferencesListener);
    hookContextMenu();
  }
  
  private void setTrimVisible(boolean visible)
  {
    IWorkbenchWindow window = PlatformUI.getWorkbench().getActiveWorkbenchWindow();
    if ((window instanceof WorkbenchWindow))
    {
      IWindowTrim trim = ((WorkbenchWindow)window).getTrimManager().getTrim(ID_CONTAINER);
      if (trim != null)
      {
        ((WorkbenchWindow)window).getTrimManager().setTrimVisible(trim, visible);
        ((WorkbenchWindow)window).getTrimManager().forceLayout();
      }
    }
  }
  
  public void dispose()
  {
    if ((composite != null) && (!composite.isDisposed())) {
      composite.dispose();
    }
    composite = null;
    if (menuManager != null)
    {
      menuManager.removeAll();
      menuManager.dispose();
    }
    menuManager = null;
    if ((menu != null) && (!menu.isDisposed())) {
      menu.dispose();
    }
    menu = null;
    
    actionGroup.setSelectionProvider(null);
    
    TasksUi.getTaskActivityManager().removeActivationListener(taskActivationListener);
    TasksUiPlugin.getTaskList().removeChangeListener(taskListListener);
    TasksUiPlugin.getDefault().getPreferenceStore().removePropertyChangeListener(preferencesListener);
  }
  
  protected Control createControl(Composite parent)
  {
    composite = new Composite(parent, 0);
    
    GridLayout layout = new GridLayout();
    numColumns = 1;
    horizontalSpacing = 0;
    marginHeight = 0;
    marginLeft = 0;
    marginRight = 0;
    composite.setLayout(layout);
    
    createStatusComposite(composite);
    if (!shouldShowTrim())
    {
      if ((parent instanceof ToolBar)) {
        parent.setVisible(false);
      }
      parent.getDisplay().asyncExec(new Runnable()
      {
        public void run()
        {
          TaskTrimWidget.this.setTrimVisible(TaskTrimWidget.access$3(TaskTrimWidget.this));
        }
      });
    }
    return composite;
  }
  
  private boolean shouldShowTrim()
  {
    IPreferenceStore uiPreferenceStore = TasksUiPlugin.getDefault().getPreferenceStore();
    return uiPreferenceStore.getBoolean("org.eclipse.mylyn.tasks.ui.show.trim");
  }
  
  private Composite createStatusComposite(final Composite container)
  {
    GC gc = new GC(container);
    Point p = gc.textExtent("WWWWWWWWWWWWWWW");
    gc.dispose();
    
    activeTaskLabel = new TaskScalingHyperlink(container, 131072);
    
    GridData gridData = new GridData(16384, 16777216, false, true);
    widthHint = x;
    minimumWidth = x;
    horizontalIndent = 0;
    activeTaskLabel.setLayoutData(gridData);
    activeTaskLabel.setText(Messages.TaskTrimWidget__no_task_active_);
    
    activeTask = TasksUi.getTaskActivityManager().getActiveTask();
    if (activeTask != null) {
      indicateActiveTask();
    }
    activeTaskLabel.addMenuDetectListener(new MenuDetectListener()
    {
      public void menuDetected(MenuDetectEvent e)
      {
        if (menu != null) {
          menu.dispose();
        }
        menu = menuManager.createContextMenu(container);
        menu.setVisible(true);
      }
    });
    activeTaskLabel.addHyperlinkListener(new HyperlinkAdapter()
    {
      public void linkActivated(HyperlinkEvent e)
      {
        TaskListView taskListView = TaskListView.getFromActivePerspective();
        if ((taskListView != null) && (taskListView.getDrilledIntoCategory() != null)) {
          taskListView.goUpToRoot();
        }
        TasksUiInternal.refreshAndOpenTaskListElement(TasksUi.getTaskActivityManager().getActiveTask());
      }
    });
    activeTaskLabel.addMouseListener(new MouseAdapter()
    {
      public void mouseDown(MouseEvent e)
      {
        if (button == 1)
        {
          if (activeTask == null) {
            return;
          }
          TaskListView taskListView = TaskListView.getFromActivePerspective();
          if ((taskListView != null) && (taskListView.getDrilledIntoCategory() != null)) {
            taskListView.goUpToRoot();
          }
          TasksUiInternal.refreshAndOpenTaskListElement(activeTask);
        }
      }
    });
    return activeTaskLabel;
  }
  
  private void hookContextMenu()
  {
    activeTaskSelectionProvider = new SelectionProviderAdapter();
    
    actionGroup = new RepositoryElementActionGroup();
    actionGroup.setSelectionProvider(activeTaskSelectionProvider);
    
    menuManager = new MenuManager("#PopupMenu");
    menuManager.setRemoveAllWhenShown(true);
    menuManager.addMenuListener(new IMenuListener()
    {
      public void menuAboutToShow(IMenuManager manager)
      {
        actionGroup.fillContextMenu(manager);
        
        ObjectActionContributorManager.getManager().contributeObjectActions(null, manager, 
          activeTaskSelectionProvider);
      }
    });
  }
  
  public void indicateActiveTask()
  {
    if ((activeTaskLabel != null) && (activeTaskLabel.isDisposed())) {
      return;
    }
    activeTaskLabel.setText(activeTask.getSummary());
    activeTaskLabel.setUnderlined(true);
    activeTaskLabel.setToolTipText(activeTask.getSummary());
    activeTaskSelectionProvider.setSelection(new StructuredSelection(activeTask));
  }
  
  public void indicateNoActiveTask()
  {
    if ((activeTaskLabel != null) && (activeTaskLabel.isDisposed())) {
      return;
    }
    activeTaskLabel.setText(Messages.TaskTrimWidget__no_active_task_);
    activeTaskLabel.setUnderlined(false);
    activeTaskLabel.setToolTipText("");
    activeTaskSelectionProvider.setSelection(StructuredSelection.EMPTY);
  }
}

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

import java.lang.reflect.Method;
import java.util.ArrayList;
import org.eclipse.ui.IFolderLayout;
import org.eclipse.ui.IPageLayout;
import org.eclipse.ui.IPerspectiveFactory;

public class PlanningPerspectiveFactory
  implements IPerspectiveFactory
{
  public void createInitialLayout(IPageLayout layout)
  {
    defineActions(layout);
    defineLayout(layout);
  }
  
  public void defineActions(IPageLayout layout)
  {
    layout.addShowViewShortcut("org.eclipse.ui.views.ResourceNavigator");
    layout.addShowViewShortcut("org.eclipse.ui.views.PropertySheet");
    layout.addShowViewShortcut("org.eclipse.mylyn.tasks.ui.views.tasks");
    
    layout.addActionSet("org.eclipse.ui.NavigateActionSet");
    removeUninterestingActionSets(layout);
  }
  
  public void defineLayout(IPageLayout layout)
  {
    String editorArea = layout.getEditorArea();
    
    IFolderLayout topRight = layout.createFolder("topRight", 2, 0.6F, editorArea);
    topRight.addView("org.eclipse.mylyn.tasks.ui.views.tasks");
    
    topRight.addPlaceholder("org.eclipse.ui.views.ResourceNavigator");
  }
  
  public static void removeUninterestingActionSets(IPageLayout layout)
  {
    try
    {
      Class<?> clazz = Class.forName("org.eclipse.ui.internal.PageLayout");
      if ((clazz != null) && (clazz.isInstance(layout)))
      {
        Method method = clazz.getDeclaredMethod("getActionSets", new Class[0]);
        ArrayList<?> actionSets = (ArrayList)method.invoke(layout, new Object[0]);
        actionSets.remove("org.eclipse.ui.edit.text.actionSet.annotationNavigation");
        actionSets.remove("org.eclipse.ui.edit.text.actionSet.convertLineDelimitersTo");
        actionSets.remove("org.eclipse.ui.externaltools.ExternalToolsSet");
      }
    }
    catch (Exception localException) {}
  }
}

/* Location:
 * Qualified Name:     org.eclipse.mylyn.internal.tasks.ui.PlanningPerspectiveFactory
 * Java Class Version
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