Title] add property pages for info, permission
authorhyunsik.noh <hyunsik.noh@samsung.com>
Sun, 18 Sep 2011 10:28:22 +0000 (19:28 +0900)
committerhyunsik.noh <hyunsik.noh@samsung.com>
Sun, 18 Sep 2011 10:28:22 +0000 (19:28 +0900)
[Type] Enhancement
[Module] Connection Explorer
[Redmine#] #2031

Change-Id: Idb38789c239e1db415b6aeaf84ee0a4b5742335f

com.samsung.slp.common.connection/plugin.xml
com.samsung.slp.common.connection/src/com/samsung/slp/common/connection/properties/ConnectionExplorerInfoPropertyPages.java [new file with mode: 0644]
com.samsung.slp.common.connection/src/com/samsung/slp/common/connection/properties/ConnectionExplorerPermissionPropertyPages.java [new file with mode: 0644]
com.samsung.slp.common.connection/src/com/samsung/slp/common/connection/ui/ConnectionExplorer.java
com.samsung.slp.common.connection/src/com/samsung/slp/common/connection/ui/ConnectionExplorerPanel.java

index 018333b..da8f500 100644 (file)
                </action>
                                                                                
    </extension>
+   <extension
+         point="org.eclipse.ui.propertyPages">
+      <page
+            class="com.samsung.slp.common.connection.properties.ConnectionExplorerInfoPropertyPages"
+            id="com.samsung.slp.common.connection.properties.Info"
+            name="Info"
+            nameFilter="*.*">
+      </page>
+         <page
+            class="com.samsung.slp.common.connection.properties.ConnectionExplorerPermissionPropertyPages"
+            id="com.samsung.slp.common.connection.properties.Permission"
+            name="Permission"
+            nameFilter="*.*">
+      </page>
+   </extension>
    
 <!--           <extension
          point="org.eclipse.ui.menus">         
diff --git a/com.samsung.slp.common.connection/src/com/samsung/slp/common/connection/properties/ConnectionExplorerInfoPropertyPages.java b/com.samsung.slp.common.connection/src/com/samsung/slp/common/connection/properties/ConnectionExplorerInfoPropertyPages.java
new file mode 100644 (file)
index 0000000..e28aafc
--- /dev/null
@@ -0,0 +1,167 @@
+package com.samsung.slp.common.connection.properties;
+
+import org.eclipse.jface.preference.PreferencePage;
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.layout.GridData;
+import org.eclipse.swt.layout.GridLayout;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.swt.widgets.Control;
+import org.eclipse.swt.widgets.Label;
+import org.eclipse.ui.dialogs.PropertyPage;
+
+import com.samsung.slp.common.connection.ddmlib.FileListingService.FileEntry;
+
+public class ConnectionExplorerInfoPropertyPages extends PropertyPage {
+
+       
+       private static final String PATH_TITLE = "Path:";
+       private static final String TYPE_TITLE = "Type:";
+       private static final String SIZE_TITLE = "Size:";
+       private static final String LAST_TITLE = "Last Modified:";
+
+       /**
+        * Constructor for SamplePropertyPage.
+        */
+       public ConnectionExplorerInfoPropertyPages() {
+               super();
+       }
+
+       private void addFirstSection(Composite parent) {
+               
+               Composite composite = createDefaultComposite(parent);
+
+               //Label for path field
+               Label pathLabel = new Label(composite, SWT.NONE);
+               pathLabel.setText(PATH_TITLE);
+
+               FileEntry f = (FileEntry)getElement().getAdapter(FileEntry.class);
+               // Path text field
+               Label pathValueText = new Label(composite, SWT.NONE);
+//             pathValueText.setText(((IResource) getElement()).getFullPath().toString());
+               pathValueText.setText(f.getFullPath());
+       }
+
+       private void addSeparator(Composite parent) {
+               Label separator = new Label(parent, SWT.SEPARATOR | SWT.HORIZONTAL);
+               GridData gridData = new GridData();
+               gridData.horizontalAlignment = GridData.FILL;
+               gridData.grabExcessHorizontalSpace = true;
+               separator.setLayoutData(gridData);
+       }
+
+       private void addSecondSection(Composite parent) {
+
+               Composite composite = createDefaultComposite(parent);
+
+               //Label for path field
+               Label pathLabel = new Label(composite, SWT.NONE);
+               pathLabel.setText(TYPE_TITLE);
+
+               FileEntry f = (FileEntry)getElement().getAdapter(FileEntry.class);
+               // Path text field
+               Label pathValueText = new Label(composite, SWT.NONE);
+               pathValueText.setText( getType( f.getType()) );
+       }
+       
+       private void addThirdSection(Composite parent) {
+               Composite composite = createDefaultComposite(parent);
+
+               //Label for path field
+               Label pathLabel = new Label(composite, SWT.NONE);
+               pathLabel.setText(SIZE_TITLE);
+
+               FileEntry f = (FileEntry)getElement().getAdapter(FileEntry.class);
+               // Path text field
+               Label pathValueText = new Label(composite, SWT.NONE);
+               pathValueText.setText(f.getSize() + " bytes");
+       }
+
+       
+       private void addFourthSection(Composite parent) {
+               Composite composite = createDefaultComposite(parent);
+
+               //Label for path field
+               Label pathLabel = new Label(composite, SWT.NONE);
+               pathLabel.setText(LAST_TITLE);
+
+               FileEntry f = (FileEntry)getElement().getAdapter(FileEntry.class);
+               // Path text field
+               Label pathValueText = new Label(composite, SWT.NONE);
+               pathValueText.setText(f.getDate() + " "+ f.getTime());
+       }
+
+
+       /**
+        * @see PreferencePage#createContents(Composite)
+        */
+       protected Control createContents(Composite parent) {
+               Composite composite = new Composite(parent, SWT.NONE);
+               GridLayout layout = new GridLayout();
+               composite.setLayout(layout);
+               GridData data = new GridData(GridData.VERTICAL_ALIGN_BEGINNING);
+               data.grabExcessHorizontalSpace = true;
+               composite.setLayoutData(data);
+
+               addFirstSection(composite);
+               addSecondSection(composite);
+               addThirdSection(composite);
+               addFourthSection(composite);
+               addSeparator(composite);
+               return composite;
+       }
+
+       private Composite createDefaultComposite(Composite parent) {
+               Composite composite = new Composite(parent, SWT.NULL);
+               GridLayout layout = new GridLayout();
+               layout.numColumns = 2;
+               composite.setLayout(layout);
+
+               GridData data = new GridData();
+               data.verticalAlignment = GridData.FILL;
+               data.horizontalAlignment = GridData.FILL;
+               composite.setLayoutData(data);
+
+               return composite;
+       }
+
+       protected void performDefaults() {
+               super.performDefaults();
+       }
+       
+       public boolean performOk() {
+               return true;
+       }
+       
+       private String getType( int type )
+       {
+               switch( type )
+               {
+               case 0:
+                       return "File";
+               case 1:
+                       return "Diretory";
+               
+               case 2:
+                       return "Directory Link";
+               case 3:
+                       return "Block";
+               case 4:
+                       return "Character";
+               case 5:
+                       return "Type Link";
+               case 6:
+                       return "Socket";
+               case 7:
+                       return "Type Fifo";
+               case 8:
+                       return "Type Other";
+               case 9:
+                       return "Emulator";
+               case 10:
+                       return "Device";
+               default:
+                       return "Unknown";
+               }
+       }
+
+}
\ No newline at end of file
diff --git a/com.samsung.slp.common.connection/src/com/samsung/slp/common/connection/properties/ConnectionExplorerPermissionPropertyPages.java b/com.samsung.slp.common.connection/src/com/samsung/slp/common/connection/properties/ConnectionExplorerPermissionPropertyPages.java
new file mode 100644 (file)
index 0000000..bc34d55
--- /dev/null
@@ -0,0 +1,176 @@
+package com.samsung.slp.common.connection.properties;
+
+import org.eclipse.jface.preference.PreferencePage;
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.custom.TableEditor;
+import org.eclipse.swt.layout.FillLayout;
+import org.eclipse.swt.layout.GridData;
+import org.eclipse.swt.layout.GridLayout;
+import org.eclipse.swt.widgets.Button;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.swt.widgets.Control;
+import org.eclipse.swt.widgets.Group;
+import org.eclipse.swt.widgets.Label;
+import org.eclipse.swt.widgets.Table;
+import org.eclipse.swt.widgets.TableColumn;
+import org.eclipse.swt.widgets.TableItem;
+import org.eclipse.ui.dialogs.PropertyPage;
+
+import com.samsung.slp.common.connection.ddmlib.FileListingService.FileEntry;
+
+public class ConnectionExplorerPermissionPropertyPages extends PropertyPage {
+
+       
+       private static final String PERMISSION_TITLE = "Permission:";
+       
+       private TableItem itemUser;
+       private TableItem itemGroup;
+       private TableItem itemOther;
+
+
+       /**
+        * Constructor for SamplePropertyPage.
+        */
+       public ConnectionExplorerPermissionPropertyPages() {
+               super();
+       }
+
+       private void addFirstSection(Composite parent) {
+               
+               FileEntry f = (FileEntry)getElement().getAdapter(FileEntry.class);
+               String permission = f.getPermissions();
+               
+               itemUser.setText(1, permission.charAt(1) != '-' ? "O" : "X");
+               itemUser.setText(2, permission.charAt(2) != '-' ? "O" : "X");
+               itemUser.setText(3, permission.charAt(3) != '-' ? "O" : "X");
+               
+               itemGroup.setText(1, permission.charAt(4) != '-' ? "O" : "X");
+               itemGroup.setText(2, permission.charAt(5) != '-' ? "O" : "X");
+               itemGroup.setText(3, permission.charAt(6) != '-' ? "O" : "X");
+               
+               itemOther.setText(1, permission.charAt(7) != '-' ? "O" : "X");
+               itemOther.setText(2, permission.charAt(8) != '-' ? "O" : "X");
+               itemOther.setText(3, permission.charAt(9) != '-' ? "O" : "X");
+               
+               
+       }
+
+       private void addSeparator(Composite parent) {
+               Label separator = new Label(parent, SWT.SEPARATOR | SWT.HORIZONTAL);
+               GridData gridData = new GridData();
+               gridData.horizontalAlignment = GridData.FILL;
+               gridData.grabExcessHorizontalSpace = true;
+               separator.setLayoutData(gridData);
+       }
+
+       
+       /**
+        * @see PreferencePage#createContents(Composite)
+        */
+       protected Control createContents(Composite parent) {
+               Composite composite = new Composite(parent, SWT.NONE);
+               GridLayout layout = new GridLayout();
+               composite.setLayout(layout);
+               GridData data = new GridData();
+//             data.grabExcessHorizontalSpace = true;
+               composite.setLayoutData(data);
+
+               createTable(composite);
+               addFirstSection(composite);
+//             addSeparator(composite);
+               return composite;
+       }
+       
+       private void createTable( Composite parent )
+       {
+               Group group = new Group( parent, SWT.NONE);
+               group.setText( "Permission");
+               GridLayout layout = new GridLayout();
+               layout.numColumns = 1;
+               group.setLayout(layout);
+               GridData data = new GridData();
+               data.horizontalSpan = 1;
+               group.setLayoutData(data);
+
+               Table table = new Table( group, SWT.BORDER);
+               GridData gridData = new GridData();
+               gridData.horizontalSpan = 3;
+               gridData.verticalSpan = 3;
+               table.setLayoutData( gridData );
+               
+               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");
+               
+               
+               itemUser = new TableItem(table, SWT.NONE);
+               itemUser.setText( 0, "User");
+               
+//              TableEditor editor = new TableEditor (table);
+//              
+//               Button checkButton = new Button(table, SWT.CHECK);
+//                checkButton.pack();
+//              
+//               editor.minimumWidth = checkButton.getSize ().x;
+//                editor.setEditor(checkButton, item1, 2);
+                
+               itemGroup = new TableItem(table, SWT.NONE);
+               itemGroup.setText(0, "Group");
+               
+               itemOther = new TableItem(table, SWT.NONE);
+               itemOther.setText(0, "Other");
+       }
+
+       private Composite createDefaultComposite(Composite parent) {
+               Composite composite = new Composite(parent, SWT.NULL);
+               GridLayout layout = new GridLayout();
+               layout.numColumns = 2;
+               composite.setLayout(layout);
+
+               GridData data = new GridData();
+               data.verticalAlignment = GridData.FILL;
+               data.horizontalAlignment = GridData.FILL;
+               composite.setLayoutData(data);
+
+               return composite;
+       }
+       
+       private TableColumn createTableColumn(Table parent, String header,
+                           int style, String sample_text) {
+               
+               TableColumn col = new TableColumn(parent, style);
+
+               col.setText(sample_text);
+               col.setResizable( false);
+               col.pack();
+
+               col.setText(header);
+
+              return col;
+       }
+       
+       protected void performDefaults() {
+               super.performDefaults();
+       }
+       
+       public boolean performOk() {
+//             // store the value in the owner text field
+//             try {
+//                     ((IResource) getElement()).setPersistentProperty(
+//                             new QualifiedName("", OWNER_PROPERTY),
+//                             ownerText.getText());
+//             } catch (CoreException e) {
+//                     return false;
+//             }
+               return true;
+       }
+
+}
\ No newline at end of file
index b6c8e55..8b2455b 100644 (file)
@@ -4,6 +4,7 @@ import org.eclipse.jface.action.Action;
 import org.eclipse.jface.action.IMenuListener;
 import org.eclipse.jface.action.IMenuManager;
 import org.eclipse.jface.action.MenuManager;
+import org.eclipse.jface.action.Separator;
 import org.eclipse.jface.dialogs.IDialogConstants;
 import org.eclipse.jface.dialogs.InputDialog;
 import org.eclipse.jface.window.Window;
@@ -27,6 +28,7 @@ import org.eclipse.swt.widgets.MenuItem;
 import org.eclipse.swt.widgets.Shell;
 import org.eclipse.swt.widgets.ToolBar;
 import org.eclipse.swt.widgets.ToolItem;
+import org.eclipse.ui.dialogs.PropertyDialogAction;
 import org.eclipse.ui.part.ViewPart;
 
 import com.samsung.slp.common.connection.ConnectionActivator;
@@ -38,6 +40,7 @@ import com.samsung.slp.common.connection.ddmuilib.DevicePanel.IUiSelectionListen
 import com.samsung.slp.common.connection.ddmuilib.FileDialogUtils;
 import com.samsung.slp.common.connection.ddmuilib.ImageLoader;
 import com.samsung.slp.common.connection.ddmuilib.explorer.DeviceExplorer;
+import com.samsung.slp.common.connection.properties.ConnectionExplorerInfoPropertyPages;
 
 public class ConnectionExplorer extends ViewPart implements ISelectionListener {
 
@@ -66,7 +69,7 @@ public class ConnectionExplorer extends ViewPart implements ISelectionListener {
        
        private Action actionRename;
        private Action actionDelete;
-       private Action actionProperties;
+       private PropertyDialogAction p;
        
        private MenuManager menuMgr;
        private FileEntry currentFileEntry;
@@ -129,7 +132,7 @@ public class ConnectionExplorer extends ViewPart implements ISelectionListener {
        
        private void initContextMenu() {
                 // initalize the context menu
-                menuMgr = new MenuManager("Connection Explorer"); //$NON-NLS-1$
+                menuMgr = new MenuManager("Connection Explorer MenuMgr"); //$NON-NLS-1$
                 menuMgr.setRemoveAllWhenShown(true);
                 menuMgr.addMenuListener(new IMenuListener() {
                         
@@ -167,25 +170,30 @@ public class ConnectionExplorer extends ViewPart implements ISelectionListener {
                                 
                         actionDelete = new Action() {
                                 public void run() {
-                                super.run();
-                                
-                                int ret = FileDialogUtils.getInstance().confirmDelete(currentFileEntry.getName());
-                                       if (ret == IDialogConstants.CANCEL_ID)
-                                                       return;
-                                       mPanel.deleteSelection();
+                                        super.run();
+                                        int ret = FileDialogUtils.getInstance().confirmDelete(currentFileEntry.getName());
+                                               if (ret == IDialogConstants.CANCEL_ID)
+                                                               return;
+                                        mPanel.deleteSelection();
                                        }
                                 };
                         actionDelete.setText("Delete");
                         manager.add(actionDelete);     
                         
-                        actionProperties = new Action() {
-                                public void run() {
-                                super.run();
+                        manager.add( new Separator());
+                        
+//                      actionProperties = new Action() {
+//                              public void run() {
+//                              super.run();
                                 // TODO do something
-                                       }
-                                };
-                        actionProperties.setText("Properties");
-                        manager.add(actionProperties);          
+//                              new ConnectionExplorerPropertyPages();
+//                                     }
+//                              };
+//                      actionProperties.setText("Properties");
+//                      manager.add(actionProperties);          
+                        manager.add( new PropertyDialogAction( getSite() , mPanel.getTreeViewer()));
+                        
+                        manager.add( new Separator());
                }
        }
        
index ad6f98c..4d80b1e 100644 (file)
@@ -10,7 +10,6 @@ import java.util.regex.Matcher;
 import java.util.regex.Pattern;
 
 import org.eclipse.core.runtime.IProgressMonitor;
-import org.eclipse.jface.dialogs.IDialogConstants;
 import org.eclipse.jface.dialogs.ProgressMonitorDialog;
 import org.eclipse.jface.operation.IRunnableWithProgress;
 import org.eclipse.jface.preference.IPreferenceStore;
@@ -56,7 +55,6 @@ import com.samsung.slp.common.connection.ddmlib.SyncService;
 import com.samsung.slp.common.connection.ddmlib.SyncService.ISyncProgressMonitor;
 import com.samsung.slp.common.connection.ddmlib.SyncService.SyncResult;
 import com.samsung.slp.common.connection.ddmuilib.DdmUiPreferences;
-import com.samsung.slp.common.connection.ddmuilib.FileDialogUtils;
 import com.samsung.slp.common.connection.ddmuilib.Panel;
 import com.samsung.slp.common.connection.ddmuilib.SyncProgressMonitor;
 import com.samsung.slp.common.connection.ddmuilib.TableHelper;
@@ -693,42 +691,52 @@ public class ConnectionExplorerPanel extends Panel implements IDeviceChangeListe
        }
        
        public void deleteSelection() {
-               // get the name of the object we're going to pull
+               
                TreeItem[] items = mTree.getSelection();
 
-               if (items.length != 1) {
-                       return;
-               }
-
-               FileEntry entry = (FileEntry) items[0].getData();
-               final FileEntry parentEntry = entry.getParent();
-
-               // create the delete command
-               String command = "rm " + entry.getFullEscapedPath(); //$NON-NLS-1$
+//             FileEntry entry = (FileEntry) items[0].getData();
+//             final FileEntry parentEntry = entry.getParent();
                
-               try {
-                       mCurrentDevice.executeShellCommand(command,
-                                       new IShellOutputReceiver() {
-                                               public void addOutput(byte[] data, int offset,
-                                                               int length) {
-                                                       // pass
-                                                       // TODO get output to display errors if any.
-                                               }
+               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(); //$NON-NLS-1$
+                       }
+                       else
+                       {
+                               command = "rm " + entry.getFullEscapedPath(); //$NON-NLS-1$
+                       }
+                       
+                       try {
+                               mCurrentDevice.executeShellCommand(command,
+                                               new IShellOutputReceiver() {
+                                                       public void addOutput(byte[] data, int offset,
+                                                                       int length) {
+                                                               // pass
+                                                               // TODO get output to display errors if any.
+                                                       }
 
-                                               public void flush() {
-                                                       mTreeViewer.refresh(parentEntry);
-                                               }
+                                                       public void flush() {
+                                                               mTreeViewer.refresh(entry.getParent());
+                                                       }
 
-                                               public boolean isCancelled() {
-                                                       return false;
-                                               }
-                                       });
-               } catch (IOException e) {
-                       // adb failed somehow, we do nothing. We should be displaying the
-                       // error from the output
-                       // of the shell command.
+                                                       public boolean isCancelled() {
+                                                               return false;
+                                                       }
+                                               });
+                       } catch (IOException e) {
+                               // adb failed somehow, we do nothing. We should be displaying the
+                               // error from the output
+                               // of the shell command.
+                       }
+                       refresh(entry.getParent());                             
                }
-               refresh(parentEntry);
+               
+       
 
        }