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

t != null)
      {
        AbstractContextStructureBridge bridge = ContextCore.getStructureBridge(object);
        element = ContextCore.getContextManager().getElement(bridge.getHandleIdentifier(object));
      }
      if (element == null)
      {
        Object adapter = editorPart.getEditorInput().getAdapter(IResource.class);
        if ((adapter instanceof IResource))
        {
          IResource resource = (IResource)adapter;
          AbstractContextStructureBridge resourceBridge = ContextCore.getStructureBridge(resource);
          element = ContextCore.getContextManager().getElement(resourceBridge.getHandleIdentifier(resource));
        }
      }
      if (element != null) {
        ContextCorePlugin.getContextManager().manipulateInterestForElement(element, false, false, false, 
          "org.eclipse.mylyn.resources.ui.editor.tracker.interest");
      }
    }
  }
  
  private boolean otherEditorsOpenForResource(IEditorPart editorPart)
  {
    Object adapter = editorPart.getEditorInput().getAdapter(IResource.class);
    if ((adapter instanceof IResource))
    {
      IResource resource = (IResource)adapter;
      IWorkbenchPage page = editorPart.getSite().getPage();
      IEditorReference[] arrayOfIEditorReference;
      int j = (arrayOfIEditorReference = page.getEditorReferences()).length;
      for (int i = 0; i < j; i++)
      {
        IEditorReference editorReference = arrayOfIEditorReference[i];
        try
        {
          Object otherAdapter = editorReference.getEditorInput().getAdapter(IResource.class);
          if (((otherAdapter instanceof IResource)) && (otherAdapter.equals(resource))) {
            return true;
          }
        }
        catch (PartInitException localPartInitException) {}
      }
    }
    return false;
  }
}

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

import org.eclipse.jface.util.IPropertyChangeListener;
import org.eclipse.jface.util.PropertyChangeEvent;

class ResourcesUiBridgePlugin$1
  implements IPropertyChangeListener
{
  ResourcesUiBridgePlugin$1(ResourcesUiBridgePlugin paramResourcesUiBridgePlugin) {}
  
  public void propertyChange(PropertyChangeEvent event)
  {
    ResourcesUiBridgePlugin.access$0(this$0);
  }
}

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

import java.util.HashSet;
import java.util.Set;
import org.eclipse.jface.dialogs.Dialog;
import org.eclipse.jface.dialogs.InputDialog;
import org.eclipse.jface.layout.GridDataFactory;
import org.eclipse.jface.layout.GridLayoutFactory;
import org.eclipse.jface.preference.IPreferenceStore;
import org.eclipse.jface.preference.PreferencePage;
import org.eclipse.mylyn.commons.ui.CommonUiUtil;
import org.eclipse.mylyn.internal.resources.ui.ResourcesUiBridgePlugin;
import org.eclipse.mylyn.internal.resources.ui.ResourcesUiExtensionPointReader;
import org.eclipse.mylyn.internal.resources.ui.ResourcesUiPreferenceInitializer;
import org.eclipse.swt.events.SelectionAdapter;
import org.eclipse.swt.events.SelectionEvent;
import org.eclipse.swt.graphics.Color;
import org.eclipse.swt.layout.GridData;
import org.eclipse.swt.layout.GridLayout;
import org.eclipse.swt.widgets.Button;
import org.eclipse.swt.widgets.Composite;
import org.eclipse.swt.widgets.Control;
import org.eclipse.swt.widgets.Display;
import org.eclipse.swt.widgets.Event;
import org.eclipse.swt.widgets.Group;
import org.eclipse.swt.widgets.Label;
import org.eclipse.swt.widgets.Listener;
import org.eclipse.swt.widgets.Table;
import org.eclipse.swt.widgets.TableItem;
import org.eclipse.ui.IWorkbench;
import org.eclipse.ui.IWorkbenchPreferencePage;

public class FocusedResourcesPreferencePage
  extends PreferencePage
  implements IWorkbenchPreferencePage
{
  public static final Color GRAY = new Color(Display.getDefault(), 100, 100, 100);
  private static final String LABEL_AUTOMATIC = Messages.FocusedResourcesPreferencePage__automatic_;
  private Table ignoreTable;
  private Button addButton;
  private Button removeButton;
  private Button resourceMonitoringButton;
  private Group monitoringExclusionsGroup;
  
  public void init(IWorkbench workbench)
  {
    setDescription(Messages.FocusedResourcesPreferencePage_Configure_file_change_monitoring_Description);
  }
  
  protected IPreferenceStore doGetPreferenceStore()
  {
    return ResourcesUiBridgePlugin.getDefault().getPreferenceStore();
  }
  
  protected Control createContents(Composite parent)
  {
    Composite composite = new Composite(parent, 0);
    GridLayoutFactory.fillDefaults().applyTo(composite);
    
    resourceMonitoringButton = new Button(composite, 96);
    resourceMonitoringButton.setText(Messages.FocusedResourcesPreferencePage__Enable_file_change_monitoring_Label);
    boolean resourceModificationsEnabled = getPreferenceStore().getBoolean(
      "org.eclipse.mylyn.ide.resources.resource.monitor.enabled");
    resourceMonitoringButton.setSelection(resourceModificationsEnabled);
    resourceMonitoringButton.setLayoutData(new GridData(768));
    resourceMonitoringButton.addSelectionListener(new SelectionAdapter()
    {
      public void widgetSelected(SelectionEvent e)
      {
        FocusedResourcesPreferencePage.this.updateEnablement();
      }
    });
    createExcludesTable(composite);
    
    updateEnablement();
    
    Dialog.applyDialogFont(composite);
    return composite;
  }
  
  private void updateEnablement()
  {
    boolean enabled = resourceMonitoringButton.getSelection();
    if (enabled != monitoringExclusionsGroup.isEnabled()) {
      CommonUiUtil.setEnabled(monitoringExclusionsGroup, enabled);
    }
    if (enabled) {
      if (ignoreTable.getSelectionCount() > 0) {
        removeButton.setEnabled(true);
      } else {
        removeButton.setEnabled(false);
      }
    }
  }
  
  private void createExcludesTable(Composite parent)
  {
    monitoringExclusionsGroup = new Group(parent, 16);
    monitoringExclusionsGroup.setText(Messages.FocusedResourcesPreferencePage_Resource_Monitoring_Exclusions);
    GridLayout layout = new GridLayout(1, false);
    monitoringExclusionsGroup.setLayoutData(new GridData(1808));
    monitoringExclusionsGroup.setLayout(layout);
    
    Composite composite = new Composite(monitoringExclusionsGroup, 0);
    layout = new GridLayout();
    marginWidth = 0;
    marginHeight = 0;
    numColumns = 2;
    composite.setLayout(layout);
    composite.setLayoutData(new GridData(1808));
    
    Label l1 = new Label(composite, 0);
    l1.setText(Messages.FocusedResourcesPreferencePage_Matching_file_or_directory_names_will_not_be_added_automatically_to_the_context);
    GridData data = new GridData(2);
    horizontalSpan = 2;
    l1.setLayoutData(data);
    
    ignoreTable = new Table(composite, 2048);
    GridDataFactory.fillDefaults().grab(true, true).hint(-1, 200).applyTo(ignoreTable);
    ignoreTable.addListener(13, new Listener()
    {
      public void handleEvent(Event e)
      {
        FocusedResourcesPreferencePage.this.updateEnablement();
      }
    });
    Composite buttons = new Composite(composite, 0);
    buttons.setLayoutData(new GridData(2));
    layout = new GridLayout();
    marginHeight = 0;
    marginWidth = 0;
    buttons.setLayout(layout);
    
    addButton = new Button(buttons, 8);
    addButton.setText(Messages.FocusedResourcesPreferencePage_Add_);
    addButton.addListener(13, new Listener()
    {
      public void handleEvent(Event e)
      {
        FocusedResourcesPreferencePage.this.addIgnore();
      }
    });
    removeButton = new Button(buttons, 8);
    removeButton.setText(Messages.FocusedResourcesPreferencePage_Remove);
    removeButton.setEnabled(false);
    removeButton.addListener(13, new Listener()
    {
      public void handleEvent(Event e)
      {
        FocusedResourcesPreferencePage.this.removeIgnore();
      }
    });
    fillTable(ResourcesUiPreferenceInitializer.getExcludedResourcePatterns(), 
      ResourcesUiPreferenceInitializer.getForcedExcludedResourcePatterns());
    setButtonLayoutData(addButton);
    setButtonLayoutData(removeButton);
  }
  
  public boolean performOk()
  {
    ResourcesUiBridgePlugin.getDefault().getPreferenceStore().setValue("org.eclipse.mylyn.ide.resources.resource.monitor.enabled", 
      resourceMonitoringButton.getSelection());
    
    Set<String> patterns = new HashSet();
    TableItem[] items = ignoreTable.getItems();
    for (int i = 0; i < items.length; i++) {
      if (!items[i].getText().endsWith(LABEL_AUTOMATIC)) {
        patterns.add(items[i].getText());
      }
    }
    ResourcesUiPreferenceInitializer.setExcludedResourcePatterns(patterns);
    return true;
  }
  
  protected void performDefaults()
  {
    super.performDefaults();
    
    boolean resourceModificationsEnabled = ResourcesUiBridgePlugin.getDefault()
      .getPreferenceStore()
      .getDefaultBoolean("org.eclipse.mylyn.ide.resources.resource.monitor.enabled");
    resourceMonitoringButton.setSelection(resourceModificationsEnabled);
    ignoreTable.removeAll();
    fillTable(ResourcesUiExtensionPointReader.getDefaultResourceExclusions(), 
      ResourcesUiPreferenceInitializer.getForcedExcludedResourcePatterns());
  }
  
  private void fillTable(Set<String> ignored, Set<String> forced)
  {
    for (String pattern : ignored)
    {
      TableItem item = new TableItem(ignoreTable, 0);
      item.setText(pattern);
    }
    for (String pattern : forced)
    {
      TableItem item = new TableItem(ignoreTable, 0);
      item.setText(pattern + " " + LABEL_AUTOMATIC);
      item.setForeground(GRAY);
    }
  }
  
  private void addIgnore()
  {
    InputDialog dialog = new InputDialog(getShell(), Messages.FocusedResourcesPreferencePage_Add__IGNORED_RESOURCE, 
      Messages.FocusedResourcesPreferencePage_Enter_pattern_____any_string_, null, null);
    dialog.open();
    if (dialog.getReturnCode() != 0) {
      return;
    }
    String pattern = dialog.getValue();
    if (pattern.equals("")) {
      return;
    }
    TableItem item = new TableItem(ignoreTable, 0);
    item.setText(pattern);
    item.setChecked(true);
  }
  
  private void removeIgnore()
  {
    int[] selection = ignoreTable.getSelectionIndices();
    ignoreTable.remove(selection);
  }
}

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

import org.eclipse.swt.events.SelectionAdapter;
import org.eclipse.swt.events.SelectionEvent;

class FocusedResourcesPreferencePage$1
  extends SelectionAdapter
{
  FocusedResourcesPreferencePage$1(FocusedResourcesPreferencePage paramFocusedResourcesPreferencePage) {}
  
  public void widgetSelected(SelectionEvent e)
  {
    FocusedResourcesPreferencePage.access$0(this$0);
  }
}

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

import org.eclipse.swt.widgets.Event;
import org.eclipse.swt.widgets.Listener;

class FocusedResourcesPreferencePage$2
  implements Listener
{
  FocusedResourcesPreferencePage$2(FocusedResourcesPreferencePage paramFocusedResourcesPreferencePage) {}
  
  public void handleEvent(Event e)
  {
    FocusedResourcesPreferencePage.access$0(this$0);
  }
}

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

import org.eclipse.swt.widgets.Event;
import org.eclipse.swt.widgets.Listener;

class FocusedResourcesPreferencePage$3
  implements Listener
{
  FocusedResourcesPreferencePage$3(FocusedResourcesPreferencePage paramFocusedResourcesPreferencePage) {}
  
  public void handleEvent(Event e)
  {
    FocusedResourcesPreferencePage.access$1(this$0);
  }
}

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

import org.eclipse.swt.widgets.Event;
import org.eclipse.swt.widgets.Listener;

class FocusedResourcesPreferencePage$4
  implements Listener
{
  FocusedResourcesPreferencePage$4(FocusedResourcesPreferencePage paramFocusedResourcesPreferencePage) {}
  
  public void handleEvent(Event e)
  {
    FocusedResourcesPreferencePage.access$2(this$0);
  }
}

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

import org.eclipse.osgi.util.NLS;

public class Messages
  extends NLS
{
  private static final String BUNDLE_NAME = "org.eclipse.mylyn.internal.resources.ui.preferences.messages";
  public static String FocusedResourcesPreferencePage_Add_;
  public static String FocusedResourcesPreferencePage_Add__IGNORED_RESOURCE;
  public static String FocusedResourcesPreferencePage__automatic_;
  public static String FocusedResourcesPreferencePage__Enable_file_change_monitoring_Label;
  public static String FocusedResourcesPreferencePage_Configure_file_change_monitoring_Description;
  public static String FocusedResourcesPreferencePage_Enter_pattern_____any_string_;
  public static String FocusedResourcesPreferencePage_Matching_file_or_directory_names_will_not_be_added_automatically_to_the_context;
  public static String FocusedResourcesPreferencePage_Remove;
  public static String FocusedResourcesPreferencePage_Resource_Monitoring_Exclusions;
  
  static {}
  
  public static void reloadMessages()
  {
    NLS.initializeMessages("org.eclipse.mylyn.internal.resources.ui.preferences.messages", Messages.class);
  }
}

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

import java.util.ArrayList;
import java.util.HashSet;
import java.util.List;
import java.util.Set;
import org.eclipse.core.resources.IFile;
import org.eclipse.core.resources.IFolder;
import org.eclipse.core.resources.IProject;
import org.eclipse.core.resources.IResource;
import org.eclipse.core.resources.IResourceChangeEvent;
import org.eclipse.core.resources.IResourceChangeListener;
import org.eclipse.core.resources.IResourceDelta;
import org.eclipse.core.resources.IResourceDeltaVisitor;
import org.eclipse.core.runtime.CoreException;
import org.eclipse.core.runtime.Status;
import org.eclipse.mylyn.commons.core.StatusHandler;
import org.eclipse.mylyn.context.core.ContextCore;
import org.eclipse.mylyn.context.core.IInteractionContextManager;
import org.eclipse.mylyn.monitor.core.InteractionEvent.Kind;
import org.eclipse.mylyn.resources.ui.ResourcesUi;

public class ResourceChangeMonitor
  implements IResourceChangeListener
{
  private static final int MAX_FILE_DELTA_SIZE = 10;
  private static final int MAX_NEW_FOLDER_DELTA_SIZE = 3;
  private boolean enabled;
  
  private class ResourceDeltaVisitor
    implements IResourceDeltaVisitor
  {
    private final Set<IResource> addedResources;
    private final Set<IResource> changedResources;
    private boolean haveTeamPrivateMember;
    private final List<IResourceExclusionStrategy> resourceExclusions;
    private int numNonExcludedFiles = 0;
    private int numAddedFolders = 0;
    
    public ResourceDeltaVisitor()
    {
      this.resourceExclusions = resourceExclusions;
      addedResources = new HashSet();
      changedResources = new HashSet();
      for (IResourceExclusionStrategy exclusion : exclusions) {
        exclusion.update();
      }
    }
    
    public boolean hasValidResult()
    {
      return !haveTeamPrivateMember;
    }
    
    public boolean visit(IResourceDelta delta)
    {
      IResource deltaResource = delta.getResource();
      if (((deltaResource instanceof IProject)) && (
        (delta.getKind() == 2) || ((delta.getFlags() & 0x4000) != 0))) {
        return false;
      }
      if (hasTeamPrivate(deltaResource)) {
        return false;
      }
      if (isExcluded(deltaResource)) {
        return false;
      }
      IResourceDelta[] added = delta.getAffectedChildren(1);
      IResourceDelta[] arrayOfIResourceDelta1;
      int j = (arrayOfIResourceDelta1 = added).length;
      IResource resource;
      for (int i = 0; i < j; i++)
      {
        IResourceDelta element = arrayOfIResourceDelta1[i];
        resource = element.getResource();
        if ((((resource instanceof IFile)) || ((resource instanceof IFolder))) && (!isExcluded(resource)))
        {
          if (hasTeamPrivate(resource)) {
            return false;
          }
          if ((resource instanceof IFile)) {
            numNonExcludedFiles += 1;
          } else if ((resource instanceof IFolder)) {
            numAddedFolders += 1;
          }
          addedResources.add(resource);
        }
      }
      IResourceDelta[] changed = delta.getAffectedChildren(6);
      int k = (resource = changed).length;
      for (j = 0; j < k; j++)
      {
        IResourceDelta element = resource[j];
        IResource resource = element.getResource();
        if (((resource instanceof IFile)) && (!isExcluded(resource)) && (!"feature.xml".equals(resource.getName())) && (
          (element.getKind() != 4) || 
          ((element.getFlags() & 0x100) != 0)))
        {
          if (hasTeamPrivate(resource)) {
            return false;
          }
          if ((resource instanceof IFile)) {
            numNonExcludedFiles += 1;
          }
          changedResources.add(resource);
        }
      }
      return true;
    }
    
    private boolean hasTeamPrivate(IResource resource)
    {
      if (haveTeamPrivateMember) {
        return true;
      }
      if (resource.isTeamPrivateMember())
      {
        haveTeamPrivateMember = true;
        return true;
      }
      return false;
    }
    
    private boolean isExcluded(IResource resource)
    {
      for (IResourceExclusionStrategy exclusion : resourceExclusions) {
        if (exclusion.isExcluded(resource)) {
          return true;
        }
      }
      return false;
    }
    
    public Set<IResource> getChangedResources()
    {
      return changedResources;
    }
    
    public Set<IResource> getAddedResources()
    {
      return addedResources;
    }
    
    public int getNumChangedAndAddedFiles()
    {
      return numNonExcludedFiles;
    }
    
    public int getNumAddedFolders()
    {
      return numAddedFolders;
    }
  }
  
  private final List<IResourceExclusionStrategy> exclusions = new ArrayList();
  
  public ResourceChangeMonitor()
  {
    enabled = true;
    
    exclusions.add(new ResourcePatternExclusionStrategy());
    
    exclusions.add(new ResourceModifiedDateExclusionStrategy());
    for (IResourceExclusionStrategy exclusion : exclusions) {
      exclusion.init();
    }
  }
  
  public void dispose()
  {
    for (IResourceExclusionStrategy exclusion : exclusions) {
      exclusion.dispose();
    }
    exclusions.clear();
  }
  
  public void resourceChanged(IResourceChangeEvent event)
  {
    if ((!enabled) || (!ContextCore.getContextManager().isContextActive())) {
      return;
    }
    if (event.getType() != 1) {
      return;
    }
    IResourceDelta rootDelta = event.getDelta();
    if (rootDelta != null)
    {
      ResourceDeltaVisitor visitor = new ResourceDeltaVisitor(exclusions);
      try
      {
        rootDelta.accept(visitor, 10);
        if (visitor.hasValidResult()) {
          if ((visitor.getNumChangedAndAddedFiles() <= 10) && 
            (visitor.getNumAddedFolders() <= 3))
          {
            ResourcesUi.addResourceToContext(visitor.getChangedResources(), 
              InteractionEvent.Kind.PREDICTION);
            ResourcesUi.addResourceToContext(visitor.getAddedResources(), InteractionEvent.Kind.PROPAGATION);
          }
        }
      }
      catch (CoreException e)
      {
        StatusHandler.log(new Status(4, "org.eclipse.mylyn.resources.ui", 
          "Could not accept marker visitor", e));
      }
    }
  }
  
  public boolean isEnabled()
  {
    return enabled;
  }
  
  public void setEnabled(boolean enabled)
  {
    this.enabled = enabled;
  }
}

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

import java.net.URI;
import java.util.Collection;
import java.util.HashSet;
import java.util.Set;
import org.apache.tools.ant.types.selectors.SelectorUtils;
import org.eclipse.core.resources.IResource;
import org.eclipse.core.runtime.IPath;

public class ResourcePatternExclusionStrategy
  implements IResourceExclusionStrategy
{
  private static final String TRAILING_PATH_WILDCARD = "/**";
  private static final String LEADING_PATH_WILDCARD = "**/";
  private Set<String> excludedPatterns = new HashSet();
  
  public void init() {}
  
  public void dispose() {}
  
  public void update()
  {
    Set<String> excludedPatterns = new HashSet();
    Set<String> excludedResourcePatterns = ResourcesUiPreferenceInitializer.getExcludedResourcePatterns();
    excludedResourcePatterns.addAll(ResourcesUiPreferenceInitializer.getForcedExcludedResourcePatterns());
    for (String pattern : excludedResourcePatterns) {
      if ((pattern != null) && (pattern.length() > 0)) {
        excludedPatterns.add(pattern);
      }
    }
    this.excludedPatterns = excludedPatterns;
  }
  
  public boolean isExcluded(IResource resource)
  {
    return isExcluded(resource.getProjectRelativePath(), resource, excludedPatterns);
  }
  
  public static boolean isExcluded(IPath path, IResource resource, Set<String> excludedPatterns)
  {
    if ((resource != null) && (resource.isDerived())) {
      return true;
    }
    String pathString = path.toPortableString();
    for (String pattern : excludedPatterns)
    {
      if ((resource != null) && 
        (pattern.startsWith("file:/")) && (isUriExcluded(resource.getLocationURI().toString(), pattern))) {
        return true;
      }
      if ((SelectorUtils.matchPath(pattern, pathString, false)) || 
        (SelectorUtils.match(pattern, pathString, false))) {
        return true;
      }
    }
    return false;
  }
  
  public static boolean isUriExcluded(String uri, String pattern)
  {
    if ((uri != null) && (uri.startsWith(pattern))) {
      return true;
    }
    return false;
  }
  
  public static Collection<String> convertToAntPattern(String basicPattern)
  {
    Set<String> patterns = new HashSet();
    patterns.add(basicPattern);
    if ((!basicPattern.contains("**/")) && (!basicPattern.contains("/**")))
    {
      patterns.add("**/" + basicPattern + "/**");
      patterns.add("**/" + basicPattern);
      patterns.add(basicPattern + "/**");
    }
    return patterns;
  }
}

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

import java.io.IOException;
import java.io.StringReader;
import java.io.StringWriter;
import java.util.HashSet;
import java.util.Set;
import java.util.StringTokenizer;
import org.eclipse.core.runtime.Status;
import org.eclipse.core.runtime.preferences.AbstractPreferenceInitializer;
import org.eclipse.jface.preference.IPreferenceStore;
import org.eclipse.mylyn.commons.core.StatusHandler;
import org.eclipse.ui.IMemento;
import org.eclipse.ui.WorkbenchException;
import org.eclipse.ui.XMLMemento;

public class ResourcesUiPreferenceInitializer
  extends AbstractPreferenceInitializer
{
  public static final String PREF_DEFAULT_SCOPE = "org.eclipse.mylyn.ide.resources";
  @Deprecated
  private static final String PREF_STORE_DELIM = ", ";
  @Deprecated
  private static final String PREF_RESOURCES_IGNORED = "org.eclipse.mylyn.ide.resources.ignored.pattern";
  public static final String PREF_RESOURCE_MONITOR_ENABLED = "org.eclipse.mylyn.ide.resources.resource.monitor.enabled";
  private static final String PREF_RESOURCES_IGNORED_ANT = "org.eclipse.mylyn.ide.resources.ignored.pattern.ant";
  public static final String PREF_MODIFIED_DATE_EXCLUSIONS = "org.eclipse.mylyn.ide.resources.date.modified.exclusion";
  public static final String PREF_RESOURCE_PATTERNS_VERSION = "org.eclipse.mylyn.ide.resources.ignore.pattern.version";
  private static final String RESOURCE_PATTERN_VERSION = "1.0";
  private static final Set<String> ADDED_PATTERNS_1_0;
  private static final String KEY_RESOURCE_EXCLUSIONS = "resourceExclusions";
  private static final String KEY_EXCLUSION = "exclusion";
  private static final String KEY_ANT_PATTERN = "antPattern";
  public static Set<String> forcedExclusionPatterns = new HashSet();
  public static Set<String> cachedExclusionPatterns = null;
  
  static
  {
    ADDED_PATTERNS_1_0 = new HashSet(1);
    ADDED_PATTERNS_1_0.add("target/**");
  }
  
  public void initializeDefaultPreferences()
  {
    Set<String> defaultPatterns = new HashSet();
    
    defaultPatterns.addAll(ResourcePatternExclusionStrategy.convertToAntPattern(".*"));
    defaultPatterns.addAll(ADDED_PATTERNS_1_0);
    
    defaultPatterns.addAll(ResourcesUiExtensionPointReader.getDefaultResourceExclusions());
    
    ResourcesUiBridgePlugin.getDefault().getPreferenceStore().setDefault("org.eclipse.mylyn.ide.resources.resource.monitor.enabled", true);
    ResourcesUiBridgePlugin.getDefault()
      .getPreferenceStore()
      .setDefault("org.eclipse.mylyn.ide.resources.ignored.pattern.ant", createResourceExclusionMemento(defaultPatterns));
    ResourcesUiBridgePlugin.getDefault().getPreferenceStore().setDefault("org.eclipse.mylyn.ide.resources.date.modified.exclusion", true);
  }
  
  public static synchronized void setExcludedResourcePatterns(Set<String> patterns)
  {
    cachedExclusionPatterns = new HashSet(patterns);
    
    String memento = createResourceExclusionMemento(patterns);
    if (memento != null) {
      ResourcesUiBridgePlugin.getDefault().getPreferenceStore().setValue("org.eclipse.mylyn.ide.resources.ignored.pattern.ant", memento);
    }
  }
  
  private static String createResourceExclusionMemento(Set<String> patterns)
  {
    XMLMemento rootMemento = XMLMemento.createWriteRoot("resourceExclusions");
    for (String string : patterns)
    {
      IMemento memento = rootMemento.createChild("exclusion");
      memento.putString("antPattern", string);
    }
    StringWriter writer = new StringWriter();
    String memento = null;
    try
    {
      rootMemento.save(writer);
      memento = writer.getBuffer().toString();
    }
    catch (IOException e)
    {
      StatusHandler.log(new Status(4, "org.eclipse.mylyn.resources.ui", 
        "Could not store resource exclusions", e));
    }
    return memento;
  }
  
  private static Set<String> getResourceExclusionsFromMemento(String mementoString)
  {
    Set<String> exclusions = new HashSet();
    try
    {
      XMLMemento rootMemento = XMLMemento.createReadRoot(new StringReader(mementoString));
      IMemento[] arrayOfIMemento;
      int j = (arrayOfIMemento = rootMemento.getChildren("exclusion")).length;
      for (int i = 0; i < j; i++)
      {
        IMemento memento = arrayOfIMemento[i];
        String pattern = memento.getString("antPattern");
        if (pattern != null) {
          exclusions.add(pattern);
        }
      }
    }
    catch (WorkbenchException e)
    {
      StatusHandler.log(new Status(4, "org.eclipse.mylyn.resources.ui", 
        "Could not load resource exclusions", e));
    }
    return exclusions;
  }
  
  public static synchronized Set<String> getExcludedResourcePatterns()
  {
    if (cachedExclusionPatterns != null) {
      return new HashSet(cachedExclusionPatterns);
    }
    Set<String> exclusions = new HashSet();
    if ((ResourcesUiBridgePlugin.getDefault().getPreferenceStore().contains("org.eclipse.mylyn.ide.resources.ignored.pattern.ant")) && 
      (!ResourcesUiBridgePlugin.getDefault().getPreferenceStore().isDefault("org.eclipse.mylyn.ide.resources.ignored.pattern.ant")))
    {
      exclusions = getResourceExclusionsFromMemento(ResourcesUiBridgePlugin.getDefault()
        .getPreferenceStore()
        .getString("org.eclipse.mylyn.ide.resources.ignored.pattern.ant"));
    }
    else if (ResourcesUiBridgePlugin.getDefault().getPreferenceStore().contains("org.eclipse.mylyn.ide.resources.ignored.pattern"))
    {
      String read = ResourcesUiBridgePlugin.getDefault().getPreferenceStore().getString("org.eclipse.mylyn.ide.resources.ignored.pattern");
      if (read != null)
      {
        StringTokenizer st = new StringTokenizer(read, ", ");
        while (st.hasMoreTokens()) {
          exclusions.addAll(ResourcePatternExclusionStrategy.convertToAntPattern(st.nextToken()));
        }
      }
      setExcludedResourcePatterns(exclusions);
    }
    else
    {
      exclusions = getResourceExclusionsFromMemento(ResourcesUiBridgePlugin.getDefault()
        .getPreferenceStore()
        .getString("org.eclipse.mylyn.ide.resources.ignored.pattern.ant"));
    }
    cachedExclusionPatterns = new HashSet(exclusions);
    if (!"1.0".equals(ResourcesUiBridgePlugin.getDefault()
      .getPreferenceStore()
      .getString("org.eclipse.mylyn.ide.resources.ignore.pattern.version")))
    {
      cachedExclusionPatterns.addAll(ADDED_PATTERNS_1_0);
      ResourcesUiBridgePlugin.getDefault()
        .getPreferenceStore()
        .setValue("org.eclipse.mylyn.ide.resources.ignore.pattern.version", "1.0");
      
      setExcludedResourcePatterns(cachedExclusionPatterns);
    }
    return cachedExclusionPatterns;
  }
  
  public static Set<String> getForcedExcludedResourcePatterns()
  {
    return forcedExclusionPatterns;
  }
  
  public static void addForcedExclusionPattern(String pattern)
  {
    forcedExclusionPatterns.add(pattern);
  }
  
  public static void removeForcedExclusionPattern(String pattern)
  {
    forcedExclusionPatterns.remove(pattern);
  }
}

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

import java.util.Date;
import org.eclipse.core.commands.operations.IOperationHistory;
import org.eclipse.core.commands.operations.IOperationHistoryListener;
import org.eclipse.core.commands.operations.OperationHistoryEvent;
import org.eclipse.core.commands.operations.OperationHistoryFactory;
import org.eclipse.core.resources.IFile;
import org.eclipse.core.resources.IResource;
import org.eclipse.jface.preference.IPreferenceStore;
import org.eclipse.jface.util.IPropertyChangeListener;
import org.eclipse.jface.util.PropertyChangeEvent;
import org.eclipse.mylyn.context.core.AbstractContextListener;
import org.eclipse.mylyn.context.core.ContextChangeEvent;
import org.eclipse.mylyn.context.core.ContextCore;
import org.eclipse.mylyn.context.core.IInteractionContextManager;

public class ResourceModifiedDateExclusionStrategy
  extends AbstractContextListener
  implements IResourceExclusionStrategy, IPropertyChangeListener, IOperationHistoryListener
{
  private transient Date lastActivatedDate = null;
  private boolean isEnabled = false;
  private boolean performingChange;
  
  public void dispose()
  {
    ContextCore.getContextManager().removeListener(this);
    ResourcesUiBridgePlugin.getDefault().getPreferenceStore().removePropertyChangeListener(this);
    OperationHistoryFactory.getOperationHistory().removeOperationHistoryListener(this);
  }
  
  public void init()
  {
    ResourcesUiBridgePlugin.getDefault().getPreferenceStore().addPropertyChangeListener(this);
    isEnabled = ResourcesUiBridgePlugin.getDefault()
      .getPreferenceStore()
      .getBoolean("org.eclipse.mylyn.ide.resources.date.modified.exclusion");
    ContextCore.getContextManager().addListener(this);
    if (ContextCore.getContextManager().isContextActive()) {
      lastActivatedDate = new Date();
    }
    OperationHistoryFactory.getOperationHistory().addOperationHistoryListener(this);
  }
  
  public void update() {}
  
  public boolean isEnabled()
  {
    return isEnabled;
  }
  
  public void setEnabled(boolean isEnabled)
  {
    this.isEnabled = isEnabled;
  }
  
  public boolean isExcluded(IResource resource)
  {
    if ((isEnabled()) && (!performingChange)) {
      return ((resource instanceof IFile)) && (!wasModifiedAfter(resource, lastActivatedDate));
    }
    return false;
  }
  
  public boolean wasModifiedAfter(IResource resource, Date date)
  {
    if (date == null) {
      return false;
    }
    long modificationStamp = resource.getLocalTimeStamp();
    if ((modificationStamp > 0L) && (modificationStamp != -1L))
    {
      Date resourceDate = new Date(modificationStamp);
      return (resourceDate.equals(date)) || (resourceDate.after(date));
    }
    return false;
  }
  
  public Date getLastActivatedDate()
  {
    return lastActivatedDate;
  }
  
  public void contextChanged(ContextChangeEvent event)
  {
    switch (event.getEventKind())
    {
    case CLEARED: 
      long currentTime = new Date().getTime();
      currentTime = (currentTime - currentTime % 1000.0D);
      lastActivatedDate = new Date(currentTime);
      break;
    case DEACTIVATED: 
      lastActivatedDate = null;
    }
  }
  
  public void propertyChange(PropertyChangeEvent event)
  {
    if ("org.eclipse.mylyn.ide.resources.date.modified.exclusion".equals(event.getProperty()))
    {
      Object newValue = event.getNewValue();
      if ((newValue instanceof Boolean)) {
        setEnabled(((Boolean)newValue).booleanValue());
      } else if ((newValue instanceof String)) {
        setEnabled(Boolean.parseBoolean((String)newValue));
      }
    }
  }
  
  public void historyNotification(OperationHistoryEvent event)
  {
    if (event.getEventType() == 1) {
      performingChange = true;
    } else if ((event.getEventType() == 4) || 
      (event.getEventType() == 7)) {
      performingChange = false;
    }
  }
}

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

import java.util.HashSet;
import java.util.List;
import java.util.Set;
import org.eclipse.core.resources.IFile;
import org.eclipse.core.resources.IFolder;
import org.eclipse.core.resources.IProject;
import org.eclipse.core.resources.IResource;
import org.eclipse.core.resources.IResourceDelta;
import org.eclipse.core.resources.IResourceDeltaVisitor;

class ResourceChangeMonitor$ResourceDeltaVisitor
  implements IResourceDeltaVisitor
{
  private final Set<IResource> addedResources;
  private final Set<IResource> changedResources;
  private boolean haveTeamPrivateMember;
  private final List<IResourceExclusionStrategy> resourceExclusions;
  private int numNonExcludedFiles = 0;
  private int numAddedFolders = 0;
  
  public ResourceChangeMonitor$ResourceDeltaVisitor(List<IResourceExclusionStrategy> arg1)
  {
    this.resourceExclusions = resourceExclusions;
    addedResources = new HashSet();
    changedResources = new HashSet();
    for (IResourceExclusionStrategy exclusion : ResourceChangeMonitor.access$0(???)) {
      exclusion.update();
    }
  }
  
  public boolean hasValidResult()
  {
    return !haveTeamPrivateMember;
  }
  
  public boolean visit(IResourceDelta delta)
  {
    IResource deltaResource = delta.getResource();
    if (((deltaResource instanceof IProject)) && (
      (delta.getKind() == 2) || ((delta.getFlags() & 0x4000) != 0))) {
      return false;
    }
    if (hasTeamPrivate(deltaResource)) {
      return false;
    }
    if (isExcluded(deltaResource)) {
      return false;
    }
    IResourceDelta[] added = delta.getAffectedChildren(1);
    IResourceDelta[] arrayOfIResourceDelta1;
    int j = (arrayOfIResourceDelta1 = added).length;
    IResource resource;
    for (int i = 0; i < j; i++)
    {
      IResourceDelta element = arrayOfIResourceDelta1[i];
      resource = element.getResource();
      if ((((resource instanceof IFile)) || ((resource instanceof IFolder))) && (!isExcluded(resource)))
      {
        if (hasTeamPrivate(resource)) {
          return false;
        }
        if ((resource instanceof IFile)) {
          numNonExcludedFiles += 1;
        } else if ((resource instanceof IFolder)) {
          numAddedFolders += 1;
        }
        addedResources.add(resource);
      }
    }
    IResourceDelta[] changed = delta.getAffectedChildren(6);
    int k = (resource = changed).length;
    for (j = 0; j < k; j++)
    {
      IResourceDelta element = resource[j];
      IResource resource = element.getResource();
      if (((resource instanceof IFile)) && (!isExcluded(resource)) && (!"feature.xml".equals(resource.getName())) && (
        (element.getKind() != 4) || 
        ((element.getFlags() & 0x100) != 0)))
      {
        if (hasTeamPrivate(resource)) {
          return false;
        }
        if ((resource instanceof IFile)) {
          numNonExcludedFiles += 1;
        }
        changedResources.add(resource);
      }
    }
    return true;
  }
  
  private boolean hasTeamPrivate(IResource resource)
  {
    if (haveTeamPrivateMember) {
      return true;
    }
    if (resource.isTeamPrivateMember())
    {
      haveTeamPrivateMember = true;
      return true;
    }
    return false;
  }
  
  private boolean isExcluded(IResource resource)
  {
    for (IResourceExclusionStrategy exclusion : resourceExclusions) {
      if (exclusion.isExcluded(resource)) {
        return true;
      }
    }
    return false;
  }
  
  public Set<IResource> getChangedResources()
  {
    return changedResources;
  }
  
  public Set<IResource> getAddedResources()
  {
    return addedResources;
  }
  
  public int getNumChangedAndAddedFiles()
  {
    return numNonExcludedFiles;
  }
  
  public int getNumAddedFolders()
  {
    return numAddedFolders;
  }
}

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

import java.util.HashSet;
import java.util.Set;
import org.eclipse.core.runtime.IConfigurationElement;
import org.eclipse.core.runtime.IExtension;
import org.eclipse.core.runtime.IExtensionPoint;
import org.eclipse.core.runtime.IExtensionRegistry;
import org.eclipse.core.runtime.Platform;

public class ResourcesUiExtensionPointReader
{
  public static final String EXTENSION_CHANGE_MONITORING = "changeMonitoring";
  public static final String ELEMENT_EXCLUDE = "exclude";
  public static final String ATTR_PATTERN = "pattern";
  public static final String ATTR_ANT_PATTERN = "antPattern";
  private static Set<String> resourceExclusionPatterns = new HashSet();
  private static boolean extensionsRead = false;
  
  public static Set<String> getDefaultResourceExclusions()
  {
    if (!extensionsRead) {
      readExtensions();
    }
    return resourceExclusionPatterns;
  }
  
  private static void readExtensions()
  {
    IExtensionPoint teamProvider = Platform.getExtensionRegistry().getExtensionPoint(
      "org.eclipse.mylyn.resources.ui.changeMonit
1 2 3

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