[Title] binary settings update
authorjooyoul_lee <jy.exe.lee@samsung.com>
Tue, 7 Jan 2014 03:31:40 +0000 (12:31 +0900)
committerjooyoul_lee <jy.exe.lee@samsung.com>
Tue, 7 Jan 2014 03:31:40 +0000 (12:31 +0900)
[Desc.]
[Issue]

org.tizen.dynamicanalyzer.widgets/src/org/tizen/dynamicanalyzer/widgets/button/DACustomButton.java
org.tizen.dynamicanalyzer.workbench/dynamic-analyzer/tool/debuginfo.sh [changed mode: 0644->0755]
org.tizen.dynamicanalyzer/src/org/tizen/dynamicanalyzer/common/AnalyzerPaths.java
org.tizen.dynamicanalyzer/src/org/tizen/dynamicanalyzer/listeners/AnalyzerPerspectiveListener.java
org.tizen.dynamicanalyzer/src/org/tizen/dynamicanalyzer/swap/platform/BinarySettingData.java
org.tizen.dynamicanalyzer/src/org/tizen/dynamicanalyzer/swap/platform/BinarySettingManager.java
org.tizen.dynamicanalyzer/src/org/tizen/dynamicanalyzer/swap/platform/ui/InputRow.java
org.tizen.dynamicanalyzer/src/org/tizen/dynamicanalyzer/ui/toolbar/configuration/BinarySettingsPage.java
org.tizen.dynamicanalyzer/src/org/tizen/dynamicanalyzer/ui/toolbar/configuration/ConfigurationDialog.java
org.tizen.dynamicanalyzer/src/org/tizen/dynamicanalyzer/ui/widgets/WarningDialog.java [new file with mode: 0644]

index a1e4b00..2904e4a 100644 (file)
@@ -274,6 +274,7 @@ public class DACustomButton extends Canvas {
         */
        public void setText(String newTitle) {
                attr.setText(newTitle);
+               this.redraw();
        }
 
        /**
index 86ba509..af70157 100644 (file)
@@ -51,7 +51,8 @@ public class AnalyzerPaths {
                        + File.separator + AnalyzerConstants.TEMP_FOLDER_NAME;
        public static final String CONFIG_FOLDER_PATH = PathManager
                        .getConfigFolderPath();
-       public static final String WORKBENCH_FOLDER_PATH = PathManager.getWorkbenchPath();
+       public static final String WORKBENCH_FOLDER_PATH = PathManager
+                       .getWorkbenchPath();
        public static final String ABOUT_FILE_PATH = PathManager.getAboutPath();
        public static final String SDB_PATH = PathManager.getSdbPath();
        public static final String READELF_PATH = DYNAMIC_ANALYZER_INSTALL_PATH
@@ -92,6 +93,8 @@ public class AnalyzerPaths {
                        + AnalyzerConstants.TOOLS_FOLDER_NAME + File.separator
                        + "smart-build-interface" + File.separator + "bin" + File.separator
                        + "sbi";
-       
+
        public static final String SDK_INFO_RELATIVE_PATH = "../../sdk.info"; //$NON-NLS-1$
+       public static final String BINARY_AUTO_SAVE_PATH = PathManager
+                       .getSavePath() + File.separator + "BinarySettings.save";
 }
index e0b3b2c..2f32ae5 100644 (file)
@@ -30,6 +30,7 @@ import org.eclipse.ui.IPerspectiveDescriptor;
 import org.eclipse.ui.IWorkbenchPage;
 import org.eclipse.ui.PerspectiveAdapter;
 import org.tizen.dynamicanalyzer.communicator.DACommunicator;
+import org.tizen.dynamicanalyzer.swap.platform.BinarySettingManager;
 import org.tizen.dynamicanalyzer.ui.toolbar.ToolbarArea;
 
 public class AnalyzerPerspectiveListener extends PerspectiveAdapter {
@@ -45,6 +46,7 @@ public class AnalyzerPerspectiveListener extends PerspectiveAdapter {
                        DACommunicator.addDeviceListener();
                        DACommunicator.loadDevices();
                        DACommunicator.updateToolbarDevice();
+                       BinarySettingManager.getInstance().initBinarySettings();
                        init = true;
                }
        }
index b3970ca..6098072 100644 (file)
@@ -97,7 +97,9 @@ public class BinarySettingData {
                setDebugSourcePath(splitContent[1]);
                setDebugRpmPath(splitContent[2]);
                setDebugFilePath(splitContent[3]);
-               setUserSourcePath(splitContent[4]);
+               if (splitContent.length >= 5) {
+                       setUserSourcePath(splitContent[4]);
+               }
        }
 
        public boolean isEqual(String binPath) {
index 78947e0..d72e74a 100644 (file)
@@ -27,6 +27,8 @@ package org.tizen.dynamicanalyzer.swap.platform;
 
 import java.io.BufferedReader;
 import java.io.File;
+import java.io.FileNotFoundException;
+import java.io.FileReader;
 import java.io.IOException;
 import java.io.InputStreamReader;
 import java.util.ArrayList;
@@ -39,6 +41,8 @@ import org.tizen.dynamicanalyzer.common.AnalyzerPaths;
 import org.tizen.dynamicanalyzer.common.CommonConstants;
 import org.tizen.dynamicanalyzer.common.PathManager;
 import org.tizen.dynamicanalyzer.swap.channel.control.BinaryInfo;
+import org.tizen.dynamicanalyzer.swap.platform.ui.BinarySettingProcessor;
+import org.tizen.dynamicanalyzer.swap.platform.ui.BinarySettingProgressManager;
 import org.tizen.dynamicanalyzer.swap.platform.ui.InputRow;
 import org.tizen.dynamicanalyzer.utils.AnalyzerUtil;
 
@@ -55,7 +59,7 @@ public class BinarySettingManager {
        private List<BinarySettingData> realBinarySettings = new ArrayList<BinarySettingData>();
 
        private String debugRoot = PathManager.getRootStrapsPath();
-       
+
        public static synchronized BinarySettingManager getInstance() {
                if (null == instance) {
                        instance = new BinarySettingManager();
@@ -408,4 +412,28 @@ public class BinarySettingManager {
        public void setDebugRoot(String debugRoot) {
                this.debugRoot = debugRoot;
        }
+
+       public void initBinarySettings() {
+               File saveFile = new File(AnalyzerPaths.BINARY_AUTO_SAVE_PATH);
+               BufferedReader br = null;
+               String content = null;
+               try {
+                       List<BinarySettingData> binarySettings = new ArrayList<BinarySettingData>();
+                       br = new BufferedReader(new FileReader(saveFile));
+                       while (null != (content = br.readLine())) {
+                               BinarySettingData binaryData = new BinarySettingData();
+                               binaryData.loadSaveData(content);
+                               binarySettings.add(binaryData);
+                       }
+
+                       BinarySettingManager.getInstance().putRealBinarySettingData(
+                                       binarySettings);
+               } catch (FileNotFoundException e) {
+                       e.printStackTrace();
+               } catch (IOException e) {
+                       e.printStackTrace();
+               } finally {
+                       AnalyzerUtil.tryClose(br);
+               }
+       }
 }
index 8cd3d8d..c618d6b 100644 (file)
@@ -92,7 +92,8 @@ public class InputRow extends Composite {
                        FileExplorerDialog dialog = new FileExplorerDialog(getShell());
                        dialog.setFilter("debug");
                        dialog.getExplorer().setRoot(
-                                       BinarySettingManager.getInstance().getDebugRoot());
+//                                     BinarySettingManager.getInstance().getDebugRoot());
+                                       "/home/");
                        Object result = dialog.open();
                        List<BinarySettingData> bins = new ArrayList<BinarySettingData>();
                        if (result != null) {
index a61e224..b79f6d5 100644 (file)
 package org.tizen.dynamicanalyzer.ui.toolbar.configuration;
 
 import java.io.BufferedReader;
+import java.io.BufferedWriter;
 import java.io.File;
 import java.io.FileNotFoundException;
 import java.io.FileReader;
+import java.io.FileWriter;
 import java.io.IOException;
 import java.util.ArrayList;
 import java.util.HashMap;
@@ -62,6 +64,7 @@ import org.tizen.dynamicanalyzer.swap.platform.ui.DeviceExplorer.DeviceExplorerD
 import org.tizen.dynamicanalyzer.swap.platform.ui.FileExplorer.FileExplorerDialog;
 import org.tizen.dynamicanalyzer.ui.page.DAPageComposite;
 import org.tizen.dynamicanalyzer.ui.widgets.DAButton;
+import org.tizen.dynamicanalyzer.ui.widgets.WarningDialog;
 import org.tizen.dynamicanalyzer.utils.AnalyzerUtil;
 import org.tizen.dynamicanalyzer.widgets.button.DACustomButton;
 import org.tizen.dynamicanalyzer.widgets.button.DACustomButtonClickEventListener;
@@ -196,6 +199,14 @@ public class BinarySettingsPage extends DAPageComposite {
 
                @Override
                public void handleClickEvent(DACustomButton button) {
+                       if (null != button) {
+                               WarningDialog dialog = new WarningDialog(getShell(), SWT.NONE);
+                               dialog.setMessage("Clear binary settings?\nIf you click 'Ok', All settings will be deleted");
+                               boolean result = dialog.open();
+                               if (!result) {
+                                       return;
+                               }
+                       }
                        List<BinarySettingData> binaries = BinarySettingManager
                                        .getInstance().getRealBinarySettings();
                        if (!binaries.isEmpty()) {
@@ -370,6 +381,40 @@ public class BinarySettingsPage extends DAPageComposite {
                System.out.println("update complete!");
        }
 
+       public void doClose() {
+               String targetPath = AnalyzerPaths.BINARY_AUTO_SAVE_PATH;
+
+               File saveFile = new File(targetPath);
+               FileWriter fileWriter = null;
+               BufferedWriter bufWriter = null;
+
+               List<BinarySettingData> saveData = BinarySettingManager.getInstance()
+                               .getRealBinarySettings();
+
+               boolean success = false;
+               try {
+                       fileWriter = new FileWriter(saveFile);
+                       bufWriter = new BufferedWriter(fileWriter);
+                       for (int i = 0; i < saveData.size(); i++) {
+                               bufWriter.write(saveData.get(i).getSaveData());
+                               bufWriter.newLine();
+                       }
+                       success = true;
+               } catch (IOException e) {
+                       e.printStackTrace();
+               } finally {
+                       AnalyzerUtil.tryClose(bufWriter, fileWriter);
+               }
+
+               if (success) {
+                       // add snapshot model update
+                       System.out.println("binary settings auto save success!!"); //$NON-NLS-1$
+
+               } else {
+                       System.out.println("binary settings auto save fail..."); //$NON-NLS-1$
+               }
+       }
+
        public void initInputRows() {
                List<BinarySettingData> binData = null;
                binData = BinarySettingManager.getInstance().getRealBinarySettings();
@@ -377,7 +422,7 @@ public class BinarySettingsPage extends DAPageComposite {
                for (int i = 0; i < binData.size(); i++) {
                        InputRow inputRow = new InputRow(inputComposite);
                        inputRow.setBinaryText(binData.get(i).getBinaryPath());
-//                     String debug = binData.get(i).getDebugFilePath();
+                       // String debug = binData.get(i).getDebugFilePath();
                        String debug = binData.get(i).getDebugRpmPath();
                        if (null != debug && !debug.isEmpty()) {
                                inputRow.setDebugText(debug);
@@ -389,7 +434,12 @@ public class BinarySettingsPage extends DAPageComposite {
                        if (null != source && !source.isEmpty()) {
                                inputRow.setSourceText(source);
                        } else {
-                               inputRow.setSourceText(CommonConstants.EMPTY);
+                               source = binData.get(i).getDebugSourcePath();
+                               if (null != source && !source.isEmpty()) {
+                                       inputRow.setSourceText(source);
+                               } else {
+                                       inputRow.setSourceText(CommonConstants.EMPTY);
+                               }
                        }
                        inputRowHash.put(binData.get(i).getBinaryPath(), inputRow);
                        inputRowList.add(inputRow);
index 870e78a..be4bd16 100644 (file)
@@ -36,7 +36,9 @@ 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.Event;
 import org.eclipse.swt.widgets.Label;
+import org.eclipse.swt.widgets.Listener;
 import org.eclipse.swt.widgets.Shell;
 import org.tizen.dynamicanalyzer.nl.AnalyzerLabels;
 import org.tizen.dynamicanalyzer.resources.ColorResources;
@@ -55,7 +57,8 @@ public class ConfigurationDialog extends DAMessageBox {
        private DACustomButton applyButton = null;
        private DACustomButton okButton = null;
        private DACustomButton cancelButton = null;
-       DATabComposite tabView = null;
+       private DATabComposite tabView = null;
+       private Composite buttonContentsComp = null;
        private DATableComposite featuresTable;
 
        public ConfigurationDialog(Shell parent) {
@@ -102,8 +105,16 @@ public class ConfigurationDialog extends DAMessageBox {
        }
 
        private void doBack() {
-               ConfigurationDialogDataManager.getInstance()
-                               .setSettingValueFromConfigureManager();
+               Composite selectedComposite = tabView.getTopComposite();
+               if (!(selectedComposite instanceof BinarySettingsPage)) {
+                       ConfigurationDialogDataManager.getInstance()
+                       .setSettingValueFromConfigureManager();
+               } else {
+                       BinarySettingsPage page = (BinarySettingsPage) selectedComposite;
+                       page.doClose();
+               }
+
+               
        }
 
        public void enableButteon() {
@@ -187,7 +198,7 @@ public class ConfigurationDialog extends DAMessageBox {
                                tabView.getContentComposite(), SWT.NONE);
                tabView.addView(binarySettings, false);
                // button
-               Composite buttonContentsComp = new Composite(shell, SWT.NONE);
+               buttonContentsComp = new Composite(shell, SWT.NONE);
                buttonContentsComp.addPaintListener(new PaintListener() {
                        @Override
                        public void paintControl(PaintEvent e) {
@@ -197,6 +208,39 @@ public class ConfigurationDialog extends DAMessageBox {
                                e.gc.drawLine(0, 0, rect.x + rect.width, 0);
                        }
                });
+
+               binarySettings.addListener(SWT.Show, new Listener() {
+
+                       @Override
+                       public void handleEvent(Event event) {
+                               System.out.println("binary settings show");
+                               cancelButton.setText(AnalyzerLabels.CLOSE);
+                               FormData data = (FormData) okButton.getLayoutData();
+                               data.width = 0;
+
+                               data = (FormData) applyButton.getLayoutData();
+                               data.width = 0;
+
+                               buttonContentsComp.layout();
+                       }
+               });
+
+               binarySettings.addListener(SWT.Hide, new Listener() {
+
+                       @Override
+                       public void handleEvent(Event event) {
+                               System.out.println("binary settings hide");
+                               cancelButton.setText(AnalyzerLabels.CANCEL);
+                               FormData data = (FormData) okButton.getLayoutData();
+                               data.width = 100;
+
+                               data = (FormData) applyButton.getLayoutData();
+                               data.width = 100;
+
+                               buttonContentsComp.layout();
+                       }
+               });
+
                compLayout = new FormLayout();
                buttonContentsComp.setLayout(compLayout);
                buttonContentsComp
diff --git a/org.tizen.dynamicanalyzer/src/org/tizen/dynamicanalyzer/ui/widgets/WarningDialog.java b/org.tizen.dynamicanalyzer/src/org/tizen/dynamicanalyzer/ui/widgets/WarningDialog.java
new file mode 100644 (file)
index 0000000..d9c4f05
--- /dev/null
@@ -0,0 +1,207 @@
+/*
+ *  Dynamic Analyzer
+ *
+ * Copyright (c) 2014 Samsung Electronics Co., Ltd. All rights reserved.
+ *
+ * Contact: 
+ * Jooyoul Lee <jy.exe.lee@samsung.com>
+ * Juyoung Kim <j0.kim@samsung.com>
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * 
+ * Contributors:
+ * - S-Core Co., Ltd
+ * 
+ */
+
+package org.tizen.dynamicanalyzer.ui.widgets;
+
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.events.PaintEvent;
+import org.eclipse.swt.events.PaintListener;
+import org.eclipse.swt.graphics.Image;
+import org.eclipse.swt.graphics.Rectangle;
+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.Label;
+import org.eclipse.swt.widgets.Shell;
+import org.tizen.dynamicanalyzer.common.CommonConstants;
+import org.tizen.dynamicanalyzer.common.DesignConstants;
+import org.tizen.dynamicanalyzer.nl.AnalyzerLabels;
+import org.tizen.dynamicanalyzer.resources.ColorResources;
+import org.tizen.dynamicanalyzer.resources.FontResources;
+import org.tizen.dynamicanalyzer.resources.ImageResources;
+import org.tizen.dynamicanalyzer.widgets.button.DACustomButton;
+import org.tizen.dynamicanalyzer.widgets.button.DACustomButtonClickEventListener;
+
+public class WarningDialog {
+
+       private Shell parent = null;
+       private Shell shell = null;
+       private DACustomButton okButton = null;
+       private DACustomButton cancelButton = null;
+       private String message = CommonConstants.EMPTY;
+       private boolean returnType = false;
+       private String titleText = AnalyzerLabels.DA_WARNING;
+
+       private Image iconImage = ImageResources.DIALOG_WARNING_ICON;
+
+       private DACustomButtonClickEventListener okButtonListener = new DACustomButtonClickEventListener() {
+
+               @Override
+               public void handleClickEvent(DACustomButton button) {
+                       returnType = true;
+                       shell.dispose();
+               }
+       };
+
+       private DACustomButtonClickEventListener cancelButtonListener = new DACustomButtonClickEventListener() {
+
+               @Override
+               public void handleClickEvent(DACustomButton button) {
+                       returnType = false;
+                       shell.dispose();
+               }
+       };
+
+       public WarningDialog(Shell parent, int style) {
+               this.parent = parent;
+       }
+
+       public WarningDialog(Shell parent, int style, int width, int height) {
+               this(parent, style);
+       }
+
+       public boolean open() {
+               shell = new Shell(parent, SWT.APPLICATION_MODAL | SWT.DIALOG_TRIM);
+               shell.setSize(446, 153);
+               shell.setLayout(new FormLayout());
+               shell.setText(titleText);
+
+               Composite base = new Composite(shell, SWT.NONE);
+               base.setLayout(new FormLayout());
+               FormData baseData = new FormData();
+               baseData.top = new FormAttachment(0, 0);
+               baseData.left = new FormAttachment(0, 0);
+               baseData.right = new FormAttachment(100, 0);
+               baseData.height = 76;
+               base.setLayoutData(baseData);
+               base.setVisible(true);
+               base.setBackground(ColorResources.DIALOG_BG_UPPER);
+
+               // Icon
+               Label icon = new Label(base, SWT.TRANSPARENT);
+               icon.setBackground(ColorResources.DIALOG_BG_UPPER);
+               icon.setImage(iconImage);
+
+               // Contents
+               Label strMessage = new Label(base, SWT.TRANSPARENT);
+               strMessage.setText(message);
+               strMessage.setBackground(ColorResources.DIALOG_BG_UPPER);
+               strMessage.setAlignment(SWT.LEFT);
+               strMessage.setForeground(ColorResources.DEFAULT_FONT_COLOR);
+               strMessage.setFont(FontResources.ABOUT_TEXT);
+
+               FormData labelData = new FormData();
+               labelData.left = new FormAttachment(0, 15);
+               labelData.top = new FormAttachment(0, 6);
+               labelData.height = 64;
+               labelData.width = 64;
+               icon.setLayoutData(labelData);
+
+               labelData = new FormData();
+               labelData.left = new FormAttachment(0, 95);
+               labelData.right = new FormAttachment(100, 0);
+               labelData.top = new FormAttachment(0, 15);
+               labelData.height = 40;
+               strMessage.setLayoutData(labelData);
+
+               Composite buttonComp = new Composite(shell, SWT.NONE);
+               FormLayout compLayout = new FormLayout();
+               buttonComp.setLayout(compLayout);
+               buttonComp.setBackground(ColorResources.DIALOG_BG_LOWER);
+
+               buttonComp.addPaintListener(new PaintListener() {
+
+                       @Override
+                       public void paintControl(PaintEvent e) {
+                               Composite comp = (Composite) e.widget;
+                               Rectangle rect = comp.getClientArea();
+                               e.gc.setForeground(ColorResources.DIALOG_SUNKEN_1);
+                               e.gc.drawLine(rect.x, rect.y, rect.x + rect.width, rect.y);
+                               e.gc.setForeground(ColorResources.DIALOG_SUNKEN_2);
+                               e.gc.drawLine(rect.x, rect.y + 1, rect.x + rect.width,
+                                               rect.y + 1);
+                       }
+               });
+
+               FormData compData = new FormData();
+               compData.top = new FormAttachment(base, 0);
+               compData.left = new FormAttachment(0, 0);
+               compData.right = new FormAttachment(100, 0);
+               compData.bottom = new FormAttachment(100, 0);
+               buttonComp.setLayoutData(compData);
+
+               cancelButton = new DAButton(buttonComp, SWT.NONE);
+               cancelButton.addClickListener(cancelButtonListener);
+               cancelButton.setText(AnalyzerLabels.CANCEL);
+               cancelButton.setButtonFont(FontResources.DIALOG_BUTTON_FONT);
+
+               FormData data = new FormData();
+               data.top = new FormAttachment(0, 12);
+               data.right = new FormAttachment(100, -9);
+               data.width = DesignConstants.DA_BUTTON_WIDTH;
+               data.height = DesignConstants.DA_BUTTON_HEIGHT;
+               cancelButton.setLayoutData(data);
+
+               okButton = new DAButton(buttonComp, SWT.NONE);
+               okButton.addClickListener(okButtonListener);
+               okButton.setText(AnalyzerLabels.OK);
+               okButton.setButtonFont(FontResources.DIALOG_BUTTON_FONT);
+
+               FormData okData = new FormData();
+               okData.top = new FormAttachment(0, 12);
+               okData.right = new FormAttachment(cancelButton, -5);
+               okData.width = DesignConstants.DA_BUTTON_WIDTH;
+               okData.height = DesignConstants.DA_BUTTON_HEIGHT;
+               okButton.setLayoutData(okData);
+
+               shell.open();
+
+               Display display = Display.getCurrent();
+
+               while (!shell.isDisposed()) {
+                       if (!display.readAndDispatch()) {
+                               display.sleep();
+                       }
+               }
+
+               shell.dispose();
+               return returnType;
+       }
+
+       public void setMessage(String msg) {
+               message = msg;
+       }
+
+       public void setIcon(Image img) {
+               iconImage = img;
+       }
+
+       public void setTitleText(String title) {
+               titleText = title;
+       }
+}