Added IWorkbenchAdapter for properties
authorkh5325.kim <kh5325.kim@samsung.com>
Thu, 5 Sep 2013 02:48:23 +0000 (11:48 +0900)
committerkh5325.kim <kh5325.kim@samsung.com>
Thu, 5 Sep 2013 02:48:23 +0000 (11:48 +0900)
org.tizen.common.connection/plugin.xml
org.tizen.common.connection/src/org/tizen/common/connection/ConnectionPlugin.java
org.tizen.common.connection/src/org/tizen/common/connection/FileEntryAdapter.java [new file with mode: 0644]
org.tizen.common.connection/src/org/tizen/common/connection/FileEntryAdapterFactory.java [new file with mode: 0644]

index bc93d12..639cffd 100644 (file)
             nameFilter="*"
             objectClass="org.tizen.sdblib.service.FileEntry">
       </page>
-         <page
-               class="org.tizen.common.connection.properties.ConnectionExplorerPermissionPropertyPages"
-               id="org.tizen.common.connection.properties.Permission"
-               name="%properties.page.permission"
-               nameFilter="*"
-               objectClass="org.tizen.sdblib.service.FileEntry">
+      <page
+            class="org.tizen.common.connection.properties.ConnectionExplorerPermissionPropertyPages"
+            id="org.tizen.common.connection.properties.Permission"
+            name="%properties.page.permission"
+            nameFilter="*"
+            objectClass="org.tizen.sdblib.service.FileEntry">
       </page>
    </extension>
    <extension
index e071c48..ee5b9e6 100755 (executable)
@@ -29,6 +29,9 @@ package org.tizen.common.connection;
 
 import java.util.ArrayList;
 
+import org.eclipse.core.runtime.IAdapterFactory;
+import org.eclipse.core.runtime.IAdapterManager;
+import org.eclipse.core.runtime.Platform;
 import org.eclipse.jface.preference.IPreferenceStore;
 import org.eclipse.jface.resource.ImageDescriptor;
 import org.eclipse.ui.plugin.AbstractUIPlugin;
@@ -86,21 +89,22 @@ public class ConnectionPlugin extends AbstractUIPlugin {
      * @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())
-        {
+        if (OSChecker.isWindows()) {
             this.os = WINDOWS;
         }
-        else
-        {
+        else {
             this.os = LINUX;
         }
 
+        IAdapterManager manager = Platform.getAdapterManager();
+        // properties adapters
+        IAdapterFactory factory = new FileEntryAdapterFactory();
+        manager.registerAdapters(factory, FileEntry.class);
     }
-    
+
     /* (non-Javadoc)
      * @see org.eclipse.ui.plugin.AbstractUIPlugin#initializeDefaultPreferences(org.eclipse.jface.preference.IPreferenceStore)
      */
@@ -119,8 +123,7 @@ public class ConnectionPlugin extends AbstractUIPlugin {
         plugin = null;
 
         int deviceCnt = SmartDevelopmentBridge.getBridge().getDevices().length;
-        if (deviceCnt==0)
-        {
+        if (deviceCnt == 0) {
             SmartDevelopmentBridge.disconnectBridge();
         }
         super.stop(context);
diff --git a/org.tizen.common.connection/src/org/tizen/common/connection/FileEntryAdapter.java b/org.tizen.common.connection/src/org/tizen/common/connection/FileEntryAdapter.java
new file mode 100644 (file)
index 0000000..f183d83
--- /dev/null
@@ -0,0 +1,58 @@
+/*
+ *  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
+ *
+ */ 
+
+package org.tizen.common.connection;
+
+import org.eclipse.jface.resource.ImageDescriptor;
+import org.eclipse.ui.model.IWorkbenchAdapter;
+import org.tizen.sdblib.service.FileEntry;
+
+/**
+ * The Adapter class for providing the properties.
+ */
+public class FileEntryAdapter implements IWorkbenchAdapter {
+    @Override
+    public Object[] getChildren(Object o) {
+        return null;
+    }
+
+    @Override
+    public ImageDescriptor getImageDescriptor(Object object) {
+        return null;
+    }
+
+    @Override
+    public String getLabel(Object o) {
+        if (o instanceof FileEntry)
+            return ((FileEntry) o).getName();
+        return null;
+    }
+
+    @Override
+    public Object getParent(Object o) {
+        return null;
+    }
+}
diff --git a/org.tizen.common.connection/src/org/tizen/common/connection/FileEntryAdapterFactory.java b/org.tizen.common.connection/src/org/tizen/common/connection/FileEntryAdapterFactory.java
new file mode 100644 (file)
index 0000000..772c770
--- /dev/null
@@ -0,0 +1,53 @@
+/*
+ *  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
+ *
+ */ 
+
+package org.tizen.common.connection;
+
+import org.eclipse.core.runtime.IAdapterFactory;
+import org.eclipse.ui.model.IWorkbenchAdapter;
+import org.tizen.sdblib.service.FileEntry;
+
+/**
+ * The AdapterFactory class for providing the properties.
+ */
+public class FileEntryAdapterFactory implements IAdapterFactory {
+    private Object fileEntryAdapter = new FileEntryAdapter();
+
+    @Override
+    public Object getAdapter(Object adaptableObject, Class adapterType) {
+        if (adapterType == IWorkbenchAdapter.class) {
+            if (adaptableObject instanceof FileEntry) {
+                return fileEntryAdapter;
+            }
+        }
+        return null;
+    }
+
+    @Override
+    public Class[] getAdapterList() {
+        return new Class[] { IWorkbenchAdapter.class };
+    }
+}