From 5b0cffed7ec28e0bc94f4f80b06b380a23a599d4 Mon Sep 17 00:00:00 2001 From: "shingil.kang" Date: Sun, 9 Feb 2014 17:11:09 +0900 Subject: [PATCH] TOOLS: Fixed a bug where the Connection Explorer does not properly focus on tableviewer or treeviewer. Change-Id: I1b25acba5f25e1bd6d07369a2c42aa4d93f3c871 Signed-off-by: shingil.kang --- .../explorer/ConnectionExplorerPanel.java | 80 +++++++++++++++++----- 1 file changed, 63 insertions(+), 17 deletions(-) diff --git a/org.tizen.common.connection/src/org/tizen/common/connection/explorer/ConnectionExplorerPanel.java b/org.tizen.common.connection/src/org/tizen/common/connection/explorer/ConnectionExplorerPanel.java index ab911f5..83436a5 100755 --- a/org.tizen.common.connection/src/org/tizen/common/connection/explorer/ConnectionExplorerPanel.java +++ b/org.tizen.common.connection/src/org/tizen/common/connection/explorer/ConnectionExplorerPanel.java @@ -188,6 +188,27 @@ public class ConnectionExplorerPanel implements IDeviceChangeListener, IDebugBri private boolean isSingleViewMode = false; private boolean selectionInDeviceView = false; + private enum Focus + { + TREE, TABLE, NONE + }; + + private class RefreshViewThread extends Thread + { + FileEntry entry; + + RefreshViewThread(FileEntry entry) + { + this.entry = entry; + } + + public void run() + { + treeViewer.refresh(entry, true); + tableViewer.refresh(entry, true); + } + }; + public ConnectionExplorerPanel() { ConsoleManager cm = new ConsoleManager("Connection Explorer", false); @@ -911,7 +932,7 @@ public class ConnectionExplorerPanel implements IDeviceChangeListener, IDebugBri throw new RuntimeException(e); } - refresh(entry.getParent()); + syncRefresh(entry.getParent()); setActionEnabled(); } } @@ -1024,16 +1045,14 @@ public class ConnectionExplorerPanel implements IDeviceChangeListener, IDebugBri */ private void refresh(final FileEntry entry) { - Display d = treeViewer.getTree().getDisplay(); - d.asyncExec(new Runnable() - { - @Override - public void run() - { - treeViewer.refresh(entry, true); - tableViewer.refresh(entry, true); - } - }); + RefreshViewThread refreshThread = new RefreshViewThread(entry); + SWTUtil.asyncExec(refreshThread); + } + + private void syncRefresh(final FileEntry entry) + { + RefreshViewThread refreshThread = new RefreshViewThread(entry); + SWTUtil.syncExec(refreshThread); } public void refreshSelection() @@ -1491,8 +1510,9 @@ public class ConnectionExplorerPanel implements IDeviceChangeListener, IDebugBri private FileEntry getSingleFileEntry() { Item[] items; + Focus focus = getFocus(); - if (treeViewer.getTree().isFocusControl()) + if (focus == Focus.TREE) { Tree tree = treeViewer.getTree(); if (tree.getSelectionCount() != 0) @@ -1505,7 +1525,7 @@ public class ConnectionExplorerPanel implements IDeviceChangeListener, IDebugBri return null; } } - else if (tableViewer.getTable().isFocusControl()) + else if (focus == Focus.TABLE) { Table table = tableViewer.getTable(); if (table.getSelectionCount() != 0) @@ -1528,8 +1548,9 @@ public class ConnectionExplorerPanel implements IDeviceChangeListener, IDebugBri private FileEntry[] getMultiFileEntry() { Item[] items; + Focus focus = getFocus(); - if (treeViewer.getTree().isFocusControl()) + if (focus == Focus.TREE) { Tree tree = treeViewer.getTree(); if (tree.getSelectionCount() != 0) @@ -1548,7 +1569,7 @@ public class ConnectionExplorerPanel implements IDeviceChangeListener, IDebugBri return null; } } - else if (tableViewer.getTable().isFocusControl()) + if (focus == Focus.TABLE) { Table table = tableViewer.getTable(); if (table.getSelectionCount() != 0) @@ -1577,13 +1598,14 @@ public class ConnectionExplorerPanel implements IDeviceChangeListener, IDebugBri private int getSelectionCount() { int selectionCount = 0; + Focus focus = getFocus(); - if (tableViewer.getTable().isFocusControl()) + if (focus == Focus.TABLE) { selectionCount = tableViewer.getTable().getSelectionCount(); } - else if (treeViewer.getTree().isFocusControl()) + else if (focus == Focus.TREE) { selectionCount = treeViewer.getTree().getSelectionCount(); } @@ -1591,6 +1613,30 @@ public class ConnectionExplorerPanel implements IDeviceChangeListener, IDebugBri return selectionCount; } + private Focus getFocus() + { + int tableSelectionCount = tableViewer.getTable().getSelectionCount(); + int treeSelectionCount = treeViewer.getTree().getSelectionCount(); + + if (tableViewer.getTable().isFocusControl() && tableSelectionCount != 0) + { + return Focus.TABLE; + } + if (treeViewer.getTree().isFocusControl() && treeSelectionCount != 0) + { + return Focus.TREE; + } + if (tableSelectionCount != 0) + { + return Focus.TABLE; + } + if (treeSelectionCount != 0) + { + return Focus.TREE; + } + return Focus.NONE; + } + @Override public void selectionChanged(final FileEntry selectedEntry) { -- 2.7.4