[Title] support linkfile listing
authorYoonKi Park <yoonki.park@samsung.com>
Mon, 29 Aug 2011 13:45:25 +0000 (22:45 +0900)
committerYoonKi Park <yoonki.park@samsung.com>
Mon, 29 Aug 2011 13:45:25 +0000 (22:45 +0900)
com.samsung.slp.common.connection/icons/file.gif [new file with mode: 0644]
com.samsung.slp.common.connection/icons/file_link.gif [new file with mode: 0644]
com.samsung.slp.common.connection/icons/folder.gif [new file with mode: 0644]
com.samsung.slp.common.connection/icons/folder_link.gif [new file with mode: 0644]
com.samsung.slp.common.connection/src/com/samsung/slp/common/connection/ddmlib/FileListingService.java
com.samsung.slp.common.connection/src/com/samsung/slp/common/connection/ddmuilib/DevicePanel.java
com.samsung.slp.common.connection/src/com/samsung/slp/common/connection/ddmuilib/explorer/DeviceContentProvider.java
com.samsung.slp.common.connection/src/com/samsung/slp/common/connection/ddmuilib/explorer/DeviceExplorer.java
com.samsung.slp.common.connection/src/com/samsung/slp/common/connection/ui/ConnectionsView.java

diff --git a/com.samsung.slp.common.connection/icons/file.gif b/com.samsung.slp.common.connection/icons/file.gif
new file mode 100644 (file)
index 0000000..7ccc6a7
Binary files /dev/null and b/com.samsung.slp.common.connection/icons/file.gif differ
diff --git a/com.samsung.slp.common.connection/icons/file_link.gif b/com.samsung.slp.common.connection/icons/file_link.gif
new file mode 100644 (file)
index 0000000..caa39dc
Binary files /dev/null and b/com.samsung.slp.common.connection/icons/file_link.gif differ
diff --git a/com.samsung.slp.common.connection/icons/folder.gif b/com.samsung.slp.common.connection/icons/folder.gif
new file mode 100644 (file)
index 0000000..310eb18
Binary files /dev/null and b/com.samsung.slp.common.connection/icons/folder.gif differ
diff --git a/com.samsung.slp.common.connection/icons/folder_link.gif b/com.samsung.slp.common.connection/icons/folder_link.gif
new file mode 100644 (file)
index 0000000..4b39f0a
Binary files /dev/null and b/com.samsung.slp.common.connection/icons/folder_link.gif differ
index d5c20ca..5682c26 100644 (file)
@@ -61,7 +61,7 @@ public final class FileListingService {
        private final static String[] sRootLevelApprovedItems = { DIRECTORY_DATA,
                        DIRECTORY_SDCARD, DIRECTORY_SYSTEM, DIRECTORY_TEMP, DIRECTORY_MNT, };
 
-       public static final long REFRESH_RATE = 5000L;
+       public static final long REFRESH_RATE = 99995000L;
        /**
         * Refresh test has to be slightly lower for precision issue.
         */
@@ -94,22 +94,14 @@ public final class FileListingService {
        /**
         * Regexp pattern to parse the result from ls.
         */
-       // String permissions = m.group(1);
-       // String owner = m.group(2);
-       // String group = m.group(3);
-       // String size = m.group(4);
-       // String date = m.group(5);
-       // String time = m.group(6);
-       // String info = null;
-       // -rwxr-xr-x 1 mustafa mustafa 310547 2011-08-23 14:52 adb
-       // -rw-r--r-- 1 root root 26591 Aug 19 11:14 COPYING
+
        private static String patternPermisions = "([bcdlsp-][-r][-w][-xsS][-r][-w][-xsS][-r][-w][-xstST])";
-       private static String patternFilecount = "(\\d)";
+       private static String patternFilecount = "(\\d{1,})";
        private static String patternOwner = "(\\S+)";
        private static String patternGroup = "(\\S+)";
        private static String patternSize = "([\\d\\s,]*)";
-       private static String patternDate = "([A-Z][a-z]{2}\\s\\d\\d)";
-       private static String patternTime = "(\\d\\d:\\d\\d)";
+       private static String patternDate = "([a-zA-Z]{3}\\s\\d{1,2})";
+       private static String patternTime = "(\\d{1,2}:\\d{1,2})";
        private static String patternName = "(.*)";
        private static String patternLsEmulator = "^" + patternPermisions + "\\s+"
                        + patternFilecount + "\\s+" + patternOwner + "\\s+" + patternGroup
@@ -154,6 +146,7 @@ public final class FileListingService {
                String time;
                String owner;
                String group;
+               String linkTo;
                int type;
                boolean isAppPackage;
 
@@ -243,7 +236,9 @@ public final class FileListingService {
                public String getInfo() {
                        return info;
                }
-
+               public String getLinkTo() {
+                       return linkTo;
+               }
                /**
                 * Return the full path of the entry.
                 * 
@@ -507,7 +502,7 @@ public final class FileListingService {
                                String date = m.group(6);
                                String time = m.group(7);
                                String info = null;
-
+                               String linkTo = null;
                                // and the type
                                int objectType = TYPE_OTHER;
                                switch (permissions.charAt(0)) {
@@ -545,7 +540,7 @@ public final class FileListingService {
 
                                                // and the link name
                                                info = segments[1];
-
+                                               linkTo = segments[1];
                                                // now get the path to the link
                                                String[] pathSegments = info.split(FILE_SEPARATOR);
                                                if (pathSegments.length == 1) {
@@ -580,6 +575,7 @@ public final class FileListingService {
                                entry.group = group;
                                if (objectType == TYPE_LINK) {
                                        entry.info = info;
+                                       entry.linkTo = linkTo;                                  
                                }
 
                                mEntryList.add(entry);
@@ -714,7 +710,7 @@ public final class FileListingService {
                        doLs(entry);
                        return entry.getCachedChildren();
                }
-
+       
                // this is a asynchronous call.
                // we launch a thread that will do ls and give the listing
                // to the receiver
@@ -812,7 +808,15 @@ public final class FileListingService {
 
                try {
                        // create the command
-                       String command = "ls -l " + entry.getFullPath(); //$NON-NLS-1$
+                       String command = null;
+                       if (entry.getType() == FileListingService.TYPE_LINK) {
+                               if (entry.getLinkTo().charAt(0) == '/')
+                                       command = "ls -l " + entry.getLinkTo(); //$NON-NLS-1$
+                               else
+                                       command = "ls -l /" + entry.getLinkTo(); //$NON-NLS-1$
+                       }else {
+                               command = "ls -l " + entry.getFullPath(); //$NON-NLS-1$
+                       }
 
                        // create the receiver object that will parse the result from ls
                        LsReceiver receiver = new LsReceiver(entry, entryList, linkList);
index c32720b..a7319f1 100644 (file)
@@ -110,8 +110,8 @@ public final class DevicePanel extends Panel implements IDebugBridgeChangeListen
     private class ContentProvider implements ITreeContentProvider {
         public Object[] getChildren(Object parentElement) {
             if (parentElement instanceof IDevice) {
-                return ((IDevice)parentElement).getClients();
-            }
+               return ((IDevice)parentElement).getClients();
+                                               }
             return new Object[0];
         }
 
index e464941..f7453ee 100644 (file)
@@ -29,7 +29,7 @@ import org.eclipse.swt.widgets.Tree;
 /**
  * Content provider class for device Explorer.
  */
-class DeviceContentProvider implements ITreeContentProvider {
+public class DeviceContentProvider implements ITreeContentProvider {
 
     private TreeViewer mViewer;
     private FileListingService mFileListingService;
@@ -127,8 +127,10 @@ class DeviceContentProvider implements ITreeContentProvider {
     public boolean hasChildren(Object element) {
         if (element instanceof FileEntry) {
             FileEntry entry = (FileEntry)element;
-
-            return entry.getType() == FileListingService.TYPE_DIRECTORY;
+                                               if (entry.getType() == FileListingService.TYPE_LINK)
+                                                                                               return true;
+                                               else
+                                                       return (entry.getType() == FileListingService.TYPE_DIRECTORY);
         }
         return false;
     }
@@ -164,4 +166,7 @@ class DeviceContentProvider implements ITreeContentProvider {
             mRootEntry = (FileEntry)newInput;
         }
     }
+    public void setRootEntry(FileEntry fe) {
+       mRootEntry = fe;
+    }
 }
index 2fb2573..752be76 100644 (file)
@@ -157,10 +157,10 @@ public class DeviceExplorer extends Panel {
 
                ImageLoader loader = ImageLoader.getDdmUiLibLoader();
                if (mFileImage == null) {
-                       mFileImage = loader.loadImage("file.png", mParent.getDisplay());
+                       mFileImage = loader.loadImage("file.gif", mParent.getDisplay());
                }
                if (mFolderImage == null) {
-                       mFolderImage = loader.loadImage("folder.png", mParent.getDisplay());
+                       mFolderImage = loader.loadImage("folder.gif", mParent.getDisplay());
                }
                if (mPackageImage == null) {
                        mPackageImage = loader.loadImage("android.png",
@@ -359,7 +359,8 @@ public class DeviceExplorer extends Panel {
                                                        display.asyncExec(new Runnable() {
                                                                public void run() {
                                                                        if (mTree.isDisposed() == false) {
-                                                                               mTreeViewer.refresh(true);
+                                                                               //TODO : SDB fixed
+                                                                               //mTreeViewer.refresh(true);
                                                                        }
                                                                }
                                                        });
index 9153ea7..e131cc9 100644 (file)
@@ -4,30 +4,26 @@ import org.eclipse.jface.action.Action;
 import org.eclipse.jface.action.IMenuManager;
 import org.eclipse.jface.action.IToolBarManager;
 import org.eclipse.jface.action.Separator;
-import org.eclipse.jface.viewers.ArrayContentProvider;
-import org.eclipse.jface.viewers.IStructuredSelection;
 import org.eclipse.jface.viewers.TableViewer;
-import org.eclipse.swt.SWT;
-import org.eclipse.swt.events.MouseEvent;
-import org.eclipse.swt.events.MouseListener;
-import org.eclipse.swt.layout.GridData;
 import org.eclipse.swt.widgets.Composite;
 import org.eclipse.swt.widgets.Shell;
-import org.eclipse.swt.widgets.Table;
 import org.eclipse.ui.IActionBars;
+import org.eclipse.ui.ISharedImages;
+import org.eclipse.ui.PlatformUI;
 import org.eclipse.ui.part.ViewPart;
 
-import com.samsung.slp.common.connection.ddmuilib.DevicePanel.IUiSelectionListener;
-import com.samsung.slp.common.connection.ddmuilib.DevicePanel;
 import com.samsung.slp.common.connection.ConnectionActivator;
 import com.samsung.slp.common.connection.ConnectionActivator.ISelectionListener;
-import com.samsung.slp.common.connection.ddmuilib.ImageLoader;
-import com.samsung.slp.common.connection.ddmuilib.explorer.DeviceExplorer;
 import com.samsung.slp.common.connection.ddmlib.AndroidDebugBridge;
 import com.samsung.slp.common.connection.ddmlib.Client;
 import com.samsung.slp.common.connection.ddmlib.IDevice;
+import com.samsung.slp.common.connection.ddmuilib.DevicePanel;
+import com.samsung.slp.common.connection.ddmuilib.DevicePanel.IUiSelectionListener;
+import com.samsung.slp.common.connection.ddmuilib.ImageLoader;
+import com.samsung.slp.common.connection.ddmuilib.explorer.DeviceExplorer;
 
-public class ConnectionsView extends ViewPart implements IUiSelectionListener,ISelectionListener{
+public class ConnectionsView extends ViewPart implements IUiSelectionListener,
+               ISelectionListener {
 
        private TableViewer Connections;
        private final static String COLUMN_NAME = ConnectionActivator.PLUGIN_ID
@@ -42,7 +38,7 @@ public class ConnectionsView extends ViewPart implements IUiSelectionListener,IS
                        + ".explorer.permissions"; //$NON-NLS-1S
        private final static String COLUMN_INFO = ConnectionActivator.PLUGIN_ID
                        + ".explorer.info"; //$NON-NLS-1$
-       
+
        private final static boolean USE_SELECTED_DEBUG_PORT = true;
        private DeviceExplorer mExplorer;
        private Shell mParentShell;
@@ -51,13 +47,12 @@ public class ConnectionsView extends ViewPart implements IUiSelectionListener,IS
 
        @Override
        public void createPartControl(Composite parent) {
-               createViewer(parent);
-               //createFileExplorerView(parent);
+               // createViewer(parent);
+               createFileExplorerView(parent);
        }
-       
-       private void createViewer(Composite parent)
-       {
-               
+
+       private void createViewer(Composite parent) {
+
                mParentShell = parent.getShell();
 
                ImageLoader loader = ImageLoader.getDdmUiLibLoader();
@@ -65,7 +60,7 @@ public class ConnectionsView extends ViewPart implements IUiSelectionListener,IS
                mDeviceList = new DevicePanel(USE_SELECTED_DEBUG_PORT);
                mDeviceList.createPanel(parent);
                mDeviceList.addSelectionListener(this);
-               
+
                mCaptureAction = new Action("Screen Capture") {
                        @Override
                        public void run() {
@@ -74,8 +69,9 @@ public class ConnectionsView extends ViewPart implements IUiSelectionListener,IS
 
                };
                mCaptureAction.setToolTipText("Screen Capture");
-               mCaptureAction.setImageDescriptor(loader.loadDescriptor("Export Log.gif"));
-           
+               mCaptureAction.setImageDescriptor(loader
+                               .loadDescriptor("Export Log.gif"));
+
                placeActions();
        }
 
@@ -90,7 +86,7 @@ public class ConnectionsView extends ViewPart implements IUiSelectionListener,IS
                menuManager.removeAll();
                menuManager.add(mCaptureAction);
                menuManager.add(new Separator());
-               
+
                // and then in the toolbar
                IToolBarManager toolBarManager = actionBars.getToolBarManager();
                toolBarManager.removeAll();
@@ -98,54 +94,62 @@ public class ConnectionsView extends ViewPart implements IUiSelectionListener,IS
                toolBarManager.add(new Separator());
        }
 
-       private void createFileExplorerView(Composite parent)
-       {
+       private void createFileExplorerView(Composite parent) {
                ImageLoader loader = ImageLoader.getDdmUiLibLoader();
-   DeviceExplorer.COLUMN_NAME = COLUMN_NAME;
-   DeviceExplorer.COLUMN_SIZE = COLUMN_SIZE;
-   DeviceExplorer.COLUMN_DATE = COLUMN_DATE;
-   DeviceExplorer.COLUMN_TIME = COLUMN_TIME;
-   DeviceExplorer.COLUMN_PERMISSIONS = COLUMN_PERMISSIONS;
-   DeviceExplorer.COLUMN_INFO = COLUMN_INFO;
-
-   // device explorer
-   mExplorer = new DeviceExplorer();
-   mExplorer.createPanel(parent);
-   IDevice[] devices = AndroidDebugBridge.getBridge().getDevices();
+               DeviceExplorer.COLUMN_NAME = COLUMN_NAME;
+               DeviceExplorer.COLUMN_SIZE = COLUMN_SIZE;
+               DeviceExplorer.COLUMN_DATE = COLUMN_DATE;
+               DeviceExplorer.COLUMN_TIME = COLUMN_TIME;
+               DeviceExplorer.COLUMN_PERMISSIONS = COLUMN_PERMISSIONS;
+               DeviceExplorer.COLUMN_INFO = COLUMN_INFO;
+
+               // device explorer
+               mExplorer = new DeviceExplorer();
+               mExplorer.createPanel(parent);
+               IDevice[] devices = AndroidDebugBridge.getBridge().getDevices();
                String deviceSerial = null;
                for (IDevice d : devices) {
                        deviceSerial = d.getSerialNumber();
                        System.out.println(deviceSerial);
                        mExplorer.switchDevice(d);
-                }
-       
-   //ConnectionActivator.getDefault().addSelectionListener(this);
-       }
+               }
+               mExplorer.setCustomImages(
+                               PlatformUI.getWorkbench().getSharedImages()
+                                               .getImage(ISharedImages.IMG_OBJ_FILE),
+                               PlatformUI.getWorkbench().getSharedImages()
+                                               .getImage(ISharedImages.IMG_OBJ_FOLDER),
+                               null /* apk image */,
+                               PlatformUI.getWorkbench().getSharedImages()
+                                               .getImage(ISharedImages.IMG_OBJ_ELEMENT));
+
+               // ConnectionActivator.getDefault().addSelectionListener(this);
+       }
+
        @Override
        public void setFocus() {
                // TODO Auto-generated method stub
-               
+
        }
 
        @Override
        public void selectionChanged(Client selectedClient) {
                // TODO Auto-generated method stub
-               
+
        }
 
        @Override
        public void selectionChanged(IDevice selectedDevice) {
                // TODO Auto-generated method stub
                mExplorer.switchDevice(selectedDevice);
-               
+
        }
 
        @Override
        public void selectionChanged(IDevice selectedDevice, Client selectedClient) {
                // TODO Auto-generated method stub
                // update the buttons
-        //doSelectionChanged(selectedClient);
-        //doSelectionChanged(selectedDevice);
+               // doSelectionChanged(selectedClient);
+               // doSelectionChanged(selectedDevice);
        }
 
 }