[Title] fix. snapshot dlg in replay editor dlg.
authorHyunjong,park <phjwithyou.park@samsung.com>
Wed, 11 Dec 2013 09:29:11 +0000 (18:29 +0900)
committerHyunjong,park <phjwithyou.park@samsung.com>
Wed, 11 Dec 2013 09:29:11 +0000 (18:29 +0900)
[Desc.] get emulaotr resolution value from emulator xml
[Issue] -

org.tizen.dynamicanalyzer/src/org/tizen/dynamicanalyzer/ui/toolbar/replayEditor/ReplayEditSnapshotDialog.java

index 08350dc..ed6f8ac 100644 (file)
 
 package org.tizen.dynamicanalyzer.ui.toolbar.replayEditor;
 
+import java.io.File;
+import java.io.IOException;
+
+import javax.xml.parsers.DocumentBuilder;
+import javax.xml.parsers.DocumentBuilderFactory;
+import javax.xml.parsers.ParserConfigurationException;
+
 import org.eclipse.nebula.widgets.grid.GridItem;
 import org.eclipse.swt.SWT;
 import org.eclipse.swt.events.MouseEvent;
@@ -40,24 +47,35 @@ import org.eclipse.swt.widgets.Composite;
 import org.eclipse.swt.widgets.Display;
 import org.eclipse.swt.widgets.Shell;
 import org.tizen.dynamicanalyzer.common.AnalyzerConstants;
+import org.tizen.dynamicanalyzer.common.AnalyzerPaths;
+import org.tizen.dynamicanalyzer.common.CommonConstants;
 import org.tizen.dynamicanalyzer.common.SnapshotConstants;
+import org.tizen.dynamicanalyzer.communicator.DACommunicator;
 import org.tizen.dynamicanalyzer.nl.ReplayEditLabels;
 import org.tizen.dynamicanalyzer.resources.ColorResources;
 import org.tizen.dynamicanalyzer.ui.widgets.DAMessageBox;
 import org.tizen.dynamicanalyzer.ui.widgets.table.DATableComposite;
 import org.tizen.dynamicanalyzer.ui.widgets.table.DefaultTableComparator;
+import org.w3c.dom.Document;
+import org.w3c.dom.Element;
+import org.w3c.dom.Node;
+import org.w3c.dom.NodeList;
+import org.xml.sax.SAXException;
 
 public class ReplayEditSnapshotDialog extends DAMessageBox {
        private DATableComposite snapShotTable = null;
 
        int[] sortTypes = { AnalyzerConstants.SORT_TYPE_GRID };
        int[] sourceColumns = { 0 };
-       private String[] columnNames = { "" };//$NON-NLS-1$
+       private String[] columnNames = { CommonConstants.EMPTY };//$NON-NLS-1$
        private int[] columnSizes = { SnapshotConstants.DEFAULT_IMAGE_WIDTH + 15 };
        private boolean[] columnVisibility = { true };
 
        protected GridItem item = null;
 
+       private String resolutionWidth = CommonConstants.EMPTY;
+       private String resolutionHeight = CommonConstants.EMPTY;
+
        public ReplayEditSnapshotDialog(Shell parent, GridItem item) {
                super(parent);
                this.item = item;
@@ -101,6 +119,9 @@ public class ReplayEditSnapshotDialog extends DAMessageBox {
                snapShotTable.getTable().setItemHeight(
                                SnapshotConstants.DEFAULT_IMAGE_HEIGHT);
                snapShotTable.updateTable();
+
+               getDeviceResolution();
+
                return true;
        }
 
@@ -131,8 +152,16 @@ public class ReplayEditSnapshotDialog extends DAMessageBox {
                        int imgClickY = DisplyPt.y - tableY - 55;
                        int drawImagWidth = SnapshotConstants.DEFAULT_IMAGE_WIDTH;
                        int drawImagHeight = SnapshotConstants.DEFAULT_IMAGE_HEIGHT - 20;
+
                        int imgWidth = 720;
                        int imgHeight = 1280;
+                       if (!resolutionWidth.equals(CommonConstants.EMPTY)) {
+                               imgWidth = Integer.parseInt(resolutionWidth);
+                       }
+
+                       if (!resolutionHeight.equals(CommonConstants.EMPTY)) {
+                               imgWidth = Integer.parseInt(resolutionHeight);
+                       }
 
                        if ((0 <= imgClickX && imgClickX <= drawImagWidth)
                                        && (0 <= imgClickY && imgClickY <= drawImagHeight)) {
@@ -160,4 +189,57 @@ public class ReplayEditSnapshotDialog extends DAMessageBox {
                return this.snapShotTable;
        }
 
+       private void getDeviceResolution() {
+               String selDeviceName = DACommunicator.getSelectedDevice().getIDevice()
+                               .getDeviceName();
+               String resolutionInfoXmlPath = AnalyzerPaths.TIZEN_SDK_DATA_PATH
+                               + File.separator + "emulator-vms" + File.separator + "vms"//$NON-NLS-1$
+                               + File.separator + selDeviceName + File.separator
+                               + "vm_config.xml";//$NON-NLS-1$
+
+               DocumentBuilder builder = null;
+               Document doc = null;
+
+               try {
+                       builder = DocumentBuilderFactory.newInstance().newDocumentBuilder();
+                       doc = builder.parse(resolutionInfoXmlPath);
+               } catch (ParserConfigurationException e) {
+                       // TODO Auto-generated catch block
+                       e.printStackTrace();
+               } catch (SAXException e) {
+                       // TODO Auto-generated catch block
+                       e.printStackTrace();
+               } catch (IOException e) {
+                       // TODO Auto-generated catch block
+                       e.printStackTrace();
+               }
+
+               if (null == doc) {
+                       return;
+               }
+
+               Element root = doc.getDocumentElement();
+
+               NodeList deviceNode = root.getElementsByTagName("device");//$NON-NLS-1$
+               Element deviceElement = (Element) deviceNode.item(0);
+
+               NodeList displayNode = deviceElement.getElementsByTagName("display");//$NON-NLS-1$
+               Element displayElement = (Element) displayNode.item(0);
+
+               NodeList resolutionNode = displayElement
+                               .getElementsByTagName("resolution");//$NON-NLS-1$
+               Element resolutionElement = (Element) resolutionNode.item(0);
+
+               NodeList widthNodeList = resolutionElement
+                               .getElementsByTagName("width");//$NON-NLS-1$
+               Element widthElement = (Element) widthNodeList.item(0);
+               Node widthNode = widthElement.getFirstChild();
+               resolutionWidth = widthNode.getNodeValue();
+               NodeList heightNodeList = resolutionElement
+                               .getElementsByTagName("height");//$NON-NLS-1$
+               Element heightElement = (Element) heightNodeList.item(0);
+               Node heightNode = heightElement.getFirstChild();
+               resolutionHeight = heightNode.getNodeValue();
+       }
+
 }
\ No newline at end of file