Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorWilliam Chen2012-05-31 09:07:10 +0000
committerWilliam Chen2012-05-31 09:08:01 +0000
commit440feb0d35714c33ded9434a42cc4053a7c54c5e (patch)
tree528a9f13e2503723a36b41b822e66c8391b0971b /target_explorer/plugins
parent1882159a8e0d26c07d23566a32d883976c29507a (diff)
downloadorg.eclipse.tcf-440feb0d35714c33ded9434a42cc4053a7c54c5e.tar.gz
org.eclipse.tcf-440feb0d35714c33ded9434a42cc4053a7c54c5e.tar.xz
org.eclipse.tcf-440feb0d35714c33ded9434a42cc4053a7c54c5e.zip
Target Explorer: After the tree viewer changes after filtering, the pop
up dialog should be changed accordingly.
Diffstat (limited to 'target_explorer/plugins')
-rw-r--r--target_explorer/plugins/org.eclipse.tcf.te.ui/src/org/eclipse/tcf/te/ui/internal/utils/QuickFilter.java52
-rw-r--r--target_explorer/plugins/org.eclipse.tcf.te.ui/src/org/eclipse/tcf/te/ui/internal/utils/QuickFilterPopup.java1
2 files changed, 39 insertions, 14 deletions
diff --git a/target_explorer/plugins/org.eclipse.tcf.te.ui/src/org/eclipse/tcf/te/ui/internal/utils/QuickFilter.java b/target_explorer/plugins/org.eclipse.tcf.te.ui/src/org/eclipse/tcf/te/ui/internal/utils/QuickFilter.java
index 237acd63f..88038be78 100644
--- a/target_explorer/plugins/org.eclipse.tcf.te.ui/src/org/eclipse/tcf/te/ui/internal/utils/QuickFilter.java
+++ b/target_explorer/plugins/org.eclipse.tcf.te.ui/src/org/eclipse/tcf/te/ui/internal/utils/QuickFilter.java
@@ -21,6 +21,7 @@ import org.eclipse.jface.viewers.Viewer;
import org.eclipse.jface.viewers.ViewerFilter;
import org.eclipse.swt.graphics.Point;
import org.eclipse.swt.graphics.Rectangle;
+import org.eclipse.swt.widgets.Shell;
import org.eclipse.swt.widgets.TreeItem;
import org.eclipse.tcf.te.core.interfaces.IPropertyChangeProvider;
/**
@@ -55,27 +56,50 @@ public class QuickFilter extends TablePatternFilter implements PropertyChangeLis
viewer.addFilter(this);
}
QuickFilterPopup popup = new QuickFilterPopup(viewer, this);
- Point location = null;
+ Point location = computePopupLocation();
+ popup.open();
+ popup.getShell().setLocation(location);
+ }
+
+ /**
+ * Compute the best location of the pop up dialog.
+ *
+ * @return The best location of the pop up dialog.
+ */
+ private Point computePopupLocation() {
+ Point location = null;
if (root != null) {
- TreeItem[] items = viewer.getTree().getSelection();
- if (items != null && items.length > 0) {
- for(TreeItem item : items) {
- viewer.getTree().showItem(item);
- }
- Rectangle bounds = items[0].getBounds();
- location = new Point(bounds.x, bounds.y);
- }
- else {
- location = new Point(0, 0);
- }
+ TreeItem[] items = viewer.getTree().getSelection();
+ if (items != null && items.length > 0) {
+ for(TreeItem item : items) {
+ viewer.getTree().showItem(item);
+ }
+ Rectangle bounds = items[0].getBounds();
+ location = new Point(bounds.x, bounds.y);
+ }
+ else {
+ location = new Point(0, 0);
+ }
}
else {
location = new Point(0, 0);
}
location.y -= viewer.getTree().getItemHeight();
location = viewer.getTree().toDisplay(location);
- popup.open();
- popup.getShell().setLocation(location);
+ return location;
+ }
+
+ /**
+ * Adjust the position of the pop up when the tree viewer has changed.
+ *
+ * @param popshell The shell of the pop up dialog.
+ */
+ void adjustPopup(Shell popshell) {
+ Point location = computePopupLocation();
+ Point shellLocation = popshell.getLocation();
+ if(shellLocation != null && !shellLocation.equals(location)) {
+ popshell.setLocation(location);
+ }
}
/*
diff --git a/target_explorer/plugins/org.eclipse.tcf.te.ui/src/org/eclipse/tcf/te/ui/internal/utils/QuickFilterPopup.java b/target_explorer/plugins/org.eclipse.tcf.te.ui/src/org/eclipse/tcf/te/ui/internal/utils/QuickFilterPopup.java
index ce29a2dbe..dc774c6e2 100644
--- a/target_explorer/plugins/org.eclipse.tcf.te.ui/src/org/eclipse/tcf/te/ui/internal/utils/QuickFilterPopup.java
+++ b/target_explorer/plugins/org.eclipse.tcf.te.ui/src/org/eclipse/tcf/te/ui/internal/utils/QuickFilterPopup.java
@@ -206,5 +206,6 @@ public class QuickFilterPopup extends PopupDialog {
protected void filterTextModifyText(ModifyEvent e) {
quickFilter.setPattern(filterText.getText());
treeViewer.refresh();
+ quickFilter.adjustPopup(getShell());
}
}

Back to the top