[SRADA-767] Implement Target dialog
authordongkyu6 lee <dongkyu6.lee@samsung.com>
Wed, 8 Jun 2016 06:03:26 +0000 (15:03 +0900)
committerdongkyu6 lee <dongkyu6.lee@samsung.com>
Wed, 15 Jun 2016 01:31:11 +0000 (10:31 +0900)
Change-Id: Ic63eb0a2953d914007f5d8d6de4899eeb098f77c

org.tizen.dynamicanalyzer.appearance/src/org/tizen/dynamicanalyzer/resources/ImageResources.java
org.tizen.dynamicanalyzer.appearance/theme/flat/img/btn_connect_nor.png [new file with mode: 0644]
org.tizen.dynamicanalyzer.appearance/theme/flat/img/btn_connect_over.png [new file with mode: 0644]
org.tizen.dynamicanalyzer.appearance/theme/flat/img/btn_connect_sel.png [new file with mode: 0644]
org.tizen.dynamicanalyzer/src/org/tizen/dynamicanalyzer/ui/page/MenuBar.java
org.tizen.dynamicanalyzer/src/org/tizen/dynamicanalyzer/ui/toolbar/setting/FlatFeatureDialogTargetPage.java
org.tizen.dynamicanalyzer/src/org/tizen/dynamicanalyzer/ui/toolbar/setting/TargetDialog.java
org.tizen.dynamicanalyzer/src/org/tizen/dynamicanalyzer/ui/toolbar/setting/TargetDialogAppListPage.java [new file with mode: 0644]
org.tizen.dynamicanalyzer/src/org/tizen/dynamicanalyzer/ui/toolbar/setting/TargetDialogInfoPage.java [new file with mode: 0644]
org.tizen.dynamicanalyzer/src/org/tizen/dynamicanalyzer/ui/toolbar/setting/TargetDialogTargetPage.java [new file with mode: 0644]

index 7d66f09..aa281bb 100644 (file)
@@ -815,6 +815,11 @@ public class ImageResources {
        public static final Image ZOOM_IN_ICON_MV = getPngImage("zoom_in_icon_mv");
        public static final Image ZOOM_OUT_ICON = getPngImage("zoom_out_icon");
        public static final Image ZOOM_OUT_ICON_MV = getPngImage("zoom_out_icon_mv");
+       
+       /** target dialog **/
+       public static final Image CONNECT_BTN_NOR = getPngImage("btn_connect_nor");
+       public static final Image CONNECT_BTN_OVER = getPngImage("btn_connect_over");
+       public static final Image CONNECT_BTN_SEL = getPngImage("btn_connect_sel");
 
        private static Image getImage(String pluginId, String folderName,
                        String imageName, String extension) {
diff --git a/org.tizen.dynamicanalyzer.appearance/theme/flat/img/btn_connect_nor.png b/org.tizen.dynamicanalyzer.appearance/theme/flat/img/btn_connect_nor.png
new file mode 100644 (file)
index 0000000..df68b2c
Binary files /dev/null and b/org.tizen.dynamicanalyzer.appearance/theme/flat/img/btn_connect_nor.png differ
diff --git a/org.tizen.dynamicanalyzer.appearance/theme/flat/img/btn_connect_over.png b/org.tizen.dynamicanalyzer.appearance/theme/flat/img/btn_connect_over.png
new file mode 100644 (file)
index 0000000..08b0eab
Binary files /dev/null and b/org.tizen.dynamicanalyzer.appearance/theme/flat/img/btn_connect_over.png differ
diff --git a/org.tizen.dynamicanalyzer.appearance/theme/flat/img/btn_connect_sel.png b/org.tizen.dynamicanalyzer.appearance/theme/flat/img/btn_connect_sel.png
new file mode 100644 (file)
index 0000000..3d54718
Binary files /dev/null and b/org.tizen.dynamicanalyzer.appearance/theme/flat/img/btn_connect_sel.png differ
index fccf355..119548f 100644 (file)
@@ -131,8 +131,7 @@ public class MenuBar {
 
                MenuItem analyzeTarget = new MenuItem(analyzeMenu, SWT.PUSH);
                analyzeTarget.setText(MenuBarLabels.ANALYZE_TARGET);
-               analyzeTarget.addSelectionListener(anlysisMenuListener);
-               analyzeTarget.setEnabled(false);
+               analyzeTarget.addSelectionListener(anlysisMenuListener);                
 
                MenuItem analyzeScreenshot = new MenuItem(analyzeMenu, SWT.PUSH);
                analyzeScreenshot.setText(MenuBarLabels.ANALYZE_SCREENSHOT);
index 16c3968..f375a12 100644 (file)
@@ -38,7 +38,6 @@ import org.eclipse.swt.layout.FormAttachment;
 import org.eclipse.swt.layout.FormData;
 import org.eclipse.swt.layout.FormLayout;
 import org.eclipse.swt.widgets.Composite;
-import org.eclipse.swt.widgets.Display;
 import org.eclipse.swt.widgets.Event;
 import org.eclipse.swt.widgets.Label;
 import org.eclipse.swt.widgets.Listener;
@@ -49,10 +48,8 @@ import org.tizen.dynamicanalyzer.resources.FontResources;
 import org.tizen.dynamicanalyzer.resources.ImageResources;
 import org.tizen.dynamicanalyzer.setting.SettingDataManager;
 import org.tizen.dynamicanalyzer.setting.TargetData;
-import org.tizen.dynamicanalyzer.util.Logger;
 import org.tizen.dynamicanalyzer.widgets.button.toggle.DACustomFeatureToggleButton;
 import org.tizen.dynamicanalyzer.widgets.button.toggle.DACustomFeatureToggleButtonGroup;
-import org.tizen.dynamicanalyzer.widgets.button.toggle.DACustomToggleButton;
 import org.tizen.dynamicanalyzer.widgets.da.view.DAPageComposite;
 
 public class FlatFeatureDialogTargetPage extends DAPageComposite {     
index 5c36bd7..d4300bc 100644 (file)
@@ -1,27 +1,86 @@
+/*
+ *  Dynamic Analyzer
+ *
+ * Copyright (c) 2000 - 2016 Samsung Electronics Co., Ltd. All rights reserved.
+ *
+ * Contact: 
+ * Dongkye Lee <dongkyu6.lee@samsung.com>
+ * Jaeyong Lee <jae-yong.lee@@samsung.com>
+ * Gihun Chang <gihun.chang@@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.
+ * 
+ */
+
 package org.tizen.dynamicanalyzer.ui.toolbar.setting;
 
 import org.eclipse.swt.SWT;
-import org.eclipse.swt.custom.ScrolledComposite;
+import org.eclipse.swt.events.DisposeEvent;
+import org.eclipse.swt.events.DisposeListener;
 import org.eclipse.swt.events.ShellEvent;
 import org.eclipse.swt.events.ShellListener;
+import org.eclipse.swt.layout.FillLayout;
 import org.eclipse.swt.layout.FormAttachment;
 import org.eclipse.swt.layout.FormData;
 import org.eclipse.swt.layout.FormLayout;
+import org.eclipse.swt.widgets.Button;
 import org.eclipse.swt.widgets.Composite;
+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.Shell;
+import org.tizen.dynamicanalyzer.common.Global;
+import org.tizen.dynamicanalyzer.communicator.DeviceInfo;
 import org.tizen.dynamicanalyzer.nl.TargetDialogLabels;
 import org.tizen.dynamicanalyzer.nl.WidgetLabels;
+import org.tizen.dynamicanalyzer.project.PackageInfo;
 import org.tizen.dynamicanalyzer.resources.ColorResources;
 import org.tizen.dynamicanalyzer.resources.FontResources;
 import org.tizen.dynamicanalyzer.shortcut.ShortCutManager;
-import org.tizen.dynamicanalyzer.widgets.button.DACustomButton;
-import org.tizen.dynamicanalyzer.widgets.button.DACustomButtonClickEventListener;
-import org.tizen.dynamicanalyzer.widgets.da.base.DAButton;
+import org.tizen.dynamicanalyzer.ui.toolbar.Toolbar;
+import org.tizen.dynamicanalyzer.util.Logger;
 import org.tizen.dynamicanalyzer.widgets.da.base.DAMessageBox;
 
 public class TargetDialog extends DAMessageBox {
        private static boolean opened = false;
 
+       final private int WINDOW_WIDTH = 810;
+       final private int WINDOW_HEIGHT = 620;
+       final private int CONTENT_HEIGHT = 489;
+
+       final private int TITLE_HEIGTH = 38;
+       final private int LINE = 1;
+
+       final private int BUTTONCOMP_HEIGHT = 60;
+
+       final private int TARGET_COMP_WIDTH = 180; // TargetComp have to draw line
+       final private int TARGET_COMP_HEIGHT = CONTENT_HEIGHT;
+
+       final private int APPLIST_WIDTH = 180;
+       final private int APPLIST_HEIGHT = CONTENT_HEIGHT;
+
+       final private int INFO_HEIGHT = CONTENT_HEIGHT;
+
+       final private int BUTTON_WIDTH = 86;
+       final private int BUTTON_HEIGHT = 24;
+       
+       private Button okButton = null;
+
+       private TargetDialogTargetPage targetDialogTargetPage = null;
+       private TargetDialogAppListPage targetDialogAppListPage = null;
+       private TargetDialogInfoPage targetDialogInfoPage = null;
+
        public TargetDialog(Shell parentShell) {
                super(parentShell);
        }
@@ -30,142 +89,291 @@ public class TargetDialog extends DAMessageBox {
                if (opened) {
                        return false;
                }
-               
-               shell.setSize(1010, 620);
+
+               int dialogLocationX = shell.getParent().getLocation().x + (shell.getParent().getSize().x - WINDOW_WIDTH) / 2;
+               int dialogLocationY = shell.getParent().getLocation().y + (shell.getParent().getSize().y - WINDOW_HEIGHT) / 2;
+               shell.setLocation(dialogLocationX, dialogLocationY);
+               shell.setSize(WINDOW_WIDTH, WINDOW_HEIGHT);
                shell.setLayout(new FormLayout());
                shell.setText(TargetDialogLabels.TITLE);
-               shell.setBackground(ColorResources.WHITE);
-
-               // base composite
-               Composite baseComp = new Composite(shell, SWT.NONE);
-               FormLayout compLayout = new FormLayout();
-               baseComp.setLayout(compLayout);
-       
-               FormData compData = new FormData();
-               compData.top = new FormAttachment(0, 0);
-               compData.left = new FormAttachment(0, 0);
-               compData.right = new FormAttachment(100, 0);
-               compData.bottom = new FormAttachment(100, -60);
-               baseComp.setLayoutData(compData);
-               
-               ScrolledComposite scrolledComp = new ScrolledComposite(baseComp, SWT.BORDER | SWT.V_SCROLL);
-               scrolledComp.setLayout(new FormLayout());
-               FormData scrollCompData = new FormData();
-               scrollCompData.top = new FormAttachment(0, 0);
-               scrollCompData.left = new FormAttachment(0, 0);
-               scrollCompData.right = new FormAttachment(100, 0);
-               scrollCompData.bottom = new FormAttachment(100, 0);
-               scrolledComp.setLayoutData(scrollCompData);
-               scrolledComp.setExpandVertical(true);
-               scrolledComp.setBackground(ColorResources.WHITE);
-               
-               
+               shell.setBackground(ColorResources.DIALOG_MIDDLE_LINE_COLOR);
+               shell.addDisposeListener(new DisposeListener() {
+
+                       @Override
+                       public void widgetDisposed(DisposeEvent arg0) {
+                               opened = false;
+                               ShortCutManager.getInstance().setEnabled(!opened);
+                       }
+               });
+
+               // for top margin : height - 1
+
+               Composite topMarginComp = new Composite(shell, SWT.NONE);
+               FormData compData = new FormData();
+               compData.top = new FormAttachment(0, 0);
+               compData.left = new FormAttachment(0, 0);
+               compData.right = new FormAttachment(100, 0);
+               compData.height = LINE;
+               topMarginComp.setLayoutData(compData);
+               topMarginComp.setLayout(new FillLayout());
+               topMarginComp.setBackground(ColorResources.DIALOG_TOP_LINE_COLOR);
+
+               Composite textComp = new Composite(shell, SWT.NONE);
+               textComp.setLayout(new FormLayout());
+               compData = new FormData();
+               compData.top = new FormAttachment(0, 1);
+               compData.left = new FormAttachment(0, 0);
+               compData.right = new FormAttachment(100, 0);
+               compData.height = TITLE_HEIGTH;
+               textComp.setLayoutData(compData);
+               textComp.setLayout(new FormLayout());
+               textComp.setBackground(ColorResources.FEATURE_TITLE_BACKGROUND);
+
+               Composite contentsComp = new Composite(shell, SWT.NONE);
+               compData = new FormData();
+               compData.top = new FormAttachment(textComp, LINE);
+               compData.left = new FormAttachment(0, 0);
+               compData.right = new FormAttachment(100, 0);
+               compData.height = CONTENT_HEIGHT;
+               contentsComp.setLayoutData(compData);
+               contentsComp.setLayout(new FormLayout());
+               contentsComp.setBackground(ColorResources.DIALOG_MIDDLE_LINE_COLOR);
 
                // button composite
-               Composite buttonContentsComp = new Composite(shell, SWT.NONE);
-               compLayout = new FormLayout();
-               buttonContentsComp.setLayout(compLayout);
-               buttonContentsComp.setBackground(ColorResources.WHITE);
+               Composite buttonComp = new Composite(shell, SWT.NONE);
                compData = new FormData();
-               compData.top = new FormAttachment(100, -60);
+               compData.top = new FormAttachment(contentsComp, LINE);
                compData.left = new FormAttachment(0, 0);
                compData.right = new FormAttachment(100, 0);
                compData.bottom = new FormAttachment(100, 0);
-               buttonContentsComp.setLayoutData(compData);
+               buttonComp.setLayoutData(compData);
+               buttonComp.setLayout(new FormLayout());
+               buttonComp.setBackground(ColorResources.WHITE);
 
-               DACustomButton okButton = new DAButton(buttonContentsComp, SWT.NONE);
-               okButton.addClickListener(okButtonListener);
-               okButton.setText(WidgetLabels.OK);
-               okButton.setButtonFont(FontResources.DIALOG_BUTTON_FONT);
-               FormData buttonData = new FormData();
-               buttonData.top = new FormAttachment(0, 15);
-               buttonData.right = new FormAttachment(100, -15);
-               buttonData.width = 100;
-               buttonData.height = 30;
-               okButton.setLayoutData(buttonData);
+               createTextComp(textComp);
 
-               DACustomButton cancelButton = new DAButton(buttonContentsComp, SWT.NONE);
-               cancelButton.addClickListener(cancelButtonListener);
-               cancelButton.setText(WidgetLabels.CANCEL);
-               cancelButton.setButtonFont(FontResources.DIALOG_BUTTON_FONT);
-               buttonData = new FormData();
-               buttonData.top = new FormAttachment(0, 15);
-               buttonData.right = new FormAttachment(okButton, -8);
-               buttonData.width = 100;
-               buttonData.height = 30;
-               cancelButton.setLayoutData(buttonData);
+               createContentComp(contentsComp);
+
+               createButtonComp(buttonComp);
                
-               DACustomButton refressButton = new DAButton(buttonContentsComp, SWT.NONE);
-               refressButton.addClickListener(refreshButtonListener);
-               refressButton.setText(TargetDialogLabels.REFRESH);
-               refressButton.setButtonFont(FontResources.DIALOG_BUTTON_FONT);
-               buttonData = new FormData();
-               buttonData.top = new FormAttachment(0, 15);
-               buttonData.right = new FormAttachment(cancelButton, -8);
-               buttonData.width = 100;
-               buttonData.height = 30;
-               refressButton.setLayoutData(buttonData);
+               if (Global.getCurrentDeviceInfo() != null) {
+                       DeviceInfo selecedDev = Global.getCurrentDeviceInfo();
+                       if(targetDialogTargetPage.selectDevice(selecedDev)) {
+                               if (Global.getCurrentApplication() != null) {
+                                       PackageInfo selecedApp = Global.getCurrentApplication();
+                                       targetDialogAppListPage.selectApp(selecedApp);
+                               }       
+                       }
+               }
 
                opened = true;
                ShortCutManager.getInstance().setEnabled(!opened);
 
                shell.addShellListener(shellListener);
                shell.open();
-               
                return true;
        }
-       
-       private DACustomButtonClickEventListener okButtonListener = new DACustomButtonClickEventListener() {
 
-               @Override
-               public void handleClickEvent(DACustomButton button) {
-                       shell.close();
-               }
-       };
-       
-       private DACustomButtonClickEventListener cancelButtonListener = new DACustomButtonClickEventListener() {
+       private void createTextComp(Composite textComp) {
+               int labelY = 10;
+               int labelX = 20;
 
-               @Override
-               public void handleClickEvent(DACustomButton button) {
-                       shell.close();
-               }
-       };
-       
-       private DACustomButtonClickEventListener refreshButtonListener = new DACustomButtonClickEventListener() {
+               Label device = new Label(textComp, SWT.NONE);
+               FormData compData = new FormData();
+               compData.top = new FormAttachment(0, labelY);
+               compData.left = new FormAttachment(0, labelX);
+               compData.bottom = new FormAttachment(100, 0);
+               compData.width = TARGET_COMP_WIDTH - labelX;
+               device.setLayoutData(compData);
+               device.setBackground(ColorResources.FEATURE_TITLE_BACKGROUND);
+               device.setText(TargetDialogLabels.DEVICE);
+
+               Label application = new Label(textComp, SWT.NONE);
+               compData = new FormData();
+               compData.top = new FormAttachment(0, labelY);
+               compData.left = new FormAttachment(device, labelX);
+               compData.bottom = new FormAttachment(100, 0);
+               compData.width = APPLIST_WIDTH - labelX;
+               application.setLayoutData(compData);
+               application.setBackground(ColorResources.FEATURE_TITLE_BACKGROUND);
+               application.setText(TargetDialogLabels.APPLICATION);
+
+               Label description = new Label(textComp, SWT.NONE);
+               compData = new FormData();
+               compData.top = new FormAttachment(0, labelY);
+               compData.left = new FormAttachment(application, labelX);
+               compData.bottom = new FormAttachment(100, 0);
+               compData.right = new FormAttachment(100, 0);
+               description.setLayoutData(compData);
+               description.setBackground(ColorResources.FEATURE_TITLE_BACKGROUND);
+               description.setText(TargetDialogLabels.DESCRIPTION);
+       }
+
+       private void createContentComp(Composite contentsComp) {
+               // target composite
+               Composite targetComp = new Composite(contentsComp, SWT.NONE);
+               FormData compData = new FormData();
+               compData.top = new FormAttachment(0, 0);
+               compData.left = new FormAttachment(0, 0);
+               compData.width = TARGET_COMP_WIDTH;
+               compData.height = TARGET_COMP_HEIGHT;
+               targetComp.setLayoutData(compData);
+               targetComp.setLayout(new FormLayout());
+               targetComp.setBackground(ColorResources.FEATURE_TARGETCOMP_BACKGROUND);
+
+               // app list composite
+               Composite appListComp = new Composite(contentsComp, SWT.NONE);
+               compData = new FormData();
+               compData.top = new FormAttachment(0, 0);
+               compData.left = new FormAttachment(targetComp, LINE);
+               compData.width = APPLIST_WIDTH;
+               compData.height = APPLIST_HEIGHT;
+               appListComp.setLayoutData(compData);
+               appListComp.setLayout(new FormLayout());
+               appListComp.setBackground(ColorResources.FEATURE_FEATURELISTCOMP_NORMAL_BACKGROUND);
+
+               // information composite
+               Composite infoComp = new Composite(contentsComp, SWT.NONE);
+               compData = new FormData();
+               compData.top = new FormAttachment(0, 0);
+               compData.left = new FormAttachment(appListComp, LINE);
+               compData.right = new FormAttachment(100, 0);
+               compData.height = INFO_HEIGHT;
+               infoComp.setLayoutData(compData);
+               infoComp.setLayout(new FormLayout());
+               infoComp.setBackground(ColorResources.FEATURE_FEATURELISTCOMP_NORMAL_BACKGROUND);
+
+               targetDialogTargetPage = new TargetDialogTargetPage(targetComp, this, SWT.TRANSPARENT);
+               targetDialogAppListPage = new TargetDialogAppListPage(appListComp, this, SWT.TRANSPARENT);
+               targetDialogInfoPage = new TargetDialogInfoPage(infoComp, SWT.TRANSPARENT);
+       }
+
+       private void createButtonComp(Composite buttonComp) {
+               int buttonposition = (BUTTONCOMP_HEIGHT - BUTTON_HEIGHT) / 2;
+
+               okButton = new Button(buttonComp, SWT.PUSH);
+               okButton.addListener(SWT.Selection, new Listener() {
+                       @Override
+                       public void handleEvent(Event event) {
+                               updateToolBar();
+                               shell.close();
+                       }
+               });
+               okButton.setText(WidgetLabels.OK);
+               okButton.setFont(FontResources.DIALOG_BUTTON_FONT);
+               FormData buttonData = new FormData();
+               buttonData.top = new FormAttachment(0, buttonposition);
+               buttonData.right = new FormAttachment(100, -15);
+               buttonData.width = BUTTON_WIDTH;
+               buttonData.height = BUTTON_HEIGHT;
+               okButton.setLayoutData(buttonData);
+               okButton.setEnabled(false);
+
+               Button cancelButton = new Button(buttonComp, SWT.PUSH);
+               cancelButton.addListener(SWT.Selection, new Listener() {
+                       @Override
+                       public void handleEvent(Event event) {
+                               shell.close(); // close dialog
+                       }
+               });
+               cancelButton.setText(WidgetLabels.CANCEL);
+               cancelButton.setFont(FontResources.DIALOG_BUTTON_FONT);
+               buttonData = new FormData();
+               buttonData.top = new FormAttachment(0, buttonposition);
+               buttonData.right = new FormAttachment(okButton, -8);
+               buttonData.width = BUTTON_WIDTH;
+               buttonData.height = BUTTON_HEIGHT;
+               cancelButton.setLayoutData(buttonData);
+
+               Button refershButton = new Button(buttonComp, SWT.PUSH);
+               refershButton.addListener(SWT.Selection, new Listener() {
+                       @Override
+                       public void handleEvent(Event event) {
+                               if (targetDialogTargetPage != null) {
+                                       targetDialogTargetPage.drawTarageData();
+                                       targetDialogAppListPage.drawAppList(null);
+                                       targetDialogInfoPage.drawDeviceInfoPage(null);
+                                       targetDialogInfoPage.drawAppInfoPage(null);
+                                       setOKButtonEnable(false);
+                               }
+                       }
+               });
+               refershButton.setText(TargetDialogLabels.REFRESH);
+               refershButton.setFont(FontResources.DIALOG_BUTTON_FONT);
+               buttonData = new FormData();
+               buttonData.top = new FormAttachment(0, buttonposition);
+               buttonData.right = new FormAttachment(cancelButton, -8);
+               buttonData.width = BUTTON_WIDTH;
+               buttonData.height = BUTTON_HEIGHT;
+               refershButton.setLayoutData(buttonData);
+       }
 
-               @Override
-               public void handleClickEvent(DACustomButton button) {
-                       
-               }
-       };
-       
        private ShellListener shellListener = new ShellListener() {
 
                @Override
                public void shellActivated(ShellEvent e) {
-                       // TODO Auto-generated method stub
                }
 
                @Override
                public void shellClosed(ShellEvent e) {
-                       opened = false;
-                       ShortCutManager.getInstance().setEnabled(!opened);
                }
 
                @Override
                public void shellDeactivated(ShellEvent e) {
-                       // TODO Auto-generated method stub
                }
 
                @Override
                public void shellDeiconified(ShellEvent e) {
-                       // TODO Auto-generated method stub
                }
 
                @Override
                public void shellIconified(ShellEvent e) {
-                       // TODO Auto-generated method stub
                }
 
        };
+
+       public TargetDialogTargetPage getTargetPage() {
+               return this.targetDialogTargetPage;
+       }
+
+       public TargetDialogAppListPage getAppListPage() {
+               return this.targetDialogAppListPage;
+       }
+
+       public TargetDialogInfoPage getInfoPage() {
+               return this.targetDialogInfoPage;
+       }
+       
+       public void setOKButtonEnable(boolean enable) {
+               if(this.okButton != null) {
+                       this.okButton.setEnabled(enable);
+               }
+       }
+
+       private void updateToolBar() {
+               final DeviceInfo curDev = targetDialogInfoPage.getSelectedDevice();
+               final PackageInfo curApp = targetDialogInfoPage.getSelectedApp();
+               
+               if(curDev == null || curApp == null) {
+                       return;
+               }
+               
+               Display.getDefault().syncExec(new Runnable() {
+                       @Override
+                       public void run() {
+                               String devName = curDev.getIDevice().getSerialNumber();
+                               if (Toolbar.INSTANCE.setDevice(devName)) {
+                                       Global.setCurrentDeviceInfo(curDev);
+                                       String appName = curApp.getMainApp().getLabel();
+                                       if (Toolbar.INSTANCE.setApplication(appName)) {
+                                               Global.setCurrentApplication(curApp);
+                                       } else {
+                                               Logger.warning("Failed to set application to toolbar - " + appName);
+                                       }
+                               } else {
+                                       Logger.warning("Failed to set device to toolbar - " + devName);
+                               }
+                       }
+               });
+       }
 }
diff --git a/org.tizen.dynamicanalyzer/src/org/tizen/dynamicanalyzer/ui/toolbar/setting/TargetDialogAppListPage.java b/org.tizen.dynamicanalyzer/src/org/tizen/dynamicanalyzer/ui/toolbar/setting/TargetDialogAppListPage.java
new file mode 100644 (file)
index 0000000..26d71b9
--- /dev/null
@@ -0,0 +1,245 @@
+/*
+ *  Dynamic Analyzer
+ *
+ * Copyright (c) 2000 - 2016 Samsung Electronics Co., Ltd. All rights reserved.
+ *
+ * Contact: 
+ * Dongkye Lee <dongkyu6.lee@samsung.com>
+ * Jaeyong Lee <jae-yong.lee@@samsung.com>
+ * Gihun Chang <gihun.chang@@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.
+ * 
+ */
+
+package org.tizen.dynamicanalyzer.ui.toolbar.setting;
+
+import java.util.ArrayList;
+import java.util.List;
+import java.util.Map;
+
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.custom.ScrolledComposite;
+import org.eclipse.swt.graphics.Cursor;
+import org.eclipse.swt.graphics.Image;
+import org.eclipse.swt.graphics.Point;
+import org.eclipse.swt.layout.FillLayout;
+import org.eclipse.swt.layout.FormAttachment;
+import org.eclipse.swt.layout.FormData;
+import org.eclipse.swt.layout.FormLayout;
+import org.eclipse.swt.layout.RowData;
+import org.eclipse.swt.layout.RowLayout;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.swt.widgets.Event;
+import org.eclipse.swt.widgets.Listener;
+import org.tizen.dynamicanalyzer.project.PackageInfo;
+import org.tizen.dynamicanalyzer.resources.ColorResources;
+import org.tizen.dynamicanalyzer.resources.FontResources;
+import org.tizen.dynamicanalyzer.resources.ImageResources;
+import org.tizen.dynamicanalyzer.widgets.button.toggle.DACustomFeatureToggleButton;
+import org.tizen.dynamicanalyzer.widgets.da.view.DAPageComposite;
+
+public class TargetDialogAppListPage extends DAPageComposite {
+
+       private TargetDialog targetDialog = null;
+       private Composite appListParentComp = null;
+
+       private ScrolledComposite appListScrolledComposite = null;
+       private Composite appListComp = null;
+       private List<DACustomFeatureToggleButton> appToggleList = new ArrayList<DACustomFeatureToggleButton>();
+       private Cursor daCursor = null;
+       private Map<String, PackageInfo> appListFromDevice = null;
+
+       public TargetDialogAppListPage(Composite parent, TargetDialog targetDialog, int style) {
+               super(parent, style);
+               this.setLayout(new FormLayout());
+               this.setBackground(ColorResources.FEATURE_FEATURELISTCOMP_NORMAL_BACKGROUND);
+
+               this.targetDialog = targetDialog;
+               this.appListParentComp = parent;
+       }
+
+       public void drawAppList(Map<String, PackageInfo> appMap) {
+               appToggleList.clear();
+               appListFromDevice = appMap;
+
+               if (appListScrolledComposite != null) {
+                       appListScrolledComposite.dispose();
+                       appListScrolledComposite = null;
+               }
+
+               if (appListComp != null) {
+                       appListComp.dispose();
+                       appListComp = null;
+               }
+
+               // scrolledComposite
+               appListScrolledComposite = new ScrolledComposite(appListParentComp, SWT.V_SCROLL);
+               appListScrolledComposite.setLayout(new FormLayout());
+               FormData data = new FormData();
+               data.top = new FormAttachment(0, 0);
+               data.left = new FormAttachment(0, 0);
+               data.right = new FormAttachment(100, 0);
+               data.bottom = new FormAttachment(100, 0);
+               appListScrolledComposite.setLayoutData(data);
+               appListScrolledComposite.setExpandHorizontal(true);
+               appListScrolledComposite.setExpandVertical(true);
+               appListScrolledComposite.setBackground(ColorResources.FEATURE_FEATURELISTCOMP_NORMAL_BACKGROUND);
+
+               appListComp = new Composite(appListScrolledComposite, SWT.NONE);
+               appListComp.setBackground(ColorResources.FEATURE_FEATURELISTCOMP_NORMAL_BACKGROUND);
+               appListComp.setLayout(new RowLayout(SWT.VERTICAL));
+
+               appListScrolledComposite.setContent(appListComp);
+
+               if(appMap != null) {
+                       Composite buttonComp = new Composite(appListComp, SWT.NONE);
+                       buttonComp.setLayoutData(new RowData(SWT.DEFAULT, 15));
+                       buttonComp.setLayout(new FillLayout());
+       
+                       for (Map.Entry<String, PackageInfo> elem : appMap.entrySet()) {
+                               DACustomFeatureToggleButton toggle = createToggleButton(appListComp, elem.getKey(),
+                                               elem.getValue().getPackageId());
+       
+                               toggle.addListener(SWT.MouseUp, toggleUpListener);
+                               toggle.addListener(SWT.MouseDown, toggleDownListener);
+                               toggle.addListener(SWT.MouseEnter, cursorListener);
+                               toggle.addListener(SWT.MouseExit, cursorListener);
+       
+                               appToggleList.add(toggle);
+                       }
+               }
+
+               appListParentComp.layout(true);
+               appListScrolledComposite.layout();
+               appListScrolledComposite.setMinSize(appListComp.computeSize(SWT.DEFAULT, SWT.DEFAULT));
+       }
+       
+       public boolean selectApp(PackageInfo curApp) {
+               String selectedAppStr = curApp.getPackageId();
+               for (DACustomFeatureToggleButton toggleButton : appToggleList) {
+                       if (toggleButton.getToolTipText().equals(selectedAppStr)) {
+                               toggleButton.setToggled(true);
+                               toggleButton.getParent().setBackground(ColorResources.FEATURE_FEATURELISTCOMP_SELECT_BACKGROUND);
+                                                                       
+                               targetDialog.getInfoPage().drawAppInfoPage(curApp);
+                               targetDialog.setOKButtonEnable(true);
+                               return true;
+                       }
+               }
+               return false;
+       }
+
+       private DACustomFeatureToggleButton createToggleButton(Composite composit, String appName, String serial) {
+               Composite buttonComp = new Composite(composit, SWT.NONE);
+               buttonComp.setLayoutData(new RowData(SWT.DEFAULT, 65));
+               buttonComp.setBackground(ColorResources.FEATURE_FEATURELISTCOMP_NORMAL_BACKGROUND);
+               buttonComp.setLayout(new FormLayout());
+
+               Image normalImage = ImageResources.APP_NOR;
+               Image pushImage = ImageResources.APP_SEL;
+               Image hoverImage = ImageResources.APP_OVER;
+
+               DACustomFeatureToggleButton toggle = new DACustomFeatureToggleButton(buttonComp, SWT.NONE);
+               // color and image
+               toggle.setColors(ColorResources.FEATURE_FEATURELISTCOMP_NORMAL_BACKGROUND, ColorResources.FEATURE_FEATURELISTCOMP_NORMAL_BACKGROUND,
+                               ColorResources.FEATURE_FEATURELISTCOMP_NORMAL_BACKGROUND, ColorResources.FEATURE_FEATURELISTCOMP_NORMAL_BACKGROUND,
+                               ColorResources.FEATURE_FEATURELISTCOMP_SELECT_BACKGROUND,
+                               ColorResources.FEATURE_FEATURELISTCOMP_SELECT_BACKGROUND,
+                               ColorResources.FEATURE_FEATURELISTCOMP_SELECT_BACKGROUND);
+               toggle.setButtonImages(normalImage, pushImage, hoverImage, normalImage, pushImage, hoverImage, pushImage);
+               toggle.setButtonImagePoint(new Point(0, 0));
+
+               // font
+               toggle.setTitle(appName);
+               toggle.setFontPoint(new Point(55, 10));
+               toggle.setFontColors(ColorResources.SETTING_COLOR, ColorResources.SETTING_COLOR, ColorResources.SETTING_COLOR,
+                               ColorResources.SETTING_COLOR);
+               toggle.setButtonFont(FontResources.SETTING_BUTTON_FONT);
+               toggle.setBackground(ColorResources.FEATURE_FEATURELISTCOMP_NORMAL_BACKGROUND);
+               toggle.setToolTipText(serial);
+
+               // layout
+               FormData data = new FormData();
+               data.top = new FormAttachment(0, 13);
+               data.left = new FormAttachment(0, 20);
+               data.height = 40;
+               data.width = 155;
+               toggle.setLayoutData(data);
+
+               return toggle;
+       }
+
+       private Listener toggleUpListener = new Listener() {
+               public void handleEvent(Event event) {
+                       DACustomFeatureToggleButton toggleButton = (DACustomFeatureToggleButton) event.widget;
+                       if (!toggleButton.isToggled()) {
+                               toggleButton.getParent().setBackground(ColorResources.FEATURE_FEATURELISTCOMP_NORMAL_BACKGROUND);
+                       } else {
+                               toggleButton.getParent().setBackground(ColorResources.FEATURE_FEATURELISTCOMP_SELECT_BACKGROUND);
+
+                               for (DACustomFeatureToggleButton other : appToggleList) {
+                                       if (!other.getToolTipText().equals(toggleButton.getToolTipText()) && other.isToggled()) {
+                                               other.setToggled(false);
+                                               other.getParent().setBackground(ColorResources.FEATURE_FEATURELISTCOMP_NORMAL_BACKGROUND);
+                                       }
+                               }
+                       }
+                       
+                       for (Map.Entry<String, PackageInfo> elem : appListFromDevice.entrySet()) {
+                               if(elem.getValue().getPackageId().equals(toggleButton.getToolTipText())) {
+                                       if(toggleButton.isToggled()) {
+                                               targetDialog.getInfoPage().drawAppInfoPage(elem.getValue());
+                                       }
+                                       else {
+                                               targetDialog.getInfoPage().drawAppInfoPage(null);
+                                       }
+                                       break;
+                               }
+                       }
+                       
+                       targetDialog.setOKButtonEnable(toggleButton.isToggled());
+               }
+       };
+
+       private Listener toggleDownListener = new Listener() {
+               @Override
+               public void handleEvent(Event event) {
+                       DACustomFeatureToggleButton toggleButton = (DACustomFeatureToggleButton) event.widget;
+                       if (toggleButton.isToggled()) {
+                               toggleButton.getParent().setBackground(ColorResources.FEATURE_FEATURELISTCOMP_NORMAL_BACKGROUND);
+                       }
+               }
+       };
+
+       private Listener cursorListener = new Listener() {
+               public void handleEvent(Event event) {
+                       if (event.type == SWT.MouseEnter || event.type == SWT.MouseExit) {
+                               DACustomFeatureToggleButton toggleButton = (DACustomFeatureToggleButton) event.widget;
+                               toggleButton.setFocus();
+
+                               if (daCursor != null)
+                                       daCursor.dispose();
+
+                               if (event.type == SWT.MouseEnter)
+                                       daCursor = new Cursor(getShell().getDisplay(), SWT.CURSOR_HAND);
+                               else if (event.type == SWT.MouseExit)
+                                       daCursor = new Cursor(getShell().getDisplay(), SWT.CURSOR_ARROW);
+                               else
+                                       return;
+
+                               getShell().setCursor(daCursor);
+                       }
+               }
+       };
+}
diff --git a/org.tizen.dynamicanalyzer/src/org/tizen/dynamicanalyzer/ui/toolbar/setting/TargetDialogInfoPage.java b/org.tizen.dynamicanalyzer/src/org/tizen/dynamicanalyzer/ui/toolbar/setting/TargetDialogInfoPage.java
new file mode 100644 (file)
index 0000000..4dd44f3
--- /dev/null
@@ -0,0 +1,259 @@
+/*
+ *  Dynamic Analyzer
+ *
+ * Copyright (c) 2000 - 2016 Samsung Electronics Co., Ltd. All rights reserved.
+ *
+ * Contact: 
+ * Dongkye Lee <dongkyu6.lee@samsung.com>
+ * Jaeyong Lee <jae-yong.lee@@samsung.com>
+ * Gihun Chang <gihun.chang@@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.
+ * 
+ */
+
+package org.tizen.dynamicanalyzer.ui.toolbar.setting;
+
+import java.io.IOException;
+import java.text.SimpleDateFormat;
+import java.util.Date;
+
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.layout.FormAttachment;
+import org.eclipse.swt.layout.FormData;
+import org.eclipse.swt.layout.FormLayout;
+import org.eclipse.swt.layout.RowLayout;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.swt.widgets.Label;
+import org.tizen.dynamicanalyzer.communicator.DeviceInfo;
+import org.tizen.dynamicanalyzer.nl.TargetDialogLabels;
+import org.tizen.dynamicanalyzer.project.PackageInfo;
+import org.tizen.dynamicanalyzer.resources.ColorResources;
+import org.tizen.dynamicanalyzer.resources.FontResources;
+import org.tizen.dynamicanalyzer.widgets.da.view.DAPageComposite;
+import org.tizen.dynamicanalyzer.widgets.helper.Formatter;
+import org.tizen.sdblib.exception.SdbCommandRejectedException;
+import org.tizen.sdblib.exception.TimeoutException;
+
+public class TargetDialogInfoPage extends DAPageComposite {
+       
+       private Composite infoParentComp = null;
+       
+       private Composite deviceInfoComp = null;
+       private Composite appInfoComp = null;
+       
+       private DeviceInfo selectedDev = null;
+       private PackageInfo selectedApp = null;
+
+       public TargetDialogInfoPage(Composite parent, int style) {
+               super(parent, style);
+               this.setLayout(new FormLayout());
+               this.setBackground(ColorResources.FEATURE_FEATURELISTCOMP_NORMAL_BACKGROUND);
+               
+               this.infoParentComp = parent;
+       }
+       
+       public void drawDeviceInfoPage(DeviceInfo curDev) {
+               if(deviceInfoComp != null){
+                       deviceInfoComp.dispose();
+                       deviceInfoComp = null;
+               }
+               
+               selectedDev = curDev;
+               
+               deviceInfoComp = new Composite(infoParentComp, SWT.NONE);
+               FormData data = new FormData();
+               data.top = new FormAttachment(0, 38);
+               data.left = new FormAttachment(0, 40);
+               data.right = new FormAttachment(100, 0);
+               data.height = 180;
+               deviceInfoComp.setLayoutData(data);
+               deviceInfoComp.setBackground(ColorResources.FEATURE_FEATURELISTCOMP_NORMAL_BACKGROUND);
+               deviceInfoComp.setLayout(new FormLayout());
+               
+               if(curDev != null) {
+                       createDevInfoLabels(deviceInfoComp, curDev);
+               }
+               
+               infoParentComp.layout(true);
+               deviceInfoComp.layout();
+       }
+       
+       public void drawAppInfoPage(PackageInfo curApp) {
+               if(appInfoComp != null){
+                       appInfoComp.dispose();
+                       appInfoComp = null;
+               }
+               
+               selectedApp = curApp;
+               
+               appInfoComp = new Composite(infoParentComp, SWT.NONE);
+               FormData data = new FormData();
+               data.top = new FormAttachment(0, 38 + 180 + 20);
+               data.left = new FormAttachment(0, 40);
+               data.right = new FormAttachment(100, 0);
+               data.height = 180;
+               appInfoComp.setLayoutData(data);
+               appInfoComp.setBackground(ColorResources.FEATURE_FEATURELISTCOMP_NORMAL_BACKGROUND);
+               appInfoComp.setLayout(new FormLayout());
+               
+               if (curApp != null) {
+                       createAppInfoLabels(appInfoComp, curApp);
+               }
+               
+               infoParentComp.layout(true);
+               appInfoComp.layout();
+       }
+       
+       public DeviceInfo getSelectedDevice() {
+               return this.selectedDev;
+       }
+       
+       public PackageInfo getSelectedApp() {
+               return this.selectedApp;
+       }
+       
+       private void createDevInfoLabels(Composite deviceComp, DeviceInfo curDev) {
+               Label deviceLabel = new Label(deviceComp, SWT.LEFT);
+               FormData data = new FormData();
+               data.top = new FormAttachment(0, 0);
+               data.left = new FormAttachment(0, 0);
+               data.right = new FormAttachment(100, 0);
+               data.height = 25;
+               deviceLabel.setLayoutData(data);
+               deviceLabel.setBackground(ColorResources.FEATURE_FEATURELISTCOMP_NORMAL_BACKGROUND);
+               deviceLabel.setFont(FontResources.DIALOG_CONTENTS_BOLD_FONT);
+               deviceLabel.setText(TargetDialogLabels.DEVICE);
+               
+               RowLayout rowlayout = new RowLayout(SWT.VERTICAL);
+               rowlayout.justify = true;
+               rowlayout.fill = true;
+               
+               Composite leftComp = new Composite(deviceComp, SWT.NONE);
+               data = new FormData();
+               data.top = new FormAttachment(deviceLabel, 0);
+               data.left = new FormAttachment(0, 10);
+               data.bottom = new FormAttachment(100, 0);
+               data.width = 128;
+               leftComp.setLayoutData(data);
+               leftComp.setBackground(ColorResources.FEATURE_FEATURELISTCOMP_NORMAL_BACKGROUND);
+               leftComp.setLayout(rowlayout);
+               
+               createLabel(leftComp, TargetDialogLabels.VERSION);
+               createLabel(leftComp, TargetDialogLabels.CPU);
+               createLabel(leftComp, TargetDialogLabels.RAM);
+               createLabel(leftComp, "Device Name");
+               
+               Composite rightComp = new Composite(deviceComp, SWT.NONE);
+               data = new FormData();
+               data.top = new FormAttachment(deviceLabel, 0);
+               data.left = new FormAttachment(leftComp, 40);
+               data.bottom = new FormAttachment(100, 0);
+               data.width = 190;
+               rightComp.setLayoutData(data);
+               rightComp.setBackground(ColorResources.FEATURE_FEATURELISTCOMP_NORMAL_BACKGROUND);
+               rightComp.setLayout(rowlayout);
+               
+               String version = "unknown";
+               String arch = "unknown";
+               String ram = "unknown";
+               String devicename = "unknown";          
+               
+               try {
+                       version = curDev.getIDevice().getPlatformInfo().getPlatformVersion();
+                       
+                       if(curDev.getIDevice().getArch().getArch().contains("86")) {
+                               arch = "x86";
+                       }
+                       else if(curDev.getIDevice().getArch().getArch().toLowerCase().equals("arm")) {
+                               arch = "ARM";
+                       }
+                       else {
+                               arch = "unknown";
+                       }
+                       
+                       ram = Formatter.toByteFormat(curDev.getDeviceStatusInfo().getSystemMemorySize());
+                       devicename = curDev.getIDevice().getDeviceName();
+               } catch (TimeoutException e) {
+                       e.printStackTrace();
+               } catch (SdbCommandRejectedException e) {
+                       e.printStackTrace();
+               } catch (IOException e) {
+                       e.printStackTrace();
+               }
+               finally {
+                       createLabel(rightComp, version);
+                       createLabel(rightComp, arch);
+                       createLabel(rightComp, ram);
+                       createLabel(rightComp, devicename);
+               }
+       }
+
+       private void createAppInfoLabels(Composite appComp, PackageInfo curApp) {
+               Label applicationLabel = new Label(appComp, SWT.LEFT);
+               FormData data = new FormData();
+               data.top = new FormAttachment(0, 0);
+               data.left = new FormAttachment(0, 0);
+               data.right = new FormAttachment(100, 0);
+               data.height = 25;
+               applicationLabel.setLayoutData(data);
+               applicationLabel.setBackground(ColorResources.FEATURE_FEATURELISTCOMP_NORMAL_BACKGROUND);
+               applicationLabel.setFont(FontResources.DIALOG_CONTENTS_BOLD_FONT);
+               applicationLabel.setText(TargetDialogLabels.APPLICATION);
+               
+               RowLayout rowlayout = new RowLayout(SWT.VERTICAL);
+               rowlayout.justify = true;
+               rowlayout.fill = true;
+               
+               Composite leftComp = new Composite(appComp, SWT.NONE);
+               data = new FormData();
+               data.top = new FormAttachment(applicationLabel, 0);
+               data.left = new FormAttachment(0, 10);
+               data.bottom = new FormAttachment(100, 0);
+               data.width = 128;
+               leftComp.setLayoutData(data);
+               leftComp.setBackground(ColorResources.FEATURE_FEATURELISTCOMP_NORMAL_BACKGROUND);
+               leftComp.setLayout(rowlayout);
+               
+               createLabel(leftComp, TargetDialogLabels.PACKAGE_NAME);
+               createLabel(leftComp, TargetDialogLabels.PACKAGE_VERSION);
+               createLabel(leftComp, TargetDialogLabels.PACKAGE_INSTALLED_TIME);
+               createLabel(leftComp, TargetDialogLabels.ALLPLICATION_EXEC_PATH);
+               
+               Composite rightComp = new Composite(appComp, SWT.NONE);
+               data = new FormData();
+               data.top = new FormAttachment(applicationLabel, 0);
+               data.left = new FormAttachment(leftComp, 40);
+               data.bottom = new FormAttachment(100, 0);
+               data.width = 190;
+               rightComp.setLayoutData(data);
+               rightComp.setBackground(ColorResources.FEATURE_FEATURELISTCOMP_NORMAL_BACKGROUND);
+               rightComp.setLayout(rowlayout);
+               
+               SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
+               
+               createLabel(rightComp, curApp.getPackageId());
+               createLabel(rightComp, curApp.getVersion());
+               createLabel(rightComp, dateFormat.format(new Date(curApp.getInstallTime() * 1000)));
+               createLabel(rightComp, curApp.getMainApp().getExecPath());
+       }
+       
+       private Label createLabel(Composite parent, String text) {
+               Label label = new Label(parent, SWT.LEFT);
+               label.setBackground(ColorResources.FEATURE_FEATURELISTCOMP_NORMAL_BACKGROUND);
+               label.setFont(FontResources.DIALOG_CONTENTS_NORMAL_FONT);
+               label.setText(text);
+
+               return label;
+       }
+}
diff --git a/org.tizen.dynamicanalyzer/src/org/tizen/dynamicanalyzer/ui/toolbar/setting/TargetDialogTargetPage.java b/org.tizen.dynamicanalyzer/src/org/tizen/dynamicanalyzer/ui/toolbar/setting/TargetDialogTargetPage.java
new file mode 100644 (file)
index 0000000..bdaa47a
--- /dev/null
@@ -0,0 +1,437 @@
+/*
+ *  Dynamic Analyzer
+ *
+ * Copyright (c) 2000 - 2016 Samsung Electronics Co., Ltd. All rights reserved.
+ *
+ * Contact: 
+ * Dongkye Lee <dongkyu6.lee@samsung.com>
+ * Jaeyong Lee <jae-yong.lee@@samsung.com>
+ * Gihun Chang <gihun.chang@@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.
+ * 
+ */
+
+package org.tizen.dynamicanalyzer.ui.toolbar.setting;
+
+import java.util.ArrayList;
+import java.util.List;
+import java.util.Map;
+
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.custom.ScrolledComposite;
+import org.eclipse.swt.graphics.Cursor;
+import org.eclipse.swt.graphics.Image;
+import org.eclipse.swt.graphics.Point;
+import org.eclipse.swt.layout.FillLayout;
+import org.eclipse.swt.layout.FormAttachment;
+import org.eclipse.swt.layout.FormData;
+import org.eclipse.swt.layout.FormLayout;
+import org.eclipse.swt.layout.RowData;
+import org.eclipse.swt.layout.RowLayout;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.swt.widgets.Event;
+import org.eclipse.swt.widgets.Listener;
+import org.eclipse.swt.widgets.Shell;
+import org.tizen.dynamicanalyzer.common.AnalyzerConstants;
+import org.tizen.dynamicanalyzer.common.AnalyzerShellCommands;
+import org.tizen.dynamicanalyzer.communicator.CommunicatorUtils;
+import org.tizen.dynamicanalyzer.communicator.DeviceInfo;
+import org.tizen.dynamicanalyzer.communicator.DeviceManager;
+import org.tizen.dynamicanalyzer.control.ApplistManager;
+import org.tizen.dynamicanalyzer.nl.ConfigureLabels;
+import org.tizen.dynamicanalyzer.project.AppInfo;
+import org.tizen.dynamicanalyzer.project.PackageInfo;
+import org.tizen.dynamicanalyzer.resources.ColorResources;
+import org.tizen.dynamicanalyzer.resources.FontResources;
+import org.tizen.dynamicanalyzer.resources.ImageResources;
+import org.tizen.dynamicanalyzer.ui.toolbar.RemoteDeviceDialog;
+import org.tizen.dynamicanalyzer.util.Logger;
+import org.tizen.dynamicanalyzer.util.WorkbenchUtil;
+import org.tizen.dynamicanalyzer.widgets.button.DACustomButton;
+import org.tizen.dynamicanalyzer.widgets.button.DACustomButtonClickEventListener;
+import org.tizen.dynamicanalyzer.widgets.button.toggle.DACustomFeatureToggleButton;
+import org.tizen.dynamicanalyzer.widgets.da.view.DAPageComposite;
+import org.tizen.sdblib.receiver.MultiLineReceiver;
+
+public class TargetDialogTargetPage extends DAPageComposite {
+
+       private enum ProfileDisplayInfo {
+               PROFILE_NAME_MOBILE(0, ConfigureLabels.TARGET_NAME_FLAT_MOBILE_FOCUS,
+                               ImageResources.TARGET_NAME_FLAT_MOBILE_SEL, ImageResources.TARGET_NAME_FLAT_MOBILE_NORMAL,
+                               ImageResources.TARGET_NAME_FLAT_MOBILE_OVER), PROFILE_NAME_TV(1,
+                                               ConfigureLabels.TARGET_NAME_FLAT_TV_FOCUS, ImageResources.TARGET_NAME_FLAT_TV_SEL,
+                                               ImageResources.TARGET_NAME_FLAT_TV_NORMAL,
+                                               ImageResources.TARGET_NAME_FLAT_TV_OVER), PROFILE_NAME_WEARABLE(2,
+                                                               ConfigureLabels.TARGET_NAME_FLAT_WEARABLE_FOCUS,
+                                                               ImageResources.TARGET_NAME_FLAT_WEARABLE_SEL,
+                                                               ImageResources.TARGET_NAME_FLAT_WEARABLE_NORMAL,
+                                                               ImageResources.TARGET_NAME_FLAT_WEARABLE_OVER);
+
+               private String displayName = null;
+               private Image focusImage = null;
+               private Image normalImage = null;
+               private Image overImage = null;
+
+               private ProfileDisplayInfo(int id, String displayName, Image focusImage, Image normalImage, Image overImage) {
+                       this.displayName = displayName;
+                       this.focusImage = focusImage;
+                       this.normalImage = normalImage;
+                       this.overImage = overImage;
+               }
+
+               public static Image getImage(String displayName) {
+                       ProfileDisplayInfo[] profiles = ProfileDisplayInfo.values();
+                       for (ProfileDisplayInfo profile : profiles) {
+                               if (profile.displayName.equals(displayName)) {
+                                       return profile.normalImage;
+                               }
+                       }
+                       return null;
+               }
+
+               public static Image getFocusImage(String displayName) {
+                       ProfileDisplayInfo[] profiles = ProfileDisplayInfo.values();
+                       for (ProfileDisplayInfo profile : profiles) {
+                               if (profile.displayName.equals(displayName)) {
+                                       return profile.focusImage;
+                               }
+                       }
+                       return null;
+               }
+
+               public static Image getOverImage(String displayName) {
+                       ProfileDisplayInfo[] profiles = ProfileDisplayInfo.values();
+                       for (ProfileDisplayInfo profile : profiles) {
+                               if (profile.displayName.equals(displayName)) {
+                                       return profile.overImage;
+                               }
+                       }
+                       return null;
+               }
+       };
+
+       private Composite targetParentComp = null;
+       private TargetDialog targetDialog = null;
+       private List<DeviceInfo> deviceList = new ArrayList<DeviceInfo>();
+
+       private ScrolledComposite targetScrolledComposite = null;
+       private Composite targetCom = null;
+       private Cursor daCursor = null;
+       private List<DACustomFeatureToggleButton> targetList = new ArrayList<DACustomFeatureToggleButton>();
+
+       public TargetDialogTargetPage(Composite parent, TargetDialog targetDialog, int style) {
+               super(parent, style);
+               this.setLayout(new FormLayout());
+               this.setBackground(ColorResources.FEATURE_TARGETCOMP_BACKGROUND);
+
+               this.targetDialog = targetDialog;
+               this.targetParentComp = parent;
+
+               Composite connectComp = new Composite(targetParentComp, SWT.NONE);
+               FormData data = new FormData();
+               data.top = new FormAttachment(0, 419);
+               data.left = new FormAttachment(0, 0);
+               data.right = new FormAttachment(100, 0);
+               data.bottom = new FormAttachment(100, 0);
+               connectComp.setLayoutData(data);
+               connectComp.setLayout(new FormLayout());
+               connectComp.setBackground(ColorResources.FEATURE_TARGETCOMP_BACKGROUND);
+
+               DACustomButton connectbutton = new DACustomButton(connectComp, SWT.NONE);
+               connectbutton.setImages(ImageResources.CONNECT_BTN_NOR, ImageResources.CONNECT_BTN_SEL,
+                               ImageResources.CONNECT_BTN_OVER, ImageResources.CONNECT_BTN_NOR);
+               data = new FormData();
+               data.top = new FormAttachment(0, 20);
+               data.left = new FormAttachment(0, 27);
+               data.width = 126;
+               data.height = 30;
+               connectbutton.setLayoutData(data);
+               connectbutton.addClickListener(new DACustomButtonClickEventListener() {
+
+                       @Override
+                       public void handleClickEvent(DACustomButton button) {
+                               Shell shell = WorkbenchUtil.getWorkbenchWindow().getShell();
+                               RemoteDeviceDialog pdialog = new RemoteDeviceDialog(shell);
+                               pdialog.open();
+                               String newDevice = pdialog.getAddress();
+                               if (newDevice != null && !newDevice.isEmpty()) {
+                                       drawTarageData();
+                               }
+                       }
+               });
+
+               drawTarageData();               
+       }
+
+       public void drawTarageData() {
+               deviceList.clear();
+               targetList.clear();
+
+               if (targetScrolledComposite != null) {
+                       targetScrolledComposite.dispose();
+                       targetScrolledComposite = null;
+               }
+
+               if (targetCom != null) {
+                       targetCom.dispose();
+                       targetCom = null;
+               }
+
+               // scrolledComposite
+               targetScrolledComposite = new ScrolledComposite(targetParentComp, SWT.V_SCROLL);
+               targetScrolledComposite.setLayout(new FormLayout());
+               FormData data = new FormData();
+               data.top = new FormAttachment(0, 0);
+               data.left = new FormAttachment(0, 0);
+               data.right = new FormAttachment(100, 0);
+               data.bottom = new FormAttachment(100, -70);
+               targetScrolledComposite.setLayoutData(data);
+               targetScrolledComposite.setExpandHorizontal(true);
+               targetScrolledComposite.setExpandVertical(true);
+               targetScrolledComposite.setBackground(ColorResources.FEATURE_TARGETCOMP_BACKGROUND);
+
+               targetCom = new Composite(targetScrolledComposite, SWT.NONE);
+               targetCom.setBackground(ColorResources.FEATURE_TARGETCOMP_BACKGROUND);
+               targetCom.setLayout(new RowLayout(SWT.VERTICAL));
+
+               targetScrolledComposite.setContent(targetCom);
+
+               Composite buttonComp = new Composite(targetCom, SWT.NONE);
+               buttonComp.setLayoutData(new RowData(SWT.DEFAULT, 15));
+               buttonComp.setLayout(new FillLayout());
+
+               if (getConnectedTargets() == true) {
+                       for (DeviceInfo device : deviceList) {
+                               try {
+                                       String profileName = device.getIDevice().getPlatformInfo().getProfileName();
+                                       String serial = device.getIDevice().getSerialNumber();
+                                       DACustomFeatureToggleButton toggle = createToggleButton(targetCom, profileName, serial);
+                                       toggle.addListener(SWT.MouseUp, toggleUpListener);
+                                       toggle.addListener(SWT.MouseDown, toggleDownListener);
+                                       toggle.addListener(SWT.MouseEnter, cursorListener);
+                                       toggle.addListener(SWT.MouseExit, cursorListener);
+
+                                       targetList.add(toggle);
+                               } catch (Exception e) {
+                                       // TODO Auto-generated catch block
+                                       e.printStackTrace();
+                               }
+                       }
+               } else {
+                       Logger.debug("Failed : Getting connected device information");
+               }
+
+               targetParentComp.layout(true);
+               targetScrolledComposite.layout();
+               targetScrolledComposite.setMinSize(targetCom.computeSize(SWT.DEFAULT, SWT.DEFAULT));
+       }
+       
+       public boolean selectDevice(DeviceInfo curDev) {
+               String selectedDevStr = curDev.getIDevice().getSerialNumber();
+               for (DACustomFeatureToggleButton toggleButton : targetList) {
+                       if (toggleButton.getToolTipText().equals(selectedDevStr)) {
+                               toggleButton.setToggled(true);
+                               toggleButton.getParent().setBackground(ColorResources.FEATURE_FEATURELISTCOMP_SELECT_BACKGROUND);
+                               
+                               targetDialog.getAppListPage().drawAppList(updateAppListFromTarget(curDev));
+                               targetDialog.getInfoPage().drawDeviceInfoPage(curDev);
+                               return true;
+                       }
+               }
+               
+               return false;
+       }
+
+       private DACustomFeatureToggleButton createToggleButton(Composite composit, String profile, String serial) {
+               Composite buttonComp = new Composite(composit, SWT.NONE);
+               buttonComp.setLayoutData(new RowData(SWT.DEFAULT, 65));
+               buttonComp.setBackground(ColorResources.FEATURE_TARGETCOMP_BACKGROUND);
+               buttonComp.setLayout(new FormLayout());
+
+               Image normalImage = ProfileDisplayInfo.getImage(profile);
+               Image pushImage = ProfileDisplayInfo.getFocusImage(profile);
+               Image hoverImage = ProfileDisplayInfo.getOverImage(profile);
+
+               DACustomFeatureToggleButton toggle = new DACustomFeatureToggleButton(buttonComp, SWT.NONE);
+               // color and image
+               toggle.setColors(ColorResources.FEATURE_TARGETCOMP_BACKGROUND, ColorResources.FEATURE_TARGETCOMP_BACKGROUND,
+                               ColorResources.FEATURE_TARGETCOMP_BACKGROUND, ColorResources.FEATURE_TARGETCOMP_BACKGROUND,
+                               ColorResources.FEATURE_FEATURELISTCOMP_SELECT_BACKGROUND,
+                               ColorResources.FEATURE_FEATURELISTCOMP_SELECT_BACKGROUND,
+                               ColorResources.FEATURE_FEATURELISTCOMP_SELECT_BACKGROUND);
+               toggle.setButtonImages(normalImage, pushImage, hoverImage, normalImage, pushImage, hoverImage, pushImage);
+               toggle.setButtonImagePoint(new Point(0, 0));
+
+               // font
+               toggle.setTitle(profile);
+               toggle.setFontPoint(new Point(55, 10));
+               toggle.setFontColors(ColorResources.SETTING_COLOR, ColorResources.SETTING_COLOR, ColorResources.SETTING_COLOR,
+                               ColorResources.SETTING_COLOR);
+               toggle.setButtonFont(FontResources.SETTING_BUTTON_FONT);
+               toggle.setBackground(ColorResources.FEATURE_TARGETCOMP_BACKGROUND);
+               toggle.setToolTipText(serial);
+
+               // layout
+               FormData data = new FormData();
+               data.top = new FormAttachment(0, 13);
+               data.left = new FormAttachment(0, 20);
+               data.height = 40;
+               data.width = 155;
+               toggle.setLayoutData(data);
+
+               return toggle;
+       }
+
+       private boolean getConnectedTargets() {
+               boolean ret = true;
+
+               List<DeviceInfo> devices = DeviceManager.getDevices();
+
+               if (devices == null) {
+                       return false;
+               }
+
+               for (DeviceInfo device : devices) {
+                       try {
+                               deviceList.add(device);
+                       } catch (Exception e) {
+                               ret = false;
+                       }
+
+               }
+
+               return ret;
+       }
+
+       private Map<String, PackageInfo> updateAppListFromTarget(DeviceInfo curDev) {
+               if (curDev == null) {
+                       return null;
+               }
+
+               final List<String> unittestLines = new ArrayList<String>();
+               final List<String> imeLines = new ArrayList<String>();
+               final List<String> pkginfoLines = new ArrayList<String>();
+
+               CommunicatorUtils.execShellCommand(curDev.getIDevice(), AnalyzerShellCommands.CMD_APPLICATION_LIST,
+                               new MultiLineReceiver() {
+                                       @Override
+                                       public void processNewLines(String[] appLines) {
+                                               for (int i = 0; i < appLines.length; i++) {
+                                                       pkginfoLines.add(appLines[i]);
+                                               }
+                                       }
+                               });
+
+               pkginfoLines.add("");
+
+               // add lines for running process
+               pkginfoLines.add(PackageInfo.PKGTYPE + "[unknown]" + PackageInfo.PKGID + "[" + AnalyzerConstants.RUNNING_PROCESS
+                               + "]" + PackageInfo.PRELOAD + "[1]");
+               pkginfoLines.add(AppInfo.PROPERTY.APPID.name + ":" + AnalyzerConstants.RUNNING_PROCESS);
+               pkginfoLines.add(AppInfo.PROPERTY.PACKAGE.name + ":" + AnalyzerConstants.RUNNING_PROCESS);
+               pkginfoLines.add(AppInfo.PROPERTY.LABEL.name + ":" + AnalyzerConstants.RUNNING_PROCESS_LABEL);
+               pkginfoLines.add(AppInfo.PROPERTY.APPTYPE.name + ":" + AppInfo.APPTYPE_RUNNING);
+               pkginfoLines.add("");
+
+               // add lines for common-executable
+               pkginfoLines.add(PackageInfo.PKGTYPE + "[unknown]" + PackageInfo.PKGID + "["
+                               + AnalyzerConstants.COMMON_EXECUTABLE + "]" + PackageInfo.PRELOAD + "[1]");
+               pkginfoLines.add(AppInfo.PROPERTY.APPID.name + ":" + AnalyzerConstants.COMMON_EXECUTABLE);
+               pkginfoLines.add(AppInfo.PROPERTY.PACKAGE.name + ":" + AnalyzerConstants.COMMON_EXECUTABLE);
+               pkginfoLines.add(AppInfo.PROPERTY.LABEL.name + ":" + AnalyzerConstants.COMMON_EXECUTABLE_LABEL);
+               pkginfoLines.add(AppInfo.PROPERTY.APPTYPE.name + ":" + AppInfo.APPTYPE_EXEC);
+               pkginfoLines.add("");
+
+               // add lines for without-executable
+               pkginfoLines.add(PackageInfo.PKGTYPE + "[unknown]" + PackageInfo.PKGID + "["
+                               + AnalyzerConstants.WITHOUT_EXECUTABLE + "]" + PackageInfo.PRELOAD + "[1]");
+               pkginfoLines.add(AppInfo.PROPERTY.APPID.name + ":" + AnalyzerConstants.WITHOUT_EXECUTABLE);
+               pkginfoLines.add(AppInfo.PROPERTY.PACKAGE.name + ":" + AnalyzerConstants.WITHOUT_EXECUTABLE);
+               pkginfoLines.add(AppInfo.PROPERTY.LABEL.name + ":" + AnalyzerConstants.WITHOUT_EXECUTABLE_LABEL);
+               pkginfoLines.add(AppInfo.PROPERTY.APPTYPE.name + ":" + AppInfo.APPTYPE_NONE);
+               pkginfoLines.add("");
+
+               curDev.updatePackageList(ApplistManager.parseTizenPkginfo(pkginfoLines, unittestLines, imeLines,
+                               curDev.getIDevice().getAppInstallPath()));
+
+               return curDev.getPackageInfoHash();
+       }
+
+       private Listener toggleUpListener = new Listener() {
+               public void handleEvent(Event event) {
+                       DACustomFeatureToggleButton toggleButton = (DACustomFeatureToggleButton) event.widget;
+                       if (!toggleButton.isToggled()) {
+                               toggleButton.getParent().setBackground(ColorResources.FEATURE_TARGETCOMP_BACKGROUND);
+                       } else {
+                               toggleButton.getParent().setBackground(ColorResources.FEATURE_FEATURELISTCOMP_SELECT_BACKGROUND);
+
+                               for (DACustomFeatureToggleButton other : targetList) {
+                                       if (!other.getToolTipText().equals(toggleButton.getToolTipText()) && other.isToggled()) {
+                                               other.setToggled(false);
+                                               other.getParent().setBackground(ColorResources.FEATURE_TARGETCOMP_BACKGROUND);
+                                       }
+                               }
+                       }
+
+                       for (DeviceInfo device : deviceList) {
+                               String serial = device.getIDevice().getSerialNumber();
+                               if (serial.equals(toggleButton.getToolTipText())) {
+                                       if (toggleButton.isToggled()) {
+                                               targetDialog.getAppListPage().drawAppList(updateAppListFromTarget(device));
+                                               targetDialog.getInfoPage().drawDeviceInfoPage(device);
+                                               targetDialog.getInfoPage().drawAppInfoPage(null);
+                                       } else {
+                                               targetDialog.getAppListPage().drawAppList(null);
+                                               targetDialog.getInfoPage().drawDeviceInfoPage(null);
+                                               targetDialog.getInfoPage().drawAppInfoPage(null);
+                                       }
+                                       break;
+                               }
+                       }
+
+                       targetDialog.setOKButtonEnable(false);
+               }
+       };
+
+       private Listener toggleDownListener = new Listener() {
+               @Override
+               public void handleEvent(Event event) {
+                       DACustomFeatureToggleButton toggleButton = (DACustomFeatureToggleButton) event.widget;
+                       if (toggleButton.isToggled()) {
+                               toggleButton.getParent().setBackground(ColorResources.FEATURE_TARGETCOMP_BACKGROUND);
+                       }
+               }
+       };
+
+       private Listener cursorListener = new Listener() {
+               public void handleEvent(Event event) {
+                       if (event.type == SWT.MouseEnter || event.type == SWT.MouseExit) {
+                               DACustomFeatureToggleButton toggleButton = (DACustomFeatureToggleButton) event.widget;
+                               toggleButton.setFocus();
+
+                               if (daCursor != null)
+                                       daCursor.dispose();
+
+                               if (event.type == SWT.MouseEnter)
+                                       daCursor = new Cursor(getShell().getDisplay(), SWT.CURSOR_HAND);
+                               else if (event.type == SWT.MouseExit)
+                                       daCursor = new Cursor(getShell().getDisplay(), SWT.CURSOR_ARROW);
+                               else
+                                       return;
+
+                               getShell().setCursor(daCursor);
+                       }
+               }
+       };
+}