aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorKaloyan Raev2014-01-08 10:26:18 (EST)
committerGerrit Code Review @ Eclipse.org2014-01-08 10:59:16 (EST)
commit64520adb3edacb67c9adff897a372babce2d0e7b (patch)
tree8a140b2e848a6d9a15b299ddcfb66372f08c554a
parent812394e80a0269a28b5053e6896eb09521ec9ff1 (diff)
downloadorg.eclipse.pdt-64520adb3edacb67c9adff897a372babce2d0e7b.zip
org.eclipse.pdt-64520adb3edacb67c9adff897a372babce2d0e7b.tar.gz
org.eclipse.pdt-64520adb3edacb67c9adff897a372babce2d0e7b.tar.bz2
Bug 425097 - IDE freezes when editing the active working setrefs/changes/88/20388/2
Resolves the performance issue by providing a working set filter that compares model elements based on their resource path, instead of recursively adding all children of the selected folder to the working set. Bug: 425097 Change-Id: Ie97902434fe480215e277a6df84cd6ca10253553 Signed-off-by: Kaloyan Raev <kaloyan.r@zend.com>
-rw-r--r--plugins/org.eclipse.php.ui/src/org/eclipse/php/internal/ui/actions/ViewActionGroup.java8
-rw-r--r--plugins/org.eclipse.php.ui/src/org/eclipse/php/internal/ui/workingset/PHPWorkingSetFilter.java86
-rw-r--r--plugins/org.eclipse.php.ui/src/org/eclipse/php/internal/ui/workingset/PHPWorkingSetFilterActionGroup.java61
-rw-r--r--plugins/org.eclipse.php.ui/src/org/eclipse/php/internal/ui/workingset/PhpWorkingSetPage.java9
4 files changed, 151 insertions, 13 deletions
diff --git a/plugins/org.eclipse.php.ui/src/org/eclipse/php/internal/ui/actions/ViewActionGroup.java b/plugins/org.eclipse.php.ui/src/org/eclipse/php/internal/ui/actions/ViewActionGroup.java
index 87e46d0..2c1b4d6 100644
--- a/plugins/org.eclipse.php.ui/src/org/eclipse/php/internal/ui/actions/ViewActionGroup.java
+++ b/plugins/org.eclipse.php.ui/src/org/eclipse/php/internal/ui/actions/ViewActionGroup.java
@@ -10,7 +10,6 @@
package org.eclipse.php.internal.ui.actions;
import org.eclipse.dltk.internal.ui.workingsets.IWorkingSetActionGroup;
-import org.eclipse.dltk.internal.ui.workingsets.WorkingSetFilterActionGroup;
import org.eclipse.dltk.internal.ui.workingsets.WorkingSetMessages;
import org.eclipse.dltk.internal.ui.workingsets.WorkingSetModel;
import org.eclipse.jface.action.IMenuManager;
@@ -20,6 +19,7 @@ import org.eclipse.jface.util.IPropertyChangeListener;
import org.eclipse.jface.util.PropertyChangeEvent;
import org.eclipse.jface.viewers.StructuredViewer;
import org.eclipse.jface.viewers.ViewerFilter;
+import org.eclipse.php.internal.ui.workingset.PHPWorkingSetFilterActionGroup;
import org.eclipse.ui.IActionBars;
import org.eclipse.ui.IMemento;
import org.eclipse.ui.IWorkbenchPartSite;
@@ -41,7 +41,7 @@ public class ViewActionGroup extends
private IMenuManager fMenuManager;
private IWorkingSetActionGroup fActiveActionGroup;
private WorkingSetShowActionGroup fShowActionGroup;
- private WorkingSetFilterActionGroup fFilterActionGroup;
+ private PHPWorkingSetFilterActionGroup fFilterActionGroup;
public ViewActionGroup(int mode, IPropertyChangeListener changeListener,
IWorkbenchPartSite site) {
@@ -53,7 +53,7 @@ public class ViewActionGroup extends
}
};
}
- fFilterActionGroup = new WorkingSetFilterActionGroup(site,
+ fFilterActionGroup = new PHPWorkingSetFilterActionGroup(site,
fChangeListener);
fShowActionGroup = new WorkingSetShowActionGroup(site);
fMode = mode;
@@ -139,7 +139,7 @@ public class ViewActionGroup extends
fChangeListener.propertyChange(event);
}
- public WorkingSetFilterActionGroup getFilterGroup() {
+ public PHPWorkingSetFilterActionGroup getFilterGroup() {
return fFilterActionGroup;
}
diff --git a/plugins/org.eclipse.php.ui/src/org/eclipse/php/internal/ui/workingset/PHPWorkingSetFilter.java b/plugins/org.eclipse.php.ui/src/org/eclipse/php/internal/ui/workingset/PHPWorkingSetFilter.java
new file mode 100644
index 0000000..53a2876
--- /dev/null
+++ b/plugins/org.eclipse.php.ui/src/org/eclipse/php/internal/ui/workingset/PHPWorkingSetFilter.java
@@ -0,0 +1,86 @@
+/*******************************************************************************
+ * Copyright (c) 2014 Zend Technologies and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Zend Technologies - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.php.internal.ui.workingset;
+
+import org.eclipse.core.resources.IResource;
+import org.eclipse.core.resources.IStorage;
+import org.eclipse.core.runtime.Assert;
+import org.eclipse.core.runtime.IAdaptable;
+import org.eclipse.core.runtime.IPath;
+import org.eclipse.dltk.core.IModelElement;
+import org.eclipse.dltk.internal.ui.workingsets.WorkingSetFilter;
+
+/**
+ * Overrides the DLTK working set filter to filter model elements only based on
+ * their resource path enclosure.
+ *
+ * @author Kaloyan Raev
+ */
+public class PHPWorkingSetFilter extends WorkingSetFilter {
+
+ private IAdaptable[] fCachedWorkingSet = null;
+
+ @Override
+ public boolean isEnclosing(IModelElement element) {
+ Assert.isNotNull(element);
+
+ IAdaptable[] cachedWorkingSet = fCachedWorkingSet;
+ if (cachedWorkingSet == null)
+ cachedWorkingSet = getWorkingSet().getElements();
+
+ IResource resource = (IResource) element.getAdapter(IResource.class);
+ if (resource == null)
+ return false;
+
+ IPath path = resource.getFullPath();
+ for (int i = 0; i < cachedWorkingSet.length; i++) {
+ // compare resource paths
+ if (isEnclosing(cachedWorkingSet[i], path))
+ return true;
+ }
+
+ return false;
+ }
+
+ private boolean isEnclosing(IAdaptable element, IPath path) {
+ if (path == null)
+ return false;
+
+ IPath elementPath = null;
+
+ IResource elementResource = (IResource) element
+ .getAdapter(IResource.class);
+ if (elementResource != null)
+ elementPath = elementResource.getFullPath();
+
+ if (elementPath == null) {
+ IModelElement scriptElement = (IModelElement) element
+ .getAdapter(IModelElement.class);
+ if (scriptElement != null)
+ elementPath = scriptElement.getPath();
+ }
+
+ if (elementPath == null && element instanceof IStorage)
+ elementPath = ((IStorage) element).getFullPath();
+
+ if (elementPath == null)
+ return false;
+
+ if (elementPath.isPrefixOf(path))
+ return true;
+
+ if (path.isPrefixOf(elementPath))
+ return true;
+
+ return false;
+ }
+
+}
diff --git a/plugins/org.eclipse.php.ui/src/org/eclipse/php/internal/ui/workingset/PHPWorkingSetFilterActionGroup.java b/plugins/org.eclipse.php.ui/src/org/eclipse/php/internal/ui/workingset/PHPWorkingSetFilterActionGroup.java
new file mode 100644
index 0000000..44961f7
--- /dev/null
+++ b/plugins/org.eclipse.php.ui/src/org/eclipse/php/internal/ui/workingset/PHPWorkingSetFilterActionGroup.java
@@ -0,0 +1,61 @@
+/*******************************************************************************
+ * Copyright (c) 2014 Zend Technologies and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Zend Technologies - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.php.internal.ui.workingset;
+
+import org.eclipse.dltk.internal.ui.workingsets.WorkingSetFilterActionGroup;
+import org.eclipse.jface.util.IPropertyChangeListener;
+import org.eclipse.jface.viewers.ViewerFilter;
+import org.eclipse.swt.widgets.Shell;
+import org.eclipse.ui.IWorkbenchPage;
+import org.eclipse.ui.IWorkbenchPartSite;
+import org.eclipse.ui.IWorkingSet;
+
+/**
+ * Overrides the DLTK working set filter action group for using the
+ * {@link PHPWorkingSetFilter} filter instead of the DLTK working set filter.
+ *
+ * @author Kaloyan Raev
+ */
+public class PHPWorkingSetFilterActionGroup extends WorkingSetFilterActionGroup {
+
+ private final PHPWorkingSetFilter fWorkingSetFilter;
+
+ public PHPWorkingSetFilterActionGroup(IWorkbenchPartSite site,
+ IPropertyChangeListener changeListener) {
+ super(site, changeListener);
+ fWorkingSetFilter = new PHPWorkingSetFilter();
+ }
+
+ public PHPWorkingSetFilterActionGroup(Shell shell, IWorkbenchPage page,
+ IPropertyChangeListener changeListener) {
+ super(shell, page, changeListener);
+ fWorkingSetFilter = new PHPWorkingSetFilter();
+ }
+
+ @Override
+ public boolean isFiltered(Object parent, Object object) {
+ if (fWorkingSetFilter == null)
+ return false;
+ return !fWorkingSetFilter.select(null, parent, object);
+ }
+
+ @Override
+ public void setWorkingSet(IWorkingSet workingSet, boolean refreshViewer) {
+ fWorkingSetFilter.setWorkingSet(workingSet);
+ super.setWorkingSet(workingSet, refreshViewer);
+ }
+
+ @Override
+ public ViewerFilter getWorkingSetFilter() {
+ return fWorkingSetFilter;
+ }
+
+}
diff --git a/plugins/org.eclipse.php.ui/src/org/eclipse/php/internal/ui/workingset/PhpWorkingSetPage.java b/plugins/org.eclipse.php.ui/src/org/eclipse/php/internal/ui/workingset/PhpWorkingSetPage.java
index 2260b5c..88226bb 100644
--- a/plugins/org.eclipse.php.ui/src/org/eclipse/php/internal/ui/workingset/PhpWorkingSetPage.java
+++ b/plugins/org.eclipse.php.ui/src/org/eclipse/php/internal/ui/workingset/PhpWorkingSetPage.java
@@ -327,19 +327,10 @@ public class PhpWorkingSetPage extends WizardPage implements IWorkingSetPage {
findCheckedElements(checkedResources, children[i]);
else if (fTree.getChecked(children[i])) {
checkedResources.add(children[i]);
- addChildren(checkedResources, children[i]);
}
}
}
- private void addChildren(List checkedResources, Object parent) {
- Object[] children = fTreeContentProvider.getChildren(parent);
- for (int i = 0; i < children.length; i++) {
- checkedResources.add(children[i]);
- addChildren(checkedResources, children[i]);
- }
- }
-
void handleCheckStateChange(final CheckStateChangedEvent event) {
BusyIndicator.showWhile(getShell().getDisplay(), new Runnable() {
public void run() {