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

16:46:58.060 INFO  jd.cli.Main - Decompiling org.eclipse.mylyn.team.ui_3.7.1.v20120425-0100.jar
package org.eclipse.mylyn.team.ui;

import java.util.Set;
import org.eclipse.mylyn.internal.tasks.core.TaskContainerDelta;
import org.eclipse.mylyn.internal.tasks.core.TaskContainerDelta.Kind;
import org.eclipse.mylyn.internal.tasks.ui.editors.TaskListChangeAdapter;
import org.eclipse.mylyn.tasks.core.ITask;

class AbstractContextChangeSetManager$1
  extends TaskListChangeAdapter
{
  AbstractContextChangeSetManager$1(AbstractContextChangeSetManager paramAbstractContextChangeSetManager) {}
  
  public void containersChanged(Set<TaskContainerDelta> containers)
  {
    for (TaskContainerDelta taskContainerDelta : containers)
    {
      if ((taskContainerDelta.getKind() == TaskContainerDelta.Kind.ROOT) && (!AbstractContextChangeSetManager.access$0(this$0)))
      {
        this$0.initContextChangeSets();
        AbstractContextChangeSetManager.access$1(this$0, true);
      }
      if ((taskContainerDelta.getElement() instanceof ITask))
      {
        ITask task = (ITask)taskContainerDelta.getElement();
        switch (taskContainerDelta.getKind())
        {
        case DELETED: 
          this$0.updateChangeSetLabel(task);
        }
      }
    }
  }
}

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

import org.eclipse.core.resources.IResource;
import org.eclipse.core.runtime.CoreException;
import org.eclipse.mylyn.tasks.core.ITask;

public abstract interface IContextChangeSet
{
  public abstract ITask getTask();
  
  public abstract void updateLabel();
  
  public abstract void restoreResources(IResource[] paramArrayOfIResource)
    throws CoreException;
  
  public abstract String getComment(boolean paramBoolean);
}

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

import org.eclipse.mylyn.internal.tasks.core.LocalTask;
import org.eclipse.mylyn.internal.team.ui.ContextChangeSet;
import org.eclipse.mylyn.tasks.core.ITask;
import org.eclipse.team.internal.core.subscribers.ActiveChangeSet;
import org.eclipse.team.internal.core.subscribers.ActiveChangeSetManager;

public abstract class AbstractActiveChangeSetProvider
{
  private static final String LABEL_NO_TASK = "<No Active Task>";
  private static final String HANDLE_NO_TASK = "org.eclipse.mylyn.team.ui.inactive.proxy";
  private final ITask noTaskActiveProxy = new LocalTask("org.eclipse.mylyn.team.ui.inactive.proxy", "<No Active Task>");
  
  public ActiveChangeSetManager getActiveChangeSetManager()
  {
    return null;
  }
  
  public IContextChangeSet createChangeSet(ITask task)
  {
    return new ContextChangeSet(task, getActiveChangeSetManager());
  }
  
  public void activateDefaultChangeSet()
  {
    ActiveChangeSet noTaskSet = null;
    ActiveChangeSetManager manager = getActiveChangeSetManager();
    if (manager != null)
    {
      noTaskSet = manager.getSet("<No Active Task>");
      if (noTaskSet == null)
      {
        noTaskSet = (ActiveChangeSet)createChangeSet(noTaskActiveProxy);
        manager.add(noTaskSet);
      }
      manager.makeDefault(noTaskSet);
      noTaskSet.remove(noTaskSet.getResources());
      manager.remove(noTaskSet);
    }
  }
}

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

import java.util.HashSet;
import java.util.Iterator;
import java.util.Set;
import org.eclipse.core.resources.IProject;
import org.eclipse.core.resources.IResource;
import org.eclipse.jface.dialogs.MessageDialog;
import org.eclipse.jface.preference.IPreferenceStore;
import org.eclipse.mylyn.commons.workbench.WorkbenchUtil;
import org.eclipse.mylyn.internal.tasks.ui.TasksUiPlugin;
import org.eclipse.mylyn.internal.team.ui.FocusedTeamUiPlugin;
import org.eclipse.mylyn.internal.team.ui.Messages;
import org.eclipse.mylyn.internal.team.ui.properties.TeamPropertiesLinkProvider;
import org.eclipse.mylyn.internal.team.ui.templates.CommitTemplateManager;
import org.eclipse.mylyn.tasks.core.ITask;
import org.eclipse.mylyn.tasks.core.TaskRepository;
import org.eclipse.swt.widgets.Display;

public class TeamUiUtil
{
  public static String getComment(boolean checkTaskRepository, ITask task, IResource[] resources)
  {
    String template = null;
    Set<IProject> projects = new HashSet();
    Object localObject;
    if (resources != null)
    {
      int j = (localObject = resources).length;
      for (int i = 0; i < j; i++)
      {
        IResource resource = localObject[i];
        IProject project = resource.getProject();
        if ((project != null) && (project.isAccessible()) && (!projects.contains(project)))
        {
          TeamPropertiesLinkProvider provider = new TeamPropertiesLinkProvider();
          template = provider.getCommitCommentTemplate(project);
          if (template != null) {
            break;
          }
          projects.add(project);
        }
      }
    }
    boolean proceed = true;
    if (checkTaskRepository)
    {
      boolean unmatchedRepositoryFound = false;
      for (localObject = projects.iterator(); ((Iterator)localObject).hasNext();)
      {
        IProject project = (IProject)((Iterator)localObject).next();
        TaskRepository repository = TasksUiPlugin.getDefault().getRepositoryForResource(project);
        if ((repository != null) && 
          (!repository.getRepositoryUrl().equals(task.getRepositoryUrl()))) {
          unmatchedRepositoryFound = true;
        }
      }
      if (unmatchedRepositoryFound) {
        if (Display.getCurrent() != null) {
          proceed = MessageDialog.openQuestion(WorkbenchUtil.getShell(), 
            Messages.ContextChangeSet_Mylyn_Change_Set_Management, 
            Messages.ContextChangeSet_ATTEMPTING_TO_COMMIT_RESOURCE);
        } else {
          proceed = false;
        }
      }
    }
    if (proceed)
    {
      if (template == null) {
        template = 
        
          FocusedTeamUiPlugin.getDefault().getPreferenceStore().getString("org.eclipse.mylyn.team.commit.template");
      }
      return FocusedTeamUiPlugin.getDefault().getCommitTemplateManager().generateComment(task, template);
    }
    return "";
  }
}

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

import java.util.Set;
import org.eclipse.mylyn.context.core.AbstractContextListener;
import org.eclipse.mylyn.context.core.ContextCore;
import org.eclipse.mylyn.context.core.IInteractionContextManager;
import org.eclipse.mylyn.internal.tasks.core.ITaskList;
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.ui.editors.TaskListChangeAdapter;
import org.eclipse.mylyn.internal.tasks.ui.util.TasksUiInternal;
import org.eclipse.mylyn.tasks.core.ITask;

public abstract class AbstractContextChangeSetManager
  extends AbstractContextListener
{
  protected boolean isEnabled = false;
  private boolean isInitialized = false;
  
  public void enable()
  {
    if (!isEnabled)
    {
      isEnabled = true;
      TasksUiInternal.getTaskList().addChangeListener(WORKING_SET_LABEL_UPDATE_LISTENER);
      if (!isInitialized) {
        initContextChangeSets();
      }
      if (ContextCore.getContextManager().isContextActive()) {
        contextActivated(ContextCore.getContextManager().getActiveContext());
      }
      ContextCore.getContextManager().addListener(this);
    }
  }
  
  public void disable()
  {
    ContextCore.getContextManager().removeListener(this);
    TasksUiInternal.getTaskList().removeChangeListener(WORKING_SET_LABEL_UPDATE_LISTENER);
    isEnabled = false;
  }
  
  private final ITaskListChangeListener WORKING_SET_LABEL_UPDATE_LISTENER = new TaskListChangeAdapter()
  {
    public void containersChanged(Set<TaskContainerDelta> containers)
    {
      for (TaskContainerDelta taskContainerDelta : containers)
      {
        if ((taskContainerDelta.getKind() == TaskContainerDelta.Kind.ROOT) && (!isInitialized))
        {
          initContextChangeSets();
          isInitialized = true;
        }
        if ((taskContainerDelta.getElement() instanceof ITask))
        {
          ITask task = (ITask)taskContainerDelta.getElement();
          switch (taskContainerDelta.getKind())
          {
          case DELETED: 
            updateChangeSetLabel(task);
          }
        }
      }
    }
  };
  
  protected abstract void initContextChangeSets();
  
  protected abstract void updateChangeSetLabel(ITask paramITask);
}

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

import org.eclipse.mylyn.tasks.core.ITask;

public abstract class AbstractCommitTemplateVariable
{
  protected String description;
  protected String recognizedKeyword;
  
  public String getDescription()
  {
    return "Handler for '" + recognizedKeyword + "'";
  }
  
  public void setDescription(String description)
  {
    this.description = description;
  }
  
  public String getRecognizedKeyword()
  {
    return recognizedKeyword;
  }
  
  public abstract String getValue(ITask paramITask);
  
  public void setRecognizedKeyword(String recognizedKeyword)
  {
    if (recognizedKeyword == null) {
      throw new IllegalArgumentException("Keyword to recognize must not be null");
    }
    this.recognizedKeyword = recognizedKeyword;
  }
}

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

public abstract class AbstractTaskReference
{
  public abstract String getTaskId();
  
  public abstract String getTaskUrl();
  
  public abstract String getRepositoryUrl();
  
  public abstract String getText();
}

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

import java.util.ArrayList;
import java.util.Collection;
import java.util.HashMap;
import java.util.Iterator;
import java.util.List;
import java.util.Map;
import org.eclipse.core.resources.IResource;
import org.eclipse.core.runtime.IPath;
import org.eclipse.core.runtime.Status;
import org.eclipse.mylyn.commons.core.StatusHandler;
import org.eclipse.mylyn.context.core.IInteractionContext;
import org.eclipse.mylyn.context.core.IInteractionElement;
import org.eclipse.mylyn.tasks.core.IRepositoryModel;
import org.eclipse.mylyn.tasks.core.ITask;
import org.eclipse.mylyn.tasks.core.ITaskActivityManager;
import org.eclipse.mylyn.tasks.ui.TasksUi;
import org.eclipse.mylyn.team.ui.AbstractActiveChangeSetProvider;
import org.eclipse.mylyn.team.ui.AbstractContextChangeSetManager;
import org.eclipse.mylyn.team.ui.IContextChangeSet;
import org.eclipse.team.internal.core.subscribers.ActiveChangeSet;
import org.eclipse.team.internal.core.subscribers.ActiveChangeSetManager;
import org.eclipse.team.internal.core.subscribers.ChangeSet;
import org.eclipse.team.internal.core.subscribers.IChangeSetChangeListener;

public class ContextActiveChangeSetManager
  extends AbstractContextChangeSetManager
{
  private final List<ActiveChangeSetManager> changeSetManagers = new ArrayList();
  private final List<IContextChangeSet> activeChangeSets = new ArrayList();
  private final Map<ActiveChangeSetManager, ActiveChangeSet> noTaskSetMap = new HashMap();
  private final Map<ActiveChangeSetManager, ChangeSetChangeListener> listenerByManager = new HashMap();
  
  private class ChangeSetChangeListener
    implements IChangeSetChangeListener
  {
    private final ActiveChangeSetManager manager;
    
    public ChangeSetChangeListener(ActiveChangeSetManager manager)
    {
      this.manager = manager;
    }
    
    public void setRemoved(ChangeSet set)
    {
      if ((set instanceof IContextChangeSet))
      {
        IContextChangeSet contextChangeSet = (IContextChangeSet)set;
        if ((contextChangeSet.getTask() != null) && (contextChangeSet.getTask().isActive())) {
          manager.add((ActiveChangeSet)contextChangeSet);
        }
      }
    }
    
    public void setAdded(ChangeSet set) {}
    
    public void defaultSetChanged(ChangeSet previousDefault, ChangeSet set) {}
    
    public void nameChanged(ChangeSet set) {}
    
    public void resourcesChanged(ChangeSet set, IPath[] paths) {}
  }
  
  public ContextActiveChangeSetManager()
  {
    Collection<AbstractActiveChangeSetProvider> providerList = FocusedTeamUiPlugin.getDefault()
      .getActiveChangeSetProviders();
    for (AbstractActiveChangeSetProvider provider : providerList)
    {
      ActiveChangeSetManager changeSetManager = provider.getActiveChangeSetManager();
      if (changeSetManager != null) {
        changeSetManagers.add(changeSetManager);
      }
    }
  }
  
  protected void updateChangeSetLabel(ITask task)
  {
    int j;
    int i;
    for (Iterator localIterator = changeSetManagers.iterator(); localIterator.hasNext(); i < j)
    {
      ActiveChangeSetManager collector = (ActiveChangeSetManager)localIterator.next();
      ChangeSet[] sets = collector.getSets();
      ChangeSet[] arrayOfChangeSet1;
      j = (arrayOfChangeSet1 = sets).length;i = 0; continue;ChangeSet set = arrayOfChangeSet1[i];
      if ((set instanceof IContextChangeSet))
      {
        IContextChangeSet contextChangeSet = (IContextChangeSet)set;
        if (contextChangeSet.getTask().equals(task)) {
          contextChangeSet.updateLabel();
        }
      }
      i++;
    }
  }
  
  public void enable()
  {
    super.enable();
    for (ActiveChangeSetManager collector : changeSetManagers)
    {
      ChangeSetChangeListener listener = (ChangeSetChangeListener)listenerByManager.get(collector);
      if (listener == null)
      {
        listener = new ChangeSetChangeListener(collector);
        listenerByManager.put(collector, listener);
        collector.addListener(listener);
      }
    }
  }
  
  public void disable()
  {
    super.disable();
    for (ActiveChangeSetManager collector : changeSetManagers)
    {
      ChangeSetChangeListener listener = (ChangeSetChangeListener)listenerByManager.get(collector);
      if (listener != null)
      {
        collector.removeListener(listener);
        listenerByManager.remove(collector);
      }
    }
  }
  
  protected void initContextChangeSets()
  {
    int j;
    int i;
    for (Iterator localIterator = changeSetManagers.iterator(); localIterator.hasNext(); i < j)
    {
      ActiveChangeSetManager manager = (ActiveChangeSetManager)localIterator.next();
      ChangeSet[] sets = manager.getSets();
      ChangeSet[] arrayOfChangeSet1;
      j = (arrayOfChangeSet1 = sets).length;i = 0; continue;ChangeSet restoredSet = arrayOfChangeSet1[i];
      if (!(restoredSet instanceof IContextChangeSet))
      {
        String encodedTitle = restoredSet.getName();
        String taskHandle = ContextChangeSet.getHandleFromPersistedTitle(encodedTitle);
        ITask task = TasksUi.getRepositoryModel().getTask(taskHandle);
        if (task != null) {
          try
          {
            IContextChangeSet contextChangeSet = getOrCreateSet(manager, task);
            if ((contextChangeSet instanceof ActiveChangeSet))
            {
              contextChangeSet.restoreResources(restoredSet.getResources());
              manager.remove(restoredSet);
              manager.add((ActiveChangeSet)contextChangeSet);
            }
          }
          catch (Exception e)
          {
            StatusHandler.log(new Status(4, "org.eclipse.mylyn.team.ui", 
              "Could not restore change set", e));
          }
        }
      }
      i++;
    }
  }
  
  public void clearActiveChangeSets()
  {
    activeChangeSets.clear();
  }
  
  public IResource[] getResources(ITask task)
  {
    int j;
    int i;
    for (Iterator localIterator = changeSetManagers.iterator(); localIterator.hasNext(); i < j)
    {
      ActiveChangeSetManager collector = (ActiveChangeSetManager)localIterator.next();
      ChangeSet[] sets = collector.getSets();
      ChangeSet[] arrayOfChangeSet1;
      j = (arrayOfChangeSet1 = sets).length;i = 0; continue;ChangeSet set = arrayOfChangeSet1[i];
      if ((set instanceof IContextChangeSet))
      {
        IContextChangeSet contextChangeSet = (IContextChangeSet)set;
        if ((contextChangeSet.getTask().equals(task)) && ((contextChangeSet instanceof ActiveChangeSet))) {
          return ((ActiveChangeSet)contextChangeSet).getResources();
        }
      }
      i++;
    }
    return null;
  }
  
  public void contextActivated(IInteractionContext context)
  {
    try
    {
      ITask task = getTask(context);
      if (task != null) {
        for (ActiveChangeSetManager manager : changeSetManagers)
        {
          IContextChangeSet contextChangeSet = getOrCreateSet(manager, task);
          if ((contextChangeSet instanceof ActiveChangeSet))
          {
            ActiveChangeSet activeChangeSet = (ActiveChangeSet)contextChangeSet;
            
            activeChangeSets.add(contextChangeSet);
            
            manager.makeDefault(activeChangeSet);
          }
        }
      }
    }
    catch (Exception e)
    {
      StatusHandler.log(new Status(4, "org.eclipse.mylyn.team.ui", "Could not update change set", e));
    }
  }
  
  private IContextChangeSet getOrCreateSet(ActiveChangeSetManager manager, ITask task)
  {
    ChangeSet[] sets = manager.getSets();
    ChangeSet[] arrayOfChangeSet1;
    int j = (arrayOfChangeSet1 = sets).length;
    for (int i = 0; i < j; i++)
    {
      ChangeSet set = arrayOfChangeSet1[i];
      if (((set instanceof IContextChangeSet)) && (task.equals(((IContextChangeSet)set).getTask()))) {
        return (IContextChangeSet)set;
      }
    }
    AbstractActiveChangeSetProvider provider = FocusedTeamUiPlugin.getDefault().getActiveChangeSetProvider(manager);
    return provider.createChangeSet(task);
  }
  
  public void contextDeactivated(IInteractionContext context)
  {
    for (ActiveChangeSetManager collector : changeSetManagers)
    {
      ChangeSet[] sets = collector.getSets();
      ChangeSet[] arrayOfChangeSet1;
      int j = (arrayOfChangeSet1 = sets).length;
      for (int i = 0; i < j; i++)
      {
        ChangeSet set = arrayOfChangeSet1[i];
        if ((set instanceof ActiveChangeSet))
        {
          IResource[] resources = set.getResources();
          if ((resources == null) || (resources.length == 0)) {
            collector.remove(set);
          }
        }
      }
      AbstractActiveChangeSetProvider changeSetProvider = FocusedTeamUiPlugin.getDefault()
        .getActiveChangeSetProvider(collector);
      
      changeSetProvider.activateDefaultChangeSet();
    }
    activeChangeSets.clear();
  }
  
  public void interestChanged(List<IInteractionElement> elements) {}
  
  public List<IContextChangeSet> getActiveChangeSets()
  {
    return new ArrayList(activeChangeSets);
  }
  
  private ITask getTask(IInteractionContext context)
  {
    return TasksUi.getTaskActivityManager().getActiveTask();
  }
}

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

import java.util.Collection;
import java.util.Collections;
import java.util.HashMap;
import java.util.HashSet;
import java.util.Map;
import java.util.Set;
import org.eclipse.core.runtime.Status;
import org.eclipse.jface.preference.IPreferenceStore;
import org.eclipse.mylyn.commons.core.StatusHandler;
import org.eclipse.mylyn.internal.team.ui.templates.CommitTemplateManager;
import org.eclipse.mylyn.team.ui.AbstractActiveChangeSetProvider;
import org.eclipse.mylyn.team.ui.AbstractContextChangeSetManager;
import org.eclipse.swt.widgets.Display;
import org.eclipse.team.internal.core.subscribers.ActiveChangeSetManager;
import org.eclipse.ui.IStartup;
import org.eclipse.ui.IWorkbench;
import org.eclipse.ui.PlatformUI;
import org.eclipse.ui.plugin.AbstractUIPlugin;
import org.osgi.framework.BundleContext;

public class FocusedTeamUiPlugin
  extends AbstractUIPlugin
{
  public static final String ID_PLUGIN = "org.eclipse.mylyn.team.ui";
  private static FocusedTeamUiPlugin INSTANCE;
  private final Set<AbstractContextChangeSetManager> changeSetManagers = new HashSet();
  private final Map<ActiveChangeSetManager, AbstractActiveChangeSetProvider> activeChangeSetProviders = new HashMap();
  private CommitTemplateManager commitTemplateManager;
  public static final String CHANGE_SET_MANAGE = "org.eclipse.mylyn.team.changesets.manage";
  public static final String COMMIT_TEMPLATE = "org.eclipse.mylyn.team.commit.template";
  public static final String DEFAULT_COMMIT_TEMPLATE = "${task.status} - ${connector.task.prefix} ${task.key}: ${task.description} \n${task.url}";
  private static final String OLD_DEFAULT_COMMIT_TEMPLATE = "${task.status} - ${connector.task.prefix} ${task.id}: ${task.description} \n${task.url}";
  private static final String OLD_DEFAULT_COMMIT_TEMPLATE2 = "${task.status} - ${connector.task.prefix} ${task.id}: ${task.description} \r\n${task.url}";
  
  public FocusedTeamUiPlugin()
  {
    INSTANCE = this;
  }
  
  public void start(BundleContext context)
    throws Exception
  {
    super.start(context);
    initPreferenceDefaults();
    commitTemplateManager = new CommitTemplateManager();
    
    PlatformUI.getWorkbench().getDisplay().asyncExec(new Runnable()
    {
      public void run()
      {
        try
        {
          FocusedTeamExtensionPointReader extensionPointReader = new FocusedTeamExtensionPointReader();
          extensionPointReader.readExtensions();
          if (getPreferenceStore().getBoolean("org.eclipse.mylyn.team.changesets.manage")) {
            for (AbstractContextChangeSetManager changeSetManager : changeSetManagers) {
              changeSetManager.enable();
            }
          }
        }
        catch (Exception e)
        {
          StatusHandler.log(new Status(4, "org.eclipse.mylyn.team.ui", 
            "Mylyn Team start failed", e));
        }
      }
    });
  }
  
  public void stop(BundleContext context)
    throws Exception
  {
    INSTANCE = null;
    super.stop(context);
    for (AbstractContextChangeSetManager changeSetManager : changeSetManagers) {
      changeSetManager.disable();
    }
  }
  
  private void initPreferenceDefaults()
  {
    getPreferenceStore().setDefault("org.eclipse.mylyn.team.changesets.manage", true);
    getPreferenceStore().setDefault("org.eclipse.mylyn.team.commit.template", "${task.status} - ${connector.task.prefix} ${task.key}: ${task.description} \n${task.url}");
    if ((getPreferenceStore().getString("org.eclipse.mylyn.team.commit.template").equals("${task.status} - ${connector.task.prefix} ${task.id}: ${task.description} \n${task.url}")) || 
      (getPreferenceStore().getString("org.eclipse.mylyn.team.commit.template").equals("${task.status} - ${connector.task.prefix} ${task.id}: ${task.description} \r\n${task.url}"))) {
      getPreferenceStore().setValue("org.eclipse.mylyn.team.commit.template", "${task.status} - ${connector.task.prefix} ${task.key}: ${task.description} \n${task.url}");
    }
  }
  
  public static FocusedTeamUiPlugin getDefault()
  {
    return INSTANCE;
  }
  
  public void addContextChangeSetManager(AbstractContextChangeSetManager changeSetManager)
  {
    changeSetManagers.add(changeSetManager);
  }
  
  public boolean removeContextChangeSetManager(AbstractContextChangeSetManager changeSetManager)
  {
    return changeSetManagers.remove(changeSetManager);
  }
  
  public void addActiveChangeSetProvider(AbstractActiveChangeSetProvider provider)
  {
    ActiveChangeSetManager manager = provider.getActiveChangeSetManager();
    if (manager != null) {
      activeChangeSetProviders.put(manager, provider);
    }
  }
  
  public Collection<AbstractActiveChangeSetProvider> getActiveChangeSetProviders()
  {
    return activeChangeSetProviders.values();
  }
  
  public AbstractActiveChangeSetProvider getActiveChangeSetProvider(ActiveChangeSetManager manager)
  {
    return (AbstractActiveChangeSetProvider)activeChangeSetProviders.get(manager);
  }
  
  public Set<AbstractContextChangeSetManager> getContextChangeSetManagers()
  {
    return Collections.unmodifiableSet(changeSetManagers);
  }
  
  public CommitTemplateManager getCommitTemplateManager()
  {
    return commitTemplateManager;
  }
  
  public static class FocusedTeamUiStartup
    implements IStartup
  {
    public void earlyStartup() {}
  }
}

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

import org.eclipse.compare.structuremergeviewer.IDiffElement;
import org.eclipse.core.resources.IResource;
import org.eclipse.core.runtime.IAdaptable;
import org.eclipse.core.runtime.IAdapterFactory;
import org.eclipse.core.runtime.IAdapterManager;
import org.eclipse.core.runtime.Platform;
import org.eclipse.mylyn.internal.tasks.ui.TasksUiPlugin;
import org.eclipse.mylyn.tasks.core.TaskRepository;
import org.eclipse.mylyn.team.ui.AbstractTaskReference;
import org.eclipse.mylyn.team.ui.IContextChangeSet;
import org.eclipse.team.core.history.IFileRevision;
import org.eclipse.team.internal.core.subscribers.ChangeSet;
import org.eclipse.team.internal.core.subscribers.DiffChangeSet;
import org.eclipse.team.internal.ui.synchronize.ChangeSetDiffNode;
import org.eclipse.team.internal.ui.synchronize.SynchronizeModelElement;

public class LinkedTaskInfoAdapterFactory
  implements IAdapterFactory
{
  private static final Class<?>[] ADAPTER_TYPES = { AbstractTaskReference.class };
  
  public Object getAdapter(Object object, Class adapterType)
  {
    if (!AbstractTaskReference.class.equals(adapterType)) {
      return null;
    }
    if ((object instanceof ChangeSetDiffNode)) {
      return adaptChangeSetDiffNode(object);
    }
    return adaptFromComment(object);
  }
  
  public Class[] getAdapterList()
  {
    return ADAPTER_TYPES;
  }
  
  private AbstractTaskReference adaptChangeSetDiffNode(Object object)
  {
    ChangeSetDiffNode diffNode = (ChangeSetDiffNode)object;
    ChangeSet set = diffNode.getSet();
    
    Object adapter = null;
    if ((set instanceof IAdaptable)) {
      adapter = ((IAdaptable)set).getAdapter(AbstractTaskReference.class);
    }
    if (adapter == null) {
      adapter = Platform.getAdapterManager().getAdapter(set, AbstractTaskReference.class);
    }
    if (adapter != null) {
      return (AbstractTaskReference)adapter;
    }
    return adaptFromComment(object);
  }
  
  private AbstractTaskReference adaptFromComment(Object object)
  {
    String comment = getCommentForElement(object);
    if (comment == null) {
      return null;
    }
    IResource resource = getResourceForElement(object);
    if (resource != null)
    {
      TaskRepository repository = TasksUiPlugin.getDefault().getRepositoryForResource(resource);
      if (repository != null) {
        return new LinkedTaskInfo(repository.getRepositoryUrl(), null, null, comment);
      }
    }
    return new LinkedTaskInfo(null, null, null, comment);
  }
  
  private static String getCommentForElement(Object element)
  {
    if ((element instanceof IContextChangeSet)) {
      return ((IContextChangeSet)element).getComment(false);
    }
    if ((element instanceof DiffChangeSet)) {
      return ((DiffChangeSet)element).getComment();
    }
    if ((element instanceof ChangeSetDiffNode)) {
      return ((ChangeSetDiffNode)element).getName();
    }
    if ((element instanceof IFileRevision)) {
      return ((IFileRevision)element).getComment();
    }
    return null;
  }
  
  private static IResource getResourceForElement(Object element)
  {
    if ((element instanceof DiffChangeSet))
    {
      IResource[] resources = ((DiffChangeSet)element).getResources();
      if (resources.length > 0) {
        return resources[0];
      }
    }
    if ((element instanceof SynchronizeModelElement))
    {
      SynchronizeModelElement modelElement = (SynchronizeModelElement)element;
      IResource resource = modelElement.getResource();
      if (resource != null) {
        return resource;
      }
      IDiffElement[] elements = modelElement.getChildren();
      if (elements.length > 0) {
        if ((elements[0] instanceof SynchronizeModelElement)) {
          return ((SynchronizeModelElement)elements[0]).getResource();
        }
      }
    }
    return null;
  }
}

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

import java.util.Iterator;
import java.util.Set;
import org.eclipse.jface.fieldassist.IContentProposalProvider;
import org.eclipse.jface.fieldassist.IControlContentAdapter;
import org.eclipse.jface.fieldassist.TextContentAdapter;
import org.eclipse.jface.preference.IPreferenceStore;
import org.eclipse.jface.preference.PreferencePage;
import org.eclipse.mylyn.internal.team.ui.FocusedTeamUiPlugin;
import org.eclipse.mylyn.internal.team.ui.templates.TemplateHandlerContentProposalProvider;
import org.eclipse.mylyn.team.ui.AbstractContextChangeSetManager;
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.Group;
import org.eclipse.swt.widgets.Text;
import org.eclipse.ui.IWorkbench;
import org.eclipse.ui.IWorkbenchPreferencePage;
import org.eclipse.ui.fieldassist.ContentAssistCommandAdapter;

public class FocusedTeamPreferencePage
  extends PreferencePage
  implements IWorkbenchPreferencePage
{
  public static final String PAGE_ID = "org.eclipse.mylyn.team.ui.ui.preferences";
  private Button manageChangeSets;
  private Text commitTemplate = null;
  
  public FocusedTeamPreferencePage()
  {
    setPreferenceStore(FocusedTeamUiPlugin.getDefault().getPreferenceStore());
  }
  
  protected Control createContents(Composite parent)
  {
    Composite container = new Composite(parent, 0);
    GridLayout layout = new GridLayout(1, false);
    container.setLayout(layout);
    
    createChangeSetGroup(container);
    createCommitGroup(container);
    applyDialogFont(container);
    return container;
  }
  
  public void init(IWorkbench workbench) {}
  
  public boolean performOk()
  {
    getPreferenceStore().setValue("org.eclipse.mylyn.team.commit.template", commitTemplate.getText());
    getPreferenceStore().setValue("org.eclipse.mylyn.team.changesets.manage", manageChangeSets.getSelection());
    Iterator localIterator;
    if (manageChangeSets.getSelection())
    {
      localIterator = FocusedTeamUiPlugin.getDefault().getContextChangeSetManagers().iterator();
      while (localIterator.hasNext())
      {
        AbstractContextChangeSetManager changeSetManager = (AbstractContextChangeSetManager)localIterator.next();
        changeSetManager.enable();
      }
    }
    else
    {
      localIterator = FocusedTeamUiPlugin.getDefault().getContextChangeSetManagers().iterator();
      while (localIterator.hasNext())
      {
        AbstractContextChangeSetManager changeSetManager = (AbstractContextChangeSetManager)localIterator.next();
        changeSetManager.disable();
      }
    }
    return true;
  }
  
  public boolean performCancel()
  {
    return true;
  }
  
  public void performDefaults()
  {
    super.performDefaults();
    commitTemplate.setText(getPreferenceStore().getDefaultString("org.eclipse.mylyn.team.commit.template"));
    manageChangeSets.setSelection(getPreferenceStore().getDefaultBoolean("org.eclipse.mylyn.team.changesets.manage"));
  }
  
  private void createChangeSetGroup(Composite parent)
  {
    Group group = new Group(parent, 16);
    group.setText(Messages.FocusedTeamPreferencePage_Change_Set_Management);
    group.setLayout(new GridLayout(1, false));
    group.setLayoutData(new GridData(768));
    
    manageChangeSets = new Button(group, 32);
    manageChangeSets.setText(Messages.FocusedTeamPreferencePage_Automatically_create_and_manage_with_task_context);
    manageChangeSets.setSelection(getPreferenceStore().getBoolean("org.eclipse.mylyn.team.changesets.manage"));
  }
  
  private void createCommitGroup(Composite parent)
  {
    Group group = new Group(parent, 16);
    group.setText(Messages.FocusedTeamPreferencePage_Commit_Comment_Template);
    group.setLayout(new GridLayout(2, false));
    group.setLayoutData(new GridData(768));
    
    String completedTemplate = getPreferenceStore().getString("org.eclipse.mylyn.team.commit.template");
    commitTemplate = addTemplateField(group, completedTemplate, new TemplateHandlerContentProposalProvider());
  }
  
  private Text addTemplateField(Composite parent, String text, IContentProposalProvider provider)
  {
    IControlContentAdapter adapter = new TextContentAdapter();
    Text control = new Text(parent, 2050);
    control.setText(text);
    
    new ContentAssistCommandAdapter(control, adapter, provider, null, new char[] { '$' }, true);
    
    GridData gd = new GridData();
    heightHint = 60;
    horizontalAlignment = 4;
    grabExcessHorizontalSpace = true;
    verticalAlignment = 2;
    grabExcessVerticalSpace = false;
    control.setLayoutData(gd);
    
    return control;
  }
}

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

import org.eclipse.osgi.util.NLS;

public class Messages
  extends NLS
{
  private static final String BUNDLE_NAME = "org.eclipse.mylyn.internal.team.ui.preferences.messages";
  public static String FocusedTeamPreferencePage_Automatically_create_and_manage_with_task_context;
  public static String FocusedTeamPreferencePage_Change_Set_Management;
  public static String FocusedTeamPreferencePage_Commit_Comment_Template;
  
  static {}
  
  public static void reloadMessages()
  {
    NLS.initializeMessages("org.eclipse.mylyn.internal.team.ui.preferences.messages", Messages.class);
  }
}

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

import org.eclipse.jface.viewers.IDecoration;
import org.eclipse.jface.viewers.ILabelProviderListener;
import org.eclipse.jface.viewers.ILightweightLabelDecorator;
import org.eclipse.mylyn.commons.ui.compatibility.CommonFonts;
import org.eclipse.mylyn.tasks.core.ITask;
import org.eclipse.mylyn.team.ui.IContextChangeSet;

public class ContextChangeSetDecorator
  implements ILightweightLabelDecorator
{
  public void decorate(Object element, IDecoration decoration)
  {
    if ((element instanceof IContextChangeSet))
    {
      IContextChangeSet changeSet = (IContextChangeSet)element;
      if (changeSet.getTask().isActive()) {
        decoration.setFont(CommonFonts.BOLD);
      }
    }
  }
  
  public void addListener(ILabelProviderListener listener) {}
  
  public void dispose() {}
  
  public boolean isLabelProperty(Object element, String property)
  {
    return false;
  }
  
  public void removeListener(ILabelProviderListener listener) {}
}

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

import java.util.ArrayList;
import java.util.Arrays;
import java.util.HashSet;
import java.util.List;
import java.util.Set;
import org.eclipse.core.resources.IResource;
import org.eclipse.core.resources.IWorkspace;
import org.eclipse.core.resources.IWorkspaceRoot;
import org.eclipse.core.resources.ResourcesPlugin;
import org.eclipse.core.runtime.CoreException;
import org.eclipse.core.runtime.IAdaptable;
import org.eclipse.core.runtime.IAdapterManager;
import org.eclipse.core.runtime.Platform;
import org.eclipse.mylyn.context.core.ContextCore;
import org.eclipse.mylyn.context.core.IInteractionContextManager;
import org.eclipse.mylyn.internal.resources.ui.ResourcesUiBridgePlugin;
import org.eclipse.mylyn.internal.tasks.core.AbstractTask;
import org.eclipse.mylyn.tasks.core.ITask;
import org.eclipse.mylyn.team.ui.AbstractTaskReference;
import org.eclipse.mylyn.team.ui.IContextChangeSet;
import org.eclipse.mylyn.team.ui.TeamUiUtil;
import org.eclipse.team.core.diff.IDiff;
import org.eclipse.team.core.diff.provider.ThreeWayDiff;
import org.eclipse.team.core.mapping.provider.ResourceDiff;
import org.eclipse.team.internal.core.subscribers.ActiveChangeSet;
import org.eclipse.team.internal.core.subscribers.ActiveChangeSetManager;
import org.osgi.service.prefs.Preferences;

public class ContextChangeSet
  extends ActiveChangeSet
  implements IAdaptable, IContextChangeSet
{
  private static final String CTX_TITLE = "title";
  public static final String SOURCE_ID = "org.eclipse.mylyn.java.context.changeset.add";
  private final ITask task;
  
  public ContextChangeSet(ITask task, ActiveChangeSetManager manager)
  {
    super(manager, task.getSummary());
    this.task = task;
    updateLabel();
  }
  
  public boolean isUserCreated()
  {
    return true;
  }
  
  public void updateLabel()
  {
    super.setName(task.getSummary());
    super.setTitle(task.getSummary());
  }
  
  public void save(Preferences prefs)
  {
    super.save(prefs);
    prefs.put("title", getTitleForPersistance());
  }
  
  private String getTitleForPersistance()
  {
    return getTitle() + " (" + task.getHandleIdentifier() + ")";
  }
  
  public static String getHandleFromPersistedTitle(String title)
  {
    int delimStart = title.lastIndexOf('(');
    int delimEnd = title.lastIndexOf(')');
    if ((delimStart != -1) && (delimEnd != -1)) {
      return title.substring(delimStart + 1, delimEnd);
    }
    return null;
  }
  
  public String getComment()
  {
    return getComment(true);
  }
  
  public String getComment(boolean checkTaskRepository)
  {
    return TeamUiUtil.getComment(checkTaskRepository, task, getChangedResources());
  }
  
  public void remove(IResource resource)
  {
    super.remove(resource);
  }
  
  public void remove(IResource[] newResources)
  {
    super.remove(newResources);
  }
  
  public void add(IDiff diff)
  {
    super.add(diff);
  }
  
  private IResource getResourceFromDiff(IDiff diff)
  {
    if ((diff instanceof ResourceDiff)) {
      return ((ResourceDiff)diff).getResource();
    }
    if ((diff instanceof ThreeWayDiff))
    {
      ThreeWayDiff threeWayDiff = (ThreeWayDiff)diff;
      return ResourcesPlugin.getWorkspace().getRoot().findMember(threeWayDiff.getPath());
    }
    return null;
  }
  
  public void add(IDiff[] diffs)
  {
    super.add(diffs);
  }
  
  public void add(IResource[] newResources)
    throws CoreException
  {
    super.add(newResources);
  }
  
  public void restoreResources(IResource[] newResources)
    throws CoreException
  {
    super.add(newResources);
    setComment(getComment(false));
  }
  
  public IResource[] getResources()
  {
    return super.getResources();
 
1 2 3 4 5

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-2017. Infinite Loop Ltd