NSCREEN : default device changed 23/21123/1
authorjooyoul_lee <jy.exe.lee@samsung.com>
Thu, 15 May 2014 08:29:25 +0000 (17:29 +0900)
committerjooyoul_lee <jy.exe.lee@samsung.com>
Thu, 15 May 2014 08:29:25 +0000 (17:29 +0900)
profile default device added
common feature history added

Change-Id: I90db96df13bd4b5d9aa6b4f77e7bbd1cfae20657
Signed-off-by: jooyoul_lee <jy.exe.lee@samsung.com>
org.tizen.webuibuilder/src/org/tizen/webuibuilder/ui/editor/PageDesignerToolbar.java
org.tizen.webuibuilder/src/org/tizen/webuibuilder/ui/views/nscreen/NScreenItem.java
org.tizen.webuibuilder/src/org/tizen/webuibuilder/ui/views/nscreen/NScreenPage.java

index 8540bfc..2e3b465 100644 (file)
@@ -90,7 +90,8 @@ public class PageDesignerToolbar implements ISelectionListener {
     private ResolutionManger resolution;
     private ScreenSize currentScreen;
     private ScaleData scaleData;
-    private Device defaultDevice = null;
+    private Device defaultMobileDevice = null;
+    private Device defaultWearableDevice = null;
 
     private boolean isLandscape;
     private boolean isFiting;
@@ -124,8 +125,7 @@ public class PageDesignerToolbar implements ISelectionListener {
 
         isLandscape = false;
         isFiting = false;
-        nscreen = new NScreenHistory();
-        nscreen.setModelName(BuilderConstants.NSCREENCOMMON);
+
         widgetEvent();
 
         AnimatorUtils.getWorkbenchWindow().getSelectionService().addSelectionListener(this);
@@ -136,13 +136,21 @@ public class PageDesignerToolbar implements ISelectionListener {
         // ProjectManager.getProjectManager(project);
         // PageData pageData = mainEditor.getPageData();
         // pageData.addPageListener(this);
-        defaultDevice = new Device("DefaultDevice", "Default Device [360x640, 9:16, PR:2.0]");
-        defaultDevice.setOrientation(Orientation.PORTRAIT);
-        defaultDevice.setDevicePixelRatio(2.0);
-        defaultDevice.setDeviceWidth(360);
-        defaultDevice.setDeviceHeight(640);
-        defaultDevice.setWidth(720);
-        defaultDevice.setHeight(1280);
+        defaultMobileDevice = new Device("Default", "Default [360x640]");
+        defaultMobileDevice.setOrientation(Orientation.PORTRAIT);
+        defaultMobileDevice.setDevicePixelRatio(2.0);
+        defaultMobileDevice.setDeviceWidth(360);
+        defaultMobileDevice.setDeviceHeight(640);
+        defaultMobileDevice.setWidth(720);
+        defaultMobileDevice.setHeight(1280);
+
+        defaultWearableDevice = new Device("Default", "Default [320x320]");
+        defaultWearableDevice.setOrientation(Orientation.PORTRAIT);
+        defaultWearableDevice.setDevicePixelRatio(2.0);
+        defaultWearableDevice.setDeviceWidth(320);
+        defaultWearableDevice.setDeviceHeight(320);
+        defaultWearableDevice.setWidth(720);
+        defaultWearableDevice.setHeight(1280);
     }
 
     public void dispose() {
@@ -174,12 +182,36 @@ public class PageDesignerToolbar implements ISelectionListener {
         // }
 
         if (!resolution.getDeviceMode().equals(appManager.getFrameworkScale())) {
-            setResolution(DeviceManager.getDeviceManager().getDevices(), null);
+            setResolution(DeviceManager.getDeviceManager().getDevices());
             resetMenuPart();
         }
 
     }
 
+    public void setResolution(List<Device> devices) {
+        Device device = null;
+        NScreenUtil.nscreen_log(mainEditor.getAppManager().getFrameworkScale());
+        resolution
+                .setScreeSizesFromNScreen(devices, mainEditor.getAppManager().getFrameworkScale());
+        screenSize.setEnabled(resolution.getEnable());
+
+        String profile = appManager.getPlatform();
+        if (profile.contains("mobile")) {
+            device = devices.get(1);
+
+        } else if (profile.contains("wearable")) {
+            device = devices.get(0);
+        }
+        currentScreen =
+                new ScreenSize(device.getDeviceWidth(), device.getDeviceHeight(),
+                               device.getDisplayName());
+        nscreen = new NScreenHistory();
+        nscreen.setLastResolution(device.getDisplayName());
+        nscreen.setScale(1f);
+
+        screenSizeText.setText(currentScreen.getScreenSize());
+    }
+
     public void setResolution(List<Device> devices, NScreenItem nsItem) {
         if (nsItem != null) {
             nscreen = nsItem.getNScreenHistory();
@@ -187,7 +219,12 @@ public class PageDesignerToolbar implements ISelectionListener {
         Device device = null;
 
         if (devices.isEmpty()) {
-            devices.add(defaultDevice);
+            String profile = appManager.getPlatform();
+            if (profile.contains("mobile")) {
+                devices.add(defaultMobileDevice);
+            } else if (profile.contains("wearable")) {
+                devices.add(defaultWearableDevice);
+            }
         }
         NScreenUtil.nscreen_log(mainEditor.getAppManager().getFrameworkScale());
         resolution
@@ -346,7 +383,9 @@ public class PageDesignerToolbar implements ISelectionListener {
     private void resetMenuPart() {
         // isLandscape = false;
         // isFiting = true;
-        currentScreen = resolution.getScreenSize(0);
+        if (currentScreen == null) {
+            currentScreen = resolution.getScreenSize(0);
+        }
         screenSizeText.setText(currentScreen.getScreenSize());
         scaleValueText.setText("100");
     }
index f946caa..354e29c 100644 (file)
@@ -461,6 +461,10 @@ public class NScreenItem extends Composite {
     public NScreenHistory getNScreenHistory() {
         return history;
     }
+
+    public void setNScreenHistory(NScreenHistory h) {
+        history = h;
+    }
     // public float getScale() {
     // return scale;
     // }
index b841b71..47a2a89 100644 (file)
@@ -28,20 +28,12 @@ import java.util.List;
 import org.eclipse.swt.SWT;
 import org.eclipse.swt.events.ControlEvent;
 import org.eclipse.swt.events.ControlListener;
-import org.eclipse.swt.events.PaintEvent;
-import org.eclipse.swt.events.PaintListener;
-import org.eclipse.swt.graphics.Color;
-import org.eclipse.swt.graphics.Font;
-import org.eclipse.swt.graphics.Point;
 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.Control;
 import org.eclipse.ui.part.Page;
-import org.tizen.webuibuilder.animator.ui.views.timeline.common.ColorResource;
-import org.tizen.webuibuilder.model.css.CssFile;
+import org.tizen.webuibuilder.model.nscreen.Device;
+import org.tizen.webuibuilder.model.nscreen.DeviceManager;
 import org.tizen.webuibuilder.model.nscreen.NScreenModel;
 import org.tizen.webuibuilder.ui.views.nscreen.model.NScreenPageModel;
 
@@ -115,13 +107,25 @@ public class NScreenPage extends Page {
 
         for (NScreenModel model : models) {
             if (groups.size() == 0) {
+                // first group and first item = common
                 group =
-                // mParentComposite.createNewGroup(model.getType(), mNScreenPageModel
-                // .getPageData().getName());
                         mParentComposite
                                 .createNewGroup(model.getType(), model.getType().toString());
-                // group.setHeight(40);
-                group.addItem(model);
+                NScreenItem commonItem = group.addItem(model);
+                NScreenHistory commonHistory = new NScreenHistory();
+
+                List<Device> devices = DeviceManager.getDeviceManager().getDevices();
+                Device device = null;
+                String profile = mNScreenPageModel.getAppManager().getPlatform();
+                if (profile.contains("mobile")) {
+                    device = devices.get(1);
+                } else if (profile.contains("wearable")) {
+                    device = devices.get(0);
+                }
+                commonHistory.setModelName(model.getName());
+                commonHistory.setLastResolution(device.getDisplayName());
+                commonHistory.setScale(1f);
+                commonItem.setNScreenHistory(commonHistory);
             } else {
                 NScreenGroup selectedGroup = null;
                 for (NScreenGroup g : groups) {