Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorWilliam Chen2012-06-01 03:00:08 -0400
committerWilliam Chen2012-06-01 03:00:08 -0400
commit1d487566a5a89e9e9dd9504fa9da95fc44928092 (patch)
treea3e51120dce83724acc46eba2c4f8d22eac8b3c0
parent1dca5b25ae1b456cc4994e50cb08c96272aef6c1 (diff)
downloadorg.eclipse.tcf-1d487566a5a89e9e9dd9504fa9da95fc44928092.tar.gz
org.eclipse.tcf-1d487566a5a89e9e9dd9504fa9da95fc44928092.tar.xz
org.eclipse.tcf-1d487566a5a89e9e9dd9504fa9da95fc44928092.zip
Target Explorer: The focus is not set to the correct control when
switching to a new form page.
-rw-r--r--target_explorer/plugins/org.eclipse.tcf.te.ui.views/src/org/eclipse/tcf/te/ui/views/editor/Editor.java35
-rw-r--r--target_explorer/plugins/org.eclipse.tcf.te.ui.views/src/org/eclipse/tcf/te/ui/views/editor/pages/TreeViewerExplorerEditorPage.java15
2 files changed, 50 insertions, 0 deletions
diff --git a/target_explorer/plugins/org.eclipse.tcf.te.ui.views/src/org/eclipse/tcf/te/ui/views/editor/Editor.java b/target_explorer/plugins/org.eclipse.tcf.te.ui.views/src/org/eclipse/tcf/te/ui/views/editor/Editor.java
index 638b9a3cd..ac449b88d 100644
--- a/target_explorer/plugins/org.eclipse.tcf.te.ui.views/src/org/eclipse/tcf/te/ui/views/editor/Editor.java
+++ b/target_explorer/plugins/org.eclipse.tcf.te.ui.views/src/org/eclipse/tcf/te/ui/views/editor/Editor.java
@@ -72,6 +72,41 @@ public final class Editor extends FormEditor implements IPersistableEditor, ITab
}
/**
+ * Override this method to delegate the setFocus to
+ * the active form page.
+ */
+ @Override
+ public void setFocus() {
+ int index = getActivePage();
+ if (index != -1) {
+ IFormPage fpage = getPage(index);
+ if (fpage != null) {
+ fpage.setFocus();
+ }
+ else super.setFocus();
+ }
+ else super.setFocus();
+ }
+
+ /**
+ * Returns the page which has the specified index.
+ *
+ * @param index The page's index.
+ * @return The page object or null if it does not exists.
+ */
+ private IFormPage getPage(int index) {
+ for(int i=0;i<pages.size();i++) {
+ Object page = pages.get(i);
+ if (page instanceof IFormPage) {
+ IFormPage fpage = (IFormPage)page;
+ if (fpage.getIndex() == index)
+ return fpage;
+ }
+ }
+ return null;
+ }
+
+ /**
* Update the editor page list. Pages which are not longer valid
* will be removed and pages now being valid gets added.
*/
diff --git a/target_explorer/plugins/org.eclipse.tcf.te.ui.views/src/org/eclipse/tcf/te/ui/views/editor/pages/TreeViewerExplorerEditorPage.java b/target_explorer/plugins/org.eclipse.tcf.te.ui.views/src/org/eclipse/tcf/te/ui/views/editor/pages/TreeViewerExplorerEditorPage.java
index 9d0f4aa72..5e9e31803 100644
--- a/target_explorer/plugins/org.eclipse.tcf.te.ui.views/src/org/eclipse/tcf/te/ui/views/editor/pages/TreeViewerExplorerEditorPage.java
+++ b/target_explorer/plugins/org.eclipse.tcf.te.ui.views/src/org/eclipse/tcf/te/ui/views/editor/pages/TreeViewerExplorerEditorPage.java
@@ -38,6 +38,7 @@ import org.eclipse.swt.events.FocusAdapter;
import org.eclipse.swt.events.FocusEvent;
import org.eclipse.swt.graphics.Image;
import org.eclipse.swt.widgets.Composite;
+import org.eclipse.swt.widgets.Control;
import org.eclipse.swt.widgets.Display;
import org.eclipse.tcf.te.core.interfaces.IViewerInput;
import org.eclipse.tcf.te.ui.forms.CustomFormToolkit;
@@ -79,6 +80,20 @@ public abstract class TreeViewerExplorerEditorPage extends AbstractCustomFormToo
super.dispose();
}
+ /**
+ * Set the initial focus to the tree.
+ */
+ @Override
+ public void setFocus() {
+ Control control = treeControl.getViewer().getControl();
+ if(control != null && !control.isDisposed()) {
+ control.setFocus();
+ }
+ else {
+ super.setFocus();
+ }
+ }
+
/*
* (non-Javadoc)
* @see org.eclipse.tcf.te.ui.views.editor.pages.AbstractEditorPage#setInitializationData(org.eclipse.core.runtime.IConfigurationElement, java.lang.String, java.lang.Object)

Back to the top