[Title] renewal toolbar for connection explorer
authorhyunsik.noh <hyunsik.noh@samsung.com>
Fri, 9 Sep 2011 08:03:09 +0000 (17:03 +0900)
committerhyunsik.noh <hyunsik.noh@samsung.com>
Fri, 9 Sep 2011 08:03:09 +0000 (17:03 +0900)
[Type] Enhancement
[Module] sdb connection
[Redmine#] #2031

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/ConnectionExplorerLabelProvider.java
com.samsung.slp.common.connection/src/com/samsung/slp/common/connection/ui/ConnectionExplorerPanel.java

index 3fe9ef5..ab86c94 100644 (file)
@@ -1,12 +1,9 @@
 package com.samsung.slp.common.connection.ui;
 
 import org.eclipse.swt.SWT;
-import org.eclipse.swt.events.MouseEvent;
-import org.eclipse.swt.events.MouseListener;
 import org.eclipse.swt.events.SelectionAdapter;
 import org.eclipse.swt.events.SelectionEvent;
 import org.eclipse.swt.events.SelectionListener;
-import org.eclipse.swt.graphics.Image;
 import org.eclipse.swt.graphics.Point;
 import org.eclipse.swt.graphics.Rectangle;
 import org.eclipse.swt.layout.FillLayout;
@@ -15,8 +12,11 @@ import org.eclipse.swt.layout.GridLayout;
 import org.eclipse.swt.widgets.Button;
 import org.eclipse.swt.widgets.Combo;
 import org.eclipse.swt.widgets.Composite;
+import org.eclipse.swt.widgets.Item;
 import org.eclipse.swt.widgets.Menu;
 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.part.ViewPart;
 
@@ -47,8 +47,15 @@ public class ConnectionExplorer extends ViewPart implements IUiSelectionListener
        private final static boolean USE_SELECTED_DEBUG_PORT = true;
        private ConnectionExplorerPanel mPanel;
        private ImageLoader mloader;
+       private ToolBar mToolBar;
        private Combo mCombo;
        
+       private ToolItem mScreenToolItem;
+       private ToolItem mPushToolItem;
+       private ToolItem mPullToolItem;
+       private ToolItem mInfoToolItem;
+       
+       
 
        @Override
        public void createPartControl(Composite parent) {
@@ -56,19 +63,76 @@ public class ConnectionExplorer extends ViewPart implements IUiSelectionListener
                
                parent.setLayoutData(new GridData(GridData.FILL_VERTICAL));
                parent.setLayout(new GridLayout(1, false));     
-               
+//             
+//             Composite top = new Composite( parent, SWT.NONE );
+//             top.setLayoutData(new GridData(GridData.GRAB_HORIZONTAL));
+//             top.setLayout(new GridLayout(3, false));    
+//             
+//             Composite mid = new Composite( parent, SWT.NONE );
+//             mid.setLayoutData(new GridData(GridData.FILL_BOTH));
+//            mid.setLayout(new FillLayout());
+//                     
+//            createMenu( top );
+               //2
                Composite top = new Composite( parent, SWT.NONE );
-               top.setLayoutData(new GridData(GridData.GRAB_HORIZONTAL));
-               top.setLayout(new GridLayout(3, false));    
-               
-               Composite mid = new Composite( parent, SWT.NONE );
-               mid.setLayoutData(new GridData(GridData.FILL_BOTH));
-              mid.setLayout(new FillLayout());
-                       
-              createMenu( top );
-               createFileExplorerView(mid);            
+               
+               GridLayout gridLayout = new GridLayout();
+               gridLayout.numColumns = 3;
+               gridLayout.marginHeight = gridLayout.marginWidth = 0;
+               
+               GridData gridData = new GridData(GridData.FILL_HORIZONTAL);
+//             gridData.widthHint = 185;
+//             createComboView( parent , gridData );
+//             gridData = new GridData(GridData.HORIZONTAL_ALIGN_FILL);
+               gridData.horizontalSpan = 2;
+               
+               top.setLayoutData( gridData );
+               top.setLayout( gridLayout );
+               
+              createToolBar( top, gridData );
+               
+//             Composite mid = new Composite( parent, SWT.NONE );
+//             mid.setLayoutData(new GridData());
+//             mid.setLayout(new GridLayout(1, false));
+               
+               Composite bottom = new Composite( parent, SWT.NONE );
+               bottom.setLayoutData(new GridData(GridData.FILL_BOTH));
+               bottom.setLayout(new FillLayout());
+               
+       
+              
+               createFileExplorerView( bottom );               
        }
        
+         private void createComboView(Composite parent, Object layoutData) {
+                   mCombo = new Combo(parent, SWT.NONE);
+                   mCombo.setLayoutData(layoutData);
+//                 mCombo.addSelectionListener(new SelectionAdapter() {
+//                   public void widgetSelected(SelectionEvent e) {
+//                     final File[] roots = (File[]) combo.getData(COMBODATA_ROOTS);
+//                     if (roots == null)
+//                       return;
+//                     int selection = combo.getSelectionIndex();
+//                     if (selection >= 0 && selection < roots.length) {
+//                       notifySelectedDirectory(roots[selection]);
+//                     }
+//                   }
+//
+//                   public void widgetDefaultSelected(SelectionEvent e) {
+//                     final String lastText = (String) combo
+//                         .getData(COMBODATA_LASTTEXT);
+//                     String text = combo.getText();
+//                     if (text == null)
+//                       return;
+//                     if (lastText != null && lastText.equals(text))
+//                       return;
+//                     combo.setData(COMBODATA_LASTTEXT, text);
+//                     notifySelectedDirectory(new File(text));
+//                   }
+//                 });
+                 }
+
+       
 
 
        private void createFileExplorerView(Composite parent) {
@@ -85,60 +149,103 @@ public class ConnectionExplorer extends ViewPart implements IUiSelectionListener
                mPanel.createPanel(parent);
        }
        
-       private void createMenu( Composite parent )
-       {
-               Button mButtonPush = new Button( parent, SWT.NONE);
-               mButtonPush.setImage(mloader.loadImage("Import Log.gif", parent.getDisplay()));
-               mButtonPush.addSelectionListener(new SelectionListener()
-               {
-
-                       @Override
-                       public void widgetDefaultSelected(SelectionEvent arg0) {
-                       }
-
-                       @Override
-                       public void widgetSelected(SelectionEvent arg0) {
+       private void createToolBar( Composite shell, Object layoutData ){
+               
+               mToolBar = new ToolBar(shell, SWT.NULL);
+               mToolBar.setLayoutData(layoutData);
+               
+               ToolItem item = new ToolItem(mToolBar, SWT.SEPARATOR);
+               
+               mScreenToolItem = new ToolItem(mToolBar, SWT.PUSH);
+               mScreenToolItem.setImage(mloader.loadImage("Import Log.gif", shell.getDisplay()));
+               mScreenToolItem.setToolTipText("Screen Capture");
+               mScreenToolItem.addSelectionListener(new SelectionAdapter() {
+                       public void widgetSelected(SelectionEvent e) {
+                               System.out.println("not yet");
+                               }
+                       });
+               
+               item = new ToolItem(mToolBar, SWT.SEPARATOR);
+               
+               mPushToolItem = new ToolItem(mToolBar, SWT.PUSH);
+               mPushToolItem.setImage(mloader.loadImage("Import Log.gif", shell.getDisplay()));
+               mPushToolItem.setToolTipText("Push the files");
+               mPushToolItem.addSelectionListener(new SelectionAdapter() {
+                       public void widgetSelected(SelectionEvent e) {
                                mPanel.pushIntoSelection();
-                       }
-                       
-               });
+                               }
+                       });
                
-               Button mButtonPull = new Button( parent, SWT.NONE);
-               mButtonPull.setImage(mloader.loadImage("Export Log.gif", parent.getDisplay()));
+               item = new ToolItem(mToolBar, SWT.SEPARATOR);
                
-               mButtonPull.addSelectionListener(new SelectionListener()
-               {
-
-                       @Override
-                       public void widgetDefaultSelected(SelectionEvent arg0) {
-                       }
-
-                       @Override
-                       public void widgetSelected(SelectionEvent arg0) {
+               mPullToolItem = new ToolItem(mToolBar, SWT.PUSH);
+               mPullToolItem.setImage(mloader.loadImage("Import Log.gif", shell.getDisplay()));
+               mPullToolItem.setToolTipText("Pull the selection");
+               mPullToolItem.addSelectionListener(new SelectionAdapter() {
+                       public void widgetSelected(SelectionEvent e) {
                                mPanel.pullSelection();
-                       }
-                       
-               });
-               
-               mCombo = new Combo( parent, SWT.READ_ONLY );
-               String comboItems[] = { "Size", "Date", "Time", "Permission", "Info" };         
-               mCombo.setItems( comboItems );        
-               mCombo.select(0);
-               mCombo.addSelectionListener(new SelectionListener()
-               {
-
-                               @Override
-                               public void widgetDefaultSelected(SelectionEvent arg0) {
                                }
-
-                               @Override
-                               public void widgetSelected(SelectionEvent arg0) {
-                                       int index = mCombo.getSelectionIndex();
-                                       mPanel.changeColumn(index);
+                       });
+               
+               item = new ToolItem(mToolBar, SWT.SEPARATOR);
+               
+               mInfoToolItem = new ToolItem(mToolBar, SWT.PUSH);
+               mInfoToolItem.setImage(mloader.loadImage("Import Log.gif", shell.getDisplay()));
+               mInfoToolItem.setToolTipText("Device Info");
+               mInfoToolItem.addSelectionListener(new SelectionAdapter() {
+                       public void widgetSelected(SelectionEvent e) {
+                               System.out.println("not yet");
                                }
                        });
-               }
+               item.setEnabled(false);
+               
+               item = new ToolItem(mToolBar, SWT.SEPARATOR);
+               
+               item = new ToolItem(mToolBar, SWT.DROP_DOWN);
+               item.setText("Size");
+               
+               DropdownSelectionListener detailInfoListener = new DropdownSelectionListener(item);
+               
+               detailInfoListener.add("Size");
+               detailInfoListener.add("Date");
+               detailInfoListener.add("Time");
+               detailInfoListener.add("Permission");
+               detailInfoListener.add("Info");         
+               item.addSelectionListener(detailInfoListener);
+               
+           }
        
+       class DropdownSelectionListener extends SelectionAdapter {
+                 private ToolItem dropdown;
+
+                 private Menu menu;
+
+                 public DropdownSelectionListener(ToolItem dropdown) {
+                   this.dropdown = dropdown;
+                   menu = new Menu(dropdown.getParent().getShell());
+                 }
+
+                 public void add(String item) {
+                   MenuItem menuItem = new MenuItem(menu, SWT.NONE);
+                   menuItem.setText(item);
+                   menuItem.addSelectionListener(new SelectionAdapter() {
+                     public void widgetSelected(SelectionEvent event) {
+                       MenuItem selected = (MenuItem) event.widget;
+                       dropdown.setText(selected.getText());
+                       mPanel.changeColumn(  dropdown.getText() );
+                     }
+                   });
+                 }
+
+                 public void widgetSelected(SelectionEvent event) {
+                     ToolItem item = (ToolItem) event.widget;
+                     Rectangle rect = item.getBounds();
+                     Point pt = item.getParent().toDisplay(new Point(rect.x, rect.y));
+                     menu.setLocation(pt.x, pt.y + rect.height);
+                     menu.setVisible(true);
+                 }
+       }
+
        @Override
        public void setFocus() {
                // TODO Auto-generated method stub
index d86cb49..a79292f 100644 (file)
@@ -91,6 +91,8 @@ public class ConnectionExplorerLabelProvider implements ITableLabelProvider {
                                                        return entry.getTime();
                                                case 3:                         
                                                        return entry.getPermissions();
+                                               case 4:                         
+                                                       return entry.getInfo();
                                        }
                                }
                        }
index 11e94f4..121cb4a 100644 (file)
@@ -1231,30 +1231,21 @@ public class ConnectionExplorerPanel extends Panel implements IDeviceChangeListe
                    return mCurrentDevice;
            }
            
-           public void changeColumn( int index )
+           public void changeColumn( String infoName )
            {
                    TreeColumn[] cols = mTree.getColumns();
-                   String comboText = null;
-                   switch( index )
-                   {
-                           case 0:
-                                   comboText = "Size";
-                                   break;
-                           case 1:
-                                   comboText = "Date";
-                                   break;
-                           case 2:
-                                   comboText = "Time";
-                                   break;
-                           case 3:
-                                   comboText = "Permission";
-                                   break;
-                           case 4:
-                                   comboText = "Info";
-                                   break;                          
-                   }
-                   cols[1].setText( comboText);
-                   ConnectionExplorerLabelProvider.index = index;
+                   if( infoName.equals( "Size" ))
+                                   ConnectionExplorerLabelProvider.index = 0;                              
+                   else if( infoName.equals( "Date" ))
+                                   ConnectionExplorerLabelProvider.index = 1;
+                   else if( infoName.equals( "Time" ))
+                                   ConnectionExplorerLabelProvider.index = 2;
+                   else if( infoName.equals( "Permission" ))
+                                   ConnectionExplorerLabelProvider.index = 3;
+                   else if( infoName.equals( "Info" ))
+                                   ConnectionExplorerLabelProvider.index = 4;
+                   
+                   cols[1].setText( infoName);
                    
                    refresh();
            }