summaryrefslogtreecommitdiff
path: root/org.tizen.common.connection
diff options
context:
space:
mode:
Diffstat (limited to 'org.tizen.common.connection')
-rw-r--r--org.tizen.common.connection/META-INF/MANIFEST.MF9
-rw-r--r--org.tizen.common.connection/OSGI-INF/l10n/bundle.properties27
-rw-r--r--org.tizen.common.connection/build.properties4
-rw-r--r--org.tizen.common.connection/icons/Emulator_stop.gifbin1023 -> 0 bytes
-rw-r--r--org.tizen.common.connection/icons/connection_explorer.gif (renamed from org.tizen.common.connection/icons/Connection Explorer.gif)bin1035 -> 1035 bytes
-rw-r--r--org.tizen.common.connection/icons/emulator_manager.gif (renamed from org.tizen.common.connection/icons/Emulator_start.gif)bin614 -> 614 bytes
-rw-r--r--org.tizen.common.connection/icons/log/add_tab.png (renamed from org.tizen.common.connection/icons/log/Add tab.png)bin3228 -> 3228 bytes
-rw-r--r--org.tizen.common.connection/icons/log/clear_log.png (renamed from org.tizen.common.connection/icons/log/Clear Log.png)bin3225 -> 3225 bytes
-rw-r--r--org.tizen.common.connection/icons/log/edit_tab.png (renamed from org.tizen.common.connection/icons/log/Edit tab.png)bin3214 -> 3214 bytes
-rw-r--r--org.tizen.common.connection/icons/log/export_log.png (renamed from org.tizen.common.connection/icons/log/Export Log.png)bin3236 -> 3236 bytes
-rw-r--r--org.tizen.common.connection/icons/log/logview.gif (renamed from org.tizen.common.connection/icons/log/Log View.gif)bin388 -> 388 bytes
-rw-r--r--org.tizen.common.connection/icons/log/remove_tab.png (renamed from org.tizen.common.connection/icons/log/Remove tab.png)bin3348 -> 3348 bytes
-rw-r--r--org.tizen.common.connection/icons/log/scroll_lock.pngbin0 -> 731 bytes
-rw-r--r--org.tizen.common.connection/plugin.xml128
-rwxr-xr-x[-rw-r--r--]org.tizen.common.connection/src/org/tizen/common/connection/ConnectionPlugin.java435
-rw-r--r--org.tizen.common.connection/src/org/tizen/common/connection/ConnectionPluginSurrogate.java44
-rw-r--r--org.tizen.common.connection/src/org/tizen/common/connection/ddmuilib/FileDialogUtils.java250
-rw-r--r--org.tizen.common.connection/src/org/tizen/common/connection/debugtools/DebugTool.java175
-rwxr-xr-x[-rw-r--r--]org.tizen.common.connection/src/org/tizen/common/connection/debugtools/ToolsInstall.java630
-rw-r--r--org.tizen.common.connection/src/org/tizen/common/connection/debugtools/ToolsInstallMessages.properties8
-rw-r--r--org.tizen.common.connection/src/org/tizen/common/connection/explorer/ConnectionExplorerContentProvider.java199
-rwxr-xr-x[-rw-r--r--]org.tizen.common.connection/src/org/tizen/common/connection/explorer/ConnectionExplorerLabelProvider.java241
-rwxr-xr-x[-rw-r--r--]org.tizen.common.connection/src/org/tizen/common/connection/explorer/ConnectionExplorerPanel.java2216
-rwxr-xr-x[-rw-r--r--]org.tizen.common.connection/src/org/tizen/common/connection/explorer/Messages.java76
-rw-r--r--org.tizen.common.connection/src/org/tizen/common/connection/explorer/messages.properties15
-rwxr-xr-x[-rw-r--r--]org.tizen.common.connection/src/org/tizen/common/connection/log/AddViewDialog.java622
-rw-r--r--org.tizen.common.connection/src/org/tizen/common/connection/log/LogColors.java16
-rwxr-xr-x[-rw-r--r--]org.tizen.common.connection/src/org/tizen/common/connection/log/LogPanel.java1697
-rw-r--r--org.tizen.common.connection/src/org/tizen/common/connection/log/LogTab.java1605
-rw-r--r--org.tizen.common.connection/src/org/tizen/common/connection/log/LogUIMessages.properties14
-rwxr-xr-x[-rw-r--r--]org.tizen.common.connection/src/org/tizen/common/connection/properties/ConnectionExplorerPermissionPropertyPages.java12
-rw-r--r--org.tizen.common.connection/src/org/tizen/common/connection/sdblib/dnd/FileEntryDropAdapter.java29
-rwxr-xr-x[-rw-r--r--]org.tizen.common.connection/src/org/tizen/common/connection/ui/ConnectionExplorer.java837
-rw-r--r--org.tizen.common.connection/src/org/tizen/common/connection/ui/ConnectionUIMessages.java61
-rw-r--r--org.tizen.common.connection/src/org/tizen/common/connection/ui/ConnectionUIMessages.properties17
-rw-r--r--org.tizen.common.connection/src/org/tizen/common/connection/ui/LogView.java457
-rw-r--r--org.tizen.common.connection/src/org/tizen/common/connection/ui/TizenRemoteFileDialog.java147
-rwxr-xr-x[-rw-r--r--]org.tizen.common.connection/src/org/tizen/common/connection/ui/TizenRemoteFileLabelProvider.java3
38 files changed, 5332 insertions, 4642 deletions
diff --git a/org.tizen.common.connection/META-INF/MANIFEST.MF b/org.tizen.common.connection/META-INF/MANIFEST.MF
index 3aa5a4cd4..f3a3e077c 100644
--- a/org.tizen.common.connection/META-INF/MANIFEST.MF
+++ b/org.tizen.common.connection/META-INF/MANIFEST.MF
@@ -1,17 +1,18 @@
Manifest-Version: 1.0
Bundle-ManifestVersion: 2
-Bundle-Name: Tizen Common Connection
+Bundle-Name: %Bundle-Name
Bundle-SymbolicName: org.tizen.common.connection;singleton:=true
Bundle-Version: 1.0.0.qualifier
Bundle-Activator: org.tizen.common.connection.ConnectionPlugin
-Bundle-Vendor: Samsung
+Bundle-Vendor: %Bundle-Vendor
Require-Bundle: org.eclipse.ui,
org.eclipse.core.runtime,
- org.eclipse.core.resources;bundle-version="3.6.1",
+ org.eclipse.core.resources,
org.tizen.common
Bundle-RequiredExecutionEnvironment: JavaSE-1.6
Bundle-ActivationPolicy: lazy
-Import-Package: org.tizen.common.util
+Import-Package: org.eclipse.ui.console,
+ org.tizen.common.util
Bundle-ClassPath: .
Export-Package: org.tizen.common.connection;
uses:="org.eclipse.jface.resource,
diff --git a/org.tizen.common.connection/OSGI-INF/l10n/bundle.properties b/org.tizen.common.connection/OSGI-INF/l10n/bundle.properties
new file mode 100644
index 000000000..30d37969d
--- /dev/null
+++ b/org.tizen.common.connection/OSGI-INF/l10n/bundle.properties
@@ -0,0 +1,27 @@
+Bundle-Name = Tizen Common Connection
+Bundle-Vendor = Samsung Electronics
+
+view.category = Tizen
+view.connectionExplorer = Connection Explorer
+view.log = Log
+
+properties.page.info = Info
+properties.page.permission = Permission
+
+command.category = Connection Explorer
+command.delete.name = Delete
+command.delete.description = Delete a file or folder on the connected target
+command.rename.name = Rename
+command.rename.description = Rename a file or folder on the connected target
+command.refresh.name = Refresh
+command.refresh.description = Referesh contents of the connected target
+command.property.name = Properties
+command.property.description = View properties for a selected file or folder
+
+context.delete.name = Delete
+context.rename.name = Rename
+context.refresh.name = Refresh
+context.properties.name = Properties
+
+extension.name = Connection Resource Drop
+extension-point.name = tools \ No newline at end of file
diff --git a/org.tizen.common.connection/build.properties b/org.tizen.common.connection/build.properties
index 414cf4bce..71c01b3ae 100644
--- a/org.tizen.common.connection/build.properties
+++ b/org.tizen.common.connection/build.properties
@@ -5,6 +5,8 @@ bin.includes = META-INF/,\
plugin.xml,\
icons/,\
about.html,\
- about_files/
+ about_files/,\
+ OSGI-INF/,\
+ OSGI-INF/l10n/bundle.properties
jars.compile.order = .,\
sdblib.jar
diff --git a/org.tizen.common.connection/icons/Emulator_stop.gif b/org.tizen.common.connection/icons/Emulator_stop.gif
deleted file mode 100644
index 60cf40cad..000000000
--- a/org.tizen.common.connection/icons/Emulator_stop.gif
+++ /dev/null
Binary files differ
diff --git a/org.tizen.common.connection/icons/Connection Explorer.gif b/org.tizen.common.connection/icons/connection_explorer.gif
index 111e3f9ea..111e3f9ea 100644
--- a/org.tizen.common.connection/icons/Connection Explorer.gif
+++ b/org.tizen.common.connection/icons/connection_explorer.gif
Binary files differ
diff --git a/org.tizen.common.connection/icons/Emulator_start.gif b/org.tizen.common.connection/icons/emulator_manager.gif
index 8737c07bd..8737c07bd 100644
--- a/org.tizen.common.connection/icons/Emulator_start.gif
+++ b/org.tizen.common.connection/icons/emulator_manager.gif
Binary files differ
diff --git a/org.tizen.common.connection/icons/log/Add tab.png b/org.tizen.common.connection/icons/log/add_tab.png
index b07109b79..b07109b79 100644
--- a/org.tizen.common.connection/icons/log/Add tab.png
+++ b/org.tizen.common.connection/icons/log/add_tab.png
Binary files differ
diff --git a/org.tizen.common.connection/icons/log/Clear Log.png b/org.tizen.common.connection/icons/log/clear_log.png
index 4f542ad11..4f542ad11 100644
--- a/org.tizen.common.connection/icons/log/Clear Log.png
+++ b/org.tizen.common.connection/icons/log/clear_log.png
Binary files differ
diff --git a/org.tizen.common.connection/icons/log/Edit tab.png b/org.tizen.common.connection/icons/log/edit_tab.png
index d13ab48cf..d13ab48cf 100644
--- a/org.tizen.common.connection/icons/log/Edit tab.png
+++ b/org.tizen.common.connection/icons/log/edit_tab.png
Binary files differ
diff --git a/org.tizen.common.connection/icons/log/Export Log.png b/org.tizen.common.connection/icons/log/export_log.png
index ee3f1e8a3..ee3f1e8a3 100644
--- a/org.tizen.common.connection/icons/log/Export Log.png
+++ b/org.tizen.common.connection/icons/log/export_log.png
Binary files differ
diff --git a/org.tizen.common.connection/icons/log/Log View.gif b/org.tizen.common.connection/icons/log/logview.gif
index 9007253b2..9007253b2 100644
--- a/org.tizen.common.connection/icons/log/Log View.gif
+++ b/org.tizen.common.connection/icons/log/logview.gif
Binary files differ
diff --git a/org.tizen.common.connection/icons/log/Remove tab.png b/org.tizen.common.connection/icons/log/remove_tab.png
index 6788fc85b..6788fc85b 100644
--- a/org.tizen.common.connection/icons/log/Remove tab.png
+++ b/org.tizen.common.connection/icons/log/remove_tab.png
Binary files differ
diff --git a/org.tizen.common.connection/icons/log/scroll_lock.png b/org.tizen.common.connection/icons/log/scroll_lock.png
new file mode 100644
index 000000000..41078de92
--- /dev/null
+++ b/org.tizen.common.connection/icons/log/scroll_lock.png
Binary files differ
diff --git a/org.tizen.common.connection/plugin.xml b/org.tizen.common.connection/plugin.xml
index 89e284e97..4a0b7715c 100644
--- a/org.tizen.common.connection/plugin.xml
+++ b/org.tizen.common.connection/plugin.xml
@@ -1,25 +1,37 @@
<?xml version="1.0" encoding="UTF-8"?>
<?eclipse version="3.4"?>
<plugin>
- <extension-point id="org.tizen.common.connection.tools" name="tools" schema="schema/tools.exsd"/>
- <extension
- point="org.eclipse.ui.views">
- <category
- name="Tizen"
- id="org.tizen.nativeapp.viewCategory"/>
+ <extension-point id="org.tizen.common.connection.tools" name="%extension-point.name" schema="schema/tools.exsd"/>
+ <extension
+ point="org.eclipse.ui.views">
+ <category
+ name="%view.category"
+ id="org.tizen.nativeapp.viewCategory"/>
</extension>
<extension
point="org.eclipse.ui.views">
<view
category="org.tizen.nativeapp.viewCategory"
class="org.tizen.common.connection.ui.ConnectionExplorer"
- icon="icons/Connection Explorer.gif"
+ icon="icons/connection_explorer.gif"
id="org.tizen.common.connection.ui.ConnectionExplorer"
- name="Connection Explorer"
+ name="%view.connectionExplorer"
restorable="true">
</view>
</extension>
-
+
+ <extension
+ point="org.eclipse.ui.views">
+ <view
+ name="%view.log"
+ icon="icons/log/logview.gif"
+ category="org.tizen.nativeapp.viewCategory"
+ class="org.tizen.common.connection.ui.LogView"
+ id="org.tizen.common.connection.ui.LogView"
+ allowMultiple = "true">
+ </view>
+ </extension>
+
<extension
point="org.eclipse.ui.perspectiveExtensions">
<perspectiveExtension
@@ -35,29 +47,55 @@
</viewShortcut>
</perspectiveExtension>
</extension>
+ <extension
+ point="org.eclipse.ui.perspectiveExtensions">
+ <perspectiveExtension
+ targetID="org.tizen.nativeapp.perspective">
+ <view
+ id="org.tizen.common.connection.ui.LogView"
+ ratio="1"
+ relationship="stack"
+ relative="org.eclipse.ui.views.TaskList">
+ </view>
+ <viewShortcut
+ id="org.tizen.common.connection.ui.LogView">
+ </viewShortcut>
+ </perspectiveExtension>
+ <perspectiveExtension
+ targetID="org.eclipse.debug.ui.DebugPerspective">
+ <view
+ id="org.tizen.common.connection.ui.LogView"
+ ratio="1"
+ relationship="stack"
+ relative="org.eclipse.ui.views.TaskList">
+ </view>
+ <viewShortcut
+ id="org.tizen.common.connection.ui.LogView">
+ </viewShortcut>
+ </perspectiveExtension>
+ </extension>
<extension
id="org.tizen.common.connection.ui.filedrop"
- name="Connection Resource Drop"
+ name="%extension.name"
point="org.eclipse.ui.dropActions">
- <action
- class="org.tizen.common.connection.sdblib.dnd.FileEntryDropAdapter"
- id="org.tizen.common.connection.filedrop">
- </action>
-
+ <action
+ class="org.tizen.common.connection.sdblib.dnd.FileEntryDropAdapter"
+ id="org.tizen.common.connection.filedrop">
+ </action>
</extension>
<extension
point="org.eclipse.ui.propertyPages">
<page
class="org.tizen.common.connection.properties.ConnectionExplorerInfoPropertyPages"
id="org.tizen.common.connection.properties.Info"
- name="Info"
+ name="%properties.page.info"
nameFilter="*"
objectClass="org.tizen.sdblib.FileListingService$FileEntry">
</page>
<page
class="org.tizen.common.connection.properties.ConnectionExplorerPermissionPropertyPages"
id="org.tizen.common.connection.properties.Permission"
- name="Permission"
+ name="%properties.page.permission"
nameFilter="*"
objectClass="org.tizen.sdblib.FileListingService$FileEntry">
</page>
@@ -91,72 +129,56 @@
</extension>
<extension
point="org.eclipse.ui.commands">
+ <category
+ id="org.tizen.common.connection.category"
+ name="%command.category">
+ </category>
<command
+ categoryId="org.tizen.common.connection.category"
+ description="%command.delete.description"
id="org.tizen.common.connection.delete"
- name="deleteaction">
+ name="%command.delete.name">
</command>
<command
+ categoryId="org.tizen.common.connection.category"
+ description="%command.rename.description"
id="org.tizen.common.connection.rename"
- name="renameaction">
+ name="%command.rename.name">
</command>
<command
+ categoryId="org.tizen.common.connection.category"
+ description="%command.refresh.description"
id="org.tizen.common.connection.refresh"
- name="refreshaction">
+ name="%command.refresh.name">
</command>
<command
+ categoryId="org.tizen.common.connection.category"
+ description="%command.property.description"
id="org.tizen.common.connection.property"
- name="propertyaction">
+ name="%command.property.name">
</command>
</extension>
<extension
point="org.eclipse.ui.contexts">
<context
id="org.tizen.common.connection.delete.context"
- name="delete"
+ name="%context.delete.name"
parentId="org.eclipse.ui.contexts.window">
</context>
<context
id="org.tizen.common.connection.rename.context"
- name="rename"
+ name="%context.rename.name"
parentId="org.eclipse.ui.contexts.window">
</context>
<context
id="org.tizen.common.connection.refresh.context"
- name="refresh"
+ name="%context.refresh.name"
parentId="org.eclipse.ui.contexts.window">
</context>
<context
id="org.tizen.common.connection.property.context"
- name="property"
+ name="%context.properties.name"
parentId="org.eclipse.ui.contexts.window">
</context>
</extension>
-
- <extension
- point="org.eclipse.ui.views">
- <view
- name="Log"
- icon="icons/log/Log View.gif"
- category="org.tizen.nativeapp.viewCategory"
- class="org.tizen.common.connection.ui.LogView"
- id="org.tizen.common.connection.ui.LogView"
- allowMultiple = "true">
- </view>
- </extension>
-
- <extension
- point="org.eclipse.ui.perspectiveExtensions">
- <perspectiveExtension
- targetID="org.tizen.nativeapp.perspective">
- <view
- id="org.tizen.common.connection.ui.LogView"
- ratio="1"
- relationship="stack"
- relative="org.eclipse.ui.views.TaskList">
- </view>
- <viewShortcut
- id="org.tizen.common.connection.ui.LogView">
- </viewShortcut>
- </perspectiveExtension>
- </extension>
</plugin>
diff --git a/org.tizen.common.connection/src/org/tizen/common/connection/ConnectionPlugin.java b/org.tizen.common.connection/src/org/tizen/common/connection/ConnectionPlugin.java
index dc5cbf606..09d28fd8b 100644..100755
--- a/org.tizen.common.connection/src/org/tizen/common/connection/ConnectionPlugin.java
+++ b/org.tizen.common.connection/src/org/tizen/common/connection/ConnectionPlugin.java
@@ -1,36 +1,36 @@
/*
-* Common
-*
-* Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved.
-*
-* Contact:
-* Hoon Kang <h245.kang@samsung.com>
-* Hyunsik Noh <hyunsik.noh@samsung.com>
-*
+ * Common
+ *
+ * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved.
+ *
+ * Contact:
+ * Hoon Kang <h245.kang@samsung.com>
+ * Hyunsik Noh <hyunsik.noh@samsung.com>
+ *
* Licensed under the Apache License, Version 2.0 (the "License");
-* you may not use this file except in compliance with the License.
-* You may obtain a copy of the License at
-*
-* http://www.apache.org/licenses/LICENSE-2.0
-*
-* Unless required by applicable law or agreed to in writing, software
-* distributed under the License is distributed on an "AS IS" BASIS,
-* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-* See the License for the specific language governing permissions and
-* limitations under the License.
-*
-* Contributors:
-* - S-Core Co., Ltd
-*
-*/
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ * Contributors:
+ * - S-Core Co., Ltd
+ *
+ */
package org.tizen.common.connection;
import java.io.File;
+import java.io.IOException;
import java.util.ArrayList;
import java.util.List;
-import java.util.Properties;
import org.eclipse.core.runtime.IConfigurationElement;
import org.eclipse.core.runtime.IExtensionRegistry;
@@ -40,11 +40,13 @@ import org.eclipse.jface.resource.ImageDescriptor;
import org.eclipse.ui.plugin.AbstractUIPlugin;
import org.osgi.framework.BundleContext;
import org.tizen.common.connection.debugtools.DebugTool;
-import org.tizen.common.properties.InstallPathConfig;
-
+import org.tizen.common.core.application.InstallPathConfig;
+import org.tizen.common.util.FileUtil;
+import org.tizen.common.util.HostUtil;
+import org.tizen.common.util.OSChecker;
+import org.tizen.common.util.log.Logger;
import org.tizen.sdblib.FileListingService.FileEntry;
import org.tizen.sdblib.IDevice;
-import org.tizen.sdblib.Log;
import org.tizen.sdblib.SmartDevelopmentBridge;
/**
@@ -52,23 +54,23 @@ import org.tizen.sdblib.SmartDevelopmentBridge;
*/
public class ConnectionPlugin extends AbstractUIPlugin {
- // The plug-in ID
- public static final String PLUGIN_ID = "org.tizen.common.connection"; //$NON-NLS-1$
- public static final String ID_LOGS_VIEW = "org.tizen.common.connection.ui.LogView"; //$NON-NLS-1$
- public static final String ID_CONNECTION_VIEW = "org.tizen.common.connection.ui.ConnectionExplorer";
- public static final String ID_DEBUGTOOLS_EXTENSION = "org.tizen.common.connection.tools"; //$NON-NLS-1$
-
- // The shared instance
- private static ConnectionPlugin plugin;
-
- private IDevice currentDevice;
- private final ArrayList<ISelectionListener> listeners = new ArrayList<ISelectionListener>();
-
- public int os;
- public static final int LINUX = 0;
- public static final int WINDOWS = 1;
-
- /**
+ // The plug-in ID
+ public static final String PLUGIN_ID = "org.tizen.common.connection"; //$NON-NLS-1$
+ public static final String ID_LOGS_VIEW = "org.tizen.common.connection.ui.LogView"; //$NON-NLS-1$
+ public static final String ID_CONNECTION_VIEW = "org.tizen.common.connection.ui.ConnectionExplorer";
+ public static final String ID_DEBUGTOOLS_EXTENSION = "org.tizen.common.connection.tools"; //$NON-NLS-1$
+
+ // The shared instance
+ private static ConnectionPlugin plugin;
+
+ private IDevice currentDevice;
+ private final ArrayList<ISelectionListener> listeners = new ArrayList<ISelectionListener>();
+
+ public int os;
+ public static final int LINUX = 0;
+ public static final int WINDOWS = 1;
+
+ /**
* Implements for FileEntry changed status.
*/
public interface ISelectionListener {
@@ -79,143 +81,210 @@ public class ConnectionPlugin extends AbstractUIPlugin {
*/
void selectionChanged(FileEntry selectedEntry);
}
-
- /**
- * The constructor
- */
- public ConnectionPlugin() {
- }
-
- /*
- * (non-Javadoc)
- * @see org.eclipse.ui.plugin.AbstractUIPlugin#start(org.osgi.framework.BundleContext)
- */
- public void start(BundleContext context) throws Exception {
-
- super.start(context);
- plugin = this;
-
- Properties properties = System.getProperties();
- String value = properties.getProperty("os.name");
- if (value.contains("Windows"))
- this.os = WINDOWS;
- else
- this.os = LINUX;
-
- }
-
- public static synchronized List<DebugTool> getDebugTools(IDevice device) {
-
- List<DebugTool> toolLists = new ArrayList<DebugTool>();
-
- IExtensionRegistry x = RegistryFactory.getRegistry();
- IConfigurationElement[] ces = x.getConfigurationElementsFor(ID_DEBUGTOOLS_EXTENSION);
-
- for (int i = 0; i < ces.length; ++i) {
- IConfigurationElement ce = ces[i];
- if (ce.getName().equals("tools")) {
- String packagename = ce.getAttribute("packagename");
- if (packagename == null)
- continue;
- String sourcepath = ce.getAttribute("sourcepath");
- if (sourcepath == null)
- continue;
- String description = ce.getAttribute("description");
-
- Path sourcePath = new Path(InstallPathConfig.getSDKPath() + "/" + sourcepath);
-
- File packageList = new File(sourcePath.toOSString());
- for (File f : packageList.listFiles()) {
- if (f.getName().startsWith(packagename)) {
- String[] filename = f.getName().split("_");
- if (filename.length != 3)
- continue;
- String version = filename[1];
- String[] arch = filename[2].split("\\.");
- if (arch.length != 2)
- continue;
- String architecture = arch[0];
-
- if (device.isEmulator()) {
- if (!architecture.equals("i386"))
- continue;
- } else {
- if (!architecture.equals("armel"))
- continue;
- }
- DebugTool dt = new DebugTool();
- dt.setPackagename(packagename);
- dt.setBinaryname(f.getName());
- dt.setSourcepath(sourcepath);
- dt.setDescription(description);
- dt.setVersion(version);
- dt.setArchitecture(architecture);
- toolLists.add(dt);
- }
- }
- }
- }
- return toolLists;
- }
-
- /*
- * (non-Javadoc)
- * @see org.eclipse.ui.plugin.AbstractUIPlugin#stop(org.osgi.framework.BundleContext)
- */
- public void stop(BundleContext context) throws Exception {
- plugin = null;
- SmartDevelopmentBridge.disconnectBridge();
- super.stop(context);
- }
-
- /**
- * Returns the shared instance
- *
- * @return the shared instance
- */
- public static ConnectionPlugin getDefault() {
- return plugin;
- }
-
- public void setCurrentDevice(IDevice device) {
- currentDevice = device;
- }
-
- public IDevice getCurrentDevice() {
- return currentDevice;
- }
-
-
- public void addSelectionListener(ISelectionListener listener) {
- listeners.add(listener);
- }
-
- public void removeSelectionListener(ISelectionListener listener) {
- listeners.remove(listener);
- }
-
- public void notifySelectionListeners(FileEntry file) {
-
- ISelectionListener[] listenersCopy = listeners.toArray(
- new ISelectionListener[listeners.size()]);
-
- for (ISelectionListener listener : listenersCopy) {
- try {
- listener.selectionChanged(file);
- } catch (Exception e) {
- Log.e("ConnectionPlugin", e);
- }
- }
- }
-
- /**
- * Returns an image descriptor for the image file at the given
- * plug-in relative path
- *
- * @param path the path
- * @return the image descriptor
- */
- public static ImageDescriptor getImageDescriptorFromPlugin(String path) {
- return imageDescriptorFromPlugin(PLUGIN_ID, path);
- }
+
+ /**
+ * The constructor
+ */
+ public ConnectionPlugin() {
+ }
+
+ /*
+ * (non-Javadoc)
+ * @see org.eclipse.ui.plugin.AbstractUIPlugin#start(org.osgi.framework.BundleContext)
+ */
+ public void start(BundleContext context) throws Exception {
+
+ super.start(context);
+ plugin = this;
+
+ if (OSChecker.isWindows())
+ {
+ this.os = WINDOWS;
+ }
+ else
+ {
+ this.os = LINUX;
+ }
+
+ }
+
+ public static synchronized List<DebugTool> getDebugTools(IDevice device) {
+ List<DebugTool> toolLists = new ArrayList<DebugTool>();
+ IExtensionRegistry x = RegistryFactory.getRegistry();
+ IConfigurationElement[] ces = x.getConfigurationElementsFor(ID_DEBUGTOOLS_EXTENSION);
+
+ try {
+ for ( IConfigurationElement ce : ces ) {
+ if (ce.getName().equals("tools")) {
+ String packagename = ce.getAttribute("packagename");
+ if (packagename == null)
+ {
+ continue;
+ }
+ String sourcepath = ce.getAttribute("sourcepath");
+ if (sourcepath == null)
+ {
+ continue;
+ }
+ String description = ce.getAttribute("description");
+ Path sourcePath = new Path(InstallPathConfig.getPlatformVersionPath() + "/" + sourcepath);
+ File packageList = new File(sourcePath.toOSString());
+
+ DebugTool dt = null;
+ File[] packageFileList = packageList.listFiles();
+ if ( packageFileList == null ) {
+ continue;
+ }
+ for (File f : packageList.listFiles()) {
+ if ( DebugTool.RPM_PACKAGE_TYPE.equals(FileUtil.getFileExtension(f.getName())) ) {
+ dt = makeDebugToolFromRPM(f, device, packagename, sourcepath, description);
+ }
+ else {
+ dt = makeDebugToolFromTar(f, device, packagename, sourcepath, description);
+ }
+ if ( dt != null ) {
+ toolLists.add(dt);
+ }
+ }
+ }
+ }
+ } catch (Throwable e) {
+ Logger.error("Failed making DebugTool list for on-demand install", e);
+ }
+ return toolLists;
+ }
+
+ private static DebugTool makeDebugToolFromRPM( File f, IDevice device, String packagename, String sourcepath, String description ) {
+ String architecture = "";
+ String version = "";
+ String name = "";
+
+ // Not supported "RPM" at windows
+ // architecture = HostUtil.returnExecute( String.format( DebugTool.RPM_QUERY_COMMAND, "%{ARCH}", "-p " + f.getCanonicalPath()) );
+ // version = HostUtil.returnExecute( String.format( DebugTool.RPM_QUERY_COMMAND, "%{VERSION}", "-p " + f.getCanonicalPath()) );
+ // name = HostUtil.returnExecute( String.format( DebugTool.RPM_QUERY_COMMAND, "%{NAME}", "-p " + f.getCanonicalPath()) );
+
+ // RPM file format : gtest-0.0.8-7.1.armv7l.rpm
+ String[] fileSplit = f.getName().split("-");
+ if ( fileSplit.length < 3 ) {
+ return null;
+ }
+ name = fileSplit[0];
+ // version is not used
+ // FIXME : Unsafe way to extract the version.
+ version = fileSplit[1];
+ String[] archSplit = fileSplit[fileSplit.length-1].split("\\.");
+ architecture = archSplit[archSplit.length-2];
+
+ if ( !packagename.equals(name) ) {
+ return null;
+ }
+ if (device.isEmulator()) {
+ if ( !architecture.contains("86")) {
+ return null;
+ }
+ }
+ else {
+ if ( !architecture.contains("arm")) {
+ return null;
+ }
+ }
+
+ DebugTool dt = new DebugTool(packagename, f.getName(), sourcepath, version, description, architecture, DebugTool.RPM_PACKAGE_TYPE);
+
+ return dt;
+ }
+
+ private static DebugTool makeDebugToolFromTar( File f, IDevice device, String packagename, String sourcepath, String description ) {
+ String[] filename = f.getName().split("_");
+ if (filename.length != 3) {
+ return null;
+ }
+ if( !filename[0].equals(packagename)) {
+ return null;
+ }
+ String version = filename[1];
+ String[] arch = filename[2].split("\\.");
+ if (arch.length != 2) {
+ return null;
+ }
+ String architecture = arch[0];
+
+ if (device.isEmulator()) {
+ if (!architecture.equals("i386"))
+ {
+ return null;
+ }
+ } else {
+ if (!architecture.equals("armel"))
+ {
+ return null;
+ }
+ }
+
+ DebugTool dt = new DebugTool(packagename, f.getName(), sourcepath, version, description, architecture, "tar");
+ return dt;
+ }
+
+ /*
+ * (non-Javadoc)
+ * @see org.eclipse.ui.plugin.AbstractUIPlugin#stop(org.osgi.framework.BundleContext)
+ */
+ public void stop(BundleContext context) throws Exception {
+ plugin = null;
+ int deviceCnt = SmartDevelopmentBridge.getBridge().getDevices().length;
+ if (deviceCnt==0)
+ SmartDevelopmentBridge.disconnectBridge();
+ super.stop(context);
+ }
+
+ /**
+ * Returns the shared instance
+ *
+ * @return the shared instance
+ */
+ public static ConnectionPlugin getDefault() {
+ return plugin;
+ }
+
+ public void setCurrentDevice(IDevice device) {
+ currentDevice = device;
+ }
+
+ public IDevice getCurrentDevice() {
+ return currentDevice;
+ }
+
+ public void addSelectionListener(ISelectionListener listener) {
+ listeners.add(listener);
+ }
+
+ public void removeSelectionListener(ISelectionListener listener) {
+ listeners.remove(listener);
+ }
+
+ public void notifySelectionListeners(FileEntry file) {
+
+ ISelectionListener[] listenersCopy = listeners.toArray(
+ new ISelectionListener[listeners.size()]);
+
+ for (ISelectionListener listener : listenersCopy) {
+ try {
+ listener.selectionChanged(file);
+ } catch (Exception e) {
+ Logger.error("ConnectionPlugin", e);
+ }
+ }
+ }
+
+ /**
+ * Returns an image descriptor for the image file at the given
+ * plug-in relative path
+ *
+ * @param path the path
+ * @return the image descriptor
+ */
+ public static ImageDescriptor getImageDescriptorFromPlugin(String path) {
+ return imageDescriptorFromPlugin(PLUGIN_ID, path);
+ }
} \ No newline at end of file
diff --git a/org.tizen.common.connection/src/org/tizen/common/connection/ConnectionPluginSurrogate.java b/org.tizen.common.connection/src/org/tizen/common/connection/ConnectionPluginSurrogate.java
new file mode 100644
index 000000000..5cc6a6c13
--- /dev/null
+++ b/org.tizen.common.connection/src/org/tizen/common/connection/ConnectionPluginSurrogate.java
@@ -0,0 +1,44 @@
+/*
+* Common
+*
+* Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved.
+*
+* Contact:
+* Kangho Kim <kh5325.kim@samsung.com>
+* Hyeongseok Heo <hyeongseok.heo@samsung.com>
+* BonYong Lee <bonyong.lee@samsung.com>
+* Gyeongseok Seo <gyeongseok.seo@samsung.com>
+*
+* Licensed under the Apache License, Version 2.0 (the "License");
+* you may not use this file except in compliance with the License.
+* You may obtain a copy of the License at
+*
+* http://www.apache.org/licenses/LICENSE-2.0
+*
+* Unless required by applicable law or agreed to in writing, software
+* distributed under the License is distributed on an "AS IS" BASIS,
+* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+* See the License for the specific language governing permissions and
+* limitations under the License.
+*
+* Contributors:
+* - S-Core Co., Ltd
+*
+*/
+
+package org.tizen.common.connection;
+
+import org.tizen.common.Surrogate;
+
+/**
+ * The ConnectionPluginSurrogate class adapt ConnectionPlugin default object
+ *
+ * @author BonYong Lee{@literal <bonyong.lee@samsung.com>} (S-Core)
+ * @author Gyeongseok Seo <gyeongseok.seo@samsung.com>
+ */
+public class ConnectionPluginSurrogate implements Surrogate<ConnectionPlugin> {
+ @Override
+ public ConnectionPlugin getAdapter() {
+ return ConnectionPlugin.getDefault();
+ }
+}
diff --git a/org.tizen.common.connection/src/org/tizen/common/connection/ddmuilib/FileDialogUtils.java b/org.tizen.common.connection/src/org/tizen/common/connection/ddmuilib/FileDialogUtils.java
index 9d220354d..a6af7cbbe 100644
--- a/org.tizen.common.connection/src/org/tizen/common/connection/ddmuilib/FileDialogUtils.java
+++ b/org.tizen.common.connection/src/org/tizen/common/connection/ddmuilib/FileDialogUtils.java
@@ -1,30 +1,32 @@
/*
-* Common
-*
-* Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved.
-*
-* Contact:
-* Hoon Kang <h245.kang@samsung.com>
-* Yoonki Park <yoonki.park@samsung.com>
-*
+ * Common
+ *
+ * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved.
+ *
+ * Contact:
+ * Hoon Kang <h245.kang@samsung.com>
+ * Yoonki Park <yoonki.park@samsung.com>
+ *
* Licensed under the Apache License, Version 2.0 (the "License");
-* you may not use this file except in compliance with the License.
-* You may obtain a copy of the License at
-*
-* http://www.apache.org/licenses/LICENSE-2.0
-*
-* Unless required by applicable law or agreed to in writing, software
-* distributed under the License is distributed on an "AS IS" BASIS,
-* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-* See the License for the specific language governing permissions and
-* limitations under the License.
-*
-* Contributors:
-* - S-Core Co., Ltd
-*
-*/
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ * Contributors:
+ * - S-Core Co., Ltd
+ *
+ */
package org.tizen.common.connection.ddmuilib;
+import java.util.concurrent.atomic.AtomicInteger;
+
import org.eclipse.jface.dialogs.IDialogConstants;
import org.eclipse.jface.dialogs.MessageDialog;
import org.eclipse.osgi.util.NLS;
@@ -32,147 +34,73 @@ import org.eclipse.swt.SWT;
import org.eclipse.ui.PlatformUI;
import org.tizen.common.connection.explorer.Messages;
+public class FileDialogUtils
+{
+ public static int checkOverwrite(final String filename)
+ {
+ String message = NLS.bind(Messages.getString("FileDialogUtils.overwrite.message"), filename);
+ String[] labels = new String[] { IDialogConstants.YES_LABEL, IDialogConstants.YES_TO_ALL_LABEL, IDialogConstants.NO_LABEL,
+ IDialogConstants.CANCEL_LABEL };
+ int type = MessageDialog.QUESTION;
+ return openFileDialog(labels, message, type);
+ }
-public class FileDialogUtils {
- private static FileDialogUtils instance;
-
- private FileDialogUtils() { }
-
- public static FileDialogUtils getInstance() {
- if (instance == null)
- instance = new FileDialogUtils();
- return instance;
- }
-
- public int checkOverwrite(final String filename) {
- final int[] result = new int[1]; // using array since you can't change a final int
-
- Runnable query = new Runnable() {
- public void run() {
- int[] resultId = {
- IDialogConstants.YES_ID,
- IDialogConstants.YES_TO_ALL_ID,
- IDialogConstants.NO_ID,
- IDialogConstants.CANCEL_ID };
-
- String[] labels = new String[] {
- IDialogConstants.YES_LABEL,
- IDialogConstants.YES_TO_ALL_LABEL,
- IDialogConstants.NO_LABEL,
- IDialogConstants.CANCEL_LABEL };
-
- String msg = NLS.bind(Messages.getString("FileDialogUtils.overrite.message"), filename);
- MessageDialog dialog = new MessageDialog(
- PlatformUI.getWorkbench().getDisplay().getActiveShell(),
- Messages.getString("FileDialogUtils.overrite.title"),
- null, msg , MessageDialog.QUESTION, labels, 0);
- dialog.open();
- if (dialog.getReturnCode() == SWT.DEFAULT) {
- // A window close returns SWT.DEFAULT - mapped to a cancel
- result[0] = IDialogConstants.CANCEL_ID;
- } else {
- result[0] = resultId[dialog.getReturnCode()];
- }
- }
- };
-
- PlatformUI.getWorkbench().getDisplay().syncExec(query);
- return result[0];
- }
- public int confirmDelete(final String filename) {
- final int[] result = new int[1]; // using array since you can't change a final int
-
- Runnable query = new Runnable() {
- public void run() {
- int[] resultId = {
- IDialogConstants.YES_ID,
- IDialogConstants.CANCEL_ID };
-
- String[] labels = new String[] {
- IDialogConstants.YES_LABEL,
- IDialogConstants.CANCEL_LABEL };
-
- String msg = NLS.bind(Messages.getString("FileDialogUtils.delete.message"), filename);
- MessageDialog dialog = new MessageDialog(
- PlatformUI.getWorkbench().getDisplay().getActiveShell(),
- Messages.getString("FileDialogUtils.delete.title"),
- null, msg , MessageDialog.QUESTION, labels, 0);
- dialog.open();
- if (dialog.getReturnCode() == SWT.DEFAULT) {
- // A window close returns SWT.DEFAULT - mapped to a cancel
- result[0] = IDialogConstants.CANCEL_ID;
- } else {
- result[0] = resultId[dialog.getReturnCode()];
- }
- }
- };
-
- PlatformUI.getWorkbench().getDisplay().syncExec(query);
- return result[0];
- }
-
- public int checkFileOverwrite(final String filename) {
- final int[] result = new int[1]; // using array since you can't change a final int
-
- Runnable query = new Runnable() {
- public void run() {
- int[] resultId = {
- IDialogConstants.OK_ID,
- IDialogConstants.CANCEL_ID };
+ public static int confirmDelete(final String filename)
+ {
+ String message = NLS.bind(Messages.getString("FileDialogUtils.delete.message"), filename);
+ String[] labels = new String[] { IDialogConstants.OK_LABEL, IDialogConstants.CANCEL_LABEL };
+ int type = MessageDialog.QUESTION;
+ return openFileDialog(labels, message, type);
+ }
- String[] labels = new String[] {
- IDialogConstants.OK_LABEL,
- IDialogConstants.CANCEL_LABEL };
-
- String msg = NLS.bind(Messages.getString("FileDialogUtils.overrite.message"), filename);
- MessageDialog dialog = new MessageDialog(
- PlatformUI.getWorkbench().getDisplay().getActiveShell(),
- Messages.getString("FileDialogUtils.overrite.title"),
- null, msg , MessageDialog.QUESTION, labels, 0);
- dialog.open();
- if (dialog.getReturnCode() == SWT.DEFAULT) {
- // A window close returns SWT.DEFAULT - mapped to a cancel
- result[0] = IDialogConstants.CANCEL_ID;
- } else {
- result[0] = resultId[dialog.getReturnCode()];
- }
- }
- };
+ public static int allowFileOverwrite(final String filename)
+ {
+ String message = NLS.bind(Messages.getString("FileDialogUtils.overwrite.message"), filename);
+ String[] labels = new String[] { IDialogConstants.OK_LABEL, IDialogConstants.CANCEL_LABEL };
+ int type = MessageDialog.QUESTION;
+ return openFileDialog(labels, message, type);
+ }
- PlatformUI.getWorkbench().getDisplay().syncExec(query);
- return result[0];
- }
-
- public int checkTabName(final String filename) {
- final int[] result = new int[1]; // using array since you can't change a final int
+ public static int checkTabName(final String filename)
+ {
+ String message = NLS.bind(Messages.getString("FileDialogUtils.tabName.message"), filename);
+ String[] labels = new String[] { IDialogConstants.OK_LABEL };
+ int type = MessageDialog.ERROR;
+ return openFileDialog(labels, message, type);
+ }
- Runnable query = new Runnable() {
- public void run() {
- int[] resultId = {
- IDialogConstants.OK_ID
- };
+ public static void notifyDuplication(final String filename)
+ {
+ String message = NLS.bind(Messages.getString("FileDialogUtils.duplicate.message"), filename);
+ String[] labels = new String[] { IDialogConstants.OK_LABEL };
+ int type = MessageDialog.ERROR;
+ openFileDialog(labels, message, type);
+ }
- String[] labels = new String[] {
- IDialogConstants.OK_LABEL
- };
-
- String msg = NLS.bind(Messages.getString("FileDialogUtils.tabName.message"), filename);
- MessageDialog dialog = new MessageDialog(
- PlatformUI.getWorkbench().getDisplay().getActiveShell(),
- Messages.getString("FileDialogUtils.tabName.title"),
- null, msg , MessageDialog.ERROR, labels, 0);
- dialog.open();
- if (dialog.getReturnCode() == SWT.DEFAULT) {
- // A window close returns SWT.DEFAULT - mapped to a cancel
- result[0] = IDialogConstants.CANCEL_ID;
- } else {
- result[0] = resultId[dialog.getReturnCode()];
- }
- }
- };
+ private static int openFileDialog(final String[] labels, final String message, final int type)
+ {
+ final AtomicInteger resultAtomicInteger = new AtomicInteger();
+ Runnable query = new Runnable()
+ {
+ @Override
+ public void run()
+ {
+ String title = Messages.getString("FileDialogUtils.message.title");
+ MessageDialog dialog = new MessageDialog(PlatformUI.getWorkbench().getDisplay().getActiveShell(),
+ title, null, message, type, labels, 0);
+ dialog.open();
+ if (dialog.getReturnCode() == SWT.DEFAULT)
+ {
+ // A window close returns SWT.DEFAULT - mapped to a cancel
+ resultAtomicInteger.set(IDialogConstants.CANCEL_ID);
+ } else
+ {
+ resultAtomicInteger.set(dialog.getReturnCode());
+ }
+ }
+ };
- PlatformUI.getWorkbench().getDisplay().syncExec(query);
- return result[0];
- }
-
-}
+ PlatformUI.getWorkbench().getDisplay().syncExec(query);
+ return resultAtomicInteger.get();
+ }
+} \ No newline at end of file
diff --git a/org.tizen.common.connection/src/org/tizen/common/connection/debugtools/DebugTool.java b/org.tizen.common.connection/src/org/tizen/common/connection/debugtools/DebugTool.java
index 6ed16fdbb..24e52f912 100644
--- a/org.tizen.common.connection/src/org/tizen/common/connection/debugtools/DebugTool.java
+++ b/org.tizen.common.connection/src/org/tizen/common/connection/debugtools/DebugTool.java
@@ -1,85 +1,104 @@
/*
-* Common
-*
-* Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved.
-*
-* Contact:
-* Hoon Kang <h245.kang@samsung.com>
-* YoonKi Park <yoonki.park@samsung.com>
-*
+ * Common
+ *
+ * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved.
+ *
+ * Contact:
+ * Hoon Kang <h245.kang@samsung.com>
+ * YoonKi Park <yoonki.park@samsung.com>
+ *
* Licensed under the Apache License, Version 2.0 (the "License");
-* you may not use this file except in compliance with the License.
-* You may obtain a copy of the License at
-*
-* http://www.apache.org/licenses/LICENSE-2.0
-*
-* Unless required by applicable law or agreed to in writing, software
-* distributed under the License is distributed on an "AS IS" BASIS,
-* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-* See the License for the specific language governing permissions and
-* limitations under the License.
-*
-* Contributors:
-* - S-Core Co., Ltd
-*
-*/
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ * Contributors:
+ * - S-Core Co., Ltd
+ *
+ */
package org.tizen.common.connection.debugtools;
-import org.tizen.common.properties.InstallPathConfig;
+import org.tizen.common.TizenPlatformConstants;
+import org.tizen.common.core.application.InstallPathConfig;
public class DebugTool {
- public static final String CONTROL_EXTENSION = ".control";
- public static final String TOOLS_TARGET_PATH = "/home/developer/sdk_tools";
- public static final String TOOLS_HOST_PATH = InstallPathConfig.getSDKPath();
-
- private String binaryname;
- private String packagename;
- private String sourcepath;
- private String architecture;
- private String description;
- private String version;
-
- public DebugTool() {
-
- }
- public String getBinaryname() {
- return binaryname;
- }
- public String getControlFile() {
- return "." + this.packagename + CONTROL_EXTENSION;
- }
- public String getVersion() {
- return version;
- }
- public void setVersion(String pVersion) {
- version = pVersion;
- }
- public void setBinaryname(String pBinaryname) {
- binaryname = pBinaryname;
- }
- public String getPackagename() {
- return packagename;
- }
- public void setPackagename(String pPackagename) {
- packagename = pPackagename;
- }
- public String getSourcepath() {
- return sourcepath;
- }
- public void setSourcepath(String pSourcepath) {
- sourcepath = pSourcepath;
- }
- public String getArchitecture() {
- return architecture;
- }
- public void setArchitecture(String pArchitecture) {
- architecture = pArchitecture;
- }
- public String getDescription() {
- return description;
- }
- public void setDescription(String pDescription) {
- description = pDescription;
- }
-
+ public static final String TOOLS_HOST_PATH = InstallPathConfig.getPlatformVersionPath();
+ public static final String RPM_QUERY_COMMAND = "rpm -q --queryformat=%s %s";
+ public static final String RPM_PACKAGE_TYPE = "rpm";
+ public static final String RPM_INSTALL_COMMAND = "rpm -i %s";
+ public static final String RPM_UPGRADE_COMMAND = "rpm -U %s";
+
+ private String binaryname;
+ private String packagename;
+ private String sourcepath;
+ private String architecture;
+ private String description;
+ private String version;
+ private String packagetype;
+
+ public DebugTool() {
+
+ }
+ public DebugTool(String packagename, String binaryname, String sourcepath, String version, String desc, String arch, String type) {
+ this.packagename = packagename;
+ this.binaryname = binaryname;
+ this.sourcepath = sourcepath;
+ this.version = version;
+ this.description = desc;
+ this.architecture = arch;
+ this.packagetype = type;
+ }
+ public String getBinaryname() {
+ return binaryname;
+ }
+ public String getControlFile() {
+ return "." + this.packagename + TizenPlatformConstants.CONTROL_EXTENSION;
+ }
+ public String getVersion() {
+ return version;
+ }
+ public void setVersion(String pVersion) {
+ version = pVersion;
+ }
+ public void setBinaryname(String pBinaryname) {
+ binaryname = pBinaryname;
+ }
+ public String getPackagename() {
+ return packagename;
+ }
+ public void setPackagename(String pPackagename) {
+ packagename = pPackagename;
+ }
+ public String getSourcepath() {
+ return sourcepath;
+ }
+ public void setSourcepath(String pSourcepath) {
+ sourcepath = pSourcepath;
+ }
+ public String getArchitecture() {
+ return architecture;
+ }
+ public void setArchitecture(String pArchitecture) {
+ architecture = pArchitecture;
+ }
+ public String getDescription() {
+ return description;
+ }
+ public void setDescription(String pDescription) {
+ description = pDescription;
+ }
+ public void setPackagetype(String packagetype) {
+ this.packagetype = packagetype;
+ }
+ public String getPackagetype() {
+ return packagetype;
+ }
+
}
diff --git a/org.tizen.common.connection/src/org/tizen/common/connection/debugtools/ToolsInstall.java b/org.tizen.common.connection/src/org/tizen/common/connection/debugtools/ToolsInstall.java
index c62827865..75f7af0c3 100644..100755
--- a/org.tizen.common.connection/src/org/tizen/common/connection/debugtools/ToolsInstall.java
+++ b/org.tizen.common.connection/src/org/tizen/common/connection/debugtools/ToolsInstall.java
@@ -1,35 +1,40 @@
/*
-* Common
-*
-* Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved.
-*
-* Contact:
-* Hoon Kang <h245.kang@samsung.com>
-* YoonKi Park <yoonki.park@samsung.com>
-*
+ * Common
+ *
+ * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved.
+ *
+ * Contact:
+ * Hoon Kang <h245.kang@samsung.com>
+ * YoonKi Park <yoonki.park@samsung.com>
+ * Gun Kim <gune.kim@samsung.com>
+ *
* Licensed under the Apache License, Version 2.0 (the "License");
-* you may not use this file except in compliance with the License.
-* You may obtain a copy of the License at
-*
-* http://www.apache.org/licenses/LICENSE-2.0
-*
-* Unless required by applicable law or agreed to in writing, software
-* distributed under the License is distributed on an "AS IS" BASIS,
-* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-* See the License for the specific language governing permissions and
-* limitations under the License.
-*
-* Contributors:
-* - S-Core Co., Ltd
-*
-*/
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ * Contributors:
+ * - S-Core Co., Ltd
+ *
+ */
package org.tizen.common.connection.debugtools;
+import static org.tizen.common.util.CollectionUtil.isEmpty;
+import static org.tizen.common.util.IOUtil.tryClose;
+
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.lang.reflect.InvocationTargetException;
+import java.util.ArrayList;
import java.util.List;
import java.util.regex.Pattern;
@@ -41,284 +46,335 @@ import org.eclipse.jface.operation.IRunnableWithProgress;
import org.eclipse.swt.SWT;
import org.eclipse.swt.widgets.Display;
import org.eclipse.swt.widgets.Shell;
+import org.tizen.common.TizenPlatformConstants;
import org.tizen.common.connection.ConnectionPlugin;
-import org.tizen.common.log.Logger;
-
+import org.tizen.common.util.IOUtil;
+import org.tizen.common.util.SdbCommandUtil;
+import org.tizen.common.util.log.Logger;
import org.tizen.sdblib.IDevice;
-import org.tizen.sdblib.SdbCommandRejectedException;
import org.tizen.sdblib.SdbShellProcess;
-import org.tizen.sdblib.SyncService;
-import org.tizen.sdblib.SyncService.SyncResult;
-import org.tizen.sdblib.TimeoutException;
class PackageInstallMonitorDialog extends ProgressMonitorDialog {
- public PackageInstallMonitorDialog(Shell parent) {
- super(parent);
- int shellStyle = getShellStyle();
- shellStyle &= ~SWT.APPLICATION_MODAL;
- setShellStyle(shellStyle);
- }
+ public PackageInstallMonitorDialog(Shell parent) {
+ super(parent);
+ int shellStyle = getShellStyle();
+ shellStyle &= ~SWT.APPLICATION_MODAL;
+ setShellStyle(shellStyle);
+ }
}
class InstallProgress implements IRunnableWithProgress {
- private static final String CMD_RESULT_CHECK = "; echo $?";
-
- private IDevice device = null;
-
- IProgressMonitor monitor = null;
-
- private boolean checkDirectory(String dir) throws CoreException {
- String cmd = "ls " + dir + CMD_RESULT_CHECK;
- return checkExitCode(cmd, ToolsInstallMessages.CANNOT_CHECK_DIRECTORY);
- }
-
-
- private void makeDirectory(String dir) throws CoreException {
- String cmd = "mkdir -p -m 755 " + dir + CMD_RESULT_CHECK ;
- String msg = ToolsInstallMessages.CANNOT_CREATE_DIRECTORY;
-
- if (checkExitCode(cmd, msg) == false)
- installCoreException(msg, null);
- }
-
- private boolean checkExitCode( String cmd, String msg ) throws CoreException
- {
- boolean result = false;
- SdbShellProcess lsProc;
- BufferedReader br = null;
- try {
- lsProc = device.executeShellCommand(cmd);
- br = new BufferedReader(new InputStreamReader(
- lsProc.getInputStream()));
- String lsOut = null;
- while (null != (lsOut = br.readLine())) {
- if ("0".equals(lsOut)) {
- result = true;
- break;
- }
- }
- } catch (IOException e) {
- installCoreException(msg, e);
- Logger.error(msg, e);
- }finally
- {
- if( br != null )
- try {
- br.close();
- } catch (IOException e) {
- Logger.error("Error to close BufferedReader", e);
- }
- }
- return result;
- }
-
- private boolean isInstalled(DebugTool dt) throws CoreException {
- boolean ret = false;
- BufferedReader br = null;
- try {
-
- SdbShellProcess echoProc = device.executeShellCommand(
- "cat " + DebugTool.TOOLS_TARGET_PATH + "/" + dt.getControlFile() + CMD_RESULT_CHECK);
- br = new BufferedReader(new InputStreamReader(
- echoProc.getInputStream()));
-
- String lsOut = null;
- String oldVersion = null;
- while (null != (lsOut = br.readLine())) {
- //version:0.0.0
- if (lsOut.toLowerCase().startsWith("version:")) {
- oldVersion = lsOut.split(":")[1];
- }
-
- if ("0".equals(lsOut)) {
- String v1 = normalisedVersion(oldVersion, ".", 4);
- String v2 = normalisedVersion(dt.getVersion(), ".", 4);
- if (v2.compareTo(v1) > 0) {
- //TODO : do install and save!
- ret = false;
- } else { //same version
- ret = true;
- }
- break;
- } else
- ret = false;
- }
- } catch (IOException e) {
- installCoreException(ToolsInstallMessages.CANNOT_CHECK_INSTALLED, e);
- Logger.error(ToolsInstallMessages.CANNOT_CHECK_INSTALLED, e);
- } finally {
- if(br != null)
- try {
- br.close();
- } catch (IOException e) {
- Logger.error("Error to close BufferedReader", e);
- }
- }
- return ret;
-
- }
- private String normalisedVersion(String version, String sep, int maxWidth) {
- String[] split = Pattern.compile(sep, Pattern.LITERAL).split(version);
- StringBuilder sb = new StringBuilder();
- for (String s : split) {
- sb.append(String.format("%" + maxWidth + 's', s));
- }
- return sb.toString();
- }
-
- private boolean copyPackage(String source, String destination) {
- boolean pushResult = false;
- try {
- SyncService syncService = device.getSyncService();
- SyncResult pushSyncResult = syncService.pushFile(source, destination,
- SyncService.getNullProgressMonitor());
- if (SyncService.RESULT_OK == pushSyncResult.getCode()) {
- pushResult = true;
- }
- } catch (TimeoutException e) {
- return false;
- } catch (SdbCommandRejectedException e) {
- return false;
- } catch (IOException e) {
- return false;
- }
- return pushResult;
- }
-
- private final void installPackage(DebugTool tool) throws CoreException {
- String local = DebugTool.TOOLS_HOST_PATH + "/" + tool.getSourcepath() + "/" + tool.getBinaryname();
- String remote = DebugTool.TOOLS_TARGET_PATH + "/" + tool.getBinaryname();
-
- // delete old version
- try {
- device.executeShellCommand(
- "cd " + DebugTool.TOOLS_TARGET_PATH + " && rm " + tool.getControlFile());
- } catch (IOException e) {
- installCoreException(ToolsInstallMessages.CANNOT_REMOVE_CONTROLFILE, e);
- Logger.error(ToolsInstallMessages.CANNOT_REMOVE_CONTROLFILE, e);
- }
-
-
- boolean isCopied = copyPackage(local, remote);
- monitor.worked(5);
- if (isCopied) {
- try {
- //make one string command for sequential executing
- device.executeShellCommand(
- "rm -rf " + DebugTool.TOOLS_TARGET_PATH + "/" + tool.getPackagename() + ";"
- + "cd " + DebugTool.TOOLS_TARGET_PATH + " && tar -xzf " + tool.getBinaryname() + ";"
- + "echo 'version:" + tool.getVersion() + "' >" + DebugTool.TOOLS_TARGET_PATH + "/" + tool.getControlFile() + ";"
- + "cd " + DebugTool.TOOLS_TARGET_PATH + " && rm " + tool.getBinaryname());
-
- } catch (IOException e) {
- Logger.error("Error after copied " + tool.getPackagename() , e);
- }
- }
- }
-
- @Override
- public void run(IProgressMonitor pMonitor) throws InvocationTargetException, InterruptedException {
- final List<DebugTool> debugTools = ConnectionPlugin.getDebugTools(device);
-
- if (debugTools == null || debugTools.size() == 0)
- return;
- boolean isInstalled = false;
- for (int i = 0; i < debugTools.size(); i++) {
- DebugTool dt = (DebugTool) debugTools.get(i);
- try {
- isInstalled = isInstalled(dt);
- } catch (CoreException e) {
- Logger.error("Error to check installed", e);
- }
- if (isInstalled == false)
- break;
- }
- if (isInstalled)
- return;
-
- this.monitor = pMonitor;
-
- pMonitor.beginTask(ToolsInstallMessages.DIALOG_INITILIZE, 100);
- //monitor.subTask("Prepare install");
-
- // check directory exist
- try {
- if (!checkDirectory(DebugTool.TOOLS_TARGET_PATH))
- makeDirectory(DebugTool.TOOLS_TARGET_PATH);
- } catch (CoreException e) {
- Logger.error("Error to check or make directory", e);
- }
-
- pMonitor.worked(10);
-
- // get package list to install
-
- pMonitor.worked(15);
-
- // install loop (cp, tar)
- for (int i=0 ; i<debugTools.size(); i++) {
- final DebugTool dt = (DebugTool)debugTools.get(i);
-
- if (device.isEmulator()) {
- if (!dt.getArchitecture().equals("i386"))
- continue;
- }
- else {
- if (!dt.getArchitecture().equals("armel"))
- continue;
- }
- Thread thread = new Thread(null, new Runnable() {
-
- @Override
- public void run() {
- try {
- installPackage(dt);
- } catch (CoreException e) {
- Logger.error("Error to install tools", e);
- }
- }
- }, "package check and install");
- thread.start();
- }
- pMonitor.done();
- }
-
- public void setDevice(IDevice pDevice) {
- device = pDevice;
- }
-
- private void installCoreException(String message, Throwable exception) throws CoreException {
+ private static final String CMD_RESULT_CHECK = "; echo $?";
+ private static final String CMD_TAR_INSTALL =
+ "rm -rf " + TizenPlatformConstants.TOOLS_TARGET_PATH + "/%s && " + // remove old version package
+ "cd " + TizenPlatformConstants.TOOLS_TARGET_PATH + " && " + // move to directory for on-demand
+ "tar -xzf %s && " + // install new version package
+ "echo 'version:%s'>" + TizenPlatformConstants.TOOLS_TARGET_PATH + "/%s && " + // create control file
+ "rm -f " + TizenPlatformConstants.TOOLS_TARGET_PATH + "/%s"; // remove package.tar
+
+
+ private IDevice device = null;
+
+ IProgressMonitor monitor = null;
+
+ private boolean checkDirectory(String dir) throws CoreException {
+ String cmd = "ls " + dir + CMD_RESULT_CHECK;
+ return checkExitCode(cmd, ToolsInstallMessages.CANNOT_CHECK_DIRECTORY);
+ }
+
+
+ private void makeDirectory(String dir) throws CoreException {
+ String cmd = "mkdir -p -m 755 " + dir + CMD_RESULT_CHECK ;
+ String msg = ToolsInstallMessages.CANNOT_CREATE_DIRECTORY;
+
+ if (checkExitCode(cmd, msg) == false)
+ {
+ installCoreException(msg, null);
+ }
+ }
+
+ private boolean checkExitCode( String cmd, String msg ) throws CoreException
+ {
+ boolean result = false;
+ SdbShellProcess lsProc;
+ BufferedReader br = null;
+ try {
+ lsProc = device.executeShellCommand(cmd);
+ br = new BufferedReader(new InputStreamReader(
+ lsProc.getInputStream()));
+ String lsOut = null;
+ while (null != (lsOut = br.readLine())) {
+ if ("0".equals(lsOut)) {
+ result = true;
+ break;
+ }
+ }
+ } catch (IOException e) {
+ installCoreException(msg, e);
+ Logger.error(msg, e);
+ }finally
+ {
+ tryClose( br );
+ }
+ return result;
+ }
+
+ private boolean isInstalled(DebugTool dt) throws CoreException {
+ boolean ret = false;
+ BufferedReader br = null;
+ try {
+
+ SdbShellProcess echoProc = device.executeShellCommand(
+ "cat " + TizenPlatformConstants.TOOLS_TARGET_PATH + "/" + dt.getControlFile() + CMD_RESULT_CHECK);
+ br = new BufferedReader(new InputStreamReader(
+ echoProc.getInputStream()));
+
+ String lsOut = null;
+ String oldVersion = null;
+ while (null != (lsOut = br.readLine())) {
+ //version:0.0.0
+ if (lsOut.toLowerCase().startsWith("version:")) {
+ oldVersion = lsOut.split(":")[1];
+ }
+
+ if ("0".equals(lsOut)) {
+ String v1 = normalisedVersion(oldVersion, ".", 4);
+ String v2 = normalisedVersion(dt.getVersion(), ".", 4);
+ if (v2.compareTo(v1) > 0) {
+ //TODO : do install and save!
+ ret = false;
+ } else { //same version
+ ret = true;
+ }
+ break;
+ } else
+ {
+ ret = false;
+ }
+ }
+ } catch (IOException e) {
+ installCoreException(ToolsInstallMessages.CANNOT_CHECK_INSTALLED, e);
+ Logger.error(ToolsInstallMessages.CANNOT_CHECK_INSTALLED, e);
+ } finally {
+ tryClose( br );
+ }
+ return ret;
+
+ }
+ private String normalisedVersion(String version, String sep, int maxWidth) {
+ String[] split = Pattern.compile(sep, Pattern.LITERAL).split(version);
+ StringBuilder sb = new StringBuilder();
+ for (String s : split) {
+ sb.append(String.format("%" + maxWidth + 's', s));
+ }
+ return sb.toString();
+ }
+
+ @Override
+ public void run(IProgressMonitor pMonitor) throws InvocationTargetException, InterruptedException {
+ final List<DebugTool> allDebugTools = ConnectionPlugin.getDebugTools(device);
+ List<DebugTool> installDebugTools = new ArrayList<DebugTool>();
+
+ if ( isEmpty( allDebugTools ) )
+ {
+ return;
+ }
+ boolean isInstalled = false;
+ for ( DebugTool dt : allDebugTools ) {
+ try {
+ isInstalled = isInstalled(dt);
+ } catch (CoreException e) {
+ Logger.error("Error to check installed", e);
+ }
+ if (isInstalled == false) {
+ installDebugTools.add(dt);
+ }
+ }
+ if ( installDebugTools.isEmpty() ) {
+ return;
+ }
+
+ this.monitor = pMonitor;
+
+ pMonitor.beginTask(ToolsInstallMessages.DIALOG_INITILIZE, 100);
+ //monitor.subTask("Prepare install");
+
+ // check directory exist
+ try {
+ if (!checkDirectory(TizenPlatformConstants.TOOLS_TARGET_PATH))
+ makeDirectory(TizenPlatformConstants.TOOLS_TARGET_PATH);
+ } catch (CoreException e) {
+ Logger.error("Error to check or make directory", e);
+ }
+
+ pMonitor.worked(10);
+
+ // get package list to install
+
+ pMonitor.worked(15);
+ String threadName = "";
+ // install loop (cp, tar)
+ for ( DebugTool dt : installDebugTools ) {
+ if (device.isEmulator()) {
+ if (!dt.getArchitecture().contains("86"))
+ continue;
+ }
+ else {
+ if (!dt.getArchitecture().contains("arm"))
+ continue;
+ }
+
+ threadName = "OnDemandInstallThread-" + dt.getPackagename();
+ Runnable r = new OnDemandInstall(dt);
+ Thread t = new Thread(r, threadName);
+ t.start();
+ }
+ pMonitor.done();
+ }
+
+ public void setDevice(IDevice pDevice) {
+ device = pDevice;
+ }
+
+ private boolean copyPackage(String source, String destination) {
+ return SdbCommandUtil.filePush(device, source, destination);
+ }
+
+ private final void installTarPackage(DebugTool tool) throws CoreException {
+ String local = DebugTool.TOOLS_HOST_PATH + "/" + tool.getSourcepath() + "/" + tool.getBinaryname();
+ String remote = TizenPlatformConstants.TOOLS_TARGET_PATH + "/" + tool.getBinaryname();
+
+ // delete old version
+ try {
+ device.executeShellCommand(
+ "cd " + TizenPlatformConstants.TOOLS_TARGET_PATH + " && rm " + tool.getControlFile());
+ } catch (IOException e) {
+ Logger.error("Failed delete old version ( " + tool.getPackagename() + " )");
+ return;
+ }
+
+ boolean isCopied = copyPackage(local, remote);
+ if (isCopied) {
+ try {
+ //make one string command for sequential executing
+ String installCommand = String.format(CMD_TAR_INSTALL, tool.getPackagename(),
+ tool.getBinaryname(),
+ tool.getVersion(), tool.getControlFile(),
+ tool.getBinaryname());
+ device.executeShellCommand(installCommand);
+
+ } catch (IOException e) {
+ Logger.error("Error after copied " + tool.getPackagename() , e);
+ }
+ }
+ else if (!isCopied) {
+ Logger.error("Failed file copy ( " + tool.getBinaryname() + " )");
+ }
+ }
+
+ private final void installRPMPackage(DebugTool tool) throws CoreException {
+ boolean isInstalled = false;
+ String local = DebugTool.TOOLS_HOST_PATH + "/" + tool.getSourcepath() + "/" + tool.getBinaryname();
+ String remote = TizenPlatformConstants.TOOLS_TARGET_PATH + "/" + tool.getBinaryname();
+
+ String packagename;
+
+ BufferedReader br = null;
+ SdbShellProcess sdbShell = null;
+ try {
+ sdbShell = device.executeShellCommand(String.format( DebugTool.RPM_QUERY_COMMAND, "\"%{NAME}\\n\"", tool.getPackagename()));
+ br = new BufferedReader(new InputStreamReader(sdbShell.getInputStream()));
+
+ while (null != (packagename = br.readLine())) {
+ if ( tool.getPackagename().equals(packagename)){
+ isInstalled = true;
+ break;
+ }
+ }
+ } catch (IOException e1) {
+ } finally {
+ IOUtil.tryClose(br);
+ if ( sdbShell != null ) {
+ sdbShell.destroy();
+ }
+ }
+
+ boolean isCopied = copyPackage(local, remote);
+ if (isCopied) {
+ String command = null;
+ if ( isInstalled ) {
+ command = String.format(DebugTool.RPM_UPGRADE_COMMAND, remote);
+ }
+ else {
+ command = String.format(DebugTool.RPM_INSTALL_COMMAND, remote);
+ }
+ try {
+ command = command + String.format("; rm -f %s", remote);
+ device.executeShellCommand(command);
+ } catch (IOException e) {
+ Logger.error("Error occurred while executing rpm command " + command , e);
+ }
+ }
+ else if (!isCopied) {
+ Logger.error("Failed file copy ( " + tool.getBinaryname() + " )");
+ }
+ }
+
+ private void installCoreException(String message, Throwable exception) throws CoreException {
Status status = new Status(Status.ERROR, ConnectionPlugin.PLUGIN_ID, message, exception);
throw new CoreException(status);
}
+
+ class OnDemandInstall implements Runnable {
+ private final DebugTool tool;
+
+ OnDemandInstall(final DebugTool tool) {
+ this.tool = tool;
+ }
+
+ @Override
+ public void run() {
+ try {
+ if ( DebugTool.RPM_PACKAGE_TYPE.equals(tool.getPackagetype()) ) {
+ installRPMPackage(tool);
+ }
+ else {
+ installTarPackage(tool);
+ }
+ } catch (CoreException e) {
+ Logger.error("Error to install tools", e);
+ }
+ }
+ }
}
public class ToolsInstall {
- public static void installPackages(IDevice device) {
- final IDevice tDevice = device;
-
- if (tDevice.isOffline()) {
- return;
- }
-
- Display.getDefault().asyncExec(new Runnable() {
- @Override
- public void run() {
- final PackageInstallMonitorDialog installDialog = new PackageInstallMonitorDialog(
- Display.getDefault().getActiveShell());
- try {
- InstallProgress installProgress = new InstallProgress();
- installProgress.setDevice(tDevice);
- installDialog.run(true, false, installProgress);
- } catch (InvocationTargetException e) {
- return;
- } catch (InterruptedException e) {
- return;
- }
- }
- });
-
- }
+ public static void installPackages(IDevice device) {
+ final IDevice tDevice = device;
+
+ if (tDevice.isOffline()) {
+ return;
+ }
+
+ Display.getDefault().asyncExec(new Runnable() {
+ @Override
+ public void run() {
+ final PackageInstallMonitorDialog installDialog = new PackageInstallMonitorDialog(
+ Display.getDefault().getActiveShell());
+ try {
+ InstallProgress installProgress = new InstallProgress();
+ installProgress.setDevice(tDevice);
+ installDialog.run(true, false, installProgress);
+ } catch (InvocationTargetException e) {
+ Logger.error("Failed on-demand install", e);
+ return;
+ } catch (InterruptedException e) {
+ Logger.error("Failed on-demand install", e);
+ return;
+ }
+ }
+ });
+ }
}
diff --git a/org.tizen.common.connection/src/org/tizen/common/connection/debugtools/ToolsInstallMessages.properties b/org.tizen.common.connection/src/org/tizen/common/connection/debugtools/ToolsInstallMessages.properties
index 5d8397958..f192516cf 100644
--- a/org.tizen.common.connection/src/org/tizen/common/connection/debugtools/ToolsInstallMessages.properties
+++ b/org.tizen.common.connection/src/org/tizen/common/connection/debugtools/ToolsInstallMessages.properties
@@ -1,8 +1,6 @@
-
-DIALOG_INITILIZE=Connection Explorer is initializing now. It might take few minutes.
+DIALOG_INITILIZE=Connection Explorer is initializing. It can take a few minutes.
CANNOT_CREATE_DIRECTORY=Cannot create sdk tools directory
CANNOT_CHECK_DIRECTORY=Cannot check sdk tools directory
CANNOT_CHECK_INSTALLED=Cannot check installed tools
-CANNOT_COPY_FILE=Cannot copy file
-CANNOT_REMOVE_CONTROLFILE=Cannot copy file
-
+CANNOT_COPY_FILE=Cannot copy the file
+CANNOT_REMOVE_CONTROLFILE=Cannot delete the file
diff --git a/org.tizen.common.connection/src/org/tizen/common/connection/explorer/ConnectionExplorerContentProvider.java b/org.tizen.common.connection/src/org/tizen/common/connection/explorer/ConnectionExplorerContentProvider.java
index 4aa5e2d27..f469f27e5 100644
--- a/org.tizen.common.connection/src/org/tizen/common/connection/explorer/ConnectionExplorerContentProvider.java
+++ b/org.tizen.common.connection/src/org/tizen/common/connection/explorer/ConnectionExplorerContentProvider.java
@@ -1,152 +1,107 @@
/*
-* Common
-*
-* Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved.
-*
-* Contact:
-* Hoon Kang <h245.kang@samsung.com>
-* Hyunsik Noh <hyunsik.noh@samsung.com>
-*
+ * Common
+ *
+ * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved.
+ *
+ * Contact:
+ * Hoon Kang <h245.kang@samsung.com>
+ * Hyunsik Noh <hyunsik.noh@samsung.com>
+ *
* Licensed under the Apache License, Version 2.0 (the "License");
-* you may not use this file except in compliance with the License.
-* You may obtain a copy of the License at
-*
-* http://www.apache.org/licenses/LICENSE-2.0
-*
-* Unless required by applicable law or agreed to in writing, software
-* distributed under the License is distributed on an "AS IS" BASIS,
-* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-* See the License for the specific language governing permissions and
-* limitations under the License.
-*
-* Contributors:
-* - S-Core Co., Ltd
-*
-*/
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ * Contributors:
+ * - S-Core Co., Ltd
+ *
+ */
package org.tizen.common.connection.explorer;
import org.eclipse.jface.viewers.ITreeContentProvider;
-import org.eclipse.jface.viewers.TreeViewer;
import org.eclipse.jface.viewers.Viewer;
-import org.eclipse.swt.widgets.Display;
-import org.eclipse.swt.widgets.Tree;
-
import org.tizen.sdblib.FileListingService;
import org.tizen.sdblib.FileListingService.FileEntry;
-import org.tizen.sdblib.FileListingService.IListingReceiver;
import org.tizen.sdblib.IDevice;
import org.tizen.sdblib.SmartDevelopmentBridge;
-public class ConnectionExplorerContentProvider implements ITreeContentProvider {
-
- private TreeViewer viewer;
- private FileEntry rootEntry;
-
- private IListingReceiver listingReceiver = new IListingReceiver() {
- public void setChildren(final FileEntry entry, FileEntry[] children) {
- final Tree t = viewer.getTree();
- if (t != null && t.isDisposed() == false) {
- Display display = t.getDisplay();
- if (display.isDisposed() == false) {
- display.asyncExec(new Runnable() {
- public void run() {
- if (t.isDisposed() == false) {
- // refresh the entry.
- viewer.refresh(entry);
- viewer.setExpandedState(entry, true);
- }
- }
- });
- }
- }
- }
+public class ConnectionExplorerContentProvider implements ITreeContentProvider
+{
- public void refreshEntry(final FileEntry entry) {
- final Tree t = viewer.getTree();
- if (t != null && t.isDisposed() == false) {
- Display display = t.getDisplay();
- if (display.isDisposed() == false) {
- display.asyncExec(new Runnable() {
- public void run() {
- if (t.isDisposed() == false) {
- // refresh the entry.
- viewer.refresh(entry);
- }
- }
- });
- }
- }
- }
- };
+ @Override
+ public void dispose()
+ {
+ }
-
- @Override
- public void dispose() {
- }
+ @Override
+ public void inputChanged(Viewer pViewer, Object pOldInput, Object pNewInput)
+ {
+ }
- @Override
- public void inputChanged(Viewer pViewer, Object pOldInput, Object pNewInput) {
- if (pViewer instanceof TreeViewer) {
- viewer = (TreeViewer) pViewer;
- }
- if (pNewInput instanceof FileEntry) {
- rootEntry = (FileEntry) pNewInput;
- }
- }
-
- @Override
- public Object[] getChildren(Object arg0) {
- if (arg0 instanceof FileEntry) {
+ @Override
+ public Object[] getChildren(Object arg0)
+ {
+ if (arg0 instanceof FileEntry)
+ {
FileEntry parentEntry = (FileEntry) arg0;
+ Object[] newEntries = parentEntry.getFileListingService().getChildren(parentEntry, false, null);
- Object[] oldEntries = parentEntry.getCachedChildren();
- Object[] newEntries = parentEntry.getFileListingService().getChildren(parentEntry,
- true, listingReceiver);
-
- if (newEntries != null) {
+ if (newEntries != null)
+ {
return newEntries;
- } else {
- return oldEntries;
}
}
return new Object[0];
- }
+ }
- @Override
- public Object[] getElements(Object arg0) {
- IDevice[] devices = SmartDevelopmentBridge.getBridge().getDevices();
- FileEntry[] entries = new FileEntry[ devices.length ];
- for (int i = 0; i < devices.length; i++) {
- entries[i] = devices[i].getFileListingService().getRoot();
+ @Override
+ public Object[] getElements(Object arg0)
+ {
+ IDevice[] devices = SmartDevelopmentBridge.getBridge().getDevices();
+ FileEntry[] entries = new FileEntry[devices.length];
+ for (int i = 0; i < devices.length; i++)
+ {
+ entries[i] = devices[i].getFileListingService().getRoot();
}
return entries;
- }
+ }
- @Override
- public Object getParent(Object arg0) {
- if (arg0 instanceof FileEntry) {
+ @Override
+ public Object getParent(Object arg0)
+ {
+ if (arg0 instanceof FileEntry)
+ {
FileEntry entry = (FileEntry) arg0;
return entry.getParent();
}
return null;
- }
+ }
- @Override
- public boolean hasChildren(Object arg0) {
- if (arg0 instanceof FileEntry) {
- FileEntry entry = (FileEntry) arg0;
- if (entry.getType() == FileListingService.TYPE_DIRECTORY_LINK)
- return true;
- else if (entry.getType() == FileListingService.TYPE_LINK)
- return true;
- else if (entry.getType() == FileListingService.TYPE_DIRECTORY)
- return true;
- else if (entry.getType() == FileListingService.TYPE_ROOT_EMULATOR)
- return true;
- else if (entry.getType() == FileListingService.TYPE_ROOT_DEVICE)
- return true;
- }
- return false;
- }
-}
+ @Override
+ public boolean hasChildren(Object arg0)
+ {
+ if (arg0 instanceof FileEntry)
+ {
+ FileEntry entry = (FileEntry) arg0;
+ if (entry.getType() == FileListingService.TYPE_DIRECTORY_LINK)
+ return true;
+ else if (entry.getType() == FileListingService.TYPE_LINK)
+ return true;
+ else if (entry.getType() == FileListingService.TYPE_DIRECTORY)
+ return true;
+ else if (entry.getType() == FileListingService.TYPE_ROOT_EMULATOR)
+ return true;
+ else if (entry.getType() == FileListingService.TYPE_ROOT_DEVICE)
+ return true;
+ }
+ return false;
+ }
+} \ No newline at end of file
diff --git a/org.tizen.common.connection/src/org/tizen/common/connection/explorer/ConnectionExplorerLabelProvider.java b/org.tizen.common.connection/src/org/tizen/common/connection/explorer/ConnectionExplorerLabelProvider.java
index 3b8c5ca14..c9a59c4d9 100644..100755
--- a/org.tizen.common.connection/src/org/tizen/common/connection/explorer/ConnectionExplorerLabelProvider.java
+++ b/org.tizen.common.connection/src/org/tizen/common/connection/explorer/ConnectionExplorerLabelProvider.java
@@ -1,124 +1,161 @@
/*
-* Common
-*
-* Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved.
-*
-* Contact:
-* Hoon Kang <h245.kang@samsung.com>
-* Hyunsik Noh <hyunsik.noh@samsung.com>
-*
+ * Common
+ *
+ * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved.
+ *
+ * Contact:
+ * Hoon Kang <h245.kang@samsung.com>
+ * Hyunsik Noh <hyunsik.noh@samsung.com>
+ *
* Licensed under the Apache License, Version 2.0 (the "License");
-* you may not use this file except in compliance with the License.
-* You may obtain a copy of the License at
-*
-* http://www.apache.org/licenses/LICENSE-2.0
-*
-* Unless required by applicable law or agreed to in writing, software
-* distributed under the License is distributed on an "AS IS" BASIS,
-* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-* See the License for the specific language governing permissions and
-* limitations under the License.
-*
-* Contributors:
-* - S-Core Co., Ltd
-*
-*/
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ * Contributors:
+ * - S-Core Co., Ltd
+ *
+ */
package org.tizen.common.connection.explorer;
import org.eclipse.jface.viewers.ILabelProviderListener;
import org.eclipse.jface.viewers.ITableLabelProvider;
import org.eclipse.swt.graphics.Image;
import org.eclipse.swt.widgets.Display;
-import org.tizen.common.connection.ddmuilib.ImageLoader;
-
+import org.tizen.common.connection.ConnectionPlugin;
+import org.tizen.common.util.SWTUtil;
import org.tizen.sdblib.FileListingService;
import org.tizen.sdblib.FileListingService.FileEntry;
import org.tizen.sdblib.IDevice;
-public class ConnectionExplorerLabelProvider implements ITableLabelProvider {
+public class ConnectionExplorerLabelProvider implements ITableLabelProvider
+{
+
+ private final Image fileImage;
+ private final Image folderImage;
+ private final Image fileLinkImage;
+ private final Image folderLinkImage;
+ private final Image otherImage;
+ private final Image emulatorImage;
+ private final Image deviceImage;
+ public static int index;
+
+ public ConnectionExplorerLabelProvider(Display display)
+ {
+
+ fileImage = ConnectionPlugin.getImageDescriptorFromPlugin("icons/file.gif").createImage();
+ folderImage = ConnectionPlugin.getImageDescriptorFromPlugin("icons/directory.gif")
+ .createImage();
+ fileLinkImage = ConnectionPlugin.getImageDescriptorFromPlugin("icons/file_link.gif")
+ .createImage();
+ folderLinkImage = ConnectionPlugin.getImageDescriptorFromPlugin("icons/directory_link.gif")
+ .createImage();
+ otherImage = ConnectionPlugin.getImageDescriptorFromPlugin("icons/file.gif").createImage();
+ emulatorImage = ConnectionPlugin.getImageDescriptorFromPlugin("icons/emulator.gif")
+ .createImage();
+ deviceImage = ConnectionPlugin.getImageDescriptorFromPlugin("icons/device.gif")
+ .createImage();
+ }
- private Image fileImage;
- private Image folderImage;
- private Image fileLinkImage;
- private Image folderLinkImage;
- private Image otherImage;
- private Image emulatorImage;
- private Image deviceImage;
- public static int index;
-
- public ConnectionExplorerLabelProvider(Display display) {
- ImageLoader loader = ImageLoader.getDdmUiLibLoader();
-
- fileImage = loader.loadImage("file.gif", display);
- folderImage = loader.loadImage("directory.gif", display);
- fileLinkImage = loader.loadImage("file_link.gif", display);
- folderLinkImage = loader.loadImage("directory_link.gif", display);
- otherImage = loader.loadImage("file.gif", display);
- emulatorImage = loader.loadImage("emulator.gif", display);
- deviceImage = loader.loadImage("device.gif", display);
- }
+ @Override
+ public Image getColumnImage(Object element, int columnIndex)
+ {
+ if (columnIndex == 0)
+ {
+ if (element instanceof FileEntry)
+ {
+ FileEntry entry = (FileEntry) element;
+ switch (entry.getType())
+ {
+ case FileListingService.TYPE_FILE:
+ return fileImage;
+ case FileListingService.TYPE_LINK:
+ return fileLinkImage;
+ case FileListingService.TYPE_DIRECTORY:
+ return folderImage;
+ case FileListingService.TYPE_DIRECTORY_LINK:
+ return folderLinkImage;
+ case FileListingService.TYPE_ROOT_EMULATOR:
+ return emulatorImage;
+ case FileListingService.TYPE_ROOT_DEVICE:
+ return deviceImage;
+ default:
+ return otherImage;
+ }
+ }
+ }
+ return null;
+ }
- @Override
- public Image getColumnImage(Object element, int columnIndex) {
- if (columnIndex == 0) {
- if (element instanceof FileEntry) {
- FileEntry entry = (FileEntry) element;
- switch (entry.getType()) {
- case FileListingService.TYPE_FILE:
- return fileImage;
- case FileListingService.TYPE_LINK:
- return fileLinkImage;
- case FileListingService.TYPE_DIRECTORY:
- return folderImage;
- case FileListingService.TYPE_DIRECTORY_LINK:
- return folderLinkImage;
- case FileListingService.TYPE_ROOT_EMULATOR:
- return emulatorImage;
- case FileListingService.TYPE_ROOT_DEVICE:
- return deviceImage;
- default:
- return null;
- }
- }
+ @Override
+ public String getColumnText(Object element, int columnIndex)
+ {
+ if (element instanceof FileEntry)
+ {
+ FileEntry entry = (FileEntry) element;
- return otherImage;
- }
- return null;
- }
+ switch (columnIndex)
+ {
+ case 0:
+ if (entry.isRoot())
+ {
+ return getDeviceSerialWithName(entry);
+ } else
+ {
+ return entry.getName();
+ }
+ default:
+ return null;
+ }
+ } else if (element instanceof IDevice)
+ {
+ IDevice device = (IDevice) element;
+ return device.getDeviceName();
+ }
+ return null;
+ }
- @Override
- public String getColumnText(Object element, int columnIndex) {
- if (element instanceof FileEntry) {
- FileEntry entry = (FileEntry) element;
+ @Override
+ public void addListener(ILabelProviderListener listener)
+ {}
- switch (columnIndex) {
- case 0:
- return entry.getName();
- default:
- return null;
- }
- } else if (element instanceof IDevice) {
- IDevice device = (IDevice) element;
- return device.getSerialNumber();
- }
- return null;
- }
+ @Override
+ public void dispose()
+ {
+ SWTUtil.tryDispose(fileImage, folderImage, fileLinkImage, folderLinkImage, otherImage,
+ emulatorImage, deviceImage);
+ }
- @Override
- public void addListener(ILabelProviderListener listener) {
- }
+ @Override
+ public boolean isLabelProperty(Object element, String property)
+ {
+ return false;
+ }
- @Override
- public void dispose() {
- }
+ @Override
+ public void removeListener(ILabelProviderListener listener)
+ {}
- @Override
- public boolean isLabelProperty(Object element, String property) {
- return false;
- }
+ public static String getDeviceSerialWithName(IDevice device)
+ {
+ return combineSerialWithName(device.getSerialNumber(), device.getDeviceName());
+ }
- @Override
- public void removeListener(ILabelProviderListener listener) {
- }
+ public static String getDeviceSerialWithName(FileEntry entry)
+ {
+ return combineSerialWithName(entry.getFileListingService().getDevice().getSerialNumber(), entry.getName());
+ }
+
+ private static String combineSerialWithName(String serial, String name)
+ {
+ return String.format("%s (%s)", serial, name);
+ }
-}
+} \ No newline at end of file
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 3f72e4746..2478c1dc4 100644..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
@@ -1,35 +1,35 @@
/*
-* Common
-*
-* Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved.
-*
-* Contact:
-* Hoon Kang <h245.kang@samsung.com>
-* Hyunsik Noh <hyunsik.noh@samsung.com>
-*
+ * Common
+ *
+ * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved.
+ *
+ * Contact:
+ * Hoon Kang <h245.kang@samsung.com>
+ * Hyunsik Noh <hyunsik.noh@samsung.com>
+ *
* Licensed under the Apache License, Version 2.0 (the "License");
-* you may not use this file except in compliance with the License.
-* You may obtain a copy of the License at
-*
-* http://www.apache.org/licenses/LICENSE-2.0
-*
-* Unless required by applicable law or agreed to in writing, software
-* distributed under the License is distributed on an "AS IS" BASIS,
-* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-* See the License for the specific language governing permissions and
-* limitations under the License.
-*
-* Contributors:
-* - S-Core Co., Ltd
-*
-*/
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ * Contributors:
+ * - S-Core Co., Ltd
+ *
+ */
package org.tizen.common.connection.explorer;
import java.io.File;
import java.io.IOException;
import java.lang.reflect.InvocationTargetException;
import java.util.ArrayList;
-import java.util.regex.Pattern;
+import java.util.List;
import org.eclipse.core.runtime.IProgressMonitor;
import org.eclipse.core.runtime.IStatus;
@@ -59,14 +59,19 @@ import org.eclipse.swt.events.SelectionEvent;
import org.eclipse.swt.layout.FillLayout;
import org.eclipse.swt.widgets.Composite;
import org.eclipse.swt.widgets.Control;
+import org.eclipse.swt.widgets.Dialog;
import org.eclipse.swt.widgets.DirectoryDialog;
import org.eclipse.swt.widgets.Display;
import org.eclipse.swt.widgets.FileDialog;
import org.eclipse.swt.widgets.ToolItem;
import org.eclipse.swt.widgets.Tree;
import org.eclipse.swt.widgets.TreeItem;
+import org.eclipse.ui.IWorkbenchPartSite;
+import org.eclipse.ui.console.MessageConsoleStream;
+import org.eclipse.ui.dialogs.PropertyDialogAction;
import org.eclipse.ui.part.PluginTransfer;
import org.eclipse.ui.part.PluginTransferData;
+import org.tizen.common.TizenPlatformConstants;
import org.tizen.common.connection.ConnectionPlugin;
import org.tizen.common.connection.ConnectionPlugin.ISelectionListener;
import org.tizen.common.connection.ddmuilib.DdmUiPreferences;
@@ -74,13 +79,14 @@ import org.tizen.common.connection.ddmuilib.FileDialogUtils;
import org.tizen.common.connection.ddmuilib.Panel;
import org.tizen.common.connection.ddmuilib.SyncProgressMonitor;
import org.tizen.common.connection.ddmuilib.TableHelper;
-import org.tizen.common.connection.ddmuilib.console.DdmConsole;
import org.tizen.common.connection.debugtools.ToolsInstall;
import org.tizen.common.connection.sdblib.dnd.FileEntryTransfer;
-import org.tizen.common.console.AnsicodeAdapter;
-import org.tizen.common.log.Logger;
-
-import org.tizen.sdblib.FileListingService;
+import org.tizen.common.connection.ui.ConnectionUIMessages;
+import org.tizen.common.ui.view.console.AnsicodeAdapter;
+import org.tizen.common.ui.view.console.ConsoleManager;
+import org.tizen.common.util.DialogUtil;
+import org.tizen.common.util.FilenameUtil;
+import org.tizen.common.util.log.Logger;
import org.tizen.sdblib.FileListingService.FileEntry;
import org.tizen.sdblib.IDevice;
import org.tizen.sdblib.MultiLineReceiver;
@@ -91,1028 +97,1132 @@ import org.tizen.sdblib.SyncService;
import org.tizen.sdblib.SyncService.ISyncProgressMonitor;
import org.tizen.sdblib.SyncService.SyncResult;
-public class ConnectionExplorerPanel extends Panel
- implements
- IDeviceChangeListener,
- IDebugBridgeChangeListener,
- ISelectionListener {
-
- private static final String DRAGACTIONID = "org.tizen.common.connection.filedrop";
- private static final String INVALID_FOR_FILENAME = ";";
-
- private static final String COLUMN_NAME = "name"; //$NON-NLS-1S
- private static final String CMD_RESULT_CHECK = "; echo $?";
-
- private Composite parent;
- private TreeViewer treeViewer;
- private Tree tree;
- private ConnectionExplorerContentProvider mContentProvider;
-
- private ToolItem pushToolItem;
- private ToolItem pullToolItem;
- private ToolItem emulStartToolItem;
-
- private MenuManager subMenu;
- private Action actionPush;
- private Action actionPull;
- private Action actionRefresh;
- private Action actionRename;
- private Action actionProperty;
- private Action actionDelete;
-
- private IDevice mCurrentDevice;
-
- private String defaultSave;
- // only use on linux system
- private static final String PATH_SEPARATOR = "/";
-
- private final ArrayList<IDevice> devicesToExpand = new ArrayList<IDevice>();
- private final ArrayList<IDevice> devicesList = new ArrayList<IDevice>();
- private FileEntry currentFileEntry;
-
- public ConnectionExplorerPanel() {
- }
-
-
- @Override
- protected Control createControl(Composite pParent) {
- parent = pParent;
- parent.setLayout(new FillLayout());
-
- tree = new Tree(parent, SWT.MULTI | SWT.FULL_SELECTION);
- tree.setHeaderVisible(true);
-
- IPreferenceStore store = DdmUiPreferences.getStore();
-
- TableHelper.createTreeColumn(tree, "FileEntry", SWT.LEFT,
- "abcdefghijklmnopqrstuvwzabcdefghijk", COLUMN_NAME, store); //$NON-NLS-1$
- tree.setHeaderVisible(true);
-
- treeViewer = new TreeViewer(tree);
- mContentProvider = new ConnectionExplorerContentProvider();
- treeViewer.setContentProvider(mContentProvider);
- treeViewer.setLabelProvider(new ConnectionExplorerLabelProvider(
- parent.getDisplay()));
-
- tree.addSelectionListener(new SelectionAdapter() {
- @Override
- public void widgetSelected(SelectionEvent e) {
- notifyListeners();
- }
- });
-
- // setup drag listener
- treeViewer.addDragSupport(
- DND.DROP_MOVE | DND.DROP_COPY,
- new Transfer[]{PluginTransfer.getInstance(),
- FileEntryTransfer.getInstance()},
- new DragSourceListener() {
-
- @Override
- public void dragStart(DragSourceEvent e) {
-
- TreeItem[] items = tree.getSelection();
-
- for (int i = 0; i < items.length; i++) {
- Object data = items[i].getData();
- if (data instanceof FileEntry) {
- if (((FileEntry) data).isDirectory() == true || ((FileEntry) data).isRoot() == true) {
- e.doit = false;
- return;
- }
- }
- }
- e.doit = true;
- }
- @Override
- public void dragFinished(DragSourceEvent arg0) {
-
- }
-
- @Override
- public void dragSetData(DragSourceEvent e) {
- // get the selection
- TreeItem[] items = tree.getSelection();
- FileEntry[] entries = new FileEntry[items.length];
-
- for (int i = 0; i < items.length; i++) {
- Object data = items[i].getData();
- if (data instanceof FileEntry) {
- entries[i] = ((FileEntry) data);
- }
- }
-
- if (FileEntryTransfer.getInstance().isSupportedType(
- e.dataType)) {
- e.data = entries;
- } else if (PluginTransfer.getInstance()
- .isSupportedType(e.dataType)) {
- byte[] data = FileEntryTransfer.getInstance()
- .toByteArray(entries);
- e.data = new PluginTransferData(DRAGACTIONID, data);
- }
-
- }
- });
-
- // setup drop listener
- treeViewer.addDropSupport(DND.DROP_COPY | DND.DROP_MOVE,
- new Transfer[]{FileTransfer.getInstance()},
- new ViewerDropAdapter(treeViewer) {
- @Override
- public boolean performDrop(Object data) {
- // get the item on which we dropped the item(s)
- FileEntry target = (FileEntry) getCurrentTarget();
-
- // in case we drop at the same level as root
- if (target == null) {
- return false;
- }
-
- // if the target is not a directory, we get the parent
- // directory
- if (target.isDirectory() == false) {
- target = target.getParent();
- }
-
- if (target == null) {
- return false;
- }
-
- // get the list of files to drop
- String[] files = (String[]) data;
-
- // do the drop
- pushFiles(files, target);
-
- // we need to finish with a refresh
- refresh(target);
-
- return true;
- }
-
- @Override
- public boolean validateDrop(Object target, int operation,
- TransferData transferType) {
- if (target == null) {
- return false;
- }
-
- // convert to the real item
- FileEntry targetEntry = (FileEntry) target;
-
- // if the target is not a directory, we get the parent
- // directory
- if (targetEntry.isDirectory() == false) {
- target = targetEntry.getParent();
- }
-
- if (target == null) {
- return false;
- }
-
- return true;
- }
- });
-
- return tree;
- }
-
- public void setToolItems(ToolItem push, ToolItem pull, ToolItem start) {
- pushToolItem = push;
- pullToolItem = pull;
- emulStartToolItem = start;
- }
-
- public void setActions(MenuManager pSubMenu, Action pActionPush, Action pActionPull, Action pActionRefresh,
- Action pActionRename, Action pActionProperty, Action pActionDelete) {
- this.subMenu = pSubMenu;
- this.actionPush = pActionPush;
- this.actionPull = pActionPull;
- this.actionRefresh = pActionRefresh;
- this.actionRename = pActionRename;
- this.actionProperty = pActionProperty;
- this.actionDelete = pActionDelete;
- }
-
- @Override
- protected void postCreation() {
- ConnectionPlugin.getDefault().addSelectionListener(this);
- SmartDevelopmentBridge sdbBridge = SmartDevelopmentBridge.getBridge();
- SmartDevelopmentBridge.addDebugBridgeChangeListener(this);
- SmartDevelopmentBridge.addDeviceChangeListener(this);
-
- IDevice[] devices = null;
- if (sdbBridge != null) {
- devices = sdbBridge.getDevices();
- }
- if (devices != null && devices.length != 0) {
- for (IDevice device : devices) {
- this.deviceConnected(device);
- }
- }
- }
-
- /**
- * Sets the focus to the proper control inside the panel.
- */
- @Override
- public void setFocus() {
- tree.setFocus();
- }
-
- /**
- * Pull the current selection on the local drive. This method displays a
- * dialog box to let the user select where to store the file(s) and
- * folder(s).
- */
- public void pullSelection() {
- // get the selection
- TreeItem[] items = tree.getSelection();
-
- // name of the single file pull, or null if we're pulling a directory
- // or more than one object.
- String filePullName = null;
- FileEntry singleEntry = null;
-
- //Pull the single file
- if (items.length == 1) {
- singleEntry = (FileEntry) items[0].getData();
- if (singleEntry.getType() == FileListingService.TYPE_FILE) {
- filePullName = singleEntry.getName();
- }
- }
-
- // where do we save by default?
- String defaultPath = defaultSave;
- if (defaultPath == null) {
- defaultPath = System.getProperty("user.home"); //$NON-NLS-1$
- }
-
- if (filePullName != null) {
- FileDialog fileDialog = new FileDialog(parent.getShell(), SWT.SAVE);
-
- fileDialog.setText("Pull the Selection");
- fileDialog.setFileName(filePullName);
- fileDialog.setFilterPath(defaultPath);
-
- String fileName = fileDialog.open();
- if (fileName != null) {
- defaultSave = fileDialog.getFilterPath();
-
- pullFile(singleEntry, fileName);
- }
- } else {
- DirectoryDialog directoryDialog = new DirectoryDialog(
- parent.getShell(), SWT.SAVE);
-
- directoryDialog.setText("Pull the Selection");
- directoryDialog.setFilterPath(defaultPath);
-
- String directoryName = directoryDialog.open();
- if (directoryName != null) {
- pullSelection(items, directoryName);
- }
- }
- }
-
- /**
- * Push new file(s) and folder(s) into the current selection. Current
- * selection must be single item. If the current selection is not a
- * directory, the ` directory is used. This method displays a dialog to
- * let the user choose file to push to the device.
- */
- public void pushIntoSelection() {
- // get the name of the object we're going to pull
- TreeItem[] items = tree.getSelection();
-
- if (items.length == 0) {
- return;
- }
-
- FileDialog dlg = new FileDialog(parent.getShell(), SWT.OPEN);
- String fileName;
-
- dlg.setText("Push the Files");
-
- // There should be only one.
- FileEntry entry = (FileEntry) items[0].getData();
-
- String defaultPath = defaultSave;
- if (defaultPath == null) {
- defaultPath = System.getProperty("user.home"); //$NON-NLS-1$
- }
- dlg.setFilterPath(defaultPath);
-
- fileName = dlg.open();
- if (fileName != null) {
- defaultSave = dlg.getFilterPath();
-
- // we need to figure out the remote path based on the current
- // selection type.
- String remotePath;
- FileEntry toRefresh = entry;
- if (entry.isDirectory() || entry.isRoot()) {
- remotePath = entry.getFullPath();
- } else {
- toRefresh = entry.getParent();
- remotePath = toRefresh.getFullPath();
- }
-
- pushFile(fileName, remotePath);
- treeViewer.refresh(toRefresh);
- }
- }
-
- public void addNewFileSelection() {
- InputDialog addNewDialog = new InputDialog(Display.getCurrent()
- .getActiveShell(), "New File Resource", "New File Name: ", "",
- new FileNameValidator());
- if (addNewDialog.open() != Window.OK)
- return;
-
- String fullPath = currentFileEntry.getFullPath();
-
- TreeItem[] items = tree.getSelection();
-
- if (items.length != 1) {
- return;
- }
-
- final FileEntry parentEntry = ((FileEntry) items[0].getData())
- .getParent();
- // create the touch command
- String command = "touch " + fullPath + PATH_SEPARATOR + addNewDialog.getValue() + CMD_RESULT_CHECK; //$NON-NLS-1$
-
- try {
- mCurrentDevice.executeShellCommand(command,
- new MultiLineReceiver() {
-
- @Override
- public void processNewLines(String[] lines) {
- if(!lines[lines.length - 1].contains("0"))
- {
- StringBuilder sb = new StringBuilder();
- for (String line : lines) {
- line = AnsicodeAdapter.getStripAnsiString(line);
- sb.append(line);
-
- }
- Status status = new Status(IStatus.ERROR, "Add File Failed", 0,
- sb.toString() , null);
- ErrorDialog.openError(Display.getCurrent().getActiveShell(), "Add File Failed", "A file failed to be added", status);
-
-
- }
- }
- });
- } catch (IOException e) {
- Logger.error("failed to do add new file", e);
- throw new RuntimeException(e);
- }
- refresh(parentEntry);
- }
-
- public void addNewFolderSelection() {
- InputDialog addNewDialog = new InputDialog(Display.getCurrent()
- .getActiveShell(), "New Folder Resource", "New Folder Name: ",
- "", null);
- if (addNewDialog.open() != Window.OK)
- return;
- String fullPath = currentFileEntry.getFullPath();
-
- TreeItem[] items = tree.getSelection();
-
- if (items.length != 1) {
- return;
- }
-
- final FileEntry parentEntry = ((FileEntry) items[0].getData())
- .getParent();
- // create the mkdir command
- String command = "mkdir " + fullPath + PATH_SEPARATOR + addNewDialog.getValue() + CMD_RESULT_CHECK; //$NON-NLS-1$
- try {
- mCurrentDevice.executeShellCommand(command,
- new MultiLineReceiver() {
-
- @Override
- public void processNewLines(String[] lines) {
- if(!lines[lines.length - 1].contains("0"))
- {
- StringBuilder sb = new StringBuilder();
- for (String line : lines) {
- line = AnsicodeAdapter.getStripAnsiString(line);
- sb.append(line);
-
- }
- Status status = new Status(IStatus.ERROR, "Add Folder Failed", 0,
- sb.toString() , null);
- ErrorDialog.openError(Display.getCurrent().getActiveShell(), "Add Folder Failed", "A folder failed to be added", status);
- }
- }
- });
- } catch (IOException e) {
- Logger.error("failed to do add new folder", e);
- throw new RuntimeException(e);
- }
- refresh(parentEntry);
- }
-
- public void renameSelection() {
- InputDialog renameDialog = new InputDialog(Display.getCurrent()
- .getActiveShell(), "Rename Resource", "New name: ",
- currentFileEntry.getName(), new FileNameValidator());
- if (renameDialog.open() != Window.OK)
- return;
-
- String fullPath = currentFileEntry.getFullPath();
- int lastIndex = fullPath.lastIndexOf(PATH_SEPARATOR);
- String newPath = fullPath.substring(0, lastIndex) + PATH_SEPARATOR + renameDialog.getValue();
-
- TreeItem[] items = tree.getSelection();
-
- if (items.length != 1) {
- return;
- }
-
- final FileEntry parentEntry = ((FileEntry) items[0].getData())
- .getParent();
- // create the mv command
- String command = "mv " + fullPath + " " + newPath + CMD_RESULT_CHECK; //$NON-NLS-1$
-
- try {
- mCurrentDevice.executeShellCommand(command,
- new MultiLineReceiver() {
-
- @Override
- public void processNewLines(String[] lines) {
- if(!lines[lines.length - 1].contains("0"))
- {
- StringBuilder sb = new StringBuilder();
- for (String line : lines) {
- line = AnsicodeAdapter.getStripAnsiString(line);
- sb.append(line);
-
- }
- Status status = new Status(IStatus.ERROR, "Rename failed", 0,
- sb.toString() , null);
- ErrorDialog.openError(Display.getCurrent().getActiveShell(), "Rename failed", "A selection failed to be renamed",status);
- }
- }
- });
- } catch (IOException e) {
- Logger.error("failed to do rename", e);
- throw new RuntimeException(e);
- }
- refresh(parentEntry);
- }
-
- public void deleteSelection() {
- int ret = FileDialogUtils.getInstance().confirmDelete(
- currentFileEntry.getName());
- if (ret == IDialogConstants.CANCEL_ID)
- return;
-
- TreeItem[] items = tree.getSelection();
-
- for (TreeItem item : items) {
- final FileEntry entry = (FileEntry) item.getData();
- String command = null;
- // create the delete command
- if (entry.isDirectory()) {
- command = "rm -rf " + entry.getFullEscapedPath() + CMD_RESULT_CHECK; //$NON-NLS-1$
- } else {
- command = "rm " + entry.getFullEscapedPath() + CMD_RESULT_CHECK; //$NON-NLS-1$
- }
-
- try {
- mCurrentDevice.executeShellCommand(command,
- new MultiLineReceiver() {
-
- @Override
- public void processNewLines(String[] lines) {
- if(!lines[lines.length - 1].contains("0"))
- {
- StringBuilder sb = new StringBuilder();
- for (String line : lines) {
- line = AnsicodeAdapter.getStripAnsiString(line);
- sb.append(line);
- }
- Status status = new Status(IStatus.ERROR, "Delete Failed", 0,
- sb.toString() , null);
- ErrorDialog.openError(Display.getCurrent().getActiveShell(), "Delete failed", "A selection failed to be deleted", status);
- }
- }
- });
- } catch (IOException e) {
- Logger.error("failed to do delete", e);
- throw new RuntimeException(e);
-
- }
- refresh(entry.getParent());
- }
-
- }
-
- /**
- * Force a full refresh of the explorer.
- */
- public void refresh() {
- treeViewer.refresh(true);
- }
-
- /**
- * Sent when a new {@link SmartDevelopmentBridge} is started.
- * <p/>
- * This is sent from a non UI thread.
- *
- * @param bridge
- * the new {@link SmartDevelopmentBridge} object.
- *
- * @see IDebugBridgeChangeListener#serverChanged(SmartDevelopmentBridge)
- */
- public void bridgeChanged(final SmartDevelopmentBridge bridge) {
- if (tree.isDisposed() == false) {
- exec(new Runnable() {
- public void run() {
- if (tree.isDisposed() == false) {
- // set up the data source.
- treeViewer.setInput(bridge);
-
- } else {
- // tree is disposed, we need to do something.
- // lets remove ourselves from the listener.
- SmartDevelopmentBridge
- .removeDebugBridgeChangeListener(ConnectionExplorerPanel.this);
- SmartDevelopmentBridge
- .removeDeviceChangeListener(ConnectionExplorerPanel.this);
- }
- }
- });
- }
-
- // all current devices are obsolete
- synchronized (devicesToExpand) {
- devicesToExpand.clear();
- }
- }
-
- /**
- * Refresh an entry from a non ui thread.
- *
- * @param entry
- * the entry to refresh.
- */
- private void refresh(final FileEntry entry) {
- Display d = treeViewer.getTree().getDisplay();
- d.asyncExec(new Runnable() {
- public void run() {
- treeViewer.refresh(entry);
- }
- });
- }
- public void refreshSelection() {
- if (currentFileEntry == null)
- return;
- Display d = treeViewer.getTree().getDisplay();
- d.asyncExec(new Runnable() {
- public void run() {
- treeViewer.refresh(currentFileEntry);
- }
- });
- }
-
- /**
- * Pulls the selection from a device.
- *
- * @param items
- * the tree selection the remote file on the device
- * @param localDirector
- * the local directory in which to save the files.
- */
- private void pullSelection(TreeItem[] items, final String localDirectory) {
- try {
- final SyncService sync = mCurrentDevice.getSyncService();
- if (sync != null) {
- // make a list of the FileEntry.
- ArrayList<FileEntry> entries = new ArrayList<FileEntry>();
- for (TreeItem item : items) {
- Object data = item.getData();
- if (data instanceof FileEntry) {
- entries.add((FileEntry) data);
- }
- }
- final FileEntry[] entryArray = entries
- .toArray(new FileEntry[entries.size()]);
-
- // get a progress dialog
- new ProgressMonitorDialog(parent.getShell()).run(true, true,
- new IRunnableWithProgress() {
- public void run(IProgressMonitor monitor)
- throws InvocationTargetException,
- InterruptedException {
- // create a monitor wrapper around the jface
- // monitor
- SyncResult result = sync
- .pull(entryArray,
- localDirectory,
- (ISyncProgressMonitor) new SyncProgressMonitor(
- monitor,
- "Pulling file(s) from the device"));
-
- if (result.getCode() != SyncService.RESULT_OK) {
- DdmConsole.printErrorToConsole(String
- .format("Failed to pull selection: %1$s",
- result.getMessage()));
- }
- sync.close();
- }
- });
- }
- } catch (Exception e) {
- DdmConsole.printErrorToConsole("Failed to pull selection");
- DdmConsole.printErrorToConsole(e.getMessage());
- }
- }
-
- /**
- * Pulls a file from a device.
- *
- * @param remote
- * the remote file on the device
- * @param local
- * the destination filepath
- */
- private void pullFile(final FileEntry remote, final String local) {
- try {
- final SyncService sync = mCurrentDevice.getSyncService();
- if (sync != null) {
- new ProgressMonitorDialog(parent.getShell()).run(true, true,
- new IRunnableWithProgress() {
- public void run(IProgressMonitor monitor)
- throws InvocationTargetException,
- InterruptedException {
- SyncResult result = sync
- .pullFile(
- remote,
- local,
- (ISyncProgressMonitor) new SyncProgressMonitor(
- monitor,
- String.format(
- "Pulling %1$s from the device",
- remote.getName())));
- if (result.getCode() != SyncService.RESULT_OK) {
- DdmConsole.printErrorToConsole(String
- .format("Failed to pull %1$s: %2$s",
- remote, result.getMessage()));
- }
-
- sync.close();
- }
- });
- }
- } catch (Exception e) {
- DdmConsole.printErrorToConsole("Failed to pull selection");
- DdmConsole.printErrorToConsole(e.getMessage());
- }
- }
-
- /**
- * Pushes several files and directory into a remote directory.
- *
- * @param localFiles
- * @param remoteDirectory
- */
- private void pushFiles(final String[] localFiles,
- final FileEntry remoteDirectory) {
- try {
- final SyncService sync = mCurrentDevice.getSyncService();
- if (sync != null) {
- new ProgressMonitorDialog(parent.getShell()).run(true, true,
- new IRunnableWithProgress() {
- public void run(IProgressMonitor monitor)
- throws InvocationTargetException,
- InterruptedException {
- SyncResult result = sync
- .push(localFiles,
- remoteDirectory,
- (ISyncProgressMonitor) new SyncProgressMonitor(
- monitor,
- "Pushing file(s) to the device"));
- if (result.getCode() != SyncService.RESULT_OK) {
- DdmConsole.printErrorToConsole(String
- .format("Failed to push the items: %1$s",
- result.getMessage()));
- }
-
- sync.close();
- }
- });
- }
- } catch (Exception e) {
- DdmConsole.printErrorToConsole("Failed to push the items");
- DdmConsole.printErrorToConsole(e.getMessage());
- }
- }
-
- /**
- * Pushes a file on a device.
- *
- * @param local
- * the local file path of the file to push
- * @param remoteDirectory
- * the remote destination directory on the device
- */
- private void pushFile(final String local, final String remoteDirectory) {
- try {
- final SyncService sync = mCurrentDevice.getSyncService();
- if (sync != null) {
- new ProgressMonitorDialog(parent.getShell()).run(true, true,
- new IRunnableWithProgress() {
- public void run(IProgressMonitor monitor)
- throws InvocationTargetException,
- InterruptedException {
- // get the file name
- String[] segs = local.split(Pattern
- .quote(File.separator));
- String name = segs[segs.length - 1];
- String remoteFile = remoteDirectory + FileListingService.FILE_SEPARATOR + name;
-
- SyncResult result = sync
- .pushFile(
- local,
- remoteFile,
- (ISyncProgressMonitor) new SyncProgressMonitor(
- monitor,
- String.format(
- "Pushing %1$s to the device.",
- name)));
- if (result.getCode() != SyncService.RESULT_OK) {
- DdmConsole.printErrorToConsole(String
- .format("Failed to push %1$s on %2$s: %3$s",
- name, mCurrentDevice
- .getSerialNumber(),
- result.getMessage()));
- }
-
- sync.close();
- }
- });
- }
- } catch (Exception e) {
- DdmConsole.printErrorToConsole("Failed to push the item(s).");
- DdmConsole.printErrorToConsole(e.getMessage());
- }
- }
-
- /**
- * Sent when the a device is connected to the {@link SmartDevelopmentBridge}
- * .
- * <p/>
- * This is sent from a non UI thread.
- *
- * @param device
- * the new device.
- *
- * @see IDeviceChangeListener#deviceConnected(IDevice)
- */
- public void deviceConnected(IDevice device) {
- if (device.isOffline())
- return;
- devicesList.add(device);
- ToolsInstall.installPackages(device);
-
- exec(new Runnable() {
- public void run() {
- if (tree.isDisposed() == false) {
- // refresh all
- treeViewer.refresh();
-
- // notify the listener of a possible selection change.
- notifyListeners();
- } else {
- // tree is disposed, we need to do something.
- // lets remove ourselves from the listener.
- SmartDevelopmentBridge
- .removeDebugBridgeChangeListener(ConnectionExplorerPanel.this);
- SmartDevelopmentBridge
- .removeDeviceChangeListener(ConnectionExplorerPanel.this);
- }
- }
- });
-
- synchronized (devicesToExpand) {
- devicesToExpand.add(device);
- }
-
- }
-
- @Override
- public void deviceDisconnected(IDevice device) {
- devicesList.remove(device);
- exec(new Runnable() {
- public void run() {
- if (tree.isDisposed() == false) {
- // refresh all
- treeViewer.refresh();
-
- // notify the listener of a possible selection change.
- notifyListeners();
- } else {
- // tree is disposed, we need to do something.
- // lets remove ourselves from the listener.
- SmartDevelopmentBridge
- .removeDebugBridgeChangeListener(ConnectionExplorerPanel.this);
- SmartDevelopmentBridge
- .removeDeviceChangeListener(ConnectionExplorerPanel.this);
- }
- }
- });
-
- synchronized (devicesToExpand) {
- devicesToExpand.add(device);
- }
- // }
- }
-
- @Override
- public void deviceChanged(IDevice device, int changeMask) {
- if (changeMask == 1) {
- devicesList.add(device);
- ToolsInstall.installPackages(device);
- exec(new Runnable() {
- public void run() {
- if (tree.isDisposed() == false) {
- // refresh all
- treeViewer.refresh();
-
- // notify the listener of a possible selection change.
- notifyListeners();
- } else {
- // tree is disposed, we need to do something.
- // lets remove ourselves from the listener.
- SmartDevelopmentBridge
- .removeDebugBridgeChangeListener(ConnectionExplorerPanel.this);
- SmartDevelopmentBridge
- .removeDeviceChangeListener(ConnectionExplorerPanel.this);
- }
- }
- });
-
- synchronized (devicesToExpand) {
- devicesToExpand.add(device);
- }
- }
- }
-
- public ArrayList<IDevice> getDeviceList() {
- return devicesList;
- }
-
- private void exec(Runnable runnable) {
- if (tree.isDisposed() == false) {
- try {
- Display display = tree.getDisplay();
- display.asyncExec(runnable);
- } catch (SWTException e) {
- // tree is disposed, we need to do something. lets remove ourselves
- // from the listener.
- SmartDevelopmentBridge
- .removeDebugBridgeChangeListener(ConnectionExplorerPanel.this);
- SmartDevelopmentBridge
- .removeDeviceChangeListener(ConnectionExplorerPanel.this);
- }
- }
- }
-
- private void notifyListeners() {
- // get the selection
- TreeItem[] items = tree.getSelection();
-
- FileEntry file = null;
-
- if (items.length != 0) {
- Object object = items[0].getData();
- if (object instanceof FileEntry) {
- file = (FileEntry) object;
- }
- }
- notifySelectionListeners(file);
- }
-
- private void notifySelectionListeners(FileEntry file) {
- if (file != null) {
- mCurrentDevice = file.getFileListingService().getDevice();
- } else {
- IDevice[] devices = SmartDevelopmentBridge.getBridge().getDevices();
- if (devices.length != 0) {
- mCurrentDevice = devices[0];
- file = devices[0].getFileListingService().getRoot();
- for (TreeItem item : tree.getItems()) {
- if (item.getText().equals(file.getName()))
- tree.setSelection(item);
- }
- } else
- mCurrentDevice = null;
- }
- currentFileEntry = file;
- ConnectionPlugin.getDefault().setCurrentDevice(mCurrentDevice);
- ConnectionPlugin.getDefault().notifySelectionListeners(file);
- setIconEnabled();
- }
-
- public TreeViewer getTreeViewer() {
- return treeViewer;
- }
-
- class FileNameValidator implements IInputValidator {
-
- @Override
- public String isValid(String newText) {
- if (newText.contains(INVALID_FOR_FILENAME))
- return "\"" + INVALID_FOR_FILENAME + "\" is invalid character for file name.";
- return null;
- }
- }
-
- public void setActionState() {
- subMenu.setVisible(true);
- actionPush.setEnabled(true);
- actionPull.setEnabled(true);
- actionRename.setEnabled(true);
- actionRefresh.setEnabled(true);
- actionDelete.setEnabled(true);
- actionProperty.setEnabled(true);
-
- if (currentFileEntry == null) {
- subMenu.setVisible(false);
- actionPush.setEnabled(false);
- actionPull.setEnabled(false);
- actionRename.setEnabled(false);
- actionRefresh.setEnabled(false);
- actionDelete.setEnabled(false);
- actionProperty.setEnabled(false);
- return;
- }
- if (currentFileEntry.isRoot()) {
- actionPull.setEnabled(false);
- actionRename.setEnabled(false);
- actionDelete.setEnabled(false);
- return;
- }
- if (!currentFileEntry.isDirectory()) {
- subMenu.setVisible(false);
- actionPush.setEnabled(false);
- return;
- }
- }
-
- private void setIconEnabled() {
- boolean bPush = false;
- boolean bPull = false;
-
- if (currentFileEntry == null) {
- bPush = false;
- bPull = false;
- } else {
- if (currentFileEntry.isRoot()) {
- bPush = true;
- bPull = false;
- } else if (!currentFileEntry.isDirectory()) {
- bPush = false;
- bPull = true;
- } else {
- bPush = true;
- bPull = true;
- }
- }
-
- pushToolItem.setEnabled(bPush);
- pullToolItem.setEnabled(bPull);
-
- }
-
- @Override
- public void selectionChanged(final FileEntry selectedEntry) {
- if (selectedEntry == null)
- return;
-
- if (!selectedEntry.isRoot())
- return;
-
- exec(new Runnable() {
- public void run() {
- if (tree.isDisposed() == false) {
- for (TreeItem item : tree.getItems()) {
- if (item.getText().equals(selectedEntry.getName()))
- tree.setSelection(item);
- }
- } else {
- // tree is disposed, we need to do something.
- // lets remove ourselves from the listener.
- ConnectionPlugin.getDefault().removeSelectionListener(ConnectionExplorerPanel.this);
- }
- }
- });
- }
+public class ConnectionExplorerPanel extends Panel implements IDeviceChangeListener, IDebugBridgeChangeListener, ISelectionListener
+{
+
+ private static final String DRAGACTIONID = "org.tizen.common.connection.filedrop";
+
+ private static final String COLUMN_NAME = "name"; //$NON-NLS-1S
+
+ private Composite parent;
+ private TreeViewer treeViewer;
+ private ConnectionExplorerContentProvider contentProvider;
+
+ private final int STATE_PROPERTY = 0x0000001;
+ private final int STATE_DELETE = 0x0000010;
+ private final int STATE_RENAME = 0x0000100;
+ private final int STATE_REFRESH = 0x0001000;
+ private final int STATE_PULL = 0x0010000;
+ private final int STATE_PUSH = 0x0100000;
+ private final int STATE_SUB = 0x1000000;
+
+ private ToolItem pushToolItem;
+ private ToolItem pullToolItem;
+ private ToolItem emulStartToolItem;
+
+ private MenuManager subMenu;
+ private Action actionPush;
+ private Action actionPull;
+ private Action actionRefresh;
+ private Action actionRename;
+ private Action actionProperty;
+ private Action actionDelete;
+
+ private IDevice currentDevice;
+
+ private String defaultSave;
+ // only use on linux system
+ private static final String PATH_SEPARATOR = "/";
+
+ private final List<IDevice> devicesList = new ArrayList<IDevice>();
+
+ private final MessageConsoleStream console;
+
+ public ConnectionExplorerPanel()
+ {
+ ConsoleManager cm = new ConsoleManager("ConnectionExplorer", false);
+ cm.clear();
+ console = cm.getMessageConsoleStream();
+ }
+
+ @Override
+ protected Control createControl(Composite pParent)
+ {
+ parent = pParent;
+ parent.setLayout(new FillLayout());
+
+ treeViewer = new TreeViewer(parent, SWT.MULTI | SWT.FULL_SELECTION);
+ Tree tree = treeViewer.getTree();
+ IPreferenceStore store = DdmUiPreferences.getStore();
+
+ TableHelper.createTreeColumn(tree, Messages.getString("ConnectionExplorer.tree.header"), SWT.LEFT, "abcdefghijklmnopqrstuvwzabcdefghijk", COLUMN_NAME, store); //$NON-NLS-1$
+ tree.setHeaderVisible(true);
+
+ contentProvider = new ConnectionExplorerContentProvider();
+ treeViewer.setContentProvider(contentProvider);
+ treeViewer.setLabelProvider(new ConnectionExplorerLabelProvider(parent.getDisplay()));
+
+ tree.addSelectionListener(new SelectionAdapter()
+ {
+ @Override
+ public void widgetSelected(SelectionEvent e)
+ {
+ // set device for selected FileEntry when select FileEntry on
+ // tree
+ notifyListeners();
+ }
+ });
+
+ // setup drag listener
+ treeViewer.addDragSupport(DND.DROP_MOVE | DND.DROP_COPY, new Transfer[] { PluginTransfer.getInstance(), FileEntryTransfer.getInstance() },
+ new DragSourceListener()
+ {
+
+ @Override
+ public void dragStart(DragSourceEvent e)
+ {
+
+ TreeItem[] items = treeViewer.getTree().getSelection();
+
+ for (int i = 0; i < items.length; i++)
+ {
+ Object data = items[i].getData();
+ if (data instanceof FileEntry)
+ {
+ if (((FileEntry) data).isDirectory() == true || ((FileEntry) data).isRoot() == true)
+ {
+ e.doit = false;
+ return;
+ }
+ }
+ }
+ e.doit = true;
+ }
+
+ @Override
+ public void dragFinished(DragSourceEvent arg0)
+ {
+
+ }
+
+ @Override
+ public void dragSetData(DragSourceEvent e)
+ {
+ // get the selection
+ TreeItem[] items = treeViewer.getTree().getSelection();
+ FileEntry[] entries = new FileEntry[items.length];
+
+ for (int i = 0; i < items.length; i++)
+ {
+ Object data = items[i].getData();
+ if (data instanceof FileEntry)
+ {
+ entries[i] = ((FileEntry) data);
+ }
+ }
+
+ if (FileEntryTransfer.getInstance().isSupportedType(e.dataType))
+ {
+ e.data = entries;
+ } else if (PluginTransfer.getInstance().isSupportedType(e.dataType))
+ {
+ byte[] data = FileEntryTransfer.getInstance().toByteArray(entries);
+ e.data = new PluginTransferData(DRAGACTIONID, data);
+ }
+ }
+ });
+
+ // setup drop listener
+ treeViewer.addDropSupport(DND.DROP_COPY | DND.DROP_MOVE, new Transfer[] { FileTransfer.getInstance() }, new ViewerDropAdapter(treeViewer)
+ {
+ @Override
+ public boolean performDrop(Object data)
+ {
+ // get the item on which we dropped the item(s)
+ FileEntry target = (FileEntry) getCurrentTarget();
+
+ // in case we drop at the same level as root
+ if (target == null)
+ {
+ return false;
+ }
+
+ // if the target is not a directory, we get the parent directory
+ if (target.isDirectory() == false)
+ {
+ target = target.getParent();
+ }
+
+ if (target == null)
+ {
+ return false;
+ }
+
+ // get the list of files to drop
+ String[] files = (String[]) data;
+
+ // do the drop
+ pushFiles(files, target);
+
+ // we need to finish with a refresh
+ refresh(target);
+
+ return true;
+ }
+
+ @Override
+ public boolean validateDrop(Object target, int operation, TransferData transferType)
+ {
+ if (target == null)
+ {
+ return false;
+ }
+
+ // convert to the real item
+ FileEntry targetEntry = (FileEntry) target;
+
+ // if the target is not a directory, we get the parent directory
+ if (targetEntry.isDirectory() == false)
+ {
+ target = targetEntry.getParent();
+ }
+
+ if (target == null)
+ {
+ return false;
+ }
+
+ return true;
+ }
+ });
+
+ return tree;
+ }
+
+ public void setToolItems(ToolItem push, ToolItem pull, ToolItem start)
+ {
+ pushToolItem = push;
+ pullToolItem = pull;
+ emulStartToolItem = start;
+ }
+
+ public void setActions(MenuManager pSubMenu, Action pActionPush, Action pActionPull, Action pActionRefresh, Action pActionRename, Action pActionProperty,
+ Action pActionDelete)
+ {
+ this.subMenu = pSubMenu;
+ this.actionPush = pActionPush;
+ this.actionPull = pActionPull;
+ this.actionRefresh = pActionRefresh;
+ this.actionRename = pActionRename;
+ this.actionProperty = pActionProperty;
+ this.actionDelete = pActionDelete;
+ setActionEnabled();
+ }
+
+ @Override
+ protected void postCreation()
+ {
+ ConnectionPlugin.getDefault().addSelectionListener(this);
+ SmartDevelopmentBridge sdbBridge = SmartDevelopmentBridge.getBridge();
+ SmartDevelopmentBridge.addDebugBridgeChangeListener(this);
+ SmartDevelopmentBridge.addDeviceChangeListener(this);
+
+ IDevice[] devices = null;
+ if (sdbBridge != null)
+ {
+ devices = sdbBridge.getDevices();
+ }
+ if (devices != null && devices.length != 0)
+ {
+ for (IDevice device : devices)
+ {
+ this.deviceConnected(device);
+ }
+ }
+ }
+
+ /**
+ * Sets the focus to the proper control inside the panel.
+ */
+ @Override
+ public void setFocus()
+ {
+ treeViewer.getTree().setFocus();
+ }
+
+ /**
+ * Pull the current selection on the local drive. This method displays a
+ * dialog box to let the user select where to store the file(s) and
+ * folder(s).
+ */
+ public void pullSelection()
+ {
+ DirectoryDialog dlg = new DirectoryDialog(parent.getShell(), SWT.SAVE);
+
+ setDialog(dlg, "Pull the selected content");
+
+ String directoryName = dlg.open();
+
+ if (directoryName != null)
+ {
+ pullSelection(treeViewer.getTree().getSelection(), directoryName);
+ }
+ }
+
+ /**
+ * Push new file(s) and folder(s) into the current selection. Current
+ * selection must be single item. If the current selection is not a
+ * directory, the ` directory is used. This method displays a dialog to let
+ * the user choose file to push to the device.
+ */
+ public void pushIntoSelection()
+ {
+ doActionForEntry(new IActionForEntry()
+ {
+ @Override
+ public void doAction()
+ {
+ FileEntry entry = getSingleFileEntry();
+
+ FileDialog dlg = new FileDialog(parent.getShell(), SWT.OPEN);
+
+ setDialog(dlg, "Push the Files");
+
+ String[] fileName = new String[1];
+ fileName[0] = dlg.open();
+
+ if (fileName[0] != null)
+ {
+ // we need to figure out the remote path based on the
+ // current selection type.
+ FileEntry refreshFileEntry;
+
+ if (entry.isDirectory() || entry.isRoot())
+ {
+ refreshFileEntry = entry;
+ } else
+ {
+ refreshFileEntry = entry.getParent();
+ }
+
+ pushFiles(fileName, refreshFileEntry);
+ refresh(refreshFileEntry);
+ }
+ }
+
+ @Override
+ public boolean doCheckEnable()
+ {
+ return isSingleEntry() && actionPush.isEnabled();
+ }
+ });
+ }
+
+ // only for FileDialog and DirectoryDialog
+ private void setDialog(Dialog dialog, String text)
+ {
+ dialog.setText(text);
+
+ String defaultPath = defaultSave;
+ if (defaultPath == null)
+ {
+ defaultPath = System.getProperty("user.home"); //$NON-NLS-1$
+ }
+
+ if (dialog instanceof FileDialog)
+ {
+ FileDialog dlg = (FileDialog) dialog;
+ dlg.setFilterPath(defaultPath);
+ defaultSave = dlg.getFilterPath();
+ } else if (dialog instanceof DirectoryDialog)
+ {
+ DirectoryDialog dlg = (DirectoryDialog) dialog;
+ dlg.setFilterPath(defaultPath);
+ defaultSave = dlg.getFilterPath();
+ }
+ }
+
+ public void addNewFileSelection()
+ {
+ doActionForEntry(new IActionForEntry()
+ {
+ @Override
+ public void doAction()
+ {
+
+ FileEntry entry = getSingleFileEntry();
+
+ String name = getNameFromInputDialog("New File Resource", "New File Name: ", entry, "");
+
+ if (name == null)
+ {
+ return;
+ }
+
+ String fullPath = FilenameUtil.addDoubleQuote(entry.getFullEscapedPath() + "/" + name);
+ String command = String.format("touch %s; echo $?", fullPath);
+ try
+ {
+ currentDevice.executeShellCommand(command, new MultiLineReceiver()
+ {
+
+ @Override
+ public void processNewLines(String[] lines)
+ {
+ sayError(lines, "add_file_error", "A file failed to be added");
+ }
+ });
+ } catch (IOException e)
+ {
+ Logger.error("failed to add new file", e);
+ throw new RuntimeException(e);
+ }
+ refresh(entry);
+ }
+
+ @Override
+ public boolean doCheckEnable()
+ {
+ return isSingleEntry();
+ }
+ });
+ }
+
+ public void addNewFolderSelection()
+ {
+ doActionForEntry(new IActionForEntry()
+ {
+ @Override
+ public void doAction()
+ {
+
+ FileEntry entry = getSingleFileEntry();
+
+ String name = getNameFromInputDialog("New Folder Resource", "New Folder Name: ", entry, "");
+ if (name == null)
+ {
+ return;
+ }
+
+ // create the mkdir command
+ String fullPath = FilenameUtil.addDoubleQuote(entry.getFullEscapedPath() + "/" + name);
+ String command = String.format("mkdir %s; echo $?", fullPath);
+ try
+ {
+ currentDevice.executeShellCommand(command, new MultiLineReceiver()
+ {
+ @Override
+ public void processNewLines(String[] lines)
+ {
+ sayError(lines, "add_folder_error", "A folder failed to be added");
+ }
+ });
+ } catch (IOException e)
+ {
+ Logger.error("failed to add new folder", e);
+ throw new RuntimeException(e);
+ }
+ refresh(entry);
+ }
+
+ @Override
+ public boolean doCheckEnable()
+ {
+ return isSingleEntry();
+ }
+ });
+ }
+
+ // Get user input for adding new file or folder and rename
+ private String getNameFromInputDialog(String title, String message, FileEntry entry, String initValue)
+ {
+ boolean again;
+ InputDialog inputDialog;
+
+ do
+ {
+ again = false;
+ // open dialog to get input
+ inputDialog = new InputDialog(Display.getCurrent().getActiveShell(), title, message, initValue, new FileNameValidator());
+
+ if (inputDialog.open() != Window.OK)
+ {
+ return null;
+ }
+
+ String input = inputDialog.getValue();
+ // same entry is already exist..
+ if (findDuplicateFileEntry(input, entry))
+ {
+ again = true;
+ }
+
+ } while (again);
+
+ return FilenameUtil.getEscapedName(inputDialog.getValue());
+ }
+
+ public void renameSelection()
+ {
+ doActionForEntry(new IActionForEntry()
+ {
+ @Override
+ public void doAction()
+ {
+
+ FileEntry entry = getSingleFileEntry();
+
+ String name = getNameFromInputDialog("Rename Resource", "New name: ", entry.getParent(), entry.getName());
+
+ if (name == null)
+ {
+ return;
+ }
+
+ String fullPath = entry.getFullEscapedPath();
+ int lastIndex = fullPath.lastIndexOf(PATH_SEPARATOR);
+ String newPath = fullPath.substring(0, lastIndex) + PATH_SEPARATOR + name;
+
+ // create the mv command
+ String command = String.format("mv %s %s; echo $?", FilenameUtil.addDoubleQuote(fullPath), FilenameUtil.addDoubleQuote(newPath));
+ try
+ {
+ currentDevice.executeShellCommand(command, new MultiLineReceiver()
+ {
+
+ @Override
+ public void processNewLines(String[] lines)
+ {
+ sayError(lines, "rename_error", "A selection failed to be renamed");
+ }
+ });
+ } catch (IOException e)
+ {
+ Logger.error("failed to rename", e);
+ throw new RuntimeException(e);
+ }
+ refresh(entry.getParent());
+ }
+
+ @Override
+ public boolean doCheckEnable()
+ {
+ return isSingleEntry() && actionRename.isEnabled();
+ }
+ });
+ }
+
+ public void deleteSelection()
+ {
+ doActionForEntry(new IActionForEntry()
+ {
+ @Override
+ public void doAction()
+ {
+ TreeItem[] items = treeViewer.getTree().getSelection();
+ for (TreeItem item : items)
+ {
+ Object obj = item.getData();
+ if (obj instanceof FileEntry)
+ {
+ FileEntry entry = (FileEntry) obj;
+ int ret = FileDialogUtils.confirmDelete(entry.getName());
+ if (ret == IDialogConstants.CANCEL_ID)
+ continue;
+
+ String command = null;
+ // create the delete command
+ if (entry.isDirectory())
+ {
+ command = String.format("rm -rf %s; echo $?", FilenameUtil.addDoubleQuote(entry.getFullEscapedPath()));
+ } else
+ {
+ command = String.format("rm %s; echo $?", FilenameUtil.addDoubleQuote(entry.getFullEscapedPath()));
+ }
+
+ try
+ {
+ currentDevice.executeShellCommand(command, new MultiLineReceiver()
+ {
+
+ @Override
+ public void processNewLines(String[] lines)
+ {
+ sayError(lines, "delete_error", "A selection failed to be deleted");
+ }
+ });
+ item.dispose();
+ } catch (IOException e)
+ {
+ Logger.error("failed to delete", e);
+ throw new RuntimeException(e);
+
+ }
+ refresh(entry.getParent());
+ setActionEnabled();
+ }
+ }
+ }
+
+ @Override
+ public boolean doCheckEnable()
+ {
+ return actionDelete.isEnabled();
+ }
+ });
+ }
+
+ public void showPropertySelection(final IWorkbenchPartSite site)
+ {
+ doActionForEntry(new IActionForEntry()
+ {
+ @Override
+ public void doAction()
+ {
+ PropertyDialogAction pda = new PropertyDialogAction(site, treeViewer);
+ pda.run();
+ }
+
+ @Override
+ public boolean doCheckEnable()
+ {
+ return actionProperty.isEnabled();
+ }
+ });
+ }
+
+ private void sayError(String[] lines, String id, String message)
+ {
+ if (!lines[lines.length - 1].contains("0"))
+ {
+ StringBuilder sb = new StringBuilder();
+ for (String line : lines)
+ {
+ line = AnsicodeAdapter.getStripAnsiString(line);
+ sb.append(line);
+ }
+ Status status = new Status(IStatus.ERROR, id, 0, sb.toString(), null);
+ ErrorDialog.openError(Display.getCurrent().getActiveShell(), Messages.getString("FileDialogUtils.message.title"), message, status);
+ }
+ }
+
+ /**
+ * Sent when a new {@link SmartDevelopmentBridge} is started.
+ * <p/>
+ * This is sent from a non UI thread.
+ *
+ * @param bridge
+ * the new {@link SmartDevelopmentBridge} object.
+ *
+ * @see IDebugBridgeChangeListener#serverChanged(SmartDevelopmentBridge)
+ */
+ @Override
+ public void bridgeChanged(final SmartDevelopmentBridge bridge)
+ {
+ final Tree tree = treeViewer.getTree();
+ if (tree.isDisposed() == false)
+ {
+ exec(new Runnable()
+ {
+ @Override
+ public void run()
+ {
+ if (tree.isDisposed() == false)
+ {
+ // set up the data source.
+ treeViewer.setInput(bridge);
+ } else
+ {
+ // tree is disposed, we need to do something.
+ // lets remove ourselves from the listener.
+ SmartDevelopmentBridge.removeDebugBridgeChangeListener(ConnectionExplorerPanel.this);
+ SmartDevelopmentBridge.removeDeviceChangeListener(ConnectionExplorerPanel.this);
+ }
+ }
+ });
+ }
+ }
+
+ /**
+ * Refresh an entry from a non ui thread.
+ *
+ * @param entry
+ * the entry to refresh.
+ */
+ private void refresh(final FileEntry entry)
+ {
+ Display d = treeViewer.getTree().getDisplay();
+ d.asyncExec(new Runnable()
+ {
+ @Override
+ public void run()
+ {
+ treeViewer.refresh(entry, true);
+ }
+ });
+ }
+
+ public void refreshSelection()
+ {
+ if (treeViewer.getTree().getSelectionCount() == 0)
+ {
+ return;
+ }
+ refresh(getSingleFileEntry());
+ }
+
+ /**
+ * Pulls the selection from a device.
+ *
+ * @param items
+ * the tree selection the remote file on the device
+ * @param localDirector
+ * the local directory in which to save the files.
+ */
+ private void pullSelection(TreeItem[] items, final String localDirectory)
+ {
+ try
+ {
+ final SyncService sync = currentDevice.getSyncService();
+ if (sync != null)
+ {
+ // make a list of the FileEntry.
+ List<FileEntry> entries = new ArrayList<FileEntry>();
+ for (TreeItem item : items)
+ {
+ Object data = item.getData();
+ if (data instanceof FileEntry)
+ {
+ FileEntry entry = (FileEntry)data;
+ if (!FilenameUtil.isVaildName(entry.getName()))
+ {
+ DialogUtil.openErrorDialog(entry.getName() + "\n" +
+ ConnectionUIMessages.Explorer_Message_Invalid_Character
+ + FilenameUtil.getInvalidCharacters());
+ continue;
+ }
+ entries.add((FileEntry) data);
+ }
+ }
+ final FileEntry[] entryArray = entries.toArray(new FileEntry[entries.size()]);
+
+ // get a progress dialog
+ new ProgressMonitorDialog(parent.getShell()).run(true, true, new IRunnableWithProgress()
+ {
+ @Override
+ public void run(IProgressMonitor monitor) throws InvocationTargetException, InterruptedException
+ {
+ // create a monitor wrapper around the jface monitor
+ SyncResult result = sync.pull(entryArray, localDirectory, (ISyncProgressMonitor) new SyncProgressMonitor(monitor,
+ "Pulling file(s) from the device"));
+
+ if (result.getCode() != SyncService.RESULT_OK)
+ {
+ String message = String.format("Failed to pull selection: %1$s", result.getMessage());
+ console.println(message);
+ DialogUtil.openErrorDialog(message);
+ }
+ sync.close();
+ }
+ });
+ }
+ } catch (Exception e)
+ {
+ String message = "Failed to pull selection";
+ DialogUtil.openErrorDialog(message);
+ console.println(message);
+ console.println(e.getMessage());
+ }
+ }
+
+ /**
+ * Pushes several files and directory into a remote directory.
+ *
+ * @param localFiles
+ * @param remoteDirectory
+ */
+ private void pushFiles(final String[] localFiles, final FileEntry remoteDirectory)
+ {
+ final String[] files = getFilesToOverwrite(localFiles, remoteDirectory);
+ if (files == null || files.length == 0)
+ return;
+ try
+ {
+ final SyncService sync = currentDevice.getSyncService();
+ if (sync != null)
+ {
+ new ProgressMonitorDialog(parent.getShell()).run(true, true, new IRunnableWithProgress()
+ {
+ @Override
+ public void run(IProgressMonitor monitor) throws InvocationTargetException, InterruptedException
+ {
+ SyncResult result = sync.push(files, remoteDirectory, (ISyncProgressMonitor) new SyncProgressMonitor(monitor,
+ "Pushing file(s) to the device"));
+ if (result.getCode() != SyncService.RESULT_OK)
+ {
+ String message = String.format("Failed to push the items: %1$s", result.getMessage());
+ console.println(message);
+ DialogUtil.openErrorDialog(message);
+ }
+ sync.close();
+ }
+ });
+ }
+ } catch (Exception e)
+ {
+ String message = "Failed to push the items";
+ DialogUtil.openErrorDialog(message);
+ console.println(message);
+ console.println(e.getMessage());
+ }
+ }
+
+ private String[] getFilesToOverwrite(String[] src, FileEntry des)
+ {
+ FileEntry[] children = des.getFileListingService().getChildren(des, false, null);
+
+ List<String> listToOverwrite = new ArrayList<String>();
+ boolean yesAll = false;
+
+ for (String source : src)
+ {
+ File f = new File(source);
+ boolean bFind = false;
+ for (FileEntry entry : children)
+ {
+ if (entry.getName().equals(f.getName()))
+ {
+ bFind = true;
+ break;
+ }
+ }
+
+ if (bFind)
+ {
+ if (!yesAll)
+ {
+ int ret;
+ if (src.length == 1)
+ {
+ ret = FileDialogUtils.allowFileOverwrite(f.getName());
+ if( ret == IDialogConstants.CANCEL_ID)
+ break;
+ } else
+ {
+ ret = FileDialogUtils.checkOverwrite(f.getName());
+ switch (ret)
+ {
+ case IDialogConstants.CANCEL_ID:
+ return null;
+ case IDialogConstants.NO_ID:
+ continue;
+ case IDialogConstants.YES_TO_ALL_ID:
+ yesAll = true;
+ case IDialogConstants.YES_ID:
+ break;
+ default:
+ break;
+ }
+ }
+ }
+ }
+ listToOverwrite.add(source);
+ }
+ return listToOverwrite.toArray(new String[0]);
+ }
+
+ private boolean findDuplicateFileEntry(String src, FileEntry des)
+ {
+ FileEntry[] children = des.getFileListingService().getChildren(des, false, null);
+
+ for (FileEntry entry : children)
+ {
+ File f = new File(src);
+
+ if (entry.getName().equals(f.getName()))
+ {
+ FileDialogUtils.notifyDuplication((f.getName()));
+ return true;
+ }
+ }
+ return false;
+ }
+
+ /**
+ * Sent when the a device is connected to the {@link SmartDevelopmentBridge}
+ * .
+ * <p/>
+ * This is sent from a non UI thread.
+ *
+ * @param device
+ * the new device.
+ *
+ * @see IDeviceChangeListener#deviceConnected(IDevice)
+ */
+ @Override
+ public void deviceConnected(IDevice device)
+ {
+ if (device.isOffline())
+ {
+ return;
+ }
+ devicesList.add(device);
+ ToolsInstall.installPackages(device);
+ execRefresh();
+ }
+
+ @Override
+ public void deviceDisconnected(IDevice device)
+ {
+ devicesList.remove(device);
+ execRefresh();
+ }
+
+ @Override
+ public void deviceChanged(IDevice device, int changeMask)
+ {
+ if (changeMask == 1)
+ {
+ deviceConnected(device);
+ }
+ }
+
+ private void execRefresh()
+ {
+ exec(new Runnable()
+ {
+ @Override
+ public void run()
+ {
+ if (treeViewer.getTree().isDisposed() == false)
+ {
+ // refresh all
+ treeViewer.refresh();
+
+ // notify the listener of a possible selection change.
+ notifyListeners();
+ } else
+ {
+ // tree is disposed, we need to do something.
+ // lets remove ourselves from the listener.
+ SmartDevelopmentBridge.removeDebugBridgeChangeListener(ConnectionExplorerPanel.this);
+ SmartDevelopmentBridge.removeDeviceChangeListener(ConnectionExplorerPanel.this);
+ }
+ }
+ });
+ }
+
+ public List<IDevice> getDeviceList()
+ {
+ return devicesList;
+ }
+
+ private void exec(Runnable runnable)
+ {
+ Tree tree = treeViewer.getTree();
+
+ if (tree.isDisposed() == false)
+ {
+ try
+ {
+ Display display = tree.getDisplay();
+ display.asyncExec(runnable);
+ } catch (SWTException e)
+ {
+ // tree is disposed, we need to do something. lets remove
+ // ourselves from the listener.
+ SmartDevelopmentBridge.removeDebugBridgeChangeListener(ConnectionExplorerPanel.this);
+ SmartDevelopmentBridge.removeDeviceChangeListener(ConnectionExplorerPanel.this);
+ }
+ }
+ }
+
+ private void notifyListeners()
+ {
+ Tree tree = treeViewer.getTree();
+ FileEntry entry = null;
+ if (tree.getSelectionCount() > 0)
+ entry = getSingleFileEntry();
+
+ if (entry != null)
+ {
+ currentDevice = entry.getFileListingService().getDevice();
+ } else
+ {
+ IDevice[] devices = SmartDevelopmentBridge.getBridge().getDevices();
+ if (devices.length != 0)
+ {
+ currentDevice = devices[0];
+ entry = devices[0].getFileListingService().getRoot();
+ for (TreeItem item : tree.getItems())
+ {
+ if (item.getText().equals(entry.getName()))
+ {
+ tree.setSelection(item);
+ }
+ }
+ } else
+ currentDevice = null;
+ }
+ ConnectionPlugin.getDefault().setCurrentDevice(currentDevice);
+ ConnectionPlugin.getDefault().notifySelectionListeners(entry);
+ setActionEnabled();
+
+ }
+
+ public TreeViewer getTreeViewer()
+ {
+ return treeViewer;
+ }
+
+ class FileNameValidator implements IInputValidator
+ {
+ @Override
+ public String isValid(String fileName)
+ {
+ int os = TizenPlatformConstants.OS;
+ int validCheck = FilenameUtil.isVaildName(fileName, os);
+ if (validCheck != FilenameUtil.IS_VALID_NAME)
+ {
+ switch(validCheck)
+ {
+ case FilenameUtil.HAS_INVALID_CHARACTER:
+ return ConnectionUIMessages.Explorer_Message_Invalid_Character + FilenameUtil.getInvalidCharacters(os);
+ case FilenameUtil.HAS_NO_NAME:
+ return "";
+ default:
+ break;
+ }
+ }
+ return null;
+ }
+ }
+
+ public int getActionState()
+ {
+ //sub, push, pull, refresh, rename, delete, property
+ int length = treeViewer.getTree().getSelectionCount();
+
+ int state = 0x0000000;
+
+ if (length == 1)
+ {
+ FileEntry entry = getSingleFileEntry();
+ if (entry.isRoot())
+ {
+ state = STATE_SUB | STATE_PUSH| STATE_PULL | STATE_REFRESH | STATE_PROPERTY;
+ } else if (!entry.isDirectory())
+ {
+ state = STATE_PULL | STATE_REFRESH | STATE_RENAME | STATE_DELETE | STATE_PROPERTY;
+ } else
+ {
+ state = STATE_SUB | STATE_PUSH | STATE_PULL | STATE_REFRESH | STATE_RENAME | STATE_DELETE | STATE_PROPERTY;
+ }
+ } else if (length > 1)
+ {
+ state = STATE_PULL | STATE_DELETE;
+ }
+
+ return state;
+ }
+
+ private boolean getEnabled(int mode, int state)
+ {
+ int result = (mode & state);
+ return result != 0 ? true : false;
+ }
+
+ private void setActionEnabled()
+ {
+ int mode = getActionState();
+ subMenu.setVisible(getEnabled(mode, STATE_SUB));
+
+ boolean bPush = getEnabled(mode, STATE_PUSH);
+ actionPush.setEnabled(bPush);
+ pushToolItem.setEnabled(bPush);
+
+ boolean bPull = getEnabled(mode, STATE_PULL);
+ actionPull.setEnabled(bPull);
+ pullToolItem.setEnabled(bPull);
+
+ actionRename.setEnabled(getEnabled(mode, STATE_RENAME));
+ actionRefresh.setEnabled(getEnabled(mode, STATE_REFRESH));
+ actionDelete.setEnabled(getEnabled(mode, STATE_DELETE));
+ actionProperty.setEnabled(getEnabled(mode, STATE_PROPERTY));
+ }
+
+ private FileEntry getSingleFileEntry()
+ {
+ Tree tree = treeViewer.getTree();
+ if (tree.getSelectionCount() != 0)
+ {
+ TreeItem[] items = tree.getSelection();
+ return (FileEntry) items[0].getData();
+ } else
+ return null;
+ }
+
+ @Override
+ public void selectionChanged(final FileEntry selectedEntry)
+ {
+
+ if (selectedEntry == null)
+ {
+ return;
+ }
+
+ if (!selectedEntry.isRoot())
+ {
+ return;
+ }
+
+ final Tree tree = treeViewer.getTree();
+ exec(new Runnable()
+ {
+ @Override
+ public void run()
+ {
+ if (tree.isDisposed() == false)
+ {
+ for (TreeItem item : tree.getItems())
+ {
+ if (item.getText().equals(selectedEntry.getName()))
+ tree.setSelection(item);
+ }
+ } else
+ {
+ // tree is disposed, we need to do something.
+ // lets remove ourselves from the listener.
+ ConnectionPlugin.getDefault().removeSelectionListener(ConnectionExplorerPanel.this);
+ }
+ }
+ });
+ }
+
+ private boolean isSingleEntry()
+ {
+ Tree tree = treeViewer.getTree();
+ if (tree.getSelectionCount() == 1)
+ {
+ return true;
+ } else
+ {
+ return false;
+ }
+ }
+
+ public void doActionForEntry(IActionForEntry action)
+ {
+ if (action.doCheckEnable())
+ {
+ action.doAction();
+ }
+ }
+
+ private interface IActionForEntry
+ {
+ public boolean doCheckEnable();
+
+ public void doAction();
+ }
} \ No newline at end of file
diff --git a/org.tizen.common.connection/src/org/tizen/common/connection/explorer/Messages.java b/org.tizen.common.connection/src/org/tizen/common/connection/explorer/Messages.java
index 28a166170..f603e24c6 100644..100755
--- a/org.tizen.common.connection/src/org/tizen/common/connection/explorer/Messages.java
+++ b/org.tizen.common.connection/src/org/tizen/common/connection/explorer/Messages.java
@@ -52,80 +52,4 @@ public class Messages {
return '!' + key + '!';
}
}
- private static String messageBind(String message, Object[] args, String argZero, String argOne) {
- int length = message.length();
- //estimate correct size of string buffer to avoid growth
- int bufLen = length + (args.length * 5);
- if (argZero != null)
- bufLen += argZero.length() - 3;
- if (argOne != null)
- bufLen += argOne.length() - 3;
- StringBuffer buffer = new StringBuffer(bufLen < 0 ? 0 : bufLen);
- for (int i = 0; i < length; i++) {
- char c = message.charAt(i);
- switch (c) {
- case '{' :
- int index = message.indexOf('}', i);
- // if we don't have a matching closing brace then...
- if (index == -1) {
- buffer.append(c);
- break;
- }
- i++;
- if (i >= length) {
- buffer.append(c);
- break;
- }
- // look for a substitution
- int number = -1;
- try {
- number = Integer.parseInt(message.substring(i, index));
- } catch (NumberFormatException e) {
- throw (IllegalArgumentException) new IllegalArgumentException().initCause(e);
- }
- if (number == 0 && argZero != null)
- buffer.append(argZero);
- else if (number == 1 && argOne != null)
- buffer.append(argOne);
- else {
- if (number >= args.length || number < 0) {
- buffer.append("<missing argument>"); //$NON-NLS-1$
- i = index;
- break;
- }
- buffer.append(args[number]);
- }
- i = index;
- break;
- case '\'' :
- // if a single quote is the last char on the line then skip it
- int nextIndex = i + 1;
- if (nextIndex >= length) {
- buffer.append(c);
- break;
- }
- char next = message.charAt(nextIndex);
- // if the next char is another single quote then write out one
- if (next == '\'') {
- i++;
- buffer.append(c);
- break;
- }
- // otherwise we want to read until we get to the next single quote
- index = message.indexOf('\'', nextIndex);
- // if there are no more in the string, then skip it
- if (index == -1) {
- buffer.append(c);
- break;
- }
- // otherwise write out the chars inside the quotes
- buffer.append(message.substring(nextIndex, index));
- i = index;
- break;
- default :
- buffer.append(c);
- }
- }
- return buffer.toString();
- }
}
diff --git a/org.tizen.common.connection/src/org/tizen/common/connection/explorer/messages.properties b/org.tizen.common.connection/src/org/tizen/common/connection/explorer/messages.properties
index 3d54a9c15..28acc154d 100644
--- a/org.tizen.common.connection/src/org/tizen/common/connection/explorer/messages.properties
+++ b/org.tizen.common.connection/src/org/tizen/common/connection/explorer/messages.properties
@@ -1,9 +1,8 @@
-
-FileDialogUtils.overrite.title=File Exists
-FileDialogUtils.overrite.message=The file {0} already exists. Are you going to overwrite it?
-FileDialogUtils.delete.title=File Delete
-FileDialogUtils.delete.message=Are you going to delete {0}?
-FileDialogUtils.tabName.title=Invalid Name
-FileDialogUtils.tabName.message= "{0}" is already exist!\nPlease fill in the TabName with another.
+FileDialogUtils.message.title=Message
+FileDialogUtils.overwrite.message=The {0} file already exists. Do you want to overwrite it?
+FileDialogUtils.duplicate.message=Existing file
+FileDialogUtils.delete.message=Are you sure you want to delete the {0} file?
+FileDialogUtils.tabName.message= The tab name already exists. Enter a different name.
FileDialogUtils.update.title=Tizen SDK
-FileDialogUtils.update.message= Updates are available for Tizen SDK. Do you want to install them?
+FileDialogUtils.update.message= Tizen SDK updates are available. Do you want to install them now?
+ConnectionExplorer.tree.header=Files \ No newline at end of file
diff --git a/org.tizen.common.connection/src/org/tizen/common/connection/log/AddViewDialog.java b/org.tizen.common.connection/src/org/tizen/common/connection/log/AddViewDialog.java
index 2d6ccd340..13cb20247 100644..100755
--- a/org.tizen.common.connection/src/org/tizen/common/connection/log/AddViewDialog.java
+++ b/org.tizen.common.connection/src/org/tizen/common/connection/log/AddViewDialog.java
@@ -1,30 +1,32 @@
/*
-* Common
-*
-* Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved.
-*
-* Contact:
-* Hoon Kang <h245.kang@samsung.com>
-* Hyunsik Noh <hyunsik.noh@samsung.com>
-*
+ * Common
+ *
+ * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved.
+ *
+ * Contact:
+ * Hoon Kang <h245.kang@samsung.com>
+ * Hyunsik Noh <hyunsik.noh@samsung.com>
+ *
* Licensed under the Apache License, Version 2.0 (the "License");
-* you may not use this file except in compliance with the License.
-* You may obtain a copy of the License at
-*
-* http://www.apache.org/licenses/LICENSE-2.0
-*
-* Unless required by applicable law or agreed to in writing, software
-* distributed under the License is distributed on an "AS IS" BASIS,
-* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-* See the License for the specific language governing permissions and
-* limitations under the License.
-*
-* Contributors:
-* - S-Core Co., Ltd
-*
-*/
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ * Contributors:
+ * - S-Core Co., Ltd
+ *
+ */
package org.tizen.common.connection.log;
+import static org.tizen.common.util.StringUtil.isEmpty;
+
import org.eclipse.jface.dialogs.IDialogConstants;
import org.eclipse.swt.SWT;
import org.eclipse.swt.events.SelectionAdapter;
@@ -50,268 +52,314 @@ import org.tizen.sdblib.SmartDevelopmentBridge;
/**
* Small dialog box to open new logtab with some options.
*/
-public class AddViewDialog extends Dialog {
-
- private static final int DLG_WIDTH = 400;
- private static final int DLG_HEIGHT = 300;
-
- private Shell parent;
-
- private Shell shell;
-
- private String dialogName = null;
-
- private boolean bOk = false;
-
- private LogTab oldTab = null;
-
- private static final String TEMPNAME = "LogTab-#";
- private static int cnt = 0;
-
- private String tabName = null;
- private String device = null;
- private String pidKeyword = null;
- private String tagKeyword = null;
- private String msgKeyword = null;
-
- private Text tabNameText;
- private Text tagText;
- private Text pidText;
- private Text msgText;
- private Button okButton;
-
- public AddViewDialog(Shell pParent) {
- super(pParent, SWT.DIALOG_TRIM | SWT.BORDER | SWT.APPLICATION_MODAL);
- }
-
- public AddViewDialog(Shell pParent, String deviceName) {
- super(pParent, SWT.DIALOG_TRIM | SWT.BORDER | SWT.APPLICATION_MODAL);
- device = deviceName;
- dialogName = "Add LogTab";
- }
-
- public AddViewDialog(Shell pParent, LogTab tab) {
- super(pParent, SWT.DIALOG_TRIM | SWT.BORDER | SWT.APPLICATION_MODAL);
- if (tab != null) {
- dialogName = "Edit LogTab";
- tabName = tab.getFilterName();
- if (tab.getFilterDeviceName() == null)
- return;
- device = tab.getFilterDeviceName();
-
- pidKeyword = tab.getPidFilter();
- tagKeyword = tab.getTagFilter();
- msgKeyword = tab.getMsgFilter();
-
- oldTab = tab;
- }
- }
-
- /**
- * Opens the dialog. The method will return when the user closes the dialog
- * somehow.
- *
- * @return true if ok was pressed, false if cancelled.
- */
- public boolean open() {
- createUI();
-
- if (parent == null || shell == null) {
- return false;
- }
-
- shell.setMinimumSize(DLG_WIDTH, DLG_HEIGHT);
- Rectangle r = parent.getBounds();
- // get the center new top left.
- int cx = r.x + r.width / 2;
- int x = cx - DLG_WIDTH / 2;
- int cy = r.y + r.height / 2;
- int y = cy - DLG_HEIGHT / 2;
- shell.setBounds(x, y, DLG_WIDTH, DLG_HEIGHT);
-
- shell.open();
-
- Display display = parent.getDisplay();
- while (!shell.isDisposed()) {
- if (!display.readAndDispatch())
- display.sleep();
- }
-
- return bOk;
- }
-
- private void createUI() {
- parent = getParent();
- shell = new Shell(parent, getStyle());
- shell.setText(dialogName);
-
- shell.setLayout(new GridLayout(1, false));
-
- shell.addListener(SWT.Close, new Listener() {
- @Override
- public void handleEvent(Event event) {
- }
- });
-
- Group top = new Group(shell, SWT.SHADOW_IN);
- top.setText("LogTab");
- top.setLayoutData(new GridData(GridData.FILL_BOTH));
- top.setLayout(new GridLayout(2, false));
-
- Label l = new Label(top, SWT.NONE);
- l.setText("Name : ");
-
- tabNameText = new Text(top, SWT.SINGLE | SWT.BORDER);
- if (tabName != null)
- tabNameText.setText(tabName);
- tabNameText.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
-
- l = new Label(top, SWT.NONE);
- l.setText("Device : ");
-
- final Combo dCombo = new Combo(top, SWT.DROP_DOWN | SWT.READ_ONLY | SWT.CENTER);
- GridData gd = new GridData(GridData.FILL_HORIZONTAL);
-
- dCombo.setLayoutData(gd);
- IDevice[] devices = SmartDevelopmentBridge.getBridge().getDevices();
-
- if (devices.length != 0) {
- for (IDevice d : devices) {
- if (d.isOnline())
- dCombo.add(d.getSerialNumber());
- }
-
- if (device != null) {
- for (int i = 0; i < devices.length; i++) {
- if (device.equals(devices[i].getSerialNumber())) {
- dCombo.select(i);
- break;
- }
- }
- } else {
- dCombo.select(0);
- device = dCombo.getItem(0);
- }
- }
-
- Group mid = new Group(shell, SWT.SHADOW_IN);
- mid.setText("Search Keywords");
- mid.setLayoutData(new GridData(GridData.FILL_BOTH));
- mid.setLayout(new GridLayout(2, false));
-
- l = new Label(mid, SWT.NONE);
- l.setText("Tag : ");
-
- tagText = new Text(mid, SWT.SINGLE | SWT.BORDER);
- if (tagKeyword != null)
- tagText.setText(tagKeyword);
- tagText.setMessage("Separated by a space/comma");
- tagText.setToolTipText("Search Tag Keywords are separated by a space as well as a comma");
- tagText.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
-
- l = new Label(mid, SWT.NONE);
- l.setText("Pid : ");
-
- pidText = new Text(mid, SWT.SINGLE | SWT.BORDER);
- if (pidKeyword != null)
- pidText.setText(pidKeyword);
- pidText.setMessage("Separated by a space/comma");
- pidText.setToolTipText("Search Pid Keywords are separated by a space as well as a comma");
- pidText.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
-
- l = new Label(mid, SWT.NONE);
- l.setText("Message : ");
-
- msgText = new Text(mid, SWT.SINGLE | SWT.BORDER);
- if (msgKeyword != null)
- msgText.setText(msgKeyword);
- msgText.setMessage("Separated by a space/comma");
- msgText.setToolTipText("Search Message Keywords are separated by a space as well as a comma");
- msgText.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
-
- // bottom part with the ok/cancel
- Composite bottomComp = new Composite(shell, SWT.NONE);
- bottomComp
- .setLayoutData(new GridData(GridData.HORIZONTAL_ALIGN_CENTER));
- bottomComp.setLayout(new GridLayout(2, true));
-
- okButton = new Button(bottomComp, SWT.NONE);
- okButton.setText("OK");
- okButton.addSelectionListener(new SelectionAdapter() {
- @Override
- public void widgetSelected(SelectionEvent e) {
- String newName = tabNameText.getText();
- for (LogTab tab : LogPanel.tabs) {
- if (tab.getFilterName().equals(newName)) {
- if (oldTab != null && oldTab == tab)
- continue;
- int ret = FileDialogUtils.getInstance().checkTabName(newName);
- if (ret == IDialogConstants.OK_ID)
- return;
- }
- }
-
- bOk = true;
-
- if (tabNameText.getText().length() != 0)
- tabName = tabNameText.getText();
- else
- tabName = TEMPNAME + cnt++;
-
- if (tagText.getText().length() != 0)
- tagKeyword = tagText.getText();
- else
- tagKeyword = null;
-
- if (pidText.getText().length() != 0)
- pidKeyword = pidText.getText();
- else
- pidKeyword = null;
-
- if (msgText.getText().length() != 0)
- msgKeyword = msgText.getText();
- else
- msgKeyword = null;
-
- device = dCombo.getItem(dCombo.getSelectionIndex());
-
- shell.close();
- }
- });
- shell.setDefaultButton(okButton);
-
- Button cancelButton = new Button(bottomComp, SWT.NONE);
- cancelButton.setText("Cancel");
- cancelButton.addSelectionListener(new SelectionAdapter() {
- @Override
- public void widgetSelected(SelectionEvent e) {
- shell.close();
- }
- });
-
- }
-
- public String getName() {
- return tabName;
- }
-
- public String getDevice() {
- return device;
- }
-
- public String getPidKeyword() {
- return pidKeyword;
- }
-
- public String getTagKeyword() {
- return tagKeyword;
- }
-
- public String getMsgKeyword() {
- return msgKeyword;
- }
-
- public void setName(String name) {
- this.tabName = name;
- }
+public class AddViewDialog extends Dialog
+{
+
+ private static final int DLG_WIDTH = 400;
+ private static final int DLG_HEIGHT = 300;
+
+ private Shell parent;
+
+ private Shell shell;
+
+ private String dialogName = null;
+
+ private boolean bOk = false;
+
+ private LogTab oldTab = null;
+
+ private static final String TEMPNAME = "LogTab-#";
+ private static int cnt = 0;
+
+ private String tabName = null;
+ private String device = null;
+ private String pidKeyword = null;
+ private String tagKeyword = null;
+ private String msgKeyword = null;
+
+ private Text tabNameText;
+ private Text tagText;
+ private Text pidText;
+ private Text msgText;
+ private Button okButton;
+
+ public AddViewDialog(Shell pParent)
+ {
+ super(pParent, SWT.DIALOG_TRIM | SWT.BORDER | SWT.APPLICATION_MODAL);
+ }
+
+ public AddViewDialog(Shell pParent, String deviceName)
+ {
+ super(pParent, SWT.DIALOG_TRIM | SWT.BORDER | SWT.APPLICATION_MODAL);
+ device = deviceName;
+ dialogName = "Add LogTab";
+ }
+
+ public AddViewDialog(Shell pParent, LogTab tab)
+ {
+ super(pParent, SWT.DIALOG_TRIM | SWT.BORDER | SWT.APPLICATION_MODAL);
+ if (tab != null)
+ {
+ dialogName = "Edit LogTab";
+ tabName = tab.getLogTabName();
+ if (tab.getDeviceSerialNumber() == null)
+ {
+ return;
+ }
+ device = tab.getDeviceSerialNumber();
+
+ pidKeyword = tab.getPidFilter();
+ tagKeyword = tab.getTagFilter();
+ msgKeyword = tab.getMsgFilter();
+
+ oldTab = tab;
+ }
+ }
+
+ /**
+ * Opens the dialog. The method will return when the user closes the dialog
+ * somehow.
+ *
+ * @return true if ok was pressed, false if cancelled.
+ */
+ public boolean open()
+ {
+ createUI();
+
+ if (parent == null || shell == null)
+ {
+ return false;
+ }
+
+ shell.setMinimumSize(DLG_WIDTH, DLG_HEIGHT);
+ Rectangle r = parent.getBounds();
+ // get the center new top left.
+ int cx = r.x + r.width / 2;
+ int x = cx - DLG_WIDTH / 2;
+ int cy = r.y + r.height / 2;
+ int y = cy - DLG_HEIGHT / 2;
+ shell.setBounds(x, y, DLG_WIDTH, DLG_HEIGHT);
+
+ shell.open();
+
+ Display display = parent.getDisplay();
+ while (!shell.isDisposed())
+ {
+ if (!display.readAndDispatch())
+ display.sleep();
+ }
+
+ return bOk;
+ }
+
+ private void createUI()
+ {
+ parent = getParent();
+ shell = new Shell(parent, getStyle());
+ shell.setText(dialogName);
+
+ shell.setLayout(new GridLayout(1, false));
+
+ shell.addListener(SWT.Close, new Listener()
+ {
+ @Override
+ public void handleEvent(Event event)
+ {
+ }
+ });
+
+ Group top = new Group(shell, SWT.SHADOW_IN);
+ top.setText("LogTab");
+ top.setLayoutData(new GridData(GridData.FILL_BOTH));
+ top.setLayout(new GridLayout(2, false));
+
+ Label l = new Label(top, SWT.NONE);
+ l.setText("Name:");
+
+ tabNameText = new Text(top, SWT.SINGLE | SWT.BORDER);
+ if (tabName != null)
+ tabNameText.setText(tabName);
+ tabNameText.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
+
+ l = new Label(top, SWT.NONE);
+ l.setText("Device:");
+
+ final Combo dCombo = new Combo(top, SWT.DROP_DOWN | SWT.READ_ONLY | SWT.CENTER);
+ GridData gd = new GridData(GridData.FILL_HORIZONTAL);
+
+ dCombo.setLayoutData(gd);
+ IDevice[] devices = SmartDevelopmentBridge.getBridge().getDevices();
+
+ if (devices.length != 0)
+ {
+ for (IDevice d : devices)
+ {
+ if (d.isOnline())
+ dCombo.add(d.getSerialNumber());
+ }
+
+ if (device != null)
+ {
+ for (int i = 0; i < devices.length; i++)
+ {
+ if (device.equals(devices[i].getSerialNumber()))
+ {
+ dCombo.select(i);
+ break;
+ }
+ }
+ } else
+ {
+ dCombo.select(0);
+ device = dCombo.getItem(0);
+ }
+ }
+
+ Group mid = new Group(shell, SWT.SHADOW_IN);
+ mid.setText("Search keywords");
+ mid.setLayoutData(new GridData(GridData.FILL_BOTH));
+ mid.setLayout(new GridLayout(2, false));
+
+ l = new Label(mid, SWT.NONE);
+ l.setText("Tag:");
+
+ tagText = new Text(mid, SWT.SINGLE | SWT.BORDER);
+ if (tagKeyword != null)
+ tagText.setText(tagKeyword);
+ tagText.setMessage("Separated by a space and comma");
+ tagText.setToolTipText("Search Tag Keywords are separated by a space as well as a comma");
+ tagText.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
+
+ l = new Label(mid, SWT.NONE);
+ l.setText("Pid:");
+
+ pidText = new Text(mid, SWT.SINGLE | SWT.BORDER);
+ if (pidKeyword != null)
+ pidText.setText(pidKeyword);
+ pidText.setMessage("Separated by a space and comma");
+ pidText.setToolTipText("Search Pid Keywords are separated by a space as well as a comma");
+ pidText.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
+
+ l = new Label(mid, SWT.NONE);
+ l.setText("Message:");
+
+ msgText = new Text(mid, SWT.SINGLE | SWT.BORDER);
+ if (msgKeyword != null)
+ msgText.setText(msgKeyword);
+ msgText.setMessage("Separated by a space and comma");
+ msgText.setToolTipText("Search Message Keywords are separated by a space as well as a comma");
+ msgText.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
+
+ // bottom part with the ok/cancel
+ Composite bottomComp = new Composite(shell, SWT.NONE);
+ bottomComp.setLayoutData(new GridData(GridData.HORIZONTAL_ALIGN_CENTER));
+ bottomComp.setLayout(new GridLayout(2, true));
+
+ okButton = new Button(bottomComp, SWT.NONE);
+ okButton.setText("OK");
+ okButton.addSelectionListener(new SelectionAdapter()
+ {
+ @Override
+ public void widgetSelected(SelectionEvent e)
+ {
+ String newName = tabNameText.getText();
+ for (LogTab tab : LogPanel.logTabList)
+ {
+ if (tab.getLogTabName().equals(newName))
+ {
+ if (oldTab != null && oldTab == tab)
+ continue;
+ int ret = FileDialogUtils.checkTabName(newName);
+ if (ret == IDialogConstants.OK_ID)
+ return;
+ }
+ }
+
+ bOk = true;
+
+ if ( isEmpty( tabNameText.getText() ) )
+ {
+ tabName = TEMPNAME + cnt++;
+ }
+ else
+ {
+ tabName = tabNameText.getText();
+ }
+
+ if ( isEmpty( tagText.getText() ) )
+ {
+ tagKeyword = null;
+ }
+ else
+ {
+ tagKeyword = tagText.getText();
+ }
+
+ if ( isEmpty( pidText.getText() ) )
+ {
+ pidKeyword = null;
+ }
+ else
+ {
+ pidKeyword = pidText.getText();
+ }
+
+ if ( isEmpty( msgText.getText() ) )
+ {
+ msgKeyword = null;
+ }
+ else
+ {
+ msgKeyword = msgText.getText();
+ }
+
+ device = dCombo.getItem(dCombo.getSelectionIndex());
+
+ shell.close();
+ }
+ });
+ shell.setDefaultButton(okButton);
+
+ Button cancelButton = new Button(bottomComp, SWT.NONE);
+ cancelButton.setText("Cancel");
+ cancelButton.addSelectionListener(new SelectionAdapter()
+ {
+ @Override
+ public void widgetSelected(SelectionEvent e)
+ {
+ shell.close();
+ }
+ });
+
+ }
+
+ public String getName()
+ {
+ return tabName;
+ }
+
+ public String getDevice()
+ {
+ return device;
+ }
+
+ public String getPidKeyword()
+ {
+ return pidKeyword;
+ }
+
+ public String getTagKeyword()
+ {
+ return tagKeyword;
+ }
+
+ public String getMsgKeyword()
+ {
+ return msgKeyword;
+ }
+
+ public void setName(String name)
+ {
+ this.tabName = name;
+ }
} \ No newline at end of file
diff --git a/org.tizen.common.connection/src/org/tizen/common/connection/log/LogColors.java b/org.tizen.common.connection/src/org/tizen/common/connection/log/LogColors.java
index 83910f970..b7be8325f 100644
--- a/org.tizen.common.connection/src/org/tizen/common/connection/log/LogColors.java
+++ b/org.tizen.common.connection/src/org/tizen/common/connection/log/LogColors.java
@@ -17,6 +17,8 @@ package org.tizen.common.connection.log;
*/
import org.eclipse.swt.graphics.Color;
+import org.eclipse.swt.widgets.Display;
+import org.tizen.common.util.SWTUtil;
public class LogColors {
public Color infoColor;
@@ -24,4 +26,18 @@ public class LogColors {
public Color errorColor;
public Color warningColor;
public Color verboseColor;
+
+ public LogColors(Display display)
+ {
+ infoColor = new Color(display, 66, 120, 157);
+ debugColor = new Color(display, 129, 89, 168);
+ errorColor = new Color(display, 188, 108, 119);
+ warningColor = new Color(display, 191, 106, 51);
+ verboseColor = new Color(display, 90, 90, 90);
+ }
+
+ public void dispose()
+ {
+ SWTUtil.tryDispose(infoColor, debugColor, errorColor, warningColor, verboseColor);
+ }
} \ No newline at end of file
diff --git a/org.tizen.common.connection/src/org/tizen/common/connection/log/LogPanel.java b/org.tizen.common.connection/src/org/tizen/common/connection/log/LogPanel.java
index 12b45b632..2f9427d48 100644..100755
--- a/org.tizen.common.connection/src/org/tizen/common/connection/log/LogPanel.java
+++ b/org.tizen.common.connection/src/org/tizen/common/connection/log/LogPanel.java
@@ -1,28 +1,28 @@
/*
-* Common
-*
-* Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved.
-*
-* Contact:
-* Hoon Kang <h245.kang@samsung.com>
-* Hyunsik Noh <hyunsik.noh@samsung.com>
-*
+ * Common
+ *
+ * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved.
+ *
+ * Contact:
+ * Hoon Kang <h245.kang@samsung.com>
+ * Hyunsik Noh <hyunsik.noh@samsung.com>
+ *
* Licensed under the Apache License, Version 2.0 (the "License");
-* you may not use this file except in compliance with the License.
-* You may obtain a copy of the License at
-*
-* http://www.apache.org/licenses/LICENSE-2.0
-*
-* Unless required by applicable law or agreed to in writing, software
-* distributed under the License is distributed on an "AS IS" BASIS,
-* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-* See the License for the specific language governing permissions and
-* limitations under the License.
-*
-* Contributors:
-* - S-Core Co., Ltd
-*
-*/
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ * Contributors:
+ * - S-Core Co., Ltd
+ *
+ */
package org.tizen.common.connection.log;
import java.io.File;
@@ -30,10 +30,13 @@ import java.io.FileWriter;
import java.io.IOException;
import java.util.ArrayList;
import java.util.Arrays;
+import java.util.Iterator;
+import java.util.List;
import org.eclipse.jface.action.Action;
import org.eclipse.jface.dialogs.IDialogConstants;
import org.eclipse.swt.SWT;
+import org.eclipse.swt.custom.StackLayout;
import org.eclipse.swt.dnd.Clipboard;
import org.eclipse.swt.dnd.TextTransfer;
import org.eclipse.swt.dnd.Transfer;
@@ -65,756 +68,916 @@ import org.tizen.common.connection.ddmuilib.FileDialogUtils;
import org.tizen.common.connection.ddmuilib.ITableFocusListener;
import org.tizen.common.connection.ddmuilib.ITableFocusListener.IFocusedTableActivator;
import org.tizen.common.connection.ddmuilib.Panel;
+import org.tizen.common.connection.explorer.ConnectionExplorerLabelProvider;
import org.tizen.common.util.DialogUtil;
import org.tizen.common.util.NotificationType;
import org.tizen.common.util.NotifierDialog;
+import org.tizen.common.util.SWTUtil;
import org.tizen.sdblib.IDevice;
import org.tizen.sdblib.Log.LogLevel;
import org.tizen.sdblib.SmartDevelopmentBridge;
import org.tizen.sdblib.SmartDevelopmentBridge.IDeviceChangeListener;
-public class LogPanel extends Panel implements IDeviceChangeListener {
-
- public static final int ACTION_NOTHING = 0;
- public static final int ACTION_DEVICE_TAB = 1;
- public static final int ACTION_ADDITIONAL_TAB = 2;
-
- public static ArrayList<LogTab> tabs = new ArrayList<LogTab>();
-
- private String defaultLogSave;
-
- private static int tabCnt = 0;
-
- private Composite parent;
- private TabFolder folders;
- private Table table;
-
- private Combo panelFilterIndex;
- private Text panelFilterKeyword;
-
- private final LogColors colors;
-
- private LogTab currentTab;
-
- private Action[] levelActions;
- private Action addAction;
- private Action removeAction;
- private Action editAction;
- private Action exportAction;
- private Action clearAction;
-
- private Control control;
-
- /** message data, separated from content for multi line messages */
- protected static class LogMessageInfo {
- public LogLevel logLevel;
- public String pidString;
- public String tag;
- public String time;
- }
-
- private ITableFocusListener globalListener;
-
- /** message data, separated from content for multi line messages */
- protected static class LogMessage {
- public LogMessageInfo data;
- public String msg;
-
- @Override
- public String toString() {
- return data.time + ": " + data.logLevel + "/" + data.tag + "(" + data.pidString + "): " + msg;
- }
- }
-
- /**
- * Create the log panel with some default parameters
- *
- * @param colors
- * The display color object
- */
- public LogPanel(LogColors pColors) {
- colors = pColors;
- }
-
- public void setActions(Action[] levels, Action add, Action remove,
- Action edit, Action export, Action clear) {
- levelActions = levels;
- addAction = add;
- removeAction = remove;
- editAction = edit;
- exportAction = export;
- clearAction = clear;
- }
-
- /**
- * Creates a control capable of displaying some information. This is called
- * once, when the application is initializing, from the UI thread.
- */
- @Override
- protected Control createControl(Composite p) {
-
- parent = p;
-
- // create the tab folder
- folders = new TabFolder(parent, SWT.NONE);
- folders.setLayoutData(new GridData(GridData.FILL_BOTH));
- folders.addSelectionListener(new SelectionAdapter() {
- @Override
- public void widgetSelected(SelectionEvent e) {
- selectLogTab();
- }
- });
-
- control = getTabControl(folders);
- SmartDevelopmentBridge.addDeviceChangeListener(this);
- //Create default device tab if device(s) is connectied
- createDefaultTabs();
- selectLogTab();
- return null;
- }
-
- private void selectLogTab()
- {
- //1.get selected tabitem's logtab
- //2.set previous logtab view filter and get selected logtab view filter
- initViewFilter(getCurrentLogTab());
- if (currentTab == null)
- return;
- //remove all message and re-fill message into table from selected logtab msg buffer
- currentTab.initTab();
-
- //set icon selection from selected logtab object
- currentTab.setLevelIcon(levelActions);
-
- //Set action enabled state from selected tab(LotTab object)
- if (currentTab.isDefault()) {
- setActionEnabled(LogPanel.ACTION_DEVICE_TAB);
- } else {
- setActionEnabled(LogPanel.ACTION_ADDITIONAL_TAB);
- }
- }
-
- /**
- *
- * Create the LogFilters with default devicesd
- *
- */
- private void createDefaultTabs() {
- SmartDevelopmentBridge sdbBridge = SmartDevelopmentBridge.getBridge();
- IDevice[] devices = null;
- if (sdbBridge != null) {
- devices = sdbBridge.getDevices();
- }
-
- if (devices != null) {
- for (IDevice device : devices) {
- if (device.isOffline())
- continue;
- LogTab dTab = createDefaultTab(device, null);
- dTab.startLogTab();
- }
- }
- }
-
- private LogTab createDefaultTab(IDevice device, String tabName) {
- LogTab tab = createTab(device, null);
- tab.setDefault();
- setActionEnabled(LogPanel.ACTION_DEVICE_TAB);
- return tab;
- }
-
- private LogTab createTab(IDevice device, String tabName) {
-
- LogTab tab = null;
- if (tabName == null)
- tab = new LogTab(device.getSerialNumber(), device, colors);
- else
- tab = new LogTab(tabName, device, colors);
-
- //
- for (int i = 0; i < tabs.size(); i++) {
- LogTab oldTab = tabs.get(i);
- if (oldTab.getFilterName().equals(tab.getFilterName())) {
- oldTab.stopLogTab(true);
- tabs.remove(i);
- tabCnt--;
- oldTab.dispose();
- if (!tabs.isEmpty())
- folders.setSelection(0);
- }
- }
-
- TabItem item = new TabItem(folders, SWT.NONE, tabCnt++);
-
- item.setText(tab.getFilterName());
- tab.setTable(table);
- item.setControl(control);
- tab.setTab(item);
-
- folders.setSelection(item);
- tabs.add(tab);
-
- if (tab.isDefault()) {
- setActionEnabled(LogPanel.ACTION_DEVICE_TAB);
- } else {
- setActionEnabled(LogPanel.ACTION_ADDITIONAL_TAB);
- }
- tab.setLevelIcon(levelActions);
- return tab;
- }
-
- private void initViewFilter(LogTab tab)
- {
- if(currentTab != null)
- {
- currentTab.setFilterIndexFromPanel(panelFilterIndex.getSelectionIndex());
- currentTab.setFilterKeywordFromPanel(panelFilterKeyword.getText());
- }
-
- currentTab = tab;
-
- if(tab != null)
- {
- panelFilterIndex.select(tab.getFilterIndexFromPanel());
- panelFilterKeyword.setText(tab.getFilterKeywordFromPanel());
- }
- }
-
- private Control getTabControl(TabFolder tabFolder) {
- // Create a composite and add four buttons to it
-
- Composite composite = new Composite(tabFolder, SWT.NONE);
- composite.setLayoutData(new GridData(GridData.FILL_VERTICAL));
- composite.setLayout(new GridLayout(1, false));
-
- Composite mid = new Composite(composite, SWT.NONE);
- mid.setLayoutData(new GridData(GridData.FILL_BOTH));
- mid.setLayout(new FillLayout());
-
- table = new Table(mid, SWT.MULTI | SWT.FULL_SELECTION | SWT.BORDER | SWT.H_SCROLL);
-
- table.setHeaderVisible(true);
- table.setLinesVisible(true);
-
- if (globalListener != null) {
- addTableToFocusListener(table);
- }
-
- ControlListener listener = null;
- listener = new ControlListener() {
- @Override
- public void controlMoved(ControlEvent e) {
-
- }
-
- @Override
- public void controlResized(ControlEvent e) {
- Rectangle r = table.getClientArea();
-
- // get the size of all but the last column
- int total = table.getColumn(0).getWidth();
- total += table.getColumn(1).getWidth();
- total += table.getColumn(2).getWidth();
- total += table.getColumn(3).getWidth();
-//
- if (r.width > total) {
- table.getColumn(4).setWidth(r.width - total);
- }
- }
- };
-
- table.addControlListener(listener);
-
- // then its column
- TableColumn col = createTableColumn(table, "Time", SWT.LEFT,
- "00-00 00:00:00.000");
- col.addControlListener(listener);
-
- col = createTableColumn(table, "Level", SWT.LEFT, "Verbose");
- col.addControlListener(listener);
-
- col = createTableColumn(table, "Pid", SWT.LEFT, "9999999");
- col.addControlListener(listener);
-
- col = createTableColumn(table, "Tag", SWT.LEFT, "ABCDEFGHIJK");
- col.addControlListener(listener);
-
- col = createTableColumn(table, "Message", SWT.LEFT,
- "abcdefghijklmnopqrstuvwxyz0123456789");
-// col.setResizable(false);
-
- Composite bottom = new Composite(composite, SWT.NONE);
- bottom.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
- bottom.setLayout(new GridLayout(3, false));
-
- panelFilterIndex = new Combo(bottom, SWT.READ_ONLY);
- String[] comboItems = {"Pid", "Tag", "Message"};
- panelFilterIndex.setItems(comboItems);
- panelFilterIndex.select(2);
- panelFilterIndex.setToolTipText(LogUIMessages.Log_Tooltip_View_Filter_Combo);
- panelFilterIndex.addSelectionListener(new SelectionListener() {
- @Override
- public void widgetSelected(SelectionEvent e) {
- if(currentTab != null)
- {
- int index = panelFilterIndex.getSelectionIndex();
- if (panelFilterKeyword.getText() != null) {
- currentTab.tableRefill(index, panelFilterKeyword.getText());
- }
- }
- }
-
- @Override
- public void widgetDefaultSelected(SelectionEvent e) {
- }
- });
-
- panelFilterKeyword = new Text(bottom, SWT.SINGLE | SWT.BORDER);
- panelFilterKeyword.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
- panelFilterKeyword.setMessage(LogUIMessages.Log_Message_View_Filter_Text);
- panelFilterKeyword.addModifyListener(new ModifyListener() {
-
- @Override
- public void modifyText(ModifyEvent e) {
- if(currentTab != null)
- {
- String keyword = panelFilterKeyword.getText();
- int index = currentTab.getFilterIndexFromPanel();
- panelFilterIndex.select(index);
- if (keyword != null) {
- if (index != -1) {
- currentTab.tableRefill(index, keyword);
- }
- }
- }
- }
- });
-
- return composite;
- }
-
- @Override
- protected void postCreation() {
- // pass
- }
-
- /**
- * Sets the focus to the proper object.
- */
- @Override
- public void setFocus() {
- }
-
- /**
- * Copies the current selection of the current filter as multiline text.
- *
- * @param clipboard
- * The clipboard to place the copied content.
- */
- public void copy(Clipboard clipboard) {
- // get the current table and its selection
- copyTable(clipboard, currentTab.getTable());
- }
-
- /**
- * Selects all lines.
- */
- public void selectAll() {
- currentTab.getTable().selectAll();
- }
-
- /**
- * Sets a TableFocusListener which will be notified when one of the tables
- * gets or loses focus.
- *
- * @param listener
- */
- public void setTableFocusListener(ITableFocusListener listener) {
- // record the global listener, to make sure table created after
- // this call will still be setup.
- globalListener = listener;
-
- for (LogTab tab : tabs) {
- addTableToFocusListener(tab.getTable());
- }
- }
-
- /**
- * Sets up a Table object to notify the global Table Focus listener when it
- * gets or loses the focus.
- *
- * @param table
- * the Table object.
- */
- private void addTableToFocusListener(final Table table) {
- // create the activator for this table
- final IFocusedTableActivator activator = new IFocusedTableActivator() {
- @Override
- public void copy(Clipboard clipboard) {
- copyTable(clipboard, table);
- }
-
- @Override
- public void selectAll() {
- table.selectAll();
- }
- };
-
- // add the focus listener on the table to notify the global
- // listener
- table.addFocusListener(new FocusListener() {
- @Override
- public void focusGained(FocusEvent e) {
- globalListener.focusGained(activator);
- }
-
- @Override
- public void focusLost(FocusEvent e) {
- globalListener.focusLost(activator);
- }
- });
- }
-
- /**
- * Copies the current selection of a Table into the provided Clipboard, as
- * multi-line text.
- *
- * @param clipboard
- * The clipboard to place the copied content.
- * @param table
- * The table to copy from.
- */
- private static void copyTable(Clipboard clipboard, Table table) {
- int[] selection = table.getSelectionIndices();
-
- // we need to sort the items to be sure.
- Arrays.sort(selection);
-
- // all lines must be concatenated.
- StringBuilder sb = new StringBuilder();
-
- // loop on the selection and output the file.
- for (int i : selection) {
- TableItem item = table.getItem(i);
- LogMessage msg = (LogMessage) item.getData();
- String line = msg.toString();
- sb.append(line);
- sb.append('\n');
- }
-
- // now add that to the clipboard
- clipboard.setContents(new Object[] { sb.toString() },
- new Transfer[] { TextTransfer.getInstance() });
- }
-
-
- /**
- * saves the current selection in a text file.
- *
- * @return false if the saving failed.
- */
- public boolean save() {
- if (getCurrentLogTab() == null)
- return false;
- FileDialog dlg = new FileDialog(parent.getShell(), SWT.SAVE);
-
- dlg.setText(LogUIMessages.Log_Title_Tab_Export);
- String fileName = String.format(LogUIMessages.Log_File_Tab_Export_Postfix, getCurrentLogTab().getFilterName());
- dlg.setFileName(fileName);
- String defaultPath = defaultLogSave;
- if (defaultPath == null) {
- defaultPath = System.getProperty("user.home"); //$NON-NLS-1$
- }
- dlg.setFilterPath(defaultPath);
- dlg.setFilterNames(new String[] { LogUIMessages.Log_File_Tab_Export_Filter });
- dlg.setFilterExtensions(new String[] { LogUIMessages.Log_File_Tab_Export_Filter_Extensions });
- File check;
- boolean again;
- do {
- again = false;
- fileName = dlg.open();
- if (fileName == null)
- return false;
- check = new File(fileName);
- if (check.exists()) {
- int ret = FileDialogUtils.getInstance().checkFileOverwrite(fileName);
- if (ret == IDialogConstants.CANCEL_ID)
- again = true;
- }
- } while (again);
-
- if (fileName != null) {
- defaultLogSave = dlg.getFilterPath();
-
- // loop on the selection and output the file.
- try {
- FileWriter writer = new FileWriter(fileName);
-
- for (TableItem item : getCurrentLogTab().getTable().getItems()) {
- LogMessage msg = (LogMessage) item.getData();
- String line = msg.toString();
- writer.write(line);
- writer.write('\n');
- }
- writer.flush();
-
- } catch (IOException e) {
- return false;
- }
- }
-
- return true;
- }
-
- public void clear() {
- if (getCurrentLogTab() != null)
- this.getCurrentLogTab().clear();
- }
-
- private boolean checkTabConnection(LogTab tab, String title)
- {
- String deviceName = tab.getFilterDeviceName();
- if(deviceName == null)
- {
- String tabName = tab.getFilterName();
- String message = String.format(LogUIMessages.Log_Message_Tab_Device_Disconnected, tabName);
- DialogUtil.openErrorDialog(parent.getShell(), title, message);
- return false;
- }
- return true;
- }
-
- public void addTab() {
- LogTab tab = getCurrentLogTab();
- if (tab == null)
- return;
- if(!checkTabConnection(tab, LogUIMessages.Log_Title_Tab_AddTab_Error))
- {
- return ;
- }
-
- AddViewDialog dlg = new AddViewDialog(parent.getShell(), tab.getFilterDeviceName());
- //if base device is already disconnected,
- if(dlg.getDevice() == null)
- return ;
-
- if (dlg.open()) {
- for (IDevice device : SmartDevelopmentBridge.getBridge()
- .getDevices()) {
- if (device.getSerialNumber().equals(dlg.getDevice())) {
-
- LogTab newTab = createTab(device, dlg.getName());
- setTabRefresh(newTab);
- initViewFilter(newTab);
- newTab.setPidFilter(dlg.getPidKeyword());
- newTab.setTagFilter(dlg.getTagKeyword());
- newTab.setMsgFilter(dlg.getMsgKeyword());
-
- newTab.startLogTab();
-
- break;
- }
- }
- } else
- return;
- }
-
- public void removeTab() {
-
- int index = folders.getSelectionIndex();
- if (index < 0)
- return;
- LogTab tab = tabs.get(index);
- if (tab.isDefault()) {
- return;
- }
- tab.stopLogTab(true);
-// tab.dispose();
- folders.getItem(index).dispose();
- tabs.remove(index);
- tabCnt--;
- if (!tabs.isEmpty())
- folders.setSelection(folders.getItemCount());
- selectLogTab();
-
- }
-
- public void editTab() {
-
- LogTab oldTab = getCurrentLogTab();
- if (oldTab == null)
- return;
- if (oldTab.isDefault()) {
- return;
- }
-
- if(!checkTabConnection(oldTab, LogUIMessages.Log_Title_Tab_EditTab_Error))
- {
- return ;
- }
-
- AddViewDialog dlg = new AddViewDialog(parent.getShell(), oldTab);
- if (dlg.open()) {
- for (IDevice device : SmartDevelopmentBridge.getBridge()
- .getDevices()) {
- if (device.getSerialNumber().equals(dlg.getDevice())) {
- boolean bRestart = false;
- if (!oldTab.getFilterDeviceName().equals(
- device.getSerialNumber())) {
- oldTab.stopLogTab(true);
- oldTab.setDevice(device);
- bRestart = true;
- }
-
- for (TabItem item : folders.getItems()) {
- if (item.getText().equals(oldTab.getFilterName())) {
- item.setText(dlg.getName());
- oldTab.setFilterName(dlg.getName());
- }
- }
-
- oldTab.setPidFilter(dlg.getPidKeyword());
- oldTab.setTagFilter(dlg.getTagKeyword());
- oldTab.setMsgFilter(dlg.getMsgKeyword());
-
- if (bRestart)
- {
- oldTab.startLogTab();
- setTabRefresh(oldTab);
- initViewFilter(oldTab);
- }
- else
- {
- oldTab.refill();
- }
- break;
- }
- }
- } else
- return;
- }
-
- public static TableColumn createTableColumn(Table parent, String header,
- int style, String sampleText) {
-
- // create the column
- TableColumn col = new TableColumn(parent, style);
-
- col.setText(sampleText);
- col.pack();
-
- // set the header
- col.setText(header);
-
- return col;
- }
-
- public LogTab getCurrentLogTab() {
- if (tabs.size() != 0) {
- int index = folders.getSelectionIndex();
- LogTab tab = tabs.get(index);
- setTabRefresh(tab);
- return tab;
- } else
- return null;
- }
-
- private void setTabRefresh(LogTab tab)
- {
- for(LogTab anytab : tabs)
- {
- anytab.setPendingAsyncRefresh(false);
- }
- tab.setPendingAsyncRefresh(true);
- }
-
- public void stopAll() {
- for (LogTab tab : tabs) {
- tab.stopLogTab(true);
- }
- tabs.clear();
- tabCnt = 0;
- folders.dispose();
- }
-
- @Override
- public void deviceConnected(IDevice device) {
- if (device.isOnline()) {
- deviceChanged(device, 1);
- }
- }
-
- @Override
- public void deviceDisconnected(final IDevice device) {
- if (parent.isDisposed() == false) {
- Display display = parent.getDisplay();
- display.asyncExec(new Runnable() {
- @Override
- public void run() {
- if (parent.isDisposed() == false) {
- String deviceSN = device.getSerialNumber();
- String title = LogUIMessages.Log_Title_View_Device_Disconnected;
- String message = String.format(LogUIMessages.Log_Message_View_Device_Disconnected, deviceSN, deviceSN);
- NotifierDialog.notify(title, message, NotificationType.DISCONNECTED);
- }
- }
- });
- }
-
- }
-
- @Override
- public void deviceChanged(final IDevice device, int changeMask) {
- if (changeMask == 1) {
- if (parent.isDisposed() == false) {
- Display display = parent.getDisplay();
- display.asyncExec(new Runnable() {
- @Override
- public void run() {
- if (folders.isDisposed() == false) {
- LogTab tab = createDefaultTab(device, null);
- selectLogTab();
- tab.startLogTab();
- } else {
- SmartDevelopmentBridge
- .removeDeviceChangeListener(LogPanel.this);
- }
- }
- });
- }
- }
- }
-
- public void setActionEnabled(int enable) {
-
- if (enable == ACTION_NOTHING) {
-
- addAction.setEnabled(false);
- removeAction.setEnabled(false);
- editAction.setEnabled(false);
- exportAction.setEnabled(false);
- clearAction.setEnabled(false);
- for (Action a : levelActions) {
- a.setEnabled(false);
- }
- } else if (enable == ACTION_DEVICE_TAB) {
- addAction.setEnabled(true);
- removeAction.setEnabled(false);
- editAction.setEnabled(false);
- exportAction.setEnabled(true);
- clearAction.setEnabled(true);
- for (Action a : levelActions) {
- a.setEnabled(true);
- }
- } else if (enable == ACTION_ADDITIONAL_TAB) {
- addAction.setEnabled(true);
- removeAction.setEnabled(true);
- editAction.setEnabled(true);
- exportAction.setEnabled(true);
- clearAction.setEnabled(true);
- for (Action a : levelActions) {
- a.setEnabled(true);
- }
- }
- }
+public class LogPanel extends Panel implements IDeviceChangeListener
+{
+
+ //Nothing enabled
+ public static final int NO_TAB = 0;
+ //Only remove disabled
+ public static final int DEVICE_TAB = 1;
+ //Everything enabled
+ public static final int ADDITIONAL_TAB = 2;
+ //Only add, edit disabled
+ public static final int DISCONNECTED_TAB = 3;
+
+ private final int ENABLE_ADD = 0x0000001;
+ private final int ENABLE_REMOVE = 0x0000010;
+ private final int ENABLE_EDIT = 0x0000100;
+ private final int ENABLE_SCROLL_LOCK = 0x0001000;
+ private final int ENABLE_EXPORT = 0x0010000;
+ private final int ENABLE_CLEAR = 0x0100000;
+ private final int ENABLE_LEVEL = 0x1000000;
+
+ private final int[] ENABLE_VIEW_ACTIONS= { ENABLE_ADD, ENABLE_REMOVE, ENABLE_EDIT,
+ ENABLE_SCROLL_LOCK, ENABLE_EXPORT, ENABLE_CLEAR};
+
+ private String defaultLogSave;
+
+ private Composite parent;
+ private TabFolder tabFolder;
+
+ private final LogColors colors;
+
+ private Action[] levelActions;
+ private Action[] viewActions;
+
+ private StackLayout stackLayout;
+
+ public static List<LogTab> logTabList = new ArrayList<LogTab>();
+
+ /** message data, separated from content for multi line messages */
+ protected static class LogMessageInfo
+ {
+ public LogLevel logLevel;
+ public String pidString;
+ public String tag;
+ public String time;
+ }
+
+ private ITableFocusListener globalListener;
+
+ /** message data, separated from content for multi line messages */
+ protected static class LogMessage
+ {
+ public LogMessageInfo data;
+ public String msg;
+
+ @Override
+ public String toString()
+ {
+ return data.time + ": " + data.logLevel + "/" + data.tag + "(" + data.pidString + "): " + msg;
+ }
+ }
+
+ /**
+ * Create the log panel with some default parameters
+ *
+ * @param colors
+ * The display color object
+ */
+ public LogPanel(LogColors pColors)
+ {
+ colors = pColors;
+ }
+
+ public void setActions(Action[] levelActs, Action[] toolbarActs)
+ {
+ levelActions = levelActs;
+ viewActions = toolbarActs;
+ }
+
+ /**
+ * Creates a control capable of displaying some information. This is called
+ * once, when the application is initializing, from the UI thread.
+ */
+ @Override
+ protected Control createControl(Composite p)
+ {
+ parent = p;
+
+ // create the tab folder
+ tabFolder = new TabFolder(parent, SWT.NONE);
+ tabFolder.setLayoutData(new GridData(GridData.FILL_BOTH));
+ //use stack layout
+ stackLayout = new StackLayout();
+ tabFolder.setLayout(stackLayout);
+ tabFolder.addSelectionListener(new SelectionAdapter()
+ {
+ @Override
+ public void widgetSelected(SelectionEvent e)
+ {
+ selectTabItem();
+ }
+ });
+
+ SmartDevelopmentBridge.addDeviceChangeListener(this);
+ // Create default device tab if device(s) is connected
+ createDefaultTabs();
+ return null;
+ }
+
+ @Override
+ protected void postCreation()
+ {
+ }
+
+ /**
+ * Sets the focus to the proper object.
+ */
+ @Override
+ public void setFocus()
+ {
+ }
+
+ /**
+ * do something when select TabItem
+ */
+ private void selectTabItem()
+ {
+ int index = tabFolder.getSelectionIndex();
+ if(index == -1)
+ {
+ return ;
+ }
+ TabItem item = tabFolder.getItem(index);
+ LogTab logTab = getSelectionLogTab();
+ if(logTab == null)
+ {
+ return ;
+ }
+
+ setEnableAndCheckState(logTab);
+ stackLayout.topControl = item.getControl();
+ }
+
+
+ /**
+ * Set action enable state depending on a logTab type.
+ * And then set check state.
+ * @param logTab
+ */
+ private void setEnableAndCheckState(LogTab logTab)
+ {
+ String serial = logTab.getDeviceSerialNumber();
+ //if device is disconnected, only remove enabled.
+ if(serial == null)
+ {
+ setEnabledForActions(LogPanel.DISCONNECTED_TAB);
+ }
+ else
+ {
+ if (logTab.isDefault())
+ {
+ setEnabledForActions(LogPanel.DEVICE_TAB);
+ }
+ else
+ {
+ setEnabledForActions(LogPanel.ADDITIONAL_TAB);
+ }
+ }
+ setCheckActionState(logTab);
+ }
+
+ /**
+ * When user selects level icons, set level values and filter messages.
+ * @param level level type(Debug, Info, Error..)
+ * @param setCheck is Checked or not
+ */
+ public void setLevel(int level, boolean setCheck)
+ {
+ int levelMode = getSelectionLogTab().getLevelMode();
+ level = (int) Math.pow(2, level);
+
+ if (setCheck)
+ {
+ levelMode |= level;
+ }
+ else
+ {
+ levelMode &= (~level);
+ }
+
+ getSelectionLogTab().setLevelMode(levelMode);
+ getSelectionLogTab().filterMessages();
+ }
+
+ // create the logtab with default devices
+ private void createDefaultTabs()
+ {
+ for (IDevice device : getDevices())
+ {
+ if (device.isOffline())
+ continue;
+ LogTab dTab = createLogTab(ConnectionExplorerLabelProvider.getDeviceSerialWithName(device), device, true);
+ dTab.start();
+ }
+ }
+
+ /**
+ * Create LogTab and TabItem and
+ * set action and icon status
+ * @param device IDevice to get logs
+ * @param name logtab name
+ * @param isDefault check this is default logtab for device
+ * @return
+ */
+ private LogTab createLogTab(String name, IDevice device, boolean isDefault)
+ {
+ Iterator<LogTab> iter = logTabList.iterator();
+ while( iter.hasNext())
+ {
+ LogTab oldTab = iter.next();
+ if(oldTab.getLogTabName().equals(name))
+ {
+ removeTab(oldTab);
+ iter.remove();
+ }
+ }
+
+ LogTab logTab = new LogTab(name, device, colors);
+ if (isDefault)
+ {
+
+ logTab.setDefault();
+ setEnabledForActions(LogPanel.DEVICE_TAB);
+ } else
+ {
+ setEnabledForActions(LogPanel.ADDITIONAL_TAB);
+ }
+ setCheckActionState(logTab);
+
+ logTabList.add(logTab);
+ createTabItem(tabFolder, logTab);
+
+ return logTab;
+ }
+
+ /**
+ * create TabItem and set to LogTab
+ * @param tabFolder
+ * @param logTab
+ * @return
+ */
+ private Control createTabItem(TabFolder tabFolder, final LogTab logTab)
+ {
+ // Create a composite and add four buttons to it
+ Composite composite = new Composite(tabFolder, SWT.NONE);
+ composite.setLayoutData(new GridData(GridData.FILL_VERTICAL));
+ composite.setLayout(new GridLayout(1, false));
+
+ Composite top = new Composite(composite, SWT.NONE);
+ top.setLayoutData(new GridData(GridData.FILL_BOTH));
+ top.setLayout(new FillLayout());
+
+ final Table table = new Table(top, SWT.MULTI | SWT.FULL_SELECTION | SWT.BORDER | SWT.H_SCROLL);
+
+ table.setHeaderVisible(true);
+ table.setLinesVisible(true);
+
+ if (globalListener != null)
+ {
+ addTableToFocusListener(table);
+ }
+
+ ControlListener listener = null;
+ listener = new ControlListener()
+ {
+ @Override
+ public void controlMoved(ControlEvent e)
+ {
+ }
+
+ @Override
+ public void controlResized(ControlEvent e)
+ {
+ Rectangle r = table.getClientArea();
+
+ // get the size of all but the last column
+ int total = table.getColumn(0).getWidth();
+ total += table.getColumn(1).getWidth();
+ total += table.getColumn(2).getWidth();
+ total += table.getColumn(3).getWidth();
+ //
+ if (r.width > total)
+ {
+ table.getColumn(4).setWidth(r.width - total);
+ }
+ }
+ };
+
+ table.addControlListener(listener);
+
+ TableColumn col = createTableColumn(table, "Time", SWT.LEFT, "00-00 00:00:00.000");
+ col.addControlListener(listener);
+
+ col = createTableColumn(table, "Level", SWT.LEFT, "Verbose");
+ col.addControlListener(listener);
+
+ col = createTableColumn(table, "Pid", SWT.LEFT, "9999999");
+ col.addControlListener(listener);
+
+ col = createTableColumn(table, "Tag", SWT.LEFT, "ABCDEFGHIJK");
+ col.addControlListener(listener);
+
+ col = createTableColumn(table, "Message", SWT.LEFT, "abcdefghijklmnopqrstuvwxyz0123456789");
+ // col.setResizable(false);
+
+ Composite bottom = new Composite(composite, SWT.NONE);
+ bottom.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
+ bottom.setLayout(new GridLayout(3, false));
+
+ Combo filterComboOnView = new Combo(bottom, SWT.READ_ONLY);
+ String[] comboItems = { "Pid", "Tag", "Message" };
+ filterComboOnView.setItems(comboItems);
+ filterComboOnView.select(2);
+ filterComboOnView.setToolTipText(LogUIMessages.Log_Tooltip_View_Filter_Combo);
+ filterComboOnView.addSelectionListener(new SelectionListener()
+ {
+ @Override
+ public void widgetSelected(SelectionEvent e)
+ {
+ Combo combo = (Combo) e.widget;
+ getSelectionLogTab().setFilterCombo(combo.getSelectionIndex());
+ getSelectionLogTab().filterMessages();
+ }
+
+ @Override
+ public void widgetDefaultSelected(SelectionEvent e)
+ {
+ }
+ });
+
+ Text filterTextOnView = new Text(bottom, SWT.SINGLE | SWT.BORDER);
+ filterTextOnView.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
+ filterTextOnView.setMessage(LogUIMessages.Log_Message_View_Filter_Text);
+ filterTextOnView.addModifyListener(new ModifyListener()
+ {
+ @Override
+ public void modifyText(ModifyEvent e)
+ {
+ Text text = (Text) e.widget;
+ getSelectionLogTab().setFilterText(text.getText());
+ getSelectionLogTab().filterMessages();
+ }
+ });
+
+ TabItem tabItem = new TabItem(tabFolder, SWT.NONE, tabFolder.getItemCount());
+ tabItem.setText(logTab.getLogTabName());
+ tabItem.setControl(composite);
+ logTab.setTable(table);
+ logTab.setTabItem(tabItem);
+ tabFolder.setSelection(tabItem);
+ stackLayout.topControl = tabItem.getControl();
+
+ return composite;
+ }
+
+ /**
+ * Copies the current selection of the current filter as multiline text.
+ *
+ * @param clipboard
+ * The clipboard to place the copied content.
+ */
+ public void copy(Clipboard clipboard)
+ {
+ // get the current table and its selection
+ copyTable(clipboard, getSelectionLogTab().getTable());
+ }
+
+ /**
+ * Selects all lines.
+ */
+ public void selectAll()
+ {
+ getSelectionLogTab().getTable().selectAll();
+ }
+
+ /**
+ * Sets a TableFocusListener which will be notified when one of the tables
+ * gets or loses focus.
+ *
+ * @param listener
+ */
+ public void setTableFocusListener(ITableFocusListener listener)
+ {
+ // record the global listener, to make sure table created after
+ // this call will still be setup.
+ globalListener = listener;
+
+ for (LogTab tab : logTabList)
+ {
+ addTableToFocusListener(tab.getTable());
+ }
+ }
+
+ /**
+ * Sets up a Table object to notify the global Table Focus listener when it
+ * gets or loses the focus.
+ *
+ * @param table
+ * the Table object.
+ */
+ private void addTableToFocusListener(final Table table)
+ {
+ // create the activator for this table
+ final IFocusedTableActivator activator = new IFocusedTableActivator()
+ {
+ @Override
+ public void copy(Clipboard clipboard)
+ {
+ copyTable(clipboard, table);
+ }
+
+ @Override
+ public void selectAll()
+ {
+ table.selectAll();
+ }
+ };
+
+ // add the focus listener on the table to notify the global
+ // listener
+ table.addFocusListener(new FocusListener()
+ {
+ @Override
+ public void focusGained(FocusEvent e)
+ {
+ globalListener.focusGained(activator);
+ }
+
+ @Override
+ public void focusLost(FocusEvent e)
+ {
+ globalListener.focusLost(activator);
+ }
+ });
+ }
+
+ /**
+ * Copies the current selection of a Table into the provided Clipboard, as
+ * multi-line text.
+ *
+ * @param clipboard
+ * The clipboard to place the copied content.
+ * @param table
+ * The table to copy from.
+ */
+ private static void copyTable(Clipboard clipboard, Table table)
+ {
+ int[] selection = table.getSelectionIndices();
+
+ // we need to sort the items to be sure.
+ Arrays.sort(selection);
+
+ // all lines must be concatenated.
+ StringBuilder sb = new StringBuilder();
+
+ // loop on the selection and output the file.
+ for (int i : selection)
+ {
+ TableItem item = table.getItem(i);
+ LogMessage msg = (LogMessage) item.getData();
+ String line = msg.toString();
+ sb.append(line);
+ sb.append('\n');
+ }
+
+ // now add that to the clipboard
+ clipboard.setContents(new Object[] { sb.toString() }, new Transfer[] { TextTransfer.getInstance() });
+ }
+
+ public boolean save()
+ {
+ if (getSelectionLogTab() == null)
+ return false;
+ FileDialog dlg = new FileDialog(parent.getShell(), SWT.SAVE);
+
+ dlg.setText(LogUIMessages.Log_Title_Tab_Export);
+ String saveName = String.format(LogUIMessages.Log_File_Tab_Export_Postfix, getSelectionLogTab().getLogTabName());
+
+ dlg.setFileName(saveName);
+ String defaultPath = defaultLogSave;
+ if (defaultPath == null)
+ {
+ defaultPath = System.getProperty("user.home"); //$NON-NLS-1$
+ }
+ dlg.setFilterPath(defaultPath);
+ dlg.setFilterNames(new String[] { LogUIMessages.Log_File_Tab_Export_Filter });
+ dlg.setFilterExtensions(new String[] { LogUIMessages.Log_File_Tab_Export_Filter_Extensions });
+
+ String fileName = null;
+ boolean again;
+ do
+ {
+ File checkFile;
+ again = false;
+ fileName = dlg.open();
+ if (fileName == null)
+ return false;
+ checkFile = new File(fileName);
+ if (checkFile.exists())
+ {
+ int ret = FileDialogUtils.allowFileOverwrite(fileName);
+ if( ret == IDialogConstants.CANCEL_ID)
+ again = true;
+ }
+ } while (again);
+
+ defaultLogSave = dlg.getFilterPath();
+
+ // loop on the selection and output the file.
+ try
+ {
+ FileWriter writer = new FileWriter(fileName);
+
+ for (TableItem item : getSelectionLogTab().getTable().getItems())
+ {
+ LogMessage msg = (LogMessage) item.getData();
+ String line = msg.toString();
+ writer.write(line);
+ writer.write('\n');
+ }
+ writer.flush();
+
+ } catch (IOException e)
+ {
+ return false;
+ }
+
+ return true;
+ }
+
+ /**
+ *
+ */
+ public void clear()
+ {
+ LogTab tab = getSelectionLogTab();
+ if ( tab != null)
+ tab.clear();
+ }
+
+ /**
+ * check whether device is still connected or not
+ * then notify with dialog
+ *
+ * @param tab target to check device connection
+ * @param title dialog title
+ * @return if device is disconnected, return false
+ */
+ private boolean checkTabConnection(LogTab tab, String title)
+ {
+ String deviceName = tab.getDeviceSerialNumber();
+ if (deviceName == null)
+ {
+ String tabName = tab.getLogTabName();
+ String message = String.format(LogUIMessages.Log_Message_Tab_Device_Disconnected, tabName);
+ DialogUtil.openErrorDialog(parent.getShell(), title, message);
+ return false;
+ }
+ return true;
+ }
+
+ /**
+ * add addtional TabItem and LogTab
+ */
+ public void addTab()
+ {
+ LogTab tab = getSelectionLogTab();
+
+ if (tab == null)
+ return;
+
+ if (!checkTabConnection(tab, LogUIMessages.Log_Title_Tab_AddTab_Error))
+ {
+ return;
+ }
+
+ AddViewDialog dlg = new AddViewDialog(parent.getShell(), tab.getDeviceSerialNumber());
+
+ if (dlg.getDevice() == null)
+ return;
+
+ if (dlg.open())
+ {
+ for (IDevice device : getDevices())
+ {
+ if (device.getSerialNumber().equals(dlg.getDevice()))
+ {
+
+ LogTab newTab = createLogTab(dlg.getName(), device, false);
+ // set filter values from addViewDialog
+ newTab.setPidFilter(dlg.getPidKeyword());
+ newTab.setTagFilter(dlg.getTagKeyword());
+ newTab.setMsgFilter(dlg.getMsgKeyword());
+
+ newTab.start();
+
+ break;
+ }
+ }
+ } else
+ return;
+ }
+
+ public void removeTab(LogTab tab)
+ {
+ tab.stop(true);
+ SWTUtil.tryDispose(tab.getTabItem());
+ }
+
+ /**
+ * remove selected TabItem and LogTab
+ */
+ public void removeTab()
+ {
+ int index = tabFolder.getSelectionIndex();
+ if (index < 0)
+ return;
+ LogTab tab = logTabList.get(index);
+ removeTab(tab);
+ logTabList.remove(tab);
+ if(logTabList.isEmpty())
+ {
+ setEnabledForActions(NO_TAB);
+ }
+ }
+
+ /**
+ * edit selected TabItem and LogTab
+ */
+ public void editTab()
+ {
+
+ LogTab oldTab = getSelectionLogTab();
+
+ if (oldTab == null)
+ return;
+
+ if (oldTab.isDefault())
+ {
+ return;
+ }
+
+ if (!checkTabConnection(oldTab, LogUIMessages.Log_Title_Tab_EditTab_Error))
+ {
+ return;
+ }
+
+ AddViewDialog dlg = new AddViewDialog(parent.getShell(), oldTab);
+ if (dlg.open())
+ {
+ for (IDevice device : getDevices())
+ {
+ if (device.getSerialNumber().equals(dlg.getDevice()))
+ {
+ oldTab.stop(true);
+ oldTab.setDevice(device);
+
+ for (TabItem item : tabFolder.getItems())
+ {
+ if (item.getText().equals(oldTab.getLogTabName()))
+ {
+ item.setText(dlg.getName());
+ oldTab.setLogTabName(dlg.getName());
+ }
+ }
+
+ oldTab.setPidFilter(dlg.getPidKeyword());
+ oldTab.setTagFilter(dlg.getTagKeyword());
+ oldTab.setMsgFilter(dlg.getMsgKeyword());
+
+ oldTab.start();
+
+ break;
+ }
+ }
+ }
+ }
+
+ public static TableColumn createTableColumn(Table parent, String header, int style, String sampleText)
+ {
+
+ // create the column
+ TableColumn col = new TableColumn(parent, style);
+
+ col.setText(sampleText);
+ col.pack();
+
+ // set the header
+ col.setText(header);
+
+ return col;
+ }
+
+ /**
+ * get selected logtab from tabitem on folder
+ * @return
+ */
+ public LogTab getSelectionLogTab()
+ {
+ if (logTabList.size() != 0)
+ {
+ int index = tabFolder.getSelectionIndex();
+ TabItem item = tabFolder.getItem(index);
+
+ for(LogTab logTab : logTabList)
+ {
+ if(logTab.getTabItem() == item)
+ return logTab;
+ }
+ }
+ return null;
+ }
+
+ public void stopAllTabItems()
+ {
+ for (LogTab tab : logTabList)
+ {
+ removeTab(tab);
+ }
+ logTabList.clear();
+ }
+
+ private IDevice[] getDevices()
+ {
+ IDevice[] devices;
+ SmartDevelopmentBridge sdbBridge = SmartDevelopmentBridge.getBridge();
+ if(sdbBridge != null)
+ devices = sdbBridge.getDevices();
+ else
+ devices = new IDevice[0];
+ return devices;
+ }
+
+ @Override
+ public void deviceConnected(IDevice device)
+ {
+ if (device.isOnline())
+ {
+ deviceChanged(device, 1);
+ }
+ }
+
+ @Override
+ public void deviceDisconnected(final IDevice device)
+ {
+
+ if (parent.isDisposed() == false)
+ {
+ Display display = parent.getDisplay();
+ display.asyncExec(new Runnable()
+ {
+ @Override
+ public void run()
+ {
+ if (parent.isDisposed() == false)
+ {
+ String name = ConnectionExplorerLabelProvider.getDeviceSerialWithName(device);
+ String title = LogUIMessages.Log_Title_View_Device_Disconnected;
+ String message = String.format(LogUIMessages.Log_Message_View_Device_Disconnected, name, name);
+ NotifierDialog.notify(title, message, NotificationType.DISCONNECTED);
+ for( LogTab tab : logTabList)
+ {
+ if(device.getSerialNumber().equals(tab.getDeviceSerialNumber()))
+ {
+ tab.setDevice(null);
+ }
+ }
+ setEnabledForActions(LogPanel.DISCONNECTED_TAB);
+
+ } else
+ {
+ SmartDevelopmentBridge.removeDeviceChangeListener(LogPanel.this);
+ }
+ }
+ });
+ }
+ }
+
+ @Override
+ public void deviceChanged(final IDevice device, int changeMask)
+ {
+ if (changeMask == 1)
+ {
+ if (parent.isDisposed() == false)
+ {
+ Display display = parent.getDisplay();
+ display.asyncExec(new Runnable()
+ {
+ @Override
+ public void run()
+ {
+ if (tabFolder.isDisposed() == false)
+ {
+ LogTab tab = createLogTab(ConnectionExplorerLabelProvider.getDeviceSerialWithName(device), device, true);
+ tab.start();
+ } else
+ {
+ SmartDevelopmentBridge.removeDeviceChangeListener(LogPanel.this);
+ }
+ }
+ });
+ }
+ }
+ }
+
+ /**
+ * Get enabled state for each action with state value.
+ * @param state
+ * @param action
+ * @return
+ */
+ private boolean getEnabled(int state, int action)
+ {
+ int result = (state & action);
+ return result != 0 ? true : false;
+ }
+
+ private void setEnableState(int state)
+ {
+ for(int i = 0; i < viewActions.length; i++)
+ {
+ viewActions[i].setEnabled(getEnabled(state, ENABLE_VIEW_ACTIONS[i]));
+ }
+
+ boolean check = getEnabled(state, ENABLE_LEVEL);
+ for (Action level : levelActions)
+ {
+ level.setEnabled(check);
+ }
+ }
+
+ /**
+ * Set checked state for action(loglevel, scroll lock) depending on a logTab
+ * when create new logtab or select the logtab.
+ */
+ private void setCheckActionState(LogTab tab)
+ {
+ int levelMode = tab.getLevelMode();
+ for (int i = 0; i < 5; i++)
+ {
+ int a = levelMode & (0x1 << i);
+ levelActions[i].setChecked(a == (int) Math.pow(2, i));
+ }
+
+ //Scroll lock action is toggle action
+ viewActions[3].setChecked(tab.getScrollLock());
+ }
+
+ /**
+ * Get enabled state for action depending on a logTab type.
+ */
+ public int getEnabledStateForActions(int tabType)
+ {
+ int enable = 0x0000000;
+
+ if (tabType == NO_TAB)
+ {
+ }
+ else if (tabType == DEVICE_TAB)
+ {
+ enable = ENABLE_ADD | ENABLE_SCROLL_LOCK | ENABLE_EXPORT | ENABLE_CLEAR | ENABLE_LEVEL;
+ }
+ else if (tabType == ADDITIONAL_TAB)
+ {
+ enable = ENABLE_ADD | ENABLE_REMOVE | ENABLE_EDIT | ENABLE_SCROLL_LOCK | ENABLE_EXPORT | ENABLE_CLEAR | ENABLE_LEVEL;
+ }
+ else if (tabType == DISCONNECTED_TAB)
+ {
+ enable = ENABLE_REMOVE | ENABLE_EXPORT | ENABLE_LEVEL;
+ }
+
+ return enable;
+ }
+
+ /**
+ * Get enabled state and set enabled state for action depending on a logTab type
+ * (NO_TAB, DEVICE_TAB, ADDITIONAL_TAB).
+ * @param tabType
+ */
+ public void setEnabledForActions(int tabType)
+ {
+ int mode = getEnabledStateForActions(tabType);
+ setEnableState(mode);
+ }
+
+ /**
+ * Set scroll locked or unlocked.
+ * @param lock
+ */
+ public void setScrollLock(boolean lock)
+ {
+ getSelectionLogTab().setScrollLock(lock);
+ }
} \ No newline at end of file
diff --git a/org.tizen.common.connection/src/org/tizen/common/connection/log/LogTab.java b/org.tizen.common.connection/src/org/tizen/common/connection/log/LogTab.java
index 9c6f57432..bfd7b6d4d 100644
--- a/org.tizen.common.connection/src/org/tizen/common/connection/log/LogTab.java
+++ b/org.tizen.common.connection/src/org/tizen/common/connection/log/LogTab.java
@@ -1,820 +1,827 @@
/*
-* Common
-*
-* Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved.
-*
-* Contact:
-* Hoon Kang <h245.kang@samsung.com>
-* Hyunsik Noh <hyunsik.noh@samsung.com>
-*
+ * Common
+ *
+ * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved.
+ *
+ * Contact:
+ * Hoon Kang <h245.kang@samsung.com>
+ * Hyunsik Noh <hyunsik.noh@samsung.com>
+ *
* Licensed under the Apache License, Version 2.0 (the "License");
-* you may not use this file except in compliance with the License.
-* You may obtain a copy of the License at
-*
-* http://www.apache.org/licenses/LICENSE-2.0
-*
-* Unless required by applicable law or agreed to in writing, software
-* distributed under the License is distributed on an "AS IS" BASIS,
-* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-* See the License for the specific language governing permissions and
-* limitations under the License.
-*
-* Contributors:
-* - S-Core Co., Ltd
-*
-*/
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ * Contributors:
+ * - S-Core Co., Ltd
+ *
+ */
package org.tizen.common.connection.log;
import java.util.ArrayList;
+import java.util.List;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
-import org.eclipse.jface.action.Action;
import org.eclipse.swt.SWT;
import org.eclipse.swt.SWTException;
import org.eclipse.swt.widgets.Display;
-import org.eclipse.swt.widgets.ScrollBar;
import org.eclipse.swt.widgets.TabItem;
import org.eclipse.swt.widgets.Table;
import org.eclipse.swt.widgets.TableItem;
import org.tizen.common.connection.log.LogPanel.LogMessage;
import org.tizen.common.connection.log.LogPanel.LogMessageInfo;
-import org.tizen.common.console.AnsicodeAdapter;
+import org.tizen.common.ui.view.console.AnsicodeAdapter;
+import org.tizen.common.util.StringUtil;
+import org.tizen.common.util.log.Logger;
import org.tizen.sdblib.IDevice;
-import org.tizen.sdblib.Log;
import org.tizen.sdblib.Log.LogLevel;
import org.tizen.sdblib.MultiLineReceiver;
-public class LogTab {
-
- private static final int STRING_BUFFER_LENGTH = 10000;
-
- public static final int FILTER_NONE = -1;
- public static final int FILTER_PID = 0x0;
- public static final int FILTER_TAG = 0x1;
- public static final int FILTER_MSG = 0x2;
-
- public static final int LEVEL_ALL = 0x1F;
- public static final int LEVEL_VERBOSE = 0x1;
- public static final int LEVEL_DEBUG = 0x2;
- public static final int LEVEL_INFO = 0x4;
- public static final int LEVEL_WARNING = 0x8;
- public static final int LEVEL_ERROR = 0x16;
-
- /**
- * Single level log level as defined in Log.mLevelChar. Only valid if mMode
- * is MODE_LEVEL
- */
- private int levelMode = LEVEL_ALL;
-
- private String[] pidFilter = null;
- private String[] tagFilter = null;
- private String[] msgFilter = null;
-
- private String pidFilterString = null;
- private String tagFilterString = null;
- private String msgFilterString = null;
-
- private int filterIndexFromPanel = FILTER_MSG;
- private String filterKeywordFromPanel = "";
-
- private String filterName = null;
- private IDevice filterDevice = null;
- private LogTabOuputReceiver logger = null;
- private LogColors colors;
-
- private Table table;
- private TabItem tabItem;
-
- private static Pattern logPattern = Pattern
- .compile("^\\[\\s(\\d\\d-\\d\\d\\s\\d\\d:\\d\\d:\\d\\d\\.\\d+)" + //$NON-NLS-1$
- "\\s+(\\d*):\\s*(\\d+)\\s([VDIWE])/(.+)\\s+\\]$");
-
- private final ArrayList<LogMessage> tableMessages = new ArrayList<LogMessage>();
- private final ArrayList<LogMessage> newMessages = new ArrayList<LogMessage>();
- private final LogMessage[] buffer = new LogMessage[STRING_BUFFER_LENGTH];
-
- private LogMessageInfo lastMessageInfo = null;
- private boolean pendingAsyncRefresh = false;
-
- private boolean isDefault = false;
- private int removedMessageCount = 0;
-
- private int indexStart = -1;
- private int indexEnd = -1;
-
- public LogTab(String pName, IDevice pDevice, LogColors pColors) {
- filterName = pName;
- filterDevice = pDevice;
- this.colors = pColors;
- }
-
- public LogTab() {
- }
-
- /** Sets the name of the filter. */
- public void setFilterName(String name) {
- filterName = name;
- }
-
- public void setPidFilter(String pid) {
- pidFilterString = pid;
- if (pid != null)
- pidFilter = setFilter(pid.split("[\\s\t,]"));
- else
- pidFilter = null;
- }
-
- public void setTagFilter(String tag) {
- tagFilterString = tag;
- if (tag != null)
- tagFilter = setFilter(tag.split("[\\s\t,]"));
- else
- tagFilter = null;
- }
-
- public void setMsgFilter(String msg) {
- msgFilterString = msg;
- if (msg != null)
- msgFilter = setFilter(msg.split("[\\s\t,]"));
- else
- msgFilter = null;
- }
-
- private String[] setFilter(String[] array) {
- ArrayList<String> result = new ArrayList<String>();
- for (String s : array) {
- if (s.length() > 0) {
- result.add(s);
- }
- }
- return result.toArray(new String[(result.size())]);
- }
-
- public String getFilterName() {
- return filterName;
- }
-
- public int getLevelMode() {
- return levelMode;
- }
-
- public String getPidFilter() {
- return pidFilterString;
- }
-
- public String getTagFilter() {
- return tagFilterString;
- }
-
- public String getMsgFilter() {
- return msgFilterString;
- }
-
- public String getFilterDeviceName() {
- if(filterDevice != null)
- return filterDevice.getSerialNumber();
- else
- return null;
- }
-
- public void setTab(TabItem pTabItem) {
- tabItem = pTabItem;
- }
-
- public void setTable(Table pTable) {
- table = pTable;
- }
-
- public boolean uiReady() {
- return (table != null && tabItem != null);
- }
-
- /**
- * Returns the UI table object.
- *
- * @return
- */
- public Table getTable() {
- return table;
- }
-
- public void dispose() {
- Display d = tabItem.getDisplay();
-
- d.syncExec(new Runnable() {
- @Override
- public void run() {
- if (tabItem.isDisposed() == false) {
- tabItem.dispose();
- }
- }
- });
- table = null;
- tabItem = null;
- }
-
- public void startLogTab() {
-
- resetUI(false);
-
- if (filterDevice != null) {
-
- // create a new output receiver
- logger = new LogTabOuputReceiver();
-
- // start the LogTab in a different thread
- new Thread(filterDevice.getSerialNumber() + " Logger") { //$NON-NLS-1$
- @Override
- public void run() {
-
- while (filterDevice.isOnline() == false && logger != null && logger.isCancelled == false) {
- try {
- sleep(2000);
- } catch (InterruptedException e) {
- Log.e("LogTab",
- "Device is not online or logger is null/cancelled");
- return;
- }
- }
-
- if (logger == null || logger.isCancelled) {
- return;
- }
-
- try {
-
- filterDevice.executeShellCommand(
- "dlogutil -v long *:v", logger, 0 /* timeout */); //$NON-NLS-1$
- } catch (Exception e) {
- Log.e("LogTab", e);
- } finally {
- logger = null;
- filterDevice = null;
- stopLogTab(false);
- }
- }
- } .start();
- }
- }
-
- /** Stop the current LogTab */
- public void stopLogTab(boolean inUiThread) {
- if (logger != null) {
- logger.isCancelled = true;
-
- logger = null;
-
- clear();
-
- resetUI(inUiThread);
- }
- }
-
- //add message to tableMessages(filtered message) and replace old message to new message
- public boolean addMessage(LogMessage newMessage, LogMessage oldMessage) {
- synchronized (tableMessages) {
- if (oldMessage != null) {
- int index = tableMessages.indexOf(oldMessage);
- if (index != -1) {
- tableMessages.remove(index);
- removedMessageCount++;
- }
-
- index = tableMessages.indexOf(oldMessage);
- if (index != -1) {
- tableMessages.remove(index);
- }
- }
-
- boolean filter = accept(newMessage);
-
- if (filter) {
- tableMessages.add(newMessage);
- newMessages.add(newMessage);
- }
-
- return filter;
- }
- }
-
- boolean accept(LogMessage logMessage) {
- if (logMessage == null)
- return false;
-
- if (levelMode != LEVEL_ALL) {
- int a = 0;
- a = (levelMode & (0x1 << (logMessage.data.logLevel.getPriority() - 2)));
-
- if (a == 0)
- return false;
- }
-
- if (pidFilter != null || tagFilter != null || msgFilter != null) {
- if (pidFilter != null) {
- for (String filter : pidFilter) {
- if (logMessage.data.pidString.contains(
- filter))
- if (tableAccept(logMessage))
- return true;
- }
- }
-
- if (tagFilter != null) {
- for (String filter : tagFilter) {
- if (logMessage.data.tag.toLowerCase().contains(
- filter.toLowerCase()))
- if (tableAccept(logMessage))
- return true;
- }
- }
-
- if (msgFilter != null) {
- for (String filter : msgFilter) {
- if (logMessage.msg.toLowerCase().contains(
- filter.toLowerCase()))
- if (tableAccept(logMessage))
- return true;
- }
- }
- return false;
- }
- if (tableAccept(logMessage))
- return true;
- else
- return false;
- }
-
- public void flush() {
-
- ScrollBar bar = table.getVerticalBar();
- boolean scroll = bar.getMaximum() == bar.getSelection() + bar.getThumb();
-
- int topIndex = table.getTopIndex();
-
- table.setRedraw(false);
-
- int totalCount = newMessages.size();
-
- try {
- // remove the items of the old messages.
- for (int i = 0; i < removedMessageCount && table.getItemCount() > 0; i++) {
- table.remove(0);
- }
-
- // add the new items
- for (int i = 0; i < totalCount; i++) {
- LogMessage msg = newMessages.get(i);
- addTableItem(msg);
- }
- } catch (SWTException e) {
- // log the error and keep going. Content of the LogTab
- // table maybe unexpected
- // but at least ddms won't crash.
- Log.e("LogFilter", e);
- }
-
- // redraw
- table.setRedraw(true);
-
- // scroll if needed, by showing the last item
- if (scroll) {
- totalCount = table.getItemCount();
- if (totalCount > 0) {
- table.showItem(table.getItem(totalCount - 1));
- }
- } else if (removedMessageCount > 0) {
- // we need to make sure the topIndex is still visible.
- // Because really old items are removed from the list, this
- // could make it disappear
- // if we don't change the scroll value at all.
-
- topIndex -= removedMessageCount;
- if (topIndex < 0) {
- // looks like it disappeared. Lets just show the
- // first item
- table.showItem(table.getItem(0));
- } else {
- table.showItem(table.getItem(topIndex));
- }
- }
-
- newMessages.clear();
- removedMessageCount = 0;
-
- }
-
- void setColors(LogColors pColors) {
- colors = pColors;
- }
-
- /**
- * Add a TableItem for the index-th item of the buffer
- *
- * @param filter
- * The index of the table in which to insert the item.
- */
- private void addTableItem(LogMessage msg) {
- TableItem item = new TableItem(table, SWT.NONE);
- item.setText(0, msg.data.time);
- // item.setText(1,
- // new String(new char[]{msg.data.logLevel.getPriorityLetter()}));
- item.setText(2, msg.data.pidString);
- item.setText(3, msg.data.tag);
- item.setText(4, msg.msg);
-
- // add the buffer index as data
- item.setData(msg);
-
- if (msg.data.logLevel == LogLevel.INFO) {
- item.setForeground(colors.infoColor);
- item.setText(1, "Info");
- } else if (msg.data.logLevel == LogLevel.DEBUG) {
- item.setForeground(colors.debugColor);
- item.setText(1, "Debug");
- } else if (msg.data.logLevel == LogLevel.ERROR) {
- item.setForeground(colors.errorColor);
- item.setText(1, "Error");
- } else if (msg.data.logLevel == LogLevel.WARN) {
- item.setForeground(colors.warningColor);
- item.setText(1, "Warn");
- } else if (msg.data.logLevel == LogLevel.WARN) {
- item.setForeground(colors.verboseColor);
- item.setText(1, "Verbose");
- }
- }
-
- /**
- * objects able to receive the output of a remote shell command,
- * specifically a LogTab command in this case
- */
- private final class LogTabOuputReceiver extends MultiLineReceiver {
-
- public boolean isCancelled = false;
-
- public LogTabOuputReceiver() {
- super();
-
- setTrimLine(false);
- }
-
- @Override
- public void processNewLines(String[] lines) {
- if (isCancelled == false) {
- processLogLines(lines);
- }
- }
-
- @Override
- public boolean isCancelled() {
- return isCancelled;
- }
- }
-
- /**
- * Process new Log lines coming from {@link LogCatOuputReceiver}.
- *
- * @param lines the new lines
- */
- protected void processLogLines(String[] lines) {
- // WARNING: this will not work if the string contains more line
- // than
- // the buffer holds.
-
- if (lines.length > STRING_BUFFER_LENGTH) {
- Log.e("LogTab", "Receiving more lines than STRING_BUFFER_LENGTH");
- }
-
- // parse the lines and create LogMessage that are stored in a
- // temporary list
- final ArrayList<LogMessage>newMessages = new ArrayList<LogMessage>();
-
- synchronized (buffer) {
- for (String line : lines) {
- line = AnsicodeAdapter.getStripAnsiString(line);
- // ignore empty lines.
- if (line.length() > 0) {
- // check for header lines.
- Matcher matcher = logPattern.matcher(line);
- if (matcher.matches()) {
- // this is a header line, parse the header and keep it around.
- lastMessageInfo = new LogMessageInfo();
-
- lastMessageInfo.time = matcher.group(1);
- lastMessageInfo.pidString = matcher.group(2);
- lastMessageInfo.logLevel = LogLevel
- .getByLetterString(matcher.group(4));
- lastMessageInfo.tag = matcher.group(5).trim();
- } else {
-
- if (lastMessageInfo == null) {
- return;
- }
-
- // This is not a header line.
- // Create a new LogMessage and process it.
- LogMessage mc = new LogMessage();
-
- // If someone printed a log message with embedded '\n' characters,
- //there will one header line followed by multiple text lines.
- // Use the last header that we saw.
- mc.data = lastMessageInfo;
-
- // tabs seem to display as only 1 tab so we replace the leading tabs by 4 spaces.
- mc.msg = line.replaceAll("\t", " "); //$NON-NLS-1$ //$NON-NLS-2$
-
- // process the new LogMessage.
- processNewMessage(mc);
-
- // store the new LogMessage
- newMessages.add(mc);
- }
- }
- }
-
- if (pendingAsyncRefresh) {
-// pendingAsyncRefresh = true;
-
- try {
- Display display = table.getDisplay();
-
- // run in sync because this will update the
- // buffer start/end indices
- display.asyncExec(new Runnable() {
- @Override
- public void run() {
- asyncRefresh();
- }
- });
- } catch (SWTException e) {
- stopLogTab(false);
- }
- }
- }
- }
-
- /**
- * Processes a new Message.
- * <p/>
- * This adds the new message to the buffer, and gives it to the existing
- * filters.
- *
- * @param newMessage
- */
- private void processNewMessage(LogMessage newMessage) {
-
- // compute the index where the message goes.
- // was the buffer empty?
- int messageIndex = -1;
- if (indexStart == -1) {
- indexStart = 0;
- messageIndex = indexStart;
- indexEnd = 1;
- } else {
- messageIndex = indexEnd;
-
- // check we aren't overwriting start
- if (indexEnd == indexStart) {
- indexStart = (indexStart + 1) % STRING_BUFFER_LENGTH;
- }
-
- // increment the next usable slot index
- indexEnd = (indexEnd + 1) % STRING_BUFFER_LENGTH;
- }
-
- LogMessage oldMessage = null;
-
- // record the message that was there before
- if (buffer[messageIndex] != null) {
- oldMessage = buffer[messageIndex];
- }
-
- // then add the new one
- buffer[messageIndex] = newMessage;
-
- addMessage(newMessage, oldMessage);
- }
-
- /**
- * Refreshes the UI with new messages.
- */
- private void asyncRefresh() {
- if (table.isDisposed() == false) {
- synchronized (buffer) {
- flush();
-// try {
-// // the circular buffer has been updated, let
-// // have the filter flush
-// // their display with the new messages.
-// flush();
-//
-// } finally {
-// // the pending refresh is done.
-// pendingAsyncRefresh = false;
-// }
- }
- } else {
- stopLogTab(true);
- }
- }
-
- public void resetUI(boolean inUiThread) {
-
- // the ui is static we just empty it.
- if (table.isDisposed() == false) {
- if (inUiThread) {
- table.removeAll();
- } else {
- Display d = table.getDisplay();
-
- // run sync as we need to update right now.
- d.syncExec(new Runnable() {
- @Override
- public void run() {
- if (table.isDisposed() == false) {
- table.removeAll();
- }
- }
- });
- }
- }
- }
-
- public void setLevelIcon(Action[] icons) {
- for (int i = 0; i < 5; i++) {
- int a = levelMode & (0x1 << i);
- icons[i].setChecked(a == (int) Math.pow(2, i));
- }
- }
-
- public void initTab() {
-
- // is it empty
- if (uiReady() == false) {
- return;
- }
-
- msgClear();
-
- if (indexStart != -1) {
- int max = indexEnd;
- if (indexEnd < indexStart) {
- max += STRING_BUFFER_LENGTH;
- }
-
- for (int i = indexStart; i < max; i++) {
- int realItemIndex = i % STRING_BUFFER_LENGTH;
-
- addMessage(buffer[realItemIndex], null /** old message*/);
- }
- }
-
- flush();
- }
-
- public void refill() {
- msgClear();
-
- synchronized (buffer) {
- for (LogMessage logMsg : buffer) {
- if (accept(logMsg)) {
- addMessage(logMsg, null);
- }
- }
- }
- flush();
- }
-
- public void tableRefill(int index, String filter) {
-
- filterKeywordFromPanel = filter;
- filterIndexFromPanel = index;
-
- msgClear();
-
- synchronized (buffer) {
- for (LogMessage logMsg : buffer) {
- if (accept(logMsg) && tableAccept(logMsg)) {
- addMessage(logMsg, null);
- }
- }
- }
- flush();
- }
-
- public int getFilterIndexFromPanel()
- {
- return filterIndexFromPanel;
- }
-
- public void setFilterIndexFromPanel(int index)
- {
- filterIndexFromPanel = index;
- }
-
- public String getFilterKeywordFromPanel()
- {
- return filterKeywordFromPanel;
- }
-
- public void setFilterKeywordFromPanel(String keyword)
- {
- filterKeywordFromPanel = keyword;
- }
-
- boolean tableAccept(LogMessage logMessage) {
- if (logMessage == null)
- return false;
-
- if (filterKeywordFromPanel == null || filterKeywordFromPanel.length() == 0)
- return true;
-
- switch(filterIndexFromPanel) {
- case 0:
- {
- String[] filter = filterKeywordFromPanel.split("[\\s\t,]");
- for (int i = 0; i < filter.length; i++) {
- if (logMessage.data.pidString.contains(
- filter[i]))
- return true;
- }
- }
- break;
-
- case 1:
- {
- String[] filter = filterKeywordFromPanel.split("[\\s\t,]");
- for (int i = 0; i < filter.length; i++) {
- if (logMessage.data.tag.toLowerCase().contains(
- filter[i].toLowerCase()))
- return true;
- }
- }
- break;
-
- case 2:
- {
- String[] filter = filterKeywordFromPanel.split("[\\s\t,]");
- for (int i = 0; i < filter.length; i++) {
- if (logMessage.msg.toLowerCase().contains(
- filter[i].toLowerCase()))
- return true;
- }
- }
- break;
-
- default:
- return false;
-
- }
- return false;
- }
-
- public void setLevel(int level, boolean setLevel) {
- level = (int) Math.pow(2, level);
- if (setLevel)
- levelMode |= level;
- else
- levelMode &= (~level);
- }
-
- //remove all filtered messages and tableMessages for refill or init tab
- public void msgClear() {
- removedMessageCount = 0;
- newMessages.clear();
- lastMessageInfo = null;
- tableMessages.clear();
- if (table.isDisposed() == false)
- table.removeAll();
- }
-
- //buffer clear
- public void clear() {
- for (int i = 0; i < STRING_BUFFER_LENGTH; i++) {
- buffer[i] = null;
- }
-
- indexStart = -1;
- indexEnd = -1;
-
- msgClear();
- }
-
- public void setDevice(IDevice device) {
- filterDevice = device;
- }
-
- public void setDefault() {
- isDefault = true;
- }
-
- public boolean isDefault() {
- return isDefault;
- }
-
- public void setPendingAsyncRefresh(boolean b)
- {
- pendingAsyncRefresh = b;
- }
-
+public class LogTab
+{
+
+ private static final int STRING_BUFFER_LENGTH = 5000;
+
+ public static final int FILTER_NONE = -1;
+ public static final int FILTER_PID = 0;
+ public static final int FILTER_TAG = 1;
+ public static final int FILTER_MESSAGE = 2;
+
+ public static final int LEVEL_ALL = 0x1F;
+
+ private int levelMode = LEVEL_ALL;
+
+ //words to filter
+ private String[] pidFilters = null;
+ private String[] tagFilters = null;
+ private String[] msgFilters = null;
+
+ //need to show previous input value when tab dialog is opened
+ private String pidInput = null;
+ private String tagInput = null;
+ private String msgInput = null;
+
+ private int filterCombo = FILTER_MESSAGE;
+ private String filterText = "";
+
+ private String logTabName = null;
+ private IDevice device = null;
+ private LogTabOuputReceiver logReceiver = null;
+ private LogColors colors;
+
+ private Table table;
+ private TabItem tabItem;
+
+ private boolean isScrollLocked;
+
+ private static Pattern logPattern = Pattern.compile("^\\[\\s(\\d\\d-\\d\\d\\s\\d\\d:\\d\\d:\\d\\d\\.\\d+)"
+ + "\\s+(\\d*):\\s*(\\d+)\\s([VDIWE])/(.+)\\s+\\]$");
+
+ //Array to keep all messages from device
+ private final LogMessage[] allMessages = new LogMessage[STRING_BUFFER_LENGTH];
+
+ //List about filtered messages with pidFilters, tagFilters, msgFilters
+ private final List<LogMessage> filteredMessages = new ArrayList<LogMessage>();
+
+ //List about messages need to added table contents
+ private final List<LogMessage> newMessages = new ArrayList<LogMessage>();
+
+ private LogMessageInfo lastMessageInfo = null;
+
+ private boolean isDefault = false;
+
+ //index for allMessages
+ private int indexStart = -1;
+ private int indexEnd = -1;
+
+ public LogTab(String pName, IDevice pDevice, LogColors pColors)
+ {
+ logTabName = pName;
+ device = pDevice;
+ this.colors = pColors;
+ }
+
+ public LogTab()
+ {
+ }
+
+ public void setLogTabName(String name)
+ {
+ logTabName = name;
+ }
+
+ /**
+ * Get logTab name
+ * @return String
+ */
+ public String getLogTabName()
+ {
+ return logTabName;
+ }
+
+ public void setPidFilter(String pid)
+ {
+ pidInput = pid;
+ if (pid != null)
+ pidFilters = setFilter(pid.split("[\\s\t,]"));
+ else
+ pidFilters = null;
+ }
+
+ public void setTagFilter(String tag)
+ {
+ tagInput = tag;
+ if (tag != null)
+ tagFilters = setFilter(tag.split("[\\s\t,]"));
+ else
+ tagFilters = null;
+ }
+
+ public void setMsgFilter(String msg)
+ {
+ msgInput = msg;
+ if (msg != null)
+ msgFilters = setFilter(msg.split("[\\s\t,]"));
+ else
+ msgFilters = null;
+ }
+
+ private String[] setFilter(String[] array)
+ {
+ ArrayList<String> result = new ArrayList<String>();
+ for (String s : array)
+ {
+ if (s.length() > 0)
+ {
+ result.add(s);
+ }
+ }
+ return result.toArray(new String[(result.size())]);
+ }
+
+ public void setLevelMode(int level)
+ {
+ levelMode = level;
+ }
+
+ public int getLevelMode()
+ {
+ return levelMode;
+ }
+
+ public String getPidFilter()
+ {
+ return pidInput;
+ }
+
+ public String getTagFilter()
+ {
+ return tagInput;
+ }
+
+ public String getMsgFilter()
+ {
+ return msgInput;
+ }
+
+ public String getDeviceSerialNumber()
+ {
+ if (device != null)
+ return device.getSerialNumber();
+ else
+ return null;
+ }
+
+ public void setTabItem(TabItem tabItem)
+ {
+ this.tabItem = tabItem;
+ }
+
+ public TabItem getTabItem()
+ {
+ return tabItem;
+ }
+
+ public void setTable(Table table)
+ {
+ this.table = table;
+ }
+
+ /**
+ * Returns the UI table object.
+ *
+ * @return
+ */
+ public Table getTable()
+ {
+ return table;
+ }
+
+ public void start()
+ {
+
+ if (device != null)
+ {
+ // create a new output receiver
+ logReceiver = new LogTabOuputReceiver();
+
+ // start the LogTab in a different thread
+ new Thread(device.getSerialNumber() + " Logger") { //$NON-NLS-1$
+ @Override
+ public void run()
+ {
+ while (device.isOnline() == false && logReceiver != null && logReceiver.isCancelled == false)
+ {
+ try
+ {
+ sleep(2000);
+ } catch (InterruptedException e)
+ {
+ Logger.error("LogTab : Device is not online or logger is null/cancelled", e.getMessage(), e);
+ return;
+ }
+ }
+
+ if (logReceiver == null || logReceiver.isCancelled)
+ {
+ return;
+ }
+
+ try
+ {
+ device.executeShellCommand("dlogutil -v long *:v", logReceiver, 0 /* timeout */); //$NON-NLS-1$
+ } catch (Exception e)
+ {
+ Logger.error("LogTab", e);
+ }
+ }
+ }.start();
+ }
+ }
+
+ /** Stop the current LogTab */
+ public void stop(boolean inUiThread)
+ {
+ if (logReceiver != null)
+ {
+ logReceiver.isCancelled = true;
+
+ logReceiver = null;
+
+ device = null;
+
+ clear();
+
+ }
+ }
+
+ // add message to filtered message and replace old message to
+ // new message
+ public void addFilteredMessage(LogMessage newMessage, LogMessage oldMessage)
+ {
+ synchronized (filteredMessages)
+ {
+ if (oldMessage != null && filteredMessages.size() >= STRING_BUFFER_LENGTH)
+ {
+ int index = filteredMessages.indexOf(oldMessage);
+ if (index != -1)
+ {
+ filteredMessages.remove(index);
+ }
+ }
+
+ boolean isValid = filteredByFilterString(newMessage);
+
+ if (isValid)
+ {
+ filteredMessages.add(newMessage);
+ if(filteredByIconAndText(newMessage))
+ newMessages.add(newMessage);
+ }
+ }
+ }
+
+ /**
+ * action when select level icon and input combo and text to TabItem bottom
+ */
+ public void filterMessages()
+ {
+ //1. remove table contents
+ initialize();
+ //2. filtering
+ synchronized (filteredMessages)
+ {
+ for (LogMessage logMsg : filteredMessages)
+ {
+ if (filteredByIconAndText(logMsg))
+ {
+ newMessages.add(logMsg);
+ }
+ }
+ //3. refill new messages
+ flush();
+ }
+ }
+
+ /**
+ * Filter with tab dialog(AddTab, EditTab) input value
+ * @param logMessage
+ * @return
+ */
+ private boolean filteredByFilterString(LogMessage logMessage)
+ {
+ if (logMessage == null)
+ return false;
+ if (pidFilters != null || tagFilters != null || msgFilters != null)
+ {
+ if (pidFilters != null)
+ {
+ for (String filter : pidFilters)
+ {
+ if (logMessage.data.pidString.contains(filter))
+ return true;
+ }
+ }
+
+ if (tagFilters != null)
+ {
+ for (String filter : tagFilters)
+ {
+ if (logMessage.data.tag.toLowerCase().contains(filter.toLowerCase()))
+ return true;
+ }
+ }
+
+ if (msgFilters != null)
+ {
+ for (String filter : msgFilters)
+ {
+ if (logMessage.msg.toLowerCase().contains(filter.toLowerCase()))
+ return true;
+ }
+ }
+ return false;
+ }
+
+ return true;
+ }
+
+ /**
+ * Filter with level icon on LogView toolbar
+ * @param logMessage
+ * @return
+ */
+ boolean filteredByIconAndText(LogMessage logMessage)
+ {
+ if (logMessage == null)
+ return false;
+
+ if (levelMode != LEVEL_ALL)
+ {
+ int a = 0;
+ a = (levelMode & (0x1 << (logMessage.data.logLevel.getPriority() - 2)));
+
+ if (a == 0)
+ return false;
+ }
+
+ if (filteredByText(logMessage))
+ {
+ return true;
+ }
+ else
+ {
+ return false;
+ }
+ }
+
+ /**
+ * Filter with text and combo input from TabItem bottom
+ * @param logMessage
+ * @return
+ */
+ boolean filteredByText(LogMessage logMessage)
+ {
+ if (logMessage == null)
+ {
+ return false;
+ }
+
+ if (StringUtil.isEmpty(filterText))
+ {
+ return true;
+ }
+
+ String msg = null;
+ String filter = filterText.toLowerCase();
+
+ switch (filterCombo)
+ {
+ case FILTER_PID:
+ msg = logMessage.data.pidString;
+ break;
+
+ case FILTER_TAG:
+ msg = logMessage.data.tag.toLowerCase();
+ break;
+
+ case FILTER_MESSAGE:
+ msg = logMessage.msg.toLowerCase();
+ break;
+
+ default:
+ return false;
+ }
+
+ if( msg.contains(filter))
+ {
+ return true;
+ }
+ else
+ {
+ return false;
+ }
+ }
+
+ /**
+ * flush valid messages to table and remove
+ */
+ public void flush()
+ {
+ table.setRedraw(false);
+
+ int newCount = newMessages.size();
+
+ try
+ {
+ int totalCount = table.getItemCount() + newCount;
+ if(totalCount > STRING_BUFFER_LENGTH)
+ {
+ int removeCount = totalCount - STRING_BUFFER_LENGTH;
+ //remove over than STRING_BUFFER_LENGTH
+ for (int i = 0; i < removeCount && table.getItemCount() > 0; i++)
+ {
+ table.remove(0);
+ }
+ }
+ // add the new items
+ for (int i = 0; i < newCount; i++)
+ {
+ LogMessage msg = newMessages.get(i);
+ addTableItem(msg);
+ }
+ } catch (SWTException e)
+ {
+ Logger.error("LogFilter", e);
+ }
+
+ //if isScollLocked is false, always shows last table item
+ if(!getScrollLock())
+ {
+ int count = table.getItemCount();
+ if( count > 1)
+ {
+ table.showItem(table.getItem(table.getItemCount() - 1));
+ }
+ }
+
+ table.setRedraw(true);
+
+ newMessages.clear();
+
+ }
+
+ void setColors(LogColors pColors)
+ {
+ colors = pColors;
+ }
+
+ /**
+ * Add a TableItem for the index-th item of the buffer
+ *
+ * @param filter
+ * The index of the table in which to insert the item.
+ */
+ private void addTableItem(LogMessage msg)
+ {
+ TableItem item = new TableItem(table, SWT.NONE);
+ item.setText(0, msg.data.time);
+ item.setText(2, msg.data.pidString);
+ item.setText(3, msg.data.tag);
+ item.setText(4, msg.msg);
+
+ // add the buffer index as data
+ item.setData(msg);
+
+ if (msg.data.logLevel == LogLevel.INFO)
+ {
+ item.setForeground(colors.infoColor);
+ item.setText(1, "Info");
+ } else if (msg.data.logLevel == LogLevel.DEBUG)
+ {
+ item.setForeground(colors.debugColor);
+ item.setText(1, "Debug");
+ } else if (msg.data.logLevel == LogLevel.ERROR)
+ {
+ item.setForeground(colors.errorColor);
+ item.setText(1, "Error");
+ } else if (msg.data.logLevel == LogLevel.WARN)
+ {
+ item.setForeground(colors.warningColor);
+ item.setText(1, "Warning");
+ } else if (msg.data.logLevel == LogLevel.VERBOSE)
+ {
+ item.setForeground(colors.verboseColor);
+ item.setText(1, "Verbose");
+ }
+ }
+
+ /**
+ * objects able to receive the output of a remote shell command,
+ * specifically a LogTab command in this case
+ */
+ private final class LogTabOuputReceiver extends MultiLineReceiver
+ {
+
+ public boolean isCancelled = false;
+
+ public LogTabOuputReceiver()
+ {
+ super();
+
+ setTrimLine(false);
+ }
+
+ @Override
+ public void processNewLines(String[] lines)
+ {
+ if (isCancelled == false)
+ {
+ processLogLines(lines);
+ }
+ }
+
+ @Override
+ public boolean isCancelled()
+ {
+ return isCancelled;
+ }
+ }
+
+ /**
+ * Process new Log lines coming from {@link LogCatOuputReceiver}.
+ *
+ * @param lines
+ * the new lines
+ */
+ protected void processLogLines(String[] lines)
+ {
+ // WARNING: this will not work if the string contains more line
+ // than the buffer holds.
+
+ if (lines.length > STRING_BUFFER_LENGTH)
+ {
+ Logger.error("LogTab : Receiving more lines than " + STRING_BUFFER_LENGTH, "");
+ return ;
+ }
+
+ // parse the lines and create LogMessage that are stored in a temporary
+ // list
+ final ArrayList<LogMessage> newMessages = new ArrayList<LogMessage>();
+
+ synchronized (allMessages)
+ {
+ for (String line : lines)
+ {
+ line = AnsicodeAdapter.getStripAnsiString(line);
+ // ignore empty lines.
+ if (line.length() > 0)
+ {
+ // check for header lines.
+ Matcher matcher = logPattern.matcher(line);
+ if (matcher.matches())
+ {
+ // this is a header line, parse the header and keep it
+ // around.
+ lastMessageInfo = new LogMessageInfo();
+
+ lastMessageInfo.time = matcher.group(1);
+ lastMessageInfo.pidString = matcher.group(2);
+ lastMessageInfo.logLevel = LogLevel.getByLetterString(matcher.group(4));
+ lastMessageInfo.tag = matcher.group(5).trim();
+ } else
+ {
+
+ if (lastMessageInfo == null)
+ {
+ return;
+ }
+
+ // This is not a header line.
+ // Create a new LogMessage and process it.
+ LogMessage mc = new LogMessage();
+
+ // If someone printed a log message with embedded '\n'
+ // characters,
+ // there will one header line followed by multiple text
+ // lines.
+ // Use the last header that we saw.
+ mc.data = lastMessageInfo;
+
+ // tabs seem to display as only 1 tab so we replace the
+ // leading tabs by 4 spaces.
+ mc.msg = line.replaceAll("\t", " "); //$NON-NLS-1$ //$NON-NLS-2$
+
+ // process the new LogMessage.
+ processNewMessage(mc);
+
+ // store the new LogMessage
+ newMessages.add(mc);
+ }
+ }
+ }
+
+ try
+ {
+ Display display = table.getDisplay();
+
+ // run in sync because this will update the
+ // buffer start/end indices
+ display.asyncExec(new Runnable()
+ {
+ @Override
+ public void run()
+ {
+ asyncRefresh();
+ }
+ });
+ } catch (SWTException e)
+ {
+ // display is disposed, stop the LogTab
+ stop(false);
+ }
+ }
+ }
+
+ /**
+ * Processes a new Message.
+ * <p/>
+ * This adds the new message to the buffer, and gives it to the existing
+ * filters.
+ *
+ * @param newMessage
+ */
+ private void processNewMessage(LogMessage newMessage)
+ {
+
+ // compute the index where the message goes.
+ // was the buffer empty?
+ int messageIndex = -1;
+ if (indexStart == -1)
+ {
+ indexStart = 0;
+ messageIndex = indexStart;
+ indexEnd = 1;
+ } else
+ {
+ messageIndex = indexEnd;
+
+ // check we aren't overwriting start
+ if (indexEnd == indexStart)
+ {
+ indexStart = (indexStart + 1) % STRING_BUFFER_LENGTH;
+ }
+
+ // increment the next usable slot index
+ indexEnd = (indexEnd + 1) % STRING_BUFFER_LENGTH;
+ }
+
+ LogMessage oldMessage = null;
+
+ // record the message that was there before
+ if (allMessages[messageIndex] != null)
+ {
+ oldMessage = allMessages[messageIndex];
+ }
+
+ // then add the new one
+ allMessages[messageIndex] = newMessage;
+
+ addFilteredMessage(newMessage, oldMessage);
+ }
+
+ /**
+ * Refreshes the UI with new messages.
+ */
+ private void asyncRefresh()
+ {
+ if (table.isDisposed() == false)
+ {
+ synchronized (allMessages)
+ {
+ flush();
+ }
+ } else
+ {
+ stop(true);
+ }
+ }
+
+ public void resetUI(boolean inUiThread)
+ {
+
+ // the ui is static we just empty it.
+ if (table.isDisposed() == false)
+ {
+ if (inUiThread)
+ {
+ table.removeAll();
+ } else
+ {
+ Display d = table.getDisplay();
+
+ // run sync as we need to update right now.
+ d.syncExec(new Runnable()
+ {
+ @Override
+ public void run()
+ {
+ if (table.isDisposed() == false)
+ {
+ table.removeAll();
+ }
+ }
+ });
+ }
+ }
+ }
+
+
+ public void setFilterCombo(int index)
+ {
+ filterCombo = index;
+ }
+
+ public void setFilterText(String text)
+ {
+ filterText = text;
+ }
+
+ // remove all filtered messages and tableMessages to refill or fill messages
+ public void initialize()
+ {
+ newMessages.clear();
+ lastMessageInfo = null;
+ resetUI(false);
+ }
+
+ // buffer and messages clear
+ public void clear()
+ {
+ synchronized(allMessages)
+ {
+ for (int i = 0; i < STRING_BUFFER_LENGTH; i++)
+ {
+ allMessages[i] = null;
+ }
+ }
+
+ indexStart = -1;
+ indexEnd = -1;
+ filteredMessages.clear();
+ initialize();
+ }
+
+ public void setDevice(IDevice device)
+ {
+ this.device = device;
+ }
+
+ public void setDefault()
+ {
+ isDefault = true;
+ }
+
+ public boolean isDefault()
+ {
+ return isDefault;
+ }
+
+ public void setScrollLock(boolean islock)
+ {
+ isScrollLocked = islock;
+ }
+
+ public boolean getScrollLock()
+ {
+ return isScrollLocked;
+ }
} \ No newline at end of file
diff --git a/org.tizen.common.connection/src/org/tizen/common/connection/log/LogUIMessages.properties b/org.tizen.common.connection/src/org/tizen/common/connection/log/LogUIMessages.properties
index 6f0ab47fa..973028f54 100644
--- a/org.tizen.common.connection/src/org/tizen/common/connection/log/LogUIMessages.properties
+++ b/org.tizen.common.connection/src/org/tizen/common/connection/log/LogUIMessages.properties
@@ -1,17 +1,17 @@
Log = Log
-Log_Title_Tab_AddTab_Error = Add tab error
-Log_Title_Tab_EditTab_Error = Edit tab error
-Log_Title_View_Device_Disconnected = Device is disconnected
+Log_Title_Tab_AddTab_Error = Error in adding a tab
+Log_Title_Tab_EditTab_Error = Error in editing a tab
+Log_Title_View_Device_Disconnected = Device disconnected
Log_Message_Tab_Device_Disconnected = %s tab's device is already disconnected.
Log_Message_View_Device_Disconnected = %s is disconnected.\nThe tabs for %s do not work.
-Log_Message_View_Filter_Text = Search Keywords from this table are separated by a space as well as a comma
+Log_Message_View_Filter_Text = Input search keyword
-Log_Tooltip_View_Filter_Combo = Keyword Search: Pid or Tag, Message
+Log_Tooltip_View_Filter_Combo = Keyword: Pid, Tag, or Message
-Log_Title_Tab_Export = Export Log
+Log_Title_Tab_Export = Export the log
Log_File_Tab_Export_Postfix = %s-log.txt
-Log_File_Tab_Export_Filter = Text Files (*.txt)
+Log_File_Tab_Export_Filter = Text files (*.txt)
Log_File_Tab_Export_Filter_Extensions = *.txt \ No newline at end of file
diff --git a/org.tizen.common.connection/src/org/tizen/common/connection/properties/ConnectionExplorerPermissionPropertyPages.java b/org.tizen.common.connection/src/org/tizen/common/connection/properties/ConnectionExplorerPermissionPropertyPages.java
index 538a41112..f286a6f55 100644..100755
--- a/org.tizen.common.connection/src/org/tizen/common/connection/properties/ConnectionExplorerPermissionPropertyPages.java
+++ b/org.tizen.common.connection/src/org/tizen/common/connection/properties/ConnectionExplorerPermissionPropertyPages.java
@@ -128,14 +128,10 @@ public class ConnectionExplorerPermissionPropertyPages extends PropertyPage {
table.setHeaderVisible(true);
table.setLinesVisible(true);
- TableColumn colMsg = createTableColumn(table, "", SWT.NONE,
- "EXECUTE");
- colMsg = createTableColumn(table, "Read", SWT.NONE,
- "EXECUTE");
- colMsg = createTableColumn(table, "Write", SWT.NONE,
- "EXECUTE");
- colMsg = createTableColumn(table, "Execute", SWT.NONE,
- "EXECUTE");
+ createTableColumn(table, "", SWT.NONE, "EXECUTE");
+ createTableColumn(table, "Read", SWT.NONE, "EXECUTE");
+ createTableColumn(table, "Write", SWT.NONE, "EXECUTE");
+ createTableColumn(table, "Execute", SWT.NONE, "EXECUTE");
itemUser = new TableItem(table, SWT.NONE);
diff --git a/org.tizen.common.connection/src/org/tizen/common/connection/sdblib/dnd/FileEntryDropAdapter.java b/org.tizen.common.connection/src/org/tizen/common/connection/sdblib/dnd/FileEntryDropAdapter.java
index 4b5084ac4..a67e03d6d 100644
--- a/org.tizen.common.connection/src/org/tizen/common/connection/sdblib/dnd/FileEntryDropAdapter.java
+++ b/org.tizen.common.connection/src/org/tizen/common/connection/sdblib/dnd/FileEntryDropAdapter.java
@@ -3,10 +3,10 @@
*
* Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved.
*
-* Contact:
+* Contact:
* Hoon Kang <h245.kang@samsung.com>
* Yoonki Park <yoonki.park@samsung.com>
-*
+*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
@@ -38,7 +38,6 @@ import org.eclipse.ui.part.IDropActionDelegate;
import org.tizen.common.connection.ConnectionPlugin;
import org.tizen.common.connection.ddmuilib.FileDialogUtils;
import org.tizen.common.connection.ddmuilib.console.DdmConsole;
-
import org.tizen.sdblib.SdbCommandRejectedException;
import org.tizen.sdblib.SyncService;
import org.tizen.sdblib.SyncService.ISyncProgressMonitor;
@@ -50,22 +49,22 @@ public class FileEntryDropAdapter implements IDropActionDelegate {
@Override
public boolean run(Object source, Object target) {
IResource resource = null;
-
+
if (target instanceof IAdaptable) {
target = ((IAdaptable) target).getAdapter(IResource.class);
if (target != null && target instanceof IResource) {
resource = (IResource) target;
if (resource.getType() == IResource.FILE && resource.getParent() != null)
- resource = resource.getParent();
+ resource = resource.getParent();
}
}
-
+
String[] entries = FileEntryTransfer.getInstance().fromByteArray(
(byte[]) source);
-
- if (entries.length < 1)
+
+ if (entries.length < 1)
return false;
-
+
SyncService sync = null;
try {
sync = ConnectionPlugin.getDefault().getCurrentDevice().getSyncService();
@@ -82,7 +81,7 @@ public class FileEntryDropAdapter implements IDropActionDelegate {
if (sync != null) {
ISyncProgressMonitor monitor = SyncService.getNullProgressMonitor();
boolean isAlwayCopy = false;
-
+
for (int i = 0; i < entries.length; i++) {
File f = new File(entries[i]);
if (resource == null )
@@ -91,10 +90,10 @@ public class FileEntryDropAdapter implements IDropActionDelegate {
IResource newRes = resource.getWorkspace().getRoot().findMember(localPath);
String localFilePath = resource.getLocation().append(f.getName()).toOSString();
-
+
if (newRes != null) {
if (isAlwayCopy == false) {
- int ret = FileDialogUtils.getInstance().checkOverwrite(f.getName());
+ int ret = FileDialogUtils.checkOverwrite(f.getName());
switch (ret) {
case IDialogConstants.CANCEL_ID :
return false;
@@ -104,7 +103,7 @@ public class FileEntryDropAdapter implements IDropActionDelegate {
case IDialogConstants.NO_ID :
continue;
default:
- }
+ }
}
}
SyncResult result = sync.pullFile(entries[i], localFilePath , monitor);
@@ -121,12 +120,12 @@ public class FileEntryDropAdapter implements IDropActionDelegate {
} catch (CoreException e) {
e.printStackTrace();
}
- }
+ }
}
}
}
return false;
}
-
+
}
diff --git a/org.tizen.common.connection/src/org/tizen/common/connection/ui/ConnectionExplorer.java b/org.tizen.common.connection/src/org/tizen/common/connection/ui/ConnectionExplorer.java
index a572d5c37..f542b3db5 100644..100755
--- a/org.tizen.common.connection/src/org/tizen/common/connection/ui/ConnectionExplorer.java
+++ b/org.tizen.common.connection/src/org/tizen/common/connection/ui/ConnectionExplorer.java
@@ -1,28 +1,28 @@
/*
-* Common
-*
-* Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved.
-*
-* Contact:
-* Hoon Kang <h245.kang@samsung.com>
-* Hyunsik Noh <hyunsik.noh@samsung.com>
-*
+ * Common
+ *
+ * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved.
+ *
+ * Contact:
+ * Hoon Kang <h245.kang@samsung.com>
+ * Hyunsik Noh <hyunsik.noh@samsung.com>
+ *
* Licensed under the Apache License, Version 2.0 (the "License");
-* you may not use this file except in compliance with the License.
-* You may obtain a copy of the License at
-*
-* http://www.apache.org/licenses/LICENSE-2.0
-*
-* Unless required by applicable law or agreed to in writing, software
-* distributed under the License is distributed on an "AS IS" BASIS,
-* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-* See the License for the specific language governing permissions and
-* limitations under the License.
-*
-* Contributors:
-* - S-Core Co., Ltd
-*
-*/
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ * Contributors:
+ * - S-Core Co., Ltd
+ *
+ */
package org.tizen.common.connection.ui;
import java.io.File;
@@ -45,365 +45,446 @@ import org.eclipse.swt.widgets.Composite;
import org.eclipse.swt.widgets.Menu;
import org.eclipse.swt.widgets.ToolBar;
import org.eclipse.swt.widgets.ToolItem;
+import org.eclipse.swt.widgets.Tree;
+import org.eclipse.ui.PlatformUI;
import org.eclipse.ui.contexts.IContextService;
-import org.eclipse.ui.dialogs.PropertyDialogAction;
import org.eclipse.ui.part.ViewPart;
+import org.tizen.common.TizenHelpContextIds;
import org.tizen.common.connection.ConnectionPlugin;
-import org.tizen.common.connection.ddmuilib.ImageLoader;
import org.tizen.common.connection.explorer.ConnectionExplorerPanel;
-import org.tizen.common.properties.InstallPathConfig;
+import org.tizen.common.core.application.InstallPathConfig;
import org.tizen.common.util.HostUtil;
-
-public class ConnectionExplorer extends ViewPart {
-
- private ConnectionExplorerPanel panel;
- private ImageLoader mloader;
- private ToolBar mToolBar;
-
- private ToolItem pushToolItem;
- private ToolItem pullToolItem;
- private ToolItem emulStartToolItem;
-
- private MenuManager subMenu;
- private Action actionAddFolder;
- private Action actionAddFile;
- private Action actionPush;
- private Action actionPull;
- private Action actionRefresh;
- private Action actionRename;
- private Action actionProperty;
- private Action actionDelete;
-
- private MenuManager menuMgr;
- private static ConnectionExplorer explorer;
-
- private static final String BINARYMESSAGE = "Emulator is not installed or install path is not valid.";
- private static final String EMULATOR_PATH = InstallPathConfig
- .getEmulatorPath();
- private static final String EMULATOR_BATCH = "bin" + File.separatorChar + "emulator-manager.exe";
- private static final String EMULATOR_BINARY = "bin" + File.separatorChar + "emulator-manager";
-
- public static ConnectionExplorer gerDefault() {
- if (explorer == null) {
- explorer = new ConnectionExplorer();
- }
-
- return explorer;
- }
-
- @Override
- public void createPartControl(Composite parent) {
- mloader = ImageLoader.getDdmUiLibLoader();
-
- parent.setLayoutData(new GridData(GridData.FILL_VERTICAL));
- parent.setLayout(new GridLayout(1, false));
-
- Composite top = new Composite(parent, SWT.NONE);
-
- GridLayout gridLayout = new GridLayout();
- gridLayout.numColumns = 3;
- gridLayout.marginWidth = 0;
- gridLayout.marginHeight = 0;
-
- GridData gridData = new GridData(GridData.FILL_HORIZONTAL);
- gridData.horizontalSpan = 2;
-
- top.setLayoutData(gridData);
- top.setLayout(gridLayout);
-
- createToolBar(top, gridData);
-
- Composite bottom = new Composite(parent, SWT.NONE);
- bottom.setLayoutData(new GridData(GridData.FILL_BOTH));
- bottom.setLayout(new FillLayout());
-
- createFileExplorerView(bottom);
- makeActions();
- activateContext();
- initContextMenu();
-
- panel.setToolItems(pushToolItem, pullToolItem, emulStartToolItem);
-
- panel.setActions(subMenu, actionPush,
- actionPull, actionRefresh, actionRename, actionProperty,
- actionDelete);
- }
- private void createFileExplorerView(Composite parent) {
-
- // device explorer
- panel = new ConnectionExplorerPanel();
- panel.createPanel(parent);
- panel.getTreeViewer().getTree().addKeyListener(new KeyAdapter() {
- public void keyPressed(KeyEvent e) {
- handleKeyPressed(e);
- }
- public void keyReleased(KeyEvent e) {
- handleKeyPressed(e);
- }
- });
-
- }
- private void handleKeyPressed(KeyEvent event) {
-
- if (event.keyCode == SWT.F5) {
- actionRefresh();
- } else if (event.keyCode == SWT.F2) {
- actionRename();
- } else if (event.keyCode == SWT.DEL) {
- actionDelete();
- }
- if ((event.stateMask == SWT.ALT) && (event.keyCode == SWT.CR)) {
- actionShowProperty();
- }
- }
- private void actionAddFile() {
-
- panel.addNewFileSelection();
- }
-
- private void actionAddFolder() {
- panel.addNewFolderSelection();
- }
-
- private void actionPush() {
- panel.pushIntoSelection();
- }
-
- private void actionPull() {
- panel.pullSelection();
- }
-
- private void actionRefresh() {
- panel.refreshSelection();
- }
- private void actionDelete() {
- panel.deleteSelection();
- }
- private void actionRename() {
- panel.renameSelection();
- }
- private void actionShowProperty() {
- PropertyDialogAction pda = new PropertyDialogAction(getSite(),
- panel.getTreeViewer());
- pda.run();
- }
- /*
- * make actions
- */
- private void makeActions() {
- subMenu = new MenuManager("Add New..", null);
-
- actionAddFile = new Action() {
- public void run() {
- actionAddFile();
- }
- };
- actionAddFile.setText("Add File");
-
- actionAddFolder = new Action() {
- public void run() {
- actionAddFolder();
- }
- };
- actionAddFolder.setText("Add Folder");
-
- actionPush = new Action() {
- public void run() {
- actionPush();
- }
- };
- actionPush.setText("Push the file");
-
- actionPull = new Action() {
- public void run() {
- actionPull();
- }
- };
- actionPull.setText("Pull the Selection");
-
- // Add refresh action
- actionRefresh = new Action() {
- public void run() {
- actionRefresh();
- }
- };
- actionRefresh.setText("Refresh");
- actionRefresh
- .setActionDefinitionId("org.tizen.common.connection.refresh");
-
- actionRename = new Action() {
- public void run() {
- actionRename();
- }
- };
-
- actionRename.setText("Rename");
- actionRename
- .setActionDefinitionId("org.tizen.common.connection.rename");
-
- actionDelete = new Action() {
- public void run() {
- actionDelete();
- }
- };
- actionDelete.setText("Delete");
- actionDelete
- .setActionDefinitionId("org.tizen.common.connection.delete");
-
- actionProperty = new PropertyDialogAction(getSite(),
- panel.getTreeViewer());
- actionProperty
- .setActionDefinitionId("org.tizen.common.connection.property");
-
- }
- private void initContextMenu() {
- // initalize the context menu
- menuMgr = new MenuManager("Connection Explorer MenuMgr"); //$NON-NLS-1$
- menuMgr.setRemoveAllWhenShown(true);
- menuMgr.addMenuListener(new IMenuListener() {
-
- @Override
- public void menuAboutToShow(IMenuManager manager) {
- fillContextMenu(manager);
- }
- });
-
- Menu menu = menuMgr.createContextMenu(panel.getTreeViewer().getTree());
- panel.getTreeViewer().getTree().setMenu(menu);
- getSite().registerContextMenu(menuMgr, panel.getTreeViewer());
-
- menuMgr.addMenuListener(new IMenuListener() {
- @Override
- public void menuAboutToShow(IMenuManager manager) {
- // Remove team menu from our menu
- IContributionItem[] items = manager.getItems();
- if (items != null) {
- for (int i = 0; i < items.length; i++) {
- IContributionItem item = items[i];
- if (item.getId() != null) {
- if (item.getId().equals("team.main")) {
- manager.remove(item);
- break;
- }
- }
- }
- }
- // Decide whether to enable/disable actions
- panel.setActionState();
- }
- });
- }
-
- private void activateContext() {
-
- IContextService contextService = (IContextService) getSite()
- .getService(IContextService.class);
- contextService
- .activateContext("org.tizen.common.connection.delete.context");
- contextService
- .activateContext("org.tizen.common.connection.rename.context");
- contextService
- .activateContext("org.tizen.common.connection.refresh.context");
- contextService
- .activateContext("org.tizen.common.connection.property.context");
-
- }
- private void fillContextMenu(IMenuManager manager) {
- subMenu.add(actionAddFile);
- subMenu.add(actionAddFolder);
- manager.add(subMenu);
- manager.add(new Separator());
- manager.add(actionPush);
- manager.add(actionPull);
- manager.add(new Separator());
- manager.add(actionRefresh);
- manager.add(new Separator());
- manager.add(actionRename);
- manager.add(actionDelete);
- manager.add(new Separator());
- manager.add(actionProperty);
- manager.add(new Separator());
- }
-
- private void createToolBar(Composite shell, Object layoutData) {
-
- mToolBar = new ToolBar(shell, SWT.NULL);
- mToolBar.setLayoutData(layoutData);
-
- ToolItem item = new ToolItem(mToolBar, SWT.SEPARATOR);
-
- emulStartToolItem = new ToolItem(mToolBar, SWT.PUSH);
- emulStartToolItem.setImage(mloader.loadImage("Emulator_start.gif",
- shell.getDisplay()));
- emulStartToolItem.setToolTipText("Emulator Manager");
- emulStartToolItem.addSelectionListener(new SelectionAdapter() {
- public void widgetSelected(SelectionEvent e) {
- try {
- startEmulatorManager();
- } catch (Exception e1) {
- e1.printStackTrace();
- }
- }
- });
- emulStartToolItem.setEnabled(true);
-
- item = new ToolItem(mToolBar, SWT.SEPARATOR);
-
- pushToolItem = new ToolItem(mToolBar, SWT.PUSH);
- pushToolItem
- .setImage(mloader.loadImage("push.gif", shell.getDisplay()));
- pushToolItem.setToolTipText("Push the files");
- pushToolItem.addSelectionListener(new SelectionAdapter() {
- public void widgetSelected(SelectionEvent e) {
- panel.pushIntoSelection();
- }
- });
- pushToolItem.setEnabled(false);
-
- item = new ToolItem(mToolBar, SWT.SEPARATOR);
-
- pullToolItem = new ToolItem(mToolBar, SWT.PUSH);
- pullToolItem
- .setImage(mloader.loadImage("pull.gif", shell.getDisplay()));
- pullToolItem.setToolTipText("Pull the selection");
- pullToolItem.addSelectionListener(new SelectionAdapter() {
- public void widgetSelected(SelectionEvent e) {
- panel.pullSelection();
- }
- });
- pullToolItem.setEnabled(false);
- item = new ToolItem(mToolBar, SWT.SEPARATOR);
-
- }
-
- @Override
- public void setFocus() {
- }
-
- private void startEmulatorManager() throws Exception {
- String exePath = null;
- int osType = ConnectionPlugin.getDefault().os;
- int linuxType = ConnectionPlugin.getDefault().LINUX;
-
- if (osType == linuxType) {
- exePath = EMULATOR_PATH + File.separatorChar + EMULATOR_BINARY;
- } else {
- exePath = EMULATOR_PATH + File.separatorChar + EMULATOR_BATCH;
- }
-
- if (exePath.equals("") || (!exePath.equals("") && !HostUtil.exists(exePath))) {
- throw new Exception(BINARYMESSAGE);
- }
-
- // FIXME : should implement the lines below based on windows system.
- String command = exePath;
- if (osType == linuxType) {
- command = command + " 1>/dev/null 2>/dev/null &";
-
- HostUtil.execute(command);
- } else {
- HostUtil.batchExecute(command, null, new File(EMULATOR_PATH));
- }
- }
+public class ConnectionExplorer extends ViewPart
+{
+
+ private ConnectionExplorerPanel panel;
+ private Composite parent;
+
+ private ToolBar toolBar;
+
+ private ToolItem pushToolItem;
+ private ToolItem pullToolItem;
+ private ToolItem emulManagerToolItem;
+
+ private MenuManager subMenu;
+ private Action actionAddFolder;
+ private Action actionAddFile;
+ private Action actionPush;
+ private Action actionPull;
+ private Action actionRefresh;
+ private Action actionRename;
+ private Action actionProperty;
+ private Action actionDelete;
+
+ private MenuManager menuMgr;
+ private static ConnectionExplorer explorer;
+
+ private static final String EMULATOR_PATH = InstallPathConfig.getEmulatorPath();
+ private static final String EMULATOR_BATCH = "bin" + File.separatorChar + "emulator-manager.exe";
+ private static final String EMULATOR_BINARY = "bin" + File.separatorChar + "emulator-manager";
+
+ synchronized public static ConnectionExplorer gerDefault()
+ {
+ if (explorer == null)
+ {
+ explorer = new ConnectionExplorer();
+ }
+ return explorer;
+ }
+
+ synchronized public static void release() {
+ explorer = null;
+ }
+
+ @Override
+ public void dispose()
+ {
+ }
+
+ @Override
+ public void createPartControl(Composite p)
+ {
+ parent = p;
+ PlatformUI.getWorkbench().getHelpSystem().setHelp(parent, TizenHelpContextIds.HELP_COMMON_CONNECTION_EXPLORER_CONTEXT);
+ parent.setLayoutData(new GridData(GridData.FILL_VERTICAL));
+ parent.setLayout(new GridLayout(1, false));
+
+ Composite top = new Composite(parent, SWT.NONE);
+
+ GridLayout gridLayout = new GridLayout();
+ gridLayout.numColumns = 3;
+ gridLayout.marginWidth = 0;
+ gridLayout.marginHeight = 0;
+
+ GridData gridData = new GridData(GridData.FILL_HORIZONTAL);
+ gridData.horizontalSpan = 2;
+
+ top.setLayoutData(gridData);
+ top.setLayout(gridLayout);
+
+ createToolBar(top, gridData);
+
+ Composite bottom = new Composite(parent, SWT.NONE);
+ bottom.setLayoutData(new GridData(GridData.FILL_BOTH));
+ bottom.setLayout(new FillLayout());
+
+ createFileExplorerView(bottom);
+ makeActions();
+ activateContext();
+ initContextMenu();
+
+ panel.setToolItems(pushToolItem, pullToolItem, emulManagerToolItem);
+
+ panel.setActions(subMenu, actionPush, actionPull, actionRefresh, actionRename, actionProperty, actionDelete);
+ }
+
+ private void createFileExplorerView(Composite parent)
+ {
+
+ // device explorer
+ panel = new ConnectionExplorerPanel();
+ panel.createPanel(parent);
+ panel.getTreeViewer().getTree().addKeyListener(new KeyAdapter()
+ {
+ @Override
+ public void keyPressed(KeyEvent e)
+ {
+ handleKeyPressed(e);
+ }
+
+ @Override
+ public void keyReleased(KeyEvent e)
+ {
+ }
+ });
+
+ }
+
+ private void handleKeyPressed(KeyEvent event)
+ {
+
+ Tree tree = (Tree) event.widget;
+ int length = tree.getSelectionCount();
+ if (event.keyCode == SWT.F5)
+ {
+ if (length == 1)
+ actionRefresh();
+ } else if (event.keyCode == SWT.F2)
+ {
+ if (length == 1)
+ actionRename();
+ } else if (event.keyCode == SWT.DEL)
+ {
+ actionDelete();
+ }
+ if ((event.stateMask == SWT.ALT) && (event.keyCode == SWT.CR))
+ {
+ actionShowProperty();
+ }
+ }
+
+ private void actionAddFile()
+ {
+ panel.addNewFileSelection();
+ }
+
+ private void actionAddFolder()
+ {
+ panel.addNewFolderSelection();
+ }
+
+ private void actionPush()
+ {
+ panel.pushIntoSelection();
+ }
+
+ private void actionPull()
+ {
+ panel.pullSelection();
+ }
+
+ private void actionRefresh()
+ {
+ panel.refreshSelection();
+ }
+
+ private void actionDelete()
+ {
+ panel.deleteSelection();
+ }
+
+ private void actionRename()
+ {
+ panel.renameSelection();
+ }
+
+ private void actionShowProperty()
+ {
+ panel.showPropertySelection(getSite());
+ }
+
+ /*
+ * make actions
+ */
+ private void makeActions()
+ {
+ subMenu = new MenuManager(ConnectionUIMessages.Explorer_ConetextMenu_New, null);
+
+ actionAddFile = new Action()
+ {
+ @Override
+ public void run()
+ {
+ actionAddFile();
+ }
+ };
+ actionAddFile.setText(ConnectionUIMessages.Explorer_ConetextMenu_File);
+
+ actionAddFolder = new Action()
+ {
+ @Override
+ public void run()
+ {
+ actionAddFolder();
+ }
+ };
+ actionAddFolder.setText(ConnectionUIMessages.Explorer_ConetextMenu_Folder);
+
+ actionPush = new Action()
+ {
+ @Override
+ public void run()
+ {
+ actionPush();
+ }
+ };
+ actionPush.setText(ConnectionUIMessages.Explorer_ConetextMenu_Push);
+
+ actionPull = new Action()
+ {
+ @Override
+ public void run()
+ {
+ actionPull();
+ }
+ };
+ actionPull.setText(ConnectionUIMessages.Explorer_ConetextMenu_Pull);
+
+ // Add refresh action
+ actionRefresh = new Action()
+ {
+ @Override
+ public void run()
+ {
+ actionRefresh();
+ }
+ };
+ actionRefresh.setText(ConnectionUIMessages.Explorer_ConetextMenu_Refresh);
+ actionRefresh.setActionDefinitionId("org.tizen.common.connection.refresh");
+
+ actionRename = new Action()
+ {
+ @Override
+ public void run()
+ {
+ actionRename();
+ }
+ };
+
+ actionRename.setText(ConnectionUIMessages.Explorer_ConetextMenu_Rename);
+ actionRename.setActionDefinitionId("org.tizen.common.connection.rename");
+
+ actionDelete = new Action()
+ {
+ @Override
+ public void run()
+ {
+ actionDelete();
+ }
+ };
+ actionDelete.setText(ConnectionUIMessages.Explorer_ConetextMenu_Delete);
+ actionDelete.setActionDefinitionId("org.tizen.common.connection.delete");
+
+ actionProperty = new Action()
+ {
+ @Override
+ public void run()
+ {
+ panel.showPropertySelection(getSite());
+ }
+ };
+ actionProperty.setText(ConnectionUIMessages.Explorer_ConetextMenu_Property);
+ actionProperty.setActionDefinitionId("org.tizen.common.connection.property");
+
+ }
+
+ private void initContextMenu()
+ {
+ // initalize the context menu
+ menuMgr = new MenuManager("Connection Explorer MenuMgr"); //$NON-NLS-1$
+ menuMgr.setRemoveAllWhenShown(true);
+ menuMgr.addMenuListener(new IMenuListener()
+ {
+
+ @Override
+ public void menuAboutToShow(IMenuManager manager)
+ {
+ fillContextMenu(manager);
+ }
+ });
+
+ Menu menu = menuMgr.createContextMenu(panel.getTreeViewer().getTree());
+ panel.getTreeViewer().getTree().setMenu(menu);
+ getSite().registerContextMenu(menuMgr, panel.getTreeViewer());
+
+ menuMgr.addMenuListener(new IMenuListener()
+ {
+ @Override
+ public void menuAboutToShow(IMenuManager manager)
+ {
+ // Remove team menu from our menu
+ IContributionItem[] items = manager.getItems();
+ if (items != null)
+ {
+ for (IContributionItem item : items)
+ {
+ if (("team.main").equals(item.getId()))
+ {
+ manager.remove(item);
+ break;
+ }
+ }
+ }
+ }
+ });
+ }
+
+ private void activateContext()
+ {
+ IContextService contextService = (IContextService) getSite().getService(IContextService.class);
+ contextService.activateContext("org.tizen.common.connection.delete.context");
+ contextService.activateContext("org.tizen.common.connection.rename.context");
+ contextService.activateContext("org.tizen.common.connection.refresh.context");
+ contextService.activateContext("org.tizen.common.connection.property.context");
+
+ }
+
+ private void fillContextMenu(IMenuManager manager)
+ {
+ subMenu.add(actionAddFile);
+ subMenu.add(actionAddFolder);
+ manager.add(subMenu);
+ manager.add(new Separator());
+ manager.add(actionPush);
+ manager.add(actionPull);
+ manager.add(new Separator());
+ manager.add(actionRefresh);
+ manager.add(new Separator());
+ manager.add(actionRename);
+ manager.add(actionDelete);
+ manager.add(new Separator());
+ manager.add(actionProperty);
+ manager.add(new Separator());
+ }
+
+ private void createToolBar(Composite shell, Object layoutData)
+ {
+
+ toolBar = new ToolBar(shell, SWT.NULL);
+ toolBar.setLayoutData(layoutData);
+
+ new ToolItem(toolBar, SWT.SEPARATOR); // Separator
+
+ emulManagerToolItem = new ToolItem(toolBar, SWT.PUSH);
+ emulManagerToolItem.setImage(ConnectionPlugin.getImageDescriptorFromPlugin("icons/emulator_manager.gif").createImage());
+ emulManagerToolItem.setToolTipText(ConnectionUIMessages.Explorer_Tooltip_EmulatorManager);
+ emulManagerToolItem.addSelectionListener(new SelectionAdapter()
+ {
+ @Override
+ public void widgetSelected(SelectionEvent e)
+ {
+ try
+ {
+ startEmulatorManager();
+ } catch (Exception e1)
+ {
+ e1.printStackTrace();
+ }
+ }
+ });
+ emulManagerToolItem.setEnabled(true);
+
+ new ToolItem(toolBar, SWT.SEPARATOR); // Separator
+
+ pushToolItem = new ToolItem(toolBar, SWT.PUSH);
+ pushToolItem.setImage(ConnectionPlugin.getImageDescriptorFromPlugin("icons/push.gif").createImage());
+ pushToolItem.setToolTipText(ConnectionUIMessages.Explorer_Tooltip_Push);
+ pushToolItem.addSelectionListener(new SelectionAdapter()
+ {
+ @Override
+ public void widgetSelected(SelectionEvent e)
+ {
+ panel.pushIntoSelection();
+ }
+ });
+ pushToolItem.setEnabled(false);
+
+ new ToolItem(toolBar, SWT.SEPARATOR); // Separator
+
+ pullToolItem = new ToolItem(toolBar, SWT.PUSH);
+ pullToolItem.setImage(ConnectionPlugin.getImageDescriptorFromPlugin("icons/pull.gif").createImage());
+ pullToolItem.setToolTipText(ConnectionUIMessages.Explorer_Tooltip_Pull);
+ pullToolItem.addSelectionListener(new SelectionAdapter()
+ {
+ @Override
+ public void widgetSelected(SelectionEvent e)
+ {
+ panel.pullSelection();
+ }
+ });
+ pullToolItem.setEnabled(false);
+ new ToolItem(toolBar, SWT.SEPARATOR); // Separator
+ }
+
+ @Override
+ public void setFocus()
+ {
+ if(parent != null)
+ {
+ parent.setFocus();
+ }
+ }
+
+ private void startEmulatorManager() throws Exception
+ {
+ String exePath = null;
+ int osType = ConnectionPlugin.getDefault().os;
+ int linuxType = ConnectionPlugin.LINUX;
+
+ if (osType == linuxType)
+ {
+ exePath = EMULATOR_PATH + File.separatorChar + EMULATOR_BINARY;
+ } else
+ {
+ exePath = EMULATOR_PATH + File.separatorChar + EMULATOR_BATCH;
+ }
+
+ if (exePath.equals("") || (!exePath.equals("") && !HostUtil.exists(exePath)))
+ {
+ throw new Exception(ConnectionUIMessages.Explorer_Message_EmulatorError);
+ }
+
+ // FIXME : should implement the lines below based on windows system.
+ String command = exePath;
+ if (osType == linuxType)
+ {
+ command = command + " 1>/dev/null 2>/dev/null &";
+
+ HostUtil.execute(command);
+ } else
+ {
+ HostUtil.batchExecute(command, null, new File(EMULATOR_PATH));
+ }
+ }
} \ No newline at end of file
diff --git a/org.tizen.common.connection/src/org/tizen/common/connection/ui/ConnectionUIMessages.java b/org.tizen.common.connection/src/org/tizen/common/connection/ui/ConnectionUIMessages.java
new file mode 100644
index 000000000..b0c28b6e1
--- /dev/null
+++ b/org.tizen.common.connection/src/org/tizen/common/connection/ui/ConnectionUIMessages.java
@@ -0,0 +1,61 @@
+/*
+ * Common
+ *
+ * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved.
+ *
+ * Contact:
+ * Kangho Kim <kh5225.kim@samsung.com>
+ * Hyunsik Noh <hyunsik.noh@samsung.com>
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ * Contributors:
+ * - S-Core Co., Ltd
+ *
+ */
+package org.tizen.common.connection.ui;
+
+import org.eclipse.osgi.util.NLS;
+
+public class ConnectionUIMessages extends NLS
+{
+ private static final String BUNDLE_NAME = ConnectionUIMessages.class.getPackage().getName() + ".ConnectionUIMessages"; //$NON-NLS-1$
+
+ public static String Explorer_ConetextMenu_New;
+ public static String Explorer_ConetextMenu_File;
+ public static String Explorer_ConetextMenu_Folder;
+ public static String Explorer_ConetextMenu_Push;
+ public static String Explorer_ConetextMenu_Pull;
+ public static String Explorer_ConetextMenu_Refresh;
+ public static String Explorer_ConetextMenu_Rename;
+ public static String Explorer_ConetextMenu_Delete;
+ public static String Explorer_ConetextMenu_Property;
+
+ public static String Explorer_Message_Invalid_Character;
+
+ public static String Explorer_Tooltip_EmulatorManager;
+ public static String Explorer_Tooltip_Push;
+ public static String Explorer_Tooltip_Pull;
+
+ public static String Explorer_Message_EmulatorError;
+
+ static
+ {
+ // initialize resource bundle
+ NLS.initializeMessages(BUNDLE_NAME, ConnectionUIMessages.class);
+ }
+
+ private ConnectionUIMessages()
+ {
+ }
+}
diff --git a/org.tizen.common.connection/src/org/tizen/common/connection/ui/ConnectionUIMessages.properties b/org.tizen.common.connection/src/org/tizen/common/connection/ui/ConnectionUIMessages.properties
new file mode 100644
index 000000000..056433f20
--- /dev/null
+++ b/org.tizen.common.connection/src/org/tizen/common/connection/ui/ConnectionUIMessages.properties
@@ -0,0 +1,17 @@
+Explorer_ConetextMenu_New = New
+Explorer_ConetextMenu_File = File
+Explorer_ConetextMenu_Folder = Folder
+Explorer_ConetextMenu_Push = Push the file
+Explorer_ConetextMenu_Pull = Pull the selected content
+Explorer_ConetextMenu_Refresh = Refresh
+Explorer_ConetextMenu_Rename = Rename
+Explorer_ConetextMenu_Delete = Delete
+Explorer_ConetextMenu_Property = Properties
+
+Explorer_Tooltip_EmulatorManager = Emulator Manager
+Explorer_Tooltip_Push = Push the file to the connected target device
+Explorer_Tooltip_Pull = Pull the content from the connected target device
+
+Explorer_Message_Invalid_Character = File contains invalid characters like
+
+Explorer_Message_EmulatorError = Emulator is not installed or the install path is invalid.
diff --git a/org.tizen.common.connection/src/org/tizen/common/connection/ui/LogView.java b/org.tizen.common.connection/src/org/tizen/common/connection/ui/LogView.java
index a48f3923c..837bcd344 100644
--- a/org.tizen.common.connection/src/org/tizen/common/connection/ui/LogView.java
+++ b/org.tizen.common.connection/src/org/tizen/common/connection/ui/LogView.java
@@ -1,28 +1,28 @@
/*
-* Common
-*
-* Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved.
-*
-* Contact:
-* Hoon Kang <h245.kang@samsung.com>
-* Hyunsik Noh <hyunsik.noh@samsung.com>
-*
+ * Common
+ *
+ * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved.
+ *
+ * Contact:
+ * Hoon Kang <h245.kang@samsung.com>
+ * Hyunsik Noh <hyunsik.noh@samsung.com>
+ *
* Licensed under the Apache License, Version 2.0 (the "License");
-* you may not use this file except in compliance with the License.
-* You may obtain a copy of the License at
-*
-* http://www.apache.org/licenses/LICENSE-2.0
-*
-* Unless required by applicable law or agreed to in writing, software
-* distributed under the License is distributed on an "AS IS" BASIS,
-* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-* See the License for the specific language governing permissions and
-* limitations under the License.
-*
-* Contributors:
-* - S-Core Co., Ltd
-*
-*/
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ * Contributors:
+ * - S-Core Co., Ltd
+ *
+ */
package org.tizen.common.connection.ui;
import org.eclipse.jface.action.Action;
@@ -31,12 +31,13 @@ import org.eclipse.jface.action.IMenuManager;
import org.eclipse.jface.action.IToolBarManager;
import org.eclipse.jface.action.Separator;
import org.eclipse.swt.dnd.Clipboard;
-import org.eclipse.swt.graphics.Color;
import org.eclipse.swt.widgets.Composite;
import org.eclipse.swt.widgets.Display;
import org.eclipse.ui.IActionBars;
+import org.eclipse.ui.PlatformUI;
import org.eclipse.ui.actions.ActionFactory;
import org.eclipse.ui.part.ViewPart;
+import org.tizen.common.TizenHelpContextIds;
import org.tizen.common.connection.ConnectionPlugin;
import org.tizen.common.connection.log.LogColors;
import org.tizen.common.connection.log.LogPanel;
@@ -46,184 +47,232 @@ import org.tizen.sdblib.Log.LogLevel;
* The log cat view displays log output from the current device selection.
*
*/
-public final class LogView extends ViewPart {
-
- public static final String ID = "org.tizen.common.connection.ui.LogView"; //$NON-NLS-1$
-
- private LogPanel logPanel;
-
- private Action addAction;
- private Action removeAction;
- private Action editAction;
- private Action exportAction;
- private Action clearAction;
-
- private Action[] logLevelActions;
- private final String[] logLevelIcons = { "icons/log/v.png", //$NON-NLS-1S
- "icons/log/d.png", //$NON-NLS-1S
- "icons/log/i.png", //$NON-NLS-1S
- "icons/log/w.png", //$NON-NLS-1S
- "icons/log/e.png", //$NON-NLS-1S
- };
-
- private Clipboard clipboard;
-
- @Override
- public void createPartControl(Composite parent) {
- Display d = parent.getDisplay();
- LogColors colors = new LogColors();
-
- colors.infoColor = new Color(d, 0, 127, 0);
- colors.debugColor = new Color(d, 0, 0, 127);
- colors.errorColor = new Color(d, 255, 0, 0);
- colors.warningColor = new Color(d, 255, 127, 0);
- colors.verboseColor = new Color(d, 0, 0, 0);
-
- addAction = new Action("add Tab") {
- @Override
- public void run() {
- logPanel.addTab();
- }
- };
- addAction.setToolTipText("Add LogTab");
- addAction.setImageDescriptor(ConnectionPlugin.getImageDescriptorFromPlugin("icons/log/Add tab.png"));
-
- removeAction = new Action("Remove Tab") {
- @Override
- public void run() {
- logPanel.removeTab();
- }
- };
- removeAction.setToolTipText("Remove LogTab");
- removeAction.setImageDescriptor(ConnectionPlugin.getImageDescriptorFromPlugin("icons/log/Remove tab.png"));
-
- editAction = new Action("Edit Tab") {
- @Override
- public void run() {
- logPanel.editTab();
- }
- };
- editAction.setToolTipText("Edit LogTab");
- editAction.setImageDescriptor(ConnectionPlugin.getImageDescriptorFromPlugin("icons/log/Edit tab.png"));
-
- exportAction = new Action("Export Log") {
- @Override
- public void run() {
- logPanel.save();
- }
- };
- exportAction.setToolTipText("Export Log");
- exportAction.setImageDescriptor(
- ConnectionPlugin.getImageDescriptorFromPlugin("icons/log/Export Log.png")); //$NON-NLS-1$
-
- clearAction = new Action("Clear Log") {
- @Override
- public void run() {
- logPanel.clear();
- }
- };
- clearAction.setToolTipText("Clear Log");
- clearAction.setImageDescriptor(
- ConnectionPlugin.getImageDescriptorFromPlugin("icons/log/Clear Log.png")); //$NON-NLS-1$
-
- LogLevel[] levels = LogLevel.values();
- logLevelActions = new Action[logLevelIcons.length];
- for (int i = 0; i < logLevelActions.length; i++) {
- String name = levels[i].getStringValue();
- logLevelActions[i] = new Action(name, IAction.AS_CHECK_BOX) {
- @Override
- public void run() {
- // disable the other actions and record
- // current index
- for (int i = 0; i < logLevelActions.length; i++) {
- Action a = logLevelActions[i];
- if (a == this) {
- if (logPanel.getCurrentLogTab() != null) {
- if (a.isChecked())
- a.setChecked(a.isChecked());
- logPanel.getCurrentLogTab().setLevel(i , a.isChecked());
- logPanel.getCurrentLogTab().refill();
- }
- }
- }
- }
- };
- logLevelActions[i].setChecked(true);
- logLevelActions[i].setToolTipText(name);
- logLevelActions[i].setImageDescriptor(ConnectionPlugin.getImageDescriptorFromPlugin(logLevelIcons[i]));
- }
-
- // now create the log view
- logPanel = new LogPanel(colors);
-
- logPanel.setActions(logLevelActions, addAction, removeAction, editAction, exportAction, clearAction);
- placeActions();
- logPanel.setActionEnabled(LogPanel.ACTION_NOTHING);
- logPanel.createPanel(parent);
-
- // setup the copy action
- clipboard = new Clipboard(d);
- IActionBars actionBars = getViewSite().getActionBars();
- actionBars.setGlobalActionHandler(ActionFactory.COPY.getId(), new Action("Copy") {
- @Override
- public void run() {
- logPanel.copy(clipboard);
- }
- });
-
- // setup the select all action
- actionBars.setGlobalActionHandler(ActionFactory.SELECT_ALL.getId(), new Action(
- "Select All") {
- @Override
- public void run() {
- logPanel.selectAll();
- }
- });
- }
-
- @Override
- public void dispose() {
- logPanel.stopAll();
- }
-
- @Override
- public void setFocus() {
- logPanel.setFocus();
- }
-
- /**
- * Place the actions in the ui.
- */
- private void placeActions() {
- IActionBars actionBars = getViewSite().getActionBars();
-
- // first in the menu
- IMenuManager menuManager = actionBars.getMenuManager();
- menuManager.add(addAction);
- menuManager.add(removeAction);
- menuManager.add(editAction);
- menuManager.add(new Separator());
- menuManager.add(exportAction);
- menuManager.add(clearAction);
- menuManager.add(new Separator());
-
- // and then in the toolbar
- IToolBarManager toolBarManager = actionBars.getToolBarManager();
- toolBarManager.add(new Separator());
- for (Action a : logLevelActions) {
- toolBarManager.add(a);
- }
- toolBarManager.add(new Separator());
- toolBarManager.add(addAction);
- toolBarManager.add(removeAction);
- toolBarManager.add(editAction);
- toolBarManager.add(new Separator());
- toolBarManager.add(exportAction);
- toolBarManager.add(clearAction);
- toolBarManager.add(new Separator());
- }
-
- public LogPanel getPanel() {
- return logPanel;
- }
+public final class LogView extends ViewPart
+{
+
+ public static final String ID = "org.tizen.common.connection.ui.LogView"; //$NON-NLS-1$
+
+ private LogPanel logPanel;
+ private Composite parent;
+
+ private Action addAction;
+ private Action removeAction;
+ private Action editAction;
+ private Action scrollLockAction;
+ private Action exportAction;
+ private Action clearAction;
+
+ private Action[] viewActions;
+ private Action[] logLevelActions;
+ private final String[] logLevelIcons = { "icons/log/v.png", //$NON-NLS-1S
+ "icons/log/d.png", //$NON-NLS-1S
+ "icons/log/i.png", //$NON-NLS-1S
+ "icons/log/w.png", //$NON-NLS-1S
+ "icons/log/e.png", //$NON-NLS-1S
+ };
+
+ private Clipboard clipboard;
+ private LogColors colors;
+
+ @Override
+ public void createPartControl(Composite p)
+ {
+ parent = p;
+ PlatformUI.getWorkbench().getHelpSystem().setHelp(parent, TizenHelpContextIds.HELP_COMMON_LOG_CONTEXT);
+ Display d = parent.getDisplay();
+ colors = new LogColors(d);
+
+ addAction = new Action("add Tab")
+ {
+ @Override
+ public void run()
+ {
+ logPanel.addTab();
+ }
+ };
+ addAction.setToolTipText("Add LogTab");
+ addAction.setImageDescriptor(ConnectionPlugin.getImageDescriptorFromPlugin("icons/log/add_tab.png"));
+
+ removeAction = new Action("Remove Tab")
+ {
+ @Override
+ public void run()
+ {
+ logPanel.removeTab();
+ }
+ };
+ removeAction.setToolTipText("Remove LogTab");
+ removeAction.setImageDescriptor(ConnectionPlugin.getImageDescriptorFromPlugin("icons/log/remove_tab.png"));
+
+ editAction = new Action("Edit Tab")
+ {
+ @Override
+ public void run()
+ {
+ logPanel.editTab();
+ }
+ };
+ editAction.setToolTipText("Edit LogTab");
+ editAction.setImageDescriptor(ConnectionPlugin.getImageDescriptorFromPlugin("icons/log/edit_tab.png"));
+
+ scrollLockAction = new Action("Scroll Lock")
+ {
+ @Override
+ public void run()
+ {
+ scrollLockAction.setChecked(scrollLockAction.isChecked());
+ logPanel.setScrollLock(scrollLockAction.isChecked());
+ }
+ };
+ scrollLockAction.setToolTipText("Scroll Lock");
+ scrollLockAction.setChecked(false);
+ scrollLockAction.setImageDescriptor(ConnectionPlugin.getImageDescriptorFromPlugin("icons/log/scroll_lock.png"));
+
+ exportAction = new Action("Export the log")
+ {
+ @Override
+ public void run()
+ {
+ logPanel.save();
+ }
+ };
+ exportAction.setToolTipText("Export the log");
+ exportAction.setImageDescriptor(ConnectionPlugin.getImageDescriptorFromPlugin("icons/log/export_log.png")); //$NON-NLS-1$
+
+ clearAction = new Action("Clear the log")
+ {
+ @Override
+ public void run()
+ {
+ logPanel.clear();
+ }
+ };
+ clearAction.setToolTipText("Clear the log");
+ clearAction.setImageDescriptor(ConnectionPlugin.getImageDescriptorFromPlugin("icons/log/clear_log.png")); //$NON-NLS-1$
+
+ LogLevel[] levels = LogLevel.values();
+ logLevelActions = new Action[logLevelIcons.length];
+ for (int i = 0; i < logLevelActions.length; i++)
+ {
+ String name = levels[i].getStringValue();
+ logLevelActions[i] = new Action(name, IAction.AS_CHECK_BOX)
+ {
+ @Override
+ public void run()
+ {
+ // disable the other actions and record
+ // current index
+ for (int i = 0; i < logLevelActions.length; i++)
+ {
+ Action a = logLevelActions[i];
+ if (a == this)
+ {
+ if (logPanel.getSelectionLogTab() != null)
+ {
+ if (a.isChecked())
+ a.setChecked(a.isChecked());
+ logPanel.setLevel(i, a.isChecked());
+ }
+ }
+ }
+ }
+ };
+ logLevelActions[i].setChecked(true);
+ logLevelActions[i].setToolTipText(name);
+ logLevelActions[i].setImageDescriptor(ConnectionPlugin.getImageDescriptorFromPlugin(logLevelIcons[i]));
+ }
+
+ // now create the log view
+ logPanel = new LogPanel(colors);
+ viewActions = new Action[]{addAction, removeAction, editAction, scrollLockAction, exportAction, clearAction};
+ logPanel.setActions(logLevelActions, viewActions);
+ placeActions();
+ logPanel.setEnabledForActions(LogPanel.NO_TAB);
+ logPanel.createPanel(parent);
+
+ // setup the copy action
+ clipboard = new Clipboard(d);
+ IActionBars actionBars = getViewSite().getActionBars();
+ actionBars.setGlobalActionHandler(ActionFactory.COPY.getId(), new Action("Copy")
+ {
+ @Override
+ public void run()
+ {
+ logPanel.copy(clipboard);
+ }
+ });
+
+ // setup the select all action
+ actionBars.setGlobalActionHandler(ActionFactory.SELECT_ALL.getId(), new Action("Select All")
+ {
+ @Override
+ public void run()
+ {
+ logPanel.selectAll();
+ }
+ });
+ }
+
+ @Override
+ public void dispose()
+ {
+ if (clipboard != null && !clipboard.isDisposed())
+ {
+ clipboard.dispose();
+ }
+ logPanel.stopAllTabItems();
+ colors.dispose();
+ super.dispose();
+ }
+
+ @Override
+ public void setFocus()
+ {
+ if(parent != null)
+ {
+ parent.setFocus();
+ }
+ logPanel.setFocus();
+ }
+
+ /**
+ * Place the actions in the ui.
+ */
+ private void placeActions()
+ {
+ IActionBars actionBars = getViewSite().getActionBars();
+
+ // first in the menu
+ IMenuManager menuManager = actionBars.getMenuManager();
+ menuManager.add(addAction);
+ menuManager.add(removeAction);
+ menuManager.add(editAction);
+ menuManager.add(new Separator());
+ menuManager.add(exportAction);
+ menuManager.add(clearAction);
+ menuManager.add(new Separator());
+
+ // and then in the toolbar
+ IToolBarManager toolBarManager = actionBars.getToolBarManager();
+ toolBarManager.add(new Separator());
+ for (Action a : logLevelActions)
+ {
+ toolBarManager.add(a);
+ }
+ toolBarManager.add(new Separator());
+ toolBarManager.add(addAction);
+ toolBarManager.add(removeAction);
+ toolBarManager.add(editAction);
+ toolBarManager.add(new Separator());
+ toolBarManager.add(scrollLockAction);
+ toolBarManager.add(new Separator());
+ toolBarManager.add(exportAction);
+ toolBarManager.add(clearAction);
+ toolBarManager.add(new Separator());
+ }
+
+ public LogPanel getPanel()
+ {
+ return logPanel;
+ }
} \ No newline at end of file
diff --git a/org.tizen.common.connection/src/org/tizen/common/connection/ui/TizenRemoteFileDialog.java b/org.tizen.common.connection/src/org/tizen/common/connection/ui/TizenRemoteFileDialog.java
index d5ec924f9..2acb7d20c 100644
--- a/org.tizen.common.connection/src/org/tizen/common/connection/ui/TizenRemoteFileDialog.java
+++ b/org.tizen.common.connection/src/org/tizen/common/connection/ui/TizenRemoteFileDialog.java
@@ -3,10 +3,10 @@
*
* Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved.
*
-* Contact:
+* Contact:
* Hoon Kang <h245.kang@samsung.com>
* Yoonki Park <yoonki.park@samsung.com>
-*
+*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
@@ -25,12 +25,17 @@
*/
package org.tizen.common.connection.ui;
+import java.io.IOException;
+
import org.eclipse.jface.viewers.ITableLabelProvider;
import org.eclipse.jface.viewers.TreeViewer;
import org.eclipse.swt.SWT;
-import org.eclipse.swt.SWTException;
+import org.eclipse.swt.events.ControlAdapter;
+import org.eclipse.swt.events.ControlEvent;
import org.eclipse.swt.events.SelectionAdapter;
import org.eclipse.swt.events.SelectionEvent;
+import org.eclipse.swt.graphics.Point;
+import org.eclipse.swt.graphics.Rectangle;
import org.eclipse.swt.layout.GridData;
import org.eclipse.swt.layout.GridLayout;
import org.eclipse.swt.widgets.Button;
@@ -39,23 +44,26 @@ import org.eclipse.swt.widgets.Display;
import org.eclipse.swt.widgets.Event;
import org.eclipse.swt.widgets.Label;
import org.eclipse.swt.widgets.Listener;
+import org.eclipse.swt.widgets.ScrollBar;
import org.eclipse.swt.widgets.Shell;
import org.eclipse.swt.widgets.Tree;
import org.eclipse.swt.widgets.TreeColumn;
import org.eclipse.swt.widgets.TreeItem;
-
+import org.tizen.common.TizenPlatformConstants;
+import org.tizen.common.util.log.Logger;
import org.tizen.sdblib.FileListingService.FileEntry;
import org.tizen.sdblib.IDevice;
+import org.tizen.sdblib.MultiLineReceiver;
public class TizenRemoteFileDialog {
- public enum TizenRemoteFileDialogResult {
- OK,
- CANCEL
- }
-
- private TizenRemoteFileDialogResult result = TizenRemoteFileDialogResult.CANCEL;
- private IDevice device;
+ public enum TizenRemoteFileDialogResult {
+ OK,
+ CANCEL
+ }
+
+ private TizenRemoteFileDialogResult result = TizenRemoteFileDialogResult.CANCEL;
+ private IDevice device;
private Shell shell;
private Display display;
private boolean isDirOnly = false;
@@ -64,13 +72,11 @@ public class TizenRemoteFileDialog {
private FileEntry selectedDir;
private Tree pathTree;
private TreeViewer pathTreeViewer;
+ private Composite upper;
TizenRemoteFileContentProvider remoteContentProvider = null;
- public TizenRemoteFileDialog(Shell parent, String dlgTitle, IDevice device,
- boolean isDirOnly, String defaultPath)
- throws IllegalArgumentException {
-
+ public TizenRemoteFileDialog(Shell parent, String dlgTitle, IDevice device, boolean isDirOnly, String defaultPath) throws IllegalArgumentException {
if (parent == null || device == null)
throw new IllegalArgumentException();
@@ -78,14 +84,22 @@ public class TizenRemoteFileDialog {
shell = createNewShell(parent);
shell.setText(dlgTitle);
shell.setSize(300, 400);
+ shell.addListener(SWT.Traverse, new Listener() {
+ public void handleEvent(Event event) {
+ switch (event.detail) {
+ case SWT.TRAVERSE_ESCAPE:
+ shell.close();
+ event.detail = SWT.TRAVERSE_NONE;
+ event.doit = false;
+ break;
+ }
+ }
+ });
this.device = device;
this.isDirOnly = isDirOnly;
- if (defaultPath != null)
- this.defaultPath = defaultPath;
- else
- this.defaultPath = "/";
+ setDefaultPath(defaultPath);
createControls(shell);
}
@@ -101,7 +115,7 @@ public class TizenRemoteFileDialog {
}
private void createControls(Composite parent) {
- Composite upper = new Composite(parent, SWT.NONE);
+ upper = new Composite(parent, SWT.NONE);
setUpperLayout(upper);
createPathLabels(upper);
createPathTree(upper);
@@ -112,18 +126,22 @@ public class TizenRemoteFileDialog {
}
private void fillPathTree() {
- createTreeColumn();
- createTreeViewer();
-
+ createTreeColumn();
+ createTreeViewer();
+
FileEntry root = device.getFileListingService().getRoot();
String[] defaultExpandedPath = defaultPath.substring(1).split("/");
cacheChild(root, defaultExpandedPath);
-
+
pathTreeViewer.setInput(root);
pathTreeViewer.expandAll();
-
+
selectDefaultPath(defaultExpandedPath);
+ // set default path to the top item.
+ if (pathTree.getSelection().length > 0)
+ pathTreeViewer.getTree().setTopItem(pathTree.getSelection()[0]);
+
remoteContentProvider.setInitialize(true);
pathTreeViewer.refresh();
@@ -133,7 +151,7 @@ public class TizenRemoteFileDialog {
TreeItem[] items = pathTree.getSelection();
if (items.length == 1) {
Object object = items[0].getData();
- if (object instanceof FileEntry) {
+ if (object instanceof FileEntry) {
selectedDir = (FileEntry) object;
path.setText(selectedDir.getFullPath());
}
@@ -159,7 +177,7 @@ public class TizenRemoteFileDialog {
}
}
}
-
+
if (found != null) {
pathTree.select(found);
Object data = found.getData();
@@ -179,9 +197,40 @@ public class TizenRemoteFileDialog {
}
private void createTreeColumn() {
- TreeColumn nameColumn = new TreeColumn(pathTree, SWT.LEFT);
+ final TreeColumn nameColumn = new TreeColumn(pathTree, SWT.LEFT);
nameColumn.setText("Name");
nameColumn.setWidth(100);
+
+ upper.addControlListener(new ControlAdapter() {
+ public void controlResized(ControlEvent e) {
+ Rectangle area = upper.getClientArea();
+ Point size = pathTree.computeSize(SWT.DEFAULT, SWT.DEFAULT);
+ ScrollBar vBar = pathTree.getVerticalBar();
+ int width = area.width - pathTree.computeTrim(0,0,0,0).width - vBar.getSize().x;
+ if (size.y > area.height + pathTree.getHeaderHeight()) {
+ // Subtract the scrollbar width from the total column width
+ // if a vertical scrollbar will be required
+ Point vBarSize = vBar.getSize();
+ width -= vBarSize.x;
+ }
+ Point oldSize = pathTree.getSize();
+ if (oldSize.x > area.width) {
+ // table is getting smaller so make the columns
+ // smaller first and then resize the table to
+ // match the client area width
+ //nameColumn.setWidth(width);
+ nameColumn.pack();
+ pathTree.setSize(area.width, area.height);
+ } else {
+ // table is getting bigger so make the table
+ // bigger first and then make the columns wider
+ // to match the client area width
+ pathTree.setSize(area.width, area.height);
+ //nameColumn.setWidth(width);
+ nameColumn.pack();
+ }
+ }
+ });
}
private void cacheChild(FileEntry root, String[] defaultExpandedPath) {
@@ -247,7 +296,8 @@ public class TizenRemoteFileDialog {
}
private void createPathTree(Composite pParent) {
- pathTree = new Tree(pParent, SWT.MULTI | SWT.FULL_SELECTION | SWT.VIRTUAL);
+ // if add SWT.VIRTUAL, horizontal scrol is not shown in case of Linux
+ pathTree = new Tree(pParent, SWT.MULTI | SWT.FULL_SELECTION);
setTreeLayout(pathTree);
}
@@ -272,7 +322,7 @@ public class TizenRemoteFileDialog {
}
break;
default:
-
+
}
}
});
@@ -309,21 +359,30 @@ public class TizenRemoteFileDialog {
}
private void runEventLoop(Shell loopShell) {
- Display tmpDisplay = null;
-
- if (shell == null)
- tmpDisplay = Display.getCurrent();
- else
- tmpDisplay = loopShell.getDisplay();
-
- while (loopShell != null && !loopShell.isDisposed()) {
- try {
- if (!tmpDisplay.readAndDispatch())
- tmpDisplay.sleep();
- } catch (SWTException e) {
- e.printStackTrace();
- }
+ Display tmpDisplay = loopShell.getDisplay();
+
+ while (!loopShell.isDisposed()) {
+ if (!tmpDisplay.readAndDispatch())
+ tmpDisplay.sleep();
}
display.update();
}
+
+ private void setDefaultPath(final String corePath) {
+ if (corePath == null)
+ defaultPath = "/";
+
+ String command = "ls " + TizenPlatformConstants.PRIVATE_PLATFORM_CORE_PATH + "/*/files/core.* 2&>/dev/null | wc -l";
+
+ try {
+ this.device.executeShellCommand(command, new MultiLineReceiver() {
+ @Override
+ public void processNewLines(String[] lines) {
+ defaultPath = "0".equals(lines[0]) ? corePath : TizenPlatformConstants.PRIVATE_PLATFORM_CORE_PATH;
+ }
+ });
+ } catch (IOException e) {
+ Logger.error("Problem occurred while executing command '" + command + "'", e.getMessage(), e);
+ }
+ }
} \ No newline at end of file
diff --git a/org.tizen.common.connection/src/org/tizen/common/connection/ui/TizenRemoteFileLabelProvider.java b/org.tizen.common.connection/src/org/tizen/common/connection/ui/TizenRemoteFileLabelProvider.java
index 25931bdc6..160a67584 100644..100755
--- a/org.tizen.common.connection/src/org/tizen/common/connection/ui/TizenRemoteFileLabelProvider.java
+++ b/org.tizen.common.connection/src/org/tizen/common/connection/ui/TizenRemoteFileLabelProvider.java
@@ -107,9 +107,12 @@ public class TizenRemoteFileLabelProvider implements ITableLabelProvider {
case 4:
return entry.getInfo();
default:
+ break;
}
}
+ break;
default:
+ break;
}
} else if (element instanceof IDevice) {
IDevice device = (IDevice) element;