Merge remote-tracking branch 'origin/nscreen' into develop 69/20769/1
authoryonghwan82.jeon <yonghwan82.jeon@samsung.com>
Mon, 12 May 2014 16:02:28 +0000 (01:02 +0900)
committeryonghwan82.jeon <yonghwan82.jeon@samsung.com>
Mon, 12 May 2014 16:02:28 +0000 (01:02 +0900)
* origin/nscreen: (23 commits)
  Merge remote-tracking branch 'origin/develop' into nscreen
  NSCREEN : cssfile loader added cssfile loading added
  NSCREEN : remove unused code. remove unused code.
  NSCREEN : Old nscreen source delete NScreenList, NScreenListItem class delete
  NSCREEN : NScreen view implement update NScreen view contents changed NScreen view action changed Nscreen icons added
  NSCREEN : Modify meta reader&writer. Modify meta reader and writer for Nscreen view menu info.
  NSCREEN: Make nscreenModelManager. Make nscreenModelManger.
  NSCREEN : add getNscreeNModelList(device info) get NscreenModellist.
  NSCREEN : Update device Info and modify NscreenModel Update real device and Modify Nscreenmodel.
  Nscreen: Add Fields in NscreenModel. It was meaning that allowed menu in Nscreen View.
  NSCREEN : Add device and deviceManager add Real device info and deviceManager
  NSCREEN: move  initializion of nscreenModel. If index.meta.xml file is net exist, uibuilder initialize  nscreen model. If index.meta.xml file is exist, uibuidlder read this.
  NSCREEN : Modify XSLT by new NScreenModel.
  NSCREEN : Remove unused function and Modify NscreenLisitItem. remove printNscreenModel and modify NscreenListItem.
  NSCREEN : initialize nscreenmodel. initialize nscreenmodel.
  NSCREEN : add nscreenmodel controller. when page added, nscreen item add page info. nscreen controller add nscreen item for page info.
  NScreen : add Common nscreen. addCommonNscreen() in Appmanger.
  NSCREEN : Modify nscreen model. add attribute ( link, EnabePages, devicePixelRatio ). Remove attribute (Prefix min,max attribute).
  NSCREEN : Change path for Nscreen model. Change path for Nscreen model.
  NSCREEN : Modify N-Screen model scope. page - > application.
  ...

Change-Id: Ic5ca93f769f0585532aec93565392c884ad7494f
Signed-off-by: yonghwan82.jeon <yonghwan82.jeon@samsung.com>
76 files changed:
org.tizen.webuibuilder/res/icons/common.png [new file with mode: 0644]
org.tizen.webuibuilder/res/icons/orientation-landscape.png [new file with mode: 0644]
org.tizen.webuibuilder/res/icons/orientation-portrait.png [new file with mode: 0644]
org.tizen.webuibuilder/res/icons/pixel-ratio10.png [new file with mode: 0644]
org.tizen.webuibuilder/res/icons/pixel-ratio15.png [new file with mode: 0644]
org.tizen.webuibuilder/res/icons/pixel-ratio20.png [new file with mode: 0644]
org.tizen.webuibuilder/res/icons/pixel-ratio30.png [new file with mode: 0644]
org.tizen.webuibuilder/res/icons/resoluion-1-1.png [new file with mode: 0644]
org.tizen.webuibuilder/res/icons/resoluion-10-16.png [new file with mode: 0644]
org.tizen.webuibuilder/res/icons/resoluion-16-10.png [new file with mode: 0644]
org.tizen.webuibuilder/res/icons/resoluion-16-9.png [new file with mode: 0644]
org.tizen.webuibuilder/res/icons/resoluion-2-3.png [new file with mode: 0644]
org.tizen.webuibuilder/res/icons/resoluion-3-2.png [new file with mode: 0644]
org.tizen.webuibuilder/res/icons/resoluion-3-4.png [new file with mode: 0644]
org.tizen.webuibuilder/res/icons/resoluion-3-5.png [new file with mode: 0644]
org.tizen.webuibuilder/res/icons/resoluion-4-3.png [new file with mode: 0644]
org.tizen.webuibuilder/res/icons/resoluion-4-5.png [new file with mode: 0644]
org.tizen.webuibuilder/res/icons/resoluion-5-3.png [new file with mode: 0644]
org.tizen.webuibuilder/res/icons/resoluion-5-4.png [new file with mode: 0644]
org.tizen.webuibuilder/res/icons/resoluion-9-16.png [new file with mode: 0644]
org.tizen.webuibuilder/res/xslt/page_managed_css_ver0_0_3.xslt
org.tizen.webuibuilder/src/org/tizen/webuibuilder/BuilderConstants.java
org.tizen.webuibuilder/src/org/tizen/webuibuilder/animator/ui/views/timeline/common/ColorManager.java
org.tizen.webuibuilder/src/org/tizen/webuibuilder/animator/ui/views/timeline/common/ColorResource.java
org.tizen.webuibuilder/src/org/tizen/webuibuilder/model/Part.java
org.tizen.webuibuilder/src/org/tizen/webuibuilder/model/app/AppManager.java
org.tizen.webuibuilder/src/org/tizen/webuibuilder/model/app/AppManagerForHTML.java
org.tizen.webuibuilder/src/org/tizen/webuibuilder/model/app/io/HtmlMetaReader_ver_1.java
org.tizen.webuibuilder/src/org/tizen/webuibuilder/model/app/io/HtmlMetaWriter_ver_1.java
org.tizen.webuibuilder/src/org/tizen/webuibuilder/model/css/CssFile.java
org.tizen.webuibuilder/src/org/tizen/webuibuilder/model/filedata/HtmlMetaFileData.java
org.tizen.webuibuilder/src/org/tizen/webuibuilder/model/filedata/PageFileData.java
org.tizen.webuibuilder/src/org/tizen/webuibuilder/model/io/file/PageReader_ver_2.java
org.tizen.webuibuilder/src/org/tizen/webuibuilder/model/io/file/PageWriter_ver_2.java
org.tizen.webuibuilder/src/org/tizen/webuibuilder/model/nscreen/Device.java [new file with mode: 0644]
org.tizen.webuibuilder/src/org/tizen/webuibuilder/model/nscreen/DeviceManager.java [new file with mode: 0644]
org.tizen.webuibuilder/src/org/tizen/webuibuilder/model/nscreen/NScreenModel.java [new file with mode: 0644]
org.tizen.webuibuilder/src/org/tizen/webuibuilder/model/nscreen/NScreenModelController.java [new file with mode: 0644]
org.tizen.webuibuilder/src/org/tizen/webuibuilder/model/nscreen/NScreenModelManager.java [new file with mode: 0644]
org.tizen.webuibuilder/src/org/tizen/webuibuilder/model/nscreen/descriptors/NScreenDescriptor.java [new file with mode: 0644]
org.tizen.webuibuilder/src/org/tizen/webuibuilder/model/page/PageData.java
org.tizen.webuibuilder/src/org/tizen/webuibuilder/ui/editor/PageDesigner.java
org.tizen.webuibuilder/src/org/tizen/webuibuilder/ui/editor/PageDesignerForAppXML.java
org.tizen.webuibuilder/src/org/tizen/webuibuilder/ui/editor/PageDesignerForHTML.java
org.tizen.webuibuilder/src/org/tizen/webuibuilder/ui/editor/PageDesignerToolbar.java
org.tizen.webuibuilder/src/org/tizen/webuibuilder/ui/editor/ResolutionManger.java
org.tizen.webuibuilder/src/org/tizen/webuibuilder/ui/views/nscreen/FontUtil.java [new file with mode: 0644]
org.tizen.webuibuilder/src/org/tizen/webuibuilder/ui/views/nscreen/INScreenDrawRenderer.java [new file with mode: 0644]
org.tizen.webuibuilder/src/org/tizen/webuibuilder/ui/views/nscreen/NScreenAddCommand.java [deleted file]
org.tizen.webuibuilder/src/org/tizen/webuibuilder/ui/views/nscreen/NScreenBaseComposite.java [new file with mode: 0644]
org.tizen.webuibuilder/src/org/tizen/webuibuilder/ui/views/nscreen/NScreenCustomDialog.java [deleted file]
org.tizen.webuibuilder/src/org/tizen/webuibuilder/ui/views/nscreen/NScreenDeleteCommand.java [deleted file]
org.tizen.webuibuilder/src/org/tizen/webuibuilder/ui/views/nscreen/NScreenGroup.java [new file with mode: 0644]
org.tizen.webuibuilder/src/org/tizen/webuibuilder/ui/views/nscreen/NScreenHistory.java [new file with mode: 0644]
org.tizen.webuibuilder/src/org/tizen/webuibuilder/ui/views/nscreen/NScreenItem.java [new file with mode: 0644]
org.tizen.webuibuilder/src/org/tizen/webuibuilder/ui/views/nscreen/NScreenItemFloatRenderer.java [new file with mode: 0644]
org.tizen.webuibuilder/src/org/tizen/webuibuilder/ui/views/nscreen/NScreenList.java [deleted file]
org.tizen.webuibuilder/src/org/tizen/webuibuilder/ui/views/nscreen/NScreenListItem.java [deleted file]
org.tizen.webuibuilder/src/org/tizen/webuibuilder/ui/views/nscreen/NScreenListItemImageComposite.java [deleted file]
org.tizen.webuibuilder/src/org/tizen/webuibuilder/ui/views/nscreen/NScreenPage.java
org.tizen.webuibuilder/src/org/tizen/webuibuilder/ui/views/nscreen/NScreenSimpleRenderer.java [new file with mode: 0644]
org.tizen.webuibuilder/src/org/tizen/webuibuilder/ui/views/nscreen/NScreenUtil.java [new file with mode: 0644]
org.tizen.webuibuilder/src/org/tizen/webuibuilder/ui/views/nscreen/NScreenView.java
org.tizen.webuibuilder/src/org/tizen/webuibuilder/ui/views/nscreen/command/NScreenDisableCommand.java [new file with mode: 0644]
org.tizen.webuibuilder/src/org/tizen/webuibuilder/ui/views/nscreen/command/NScreenEnableCommand.java [new file with mode: 0644]
org.tizen.webuibuilder/src/org/tizen/webuibuilder/ui/views/nscreen/command/NScreenLinkCutCommand.java [new file with mode: 0644]
org.tizen.webuibuilder/src/org/tizen/webuibuilder/ui/views/nscreen/command/NScreenLinkDownCommand.java [new file with mode: 0644]
org.tizen.webuibuilder/src/org/tizen/webuibuilder/ui/views/nscreen/command/NScreenLinkUpCommand.java [new file with mode: 0644]
org.tizen.webuibuilder/src/org/tizen/webuibuilder/ui/views/nscreen/command/NScreenMoveDownCommand.java [new file with mode: 0644]
org.tizen.webuibuilder/src/org/tizen/webuibuilder/ui/views/nscreen/command/NScreenMoveUpCommand.java [new file with mode: 0644]
org.tizen.webuibuilder/src/org/tizen/webuibuilder/ui/views/nscreen/dialog/NScreenInputWizardPage.java [new file with mode: 0644]
org.tizen.webuibuilder/src/org/tizen/webuibuilder/ui/views/nscreen/dialog/NScreenViewMessages.java [new file with mode: 0644]
org.tizen.webuibuilder/src/org/tizen/webuibuilder/ui/views/nscreen/dialog/NScreenViewMessages.properties [new file with mode: 0644]
org.tizen.webuibuilder/src/org/tizen/webuibuilder/ui/views/nscreen/dialog/NscreenInputWizard.java [new file with mode: 0644]
org.tizen.webuibuilder/src/org/tizen/webuibuilder/ui/views/nscreen/model/NScreenModel.java [deleted file]
org.tizen.webuibuilder/src/org/tizen/webuibuilder/ui/views/nscreen/model/NScreenPageModel.java

diff --git a/org.tizen.webuibuilder/res/icons/common.png b/org.tizen.webuibuilder/res/icons/common.png
new file mode 100644 (file)
index 0000000..9b94a64
Binary files /dev/null and b/org.tizen.webuibuilder/res/icons/common.png differ
diff --git a/org.tizen.webuibuilder/res/icons/orientation-landscape.png b/org.tizen.webuibuilder/res/icons/orientation-landscape.png
new file mode 100644 (file)
index 0000000..64255c1
Binary files /dev/null and b/org.tizen.webuibuilder/res/icons/orientation-landscape.png differ
diff --git a/org.tizen.webuibuilder/res/icons/orientation-portrait.png b/org.tizen.webuibuilder/res/icons/orientation-portrait.png
new file mode 100644 (file)
index 0000000..81b1a9c
Binary files /dev/null and b/org.tizen.webuibuilder/res/icons/orientation-portrait.png differ
diff --git a/org.tizen.webuibuilder/res/icons/pixel-ratio10.png b/org.tizen.webuibuilder/res/icons/pixel-ratio10.png
new file mode 100644 (file)
index 0000000..b323494
Binary files /dev/null and b/org.tizen.webuibuilder/res/icons/pixel-ratio10.png differ
diff --git a/org.tizen.webuibuilder/res/icons/pixel-ratio15.png b/org.tizen.webuibuilder/res/icons/pixel-ratio15.png
new file mode 100644 (file)
index 0000000..233e30f
Binary files /dev/null and b/org.tizen.webuibuilder/res/icons/pixel-ratio15.png differ
diff --git a/org.tizen.webuibuilder/res/icons/pixel-ratio20.png b/org.tizen.webuibuilder/res/icons/pixel-ratio20.png
new file mode 100644 (file)
index 0000000..d2955c2
Binary files /dev/null and b/org.tizen.webuibuilder/res/icons/pixel-ratio20.png differ
diff --git a/org.tizen.webuibuilder/res/icons/pixel-ratio30.png b/org.tizen.webuibuilder/res/icons/pixel-ratio30.png
new file mode 100644 (file)
index 0000000..a15e21b
Binary files /dev/null and b/org.tizen.webuibuilder/res/icons/pixel-ratio30.png differ
diff --git a/org.tizen.webuibuilder/res/icons/resoluion-1-1.png b/org.tizen.webuibuilder/res/icons/resoluion-1-1.png
new file mode 100644 (file)
index 0000000..e9e0d5c
Binary files /dev/null and b/org.tizen.webuibuilder/res/icons/resoluion-1-1.png differ
diff --git a/org.tizen.webuibuilder/res/icons/resoluion-10-16.png b/org.tizen.webuibuilder/res/icons/resoluion-10-16.png
new file mode 100644 (file)
index 0000000..f992bb8
Binary files /dev/null and b/org.tizen.webuibuilder/res/icons/resoluion-10-16.png differ
diff --git a/org.tizen.webuibuilder/res/icons/resoluion-16-10.png b/org.tizen.webuibuilder/res/icons/resoluion-16-10.png
new file mode 100644 (file)
index 0000000..7dacf7c
Binary files /dev/null and b/org.tizen.webuibuilder/res/icons/resoluion-16-10.png differ
diff --git a/org.tizen.webuibuilder/res/icons/resoluion-16-9.png b/org.tizen.webuibuilder/res/icons/resoluion-16-9.png
new file mode 100644 (file)
index 0000000..818c828
Binary files /dev/null and b/org.tizen.webuibuilder/res/icons/resoluion-16-9.png differ
diff --git a/org.tizen.webuibuilder/res/icons/resoluion-2-3.png b/org.tizen.webuibuilder/res/icons/resoluion-2-3.png
new file mode 100644 (file)
index 0000000..5d59e63
Binary files /dev/null and b/org.tizen.webuibuilder/res/icons/resoluion-2-3.png differ
diff --git a/org.tizen.webuibuilder/res/icons/resoluion-3-2.png b/org.tizen.webuibuilder/res/icons/resoluion-3-2.png
new file mode 100644 (file)
index 0000000..63b565f
Binary files /dev/null and b/org.tizen.webuibuilder/res/icons/resoluion-3-2.png differ
diff --git a/org.tizen.webuibuilder/res/icons/resoluion-3-4.png b/org.tizen.webuibuilder/res/icons/resoluion-3-4.png
new file mode 100644 (file)
index 0000000..8ffde85
Binary files /dev/null and b/org.tizen.webuibuilder/res/icons/resoluion-3-4.png differ
diff --git a/org.tizen.webuibuilder/res/icons/resoluion-3-5.png b/org.tizen.webuibuilder/res/icons/resoluion-3-5.png
new file mode 100644 (file)
index 0000000..d27bfd0
Binary files /dev/null and b/org.tizen.webuibuilder/res/icons/resoluion-3-5.png differ
diff --git a/org.tizen.webuibuilder/res/icons/resoluion-4-3.png b/org.tizen.webuibuilder/res/icons/resoluion-4-3.png
new file mode 100644 (file)
index 0000000..7109f52
Binary files /dev/null and b/org.tizen.webuibuilder/res/icons/resoluion-4-3.png differ
diff --git a/org.tizen.webuibuilder/res/icons/resoluion-4-5.png b/org.tizen.webuibuilder/res/icons/resoluion-4-5.png
new file mode 100644 (file)
index 0000000..2114d62
Binary files /dev/null and b/org.tizen.webuibuilder/res/icons/resoluion-4-5.png differ
diff --git a/org.tizen.webuibuilder/res/icons/resoluion-5-3.png b/org.tizen.webuibuilder/res/icons/resoluion-5-3.png
new file mode 100644 (file)
index 0000000..dbb0e5e
Binary files /dev/null and b/org.tizen.webuibuilder/res/icons/resoluion-5-3.png differ
diff --git a/org.tizen.webuibuilder/res/icons/resoluion-5-4.png b/org.tizen.webuibuilder/res/icons/resoluion-5-4.png
new file mode 100644 (file)
index 0000000..80fb2c1
Binary files /dev/null and b/org.tizen.webuibuilder/res/icons/resoluion-5-4.png differ
diff --git a/org.tizen.webuibuilder/res/icons/resoluion-9-16.png b/org.tizen.webuibuilder/res/icons/resoluion-9-16.png
new file mode 100644 (file)
index 0000000..c938f32
Binary files /dev/null and b/org.tizen.webuibuilder/res/icons/resoluion-9-16.png differ
index 0530185..ba9a78d 100644 (file)
 <?xml version="1.0" encoding="utf-8" ?>
-<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
-<xsl:output method="text" encoding="utf-8" indent="yes"/>
+<xsl:stylesheet version="1.0"
+       xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
+       <xsl:output method="text" encoding="utf-8" indent="yes" />
 
-<xsl:variable name="tab"><xsl:text>    </xsl:text></xsl:variable>
-<xsl:variable name="newline"><xsl:text>
-</xsl:text></xsl:variable>
+       <xsl:variable name="tab">
+               <xsl:text>    </xsl:text>
+       </xsl:variable>
+       <xsl:variable name="newline">
+               <xsl:text>
+</xsl:text>
+       </xsl:variable>
 
-<xsl:template match="/">
-    <xsl:text><![CDATA[/*******************************************************************************
+       <xsl:template match="/">
+               <xsl:text><![CDATA[/*******************************************************************************
 * This file was generated by Tizen Web UI Builder.
 * This file will be auto-generated each and everytime you save your project.
 * Do not hand edit this file.
 ********************************************************************************/
 ]]></xsl:text>
 
-<xsl:apply-templates select="/tizenFile/document/documentData/tizen.nscreen"/>
+               <xsl:apply-templates select="/tizenFile/document/documentData/tizen.nscreen" />
 
-</xsl:template>
+       </xsl:template>
 
-<xsl:template match="tizen.nscreen">
+       <xsl:template match="tizen.nscreen">
 
-    <xsl:for-each select="screen">
-               <xsl:sort select="width" order="descending" data-type="number"/>
-@import url("<xsl:value-of select="cssFileName"/>") screen and (max-width:<xsl:value-of select="width"/>px);
-    </xsl:for-each> 
+               <xsl:for-each select="screen">
+                       <!--  xsl:sort select="width" order="descending" data-type="number" / -->
 
+                               <xsl:variable name="nscreen-name"><xsl:value-of select="@name" /></xsl:variable>
 
-</xsl:template>
+                               <xsl:variable name='device-width'>
+                                       <xsl:choose>
+                                               <xsl:when test="string(@device-width) = '' or string(@device-width) = '0'"></xsl:when>
+                                               <xsl:otherwise> and (device-width:<xsl:value-of select="@device-width" />px)</xsl:otherwise>
+                                       </xsl:choose>
+                               </xsl:variable>
+                               
+                               <xsl:variable name='device-height'>
+                                       <xsl:choose>
+                                               <xsl:when test='string(@device-height) = "" or string(@device-height) = "0"'></xsl:when>
+                                               <xsl:otherwise> and (device-height:<xsl:value-of select="@device-height" />px)</xsl:otherwise>
+                                       </xsl:choose>
+                               </xsl:variable>
 
-</xsl:stylesheet>
+                               <xsl:variable name='color'>
+                                       <xsl:choose>
+                                               <xsl:when test='string(@color) = ""'></xsl:when>
+                                               <xsl:otherwise> and (color:<xsl:value-of select="@color" />)</xsl:otherwise>
+                                       </xsl:choose>
+                               </xsl:variable>
+
+                               <xsl:variable name='color-index'>
+                                       <xsl:choose>
+                                               <xsl:when test='string(@color-index) = ""'></xsl:when>
+                                               <xsl:otherwise> and (color-index:<xsl:value-of select="@color-index" />)</xsl:otherwise>
+                                       </xsl:choose>
+                               </xsl:variable>
+                               
+                               <xsl:variable name='orientation'>
+                                       <xsl:choose>
+                                               <xsl:when test='string(@orientation) = ""'></xsl:when>
+                                               <xsl:otherwise> and (orientation:<xsl:value-of select="@orientation" />)</xsl:otherwise>
+                                       </xsl:choose>
+                               </xsl:variable>
+                               
+                               <xsl:variable name='monochrome'>
+                                       <xsl:choose>
+                                               <xsl:when test='string(@monochrome) = ""'></xsl:when>
+                                               <xsl:otherwise> and (monochrome:<xsl:value-of select="@monochrome" />)</xsl:otherwise>
+                                       </xsl:choose>
+                               </xsl:variable>
+                               
+                               <xsl:variable name='resolution'>
+                                       <xsl:choose>
+                                               <xsl:when test='string(@resolution) = ""'></xsl:when>
+                                               <xsl:otherwise> and (resolution:<xsl:value-of select="@resolution" />)</xsl:otherwise>
+                                       </xsl:choose>
+                               </xsl:variable>
+                               
+                               <xsl:variable name='scan'>
+                                       <xsl:choose>
+                                               <xsl:when test='string(@scan) = ""'></xsl:when>
+                                               <xsl:otherwise> and (scan:<xsl:value-of select="@scan" />)</xsl:otherwise>
+                                       </xsl:choose>
+                               </xsl:variable>
+
+                               <xsl:variable name='grid'>
+                                       <xsl:choose>
+                                               <xsl:when test='string(@grid) = "true"'> and (grid)</xsl:when>
+                                               <xsl:otherwise></xsl:otherwise>
+                                       </xsl:choose>
+                               </xsl:variable>
+                               
+                               <xsl:variable name='devicePixelRatio'>
+                                       <xsl:choose>
+                                               <xsl:when test='string(@devicePixelRatio) = ""'></xsl:when>
+                                               <xsl:otherwise> and (-webkit-min-device-pixel-ratio:<xsl:value-of select="@devicePixelRatio" />)</xsl:otherwise>
+                                       </xsl:choose>
+                               </xsl:variable>
+                               
+                               <xsl:for-each select="enablePage">
+                                       <xsl:choose>
+                                               <xsl:when test='string(@enable) = "true"'>
+<xsl:value-of select="$newline"/>/* nscreen Name : <xsl:value-of select="$nscreen-name"/>, page name : <xsl:value-of select="@name"/> */
+@import url (" <xsl:value-of select="@name"/>_<xsl:copy-of select="$nscreen-name" />.css") screen<xsl:copy-of select="$device-width" /><xsl:copy-of select="$device-height" /><xsl:copy-of select="$color" /><xsl:copy-of select="$color-index" /><xsl:copy-of select="$orientation" /><xsl:copy-of select="$monochrome" /><xsl:copy-of select="$resolution" /><xsl:copy-of select="$scan" /><xsl:copy-of select="$grid" /><xsl:copy-of select="$devicePixelRatio" />;<xsl:value-of select="$newline"/>
+                                               </xsl:when>
+                                               <xsl:otherwise></xsl:otherwise>
+                                       </xsl:choose>
+                               </xsl:for-each>
+               </xsl:for-each>
+       </xsl:template>
+</xsl:stylesheet>
\ No newline at end of file
index 4563853..8f222f4 100644 (file)
@@ -297,4 +297,9 @@ public class BuilderConstants {
        public static final int CSS_FILE = 1 << 3;
        public static final int MANAGED_CSS_FILE = 1 << 4;
 
+       // Nscreen
+       public static final String NSCREENCOMMON = "Common"; //$NON-NLS-1$
+       public static final String NSCREENPORTRAIT = "Portrait"; //$NON-NLS-1$
+       public static final String NSCREENLANDSCAPE = "Landscape"; //$NON-NLS-1$
+
 }
index 3d0f036..5997006 100644 (file)
@@ -212,7 +212,44 @@ public class ColorManager {
 
         // keyframeWidgetText
         setColor("keyframeWidgetText", new RGB(157, 157, 157));
-
+        
+        
+        setColor("GRAY", new RGB(177, 177, 177)); //$NON-NLS-1$
+        setColor("ITEM_SELECTED", new RGB(52, 188, 254));//$NON-NLS-1$
+        setColor("ITEM_SELECTED_FONT", new RGB(1, 132, 195));//$NON-NLS-1$
+        setColor("ITEM_HOVER", new RGB(213, 231, 243));//$NON-NLS-1$
+        
+        // for NScreenItem
+        setColor("NSE_BG", new RGB(52, 188, 254)); //$NON-NLS-1$
+        setColor("NSD_BG", new RGB(160, 160, 190));//$NON-NLS-1$
+        setColor("NNE_BG", new RGB(242, 241, 240));//$NON-NLS-1$
+        setColor("NND_BG", new RGB(204, 201, 198));//$NON-NLS-1$
+        
+        setColor("HSE_BG", new RGB(126, 213, 254)); //$NON-NLS-1$
+        setColor("HSD_BG", new RGB(197, 197, 216));//$NON-NLS-1$
+        setColor("HNE_BG", new RGB(210, 240, 255));//$NON-NLS-1$
+        setColor("HND_BG", new RGB(232, 231, 230));//$NON-NLS-1$
+        
+        setColor("PSE_BG", new RGB(1, 112, 165)); //$NON-NLS-1$
+        setColor("PSD_BG", new RGB(155, 151, 155));//$NON-NLS-1$
+        setColor("PNE_BG", new RGB(1, 112, 165));//$NON-NLS-1$
+        setColor("PND_BG", new RGB(192, 188, 184));//$NON-NLS-1$
+        
+        
+        setColor("NSE_FG", new RGB(14, 13, 12)); //$NON-NLS-1$
+        setColor("NSD_FG", new RGB(112, 101, 106));//$NON-NLS-1$
+        setColor("NNE_FG", new RGB(14, 13, 12));//$NON-NLS-1$
+        setColor("NND_FG", new RGB(112, 101, 106));//$NON-NLS-1$
+        
+        setColor("HSE_FG", new RGB(14, 13, 12)); //$NON-NLS-1$
+        setColor("HSD_FG", new RGB(112, 101, 106));//$NON-NLS-1$
+        setColor("HNE_FG", new RGB(14, 13, 12));//$NON-NLS-1$
+        setColor("HND_FG", new RGB(112, 101, 106));//$NON-NLS-1$
+        
+        setColor("PSE_FG", new RGB(14, 13, 12)); //$NON-NLS-1$
+        setColor("PSD_FG", new RGB(14, 13, 12));//$NON-NLS-1$
+        setColor("PNE_FG", new RGB(14, 13, 12));//$NON-NLS-1$
+        setColor("PND_FG", new RGB(112, 101, 106));//$NON-NLS-1$
     }
 
     /**
index e606360..917a8c9 100644 (file)
@@ -172,6 +172,41 @@ public class ColorResource {
 
     public static final Color TIMEBAR_TEXT_TIME = getColor("timeBarTime");
 
+    public static final Color GRAY = getColor("GRAY");
+    public static final Color ITEM_SELECTED = getColor("ITEM_SELECTED");
+    public static final Color ITEM_SELECTED_FONT = getColor("ITEM_SELECTED_FONT");
+    public static final Color ITEM_HOVER = getColor("ITEM_HOVER");
+    
+    public static final Color NSE_BG = getColor("NSE_BG");
+    public static final Color NSD_BG = getColor("NSD_BG");
+    public static final Color NNE_BG = getColor("NNE_BG");
+    public static final Color NND_BG = getColor("NND_BG");
+    
+    public static final Color HSE_BG = getColor("HSE_BG");
+    public static final Color HSD_BG = getColor("HSD_BG");
+    public static final Color HNE_BG = getColor("HNE_BG");
+    public static final Color HND_BG = getColor("HND_BG");
+    
+    public static final Color PSE_BG = getColor("PSE_BG");
+    public static final Color PSD_BG = getColor("PSD_BG");
+    public static final Color PNE_BG = getColor("PNE_BG");
+    public static final Color PND_BG = getColor("PND_BG");
+    
+    public static final Color NSE_FG = getColor("NSE_FG");
+    public static final Color NSD_FG = getColor("NSD_FG");
+    public static final Color NNE_FG = getColor("NNE_FG");
+    public static final Color NND_FG = getColor("NND_FG");
+    
+    public static final Color HSE_FG = getColor("HSE_FG");
+    public static final Color HSD_FG = getColor("HSD_FG");
+    public static final Color HNE_FG = getColor("HNE_FG");
+    public static final Color HND_FG = getColor("HND_FG");
+    
+    public static final Color PSE_FG = getColor("PSE_FG");
+    public static final Color PSD_FG = getColor("PSD_FG");
+    public static final Color PNE_FG = getColor("PNE_FG");
+    public static final Color PND_FG = getColor("PND_FG");
+
     /**
      * Get Color
      * 
index bd90334..a7ade32 100644 (file)
@@ -1533,6 +1533,18 @@ public class Part implements ISerializer {
         }
     }
 
+    public void clearAllSelector() {
+        if (selectors.size() > 0) {
+            selectors.clear();
+        }
+        if (getChildren().size() > 0) {
+            for (Part child : getChildren()) {
+                child.clearAllSelector();
+            }
+        }
+
+    }
+
     /**
      * Removes a css selector.
      * 
index 6557eec..64dc178 100644 (file)
@@ -46,6 +46,8 @@ import org.tizen.webuibuilder.model.css.CssFile;
 import org.tizen.webuibuilder.model.css.io.CssReader;
 import org.tizen.webuibuilder.model.descriptors.DescriptorManager;
 import org.tizen.webuibuilder.model.filedata.AppFileData;
+import org.tizen.webuibuilder.model.nscreen.NScreenModelManager;
+import org.tizen.webuibuilder.model.nscreen.descriptors.NScreenDescriptor;
 import org.tizen.webuibuilder.model.page.IPageDataSetListener;
 import org.tizen.webuibuilder.model.page.PageData;
 import org.tizen.webuibuilder.model.page.PageDataSet;
@@ -83,6 +85,9 @@ public class AppManager implements IPageDataSetListener, IAppListener {
 
     private String rootFullPath;
 
+    private NScreenModelManager nscreenModelManger;
+    private NScreenDescriptor nscreenDescriptor;
+
     /**
      * Constructor.
      * 
@@ -94,6 +99,8 @@ public class AppManager implements IPageDataSetListener, IAppListener {
         this.projectManager = projectManager;
         this.descriptorManager = descriptorManager;
         partFactory = new PartFactory(descriptorManager);
+        nscreenModelManger = new NScreenModelManager();
+        nscreenDescriptor = new NScreenDescriptor(this);
 
         pageDataSet = new PageDataSet();
         pageDataSet.addPageListener(this);
@@ -719,44 +726,43 @@ public class AppManager implements IPageDataSetListener, IAppListener {
     public List<String> getSelectionPath() {
         return bindingDataSet.getSelectionPath();
     }
-    
+
     public BindingDataSet getBindingDataSet() {
         return bindingDataSet;
     }
-    
+
     public BindingData getViewModel(String name) {
-       return bindingDataSet.getViewModel(name);
+        return bindingDataSet.getViewModel(name);
+    }
+
+    public BindingObject getViewModelObject(BindingData bindingData, List<String> itemPath) {
+        return bindingDataSet.getViewModelObject(bindingData, itemPath);
     }
-    
-    public BindingObject getViewModelObject(BindingData bindingData,
-                       List<String> itemPath) {
-               return bindingDataSet.getViewModelObject(bindingData, itemPath);
-       }
 
     public void addViewModel(BindingData bindingData) {
         bindingDataSet.addViewModel(bindingData);
     }
-    
-    public void changeViewModel(BindingDataSetEventType type, BindingData bindingData, List<String> itemPath, String childName, String value) {
+
+    public void changeViewModel(BindingDataSetEventType type, BindingData bindingData,
+                                List<String> itemPath, String childName, String value) {
         bindingDataSet.changeViewModel(type, bindingData, itemPath, childName, value);
     }
-    
-    public void changeViewModel(BindingDataSetEventType type, BindingData bindingData, List<String> itemPath,
-                       BindingObject viewModelObject, String value) {
-       bindingDataSet.changeViewModel(type, bindingData, itemPath, viewModelObject, value);
-       }
-    
-    public void changeViewModel(BindingDataSetEventType type,
-                       BindingData bindingData, BindingData oldBindingData) {
-       bindingDataSet.changeViewModel(type, bindingData, oldBindingData);
-       }
-    
-    public void renameViewModel(BindingDataSetEventType type,
-                       BindingData bindingData, String newName, List<String> itemPath) {
+
+    public void changeViewModel(BindingDataSetEventType type, BindingData bindingData,
+                                List<String> itemPath, BindingObject viewModelObject, String value) {
+        bindingDataSet.changeViewModel(type, bindingData, itemPath, viewModelObject, value);
+    }
+
+    public void changeViewModel(BindingDataSetEventType type, BindingData bindingData,
+                                BindingData oldBindingData) {
+        bindingDataSet.changeViewModel(type, bindingData, oldBindingData);
+    }
+
+    public void renameViewModel(BindingDataSetEventType type, BindingData bindingData,
+                                String newName, List<String> itemPath) {
         bindingDataSet.renameViewModel(type, bindingData, newName, itemPath);
     }
 
-    
     public void removeViewModel(BindingData bindingData) {
         bindingDataSet.removeViewModel(bindingData);
     }
@@ -772,22 +778,22 @@ public class AppManager implements IPageDataSetListener, IAppListener {
     public void addDataSource(BindingData bindingData, List<BindingData> oldModels) {
         bindingDataSet.addDataSource(bindingData, oldModels);
     }
-    
+
     public void removeDataSource(BindingData bindingData) {
         bindingDataSet.removeDataSource(bindingData);
     }
-    
-    public void renameDataSource(BindingDataSetEventType type,
-                       BindingData bindingData, String newName) {
+
+    public void renameDataSource(BindingDataSetEventType type, BindingData bindingData,
+                                 String newName) {
         bindingDataSet.renameDataSource(type, bindingData, newName);
     }
 
     public void clearDataSources() {
         bindingDataSet.clearDataSources();
     }
-    
+
     public BindingData getDataSource(String name) {
-       return bindingDataSet.getDataSource(name);
+        return bindingDataSet.getDataSource(name);
     }
 
     public List<BindingData> getDataSources() {
@@ -862,4 +868,11 @@ public class AppManager implements IPageDataSetListener, IAppListener {
         return null;
     }
 
+    public NScreenModelManager getNScreenModelManger() {
+        return this.nscreenModelManger;
+    }
+
+    public NScreenDescriptor getNScreenDescriptor() {
+        return this.nscreenDescriptor;
+    }
 }
index b8135bb..b426018 100644 (file)
@@ -53,12 +53,12 @@ import org.tizen.webuibuilder.model.filedata.PageFileData;
 import org.tizen.webuibuilder.model.html.io.HtmlReader;
 import org.tizen.webuibuilder.model.html.io.HtmlWriter;
 import org.tizen.webuibuilder.model.io.CodeGenerator;
+import org.tizen.webuibuilder.model.nscreen.NScreenModel;
 import org.tizen.webuibuilder.model.page.PageData;
 import org.tizen.webuibuilder.model.page.PageDataForHTML;
 import org.tizen.webuibuilder.model.page.PageDataPaths;
 import org.tizen.webuibuilder.model.project.ProjectManager;
 import org.tizen.webuibuilder.ui.views.databinding.model.BindingData;
-import org.tizen.webuibuilder.ui.views.nscreen.model.NScreenModel;
 import org.w3c.dom.Document;
 import org.w3c.dom.Element;
 import org.w3c.dom.Node;
@@ -210,20 +210,24 @@ public class AppManagerForHTML extends AppManager {
 
                 List<NScreenModel> nscreenModel = fileData.getNscreenModelList();
                 List<CssFile> cssFiles = new ArrayList<CssFile>(nscreenModel.size());
-
+                
                 String projectFolder = projectManager.getProject().getLocation().toString();
                 for (NScreenModel model : nscreenModel) {
-                    String cssFileFullPath = projectFolder + IPath.SEPARATOR + model.getFileName();
-
-                    CssFile cssFile = loadCssFile(cssFileFullPath);
-                    cssFile.setNScreenModel(model);
-                    cssFiles.add(cssFile);
+                    getNScreenModelManger().addNScreenModel(model);
+//                    for ( String page : model.getEnalbePages() ) {
+//                        String cssFileFullPath = projectFolder + IPath.SEPARATOR + page + "." +model.getFileName();
+//
+//                        CssFile cssFile = loadCssFile(cssFileFullPath);
+//                        cssFiles.add(cssFile);
+//                        
+//                        addNScreenModel( model );
+//                    }
                 }
 
                 List<PageData> pages = pageDataSet.getPages();
                 for (PageData pageData : pages) {
                     pageData.setCssFiles(cssFiles);
-                }
+                } 
             }
         }
 
index 2e184f7..b83a3b3 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * UI Builder
+a * UI Builder
  *
  * Copyright (c) 2000 - 2014 Samsung Electronics Co., Ltd. All rights reserved.
  *
@@ -25,16 +25,9 @@ package org.tizen.webuibuilder.model.app.io;
 
 import java.util.ArrayList;
 import java.util.HashMap;
-import java.util.Iterator;
 import java.util.List;
 import java.util.Map;
 
-import org.w3c.dom.Attr;
-import org.w3c.dom.Document;
-import org.w3c.dom.Element;
-import org.w3c.dom.NamedNodeMap;
-import org.w3c.dom.Node;
-import org.w3c.dom.NodeList;
 import org.tizen.webuibuilder.BuilderConstants;
 import org.tizen.webuibuilder.model.Part;
 import org.tizen.webuibuilder.model.PartFactory;
@@ -42,9 +35,18 @@ import org.tizen.webuibuilder.model.app.AppManager;
 import org.tizen.webuibuilder.model.css.CssSelector;
 import org.tizen.webuibuilder.model.filedata.HtmlMetaFileData;
 import org.tizen.webuibuilder.model.io.file.TizenFileFormatter;
+import org.tizen.webuibuilder.model.nscreen.NScreenModel;
+import org.tizen.webuibuilder.model.nscreen.NScreenModel.NScreenType;
+import org.tizen.webuibuilder.model.nscreen.NScreenModel.Orientation;
+import org.tizen.webuibuilder.model.nscreen.NScreenModel.Scan;
 import org.tizen.webuibuilder.ui.views.databinding.model.BindingData;
 import org.tizen.webuibuilder.ui.views.databinding.model.BindingObject;
-import org.tizen.webuibuilder.ui.views.nscreen.model.NScreenModel;
+import org.w3c.dom.Attr;
+import org.w3c.dom.Document;
+import org.w3c.dom.Element;
+import org.w3c.dom.NamedNodeMap;
+import org.w3c.dom.Node;
+import org.w3c.dom.NodeList;
 
 
 public class HtmlMetaReader_ver_1 {
@@ -70,7 +72,7 @@ public class HtmlMetaReader_ver_1 {
 
         HtmlMetaFileData fileData = new HtmlMetaFileData();
 
-       NodeList elementList = root.getElementsByTagName("document");
+        NodeList elementList = root.getElementsByTagName("document");
         for (int i = 0; i < elementList.getLength(); i++) {
             parsePart(fileData, (Element) elementList.item(i), partFactory);
         }
@@ -79,18 +81,18 @@ public class HtmlMetaReader_ver_1 {
     }
 
     private static void parsePart(HtmlMetaFileData fileData, Element elem, PartFactory partFactory) {
-       NodeList elementList = elem.getElementsByTagName("documentInfo");
+        NodeList elementList = elem.getElementsByTagName("documentInfo");
         for (int i = 0; i < elementList.getLength(); i++) {
             parsePageInfo(fileData, (Element) elementList.item(i));
         }
-       elementList = elem.getElementsByTagName("documentData");
+        elementList = elem.getElementsByTagName("documentData");
         for (int i = 0; i < elementList.getLength(); i++) {
             parsePageData(fileData, (Element) elementList.item(i), partFactory);
         }
     }
 
     private static void parsePageInfo(HtmlMetaFileData fileData, Element elem) {
-       NodeList elementList = elem.getElementsByTagName("documentInfo");
+        NodeList elementList = elem.getElementsByTagName("documentInfo");
         for (int i = 0; i < elementList.getLength(); i++) {
             parsePageInfo(fileData, (Element) elementList.item(i));
         }
@@ -98,31 +100,138 @@ public class HtmlMetaReader_ver_1 {
 
     private static void parsePageData(HtmlMetaFileData fileData, Element elem,
                                       PartFactory partFactory) {
-       NodeList elementList = elem.getElementsByTagName("tizen.nscreen");
+        NodeList elementList = elem.getElementsByTagName("tizen.nscreen");
         for (int i = 0; i < elementList.getLength(); i++) {
-            Element nscreen = (Element) elementList.item(i);
-               NodeList elementList2 = nscreen.getElementsByTagName("screen");
-            for (int j = 0; j < elementList2.getLength(); j++) {
-                Element screen = (Element) elementList2.item(j);
-                NScreenModel model = new NScreenModel();
+            parseNScreen(fileData, (Element) elementList.item(i));
+        }
+
+        elementList = elem.getElementsByTagName("pageData");
+        for (int i = 0; i < elementList.getLength(); i++) {
+            parsePagePart(fileData, (Element) elementList.item(i), partFactory);
+        }
+
+        elementList = elem.getElementsByTagName(BuilderConstants.ELEMENT_DATABINDING);
+        for (int i = 0; i < elementList.getLength(); i++) {
+            parseDataBinding(fileData, (Element) elementList.item(i));
+        }
+    }
+
+    private static void parseNScreen(HtmlMetaFileData fileData, Element nscreen) {
+        NodeList elementList2 = nscreen.getElementsByTagName("screen");
+        for (int j = 0; j < elementList2.getLength(); j++) {
+            Element screen = (Element) elementList2.item(j);
+
+            NScreenModel model = null;
+            NScreenType type = null;
+            String name = screen.getAttribute("name");
+            String stringType = screen.getAttribute("type");
+
+            if (name.isEmpty()) {
+                return;
+            }
+
+            if (stringType.isEmpty()) {
+                return;
+            }
+
+            if (stringType.equalsIgnoreCase(NScreenType.COMMON.toString())) {
+                type = NScreenType.COMMON;
+            } else if (stringType.equalsIgnoreCase(NScreenType.ORIENTATION.toString())) {
+                type = NScreenType.ORIENTATION;
+            } else if (stringType.equalsIgnoreCase(NScreenType.PIXELRATIO.toString())) {
+                type = NScreenType.PIXELRATIO;
+            } else if (stringType.equalsIgnoreCase(NScreenType.RESOLUTION.toString())) {
+                type = NScreenType.RESOLUTION;
+            } else {
+                type = NScreenType.CUSTOM;
+            }
+
+            model = new NScreenModel(name, type);
+
+            if (screen.getAttribute("device-width").length() > 0) {
+                model.setDeviceWidth(Integer.parseInt(screen.getAttribute("device-width")));
+            }
+
+            if (screen.getAttribute("device-height").length() > 0) {
+                model.setDeviceHeight(Integer.parseInt(screen.getAttribute("device-height")));
+            }
+
+            if (screen.getAttribute("device-pixel-ratio").length() > 0) {
+                model.setDevicePixelRatio(Double.parseDouble(screen
+                        .getAttribute("device-pixel-ratio")));
+            }
 
-                model.setTitle(screen.getAttribute("title"));
-                model.setWidth(Integer.parseInt(screen.getAttribute("width")));
-                model.setHeight(Integer.parseInt(screen.getAttribute("height")));
+            if (screen.getAttribute("color").length() > 0)
+                model.setColor(Integer.parseInt(screen.getAttribute("color")));
+
+            if (screen.getAttribute("color-index").length() > 0)
+                model.setColor(Integer.parseInt(screen.getAttribute("color-index")));
+
+            if (screen.getAttribute("grid").length() > 0
+                    && screen.getAttribute("grid").equals("true"))
+                model.setGrid(true);
+
+            if (screen.getAttribute("monochrome").length() > 0)
+                model.setMonochrome(Integer.parseInt(screen.getAttribute("monochrome")));
+
+            if (screen.getAttribute("orientation").length() > 0) {
+                if (Orientation.LANDSCAPE.toString().toLowerCase()
+                        .equals(screen.getAttribute("orientation")))
+                    model.setOrientation(Orientation.LANDSCAPE);
+                else
+                    model.setOrientation(Orientation.PORTRAIT);
+            }
+
+            if (screen.getAttribute("resolution").length() > 0)
+                model.setResolution(screen.getAttribute("resolution"));
+
+            if (screen.getAttribute("scan").length() > 0) {
+                if (Scan.PROGRESSIVE.toString().toLowerCase().equals(screen.getAttribute("scan")))
+                    model.setScan(Scan.PROGRESSIVE);
+                else
+                    model.setScan(Scan.INTERLACE);
+            }
+
+            // cssfile
+            if (screen.getAttribute("cssFileName").length() > 0) {
                 model.setFileName(screen.getAttribute("cssFileName"));
+            }
 
-                fileData.getNscreenModelList().add(model);
+            // menu
+            if (screen.getAttribute("defaultInMenu").length() > 0) {
+                model.setDefaultInMenu(Boolean.parseBoolean(screen.getAttribute("defaultInMenu")));
+            }
+            if (screen.getAttribute("enableInMenu").length() > 0) {
+                model.setEnableInMenu(Boolean.parseBoolean(screen.getAttribute("enableInMenu")));
+            }
+            if (screen.getAttribute("linkInMenu").length() > 0) {
+                model.setLinkInMenu(Boolean.parseBoolean(screen.getAttribute("linkInMenu")));
+            }
+            if (screen.getAttribute("moveInMenu").length() > 0) {
+                model.setMoveInMenu(Boolean.parseBoolean(screen.getAttribute("moveInMenu")));
             }
-        }
 
-       elementList = elem.getElementsByTagName("pageData");
-       for (int i = 0; i < elementList.getLength(); i++) {
-            parsePagePart(fileData, (Element) elementList.item(i), partFactory);
-        }
+            NodeList nodeList = screen.getElementsByTagName("enablePage");
+
+            for (int i = 0; i < nodeList.getLength(); i++) {
+                Element enablePageNode = (Element) nodeList.item(i);
+                String pagename = enablePageNode.getAttribute("name");
+                String pageEnabled = enablePageNode.getAttribute("enable");
+                if (Boolean.parseBoolean(pageEnabled)) {
+                    model.addEnablePage(pagename);
+                } else {
+                    model.addDisablePage(pagename);
+                }
+            }
+
+            //TODO nscreen : link.
+//            if (screen.getAttribute("link").length() > 0
+//                    && Boolean.parseBoolean(screen.getAttribute("link")))
+//                model.setLink(screen.getAttribute("cssFileName"));
+//            else
+//                model.setFileName(screen.getAttribute("cssFileName"));
 
-       elementList = elem.getElementsByTagName(BuilderConstants.ELEMENT_DATABINDING);
-       for (int i = 0; i < elementList.getLength(); i++) {
-               parseDataBinding(fileData, (Element) elementList.item(i));
+            fileData.getNscreenModelList().add(model);
         }
     }
 
@@ -134,7 +243,8 @@ public class HtmlMetaReader_ver_1 {
     }
 
     private static void parseUpdateStartUp(HtmlMetaFileData fileData, Element element) {
-       NodeList elementList = element.getElementsByTagName(BuilderConstants.ELEMENT_UPDATEONSTARTUP);
+        NodeList elementList =
+                element.getElementsByTagName(BuilderConstants.ELEMENT_UPDATEONSTARTUP);
         for (int i = 0; i < elementList.getLength(); i++) {
             Element element2 = (Element) elementList.item(i);
 
@@ -154,18 +264,19 @@ public class HtmlMetaReader_ver_1 {
     }
 
     private static void parseHandlerInfo(HtmlMetaFileData fileData, Element element) {
-       NodeList elementList = element.getElementsByTagName(BuilderConstants.ELEMENT_HANDLERINFO);
+        NodeList elementList = element.getElementsByTagName(BuilderConstants.ELEMENT_HANDLERINFO);
         for (int i = 0; i < elementList.getLength(); i++) {
-            Element element2 = (Element)elementList.item(i);
+            Element element2 = (Element) elementList.item(i);
 
             String name = element2.getAttribute(BuilderConstants.ATTRIBUTE_NAME);
 
             BindingData dataModel = new BindingData(name);
             List<String> modelInfo = new ArrayList<String>();
 
-               NodeList elementList2 = element.getElementsByTagName(BuilderConstants.ELEMENT_HANDLERINFO);
+            NodeList elementList2 =
+                    element.getElementsByTagName(BuilderConstants.ELEMENT_HANDLERINFO);
             for (int j = 0; j < elementList2.getLength(); j++) {
-                Element element3 = (Element)elementList2.item(j);
+                Element element3 = (Element) elementList2.item(j);
                 String childName = element3.getAttribute(BuilderConstants.ATTRIBUTE_NAME);
                 modelInfo.add(childName);
             }
@@ -176,14 +287,15 @@ public class HtmlMetaReader_ver_1 {
     }
 
     private static void parseDataSource(HtmlMetaFileData fileData, Element element) {
-       NodeList elementList = element.getElementsByTagName(BuilderConstants.ELEMENT_DATASOURCE);
+        NodeList elementList = element.getElementsByTagName(BuilderConstants.ELEMENT_DATASOURCE);
         for (int i = 0; i < elementList.getLength(); i++) {
-            Element element2 = (Element)elementList.item(i);
+            Element element2 = (Element) elementList.item(i);
 
             String sourceName = element2.getAttribute(BuilderConstants.ATTRIBUTE_DATASOURCE);
             String modelType = element2.getAttribute(BuilderConstants.ATTRIBUTE_MODELTYPE);
 
-            if ((modelType != null) && (modelType.equals(BuilderConstants.DATABINDING_TYPE_REMOTECALL))) {
+            if ((modelType != null)
+                    && (modelType.equals(BuilderConstants.DATABINDING_TYPE_REMOTECALL))) {
                 String url = element2.getAttribute(BuilderConstants.ATTRIBUTE_URL);
                 String type = element2.getAttribute(BuilderConstants.ATTRIBUTE_TYPE);
                 String proxy = element2.getAttribute(BuilderConstants.ATTRIBUTE_PROXY);
@@ -201,7 +313,8 @@ public class HtmlMetaReader_ver_1 {
                 parseObservableObject(element2, dataModel);
 
                 fileData.addDataSource(dataModel);
-            } else if ((modelType != null) && (modelType.equals(BuilderConstants.DATABINDING_TYPE_STATIC))) {
+            } else if ((modelType != null)
+                    && (modelType.equals(BuilderConstants.DATABINDING_TYPE_STATIC))) {
                 String jsonData = element2.getAttribute(BuilderConstants.ATTRIBUTE_JSONDATA);
                 String filePath = element2.getAttribute(BuilderConstants.ATTRIBUTE_FILEPATH);
 
@@ -290,11 +403,11 @@ public class HtmlMetaReader_ver_1 {
     }
 
     private static void parseObservableObject(Element element, BindingData dataModel) {
-       NodeList elementList = element.getChildNodes();
+        NodeList elementList = element.getChildNodes();
         for (int i = 0; i < elementList.getLength(); i++) {
             Node element3 = (Node) elementList.item(i);
             if (element3.getNodeName().equals(BuilderConstants.ELEMENT_OBSERVABLEOBJECT)) {
-               Element element2 = (Element) element3;
+                Element element2 = (Element) element3;
                 String name = element2.getAttribute(BuilderConstants.ATTRIBUTE_NAME);
                 String type = element2.getAttribute(BuilderConstants.ATTRIBUTE_TYPE);
                 String value = element2.getAttribute(BuilderConstants.ATTRIBUTE_VALUE);
@@ -304,47 +417,47 @@ public class HtmlMetaReader_ver_1 {
                 BindingObject dataSource = new BindingObject(name, type, value, boolMarked);
                 parseObservableObject(element2, dataSource);
                 if (dataModel.getModelType() == null) {
-                       dataModel.addViewModelObjects(dataSource);
+                    dataModel.addViewModelObjects(dataSource);
                 } else {
-                       dataModel.addDataSourceObjects(dataSource);
+                    dataModel.addDataSourceObjects(dataSource);
                 }
             }
         }
     }
-    
-    
+
     private static void parseObservableObject(Element element, BindingObject parentObject) {
-       NodeList elementList = element.getChildNodes();
-               for (int i = 0; i < elementList.getLength(); i++) {
-                       Node element3 = (Node) elementList.item(i);
+        NodeList elementList = element.getChildNodes();
+        for (int i = 0; i < elementList.getLength(); i++) {
+            Node element3 = (Node) elementList.item(i);
             if (element3.getNodeName().equals(BuilderConstants.ELEMENT_OBSERVABLEOBJECT)) {
-               Element element2 = (Element) element3;
-               String name = element2.getAttribute(BuilderConstants.ATTRIBUTE_NAME);
-                       String type = element2.getAttribute(BuilderConstants.ATTRIBUTE_TYPE);
-                       String value = element2.getAttribute(BuilderConstants.ATTRIBUTE_VALUE);
-                       String isMarked = element2.getAttribute(BuilderConstants.ATTRIBUTE_ISMARKED);
-                       boolean boolMarked = Boolean.valueOf(isMarked).booleanValue();
-                       
-                       BindingObject bindingObject = new BindingObject(name, type, value, boolMarked);
-                       if (element2.getElementsByTagName(BuilderConstants.ELEMENT_OBSERVABLEOBJECT).getLength() > 0) {
-                               parseObservableObject(element2, bindingObject);
-                       }  
-                       parentObject.add(bindingObject);
+                Element element2 = (Element) element3;
+                String name = element2.getAttribute(BuilderConstants.ATTRIBUTE_NAME);
+                String type = element2.getAttribute(BuilderConstants.ATTRIBUTE_TYPE);
+                String value = element2.getAttribute(BuilderConstants.ATTRIBUTE_VALUE);
+                String isMarked = element2.getAttribute(BuilderConstants.ATTRIBUTE_ISMARKED);
+                boolean boolMarked = Boolean.valueOf(isMarked).booleanValue();
+
+                BindingObject bindingObject = new BindingObject(name, type, value, boolMarked);
+                if (element2.getElementsByTagName(BuilderConstants.ELEMENT_OBSERVABLEOBJECT)
+                        .getLength() > 0) {
+                    parseObservableObject(element2, bindingObject);
+                }
+                parentObject.add(bindingObject);
             }
-               }
+        }
     }
-    
+
     private static void parsePagePart(HtmlMetaFileData fileData, Element elem,
                                       PartFactory partFactory) {
         List<CssSelector> selectors = null;
 
-       NodeList elementList = elem.getElementsByTagName("tizen.css");
+        NodeList elementList = elem.getElementsByTagName("tizen.css");
         for (int i = 0; i < elementList.getLength(); i++) {
             Element elem2 = (Element) elementList.item(i);
             selectors = parseStyle(elem2);
         }
 
-       elementList = elem.getElementsByTagName("tizen.doc");
+        elementList = elem.getElementsByTagName("tizen.doc");
         for (int i = 0; i < elementList.getLength(); i++) {
             Element elem2 = (Element) elementList.item(i);
             Part part = parseElement(fileData, elem2, partFactory, selectors);
@@ -359,17 +472,17 @@ public class HtmlMetaReader_ver_1 {
         List<CssSelector> selectors = new ArrayList<CssSelector>();
 
         // Sets selectors.
-       NodeList elementList = elem.getElementsByTagName("tizen.selector");
+        NodeList elementList = elem.getElementsByTagName("tizen.selector");
         for (int i = 0; i < elementList.getLength(); i++) {
             Element element = (Element) elementList.item(i);
-            
+
             String selectorName = element.getAttribute(BuilderConstants.ATTRIBUTE_NAME);
             String partId = element.getAttribute(BuilderConstants.ATTRIBUTE_PARTID);
             CssSelector selector = new CssSelector(selectorName, "", partId);
             selectors.add(selector);
 
             // Sets styles.
-               elementList = elem.getElementsByTagName("tizen.style");
+            elementList = elem.getElementsByTagName("tizen.style");
             for (int j = 0; j < elementList.getLength(); j++) {
                 Element element2 = (Element) elementList.item(j);
 
@@ -391,12 +504,12 @@ public class HtmlMetaReader_ver_1 {
         if (part == null) {
         } else {
             if (part.isPagePart()) {
-                //fileData.setName(0, elem.getAttribute(BuilderConstants.PROPERTY_ID));
-               id = elem.getAttribute(BuilderConstants.PROPERTY_ID);
+                // fileData.setName(0, elem.getAttribute(BuilderConstants.PROPERTY_ID));
+                id = elem.getAttribute(BuilderConstants.PROPERTY_ID);
             }
 
             // Sets events and properties.
-               NamedNodeMap attrList = elem.getAttributes();
+            NamedNodeMap attrList = elem.getAttributes();
             for (int i = 0; i < attrList.getLength(); i++) {
                 Attr attr = (Attr) attrList.item(i);
                 // if (BuilderConstants.ATTRIBUTE_EVENT_PREFIX.equals((attr
@@ -457,8 +570,7 @@ public class HtmlMetaReader_ver_1 {
                }
             }
         }
-
         return part;
     }
-    
+
 }
index 628b123..3b32c14 100644 (file)
 package org.tizen.webuibuilder.model.app.io;
 
 import java.util.ArrayList;
-import java.util.Collections;
-import java.util.Comparator;
 import java.util.List;
 import java.util.Map.Entry;
 
-import org.w3c.dom.Document;
-import org.w3c.dom.Element;
 import org.tizen.webuibuilder.BuilderConstants;
 import org.tizen.webuibuilder.model.GotoPageProperty;
 import org.tizen.webuibuilder.model.Part;
 import org.tizen.webuibuilder.model.app.AppManager;
-import org.tizen.webuibuilder.model.css.CssFile;
 import org.tizen.webuibuilder.model.css.CssSelector;
 import org.tizen.webuibuilder.model.descriptors.PartDescriptor;
 import org.tizen.webuibuilder.model.descriptors.PropertyDescriptor;
 import org.tizen.webuibuilder.model.descriptors.TypeDescriptor;
 import org.tizen.webuibuilder.model.filedata.AppFileData;
 import org.tizen.webuibuilder.model.io.file.TizenFileFormatter;
+import org.tizen.webuibuilder.model.nscreen.NScreenModel;
 import org.tizen.webuibuilder.model.page.PageData;
 import org.tizen.webuibuilder.ui.views.databinding.model.BindingData;
 import org.tizen.webuibuilder.ui.views.databinding.model.BindingObject;
+import org.w3c.dom.Document;
+import org.w3c.dom.Element;
 
 
 public class HtmlMetaWriter_ver_1 {
@@ -74,7 +72,7 @@ public class HtmlMetaWriter_ver_1 {
         Element docDataElem = doc.createElement("documentData");
 
         Element nscreenElement = doc.createElement("tizen.nscreen");
-        docDataElem.appendChild(writeNScreen(doc, nscreenElement, appManager.getPageData(0).getCssFiles()));
+        docDataElem.appendChild(writeNScreen(doc, nscreenElement, appManager));
 
         for (int i = 0; i < appManager.getNumberOfPages(); i++) {
             PageData pageData = appManager.getPageData(i);
@@ -150,35 +148,82 @@ public class HtmlMetaWriter_ver_1 {
     // return elem;
     // }
 
-    public static Element writeNScreen(Document doc, Element nscreenElement, List<CssFile> list) {
-        Collections.sort(list, new Comparator<CssFile>() {
-            @Override
-            public int compare(CssFile o1, CssFile o2) {
-                int w1 = o1.getWidth();
-                int w2 = o2.getWidth();
-                if (w1 < w2) {
-                    return -1;
-                } else if (w1 == w2) {
-                    return 0;
+    public static Element writeNScreen(Document doc, Element nscreenElement, AppManager appManager) {
+        List<NScreenModel> list = appManager.getNScreenModelManger().getNScreenModels();
+        for ( NScreenModel nsModel : list ) {
+            Element screenElement = doc.createElement( "screen" );
+
+            screenElement.setAttribute("name", nsModel.getName());
+            screenElement.setAttribute("type", nsModel.getType().toString());
+
+            if (nsModel.getDevicePixelRatio() > 0.0) {
+                screenElement.setAttribute("device-pixel-ratio",
+                                           String.valueOf(nsModel.getDevicePixelRatio()));
+            }
+
+            if (nsModel.getDeviceWidth() > -1) {
+                screenElement
+                        .setAttribute("device-width", String.valueOf(nsModel.getDeviceWidth()));
+            }
+
+            if (nsModel.getDeviceHeight() > -1) {
+                screenElement.setAttribute("device-height",
+                                           String.valueOf(nsModel.getDeviceHeight()));
+            }
+
+            if ( nsModel.getColor() > 0 )
+                screenElement.setAttribute( "color", String.valueOf( nsModel.getColor() ) );
+
+            if ( nsModel.getColorIndex() > 0 )
+                screenElement.setAttribute( "color-index", String.valueOf( nsModel.getColorIndex() ) );
+
+            if ( nsModel.getGrid() )
+                screenElement.setAttribute( "grid", String.valueOf( true ) );
+
+            if ( nsModel.getMonochrome() > 0 )
+                screenElement.setAttribute( "monochrome", String.valueOf( nsModel.getMonochrome() ) );
+
+            if ( nsModel.getOrientation() != null )
+                screenElement.setAttribute( "orientation", nsModel.getOrientation().toString()
+                        .toLowerCase() );
+
+            if ( nsModel.getResolution() != null )
+                screenElement.setAttribute( "resolution", nsModel.getResolution() );
+
+            if ( nsModel.getScan() != null )
+                screenElement.setAttribute( "scan", nsModel.getScan().toString().toLowerCase() );
+
+            for (int i = 0; i < appManager.getPageDataSet().getPages().size(); i++) {
+                String pageName = appManager.getPageDataSet().getPages().get(i).getName();
+                String enable = String.valueOf(nsModel.isEnablePage(pageName));
+                String link = "";
+
+                if (nsModel.getLink(pageName) != -666) {
+                    link = String.valueOf(nsModel.getLink(pageName));
+                }
+
+                Element enablePageElement = doc.createElement("enablePage");
+
+                if (!(enable.isEmpty()) || (!link.isEmpty())) {
+                    enablePageElement.setAttribute("name", pageName);
+                    enablePageElement.setAttribute("enable", enable);
+                    if (!link.isEmpty()) {
+                        enablePageElement.setAttribute("link", link);
+                    }
+                    screenElement.appendChild(enablePageElement);
                 }
-                return 1;
             }
-        });
-
-        int preWidth = 0;
-        for (CssFile model : list) {
-            Element screenElement = doc.createElement("screen");
-            screenElement.setAttribute("title", model.getTitle());
-            screenElement.setAttribute("width", String.valueOf(model.getWidth()));
-            screenElement.setAttribute("height", String.valueOf(model.getHeight()));
-            screenElement.setAttribute("cssFileName", model.getFileName());
-            screenElement.setAttribute("minWidth", String.valueOf(preWidth));
-
-            preWidth = model.getWidth();
-            if (preWidth != 0) {
-                preWidth++;
+
+            if (!nsModel.getFileName().isEmpty()) {
+                screenElement.setAttribute("cssFileName", nsModel.getFileName());
             }
 
+            // menu flag
+            screenElement.setAttribute("defaultInMenu", String.valueOf(nsModel.getDefaultInMenu()));
+            screenElement.setAttribute("enableInMenu", String.valueOf(nsModel.getEnableInMenu()));
+            screenElement.setAttribute("linkInMenu", String.valueOf(nsModel.getLinkInMenu()));
+            screenElement.setAttribute("moveInMenu", String.valueOf(nsModel.getMoveInMenu()));
+
             nscreenElement.appendChild(screenElement);
         }
         return nscreenElement;
index 27d8f49..20dfe2e 100644 (file)
@@ -27,9 +27,7 @@ import java.util.ArrayList;
 import java.util.Collection;
 import java.util.List;
 
-import org.eclipse.core.runtime.IPath;
 import org.tizen.webuibuilder.model.css.NewCssEvent.EventType;
-import org.tizen.webuibuilder.ui.views.nscreen.model.NScreenModel;
 
 
 /**
@@ -37,7 +35,6 @@ import org.tizen.webuibuilder.ui.views.nscreen.model.NScreenModel;
  * used for NScreen.
  */
 public class CssFile {
-    private NScreenModel mNScreenModel;
     private String mCssFileFullPath = "";
     private List<CssSelector> selectors = new ArrayList<CssSelector>();
     private List<ICssSelectorListener> listeners = new ArrayList<ICssSelectorListener>();
@@ -45,39 +42,6 @@ public class CssFile {
     /**
      * Constructor.
      * 
-     * @param nScreenItemName
-     *            name of NScreen item
-     * @param width
-     *            width of NScreen item
-     * @param height
-     *            height of NScreen item
-     * @param fileName
-     *            file name of css
-     * @param cssFileFullPath
-     *            full path of css
-     */
-    public CssFile(String nScreenItemName, int width, int height, String fileName,
-            String cssFileFullPath) {
-        mNScreenModel = new NScreenModel(nScreenItemName, width, height, fileName);
-        mCssFileFullPath = cssFileFullPath;
-    }
-
-    /**
-     * Constructor.
-     * 
-     * @param cssFileFullPath
-     *            full path of css
-     * @param width
-     *            width of NScreen item.
-     */
-    public CssFile(String cssFileFullPath, int width) {
-        this("Basic", width, 0, cssFileFullPath.substring(cssFileFullPath
-                .lastIndexOf(IPath.SEPARATOR) + 1), cssFileFullPath);
-    }
-
-    /**
-     * Constructor.
-     * 
      * @param cssFileFullPath
      *            full path of css
      */
@@ -230,102 +194,6 @@ public class CssFile {
     }
 
     /**
-     * Gets a {@link NScreenModel}.
-     * 
-     * @return a {@link NScreenModel}
-     */
-    public NScreenModel getNScreenModel() {
-        return mNScreenModel;
-    }
-
-    /**
-     * Sets a {@link NScreenModel}.
-     * 
-     * @param nscreenModel
-     *            a {@link NScreenModel}
-     */
-    public void setNScreenModel(NScreenModel nscreenModel) {
-        mNScreenModel = nscreenModel;
-    }
-
-    /**
-     * Gets title string.
-     * 
-     * @return title
-     */
-    public String getTitle() {
-        return mNScreenModel.getTitle();
-    }
-
-    /**
-     * Sets title string.
-     * 
-     * @param title
-     */
-    public void setTitle(String title) {
-        if (mNScreenModel != null)
-            mNScreenModel.setTitle(title);
-    }
-
-    /**
-     * Gets width of {@link NScreenModel}.
-     * 
-     * @return width of {@link NScreenModel}
-     */
-    public int getWidth() {
-        return (mNScreenModel != null) ? mNScreenModel.getWidth() : 0;
-    }
-
-    /**
-     * Sets width of {@link NScreenModel}.
-     * 
-     * @param width
-     */
-    public void setWidth(int width) {
-        if (mNScreenModel != null)
-            mNScreenModel.setWidth(width);
-    }
-
-    /**
-     * Gets height of {@link NScreenModel}.
-     * 
-     * @return height of {@link NScreenModel}
-     */
-    public int getHeight() {
-        return (mNScreenModel != null) ? mNScreenModel.getHeight() : 0;
-    }
-
-    /**
-     * Sets height of {@link NScreenModel}.
-     * 
-     * @param height
-     */
-    public void setHeight(int height) {
-        if (mNScreenModel != null)
-            mNScreenModel.setHeight(height);
-    }
-
-    /**
-     * Gets file name.
-     * 
-     * @return string of file name
-     */
-    public String getFileName() {
-        return (mNScreenModel != null) ? mNScreenModel.getFileName() : "";
-    }
-
-    /**
-     * Set file name.
-     * 
-     * @param fileName
-     *            string of file name
-     */
-    public void setFileName(String fileName) {
-        if (mNScreenModel != null)
-            mNScreenModel.setFileName(fileName);
-    }
-
-    /**
      * Gets full path of css.
      * 
      * @return string of full path
index c7f2d54..7fd0450 100644 (file)
@@ -27,8 +27,8 @@ import java.util.ArrayList;
 import java.util.List;
 
 import org.tizen.webuibuilder.model.Part;
+import org.tizen.webuibuilder.model.nscreen.NScreenModel;
 import org.tizen.webuibuilder.ui.views.databinding.model.BindingData;
-import org.tizen.webuibuilder.ui.views.nscreen.model.NScreenModel;
 import org.w3c.dom.Document;
 
 
index 45d7618..54aadbe 100644 (file)
@@ -27,7 +27,7 @@ import java.util.ArrayList;
 import java.util.List;
 
 import org.tizen.webuibuilder.model.Part;
-import org.tizen.webuibuilder.ui.views.nscreen.model.NScreenModel;
+import org.tizen.webuibuilder.model.nscreen.NScreenModel;
 import org.w3c.dom.Document;
 
 
index b0f63e2..5f58925 100644 (file)
@@ -25,16 +25,16 @@ package org.tizen.webuibuilder.model.io.file;
 
 import java.util.List;
 
-import org.w3c.dom.Document;
-import org.w3c.dom.Element;
-import org.w3c.dom.Node;
-import org.w3c.dom.NodeList;
 import org.tizen.webuibuilder.model.Part;
 import org.tizen.webuibuilder.model.PartFactory;
 import org.tizen.webuibuilder.model.css.CssSelector;
 import org.tizen.webuibuilder.model.filedata.PageFileData;
 import org.tizen.webuibuilder.model.io.ModelDeserializer;
-import org.tizen.webuibuilder.ui.views.nscreen.model.NScreenModel;
+import org.tizen.webuibuilder.model.nscreen.NScreenModel;
+import org.w3c.dom.Document;
+import org.w3c.dom.Element;
+import org.w3c.dom.Node;
+import org.w3c.dom.NodeList;
 
 
 public class PageReader_ver_2 {
@@ -156,7 +156,7 @@ public class PageReader_ver_2 {
                        Element child = (Element)childNode;
                            String tagName = child.getNodeName();
                            if ("title".equals(tagName)) {
-                               model.setTitle(child.getTextContent());
+                               model.setName(child.getTextContent());
                            } else if ("width".equals(tagName)) {
                                model.setWidth(Integer.parseInt(child.getTextContent()));
                            } else if ("height".equals(tagName)) {
index cfa4942..622dfed 100644 (file)
 package org.tizen.webuibuilder.model.io.file;
 
 import java.util.List;
-import java.util.Map.Entry;
 
-import org.tizen.webuibuilder.BuilderConstants;
-import org.tizen.webuibuilder.model.GotoPageProperty;
 import org.tizen.webuibuilder.model.Part;
-import org.tizen.webuibuilder.model.css.CssSelector;
-import org.tizen.webuibuilder.model.descriptors.PartDescriptor;
-import org.tizen.webuibuilder.model.descriptors.PropertyDescriptor;
-import org.tizen.webuibuilder.model.descriptors.TypeDescriptor;
 import org.tizen.webuibuilder.model.filedata.PageFileData;
 import org.tizen.webuibuilder.model.io.ModelSerializer;
-import org.tizen.webuibuilder.ui.views.nscreen.model.NScreenModel;
+import org.tizen.webuibuilder.model.nscreen.NScreenModel;
 import org.w3c.dom.Document;
 import org.w3c.dom.Element;
 
@@ -160,7 +153,7 @@ public class PageWriter_ver_2 {
         for (NScreenModel model : list) {
             Element screenElement = doc.createElement("screen");
             Element titleElement = doc.createElement("title");
-            titleElement.setTextContent(model.getTitle());
+            titleElement.setTextContent(model.getName());
             Element widthElement = doc.createElement("width");
             widthElement.setTextContent(String.valueOf(model.getWidth()));
             Element heightElement = doc.createElement("height");
diff --git a/org.tizen.webuibuilder/src/org/tizen/webuibuilder/model/nscreen/Device.java b/org.tizen.webuibuilder/src/org/tizen/webuibuilder/model/nscreen/Device.java
new file mode 100644 (file)
index 0000000..0d8fda3
--- /dev/null
@@ -0,0 +1,195 @@
+/*
+ * UI Builder
+ *
+ * Copyright (c) 2000 - 2014 Samsung Electronics Co., Ltd. All rights reserved.
+ *
+ * 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.webuibuilder.model.nscreen;
+
+public class Device {
+
+    public enum Orientation {
+        LANDSCAPE, PORTRAIT
+    }
+
+    public enum Scan {
+        PROGRESSIVE, INTERLACE
+    }
+
+    // Device Info
+    private String name;
+    private String displayName;
+    private String deviceImageName = null;
+
+    // Media Feature
+    private double devicePixelRatio = 0;
+    private int deviceHeight = 0;
+    private int deviceWidth = 0;
+    private int width;
+    private int height;
+    private int color;
+    private int colorIndex;
+    private Orientation orientation = null;
+    private int monochrome;
+    private String resolution;
+    private Scan scan = null;
+    private boolean grid = false;
+
+    public Device(String name, String displayName) {
+        this.name = name;
+        this.displayName = displayName;
+    }
+
+    public String getName() {
+        return this.name;
+    }
+
+    public String getDisplayName() {
+        return this.displayName;
+    }
+
+    public String getDeviceImageName() {
+        return deviceImageName;
+    }
+
+    public void setDeviceImageName(String deviceImageName) {
+        this.deviceImageName = deviceImageName;
+    }
+
+    public double getDevicePixelRatio() {
+        return devicePixelRatio;
+    }
+
+    public void setDevicePixelRatio(double devicePixelRatio) {
+        this.devicePixelRatio = devicePixelRatio;
+    }
+
+    public int getDeviceHeight() {
+        return deviceHeight;
+    }
+
+    public void setDeviceHeight(int deviceHeight) {
+        this.deviceHeight = deviceHeight;
+    }
+
+    public int getDeviceWidth() {
+        return deviceWidth;
+    }
+
+    public void setDeviceWidth(int deviceWidth) {
+        this.deviceWidth = deviceWidth;
+    }
+
+    public int getWidth() {
+        return width;
+    }
+
+    public void setWidth(int width) {
+        this.width = width;
+    }
+
+    public int getHeight() {
+        return height;
+    }
+
+    public void setHeight(int height) {
+        this.height = height;
+    }
+
+    public int getColor() {
+        return color;
+    }
+
+    public void setColor(int color) {
+        this.color = color;
+    }
+
+    public int getColorIndex() {
+        return colorIndex;
+    }
+
+    public void setColorIndex(int colorIndex) {
+        this.colorIndex = colorIndex;
+    }
+
+    public Orientation getOrientation() {
+        return orientation;
+    }
+
+    public void setOrientation(Orientation orientation) {
+        this.orientation = orientation;
+    }
+
+    public int getMonochrome() {
+        return monochrome;
+    }
+
+    public void setMonochrome(int monochrome) {
+        this.monochrome = monochrome;
+    }
+
+    public String getResolution() {
+        return resolution;
+    }
+
+    public void setResolution(String resolution) {
+        this.resolution = resolution;
+    }
+
+    public Scan getScan() {
+        return scan;
+    }
+
+    public void setScan(Scan scan) {
+        this.scan = scan;
+    }
+
+    public boolean isGrid() {
+        return grid;
+    }
+
+    public void setGrid(boolean grid) {
+        this.grid = grid;
+    }
+
+    public String print() {
+        String printData = "Device Info  name: " + getName();
+        if (getDisplayName() != null) {
+            printData += ", Device DisplayName : ";
+            printData += getDisplayName();
+        }
+
+        if (getDevicePixelRatio() != 0) {
+            printData += ", DevicePixelRatio : ";
+            printData += getDevicePixelRatio();
+        }
+
+        if (getDeviceWidth() != 0) {
+            printData += ", DeviceWidth : ";
+            printData += getDeviceWidth();
+        }
+
+        if (getDeviceHeight() != 0) {
+            printData += ", DeviceHeight : ";
+            printData += getDeviceHeight();
+        }
+        return printData;
+    }
+}
diff --git a/org.tizen.webuibuilder/src/org/tizen/webuibuilder/model/nscreen/DeviceManager.java b/org.tizen.webuibuilder/src/org/tizen/webuibuilder/model/nscreen/DeviceManager.java
new file mode 100644 (file)
index 0000000..0bdbbc4
--- /dev/null
@@ -0,0 +1,132 @@
+/*
+ * UI Builder
+ *
+ * Copyright (c) 2000 - 2014 Samsung Electronics Co., Ltd. All rights reserved.
+ *
+ * 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.webuibuilder.model.nscreen;
+
+import java.util.LinkedList;
+import java.util.List;
+
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import org.tizen.webuibuilder.model.nscreen.Device.Orientation;
+
+
+public class DeviceManager {
+    Logger logger = LoggerFactory.getLogger(DeviceManager.class);
+
+    static DeviceManager manager = null;
+    private List<Device> devices = new LinkedList<Device>();
+
+    private DeviceManager() {
+    }
+
+    public static DeviceManager getDeviceManager() {
+        if (manager == null) {
+            manager = new DeviceManager();
+            manager.load();
+        }
+        return manager;
+    }
+
+    public void load() {
+        addDevice("GalaxyGear2", "Gear2 [320x320, 1:1, PR:1.0]", Orientation.PORTRAIT, 1.0, 320,
+                  320, 320, 320);
+        addDevice("Redwood Portrait", "Redwood [360x640, 9:16, PR:2.0]", Orientation.PORTRAIT, 2.0,
+                  360, 640, 720, 1280);
+        addDevice("Redwood Landscape", "Redwood [640x360, 16:9, PR:2.0]", Orientation.LANDSCAPE,
+                  2.0, 640, 360, 1280, 720);
+
+    }
+
+    public List<Device> getDevices() {
+        return devices;
+    }
+
+    private void addDevice(Device device) {
+        this.devices.add(device);
+
+    }
+
+    // private void removeDevice(Device device) {
+    // this.devices.remove(device);
+    // }
+
+    private void addDevice(String name, String displayName, Orientation orientation,
+                           double devicePixelRatio, int deviceWidth, int deviceHeight, int width,
+                           int height) {
+        if (name == null) {
+            return;
+        }
+
+        if (name.isEmpty()) {
+            return;
+        }
+
+        if (displayName == null) {
+            return;
+        }
+        if (displayName.isEmpty()) {
+            return;
+        }
+
+        Device device = new Device(name, displayName);
+
+        if (orientation != null) {
+            device.setOrientation(orientation);
+        }
+
+        if (devicePixelRatio != 0) {
+            device.setDevicePixelRatio(devicePixelRatio);
+        }
+
+        if (deviceWidth != 0) {
+            device.setDeviceWidth(deviceWidth);
+        }
+
+        if (deviceHeight != 0) {
+            device.setDeviceHeight(deviceHeight);
+        }
+
+        if (width != 0) {
+            device.setWidth(width);
+        }
+
+        if (height != 0) {
+            device.setHeight(height);
+        }
+
+        this.addDevice(device);
+    }
+
+    public void printDevices() {
+        for (int i = 0; i < this.devices.size(); i++) {
+            Device device = this.devices.get(i);
+            this.logger.info("Device Name : " + device.getName() + ",DispalyName : "
+                    + device.getDisplayName() + ", Orientation : " + device.getOrientation()
+                    + " , DeviceWidth : " + device.getDeviceWidth() + " , DeviceHeight : "
+                    + device.getDeviceHeight() + " DevicePixelRatio : "
+                    + device.getDevicePixelRatio());
+        }
+    }
+
+}
diff --git a/org.tizen.webuibuilder/src/org/tizen/webuibuilder/model/nscreen/NScreenModel.java b/org.tizen.webuibuilder/src/org/tizen/webuibuilder/model/nscreen/NScreenModel.java
new file mode 100644 (file)
index 0000000..c11f8e0
--- /dev/null
@@ -0,0 +1,364 @@
+/*
+ * UI Builder
+ *
+ * Copyright (c) 2000 - 2014 Samsung Electronics Co., Ltd. All rights reserved.
+ *
+ * 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.webuibuilder.model.nscreen;
+
+import java.util.HashMap;
+
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+
+public class NScreenModel {
+    Logger logger = LoggerFactory.getLogger(NScreenModel.class);
+
+    public static final int UP = -1;
+    public static final int NONE = 0;
+    public static final int DOWN = 1;
+
+    public enum Orientation {
+        LANDSCAPE, PORTRAIT;
+    }
+
+    public enum Scan {
+        PROGRESSIVE, INTERLACE
+    }
+
+    public enum NScreenType {
+        COMMON, ORIENTATION, PIXELRATIO, RESOLUTION, CUSTOM
+    }
+
+    // Nscreen Info
+    private String nscreenName;
+    private NScreenType type = null;
+    private HashMap<String, Boolean> enablePages = new HashMap<String, Boolean>();
+    private HashMap<String, Integer> link = new HashMap<String, Integer>();
+    private String imageName = null;
+
+    private boolean defaultInMenu = false;
+    private boolean enableInMenu = false;
+    private boolean linkInMenu = false;
+    private boolean moveInMenu = false;
+
+    // Media Feature
+    private double devicePixelRatio = 0;
+    private int deviceHeight = 0;
+    private int deviceWidth = 0;
+    private int width;
+    private int height;
+    private int color;
+    private int colorIndex;
+    private Orientation orientation = null;
+    private int monochrome;
+    private String resolution;
+    private Scan scan = null;
+    private boolean grid = false;
+    // TODO : Next Version.
+    // private int minDeviceHeight;
+    // private int maxDeviceHeight;
+    // private int minDeviceWidth;
+    // private int maxDeviceWidth;
+
+    private String fileName;
+
+    public NScreenModel(String name, NScreenType type) {
+        this.nscreenName = name;
+        this.type = type;
+    }
+
+    public NScreenModel() {
+    }
+
+    // Nscreen Info
+    public String getName() {
+        return nscreenName;
+    }
+
+    public void setName(String name) {
+        this.nscreenName = name;
+    }
+
+    public NScreenType getType() {
+        return type;
+    }
+
+    public void setType(NScreenType type) {
+        this.type = type;
+    }
+
+    public void addEnablePage(String pageId) {
+        this.enablePages.put(pageId, true);
+    }
+
+    public void addDisablePage(String pageId) {
+        this.enablePages.put(pageId, false);
+        link.put(pageId, NONE);
+    }
+
+    public void removeEnablePage(String pageId) {
+        this.enablePages.remove(pageId);
+    }
+
+    public boolean isEnablePage(String pageId) {
+        return this.enablePages.get(pageId);
+    }
+
+    public void addLink(String pageId, int status) {
+        if (isValidStatus(status)) {
+            this.link.put(pageId, status);
+        } else {
+            return;
+        }
+    }
+
+    public void removeLink(String pageId) {
+        this.link.remove(pageId);
+    }
+
+    public int getLink(String pageId) {
+        if (this.link.get(pageId) == null) {
+            return -666;
+        }
+        return this.link.get(pageId);
+    }
+
+    public boolean isLinked(String pageId) {
+        if (getLink(pageId) == NONE) {
+            return false;
+        }
+        return true;
+    }
+
+    public boolean isValidStatus(int status) {
+        boolean checkValue = false;
+
+        switch (status) {
+            case NScreenModel.UP:
+                checkValue = true;
+                break;
+            case NScreenModel.NONE:
+                checkValue = true;
+                break;
+            case NScreenModel.DOWN:
+                checkValue = true;
+                break;
+            default:
+                logger.info("Status is not valid.");
+                break;
+        }
+        return checkValue;
+    }
+
+    public String getImageName() {
+        return imageName;
+    }
+
+    public void setImageName(String imageName) {
+        this.imageName = imageName;
+    }
+
+    // Media Feature
+    public double getDevicePixelRatio() {
+        return devicePixelRatio;
+    }
+
+    public void setDevicePixelRatio(double devicePixelRatio) {
+        this.devicePixelRatio = devicePixelRatio;
+    }
+
+    public int getDeviceHeight() {
+        return deviceHeight;
+    }
+
+    public void setDeviceHeight(int deviceHeight) {
+        this.deviceHeight = deviceHeight;
+    }
+
+    public int getDeviceWidth() {
+        return deviceWidth;
+    }
+
+    public void setDeviceWidth(int deviceWidth) {
+        this.deviceWidth = deviceWidth;
+    }
+
+    public int getColor() {
+        return color;
+    }
+
+    public void setColor(int color) {
+        this.color = color;
+    }
+
+    public int getColorIndex() {
+        return colorIndex;
+    }
+
+    public void setColorIndex(int colorIndex) {
+        this.colorIndex = colorIndex;
+    }
+
+    public Orientation getOrientation() {
+        return orientation;
+    }
+
+    public void setOrientation(Orientation orientation) {
+        this.orientation = orientation;
+    }
+
+    public int getMonochrome() {
+        return monochrome;
+    }
+
+    public void setMonochrome(int monochrome) {
+        this.monochrome = monochrome;
+    }
+
+    public String getResolution() {
+        return resolution;
+    }
+
+    public void setResolution(String resolution) {
+        this.resolution = resolution;
+    }
+
+    public Scan getScan() {
+        return scan;
+    }
+
+    public void setScan(Scan scan) {
+        this.scan = scan;
+    }
+
+    public boolean getGrid() {
+        return grid;
+    }
+
+    public void setGrid(boolean grid) {
+        this.grid = grid;
+    }
+
+    public String getOriginFileName() {
+        return fileName;
+    }
+
+    public String getAspectRatio() {
+        return reduceRatio(width, height);
+    }
+
+    public String getDeviceAspectRatio() {
+        return reduceRatio(deviceWidth, deviceHeight);
+    }
+
+    public int getWidth() {
+        return width;
+    }
+
+    public void setWidth(int width) {
+        this.width = width;
+    }
+
+    public int getHeight() {
+        return height;
+    }
+
+    public void setHeight(int height) {
+        this.height = height;
+    }
+
+    private String reduceRatio(int numerator, int denominator) {
+        int temp = 0;
+
+        if (numerator == 0 || denominator == 0)
+            return "0/0";
+
+        if (numerator == denominator)
+            return "1/1";
+
+        if (+numerator < +denominator) {
+            temp = numerator;
+            numerator = denominator;
+            denominator = temp;
+        }
+
+        int divisor = gcd(+numerator, +denominator);
+
+        return (numerator / divisor) + "/" + (denominator / divisor);
+    }
+
+    private static int gcd(int a, int b) {
+        if (b == 0)
+            return a;
+
+        return gcd(b, a % b);
+    }
+
+    public String getFileName() {
+        return fileName;
+    }
+
+    public void setFileName(String fileName) {
+        this.fileName = fileName;
+    }
+
+    public HashMap<String, Boolean> getEnablePages() {
+        return enablePages;
+    }
+
+    public void setEnablePages(HashMap<String, Boolean> enablePages) {
+        this.enablePages = enablePages;
+    }
+
+    // NscreenView Menu
+    public boolean getDefaultInMenu() {
+        return defaultInMenu;
+    }
+
+    public void setDefaultInMenu(boolean defaultInMenu) {
+        this.defaultInMenu = defaultInMenu;
+    }
+
+    public boolean getEnableInMenu() {
+        return enableInMenu;
+    }
+
+    public void setEnableInMenu(boolean enableInMenu) {
+        this.enableInMenu = enableInMenu;
+    }
+
+    public boolean getLinkInMenu() {
+        return linkInMenu;
+    }
+
+    public void setLinkInMenu(boolean linkInMenu) {
+        this.linkInMenu = linkInMenu;
+    }
+
+    public boolean getMoveInMenu() {
+        return moveInMenu;
+    }
+
+    public void setMoveInMenu(boolean moveInMenu) {
+        this.moveInMenu = moveInMenu;
+    }
+}
diff --git a/org.tizen.webuibuilder/src/org/tizen/webuibuilder/model/nscreen/NScreenModelController.java b/org.tizen.webuibuilder/src/org/tizen/webuibuilder/model/nscreen/NScreenModelController.java
new file mode 100644 (file)
index 0000000..f28eff0
--- /dev/null
@@ -0,0 +1,75 @@
+
+
+package org.tizen.webuibuilder.model.nscreen;
+
+import java.util.List;
+
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import org.tizen.webuibuilder.model.app.AppManager;
+import org.tizen.webuibuilder.model.nscreen.NScreenModel.NScreenType;
+import org.tizen.webuibuilder.model.page.IPageDataSetListener;
+import org.tizen.webuibuilder.model.page.PageDataSetEvent;
+
+
+public class NScreenModelController implements IPageDataSetListener {
+    Logger logger = LoggerFactory.getLogger(NScreenModelController.class);
+
+    private AppManager appManager = null;
+    private List<NScreenModel> modelList;
+
+    public NScreenModelController(AppManager appManager) {
+        logger.info("Create Class");
+        this.appManager = appManager;
+        this.modelList = this.appManager.getNScreenModelManger().getNScreenModels();
+        this.addListener();
+    }
+
+    public void addListener() {
+        this.appManager.getPageDataSet().addPageListener(this);
+    }
+
+    public void removeListener() {
+        this.appManager.getPageDataSet().removePageListener(this);
+    }
+
+    @Override
+    public void allPagesReseted(PageDataSetEvent e) {
+    }
+
+    @Override
+    public void pagePreDelete(PageDataSetEvent e) {
+    }
+
+    @Override
+    public void pageAdded(PageDataSetEvent e) {
+        logger.info("NScreen add page :" + e.getPageName());
+        for (int i = 0; i < modelList.size(); i++) {
+            NScreenModel model = modelList.get(i);
+            logger.info("NScreen name :" + model.getName());
+            if (model.getType() == NScreenType.COMMON) {
+                model.addEnablePage(e.getPageName());
+            } else {
+                model.addDisablePage(e.getPageName());
+            }
+        }
+    }
+
+    @Override
+    public void pageRemoved(PageDataSetEvent e) {
+        logger.info("NScreen remove page : " + e.getPageName());
+        for (int i = 0; i < modelList.size(); i++) {
+            NScreenModel model = modelList.get(i);
+            model.removeEnablePage(e.getPageName());
+        }
+    }
+
+    @Override
+    public void pageRenamed(PageDataSetEvent e) {
+    }
+
+    @Override
+    public void pageMoved(PageDataSetEvent e) {
+    }
+
+}
diff --git a/org.tizen.webuibuilder/src/org/tizen/webuibuilder/model/nscreen/NScreenModelManager.java b/org.tizen.webuibuilder/src/org/tizen/webuibuilder/model/nscreen/NScreenModelManager.java
new file mode 100644 (file)
index 0000000..ed5eeac
--- /dev/null
@@ -0,0 +1,189 @@
+/*
+ * UI Builder
+ *
+ * Copyright (c) 2000 - 2014 Samsung Electronics Co., Ltd. All rights reserved.
+ *
+ * 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.webuibuilder.model.nscreen;
+
+import java.util.ArrayList;
+import java.util.LinkedList;
+import java.util.List;
+
+import org.tizen.webuibuilder.BuilderConstants;
+import org.tizen.webuibuilder.model.nscreen.NScreenModel.NScreenType;
+
+
+public class NScreenModelManager {
+    private List<NScreenModel> nscreenModels = new ArrayList<NScreenModel>();
+
+    public NScreenModelManager() {
+    }
+
+    public NScreenModel createCommonNscreen() {
+        NScreenModel model = new NScreenModel(BuilderConstants.NSCREENCOMMON, NScreenType.COMMON);
+        model.setFileName(BuilderConstants.NSCREENCOMMON.toLowerCase());
+        model.setDefaultInMenu(true);
+        model.setEnableInMenu(false);
+        model.setLinkInMenu(false);
+        model.setMoveInMenu(false);
+        this.addNScreenModel(model);
+        return model;
+    }
+
+    public boolean addNScreenModel(NScreenModel model) {
+        if (isValidNscreenModel(model)) {
+            this.nscreenModels.add(model);
+            return true;
+        }
+        return false;
+    }
+
+    public void removeNScreenModel(NScreenModel model) {
+        this.nscreenModels.remove(model);
+    }
+
+    public List<NScreenModel> getNScreenModels() {
+        return this.nscreenModels;
+    }
+
+    public NScreenModel getNScreenModel(String nscreenName) {
+        NScreenModel model = null;
+
+        if (nscreenName == null) {
+            return null;
+        }
+
+        if (nscreenName.isEmpty()) {
+            return null;
+        }
+
+        if (nscreenModels.size() == 0) {
+            return null;
+        }
+
+        for (int i = 0; i < nscreenModels.size(); i++) {
+            if (nscreenName.equalsIgnoreCase(this.nscreenModels.get(i).getName())) {
+                model = this.nscreenModels.get(i);
+                break;
+            }
+        }
+
+        return model;
+    }
+
+    public NScreenModel getCommonNscreen() {
+        if (nscreenModels.size() == 0) {
+            return createCommonNscreen();
+        }
+        return this.getNScreenModel(BuilderConstants.NSCREENCOMMON);
+    }
+
+    public boolean isValidNscreenModel(NScreenModel model) {
+        if (getNScreenModel(model.getName()) == null) {
+            return true;
+        }
+        return false;
+    }
+
+    private NScreenModel getNScreenModel(NScreenType type, Object object) {
+        NScreenModel model = null;
+        NScreenModel retValue = null;
+
+        if (type == null) {
+            return null;
+        }
+
+        if (object == null) {
+            return null;
+        }
+
+        // Common
+        if (type == NScreenType.COMMON) {
+            return this.getCommonNscreen();
+        }
+
+        // Orientation
+        if (type == NScreenType.ORIENTATION) {
+            if (!(object instanceof String)) {
+                return null;
+            }
+
+            String orientation = (String) object;
+
+            if (NScreenModel.Orientation.PORTRAIT.toString().equalsIgnoreCase(orientation)) {
+                return getNScreenModel(BuilderConstants.NSCREENPORTRAIT);
+            } else {
+                return getNScreenModel(BuilderConstants.NSCREENLANDSCAPE);
+            }
+
+        }
+
+        if (type == NScreenType.PIXELRATIO) {
+            if (!(object instanceof Double)) {
+                return null;
+            }
+            double pixelRatio = (Double) object;
+
+            for (int i = 0; i < this.nscreenModels.size(); i++) {
+                model = this.nscreenModels.get(i);
+                if (model.getType() == type) {
+                    if (model.getDevicePixelRatio() == pixelRatio) {
+                        retValue = model;
+                        break;
+                    }
+                }
+            }
+        }
+
+        return retValue;
+    }
+
+    public List<NScreenModel> getNScreenModelsForDevice(Device device) {
+        List<NScreenModel> list = new LinkedList<NScreenModel>();
+
+        // add Common Model.
+        list.add(this.getCommonNscreen());
+
+        // add Orientation
+        if (device.getOrientation() != null) {
+            list.add(getNScreenModel(NScreenType.ORIENTATION, device.getOrientation().toString()));
+        }
+
+        // add pixel ratio
+        if (device.getDevicePixelRatio() > 0) {
+            list.add(getNScreenModel(NScreenType.PIXELRATIO, device.getDevicePixelRatio()));
+        }
+
+        // add Resolution
+        if ((device.getDeviceWidth() > 0) && (device.getDeviceHeight() > 0)) {
+            for (int i = 0; i < this.nscreenModels.size(); i++) {
+                NScreenModel model = this.nscreenModels.get(i);
+                if (model.getDeviceWidth() == device.getDeviceWidth()) {
+                    if (model.getDeviceHeight() == device.getDeviceHeight()) {
+                        list.add(model);
+                    }
+                }
+            }
+        }
+
+        return list;
+    }
+}
diff --git a/org.tizen.webuibuilder/src/org/tizen/webuibuilder/model/nscreen/descriptors/NScreenDescriptor.java b/org.tizen.webuibuilder/src/org/tizen/webuibuilder/model/nscreen/descriptors/NScreenDescriptor.java
new file mode 100644 (file)
index 0000000..506dd4c
--- /dev/null
@@ -0,0 +1,192 @@
+/*
+ * UI Builder
+ *
+ * Copyright (c) 2000 - 2014 Samsung Electronics Co., Ltd. All rights reserved.
+ *
+ * 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.webuibuilder.model.nscreen.descriptors;
+
+import java.util.List;
+
+import org.eclipse.core.resources.IFile;
+import org.tizen.webuibuilder.BuilderConstants;
+import org.tizen.webuibuilder.model.app.AppManager;
+import org.tizen.webuibuilder.model.nscreen.NScreenModel;
+import org.tizen.webuibuilder.model.nscreen.NScreenModel.NScreenType;
+import org.tizen.webuibuilder.model.nscreen.NScreenModel.Orientation;
+
+
+public class NScreenDescriptor {
+    private AppManager appManger = null;
+    private List<NScreenModel> list = null;
+
+    public NScreenDescriptor(AppManager appManger) {
+        this.appManger = appManger;
+        this.list = this.appManger.getNScreenModelManger().getNScreenModels();
+        load();
+    }
+
+    private void load() {
+        IFile file = appManger.getProjectManager().getProject().getFile("index.meta.xml");
+        if (file.exists()) {
+            // read metafile.
+            return;
+        }
+
+        createCommonNscreen();
+        createOrientationNscreen();
+        createPixelRatioNscreen();
+        createDeviceNscreen();
+    }
+
+    public void createCommonNscreen() {
+        addNscreenModel(BuilderConstants.NSCREENCOMMON, NScreenType.COMMON, null, 0, 0, 0,
+                        BuilderConstants.NSCREENCOMMON.toLowerCase());
+    }
+
+    public void createOrientationNscreen() {
+        addNscreenModel(BuilderConstants.NSCREENPORTRAIT, NScreenType.ORIENTATION,
+                        Orientation.PORTRAIT, 0, 0, 0,
+                        BuilderConstants.NSCREENPORTRAIT.toLowerCase());
+        addNscreenModel(BuilderConstants.NSCREENLANDSCAPE, NScreenType.ORIENTATION,
+                        Orientation.LANDSCAPE, 0, 0, 0,
+                        BuilderConstants.NSCREENLANDSCAPE.toLowerCase());
+    }
+
+    public void createPixelRatioNscreen() {
+        addNscreenModel("Pixcel Ratio 1.0", NScreenType.PIXELRATIO, null, 1.0, 0, 0,
+                        "pixcel_ratio_1_0");
+        addNscreenModel("Pixcel Ratio 1.5", NScreenType.PIXELRATIO, null, 1.5, 0, 0,
+                        "pixcel_ratio_1_5");
+        addNscreenModel("Pixcel Ratio 2.0", NScreenType.PIXELRATIO, null, 2.0, 0, 0,
+                        "pixcel_ratio_2_0");
+        addNscreenModel("Pixcel Ratio 3.0", NScreenType.PIXELRATIO, null, 3.0, 0, 0,
+                        "pixcel_ratio_3_0");
+    }
+
+    public void createDeviceNscreen() {
+        addNscreenModel("Wearable 320x320 (1:1)", NScreenType.RESOLUTION, null, 0, 320, 320,
+                        "wearable_320x320");
+        addNscreenModel("Wearable 360x480 (3:4)", NScreenType.RESOLUTION, null, 0, 360, 480,
+                        "wearable_360x480");
+        addNscreenModel("Wearable 480x360 (4:3)", NScreenType.RESOLUTION, null, 0, 480, 360,
+                        "wearable_480x360");
+        addNscreenModel("Wearable 312x496 (10:16)", NScreenType.RESOLUTION, null, 0, 312, 496,
+                        "wearable_312x496");
+        addNscreenModel("Wearable 496x312 (16:10)", NScreenType.RESOLUTION, null, 0, 496, 312,
+                        "wearable_496x312");
+        addNscreenModel("Mobile 320x480 (2:3)", NScreenType.RESOLUTION, null, 0, 320, 480,
+                        "mobile_320x480");
+        addNscreenModel("Mobile 480x320 (3:2)", NScreenType.RESOLUTION, null, 0, 480, 320,
+                        "mobile_480x320");
+        addNscreenModel("Mobile 360x640 (9:16)", NScreenType.RESOLUTION, null, 0, 360, 640,
+                        "mobile_360x640");
+        addNscreenModel("Mobile 640x360 (16:9)", NScreenType.RESOLUTION, null, 0, 640, 360,
+                        "mobile_640x360");
+        addNscreenModel("Mobile 800x1280 (10:16)", NScreenType.RESOLUTION, null, 0, 800, 1280,
+                        "mobile_800x1280");
+        addNscreenModel("Mobile 1280x800 (16:10)", NScreenType.RESOLUTION, null, 0, 1280, 800,
+                        "mobile_1280x800");
+        addNscreenModel("TV 1920x1080 (16:9)", NScreenType.RESOLUTION, null, 0, 1920, 1080,
+                        "tv_1920x1080");
+        addNscreenModel("TV 1080x1920 (9:16)", NScreenType.RESOLUTION, null, 0, 1080, 1920,
+                        "tv_1080x1920");
+    }
+
+    public void addNscreenModel(String name, NScreenType type, Orientation orientation,
+                                double devicePixelRatio, int deviceWidth, int deviceHeight,
+                                String fileName) {
+        if (name == null) {
+            return;
+        }
+
+        if (name.isEmpty()) {
+            return;
+        }
+
+        if (type == null) {
+            return;
+        }
+        NScreenModel model = new NScreenModel(name, type);
+
+        if (orientation != null) {
+            model.setOrientation(orientation);
+        }
+
+        if (devicePixelRatio != 0) {
+            model.setDevicePixelRatio(devicePixelRatio);
+        }
+
+        if (deviceWidth != 0) {
+            model.setDeviceWidth(deviceWidth);
+        }
+
+        if (deviceHeight != 0) {
+            model.setDeviceHeight(deviceHeight);
+        }
+
+        if (fileName != null) {
+            if (!fileName.isEmpty()) {
+                model.setFileName(fileName);
+            }
+        }
+        this.setMenuFlag(model);
+        this.list.add(model);
+    }
+
+    public void setMenuFlag(NScreenModel model) {
+        if (model == null) {
+            return;
+        }
+
+        if (model.getType() == NScreenType.COMMON) {
+            model.setDefaultInMenu(true);
+            model.setEnableInMenu(false);
+            model.setLinkInMenu(false);
+            model.setMoveInMenu(false);
+        }
+
+        if (model.getType() == NScreenType.ORIENTATION) {
+            model.setDefaultInMenu(false);
+            model.setEnableInMenu(true);
+            model.setLinkInMenu(false);
+            model.setMoveInMenu(false);
+        }
+
+        if (model.getType() == NScreenType.PIXELRATIO) {
+            model.setDefaultInMenu(false);
+            model.setEnableInMenu(true);
+            model.setLinkInMenu(true);
+            model.setMoveInMenu(false);
+        }
+
+        if (model.getType() == NScreenType.RESOLUTION) {
+            model.setDefaultInMenu(false);
+            model.setEnableInMenu(true);
+            model.setLinkInMenu(true);
+            model.setMoveInMenu(true);
+        }
+
+        if (model.getType() == NScreenType.CUSTOM) {
+            // noting.
+        }
+    }
+
+}
index a9cd70f..7ec2e2f 100644 (file)
@@ -754,18 +754,18 @@ public class PageData implements IPartListener, ICssListener {
                if (addItem == null) {
                        return false;
                }
-               for (CssFile cssFile : cssFiles) {
-                       if (cssFile.getWidth() == addItem.getWidth()) {
-                               return false;
-                       }
-               }
+//             for (CssFile cssFile : cssFiles) {
+//                     if (cssFile.getWidth() == addItem.getWidth()) {
+//                             return false;
+//                     }
+//             }
 
                return cssFiles.add(addItem);
        }
 
-       public void addCssFile(String cssFilePath, int width) {
-               addCssFile(new CssFile(cssFilePath, width));
-       }
+//     public void addCssFile(String cssFilePath, int width) {
+//             addCssFile(new CssFile(cssFilePath, width));
+//     }
 
        public void removeCssFile(CssFile cssFile) {
                if (cssFile != null) {
@@ -773,19 +773,18 @@ public class PageData implements IPartListener, ICssListener {
                }
        }
 
-       public void removeCssFile(String fileName) {
-               removeCssFile(getCssFile(fileName));
+       public void removeCssFileByPath(String path) {
+               removeCssFile(getCssFile(path));
        }
 
-       public CssFile getCssFile(String fileName) {
-               if (fileName != null) {
+       public CssFile getCssFile(String filePath) {
+               if (filePath != null) {
                        for (CssFile cssFile : cssFiles) {
-                               if (fileName.equals(cssFile.getFileName())) {
+                               if (filePath.equals(cssFile.getCssFilePath())) {
                                        return cssFile;
                                }
                        }
                }
-
                return null;
        }
 
index a9ee210..a7f346e 100644 (file)
@@ -25,8 +25,10 @@ package org.tizen.webuibuilder.ui.editor;
 
 import java.beans.PropertyChangeEvent;
 import java.beans.PropertyChangeListener;
+import java.io.File;
 import java.io.IOException;
 import java.net.MalformedURLException;
+import java.util.ArrayList;
 import java.util.EventObject;
 import java.util.List;
 
@@ -66,7 +68,6 @@ import org.eclipse.gef.ui.palette.FlyoutPaletteComposite.FlyoutPreferences;
 import org.eclipse.gef.ui.palette.PaletteViewerPreferences;
 import org.eclipse.gef.ui.palette.PaletteViewerProvider;
 import org.eclipse.gef.ui.parts.GraphicalEditor;
-import org.eclipse.gef.ui.parts.GraphicalViewerKeyHandler;
 import org.eclipse.gef.ui.parts.ScrollingGraphicalViewer;
 import org.eclipse.gef.ui.parts.SelectionSynchronizer;
 import org.eclipse.gef.ui.rulers.RulerComposite;
@@ -150,6 +151,9 @@ import org.tizen.webuibuilder.model.css.CssFile;
 import org.tizen.webuibuilder.model.css.CssSelector;
 import org.tizen.webuibuilder.model.css.io.CssReader;
 import org.tizen.webuibuilder.model.descriptors.DescriptorManager;
+import org.tizen.webuibuilder.model.nscreen.Device;
+import org.tizen.webuibuilder.model.nscreen.NScreenModel;
+import org.tizen.webuibuilder.model.nscreen.NScreenModelController;
 import org.tizen.webuibuilder.model.page.IPageDataListener;
 import org.tizen.webuibuilder.model.page.PageData;
 import org.tizen.webuibuilder.model.page.PageDataEvent;
@@ -168,6 +172,8 @@ import org.tizen.webuibuilder.ui.editor.dnd.listener.TemplateTransferDropTargetL
 import org.tizen.webuibuilder.ui.editor.ruler.DesignerRuler;
 import org.tizen.webuibuilder.ui.editor.ruler.DesignerRulerProvider;
 import org.tizen.webuibuilder.ui.editor.texteditor.TextEditor;
+import org.tizen.webuibuilder.ui.views.nscreen.NScreenHistory;
+import org.tizen.webuibuilder.ui.views.nscreen.NScreenItem;
 import org.tizen.webuibuilder.ui.views.pages.ThumbnailEditPart;
 import org.tizen.webuibuilder.ui.views.properties.PropertiesPage;
 import org.tizen.webuibuilder.ui.views.properties.PropertiesPage.PropertiesMode;
@@ -204,6 +210,8 @@ public class PageDesigner extends GraphicalEditor implements CommandStackListene
     // private FlyoutPaletteComposite splitter;
     private Composite splitter;
 
+    protected NScreenModelController controller = null;
+
     /**
      * The width of the palette.
      */
@@ -287,8 +295,13 @@ public class PageDesigner extends GraphicalEditor implements CommandStackListene
         return file;
     }
 
-    public void setNscreenIndex(CssFile model) {
-        if (pageData.getCurrentCssFile().equals(model)) {
+    public void setNscreenIndex(NScreenModel model) {
+
+        String cssFileName = pageData.getName() + "_" + model.getName() + ".css";
+
+        File curFile = new File(pageData.getCurrentCssFile().getCssFilePath());
+
+        if (curFile.getName().equals(cssFileName)) {
             return;
         }
         // remove css selector in previous CssFile
@@ -297,10 +310,13 @@ public class PageDesigner extends GraphicalEditor implements CommandStackListene
         List<CssFile> list = pageData.getCssFiles();
         int size = list.size();
         for (int i = 0; i < size; i++) {
-            if (list.get(i).getWidth() == model.getWidth()) {
+            CssFile file = list.get(i);
+
+            String fileName = new File(file.getCssFilePath()).getName();
+            if (fileName.equals(cssFileName)) {
                 // apply new css file
                 setCssFileToModel(pageData.getCommonCssFile());
-                setCssFileToModel(model);
+                setCssFileToModel(list.get(i));
                 pageData.setCssFileIndex(i);
                 getViewer().updateStyle();
 
@@ -317,6 +333,52 @@ public class PageDesigner extends GraphicalEditor implements CommandStackListene
 
     }
 
+    public void setNscreenIndex2(Device device, NScreenHistory itemHistory) {
+        List<NScreenModel> models =
+                appManager.getNScreenModelManger().getNScreenModelsForDevice(device);
+
+        clearSelectorsOfRootPart();
+
+        List<CssFile> list = pageData.getCssFiles();
+        List<CssFile> applyList = new ArrayList<CssFile>();
+        for (NScreenModel model : models) {
+            String cssFileName = pageData.getName() + "_" + model.getName() + ".css";
+
+            int size = list.size();
+            for (int i = 0; i < size; i++) {
+                CssFile file = list.get(i);
+                String fileName = new File(file.getCssFilePath()).getName();
+                if (fileName.equals(cssFileName)) {
+                    applyList.add(file);
+                    break;
+                }
+            }
+        }
+
+        for (int i = 0; i < applyList.size(); i++) {
+            setCssFileToModel(applyList.get(i));
+        }
+        if (null != itemHistory) {
+            String cssFileName = pageData.getName() + "_" + itemHistory.getModelName() + ".css";
+            boolean isSet = false;
+            for (int i = 0; i < list.size(); i++) {
+                CssFile file = list.get(i);
+                String fileName = new File(file.getCssFilePath()).getName();
+                if (fileName.equals(cssFileName)) {
+                    pageData.setCssFileIndex(i);
+                    isSet = true;
+                    break;
+                }
+            }
+            if (!isSet) {
+                pageData.setCssFileIndex(0);
+            }
+        }
+        System.out.println(pageData.getCurrentCssFile().getCssFilePath());
+        getViewer().updateStyle();
+
+    }
+
     protected void setCssFileToModel(CssFile cssFile) {
         if (rootPart != null && cssFile != null) {
             for (CssSelector selector : cssFile.getSelectors()) {
@@ -338,18 +400,20 @@ public class PageDesigner extends GraphicalEditor implements CommandStackListene
     }
 
     protected void clearSelectorsOfRootPart() {
-        CssFile currentCssFile = pageData.getCurrentCssFile();
-        for (CssSelector selector : currentCssFile.getSelectors()) {
-            String pageId = selector.getPageId();
-            Part pagePart = rootPart.getChildOfIdPropertyValue(pageId, true);
-            if (pagePart != null) {
-                String partId = selector.getPartId();
-                Part part = rootPart.getChildOfIdPropertyValue(partId, true);
-                if (part != null) {
-                    part.removeSelector(selector.getSelectorName(), false);
-                }
-            }
-        }
+        rootPart.clearAllSelector();
+        // CssFile currentCssFile = pageData.getCurrentCssFile();
+        // Collection<CssSelector> selectors = rootPart.getSelectors();
+        // for (CssSelector selector : currentCssFile.getSelectors()) {
+        // String pageId = selector.getPageId();
+        // Part pagePart = rootPart.getChildOfIdPropertyValue(pageId, true);
+        // if (pagePart != null) {
+        // String partId = selector.getPartId();
+        // Part part = rootPart.getChildOfIdPropertyValue(partId, true);
+        // if (part != null) {
+        // part.removeSelector(selector.getSelectorName(), false);
+        // }
+        // }
+        // }
     }
 
     private DescriptorManager getDescriptorManager() {
@@ -1005,6 +1069,10 @@ public class PageDesigner extends GraphicalEditor implements CommandStackListene
 
     @Override
     public void dispose() {
+        if (controller != null) {
+            controller.removeListener();
+        }
+
         if (appManager != null) {
             appManager.removePageListener(this);
         }
@@ -1144,6 +1212,10 @@ public class PageDesigner extends GraphicalEditor implements CommandStackListene
         toolbar.adjustLayout(false);
     }
 
+    public void setShowingSize(List<Device> devices, NScreenItem nsItem) {
+        toolbar.setResolution(devices, nsItem);
+    }
+
     public void setLandscape(boolean landscape) {
         designer.setLandscape(landscape);
         preview.setLandscape(landscape);
@@ -1331,6 +1403,9 @@ public class PageDesigner extends GraphicalEditor implements CommandStackListene
             e.printStackTrace();
         }
 
+        String oldPath = cssFile.getCssFilePath();
+        String newPath = oldPath.replaceAll("%20", " ");
+        cssFile.setCssFilePath(newPath);
         return cssFile;
     }
 
@@ -1666,5 +1741,4 @@ public class PageDesigner extends GraphicalEditor implements CommandStackListene
             updateActions(getStackActions());
         }
     }
-
 }
index a108524..1108ef8 100644 (file)
@@ -46,11 +46,11 @@ import org.tizen.webuibuilder.model.filedata.PageFileData;
 import org.tizen.webuibuilder.model.io.CodeGenerator;
 import org.tizen.webuibuilder.model.io.file.PageReader;
 import org.tizen.webuibuilder.model.io.file.PageWriter;
+import org.tizen.webuibuilder.model.nscreen.NScreenModel;
 import org.tizen.webuibuilder.model.page.PageDataEvent;
 import org.tizen.webuibuilder.model.project.ProjectManager;
 import org.tizen.webuibuilder.ui.editor.texteditor.TextEditor;
 import org.tizen.webuibuilder.ui.editor.texteditor.TextEditorForAppXML;
-import org.tizen.webuibuilder.ui.views.nscreen.model.NScreenModel;
 
 
 public class PageDesignerForAppXML extends PageDesigner {
@@ -150,16 +150,22 @@ public class PageDesignerForAppXML extends PageDesigner {
 
                     model.setFileName(cssPath.substring(cssPath.lastIndexOf(IPath.SEPARATOR) + 1));
                     cssFile = loadCssFile(cssPath);
+                    if (cssFile != null) {
+                        pageData.addCssFile(cssFile);
+                    }
                 } else {
-                    String cssPath =
-                            filePath.substring(0, filePath.lastIndexOf(IPath.SEPARATOR) + 1);
-                    cssPath += model.getFileName();
-                    cssFile = loadCssFile(cssPath);
-                }
-                if (cssFile != null) {
-                    cssFile.setNScreenModel(model);
-                    pageData.addCssFile(cssFile);
+//                    for ( String page : model.getEnalbePages() ) {
+//                        String cssPath =
+//                                filePath.substring(0, filePath.lastIndexOf(IPath.SEPARATOR) + 1);
+//                        cssPath += page + "." + model.getFileName();
+//                        cssFile = loadCssFile(cssPath);
+//                        if (cssFile != null) {
+//                            pageData.addCssFile(cssFile);
+//                        }
+//                    }
                 }
+                
+                appManager.getNScreenModelManger().addNScreenModel( model );
             }
 
             setCssFileToModel(pageData.getCurrentCssFile());
@@ -192,10 +198,11 @@ public class PageDesignerForAppXML extends PageDesigner {
         PageFileData pageFileData =
                 new PageFileData(pageData.getName(), pageData.getVersion(), pageData.getRootPart(),
                                  null);
-        for (CssFile cssFile : pageData.getCssFiles()) {
-            pageFileData.getNscreenModelList().add(cssFile.getNScreenModel());
+        
+        for ( NScreenModel model : appManager.getNScreenModelManger().getNScreenModels() ) {
+            pageFileData.getNscreenModelList().add( model );
         }
-
+        
         PageWriter.writeToFile(pageFileData, filePath);
         IFile file = getFile();
         file.refreshLocal(IResource.DEPTH_ZERO, null);
index 06573ed..38c437f 100644 (file)
@@ -26,6 +26,8 @@ package org.tizen.webuibuilder.ui.editor;
 import java.io.File;
 import java.io.IOException;
 import java.io.StringBufferInputStream;
+import java.util.ArrayList;
+import java.util.List;
 
 import org.eclipse.core.resources.IFile;
 import org.eclipse.core.resources.IResource;
@@ -50,6 +52,10 @@ import org.tizen.webuibuilder.model.app.AppManagerForHTML;
 import org.tizen.webuibuilder.model.css.CssFile;
 import org.tizen.webuibuilder.model.html.io.HtmlWriter;
 import org.tizen.webuibuilder.model.io.CodeGenerator;
+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.model.nscreen.NScreenModelController;
 import org.tizen.webuibuilder.model.page.PageData;
 import org.tizen.webuibuilder.model.page.PageDataForHTML;
 import org.tizen.webuibuilder.model.project.ProjectManager;
@@ -57,7 +63,8 @@ import org.tizen.webuibuilder.ui.editor.texteditor.ITextEditorListener;
 import org.tizen.webuibuilder.ui.editor.texteditor.TextEditor;
 import org.tizen.webuibuilder.ui.editor.texteditor.TextEditorEvent;
 import org.tizen.webuibuilder.ui.editor.texteditor.TextEditorForHTML;
-import org.tizen.webuibuilder.ui.views.nscreen.model.NScreenModel;
+
+import com.phloc.commons.io.file.filter.FilenameFilterEndsWith;
 
 
 @SuppressWarnings("deprecation")
@@ -82,6 +89,8 @@ public class PageDesignerForHTML extends PageDesigner implements ITextEditorList
         editDomain = new DefaultEditDomain(this);
         setEditDomain(editDomain);
 
+        controller = new NScreenModelController(appManager);
+
         setSite(site);
         setInput(input);
         getCommandStack().addCommandStackListener(this);
@@ -120,49 +129,107 @@ public class PageDesignerForHTML extends PageDesigner implements ITextEditorList
         appManager.loadFullPath(filePath);
         // HtmlMetaReader.read(appManager, "index.meta.xml");
 
-        pageData = appManager.getPageData(0);
-
         appManager.addPageListener(this);
 
-        if (pageData != null) {
-            // rootPart = pageData.getRootPart();
-            // rootPart = ((AppManagerForHTML)appManager).getBaseRootPart();
-            rootPart = ((AppManagerForHTML) appManager).getPageDataSet().getBaseRootPart();
-            setCssFileToModel(pageData.getCurrentCssFile());
-
-            bindingAnimatorModel(rootPart);
-
-            /* load css file */
-            if (pageData.getCssFiles().size() == 0) {
-                // make directories
-                String cssFileName = "common.css";
-                String cssPath = appManager.getCssFolder() + IPath.SEPARATOR + cssFileName;
-
-                // String projectFolder = project.getLocation().toString();
-                // cssFileName = cssPath.replace(projectFolder,
-                // BuilderConstants.DOT);
-
-                try {
-                    File newCSSFile = new File(cssPath);
-                    if (!newCSSFile.exists()) {
-                        File dir = newCSSFile.getParentFile();
-                        dir.mkdirs();
-                        newCSSFile.createNewFile();
+        /* load css file */
+        // if (pageData.getCssFiles().size() == 0) {
+        // pageData = appManager.getPageData(0);
+        String cssFolderPath = appManager.getCssFolder();
+        File cssDir = new File(cssFolderPath);
+        FilenameFilterEndsWith filter = new FilenameFilterEndsWith(".css");
+        File[] files = cssDir.listFiles(filter);
+        if (!appManager.getPageDataSet().getPages().isEmpty()) {
+            for (PageData page : appManager.getPageDataSet().getPages()) {
+                String pageId = page.getName();
+                List<File> pageCssFile = new ArrayList<File>();
+                for (int i = 0; i < files.length; i++) {
+                    if (files[i].getName().contains(pageId)) {
+                        pageCssFile.add(files[i]);
                     }
-                } catch (IOException e) {
-                    e.printStackTrace();
                 }
 
-                CssFile cssFile = loadCssFile(cssPath);
+                if (pageCssFile.isEmpty()) {
+                    String cssFileName =
+                    // pageData.getName() + BuilderConstants.UNDERBAR
+                            page.getName() + BuilderConstants.UNDERBAR
+                                    + BuilderConstants.NSCREENCOMMON
+                                    + BuilderConstants.CSS_EXTENSION;
+                    String cssPath = appManager.getCssFolder() + IPath.SEPARATOR + cssFileName;
+
+                    // String projectFolder = project.getLocation().toString();
+                    // cssFileName = cssPath.replace(projectFolder,
+                    // BuilderConstants.DOT);
+
+                    try {
+                        File newCSSFile = new File(cssPath);
+                        if (!newCSSFile.exists()) {
+                            File dir = newCSSFile.getParentFile();
+                            dir.mkdirs();
+                            newCSSFile.createNewFile();
+                        }
+                    } catch (IOException e) {
+                        e.printStackTrace();
+                    }
 
-                NScreenModel model = new NScreenModel("Common Style", 0, 0, cssFileName);
-                cssFile.setNScreenModel(model);
-                pageData.addCssFile(cssFile);
+                    CssFile cssFile = loadCssFile(cssPath);
+                    // appManager.getNScreenModelManger().getCommonNscreen().setFileName(cssFileName);
+
+                    // pageData.addCssFile(cssFile);
+                    page.addCssFile(cssFile);
+
+                    // pageData.addPageListener(this);
+                    page.addPageListener(this);
+
+                    // setCssFileToModel(pageData.getCurrentCssFile());
+                    setCssFileToModel(page.getCurrentCssFile());
+                } else {
+                    for (File f : pageCssFile) {
+                        if (f.getName().contains(BuilderConstants.NSCREENCOMMON)) {
+                            CssFile cssFile = loadCssFile(f.getPath());
+                            page.addCssFile(cssFile);
+                            pageCssFile.remove(f);
+                            break;
+                        }
+                    }
 
-                pageData.addPageListener(this);
+                    for (File f : pageCssFile) {
+                        CssFile cssFile = loadCssFile(f.getPath());
+                        page.addCssFile(cssFile);
+                    }
+                }
 
-                setCssFileToModel(pageData.getCurrentCssFile());
+                // rootPart = pageData.getRootPart();
+                // rootPart = ((AppManagerForHTML)appManager).getBaseRootPart();
+                rootPart = ((AppManagerForHTML) appManager).getPageDataSet().getBaseRootPart();
+                bindingAnimatorModel(rootPart);
+
+                // setCssFileToModel(pageData.getCurrentCssFile());
+
+                Device device = DeviceManager.getDeviceManager().getDevices().get(0);
+                // NScreenModel commonModel = appManager.getNScreenModelManger().getCommonNscreen();
+                List<NScreenModel> cssModels =
+                        appManager.getNScreenModelManger().getNScreenModelsForDevice(device);
+
+                List<CssFile> applyList = new ArrayList<CssFile>();
+                List<CssFile> list = page.getCssFiles();
+                for (NScreenModel model : cssModels) {
+                    String cssFileName = page.getName() + "_" + model.getName() + ".css";
+                    int size = list.size();
+                    for (int i = 0; i < size; i++) {
+                        CssFile cssFileItem = list.get(i);
+                        String fileName = new File(cssFileItem.getCssFilePath()).getName();
+                        if (fileName.equals(cssFileName)) {
+                            applyList.add(cssFileItem);
+                            break;
+                        }
+                    }
+                }
+
+                for (int i = 0; i < applyList.size(); i++) {
+                    setCssFileToModel(applyList.get(i));
+                }
             }
+            pageData = appManager.getPageDataSet().getPages().get(0);
         } else {
             rootPart = null;
         }
@@ -253,7 +320,7 @@ public class PageDesignerForHTML extends PageDesigner implements ITextEditorList
 
         AnimatorModelManager manager = appManager.getAnimatorModelManager();
         manager.updateAnimatorModel(getRootPart());
-        manager.setPagePart((AnimatorPagePart)getRootPart().getChildren().get(0));
+        manager.setPagePart((AnimatorPagePart) getRootPart().getChildren().get(0));
 
         AnimatorBrowserViewer animatorViewer = getAnimatorViewer();
         if (animatorViewer != null) {
index 3e17a30..c5db503 100644 (file)
@@ -42,11 +42,8 @@ import org.eclipse.swt.widgets.Menu;
 import org.eclipse.swt.widgets.MenuItem;
 import org.eclipse.swt.widgets.ToolBar;
 import org.eclipse.swt.widgets.ToolItem;
-import org.eclipse.ui.IPerspectiveRegistry;
 import org.eclipse.ui.ISelectionListener;
 import org.eclipse.ui.IWorkbenchPart;
-import org.eclipse.ui.IWorkbenchWindow;
-import org.eclipse.ui.PlatformUI;
 import org.tizen.webuibuilder.BuilderConstants;
 import org.tizen.webuibuilder.animator.AnimatorConstants;
 import org.tizen.webuibuilder.animator.gef.command.AnimationCreateCommand;
@@ -58,7 +55,12 @@ import org.tizen.webuibuilder.gef.editparts.DesignerEditPart;
 import org.tizen.webuibuilder.gef.viewer.HoverBrowserRulerComposite;
 import org.tizen.webuibuilder.model.Part;
 import org.tizen.webuibuilder.model.app.AppManager;
+import org.tizen.webuibuilder.model.nscreen.Device;
+import org.tizen.webuibuilder.model.nscreen.Device.Orientation;
+import org.tizen.webuibuilder.model.nscreen.DeviceManager;
 import org.tizen.webuibuilder.nl.BuilderMessages;
+import org.tizen.webuibuilder.ui.views.nscreen.NScreenHistory;
+import org.tizen.webuibuilder.ui.views.nscreen.NScreenItem;
 import org.tizen.webuibuilder.utility.Platform;
 import org.tizen.webuibuilder.utility.ResourceManager;
 
@@ -87,16 +89,18 @@ public class PageDesignerToolbar implements ISelectionListener {
     private ResolutionManger resolution;
     private ScreenSize currentScreen;
     private ScaleData scaleData;
+    private Device defaultDevice = null;
 
     private boolean isLandscape;
     private boolean isFiting;
 
+    private NScreenHistory nscreen = null;
     private boolean PLUS = true;
     private boolean MINUS = false;
     private final int MARGIN = 15;
 
-//    private ToolItem animatorPerspectiveItem;
-//    private ToolItem designerPerspectiveItem;
+    // private ToolItem animatorPerspectiveItem;
+    // private ToolItem designerPerspectiveItem;
     private ToolItem animatorAnimationItem;
     private Part currentSelectedPart = null;
 
@@ -118,8 +122,9 @@ public class PageDesignerToolbar implements ISelectionListener {
         setResolution();
 
         isLandscape = false;
-        isFiting = true;
-
+        isFiting = false;
+        nscreen = new NScreenHistory();
+        nscreen.setModelName(BuilderConstants.NSCREENCOMMON);
         widgetEvent();
 
         AnimatorUtils.getWorkbenchWindow().getSelectionService().addSelectionListener(this);
@@ -130,6 +135,13 @@ 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);
     }
 
     public void dispose() {
@@ -154,11 +166,63 @@ public class PageDesignerToolbar implements ISelectionListener {
         // ProjectManager projectManger =
         // ProjectManager.getProjectManager(project);
 
+        // if (!resolution.getDeviceMode().equals(appManager.getFrameworkScale())) {
+        // resolution.setScreeSizesFromDeviceMode(appManager.getFrameworkScale());
+        // screenSize.setEnabled(resolution.getEnable());
+        // resetMenuPart();
+        // }
+
         if (!resolution.getDeviceMode().equals(appManager.getFrameworkScale())) {
-            resolution.setScreeSizesFromDeviceMode(appManager.getFrameworkScale());
-            screenSize.setEnabled(resolution.getEnable());
+            setResolution(DeviceManager.getDeviceManager().getDevices(), null);
             resetMenuPart();
         }
+
+    }
+
+    public void setResolution(List<Device> devices, NScreenItem nsItem) {
+        if (nsItem != null) {
+            nscreen = nsItem.getNScreenHistory();
+        }
+        Device device = null;
+
+        if (devices.isEmpty()) {
+            devices.add(defaultDevice);
+        }
+        resolution
+                .setScreeSizesFromNScreen(devices, mainEditor.getAppManager().getFrameworkScale());
+        screenSize.setEnabled(resolution.getEnable());
+        if (null != nscreen && nscreen.getLastResolution() != null) {
+            currentScreen = resolution.getScreenSize(nscreen.getLastResolution());
+            device = resolution.getDevice(nscreen.getLastResolution());
+        } else {
+            currentScreen = resolution.getScreenSize(0);
+            if (devices != null && !devices.isEmpty()) {
+                device = devices.get(0);
+            }
+        }
+        screenSizeText.setText(currentScreen.getScreenSize());
+
+        if (null != mainEditor.getViewer()) {
+            if (nscreen != null) {
+                if (nscreen.getScale() <= 0f || isFiting) {
+                    adjustLayout(true);
+                } else {
+                    mainEditor.zoomBrowser(nscreen.getScale());
+                    float value = nscreen.getScale();
+                    int intValue = 0;
+                    value = value * 100;
+                    intValue = (int) value;
+                    scaleValueText.setText("" + intValue);
+                }
+            } else {
+                resetMenuPart();
+                resetScreen();
+            }
+
+            mainEditor.setNscreenIndex2(device, nscreen);
+            mainEditor.setShowingSize(currentScreen.getWidth(), currentScreen.getHeight());
+            mainEditor.scrollToCenter();
+        }
     }
 
     private void draw() {
@@ -241,17 +305,17 @@ public class PageDesignerToolbar implements ISelectionListener {
 
         separator = new ToolItem(toolBar, SWT.SEPARATOR);
         separator.setWidth(50);
-//
-//        animatorPerspectiveItem = new ToolItem(toolBar, SWT.PUSH);
-//        animatorPerspectiveItem.setImage(ResourceManager.getImage(BuilderConstants.ICON_DIR,
-//                                                                  "video_16.png"));
-//        animatorPerspectiveItem.setToolTipText(BuilderMessages.ANIMATORMODE);
-//
-//        designerPerspectiveItem = new ToolItem(toolBar, SWT.PUSH);
-//        designerPerspectiveItem.setImage(ResourceManager.getImage(BuilderConstants.ICON_DIR,
-//                                                                  "Add_New_Page.png"));
-//        designerPerspectiveItem.setToolTipText(BuilderMessages.DESIGNERMODE);
-//        designerPerspectiveItem.setEnabled(false);
+        //
+        // animatorPerspectiveItem = new ToolItem(toolBar, SWT.PUSH);
+        // animatorPerspectiveItem.setImage(ResourceManager.getImage(BuilderConstants.ICON_DIR,
+        // "video_16.png"));
+        // animatorPerspectiveItem.setToolTipText(BuilderMessages.ANIMATORMODE);
+        //
+        // designerPerspectiveItem = new ToolItem(toolBar, SWT.PUSH);
+        // designerPerspectiveItem.setImage(ResourceManager.getImage(BuilderConstants.ICON_DIR,
+        // "Add_New_Page.png"));
+        // designerPerspectiveItem.setToolTipText(BuilderMessages.DESIGNERMODE);
+        // designerPerspectiveItem.setEnabled(false);
 
         scaleValue.addSelectionListener(new SelectionAdapter() {
             @Override
@@ -272,7 +336,9 @@ public class PageDesignerToolbar implements ISelectionListener {
 
     public void resetScreen() {
         // currentScreen = resolution.getScreenSize(0);
-        mainEditor.setShowingSize(currentScreen.getWidth(), currentScreen.getHeight());
+        if (null != mainEditor.getViewer()) {
+            mainEditor.setShowingSize(currentScreen.getWidth(), currentScreen.getHeight());
+        }
     }
 
     private void resetMenuPart() {
@@ -329,6 +395,8 @@ public class PageDesignerToolbar implements ISelectionListener {
                 public void widgetSelected(SelectionEvent e) {
                     screenSizeText.setText(item.getText());
                     currentScreen = resolution.getScreenSize(item.getText());
+                    nscreen.setLastResolution(item.getText());
+                    mainEditor.setNscreenIndex2(resolution.getDevice(item.getText()), null);
                     mainEditor.setShowingSize(currentScreen.getWidth(), currentScreen.getHeight());
                 }
             });
@@ -348,6 +416,9 @@ public class PageDesignerToolbar implements ISelectionListener {
                     float value = currentValue;
                     value = value / 100;
                     mainEditor.zoomBrowser(value);
+                    if (nscreen != null) {
+                        nscreen.setScale(value);
+                    }
                 }
             });
         }
@@ -356,7 +427,7 @@ public class PageDesignerToolbar implements ISelectionListener {
     private void insertPreDefinedAnimations(Menu menu) {
         // IProject project = ((FileEditorInput)
         // mainEditor.getEditorInput()).getFile().getProject();
-        AnimatorDescriptorManager manager = AnimatorDescriptorManager.getInstance(appManager);        
+        AnimatorDescriptorManager manager = AnimatorDescriptorManager.getInstance(appManager);
 
         List<CssAnimationDescriptor> cssAnimations = manager.getCssAnimations();
         MenuItem preSubMenuItem = null;
@@ -484,6 +555,9 @@ public class PageDesignerToolbar implements ISelectionListener {
     private void setEditorZoom(int scale) {
         float zoomScale = (float) (scale / 100.0);
         mainEditor.zoomBrowser(zoomScale);
+        if (nscreen != null) {
+            nscreen.setScale(zoomScale);
+        }
     }
 
     private float autoFit(int margin) {
@@ -519,8 +593,7 @@ public class PageDesignerToolbar implements ISelectionListener {
                 editor = composite.getSize();
             }
 
-        }
-        else if (tabMode.endsWith(BuilderMessages.TABTEXTANIMATOR)) {
+        } else if (tabMode.endsWith(BuilderMessages.TABTEXTANIMATOR)) {
             Composite composite = mainEditor.getAnimatorComposite();
             if (composite instanceof HoverBrowserRulerComposite) {
                 Rectangle clientArea = ((HoverBrowserRulerComposite) composite).getEditorBounds();
@@ -569,6 +642,9 @@ public class PageDesignerToolbar implements ISelectionListener {
     public void adjustLayout(boolean force) {
         if (force || isFiting) {
             float value = autoFit(MARGIN);
+            if (nscreen != null) {
+                nscreen.setScale(value);
+            }
             int intValue = 0;
             value = value * 100;
             intValue = (int) value;
@@ -590,37 +666,37 @@ public class PageDesignerToolbar implements ISelectionListener {
 
             }
         });
-//        animatorPerspectiveItem.addSelectionListener(new SelectionAdapter() {
-//            @Override
-//            public void widgetSelected(SelectionEvent e) {
-//                IWorkbenchWindow activeWorkbenchWindow =
-//                        PlatformUI.getWorkbench().getActiveWorkbenchWindow();
-//                IPerspectiveRegistry perspectiveRegistry =
-//                        PlatformUI.getWorkbench().getPerspectiveRegistry();
-//
-//                activeWorkbenchWindow
-//                        .getActivePage()
-//                        .setPerspective(perspectiveRegistry
-//                                                .findPerspectiveWithLabel(BuilderMessages.ANIMATOR_PERSPECTIVE));
-//                changeToAnimatorPerspective();
-//            }
-//        });
-//
-//        designerPerspectiveItem.addSelectionListener(new SelectionAdapter() {
-//            @Override
-//            public void widgetSelected(SelectionEvent e) {
-//                IWorkbenchWindow activeWorkbenchWindow =
-//                        PlatformUI.getWorkbench().getActiveWorkbenchWindow();
-//                IPerspectiveRegistry perspectiveRegistry =
-//                        PlatformUI.getWorkbench().getPerspectiveRegistry();
-//
-//                activeWorkbenchWindow
-//                        .getActivePage()
-//                        .setPerspective(perspectiveRegistry
-//                                                .findPerspectiveWithLabel(BuilderMessages.DESIGNER_PERSPECTIVE));
-//                changeToDesignerPerspective();
-//            }
-//        });
+        // animatorPerspectiveItem.addSelectionListener(new SelectionAdapter() {
+        // @Override
+        // public void widgetSelected(SelectionEvent e) {
+        // IWorkbenchWindow activeWorkbenchWindow =
+        // PlatformUI.getWorkbench().getActiveWorkbenchWindow();
+        // IPerspectiveRegistry perspectiveRegistry =
+        // PlatformUI.getWorkbench().getPerspectiveRegistry();
+        //
+        // activeWorkbenchWindow
+        // .getActivePage()
+        // .setPerspective(perspectiveRegistry
+        // .findPerspectiveWithLabel(BuilderMessages.ANIMATOR_PERSPECTIVE));
+        // changeToAnimatorPerspective();
+        // }
+        // });
+        //
+        // designerPerspectiveItem.addSelectionListener(new SelectionAdapter() {
+        // @Override
+        // public void widgetSelected(SelectionEvent e) {
+        // IWorkbenchWindow activeWorkbenchWindow =
+        // PlatformUI.getWorkbench().getActiveWorkbenchWindow();
+        // IPerspectiveRegistry perspectiveRegistry =
+        // PlatformUI.getWorkbench().getPerspectiveRegistry();
+        //
+        // activeWorkbenchWindow
+        // .getActivePage()
+        // .setPerspective(perspectiveRegistry
+        // .findPerspectiveWithLabel(BuilderMessages.DESIGNER_PERSPECTIVE));
+        // changeToDesignerPerspective();
+        // }
+        // });
 
         leftArrowButton.addSelectionListener(new SelectionAdapter() {
             @Override
@@ -639,6 +715,7 @@ public class PageDesignerToolbar implements ISelectionListener {
         fitButton.addSelectionListener(new SelectionAdapter() {
             @Override
             public void widgetSelected(SelectionEvent e) {
+                // useless isFiting value
                 isFiting = fitButton.getSelection();
                 adjustLayout(true);
             }
@@ -653,15 +730,15 @@ public class PageDesignerToolbar implements ISelectionListener {
         animatorAnimationItem.setEnabled(false);
     }
 
-//    public void changeToAnimatorPerspective() {
-//        designerPerspectiveItem.setEnabled(true);
-//        animatorPerspectiveItem.setEnabled(false);
-//    }
-//
-//    public void changeToDesignerPerspective() {
-//        designerPerspectiveItem.setEnabled(false);
-//        animatorPerspectiveItem.setEnabled(true);
-//    }
+    // public void changeToAnimatorPerspective() {
+    // designerPerspectiveItem.setEnabled(true);
+    // animatorPerspectiveItem.setEnabled(false);
+    // }
+    //
+    // public void changeToDesignerPerspective() {
+    // designerPerspectiveItem.setEnabled(false);
+    // animatorPerspectiveItem.setEnabled(true);
+    // }
 
     @Override
     public void selectionChanged(IWorkbenchPart part, ISelection selection) {
@@ -669,11 +746,11 @@ public class PageDesignerToolbar implements ISelectionListener {
             Object element = ((StructuredSelection) selection).getFirstElement();
             if ((element instanceof DesignerEditPart)) {
                 Object model = ((DesignerEditPart) element).getModel();
-                if(model instanceof Part){
-                       Part modelPart = (Part)model;
-                       if (!modelPart.isDocumentPart()) {
-                           currentSelectedPart = (Part) model;
-                       }
+                if (model instanceof Part) {
+                    Part modelPart = (Part) model;
+                    if (!modelPart.isDocumentPart()) {
+                        currentSelectedPart = (Part) model;
+                    }
                 }
             }
         }
@@ -686,5 +763,4 @@ public class PageDesignerToolbar implements ISelectionListener {
     public void setCommandStack(CommandStack commandStack) {
         this.commandStack = commandStack;
     }
-
 }
index dfb84b0..f0a8d16 100644 (file)
 
 package org.tizen.webuibuilder.ui.editor;
 
+import java.util.ArrayList;
 import java.util.LinkedList;
 import java.util.List;
 
+import org.tizen.webuibuilder.model.nscreen.Device;
+import org.tizen.webuibuilder.model.nscreen.NScreenModel;
+
 
 public class ResolutionManger {
     private List<ScreenSize> mList;
+    private List<Device> devices = null;
     private boolean enable;
     private String curDeviceMode = new String("");
 
@@ -55,7 +60,10 @@ public class ResolutionManger {
     }
 
     public ScreenSize getScreenSize(int index) {
-        return this.mList.get(index);
+        if (mList != null && !mList.isEmpty()) {
+            return this.mList.get(index);
+        }
+        return null;
     }
 
     public ScreenSize getScreenSize(String screen) {
@@ -124,8 +132,42 @@ public class ResolutionManger {
 
     }
 
+    public void setScreeSizesFromNScreen(List<Device> devices, String deviceMode) {
+        if (devices == null || deviceMode == null) {
+            return;
+        }
+
+        curDeviceMode = deviceMode;
+        removeAll();
+
+        if (deviceMode.equals("device-width")) {
+            for (Device device : devices) {
+                // StringBuffer deviceInfo = new StringBuffer();
+                // deviceInfo.append(device.getName()).append(" (").append(device.getDeviceWidth())
+                // .append("x").append(device.getDeviceHeight()).append(")");
+                // addScreenSize(device.getDeviceWidth(), device.getDeviceHeight(),
+                // deviceInfo.toString());
+                addScreenSize(device);
+                enable = true;
+            }
+        }
+
+        if (deviceMode.equals("480")) {
+            removeAll();
+            addScreenSize(480, 800, "Static 480X800");
+            enable = false;
+        }
+
+        if (deviceMode.equals("720")) {
+            removeAll();
+            addScreenSize(720, 1280, "Static 720X1280");
+            enable = false;
+        }
+    }
+
     private void init() {
         this.mList = new LinkedList<ScreenSize>();
+        this.devices = new ArrayList<Device>();
         this.enable = true;
     }
 
@@ -133,7 +175,21 @@ public class ResolutionManger {
         mList.add(new ScreenSize(width, height, resolutionText));
     }
 
+    private void addScreenSize(Device device) {
+        addScreenSize(device.getDeviceWidth(), device.getDeviceHeight(), device.getDisplayName());
+        devices.add(device);
+    }
+
     public String getDeviceMode() {
         return curDeviceMode;
     }
+
+    public Device getDevice(String resolutionText) {
+        for (Device device : devices) {
+            if (device.getDisplayName().equals(resolutionText)) {
+                return device;
+            }
+        }
+        return null;
+    }
 }
diff --git a/org.tizen.webuibuilder/src/org/tizen/webuibuilder/ui/views/nscreen/FontUtil.java b/org.tizen.webuibuilder/src/org/tizen/webuibuilder/ui/views/nscreen/FontUtil.java
new file mode 100644 (file)
index 0000000..0c20352
--- /dev/null
@@ -0,0 +1,89 @@
+
+
+package org.tizen.webuibuilder.ui.views.nscreen;
+
+import org.eclipse.jface.resource.FontRegistry;
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.graphics.Font;
+import org.eclipse.swt.graphics.FontData;
+import org.eclipse.swt.graphics.GC;
+import org.eclipse.swt.graphics.Point;
+import org.eclipse.ui.PlatformUI;
+import org.tizen.common.util.OSChecker;
+
+
+public class FontUtil {
+    private static FontRegistry fontRegistry = new FontRegistry();
+    private static final Font defaultFont = getDADefaultFont();
+
+    public static final Font NSCREEN_TITLE =
+            getFont("nscreen_title", setDefaultFontStyleAndSize(SWT.ITALIC, 15));//$NON-NLS-1$
+    // mac 11
+
+    public static final Font COMMON = getFont("nscreen_common", resizeDefaultFont(14, 1));//$NON-NLS-1$
+    // mac 11
+
+    public static final Font ORIENTATION = getFont("nscreen_orientation", resizeDefaultFont(14, 1));//$NON-NLS-1$
+    // mac 11
+
+    public static final Font PIXELRATIO = getFont("nscreen_pixelratio", resizeDefaultFont(14, 1));//$NON-NLS-1$
+    // mac 11
+    public static final Font DEVICE = getFont("nscreen_device", resizeDefaultFont(12, 1));//$NON-NLS-1$
+    // mac 11
+
+
+    private static Font getFont(String fontName, FontData[] fontData) {
+        if (!fontRegistry.hasValueFor(fontName)) {
+            fontRegistry.put(fontName, fontData);
+        }
+        return fontRegistry.get(fontName);
+    }
+
+    public static FontData[] resizeDefaultFont(int size, int mac) {
+        if (OSChecker.isMAC()) {
+            return resizeDefaultFont(size + mac);
+        }
+        return resizeDefaultFont(size);
+    }
+
+    public static FontData[] resizeDefaultFont(int size) {
+        FontData[] fontData = defaultFont.getFontData();
+        for (int i = 0; i < fontData.length; i++) {
+            fontData[i].setHeight(size);
+        }
+        return fontData;
+    }
+
+    public static FontData[] setDefaultFontStyle(int style) {
+        FontData[] fontData = defaultFont.getFontData();
+        for (int i = 0; i < fontData.length; i++) {
+            fontData[i].setStyle(style);
+        }
+        return fontData;
+    }
+
+    public static FontData[] setDefaultFontStyleAndSize(int style, int size) {
+        FontData[] fontData = defaultFont.getFontData();
+        for (int i = 0; i < fontData.length; i++) {
+            fontData[i].setStyle(style);
+            fontData[i].setHeight(size);
+        }
+        return fontData;
+    }
+
+    public static Font getDADefaultFont() {
+        String fontName = null;
+        if (OSChecker.isLinux()) {
+            fontName = "Dejavu Sans";//$NON-NLS-1$
+        } else if (OSChecker.isWindows()) {
+            fontName = "Verdana";//$NON-NLS-1$
+        } else {
+            return PlatformUI.getWorkbench().getDisplay().getSystemFont();
+        }
+        return getFont("ex_font", new FontData[] { new FontData(fontName, 9, SWT.NORMAL) }); //$NON-NLS-1$
+    }
+
+    public static Point getTextArea(String text, GC gc) {
+        return gc.textExtent(text, SWT.DRAW_MNEMONIC);
+    }
+}
diff --git a/org.tizen.webuibuilder/src/org/tizen/webuibuilder/ui/views/nscreen/INScreenDrawRenderer.java b/org.tizen.webuibuilder/src/org/tizen/webuibuilder/ui/views/nscreen/INScreenDrawRenderer.java
new file mode 100644 (file)
index 0000000..19cda0f
--- /dev/null
@@ -0,0 +1,14 @@
+
+
+package org.tizen.webuibuilder.ui.views.nscreen;
+
+import org.eclipse.swt.graphics.GC;
+import org.eclipse.swt.graphics.Image;
+import org.eclipse.swt.widgets.Canvas;
+import org.tizen.webuibuilder.model.nscreen.NScreenModel;
+
+
+public interface INScreenDrawRenderer {
+    public void draw(GC gc, Canvas canvas, int state, boolean isSelected, boolean isEnabled,
+                     Image thumb, NScreenModel model, String pageId);
+}
diff --git a/org.tizen.webuibuilder/src/org/tizen/webuibuilder/ui/views/nscreen/NScreenAddCommand.java b/org.tizen.webuibuilder/src/org/tizen/webuibuilder/ui/views/nscreen/NScreenAddCommand.java
deleted file mode 100644 (file)
index fdf46c7..0000000
+++ /dev/null
@@ -1,103 +0,0 @@
-/*
- * UI Builder
- *
- * Copyright (c) 2000 - 2014 Samsung Electronics Co., Ltd. All rights reserved.
- *
- * 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.webuibuilder.ui.views.nscreen;
-
-import java.io.File;
-import java.io.IOException;
-import java.util.List;
-
-import org.eclipse.gef.commands.Command;
-import org.tizen.webuibuilder.model.css.CssFile;
-
-
-/**
- * A class that implements Command. This class run an operation to add new Nscreen.
- */
-public class NScreenAddCommand extends Command {
-    private List<CssFile> mList = null;
-    private CssFile mModel = null;
-    private NScreenList mNscreenList = null;
-    private NScreenListItem mItem = null;
-
-    public NScreenAddCommand(List<CssFile> list, CssFile model, NScreenList screenList) {
-        mList = list;
-        mModel = model;
-        mNscreenList = screenList;
-    }
-
-    @Override
-    /*
-     * (non-Javadoc)
-     * 
-     * @see org.eclipse.gef.commands.Command#execute()
-     */
-    public void execute() {
-        mList.add(mModel);
-
-        try {
-            File newCSSFile = new File(mModel.getCssFilePath());
-            if (!newCSSFile.exists()) {
-                File dir = newCSSFile.getParentFile();
-                dir.mkdirs();
-                newCSSFile.createNewFile();
-            }
-        } catch (IOException e) {
-            e.printStackTrace();
-        }
-
-        if (mNscreenList != null && !mNscreenList.getControl().isDisposed()) {
-            mItem = mNscreenList.addItem(mModel, false);
-            mNscreenList.layout();
-        }
-    }
-
-    @Override
-    /*
-     * (non-Javadoc)
-     * 
-     * @see org.eclipse.gef.commands.Command#redo()
-     */
-    public void redo() {
-        execute();
-    }
-
-    @Override
-    /*
-     * (non-Javadoc)
-     * 
-     * @see org.eclipse.gef.commands.Command#undo()
-     */
-    public void undo() {
-        File nscreenCssFile = new File(mModel.getCssFilePath());
-        if (nscreenCssFile.exists()) {
-            nscreenCssFile.delete();
-        }
-        mList.remove(mModel);
-        if (mNscreenList != null && !mNscreenList.getControl().isDisposed()) {
-            mNscreenList.removeItem(mItem);
-            mNscreenList.layout();
-        }
-    }
-
-}
diff --git a/org.tizen.webuibuilder/src/org/tizen/webuibuilder/ui/views/nscreen/NScreenBaseComposite.java b/org.tizen.webuibuilder/src/org/tizen/webuibuilder/ui/views/nscreen/NScreenBaseComposite.java
new file mode 100644 (file)
index 0000000..e9cac7e
--- /dev/null
@@ -0,0 +1,258 @@
+
+
+package org.tizen.webuibuilder.ui.views.nscreen;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.custom.ScrolledComposite;
+import org.eclipse.swt.events.ControlAdapter;
+import org.eclipse.swt.events.ControlEvent;
+import org.eclipse.swt.events.PaintEvent;
+import org.eclipse.swt.events.PaintListener;
+import org.eclipse.swt.events.SelectionAdapter;
+import org.eclipse.swt.events.SelectionEvent;
+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.Menu;
+import org.eclipse.swt.widgets.MenuItem;
+import org.tizen.webuibuilder.animator.ui.views.timeline.common.ColorResource;
+import org.tizen.webuibuilder.model.nscreen.NScreenModel.NScreenType;
+import org.tizen.webuibuilder.ui.views.nscreen.model.NScreenPageModel;
+
+
+public class NScreenBaseComposite extends ScrolledComposite {
+
+    private List<NScreenGroup> groups = new ArrayList<NScreenGroup>();
+    private static int SEPARATOR_HEIGHT = 10;
+    private Composite comp = null;
+    private Menu popup = null;
+    private NScreenPageModel pageModel = null;
+
+    public NScreenBaseComposite(Composite parent, int style, NScreenPageModel nscreenPageModel) {
+        super(parent, SWT.V_SCROLL);
+        pageModel = nscreenPageModel;
+        comp = new Composite(this, SWT.NONE);
+        comp.setLayout(new FormLayout());
+        comp.setBackground(NScreenItem.BG_COLOR);
+        createPopupMenu();
+
+        setContent(comp);
+        setExpandVertical(true);
+        setExpandHorizontal(true);
+        addControlListener(new ControlAdapter() {
+            public void controlResized(ControlEvent e) {
+                Rectangle r = getClientArea();
+                setMinSize(comp.computeSize(r.width, SWT.DEFAULT));
+            }
+        });
+    }
+
+    private Composite addSeparator() {
+        Composite separator = new Composite(this, SWT.NONE);
+        separator.addPaintListener(new PaintListener() {
+
+            @Override
+            public void paintControl(PaintEvent e) {
+                e.gc.setBackground(ColorResource.BLACK);
+                e.gc.fillRectangle(getBounds());
+            }
+        });
+        int size = groups.size();
+        FormData data = new FormData();
+        data.top = new FormAttachment(groups.get(size - 1), 0);
+        data.left = new FormAttachment(0, 0);
+        data.right = new FormAttachment(100, 0);
+        data.height = SEPARATOR_HEIGHT;
+        separator.setLayoutData(data);
+        return separator;
+    }
+
+    private void createPopupMenu() {
+        popup = new Menu(getShell(), SWT.POP_UP);
+        MenuItem enableItem = new MenuItem(popup, SWT.PUSH);
+        enableItem.setText("Enable");
+        enableItem.addSelectionListener(new SelectionAdapter() {
+            @Override
+            public void widgetSelected(SelectionEvent e) {
+                MenuItem menuItem = (MenuItem) e.widget;
+                Object obj = menuItem.getParent().getData("caller");
+                if (obj instanceof NScreenItem) {
+                    NScreenItem item = (NScreenItem) obj;
+                    item.enableAction();
+                }
+            }
+        });
+
+        MenuItem disableItem = new MenuItem(popup, SWT.PUSH);
+        disableItem.setText("Disable");
+        disableItem.addSelectionListener(new SelectionAdapter() {
+            @Override
+            public void widgetSelected(SelectionEvent e) {
+                MenuItem menuItem = (MenuItem) e.widget;
+                Object obj = menuItem.getParent().getData("caller");
+                if (obj instanceof NScreenItem) {
+                    NScreenItem item = (NScreenItem) obj;
+                    item.disableAction();
+                }
+
+            }
+        });
+        new MenuItem(popup, SWT.SEPARATOR);
+
+        MenuItem moveUpItem = new MenuItem(popup, SWT.PUSH);
+        moveUpItem.setText("Move up");
+        moveUpItem.addSelectionListener(new SelectionAdapter() {
+            @Override
+            public void widgetSelected(SelectionEvent e) {
+                MenuItem menuItem = (MenuItem) e.widget;
+                Object obj = menuItem.getParent().getData("caller");
+                if (null != obj && obj instanceof NScreenItem) {
+                    NScreenItem item = (NScreenItem) obj;
+                    item.moveUpAction();
+                }
+            }
+        });
+
+        MenuItem moveDownItem = new MenuItem(popup, SWT.PUSH);
+        moveDownItem.setText("Move down");
+        moveDownItem.addSelectionListener(new SelectionAdapter() {
+            @Override
+            public void widgetSelected(SelectionEvent e) {
+                MenuItem menuItem = (MenuItem) e.widget;
+                Object obj = menuItem.getParent().getData("caller");
+                if (null != obj && obj instanceof NScreenItem) {
+                    NScreenItem item = (NScreenItem) obj;
+                    item.moveDownAction();
+                }
+            }
+        });
+
+        new MenuItem(popup, SWT.SEPARATOR);
+
+        MenuItem cutLinkItem = new MenuItem(popup, SWT.PUSH);
+        cutLinkItem.setText("Cut link");
+        cutLinkItem.addSelectionListener(new SelectionAdapter() {
+            @Override
+            public void widgetSelected(SelectionEvent e) {
+                MenuItem menuItem = (MenuItem) e.widget;
+                Object obj = menuItem.getParent().getData("caller");
+                if (null != obj && obj instanceof NScreenItem) {
+                    NScreenItem item = (NScreenItem) obj;
+                    item.LinkCutAction();
+                }
+            }
+        });
+
+        MenuItem linkUpItem = new MenuItem(popup, SWT.PUSH);
+        linkUpItem.setText("Link up");
+        linkUpItem.addSelectionListener(new SelectionAdapter() {
+            @Override
+            public void widgetSelected(SelectionEvent e) {
+                MenuItem menuItem = (MenuItem) e.widget;
+                Object obj = menuItem.getParent().getData("caller");
+                if (null != obj && obj instanceof NScreenItem) {
+                    NScreenItem item = (NScreenItem) obj;
+                    item.LinkUpAction();
+                }
+            }
+        });
+
+        MenuItem linkDownItem = new MenuItem(popup, SWT.PUSH);
+        linkDownItem.setText("Link down");
+        linkDownItem.addSelectionListener(new SelectionAdapter() {
+            @Override
+            public void widgetSelected(SelectionEvent e) {
+                MenuItem menuItem = (MenuItem) e.widget;
+                Object obj = menuItem.getParent().getData("caller");
+                if (null != obj && obj instanceof NScreenItem) {
+                    NScreenItem item = (NScreenItem) obj;
+                    item.LinkDownAction();
+                }
+            }
+        });
+    }
+
+    public void layout() {
+        comp.layout();
+        Rectangle r = getClientArea();
+        setMinSize(comp.computeSize(r.width, SWT.DEFAULT));
+    }
+
+    public NScreenGroup createNewGroup(NScreenType groupId, String title) {
+        int height = 0;
+        int count = groups.size();
+        Composite separator = null;
+        if (count > 0) {
+            for (NScreenGroup g : groups) {
+                height += g.getGroupHeight();
+            }
+            height += (count - 1) * SEPARATOR_HEIGHT;
+            separator  = addSeparator();
+//            height += SEPARATOR_HEIGHT;
+        }
+
+        NScreenGroup newGroup = new NScreenGroup(this, SWT.NONE, groupId);
+        if (title != null) {
+            newGroup.setTitle(title);
+        }
+
+        FormData data = new FormData();
+        if (count > 0) {
+            data.top = new FormAttachment(groups.get(count - 1), 4);
+        } else {
+            data.top = new FormAttachment(0, 0);
+        }
+        data.left = new FormAttachment(0, 0);
+        data.right = new FormAttachment(100, 0);
+        data.height = newGroup.getGroupHeight();
+        newGroup.setLayoutData(data);
+        newGroup.setMenu(popup);
+        groups.add(newGroup);
+        return newGroup;
+    }
+
+    public boolean hasSelection() {
+        for (NScreenGroup group : groups) {
+            if (group.hasSelection()) {
+                return true;
+            }
+        }
+        return false;
+    }
+
+    public void checkSelection(NScreenType selectedType) {
+        for (NScreenGroup group : groups) {
+            if (group.getType() != selectedType) {
+                group.clearSelection();
+            }
+        }
+    }
+
+    public void setFocusToSelectedItem() {
+        NScreenGroup sg = null;
+        for (NScreenGroup group : groups) {
+            if (group.hasSelection()) {
+                sg = group;
+                break;
+            }
+        }
+        sg.getSelectedItem().setFocus();
+    }
+
+    public Composite getInnerComposite() {
+        return comp;
+    }
+
+    public NScreenPageModel getNScreenPageModel() {
+        return pageModel;
+    }
+
+    public List<NScreenGroup> getNScreenGroups() {
+        return groups;
+    }
+}
diff --git a/org.tizen.webuibuilder/src/org/tizen/webuibuilder/ui/views/nscreen/NScreenCustomDialog.java b/org.tizen.webuibuilder/src/org/tizen/webuibuilder/ui/views/nscreen/NScreenCustomDialog.java
deleted file mode 100644 (file)
index 1153ade..0000000
+++ /dev/null
@@ -1,250 +0,0 @@
-/*
- * UI Builder
- *
- * Copyright (c) 2000 - 2014 Samsung Electronics Co., Ltd. All rights reserved.
- *
- * 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.webuibuilder.ui.views.nscreen;
-
-import org.eclipse.jface.dialogs.Dialog;
-import org.eclipse.jface.dialogs.IDialogConstants;
-import org.eclipse.swt.SWT;
-import org.eclipse.swt.layout.GridData;
-import org.eclipse.swt.layout.GridLayout;
-import org.eclipse.swt.widgets.Composite;
-import org.eclipse.swt.widgets.Control;
-import org.eclipse.swt.widgets.Display;
-import org.eclipse.swt.widgets.Label;
-import org.eclipse.swt.widgets.Shell;
-import org.eclipse.swt.widgets.Text;
-import org.tizen.webuibuilder.model.css.CssFile;
-
-
-/**
- * A class that implements Dialog. This class is responsible for the dialog box to add a Nscreen.
- */
-public class NScreenCustomDialog extends Dialog {
-    private Display mDisplay;
-    private Text mTitle;
-    private Text mWidth;
-    private Text mHeight;
-    private Text mCssFileName;
-    private Label mNotification;
-    private NScreenPage mNScreenPage;
-    private NScreenListItem mItem = null;
-
-    protected NScreenCustomDialog(Shell parentShell, NScreenPage nScreenPage, NScreenListItem item) {
-        super(parentShell);
-        mDisplay = parentShell.getDisplay();
-        mNScreenPage = nScreenPage;
-        mItem = item;
-    }
-
-    @Override
-    /*
-     * (non-Javadoc)
-     * 
-     * @see org.eclipse.jface.dialogs.Dialog#createDialogArea(org.eclipse.swt.widgets.Composite)
-     */
-    protected Control createDialogArea(Composite parent) {
-        Composite container = (Composite) super.createDialogArea(parent);
-        GridLayout layout = (GridLayout) container.getLayout();
-        layout.numColumns = 2;
-
-        Label title = new Label(container, SWT.RIGHT);
-        title.setText(NScreenViewMessages.LABEL_TITLE + " : ");
-        GridData data = new GridData(GridData.HORIZONTAL_ALIGN_END);
-        title.setLayoutData(data);
-
-        mTitle = new Text(container, SWT.SINGLE);
-        data = new GridData(GridData.FILL_HORIZONTAL);
-        data.widthHint = 150;
-        mTitle.setLayoutData(data);
-        if (mItem != null) {
-            mTitle.setText(mItem.getModel().getTitle());
-        }
-
-        Label width = new Label(container, SWT.RIGHT);
-        width.setText(NScreenViewMessages.LABEL_WIDTH + " : ");
-        data = new GridData(GridData.HORIZONTAL_ALIGN_END);
-        width.setLayoutData(data);
-
-        mWidth = new Text(container, SWT.SINGLE);
-        data = new GridData(GridData.FILL_HORIZONTAL);
-        mWidth.setLayoutData(data);
-        if (mItem != null) {
-            mWidth.setText(String.valueOf(mItem.getModel().getWidth()));
-        }
-
-        Label height = new Label(container, SWT.RIGHT);
-        height.setText(NScreenViewMessages.LABEL_HEIGHT + " : ");
-        data = new GridData(GridData.HORIZONTAL_ALIGN_END);
-        height.setLayoutData(data);
-
-        mHeight = new Text(container, SWT.SINGLE);
-        data = new GridData(GridData.FILL_HORIZONTAL);
-        mHeight.setLayoutData(data);
-        if (mItem != null) {
-            mHeight.setText(String.valueOf(mItem.getModel().getHeight()));
-        }
-
-        Label cssFileName = new Label(container, SWT.RIGHT);
-        cssFileName.setText(NScreenViewMessages.LABEL_CSS_FILE_NAME + " : ");
-        data = new GridData(GridData.HORIZONTAL_ALIGN_END);
-        cssFileName.setLayoutData(data);
-
-        mCssFileName = new Text(container, SWT.SINGLE);
-        data = new GridData(GridData.FILL_HORIZONTAL);
-        mCssFileName.setLayoutData(data);
-        if (mItem != null) {
-            mCssFileName.setText(String.valueOf(mItem.getModel().getFileName()));
-        }
-
-        mNotification = new Label(container, SWT.CENTER);
-        mNotification.setForeground(mDisplay.getSystemColor(SWT.COLOR_RED));
-        data = new GridData(GridData.FILL_HORIZONTAL);
-        data.horizontalSpan = 2;
-        mNotification.setLayoutData(data);
-
-        return container;
-    }
-
-    @Override
-    /*
-     * (non-Javadoc)
-     * 
-     * @see org.eclipse.jface.dialogs.Dialog#buttonPressed(int)
-     */
-    protected void buttonPressed(int buttonId) {
-        if (buttonId == IDialogConstants.OK_ID) {
-            if (mItem == null) {
-                if (checkAddNewScreen()) {
-                    super.buttonPressed(buttonId);
-                    return;
-                }
-            } else {
-                if (checkEditScreen()) {
-                    super.buttonPressed(buttonId);
-                    return;
-                }
-            }
-        } else {
-            super.buttonPressed(buttonId);
-        }
-    }
-
-    private boolean checkAddNewScreen() {
-        String title = mTitle.getText();
-        if (title.isEmpty()) {
-            mNotification.setText("Title field is empty.");
-            return false;
-        }
-
-        int width;
-        try {
-            width = Integer.parseInt(mWidth.getText());
-        } catch (Exception e) {
-            mNotification.setText("Please width field enter a number");
-            return false;
-        }
-        if (mNScreenPage.existNscreen(width)) {
-            mNotification.setText("Already exists screen width");
-            return false;
-        }
-
-        int height;
-        try {
-            height = Integer.parseInt(mHeight.getText());
-        } catch (Exception e) {
-            mNotification.setText("Please height field enter a number");
-            return false;
-        }
-
-        String cssFileName = mCssFileName.getText();
-        if (cssFileName.isEmpty()) {
-            mNotification.setText("CSS file name field is empty.");
-            return false;
-        }
-
-        mNScreenPage.addNewNscreen(title, width, height, cssFileName, false);
-        return true;
-    }
-
-    private boolean checkEditScreen() {
-        String title = mTitle.getText();
-        if (title.isEmpty()) {
-            mNotification.setText("Title field is empty.");
-            return false;
-        }
-
-        int width;
-        try {
-            width = Integer.parseInt(mWidth.getText());
-        } catch (Exception e) {
-            mNotification.setText("Please width field enter a number");
-            return false;
-        }
-        if (mItem.getModel().getWidth() != width) {
-            if (mNScreenPage.existNscreen(width)) {
-                mNotification.setText("Already exists screen width");
-                return false;
-            }
-        }
-
-        int height;
-        try {
-            height = Integer.parseInt(mHeight.getText());
-        } catch (Exception e) {
-            mNotification.setText("Please height field enter a number");
-            return false;
-        }
-
-        String cssFileName = mCssFileName.getText();
-        if (cssFileName.isEmpty()) {
-            mNotification.setText("CSS file name field is empty.");
-            return false;
-        }
-
-        CssFile model = mItem.getModel();
-        model.setTitle(title);
-        model.setWidth(width);
-        model.setHeight(height);
-        model.setFileName(cssFileName);
-
-        mItem.setTitleText(title);
-        mItem.setWidthText(mItem.makeWidthText(width));
-        mItem.setHeightText(mItem.makeHeightText(height));
-        mItem.setCssText(cssFileName);
-        mItem.mContainer.layout(true, true);
-        return true;
-    }
-
-    @Override
-    /*
-     * (non-Javadoc)
-     * 
-     * @see org.eclipse.jface.dialogs.Dialog#configureShell(org.eclipse.swt.widgets.Shell)
-     */
-    protected void configureShell(Shell newShell) {
-        super.configureShell(newShell);
-        newShell.setText(NScreenViewMessages.LABEL_CUSTOM_DIALOG);
-    }
-
-}
diff --git a/org.tizen.webuibuilder/src/org/tizen/webuibuilder/ui/views/nscreen/NScreenDeleteCommand.java b/org.tizen.webuibuilder/src/org/tizen/webuibuilder/ui/views/nscreen/NScreenDeleteCommand.java
deleted file mode 100644 (file)
index 1ed17a8..0000000
+++ /dev/null
@@ -1,99 +0,0 @@
-/*
- * UI Builder
- *
- * Copyright (c) 2000 - 2014 Samsung Electronics Co., Ltd. All rights reserved.
- *
- * 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.webuibuilder.ui.views.nscreen;
-
-import java.io.File;
-import java.io.IOException;
-import java.util.List;
-
-import org.eclipse.gef.commands.Command;
-import org.tizen.webuibuilder.model.css.CssFile;
-
-
-/**
- * A class that implements Command. This class run the operation to remove the existing Nscreen.
- */
-public class NScreenDeleteCommand extends Command {
-    private List<CssFile> mList = null;
-    private CssFile mModel = null;
-    private NScreenList mNscreenList = null;
-    private NScreenListItem mItem = null;
-
-    public NScreenDeleteCommand(List<CssFile> list, NScreenListItem item, NScreenList screenList) {
-        mList = list;
-        mItem = item;
-        mNscreenList = screenList;
-        mModel = item.getModel();
-    }
-
-    @Override
-    /*
-     * (non-Javadoc)
-     * 
-     * @see org.eclipse.gef.commands.Command#execute()
-     */
-    public void execute() {
-        File nscreenCssFile = new File(mModel.getCssFilePath());
-        if (nscreenCssFile.exists()) {
-            nscreenCssFile.delete();
-        }
-        mList.remove(mModel);
-        if (mNscreenList != null && !mNscreenList.getControl().isDisposed()) {
-            mNscreenList.removeItem(mItem);
-            mNscreenList.layout();
-        }
-    }
-
-    @Override
-    /*
-     * (non-Javadoc)
-     * 
-     * @see org.eclipse.gef.commands.Command#redo()
-     */
-    public void redo() {
-        super.redo();
-    }
-
-    @Override
-    /*
-     * (non-Javadoc)
-     * 
-     * @see org.eclipse.gef.commands.Command#undo()
-     */
-    public void undo() {
-        mList.add(mModel);
-
-        try {
-            File newCSSFile = new File(mModel.getCssFilePath());
-            newCSSFile.createNewFile();
-        } catch (IOException e) {
-            e.printStackTrace();
-        }
-
-        if (mNscreenList != null && !mNscreenList.getControl().isDisposed()) {
-            mItem = mNscreenList.addItem(mModel, false);
-            mNscreenList.layout();
-        }
-    }
-}
diff --git a/org.tizen.webuibuilder/src/org/tizen/webuibuilder/ui/views/nscreen/NScreenGroup.java b/org.tizen.webuibuilder/src/org/tizen/webuibuilder/ui/views/nscreen/NScreenGroup.java
new file mode 100644 (file)
index 0000000..774d38a
--- /dev/null
@@ -0,0 +1,333 @@
+
+
+package org.tizen.webuibuilder.ui.views.nscreen;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.events.PaintEvent;
+import org.eclipse.swt.events.PaintListener;
+import org.eclipse.swt.graphics.Color;
+import org.eclipse.swt.graphics.Image;
+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.Event;
+import org.eclipse.swt.widgets.Listener;
+import org.eclipse.swt.widgets.Menu;
+import org.eclipse.swt.widgets.MenuItem;
+import org.tizen.webuibuilder.animator.ui.views.timeline.common.ColorResource;
+import org.tizen.webuibuilder.model.nscreen.NScreenModel;
+import org.tizen.webuibuilder.model.nscreen.NScreenModel.NScreenType;
+import org.tizen.webuibuilder.ui.views.nscreen.model.NScreenPageModel;
+
+
+public class NScreenGroup extends Composite {
+
+    private List<NScreenItem> items = new ArrayList<NScreenItem>();
+
+    // FIXME
+    public static final int GROUP_LABEL_HEIGHT = 50;
+    public static final int MIN_GROUP_ITEM_HEIGHT = 50;
+    public static final int ITEM_MARGIN = 0;
+
+    private int height = MIN_GROUP_ITEM_HEIGHT;
+    private NScreenType groupType;
+    private String title = null;
+    private NScreenBaseComposite owner = null;
+
+    private Listener menuDisableListener = new Listener() {
+
+        @Override
+        public void handleEvent(Event event) {
+            Menu menu = getMenu();
+            for (MenuItem item : menu.getItems()) {
+                item.setEnabled(false);
+            }
+        }
+    };
+    private PaintListener paintListener = new PaintListener() {
+
+        @Override
+        public void paintControl(PaintEvent e) {
+            Rectangle rect = getClientArea();
+            Color color = e.display.getSystemColor(SWT.COLOR_WIDGET_BACKGROUND);
+            e.gc.setBackground(color);
+            e.gc.fillRectangle(rect);
+            e.gc.setForeground(ColorResource.BLACK);
+
+            if (null != title) {
+                e.gc.setFont(FontUtil.NSCREEN_TITLE);
+                Point textWH = FontUtil.getTextArea(title, e.gc);
+                int x = rect.x + (rect.width - textWH.x) / 2;
+                int y = rect.y + (GROUP_LABEL_HEIGHT - textWH.y) / 2;
+
+                e.gc.drawText(title, x, y);
+            }
+            // e.gc.setBackground(ColorResource.WHITE);
+            // int x = rect.x;
+            // int y = rect.y;
+            // int w = rect.width;
+            // int h = rect.height;
+            // e.gc.fillPolygon(new int[] { x + 2, y + 2, x + 170, y + 2, x + 170 + 0, y + 28,
+            // x + w - 2, y + 28, x + w - 2, y + h - 2, 2, y + h - 2, x + 2, y + 2 });
+            // e.gc.drawPolygon(new int[] {x +2, y+2,
+            // x + 170, y+2,
+            // x + 170 + 0, y +28,
+            // x +w -2, y+28,
+            // x+w-2, y+h-2,
+            // 2, y+h-2,
+            // x+2, y+2
+            // });
+
+        }
+    };
+
+    public NScreenGroup(NScreenBaseComposite owner, int style, NScreenType groupId) {
+        super(owner.getInnerComposite(), style);
+        this.owner = owner;
+        setLayout(new FormLayout());
+        groupType = groupId;
+        this.addPaintListener(paintListener);
+        this.addListener(SWT.MouseDown, menuDisableListener);
+    }
+
+    public NScreenPageModel getNScreenPageModel() {
+        return owner.getNScreenPageModel();
+    }
+
+    public NScreenItem addItem(NScreenModel model) {
+        int count = items.size();
+        // FIXME : contant -> margin is 1
+        int h = 0;
+        if (count > 0) {
+            h = height * (count - 1) + ITEM_MARGIN;
+        }
+        FormData data = new FormData();
+        data.left = new FormAttachment(0, 0);
+        data.right = new FormAttachment(100, -0);
+        if (count > 0) {
+            data.top = new FormAttachment(items.get(count - 1), ITEM_MARGIN);
+        } else {
+            if (null != title) {
+                data.top = new FormAttachment(0, GROUP_LABEL_HEIGHT);
+            } else {
+                data.top = new FormAttachment(0, ITEM_MARGIN);
+            }
+        }
+        data.height = height;
+        NScreenItem newNScreen = new NScreenItem(this, SWT.NONE, model);
+        newNScreen.setLayoutData(data);
+        items.add(newNScreen);
+
+        if (!owner.hasSelection()) {
+            newNScreen.setSelection(true);
+        }
+        newNScreen.setMenu(getMenu());
+
+        data = (FormData) getLayoutData();
+        data.height = getGroupHeight();
+        return newNScreen;
+    }
+
+    public NScreenItem addItem(Image img, NScreenModel model) {
+        NScreenItem ns = addItem(model);
+        ns.setImage(img);
+        return ns;
+    }
+
+    public List<NScreenItem> getItems() {
+        return items;
+    }
+
+    public void setTitle(String title) {
+        this.title = title;
+    }
+
+    public int getHeight() {
+        return height;
+    }
+
+    public void setHeight(int height) {
+        if (height < MIN_GROUP_ITEM_HEIGHT) {
+            height = MIN_GROUP_ITEM_HEIGHT;
+        }
+        this.height = height;
+    }
+
+    public int getGroupHeight() {
+        int h = 0;
+        if (groupType == NScreenType.COMMON) {
+            h = (height * items.size() + (items.size() - 1) * ITEM_MARGIN) + GROUP_LABEL_HEIGHT;
+        } else {
+            h = (height * items.size() + (items.size() - 1) * ITEM_MARGIN);
+        }
+        return h;
+    }
+
+    public void selected(NScreenItem selectedItem) {
+
+        for (NScreenItem item : items) {
+            if (item.isSelected()) {
+                item.setSelection(false);
+            }
+        }
+        selectedItem.setSelection(true);
+    }
+
+    public boolean hasSelection() {
+        for (NScreenItem ns : items) {
+            if (ns.isSelected()) {
+                return true;
+            }
+        }
+        return false;
+    }
+
+    public void clearSelection() {
+        for (NScreenItem ns : items) {
+            if (ns.isSelected()) {
+                ns.setSelection(false);
+            }
+        }
+    }
+
+    public boolean setDefaultSelection() {
+        if (items.size() == 0) {
+            return false;
+        }
+        items.get(0).setSelection(true);
+        return true;
+    }
+
+    public void gotSelection() {
+        owner.checkSelection(groupType);
+    }
+
+    public NScreenType getType() {
+        return groupType;
+    }
+
+    public NScreenBaseComposite getOwner() {
+        return owner;
+    }
+
+    public void setOwner(NScreenBaseComposite owner) {
+        this.owner = owner;
+    }
+
+    public List<NScreenItem> getLinkedItems(NScreenItem item) {
+        NScreenItem root = item;
+        if (!item.isRoot()) {
+            root = item.getReference();
+        }
+
+        List<NScreenItem> linked = root.getLinkedList();
+        int size = linked.size() + 1;
+        int index = 100;
+        NScreenItem childItem = null;
+        for (NScreenItem ni : linked) {
+            int linkIndex = getItems().indexOf(ni);
+            if (linkIndex < index) {
+                index = linkIndex;
+                childItem = ni;
+            }
+        }
+
+        int firstIndex = -1;
+        if (getItems().indexOf(root) > getItems().indexOf(childItem)) {
+            firstIndex = getItems().indexOf(childItem);
+        } else {
+            firstIndex = getItems().indexOf(root);
+        }
+
+        List<NScreenItem> retList = new ArrayList<NScreenItem>();
+        for (int i = firstIndex; i < firstIndex + size; i++) {
+            retList.add(getItems().get(i));
+        }
+
+        return retList;
+    }
+
+    public void changeOrder(NScreenItem prev, List<NScreenItem> source, List<NScreenItem> target,
+                            NScreenItem after) {
+        NScreenItem sourceFirst = source.get(0);
+        NScreenItem sourceLast = source.get(source.size() - 1);
+        NScreenItem targetFirst = target.get(0);
+        NScreenItem targetLast = target.get(target.size() - 1);
+
+        FormData data = null;
+
+        data = (FormData) sourceFirst.getLayoutData();
+        data.top = new FormAttachment(targetLast, NScreenGroup.ITEM_MARGIN);
+
+        if (after != null) {
+            data = (FormData) after.getLayoutData();
+            data.top = new FormAttachment(sourceLast, NScreenGroup.ITEM_MARGIN);
+        }
+
+        data = (FormData) targetFirst.getLayoutData();
+        if (null != prev) {
+            data.top = new FormAttachment(prev, NScreenGroup.ITEM_MARGIN);
+        } else {
+            data.top = new FormAttachment(0, NScreenGroup.GROUP_LABEL_HEIGHT);
+        }
+        layout();
+    }
+
+    public void changeItemIndex(List<NScreenItem> source, List<NScreenItem> target) {
+        int sourceFirstIndex = getItems().indexOf(source.get(0));
+        int sourceSize = source.size();
+        int targetSize = target.size();
+
+        for (int i = sourceFirstIndex, k = 0; i < sourceFirstIndex + targetSize && k < targetSize; i++, k++) {
+            getItems().set(i, target.get(k));
+        }
+
+        for (int i = sourceFirstIndex + targetSize, k = 0; k < sourceSize; i++, k++) {
+            getItems().set(i, source.get(k));
+        }
+    }
+
+    public void changeModelIndex(List<NScreenItem> source, List<NScreenItem> target) {
+        List<NScreenModel> models =
+                getNScreenPageModel().getAppManager().getNScreenModelManger().getNScreenModels();
+
+        int sourceFirstIndex = models.indexOf(source.get(0).getModel());
+        int sourceSize = source.size();
+        int targetSize = target.size();
+
+        for (int i = sourceFirstIndex, k = 0; i < sourceFirstIndex + targetSize && k < targetSize; i++, k++) {
+            models.set(i, target.get(k).getModel());
+        }
+
+        for (int i = sourceFirstIndex + targetSize, k = 0; k < sourceSize; i++, k++) {
+            models.set(i, source.get(k).getModel());
+        }
+    }
+
+    public NScreenItem getSelectedItem() {
+        for (NScreenItem item : items) {
+            if (item.isSelected()) {
+                return item;
+            }
+        }
+        return null;
+    }
+
+    public void createLinkTree() {
+        String pageId = owner.getNScreenPageModel().getPageData().getName();
+        for (int i = 0; i < items.size(); i++) {
+            NScreenItem item = items.get(i);
+            int dir = item.getModel().getLink(pageId);
+
+            if (dir != NScreenModel.NONE) {
+                item.setLink(dir);
+            }
+        }
+    }
+}
diff --git a/org.tizen.webuibuilder/src/org/tizen/webuibuilder/ui/views/nscreen/NScreenHistory.java b/org.tizen.webuibuilder/src/org/tizen/webuibuilder/ui/views/nscreen/NScreenHistory.java
new file mode 100644 (file)
index 0000000..dce769f
--- /dev/null
@@ -0,0 +1,38 @@
+
+
+package org.tizen.webuibuilder.ui.views.nscreen;
+
+public class NScreenHistory {
+    private String lastResolution = null;
+    private float lastScale = 0f;
+    private String modelName = null;
+
+    public NScreenHistory() {
+
+    }
+
+    public String getLastResolution() {
+        return lastResolution;
+    }
+
+    public void setLastResolution(String lastResolution) {
+        this.lastResolution = lastResolution;
+    }
+
+    public float getScale() {
+        return lastScale;
+    }
+
+    public void setScale(float lastScale) {
+        this.lastScale = lastScale;
+    }
+
+    public String getModelName() {
+        return modelName;
+    }
+
+    public void setModelName(String modelName) {
+        this.modelName = modelName;
+    }
+
+}
diff --git a/org.tizen.webuibuilder/src/org/tizen/webuibuilder/ui/views/nscreen/NScreenItem.java b/org.tizen.webuibuilder/src/org/tizen/webuibuilder/ui/views/nscreen/NScreenItem.java
new file mode 100644 (file)
index 0000000..e196715
--- /dev/null
@@ -0,0 +1,483 @@
+
+
+package org.tizen.webuibuilder.ui.views.nscreen;
+
+import java.io.File;
+import java.io.IOException;
+import java.util.ArrayList;
+import java.util.List;
+
+import org.eclipse.core.runtime.IPath;
+import org.eclipse.gef.commands.Command;
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.events.PaintEvent;
+import org.eclipse.swt.events.PaintListener;
+import org.eclipse.swt.graphics.Color;
+import org.eclipse.swt.graphics.Image;
+import org.eclipse.swt.graphics.Rectangle;
+import org.eclipse.swt.layout.FillLayout;
+import org.eclipse.swt.widgets.Canvas;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.swt.widgets.Event;
+import org.eclipse.swt.widgets.Listener;
+import org.eclipse.swt.widgets.Menu;
+import org.eclipse.swt.widgets.MenuItem;
+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.model.nscreen.NScreenModel.NScreenType;
+import org.tizen.webuibuilder.ui.views.nscreen.command.NScreenDisableCommand;
+import org.tizen.webuibuilder.ui.views.nscreen.command.NScreenEnableCommand;
+import org.tizen.webuibuilder.ui.views.nscreen.command.NScreenLinkCutCommand;
+import org.tizen.webuibuilder.ui.views.nscreen.command.NScreenLinkDownCommand;
+import org.tizen.webuibuilder.ui.views.nscreen.command.NScreenLinkUpCommand;
+import org.tizen.webuibuilder.ui.views.nscreen.command.NScreenMoveDownCommand;
+import org.tizen.webuibuilder.ui.views.nscreen.command.NScreenMoveUpCommand;
+
+
+public class NScreenItem extends Composite {
+    public static final int STATE_NORMAL = 0;
+    public static final int STATE_HOVER = 1;
+    public static final int STATE_PUSH = 2;
+
+    public static final int MENU_ENABLE = 0;
+    public static final int MENU_DISABLE = 1;
+    // public static final int SEPARATOR = 2;
+    public static final int MENU_MOVE_UP = 3;
+    public static final int MENU_MOVE_DOWN = 4;
+    // public static final int SEPARATOR = 5;
+    public static final int MENU_LINK_CUT = 6;
+    public static final int MENU_LINK_UP = 7;
+    public static final int MENU_LINK_DOWN = 8;
+
+    public static final Color BG_COLOR = ColorResource.WHITE;
+
+    private int state = STATE_NORMAL;
+    private Image thumb = null;
+    private NScreenGroup parent = null;
+    private Canvas canvas = null;
+    private NScreenModel model = null;
+
+    private NScreenHistory history = null;
+//    private float scale = 0f;
+//    private String lastResolution = null;
+
+    // ui only data
+    private NScreenItem reference = null;
+    private List<NScreenItem> linked = new ArrayList<NScreenItem>();
+
+    private boolean selected = false;
+
+    private INScreenDrawRenderer renderer = new NScreenSimpleRenderer();
+
+    private Listener keyListener = new Listener() {
+
+        @Override
+        public void handleEvent(Event event) {
+            if (parent.getType() == NScreenType.RESOLUTION) {
+                if (event.keyCode == SWT.ARROW_UP) {
+                    moveUpAction();
+                } else if (event.keyCode == SWT.ARROW_DOWN) {
+                    moveDownAction();
+                }
+            }
+        }
+    };
+    private Listener mouseListener = new Listener() {
+
+        @Override
+        public void handleEvent(Event event) {
+            if (event.type == SWT.MouseEnter) {
+                state = STATE_HOVER;
+            } else if (event.type == SWT.MouseExit) {
+                state = STATE_NORMAL;
+            } else if (event.type == SWT.MouseDown) {
+                state = STATE_PUSH;
+                setMenuState();
+                // parent.getOwner().setFocusToSelectedItem();
+            }
+
+            else if (event.type == SWT.MouseUp) {
+                state = STATE_HOVER;
+                if (event.stateMask != SWT.BUTTON2) {
+                    Rectangle rect = getClientArea();
+                    if (rect.contains(event.x, event.y)) {
+                        clicked();
+                    }
+                }
+            }
+            canvas.redraw();
+        }
+    };
+
+    private String getPageId() {
+        return parent.getNScreenPageModel().getPageData().getName();
+    }
+
+    private void setMenuState() {
+        Menu menu = getMenu();
+        menu.setData("caller", this);
+        for (MenuItem menuItem : menu.getItems()) {
+            menuItem.setEnabled(false);
+        }
+
+        if (model.getType() != NScreenType.COMMON) {
+            if (!model.isEnablePage(getPageId())) {
+                menu.getItem(MENU_ENABLE).setEnabled(true);
+            } else {
+                menu.getItem(MENU_DISABLE).setEnabled(true);
+
+                List<NScreenItem> items = parent.getItems();
+                int size = items.size();
+                int index = items.indexOf(this);
+
+                if (model.getType() != NScreenType.ORIENTATION) {
+                    if (model.getLink(getPageId()) != NScreenModel.NONE) {
+                        menu.getItem(MENU_LINK_CUT).setEnabled(true);
+                    } else {
+                        if (index > 0 && items.get(index - 1).isItemEnabled() && !isRoot()) {
+                            menu.getItem(MENU_LINK_UP).setEnabled(true);
+                        }
+                        if (index < size - 1 && items.get(index + 1).isItemEnabled() && !isRoot()) {
+                            menu.getItem(MENU_LINK_DOWN).setEnabled(true);
+                        }
+                    }
+
+                    if (model.getType() != NScreenType.PIXELRATIO) {
+                        if (index > 0 && !model.isLinked(getPageId()) && !isRoot()) {
+                            menu.getItem(MENU_MOVE_UP).setEnabled(true);
+                        }
+                        if (index < size - 1 && !model.isLinked(getPageId()) && !isRoot()) {
+                            menu.getItem(MENU_MOVE_DOWN).setEnabled(true);
+                        }
+                    }
+                }
+            }
+        }
+    }
+
+    public NScreenItem(Composite parent, int style, NScreenModel m) {
+        super(parent, SWT.TRANSPARENT);
+        this.parent = (NScreenGroup) parent;
+        this.model = m;
+        setLayout(new FillLayout());
+        this.setBackground(BG_COLOR);
+        history = new NScreenHistory();
+        history.setModelName(this.model.getName());
+        canvas = new Canvas(this, SWT.TRANSPARENT);
+
+//        if (model.getType() != NScreenType.COMMON) {
+//            if (model.isEnablePage(getPageId())) {
+//                setSelection(true);
+//            }
+//        }
+
+        addMouseListener();
+        canvas.addListener(SWT.KeyUp, keyListener);
+        canvas.addPaintListener(new PaintListener() {
+
+            @Override
+            public void paintControl(PaintEvent e) {
+                renderer.draw(e.gc, canvas, state, isSelected(), isItemEnabled(), thumb, model,
+                              getPageId());
+            }
+        });
+    }
+
+    private void addMouseListener() {
+        canvas.addListener(SWT.MouseDown, mouseListener);
+        canvas.addListener(SWT.MouseUp, mouseListener);
+        canvas.addListener(SWT.MouseEnter, mouseListener);
+        canvas.addListener(SWT.MouseExit, mouseListener);
+    }
+
+    public void clicked() {
+        if (!isSelected()) {
+            parent.selected(this);
+            setFocus();
+        }
+
+        parent.getNScreenPageModel().getPageDesigner().setShowingSize(filterScreen(), this);
+    }
+
+    private List<Device> filterScreen() {
+        List<Device> devices = DeviceManager.getDeviceManager().getDevices();
+
+        NScreenType type = model.getType();
+
+        List<Device> selected = new ArrayList<Device>();
+        if (type == NScreenType.COMMON) {
+            selected.addAll(devices);
+        } else if (type == NScreenType.ORIENTATION) {
+            for (Device device : devices) {
+                if (device.getOrientation() == null
+                        || device.getOrientation().toString()
+                                .equals(model.getOrientation().toString())) {
+                    selected.add(device);
+                }
+            }
+        } else if (type == NScreenType.PIXELRATIO) {
+            for (Device device : devices) {
+                if (device.getDevicePixelRatio() == model.getDevicePixelRatio()) {
+                    selected.add(device);
+                }
+            }
+        } else if (type == NScreenType.RESOLUTION) {
+            for (Device device : devices) {
+                if (model.getDeviceWidth() == device.getDeviceWidth()
+                        && model.getDeviceHeight() == device.getDeviceHeight()) {
+                    selected.add(device);
+                    break;
+                }
+            }
+        } else {
+            // custom
+        }
+        return selected;
+    }
+
+    public void setImage(Image img) {
+        thumb = img;
+    }
+
+    public void setSelection(boolean isSelected) {
+        if (selected == isSelected) {
+            return;
+        }
+        selected = isSelected;
+
+        if (isSelected) {
+            ((NScreenGroup) getParent()).gotSelection();
+        }
+
+        canvas.redraw();
+    }
+
+    public boolean isSelected() {
+        return selected;
+    }
+
+    public int getState() {
+        return state;
+    }
+
+    public boolean isItemEnabled() {
+        return model.isEnablePage(getPageId());
+    }
+
+    public void setItemEnabled(boolean enabled) {
+        if (enabled) { // enable
+            model.addEnablePage(getPageId());
+            state = STATE_NORMAL;
+        } else { // disable
+            model.addDisablePage(getPageId());
+        }
+    }
+
+    @Override
+    public void setMenu(Menu menu) {
+        super.setMenu(menu);
+        canvas.setMenu(menu);
+    }
+
+    public NScreenModel getModel() {
+        return model;
+    }
+
+    public void setModel(NScreenModel model) {
+        this.model = model;
+    }
+
+    public String getFileName() {
+        if (model.isLinked(getPageId())) {
+            return reference.getFileName();
+        }
+        String pageId = parent.getNScreenPageModel().getPageData().getName();
+        String screenName = model.getName();
+        StringBuffer strBuffer = new StringBuffer();
+        strBuffer.append(pageId).append("_").append(screenName).append(".css");
+        return strBuffer.toString();
+    }
+
+    public void enableAction() {
+        Command command = new NScreenEnableCommand(this);
+        parent.getNScreenPageModel().getPageDesigner().getCommandStack().execute(command);
+    }
+
+    public void disableAction() {
+        Command command = new NScreenDisableCommand(this);
+        parent.getNScreenPageModel().getPageDesigner().getCommandStack().execute(command);
+    }
+
+    public void moveUpAction() {
+        int index = parent.getItems().indexOf(this);
+        if (index != 0 && isItemEnabled() && !isLinked() && !isRoot()) {
+            Command command = new NScreenMoveUpCommand(this);
+            parent.getNScreenPageModel().getPageDesigner().getCommandStack().execute(command);
+        }
+    }
+
+    public void moveDownAction() {
+        int index = parent.getItems().indexOf(this);
+        if (index < parent.getItems().size() - 1 && isItemEnabled() && !isLinked() && !isRoot()) {
+            Command command = new NScreenMoveDownCommand(this);
+            parent.getNScreenPageModel().getPageDesigner().getCommandStack().execute(command);
+        }
+    }
+
+    public void LinkCutAction() {
+        Command command = new NScreenLinkCutCommand(this);
+        parent.getNScreenPageModel().getPageDesigner().getCommandStack().execute(command);
+    }
+
+    public void LinkUpAction() {
+        Command command = new NScreenLinkUpCommand(this);
+        parent.getNScreenPageModel().getPageDesigner().getCommandStack().execute(command);
+    }
+
+    public void LinkDownAction() {
+        Command command = new NScreenLinkDownCommand(this);
+        parent.getNScreenPageModel().getPageDesigner().getCommandStack().execute(command);
+    }
+
+    public void redrawItem() {
+        canvas.redraw();
+    }
+
+    public boolean setFocus() {
+        return canvas.setFocus();
+    }
+
+    public List<NScreenItem> getLinkedList() {
+        return linked;
+    }
+
+    public <T> boolean addList(List<T> list, T item) {
+        int index = list.indexOf(item);
+        if (index < 0) {
+            list.add(item);
+            return true;
+        }
+        return false;
+    }
+
+    public int setLink(int direction) {
+        if (direction == SWT.UP) {
+            int index = parent.getItems().indexOf(this);
+            reference = parent.getItems().get(index - 1);
+            if (reference.isLinked()) {
+                reference = reference.getReference();
+            }
+            model.addLink(getPageId(), NScreenModel.UP);
+            addList(reference.getLinkedList(), this);
+        } else if (direction == SWT.DOWN) {
+            int index = parent.getItems().indexOf(this);
+            reference = parent.getItems().get(index + 1);
+            if (reference.isLinked()) {
+                reference = reference.getReference();
+            }
+            model.addLink(getPageId(), NScreenModel.DOWN);
+            addList(reference.getLinkedList(), this);
+        } else if (direction == SWT.NONE) {
+            direction = model.getLink(getPageId());
+            reference.getLinkedList().remove(this);
+            model.addLink(getPageId(), NScreenModel.NONE);
+            reference.redrawItem();
+            reference = null;
+        }
+
+        if (reference != null) {
+            reference.redrawItem();
+        }
+        return direction;
+    }
+
+    public boolean isLinked() {
+        if (model.getLink(getPageId()) == NScreenModel.NONE) {
+            return false;
+        }
+        return true;
+    }
+
+    public NScreenItem getReference() {
+        return reference;
+    }
+
+    public void setReference(NScreenItem ref) {
+        reference = ref;
+    }
+
+    public void deleteFile() {
+        String cssFolderPath = parent.getNScreenPageModel().getAppManager().getCssFolder();
+        String filePath = cssFolderPath + IPath.SEPARATOR + getFileName();
+        File newCSSFile = new File(filePath);
+
+        if (newCSSFile.exists()) {
+            newCSSFile.delete();
+        }
+
+        parent.getNScreenPageModel().getPageData().removeCssFileByPath(filePath);
+    }
+
+    public void copyFile(NScreenItem source) {
+        String sourceFileName = source.getFileName();
+        String targetFileName = getFileName();
+
+        String filePath = parent.getNScreenPageModel().getAppManager().getCssFolder();
+//        CssFile sourceCssFile = new CssFile(filePath + IPath.SEPARATOR + sourceFileName);
+        File sourceFile = new File(filePath + IPath.SEPARATOR + sourceFileName);
+        File targetFile = new File(filePath + IPath.SEPARATOR + targetFileName);
+        parent.getNScreenPageModel().getPageData().removeCssFileByPath(filePath + IPath.SEPARATOR+sourceFileName);
+
+        sourceFile.renameTo(targetFile);
+        CssFile targetCssFile = new CssFile(filePath + IPath.SEPARATOR + sourceFileName);
+        parent.getNScreenPageModel().getPageData().addCssFile(targetCssFile);
+    }
+
+    public void createFile() {
+        String filePath = parent.getNScreenPageModel().getAppManager().getCssFolder();
+        CssFile cssFile = new CssFile(filePath + IPath.SEPARATOR + getFileName());
+        File newCSSFile = new File(filePath + IPath.SEPARATOR + getFileName());
+
+        try {
+            if (!newCSSFile.exists()) {
+                File dir = newCSSFile.getParentFile();
+                dir.mkdirs();
+                newCSSFile.createNewFile();
+            }
+        } catch (IOException e) {
+            e.printStackTrace();
+        }
+
+        parent.getNScreenPageModel().getPageData().addCssFile(cssFile);
+    }
+
+    public boolean isRoot() {
+        if (!isLinked() && linked.size() > 0) {
+            return true;
+        }
+        return false;
+    }
+
+    public NScreenHistory getNScreenHistory()
+    {
+        return history;
+    }
+//    public float getScale() {
+//        return scale;
+//    }
+//
+//    public void setScale(float scale) {
+//        this.scale = scale;
+//    }
+//
+//    public String getLastResolution() {
+//        return lastResolution;
+//    }
+//
+//    public void setLastResolution(String last) {
+//        this.lastResolution = last;
+//    }
+}
diff --git a/org.tizen.webuibuilder/src/org/tizen/webuibuilder/ui/views/nscreen/NScreenItemFloatRenderer.java b/org.tizen.webuibuilder/src/org/tizen/webuibuilder/ui/views/nscreen/NScreenItemFloatRenderer.java
new file mode 100644 (file)
index 0000000..3cd2fe8
--- /dev/null
@@ -0,0 +1,149 @@
+
+
+package org.tizen.webuibuilder.ui.views.nscreen;
+
+import static org.tizen.webuibuilder.ui.views.nscreen.NScreenItem.STATE_HOVER;
+import static org.tizen.webuibuilder.ui.views.nscreen.NScreenItem.STATE_NORMAL;
+import static org.tizen.webuibuilder.ui.views.nscreen.NScreenItem.STATE_PUSH;
+
+import org.eclipse.swt.graphics.Font;
+import org.eclipse.swt.graphics.GC;
+import org.eclipse.swt.graphics.Image;
+import org.eclipse.swt.graphics.Rectangle;
+import org.eclipse.swt.widgets.Canvas;
+import org.tizen.webuibuilder.animator.ui.views.timeline.common.ColorResource;
+import org.tizen.webuibuilder.model.nscreen.NScreenModel;
+import org.tizen.webuibuilder.model.nscreen.NScreenModel.NScreenType;
+
+
+public class NScreenItemFloatRenderer implements INScreenDrawRenderer {
+    private static int IMAGE_SIZE = 30;
+    private static int X_MARGIN = 4;
+
+    private static int TEXT_MARGIN_X = X_MARGIN + IMAGE_SIZE + 30;
+
+    @Override
+    public void draw(GC gc, Canvas canvas, int state, boolean isSelected, boolean enabled,
+                     Image thumb, NScreenModel model, String pageId) {
+//        NScreenItem item = (NScreenItem) canvas.getParent();
+//        Rectangle rect = canvas.getClientArea();
+//
+//        int canvasX = rect.x;
+//        int canvasY = rect.y;
+//        int canvasW = rect.width;
+//        int canvasH = rect.height;
+//
+//        gc.setBackground(ColorResource.BLACK);
+//        gc.fillRectangle(canvasX + 6, canvasY + 6, canvasW - 8, canvasH - 8);
+//        // e.gc.fillRoundRectangle(x + 6, y + 6, w - 8, h - 8, 10, 10);
+//
+//        Rectangle drawRect = checkState(new Rectangle(canvasX, canvasY, canvasW, canvasH), state);
+//
+//        if (isSelected) {
+//            gc.setBackground(ColorResource.BOUNCE_IN_UP);
+//        } else {
+//            gc.setBackground(ColorResource.WHITE);
+//        }
+//
+//        Rectangle linkRect =
+//                new Rectangle(drawRect.x + drawRect.width - 20, drawRect.y, 20, drawRect.height);
+//
+//        gc.fillRectangle(drawRect);
+//        // e.gc.fillRoundRectangle(drawRect.x, drawRect.y, drawRect.width, drawRect.height,
+//        // 10, 10);
+//
+//        if (state == STATE_DISABLED) {
+//            gc.setBackground(ColorResource.GRAY);
+//        } else if (model.getType() != NScreenType.COMMON) {
+//            gc.setBackground(ColorResource.NAVY);
+//
+//            int direction = model.getLink(pageId);
+//            int x = linkRect.x;
+//            int y = linkRect.y;
+//            int w = linkRect.width;
+//            int h = linkRect.height;
+//
+//            if (direction == NScreenModel.UP) {
+//                gc.fillPolygon(new int[] { x, y + 10, x + w / 2, y, x + w, y + 10, x + w, y + h,
+//                        x + w / 2, y + h - 10, x, y + h });
+//            } else if (direction == NScreenModel.DOWN) {
+//                gc.fillPolygon(new int[] { x, y, x + w / 2, y + 10, x + w, y, x + w, y, x + w,
+//                        y + h - 10, x + w / 2, y + h, x, y + h - 10 });
+//            } else if (item.isRoot()) {
+//                gc.fillRectangle(linkRect);
+//            }
+//
+//        }
+//
+//        // e.gc.drawRoundRectangle(drawRect.x, drawRect.y, drawRect.width, drawRect.height,
+//        // 10, 10);
+//        if (state == STATE_DISABLED) {
+//            gc.setForeground(ColorResource.GRAY);
+//        } else {
+//            gc.setForeground(ColorResource.BLACK);
+//        }
+//        gc.drawRectangle(drawRect);
+//
+//        // e.gc.setForeground(bgColors[state * 2]);
+//        // e.gc.setBackground(bgColors[state * 2 + 1]);
+//        //
+//        // e.gc.fillGradientRectangle(rect.x, rect.y, rect.width, rect.height, true);
+//        //
+//        // e.gc.setForeground(fgColors[state]);
+//        //
+//        int targetY = (drawRect.height - IMAGE_SIZE) / 2;
+//        if (thumb != null) {
+//            Rectangle imgRect = thumb.getBounds();
+//            gc.drawImage(thumb, imgRect.x, imgRect.y, imgRect.width, imgRect.height, drawRect.x
+//                    + X_MARGIN, drawRect.y + targetY, IMAGE_SIZE, IMAGE_SIZE);
+//        } else {
+//            gc.drawRectangle(drawRect.x + X_MARGIN, drawRect.y + targetY, IMAGE_SIZE, IMAGE_SIZE);
+//        }
+//
+//        // drawText
+//        if (isSelected) {
+//            gc.setBackground(ColorResource.BOUNCE_IN_UP);
+//        } else {
+//            gc.setBackground(ColorResource.WHITE);
+//        }
+//        if (state == STATE_DISABLED) {
+//            gc.setForeground(ColorResource.GRAY);
+//        } else {
+//            gc.setForeground(ColorResource.BLACK);
+//        }
+//        Font font = gc.getFont();
+//        gc.setFont(FontUtil.FLOATING);
+//        gc.drawText(model.getName(), drawRect.x + TEXT_MARGIN_X, targetY);
+//        gc.setFont(font);
+//    }
+//
+//    private Rectangle checkState(Rectangle rect, int state) {
+//
+//        int offset = 0;
+//        switch (state) {
+//            case STATE_NORMAL:
+//                offset = 2;
+//                break;
+//            case STATE_HOVER:
+//                offset = 0;
+//                break;
+//            case STATE_PUSH:
+//                offset = 5;
+//                break;
+//            case STATE_SELECTED:
+//                offset = 3;
+//                break;
+//            case STATE_DISABLED:
+//                offset = 2;
+//                break;
+//            default:
+//                break;
+//        }
+//        rect.width = rect.width - 8;
+//        rect.height = rect.height - 8;
+//        rect.x = rect.x + offset;
+//        rect.y = rect.y + offset;
+//        return rect;
+    }
+
+}
diff --git a/org.tizen.webuibuilder/src/org/tizen/webuibuilder/ui/views/nscreen/NScreenList.java b/org.tizen.webuibuilder/src/org/tizen/webuibuilder/ui/views/nscreen/NScreenList.java
deleted file mode 100644 (file)
index 74c3598..0000000
+++ /dev/null
@@ -1,232 +0,0 @@
-/*
- * UI Builder
- *
- * Copyright (c) 2000 - 2014 Samsung Electronics Co., Ltd. All rights reserved.
- *
- * 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.webuibuilder.ui.views.nscreen;
-
-import java.util.ArrayList;
-
-import org.eclipse.swt.SWT;
-import org.eclipse.swt.custom.ScrolledComposite;
-import org.eclipse.swt.events.ControlAdapter;
-import org.eclipse.swt.events.ControlEvent;
-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.tizen.webuibuilder.model.css.CssFile;
-import org.tizen.webuibuilder.ui.views.nscreen.model.NScreenPageModel;
-
-
-/**
- * The NScreenList class is responsible for a List is shown in the NScreenView.
- */
-public class NScreenList {
-    private Composite mContainer;
-    private ArrayList<NScreenListItem> mWidgetList;
-    private ScrolledComposite mScrolledContainer;
-    private NScreenPageModel mNScreenPageModel;
-
-    public NScreenPageModel getNScreenPageModel() {
-        return mNScreenPageModel;
-    }
-
-    private FormData makeFormData(NScreenListItem front) {
-        FormData fd_item = new FormData();
-        if (front == null) {
-            fd_item.top = new FormAttachment(0);
-        } else {
-            fd_item.top = new FormAttachment(front.mContainer, 3);
-        }
-        fd_item.left = new FormAttachment(0);
-        fd_item.right = new FormAttachment(100);
-        return fd_item;
-    }
-
-    /**
-     * list init method
-     * 
-     * @param parent
-     * @param nScreenPageModel
-     */
-    public NScreenList(Composite parent, NScreenPageModel nScreenPageModel) {
-        mNScreenPageModel = nScreenPageModel;
-
-        mWidgetList = new ArrayList<NScreenListItem>();
-        mScrolledContainer = new ScrolledComposite(parent, SWT.V_SCROLL);
-        mContainer = new Composite(mScrolledContainer, SWT.NONE);
-        mContainer.setLayout(new FormLayout());
-
-        mScrolledContainer.setContent(mContainer);
-        mScrolledContainer.setExpandVertical(true);
-        mScrolledContainer.setExpandHorizontal(true);
-        mScrolledContainer.addControlListener(new ControlAdapter() {
-            public void controlResized(ControlEvent e) {
-                Rectangle r = mScrolledContainer.getClientArea();
-                mScrolledContainer.setMinSize(mContainer.computeSize(r.width, SWT.DEFAULT));
-            }
-        });
-    }
-
-    /**
-     * NScreen Add method refer
-     * 
-     * @param model
-     * @param isSelected
-     * @return NScreenListItem instance
-     */
-    public NScreenListItem addItem(CssFile model, boolean isSelected) {
-        return addItem(mWidgetList.size(), model, isSelected);
-    }
-
-    /**
-     * NScreen Add method
-     * 
-     * @param index
-     * @param model
-     * @param isSelected
-     * @return NScreenListItem instance
-     */
-    public NScreenListItem addItem(int index, CssFile model, boolean isSelected) {
-        if (index > mWidgetList.size()) {
-            return null;
-        }
-
-        NScreenListItem item = new NScreenListItem(mContainer, this, model);
-
-        NScreenListItem front = null;
-        if (index != 0) {
-            front = mWidgetList.get(index - 1);
-        }
-        item.mContainer.setLayoutData(makeFormData(front));
-
-        if (index != mWidgetList.size()) {
-            mWidgetList.get(index).mContainer.setLayoutData(makeFormData(item));
-        }
-
-        mWidgetList.add(index, item);
-        if (isSelected) {
-            selected(item);
-        }
-        mNScreenPageModel.getPageData().addPageListener(item);
-        return item;
-    }
-
-    public void layout() {
-        mContainer.layout();
-        Rectangle r = mScrolledContainer.getClientArea();
-        mScrolledContainer.setMinSize(mContainer.computeSize(r.width, SWT.DEFAULT));
-    }
-
-    public Control getControl() {
-        return mScrolledContainer;
-    }
-
-    /**
-     * remove Nscreen
-     * 
-     * @param item
-     *            NscreenListItem to delete
-     */
-    public void removeItem(NScreenListItem item) {
-        for (int i = 0; i < mWidgetList.size(); i++) {
-            NScreenListItem listItem = mWidgetList.get(i);
-            if (listItem.equals(item)) {
-                removeItem(i);
-                return;
-            }
-        }
-
-    }
-
-    /**
-     * remove Nscreen
-     * 
-     * @param index
-     *            NscreenListItem index to delete
-     */
-    public void removeItem(int index) {
-        if (mWidgetList.size() < index + 1) {
-            return;
-        } else if (mWidgetList.size() > index + 1) {
-            if (index == 0) {
-                NScreenListItem back = mWidgetList.get(index + 1);
-                back.mContainer.setLayoutData(makeFormData(null));
-            } else {
-                NScreenListItem front = mWidgetList.get(index - 1);
-                NScreenListItem back = mWidgetList.get(index + 1);
-                back.mContainer.setLayoutData(makeFormData(front));
-            }
-        }
-
-        NScreenListItem removeItem = mWidgetList.remove(index);
-        removeItem.dispose();
-
-    }
-
-    public int size() {
-        return mWidgetList.size();
-    }
-
-    /**
-     * doing remove NscreenListItem, change selection to default Item.
-     */
-    public void defaultSelected() {
-        if (mWidgetList.size() == 0) {
-            return;
-        }
-        NScreenListItem item = mWidgetList.get(0);
-        item.clicked();
-    }
-
-    /**
-     * selction target listItem.
-     * 
-     * @param selectedItem
-     */
-    public void selected(NScreenListItem selectedItem) {
-
-        for (NScreenListItem item : mWidgetList) {
-            if (item.isSelected()) {
-                item.setSelected(false);
-            }
-        }
-        selectedItem.setSelected(true);
-
-    }
-
-    /**
-     * remove all NscreenListItems
-     */
-    public void removeAll() {
-        if (mWidgetList.size() == 0) {
-            return;
-        }
-        for (NScreenListItem item : mWidgetList) {
-            item.dispose();
-        }
-        mWidgetList.clear();
-    }
-
-}
diff --git a/org.tizen.webuibuilder/src/org/tizen/webuibuilder/ui/views/nscreen/NScreenListItem.java b/org.tizen.webuibuilder/src/org/tizen/webuibuilder/ui/views/nscreen/NScreenListItem.java
deleted file mode 100644 (file)
index dfeeab4..0000000
+++ /dev/null
@@ -1,333 +0,0 @@
-/*
- * UI Builder
- *
- * Copyright (c) 2000 - 2014 Samsung Electronics Co., Ltd. All rights reserved.
- *
- * 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.webuibuilder.ui.views.nscreen;
-
-import org.eclipse.swt.SWT;
-import org.eclipse.swt.events.FocusEvent;
-import org.eclipse.swt.events.FocusListener;
-import org.eclipse.swt.events.MouseAdapter;
-import org.eclipse.swt.events.MouseEvent;
-import org.eclipse.swt.events.MouseListener;
-import org.eclipse.swt.events.MouseTrackAdapter;
-import org.eclipse.swt.events.MouseTrackListener;
-import org.eclipse.swt.events.PaintEvent;
-import org.eclipse.swt.events.PaintListener;
-import org.eclipse.swt.events.SelectionAdapter;
-import org.eclipse.swt.events.SelectionEvent;
-import org.eclipse.swt.graphics.Color;
-import org.eclipse.swt.graphics.Rectangle;
-import org.eclipse.swt.layout.GridData;
-import org.eclipse.swt.layout.GridLayout;
-import org.eclipse.swt.widgets.Composite;
-import org.eclipse.swt.widgets.Control;
-import org.eclipse.swt.widgets.Display;
-import org.eclipse.swt.widgets.Label;
-import org.eclipse.swt.widgets.Menu;
-import org.eclipse.swt.widgets.MenuItem;
-import org.tizen.webuibuilder.model.css.CssFile;
-import org.tizen.webuibuilder.model.page.IPageDataListener;
-import org.tizen.webuibuilder.model.page.PageDataEvent;
-
-
-/**
- * The NScreenListItem class is responsible for every single item in NScreenList. The
- * NScreenListItem class that implements IPageDataListener.
- */
-public class NScreenListItem implements IPageDataListener {
-    private NScreenList mList;
-    private CssFile mModel;
-    public Composite mContainer;
-    public Composite mRightContainer;
-    // private NScreenListItemImageComposite mSnapShot;
-    private Label mSnapShot;
-    private Label mTitle;
-    private Label mWidthLabel;
-    private Label mHeightLabel;
-    private Label mCss;
-
-    private boolean mIsSelected = false;
-
-    private Menu mPopupMenu;
-    private MenuItem mPopupMenuAdd;
-    // private MenuItem mPopupMenuEdit;
-    private MenuItem mPopupMenuDel;
-
-    private MouseTrackListener mMouseTrackListener = new MouseTrackAdapter() {
-
-        @Override
-        public void mouseExit(MouseEvent e) {
-            Color color = null;
-            Color fontColor = null;
-            if (mIsSelected) {
-                color = e.display.getSystemColor(SWT.COLOR_LIST_SELECTION);
-                fontColor = e.display.getSystemColor(SWT.COLOR_LIST_SELECTION_TEXT);
-            } else {
-                color = e.display.getSystemColor(SWT.COLOR_WIDGET_BACKGROUND);
-                fontColor = e.display.getSystemColor(SWT.COLOR_LIST_FOREGROUND);
-            }
-            drawBackgroundAllControl(color, fontColor);
-        }
-
-        @Override
-        public void mouseEnter(MouseEvent e) {
-            Color color = e.display.getSystemColor(SWT.COLOR_TITLE_BACKGROUND_GRADIENT);
-            Color fontColor = e.display.getSystemColor(SWT.COLOR_LIST_FOREGROUND);
-            drawBackgroundAllControl(color, fontColor);
-        }
-
-    };
-    private MouseListener mMouseListener = new MouseAdapter() {
-
-        @Override
-        public void mouseUp(MouseEvent e) {
-            clicked();
-        }
-
-    };
-
-    private void drawBackgroundAllControl(Color backgroundColor, Color fontColor) {
-        Control[] children = mContainer.getChildren();
-        for (Control control : children) {
-            control.setBackground(backgroundColor);
-            control.setForeground(fontColor);
-        }
-        children = mRightContainer.getChildren();
-        for (Control control : children) {
-            control.setBackground(backgroundColor);
-            control.setForeground(fontColor);
-        }
-        mContainer.setBackground(backgroundColor);
-    }
-
-    private void createPopupMenu() {
-        mPopupMenu = new Menu(mContainer.getShell(), SWT.POP_UP);
-
-        mPopupMenuAdd = new MenuItem(mPopupMenu, SWT.PUSH);
-        mPopupMenuAdd.setText(NScreenViewMessages.ACTION_LABEL_ADD_NSCREEN);
-        mPopupMenuAdd.addSelectionListener(new SelectionAdapter() {
-            @Override
-            public void widgetSelected(SelectionEvent e) {
-                mList.getNScreenPageModel().getNScreenPage().customScreenDialogAddEdit(null);
-            }
-        });
-
-        if (mModel.getWidth() != 0) {
-            mPopupMenuDel = new MenuItem(mPopupMenu, SWT.PUSH);
-            mPopupMenuDel.setText(NScreenViewMessages.ACTION_LABEL_DEL_NSCREEN);
-            mPopupMenuDel.addSelectionListener(new SelectionAdapter() {
-
-                @Override
-                public void widgetSelected(SelectionEvent e) {
-                    mList.getNScreenPageModel().getNScreenPage()
-                            .deleteNScreen(NScreenListItem.this);
-                }
-
-            });
-        }
-    }
-
-    public void refreshImage() {
-        // mSnapShot.load();
-    }
-
-    public void clicked() {
-        mList.selected(NScreenListItem.this);
-        mContainer.setFocus();
-        mList.getNScreenPageModel().getPageDesigner().setNscreenIndex(mModel);
-        if (mModel.getWidth() != 0) {
-            mList.getNScreenPageModel().getPageDesigner()
-                    .setShowingSize(mModel.getWidth(), mModel.getHeight());
-        }
-    }
-
-    public void setSelected(boolean isSelected) {
-        if (mIsSelected == isSelected) {
-            return;
-        }
-        mIsSelected = isSelected;
-
-        Color color = null;
-        Color fontColor = null;
-        Display display = mContainer.getDisplay();
-        if (mIsSelected) {
-            color = display.getSystemColor(SWT.COLOR_LIST_SELECTION);
-            fontColor = display.getSystemColor(SWT.COLOR_LIST_SELECTION_TEXT);
-        } else {
-            color = display.getSystemColor(SWT.COLOR_WIDGET_BACKGROUND);
-            fontColor = display.getSystemColor(SWT.COLOR_LIST_FOREGROUND);
-        }
-        drawBackgroundAllControl(color, fontColor);
-    }
-
-    public boolean isSelected() {
-        return mIsSelected;
-    }
-
-    public void setTitleText(String text) {
-        mTitle.setText(text);
-    }
-
-    public void setWidthText(String text) {
-        mWidthLabel.setText(text);
-    }
-
-    public void setHeightText(String text) {
-        mHeightLabel.setText(text);
-    }
-
-    public void setCssText(String text) {
-        mCss.setText(text);
-    }
-
-    public NScreenListItem(Composite parent, NScreenList nScreenList, CssFile model) {
-        mList = nScreenList;
-        mModel = model;
-        mContainer = new Composite(parent, SWT.NONE);
-        mContainer.setLayout(new GridLayout(2, false));
-        mContainer.addMouseTrackListener(mMouseTrackListener);
-        mContainer.addMouseListener(mMouseListener);
-        mContainer.addFocusListener(new FocusListener() {
-
-            @Override
-            public void focusLost(FocusEvent e) {
-                mContainer.redraw();
-            }
-
-            @Override
-            public void focusGained(FocusEvent e) {
-                mContainer.redraw();
-            }
-        });
-        mContainer.addPaintListener(new PaintListener() {
-            @Override
-            public void paintControl(PaintEvent e) {
-                Rectangle rect = mContainer.getBounds();
-                if (mContainer.isFocusControl()) {
-                    e.gc.drawFocus(5, 5, rect.width - 10, rect.height - 10);
-                }
-            }
-        });
-
-        createChildren();
-        createPopupMenu();
-
-        Control[] children = mContainer.getChildren();
-        for (Control control : children) {
-            control.addMouseTrackListener(mMouseTrackListener);
-            control.addMouseListener(mMouseListener);
-            control.setMenu(mPopupMenu);
-        }
-        children = mRightContainer.getChildren();
-        for (Control control : children) {
-            control.addMouseTrackListener(mMouseTrackListener);
-            control.addMouseListener(mMouseListener);
-            control.setMenu(mPopupMenu);
-        }
-        mContainer.setMenu(mPopupMenu);
-    }
-
-    public String makeWidthText(int width) {
-        if (width == 0) {
-            return "width : default";
-        }
-        return "width : " + width;
-    }
-
-    public String makeHeightText(int height) {
-        if (height == 0) {
-            return "height : default";
-        }
-        return "height : " + height;
-    }
-
-    private void createChildren() {
-        // mSnapShot = new NScreenListItemImageComposite(mContainer, SWT.NONE,
-        // mList.getNScreenPageModel(), mModel);
-        mSnapShot = new Label(mContainer, SWT.NONE | SWT.NO_FOCUS);
-        GridData data =
-                new GridData(GridData.HORIZONTAL_ALIGN_CENTER | GridData.VERTICAL_ALIGN_CENTER);
-        mSnapShot.setLayoutData(data);
-
-        mRightContainer = new Composite(mContainer, SWT.NONE);
-        data =
-                new GridData(GridData.HORIZONTAL_ALIGN_BEGINNING | GridData.VERTICAL_ALIGN_CENTER
-                        | GridData.FILL_BOTH);
-        mRightContainer.setLayoutData(data);
-        mRightContainer.setLayout(new GridLayout(1, true));
-
-        mTitle = new Label(mRightContainer, SWT.NONE | SWT.NO_FOCUS);
-        mTitle.setText(mModel.getTitle());
-        data = new GridData();
-        data.verticalAlignment = SWT.CENTER;
-        data.grabExcessVerticalSpace = true;
-        mTitle.setLayoutData(data);
-
-        mWidthLabel = new Label(mRightContainer, SWT.NONE | SWT.NO_FOCUS);
-        mWidthLabel.setText(makeWidthText(mModel.getWidth()));
-        data = new GridData();
-        data.verticalAlignment = SWT.CENTER;
-        data.grabExcessVerticalSpace = true;
-        mWidthLabel.setLayoutData(data);
-
-        mHeightLabel = new Label(mRightContainer, SWT.NONE | SWT.NO_FOCUS);
-        mHeightLabel.setText(makeHeightText(mModel.getHeight()));
-        data = new GridData();
-        data.verticalAlignment = SWT.CENTER;
-        data.grabExcessVerticalSpace = true;
-        mHeightLabel.setLayoutData(data);
-
-        mCss = new Label(mRightContainer, SWT.NONE | SWT.NO_FOCUS);
-        mCss.setText(mModel.getFileName());
-        data = new GridData();
-        data.verticalAlignment = SWT.CENTER;
-        data.grabExcessVerticalSpace = true;
-        mCss.setLayoutData(data);
-    }
-
-    public CssFile getModel() {
-        return mModel;
-    }
-
-    /**
-     * dispose this instance
-     */
-    public void dispose() {
-        mList = null;
-        mModel = null;
-        mContainer.dispose();
-    }
-
-    @Override
-    public void pagePreDelete(PageDataEvent e) {
-    }
-
-    @Override
-    public void pageRenamed(PageDataEvent e) {
-    }
-
-    @Override
-    public void pageChanged(PageDataEvent e) {
-    }
-
-}
diff --git a/org.tizen.webuibuilder/src/org/tizen/webuibuilder/ui/views/nscreen/NScreenListItemImageComposite.java b/org.tizen.webuibuilder/src/org/tizen/webuibuilder/ui/views/nscreen/NScreenListItemImageComposite.java
deleted file mode 100644 (file)
index 823a3cd..0000000
+++ /dev/null
@@ -1,231 +0,0 @@
-/*
- * UI Builder
- *
- * Copyright (c) 2000 - 2014 Samsung Electronics Co., Ltd. All rights reserved.
- *
- * 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.webuibuilder.ui.views.nscreen;
-
-import java.util.Map.Entry;
-
-import org.eclipse.swt.graphics.Rectangle;
-import org.eclipse.swt.widgets.Composite;
-import org.tizen.webuibuilder.browserwidget.ImageBufferedBrowserWidget;
-import org.tizen.webuibuilder.model.app.AppManager;
-import org.tizen.webuibuilder.model.app.Framework;
-import org.tizen.webuibuilder.model.app.Library;
-import org.tizen.webuibuilder.model.app.Meta;
-import org.tizen.webuibuilder.model.app.Stylesheet;
-import org.tizen.webuibuilder.model.css.CssFile;
-import org.tizen.webuibuilder.ui.views.nscreen.model.NScreenPageModel;
-import org.tizen.webuibuilder.ui.views.pages.PagesViewMessages;
-import org.tizen.webuibuilder.utility.FileIo;
-
-
-/**
- * The NScreenListItemImageComposite class is responsible for widget that receives the inheritance
- * Composite, to display the thumbnail screen overall in the List item.
- */
-public class NScreenListItemImageComposite extends Composite {
-
-    private static final int DEF_BROWSER_WIDTH = 360;
-    private static final int DEF_BROWSER_HEIGHT = 640;
-
-    private int browserWidth = DEF_BROWSER_WIDTH;
-    private int browserHeight = DEF_BROWSER_HEIGHT;
-
-    private static final int MARGIN_TOP = 7;
-    private static final int IMAGE_X = 18;
-    private static final int IMAGE_Y = MARGIN_TOP;
-    private static final int IMAGE_WIDTH = 64;
-    private static final int IMAGE_HEIGHT = 96;
-
-    private Rectangle mImageAreaRectangle = null;
-    private ImageBufferedBrowserWidget mImageBufferedBrowserWidget = null;
-
-    private NScreenPageModel mNScreenPageModel;
-    private CssFile mModel;
-
-    public NScreenListItemImageComposite(Composite parent, int style,
-            NScreenPageModel nScreenPageModel, CssFile model) {
-        super(parent, style);
-        // setLayout(new FillLayout(SWT.VERTICAL));
-        mNScreenPageModel = nScreenPageModel;
-        mModel = model;
-        mImageBufferedBrowserWidget =
-                new ImageBufferedBrowserWidget(this, style, null, false, true);
-        recalBrowserArea();
-        mImageBufferedBrowserWidget.setEnabled(false);
-        mImageBufferedBrowserWidget.setVisible(true);
-        load();
-    }
-
-    public void load() {
-        String theme = mNScreenPageModel.getAppManager().getFrameworkTheme();
-        String scale = mNScreenPageModel.getAppManager().getFrameworkScale();
-        String html = mNScreenPageModel.makeHtml();
-        if (html == null) {
-            return;
-        }
-        String css = mNScreenPageModel.makeCSS(mModel);
-        update(html, css, theme, scale);
-    }
-
-    private String makeParamString(String param) {
-        for (Entry<String, String> variable : mNScreenPageModel.getAppManager()
-                .getFrameworkVariables().entrySet()) {
-            param = param.replace("%" + variable.getKey() + "%", variable.getValue());
-        }
-
-        return param;
-    }
-
-    private void recalBrowserArea() {
-        mImageBufferedBrowserWidget.setBrowserSize(browserWidth, browserHeight);
-
-        float scale = (float) IMAGE_WIDTH / browserWidth;
-        int w = IMAGE_WIDTH;
-        int h = IMAGE_WIDTH * browserHeight / browserWidth;
-        if (h > IMAGE_HEIGHT) {
-            scale = (float) IMAGE_HEIGHT / browserHeight;
-            h = IMAGE_HEIGHT;
-            w = IMAGE_HEIGHT * browserWidth / browserHeight;
-        }
-        mImageAreaRectangle =
-                new Rectangle(IMAGE_X + (IMAGE_WIDTH - w) / 2, IMAGE_Y + (IMAGE_HEIGHT - h) / 2, w,
-                              h);
-        mImageBufferedBrowserWidget.setZoomScale(scale);
-        mImageBufferedBrowserWidget.setSize(mImageAreaRectangle.width, mImageAreaRectangle.height);
-        mImageBufferedBrowserWidget.setLocation(mImageAreaRectangle.x, mImageAreaRectangle.y);
-    }
-
-    public void update(String body, String css, String theme, String scale) {
-        // String contents = ResourceManager.getString(TEMP_FILE);
-        AppManager mAppManager = mNScreenPageModel.getAppManager();
-        String tempFilePath = mAppManager.getFileFullPath(PagesViewMessages.FILE_THUMBNAIL_HTML);
-        String html = FileIo.readFile(tempFilePath);
-
-        String pagePathUri = mNScreenPageModel.getPagePathUri();
-        if (html != null) {
-            String rootPathUri = mNScreenPageModel.getRootPathUri();
-            html = html.replace("%root_path%", rootPathUri);
-            html = html.replace("%page_path%", pagePathUri);
-
-            String framework_script = new String("");
-            for (Library library : mAppManager.getAppFileData().getLibraries()) {
-                if (library.getType().equals("framework")) {
-                    if (!framework_script.isEmpty()) {
-                        framework_script = framework_script + "\n";
-                    }
-                    Framework framework =
-                            mAppManager.getAppFileData().findFramework(library.getParam());
-                    if (framework == null) {
-                        framework_script = framework_script + "<script></script>";
-                    } else {
-                        framework_script =
-                                framework_script + "<script src=\"" + rootPathUri + "/"
-                                        + framework.getPath() + "\"";
-                        if (framework.getParam2() != null && !framework.getParam2().isEmpty()) {
-                            String param = new String(framework.getParam2());
-                            param = makeParamString(param);
-                            framework_script = framework_script + param;
-                        }
-                        framework_script = framework_script + "></script>";
-                    }
-                }
-            }
-
-            String metaTag = new String("");
-            for (Meta meta : mAppManager.getAppFileData().getMetas()) {
-                if (!metaTag.isEmpty()) {
-                    metaTag = metaTag + "\n";
-                }
-                metaTag = metaTag + "<meta";
-                if (meta.getParam() != null && !meta.getParam().isEmpty()) {
-                    String param = new String(meta.getParam());
-                    param = makeParamString(param);
-                    metaTag = metaTag + " " + param;
-                }
-                if (meta.getParam2() != null && !meta.getParam2().isEmpty()) {
-                    String param = new String(meta.getParam2());
-                    param = makeParamString(param);
-                    metaTag = metaTag + " " + param;
-                }
-                metaTag = metaTag + ">";
-            }
-
-            String styleTag = new String("");
-            for (Stylesheet style : mAppManager.getAppFileData().getStylesheets()) {
-                if (!styleTag.isEmpty()) {
-                    styleTag = styleTag + "\n";
-                }
-
-                styleTag =
-                        styleTag + "<link rel=\"stylesheet\" type=\"text/css\" href=\""
-                                + rootPathUri + "/";
-                if (style.getParam() != null && !style.getParam().isEmpty()) {
-                    String param = new String(style.getParam());
-                    param = makeParamString(param);
-                    styleTag = styleTag + param;
-                }
-                styleTag = styleTag + "\"";
-
-                if (style.getParam2() != null && !style.getParam2().isEmpty()) {
-                    String param = new String(style.getParam2());
-                    param = makeParamString(param);
-                    styleTag = styleTag + " " + param;
-                }
-
-                styleTag = styleTag + ">";
-            }
-
-            html = html.replace("%meta%", metaTag);
-            html = html.replace("%framework%", framework_script);
-            html = html.replace("%style%", styleTag);
-
-            html = html.replace("%framwork_theme%", theme);
-            html = html.replace("%framwork_scale%", scale);
-            html = html.replace("%tool_path%", mNScreenPageModel.getToolPathUri());
-            html =
-                    html.replace("%page_css_path%", rootPathUri + "/"
-                            + mNScreenPageModel.getPageData().getCssPath());
-            html = html.replace("%css%", css);
-            html = html.replace("%html%", body);
-        } else {
-            // do nothing
-        }
-
-        if (scale.equals("device-width")) {
-            browserWidth = 360;
-            browserHeight = 640;
-        } else if (scale.equals("screen-width")) {
-            browserWidth = 720;
-            browserHeight = 1280;
-        } else if (scale.equals("720")) {
-            browserWidth = 720;
-            browserHeight = 1280;
-        } else if (scale.equals("480")) {
-            browserWidth = 480;
-            browserHeight = 800;
-        }
-        recalBrowserArea();
-        mImageBufferedBrowserWidget.setHtml(html, pagePathUri);
-    }
-}
index b1c6c89..78c5b8c 100644 (file)
 
 package org.tizen.webuibuilder.ui.views.nscreen;
 
-import java.io.File;
 import java.util.List;
 
-import org.eclipse.core.runtime.IPath;
-import org.eclipse.gef.commands.Command;
-import org.eclipse.jface.action.Action;
-import org.eclipse.jface.action.IMenuManager;
-import org.eclipse.jface.action.Separator;
-import org.eclipse.jface.dialogs.MessageDialog;
+import org.eclipse.swt.SWT;
 import org.eclipse.swt.widgets.Composite;
 import org.eclipse.swt.widgets.Control;
-import org.eclipse.ui.IActionBars;
 import org.eclipse.ui.part.Page;
-import org.tizen.webuibuilder.model.css.CssFile;
+import org.tizen.webuibuilder.model.nscreen.NScreenModel;
 import org.tizen.webuibuilder.ui.views.nscreen.model.NScreenPageModel;
 
 
@@ -45,184 +38,19 @@ import org.tizen.webuibuilder.ui.views.nscreen.model.NScreenPageModel;
  */
 public class NScreenPage extends Page {
     private final NScreenPageModel mNScreenPageModel;
-
-    private Action mActionTizenWVGA;
-    private Action mActionTizenHD;
-    private Action mActionWVGA;
-    private Action mActionWVGAL;
-    private Action mActionHD;
-    private Action mActionHDL;
-    private Action mActionCustom;
-    private NScreenList mNScreenList;
-    private Composite mParentComposite;
-
-    class NScrrenAction extends Action {
-        private String mTitle;
-        private int mWidth;
-        private int mHeight;
-        private String mCssFileName;
-
-        public NScrrenAction(String actionName, String title, int width, int height,
-                String cssFileName) {
-            mTitle = title;
-            mWidth = width;
-            mHeight = height;
-            mCssFileName = cssFileName + ".css";
-
-            this.setText(actionName);
-        }
-
-        @Override
-        public void run() {
-            if (existNscreen(mWidth)) {
-                showAlreadyExistsDialog();
-                return;
-            }
-            addNewNscreen(mTitle, mWidth, mHeight, mCssFileName, false);
-        }
-    }
-
-    private void makeActions() {
-        String templateText = NScreenViewMessages.ACTION_TIZEN_320;
-        int width = Integer.parseInt(NScreenViewMessages.TIZEN_320_WIDTH);
-        int height = Integer.parseInt(NScreenViewMessages.TIZEN_320_HEIGHT);
-        mActionTizenWVGA =
-                new NScrrenAction(templateText, templateText, width, height, templateText);
-
-        templateText = NScreenViewMessages.ACTION_TIZEN_360;
-        width = Integer.parseInt(NScreenViewMessages.TIZEN_360_WIDTH);
-        height = Integer.parseInt(NScreenViewMessages.TIZEN_360_HEIGHT);
-        mActionTizenHD = new NScrrenAction(templateText, templateText, width, height, templateText);
-
-        templateText = NScreenViewMessages.ACTION_WVGA;
-        width = Integer.parseInt(NScreenViewMessages.WVGA_WIDTH);
-        height = Integer.parseInt(NScreenViewMessages.WVGA_HEIGHT);
-        mActionWVGA = new NScrrenAction(templateText, templateText, width, height, templateText);
-
-        templateText = NScreenViewMessages.ACTION_HD;
-        width = Integer.parseInt(NScreenViewMessages.HD_WIDTH);
-        height = Integer.parseInt(NScreenViewMessages.HD_HEIGHT);
-        mActionHD = new NScrrenAction(templateText, templateText, width, height, templateText);
-
-        templateText = NScreenViewMessages.ACTION_WVGA_LAND;
-        width = Integer.parseInt(NScreenViewMessages.WVGA_HEIGHT);
-        height = Integer.parseInt(NScreenViewMessages.WVGA_WIDTH);
-        mActionWVGAL = new NScrrenAction(templateText, templateText, width, height, templateText);
-
-        templateText = NScreenViewMessages.ACTION_HD_LAND;
-        width = Integer.parseInt(NScreenViewMessages.HD_HEIGHT);
-        height = Integer.parseInt(NScreenViewMessages.HD_WIDTH);
-        mActionHDL = new NScrrenAction(templateText, templateText, width, height, templateText);
-
-        mActionCustom = new Action() {
-            @Override
-            public void run() {
-                NScreenCustomDialog dialog =
-                        new NScreenCustomDialog(mParentComposite.getShell(), NScreenPage.this, null);
-                dialog.open();
-            }
-        };
-        mActionCustom.setText(NScreenViewMessages.ACTION_CUSTOM);
-        mActionCustom.setEnabled(true);
-
-    }
-
-    private void showInfomationDialog(String message) {
-        MessageDialog dialog =
-                new MessageDialog(mParentComposite.getShell(),
-                                  NScreenViewMessages.LABEL_INFORMATION, null, message,
-                                  MessageDialog.INFORMATION,
-                                  new String[] { NScreenViewMessages.LABEL_OK }, 0);
-        dialog.open();
-    }
-
-    private void showAlreadyExistsDialog() {
-        MessageDialog dialog =
-                new MessageDialog(mParentComposite.getShell(),
-                                  NScreenViewMessages.LABEL_INFORMATION, null,
-                                  NScreenViewMessages.LABEL_ALREADY_EXISTS,
-                                  MessageDialog.INFORMATION,
-                                  new String[] { NScreenViewMessages.LABEL_OK }, 0);
-        dialog.open();
-    }
+    private NScreenBaseComposite mParentComposite;
 
     public boolean existNscreen(int width) {
-        List<CssFile> list = mNScreenPageModel.getPageData().getCssFiles();
-        for (CssFile cssFile : list) {
-            if (cssFile.getWidth() == width) {
+        List<NScreenModel> list =
+                mNScreenPageModel.getAppManager().getNScreenModelManger().getNScreenModels();
+        for (NScreenModel model : list) {
+            if (model.getWidth() == width) {
                 return true;
             }
         }
         return false;
     }
 
-    /**
-     * before calling this method, First, it is possible to confirm whether it is possible to add
-     * call existNscreen(int width)
-     * 
-     * @param width
-     * @param cssFileName
-     * @param isSelected
-     */
-    public void addNewNscreen(String title, int width, int height, String cssFileName,
-                              boolean isSelected) {
-        String filePath = mNScreenPageModel.getAppManager().getCssFolder();
-
-        File newCSSFile = new File(filePath + IPath.SEPARATOR + cssFileName);
-        String cssFileFullPath = newCSSFile.getAbsolutePath();
-
-        CssFile model = new CssFile(title, width, height, cssFileName, cssFileFullPath);
-
-        Command command =
-                new NScreenAddCommand(mNScreenPageModel.getPageData().getCssFiles(), model,
-                                      mNScreenList);
-        mNScreenPageModel.getPageDesigner().getCommandStack().execute(command);
-    }
-
-    public void customScreenDialogAddEdit(NScreenListItem item) {
-        if (item == null) {
-            mActionCustom.run();
-        } else {
-            NScreenCustomDialog dialog =
-                    new NScreenCustomDialog(mParentComposite.getShell(), NScreenPage.this, item);
-            dialog.open();
-        }
-    }
-
-    public void deleteNScreen(NScreenListItem item) {
-        List<CssFile> list = mNScreenPageModel.getPageData().getCssFiles();
-        if (list.get(0) == item.getModel()) {
-            showInfomationDialog("can not delete the default screen.");
-            return;
-        }
-        mNScreenList.defaultSelected();
-        Command command = new NScreenDeleteCommand(list, item, mNScreenList);
-        mNScreenPageModel.getPageDesigner().getCommandStack().execute(command);
-    }
-
-    private void contributeToActionBars() {
-        IActionBars bars = getSite().getActionBars();
-        IMenuManager manager = bars.getMenuManager();
-
-        manager.add(mActionTizenWVGA);
-        manager.add(mActionTizenHD);
-
-        manager.add(new Separator());
-
-        manager.add(mActionWVGA);
-        manager.add(mActionHD);
-
-        manager.add(new Separator());
-
-        manager.add(mActionWVGAL);
-        manager.add(mActionHDL);
-
-        manager.add(new Separator());
-
-        manager.add(mActionCustom);
-
-    }
-
     public NScreenPage(NScreenPageModel nScreenPageModel) {
         mNScreenPageModel = nScreenPageModel;
         mNScreenPageModel.setNScreenPage(this);
@@ -235,7 +63,7 @@ public class NScreenPage extends Page {
      * @see org.eclipse.ui.part.Page#dispose()
      */
     public void dispose() {
-        mNScreenList.removeAll();
+        // mNScreenList.removeAll();
         super.dispose();
     }
 
@@ -246,20 +74,41 @@ public class NScreenPage extends Page {
      * @see org.eclipse.ui.part.Page#createControl(org.eclipse.swt.widgets.Composite)
      */
     public void createControl(Composite parent) {
-        mParentComposite = parent;
-
-        makeActions();
-        contributeToActionBars();
-
-        mNScreenList = new NScreenList(parent, mNScreenPageModel);
-
-        List<CssFile> list = mNScreenPageModel.getPageData().getCssFiles();
+        mParentComposite = new NScreenBaseComposite(parent, SWT.NONE, mNScreenPageModel);
+        // addSample();
+        List<NScreenModel> models =
+                mNScreenPageModel.getAppManager().getNScreenModelManger().getNScreenModels();
+        List<NScreenGroup> groups = mParentComposite.getNScreenGroups();
+        NScreenGroup group = null;
+
+        for (NScreenModel model : models) {
+            if (groups.size() == 0) {
+                group =
+                        mParentComposite.createNewGroup(model.getType(), mNScreenPageModel
+                                .getPageData().getName());
+                group.setHeight(50);
+                NScreenItem rootItem = group.addItem(model);
+            } else {
+                NScreenGroup selectedGroup = null;
+                for (NScreenGroup g : groups) {
+                    if (g.getType() == model.getType()) {
+                        selectedGroup = g;
+                        break;
+                    }
+                }
+                if (selectedGroup == null) {
+                    group = mParentComposite.createNewGroup(model.getType(), null);
+                    group.setHeight(50);
+                    group.addItem(model);
+                } else {
+                    selectedGroup.addItem(model);
+                }
+            }
+        }
 
-        for (int i = 0, size = list.size(); i < size; i++) {
-            CssFile cssFileItem = list.get(i);
-            mNScreenList.addItem(cssFileItem, i == 0 ? true : false);
+        for (NScreenGroup g : mParentComposite.getNScreenGroups()) {
+            g.createLinkTree();
         }
-        mNScreenList.layout();
     }
 
     @Override
@@ -269,7 +118,8 @@ public class NScreenPage extends Page {
      * @see org.eclipse.ui.part.Page#getControl()
      */
     public Control getControl() {
-        return mNScreenList.getControl();
+        return mParentComposite;
+        // return mNScreenList.getControl();
     }
 
     @Override
diff --git a/org.tizen.webuibuilder/src/org/tizen/webuibuilder/ui/views/nscreen/NScreenSimpleRenderer.java b/org.tizen.webuibuilder/src/org/tizen/webuibuilder/ui/views/nscreen/NScreenSimpleRenderer.java
new file mode 100644 (file)
index 0000000..849d74e
--- /dev/null
@@ -0,0 +1,249 @@
+
+
+package org.tizen.webuibuilder.ui.views.nscreen;
+
+import static org.tizen.webuibuilder.ui.views.nscreen.NScreenItem.STATE_HOVER;
+import static org.tizen.webuibuilder.ui.views.nscreen.NScreenItem.STATE_NORMAL;
+import static org.tizen.webuibuilder.ui.views.nscreen.NScreenItem.STATE_PUSH;
+
+import org.eclipse.swt.graphics.Color;
+import org.eclipse.swt.graphics.Font;
+import org.eclipse.swt.graphics.GC;
+import org.eclipse.swt.graphics.Image;
+import org.eclipse.swt.graphics.Point;
+import org.eclipse.swt.graphics.Rectangle;
+import org.eclipse.swt.widgets.Canvas;
+import org.tizen.webuibuilder.animator.ui.views.timeline.common.ColorResource;
+import org.tizen.webuibuilder.model.nscreen.NScreenModel;
+import org.tizen.webuibuilder.model.nscreen.NScreenModel.NScreenType;
+
+
+public class NScreenSimpleRenderer implements INScreenDrawRenderer {
+    private static int X_MARGIN = 10;
+
+    @Override
+    public void draw(GC gc, Canvas canvas, int state, boolean isSelected, boolean isEnabled,
+                     Image thumb, NScreenModel model, String pageId) {
+        NScreenItem item = (NScreenItem) canvas.getParent();
+        NScreenGroup group = (NScreenGroup) item.getParent();
+        int size = group.getItems().size();
+        int index = group.getItems().indexOf(item);
+        Rectangle rect = canvas.getClientArea();
+
+        gc.setBackground(checkBackgroundColor(canvas, state, isSelected, isEnabled));
+        gc.fillRectangle(rect);
+
+        gc.setForeground(ColorResource.BLACK);
+        if (index == 0 || index == size - 1) {
+            if (index == size - 1) {
+                gc.drawRectangle(rect.x, rect.y, rect.width - 1, rect.height - 1);
+                gc.drawRectangle(rect.x + 1, rect.y - 1, rect.width - 3, rect.height - 1);
+
+            }
+            if (index == 0) {
+                gc.drawRectangle(rect.x, rect.y, rect.width - 1, rect.height);
+                gc.drawRectangle(rect.x + 1, rect.y + 1, rect.width - 3, rect.height + 4);
+            }
+        } else {
+            gc.drawRectangle(rect.x, rect.y, rect.width - 1, rect.height);
+            gc.drawRectangle(rect.x + 1, rect.y, rect.width - 3, rect.height);
+        }
+
+        // draw image
+        Image img = NScreenUtil.getScreenImage(model);
+        if (img != null) {
+            Rectangle imgRect = img.getBounds();
+            int yPosition = rect.y + (rect.height - imgRect.height) / 2;
+            gc.drawImage(img, rect.x + X_MARGIN, yPosition);
+        }
+        Font font = gc.getFont();
+        gc.setForeground(checkForegroundColor(canvas, state, isSelected, isEnabled));
+        setContents(canvas, model, gc);
+        gc.setFont(font);
+    }
+
+    private Color checkBackgroundColor(Canvas canvas, int state, boolean selected, boolean enabled) {
+        Color color = null;
+        switch (state) {
+            case STATE_NORMAL:
+                if (selected) {
+                    if (enabled) {
+                        // selected - enable
+                        color = ColorResource.NSE_BG;
+                    } else {
+                        // selected - disable
+                        color = ColorResource.NSD_BG;
+                    }
+                } else {
+                    if (enabled) {
+                        // normal - enable
+                        color = ColorResource.NNE_BG;
+                    } else {
+                        // normal - disable
+                        color = ColorResource.NND_BG;
+                    }
+                }
+                break;
+            case STATE_HOVER:
+                if (selected) {
+                    if (enabled) {
+                        // hover selected enabled
+                        color = ColorResource.HSE_BG;
+                    } else {
+                        // hover selected disabled
+                        color = ColorResource.HSD_BG;
+                    }
+                } else {
+                    if (enabled) {
+                        // hover normal enabled
+                        color = ColorResource.HNE_BG;
+                    } else {
+                        // hover normal disabled
+                        color = ColorResource.HND_BG;
+                    }
+                }
+                break;
+            case STATE_PUSH:
+                if (selected) {
+                    if (enabled) {
+                        // pushed selected enabled
+                        color = ColorResource.PSE_BG;
+                    } else {
+                        // pushed selected disabled
+                        color = ColorResource.PSD_BG;
+                    }
+                } else {
+                    if (enabled) {
+                        // pushed normal enabled
+                        color = ColorResource.PNE_BG;
+                    } else {
+                        // pushed normal disabled
+                        color = ColorResource.PND_BG;
+                    }
+                }
+                break;
+            default:
+                break;
+        }
+        return color;
+    }
+
+    private Color checkForegroundColor(Canvas canvas, int state, boolean selected, boolean enabled) {
+        Color color = null;
+        switch (state) {
+            case STATE_NORMAL:
+                if (selected) {
+                    if (enabled) {
+                        // selected - enable
+                        color = ColorResource.NSE_FG;
+                    } else {
+                        // selected - disable
+                        color = ColorResource.NSD_FG;
+                    }
+                } else {
+                    if (enabled) {
+                        // normal - enable
+                        color = ColorResource.NNE_FG;
+                    } else {
+                        // normal - disable
+                        color = ColorResource.NND_FG;
+                    }
+                }
+                break;
+            case STATE_HOVER:
+                if (selected) {
+                    if (enabled) {
+                        // hover selected enabled
+                        color = ColorResource.HSE_FG;
+                    } else {
+                        // hover selected disabled
+                        color = ColorResource.HSD_FG;
+                    }
+                } else {
+                    if (enabled) {
+                        // hover normal enabled
+                        color = ColorResource.HNE_FG;
+                    } else {
+                        // hover normal disabled
+                        color = ColorResource.HND_FG;
+                    }
+                }
+                break;
+            case STATE_PUSH:
+                if (selected) {
+                    if (enabled) {
+                        // pushed selected enabled
+                        color = ColorResource.PSE_FG;
+                    } else {
+                        // pushed selected disabled
+                        color = ColorResource.PSD_FG;
+                    }
+                } else {
+                    if (enabled) {
+                        // pushed normal enabled
+                        color = ColorResource.PNE_FG;
+                    } else {
+                        // pushed normal disabled
+                        color = ColorResource.PND_FG;
+                    }
+                }
+                break;
+            default:
+                break;
+        }
+        return color;
+    }
+
+    private Font getGroupFont(NScreenModel model) {
+        Font font = null;
+        NScreenType type = model.getType();
+        if (type == NScreenType.COMMON) {
+            font = FontUtil.COMMON;
+        } else if (type == NScreenType.ORIENTATION) {
+            font = FontUtil.ORIENTATION;
+        } else if (type == NScreenType.PIXELRATIO) {
+            font = FontUtil.PIXELRATIO;
+        } else if (type == NScreenType.RESOLUTION) {
+            font = FontUtil.DEVICE;
+        } else {
+            font = FontUtil.DEVICE;
+        }
+
+        return font;
+    }
+
+    private void setContents(Canvas canvas, NScreenModel model, GC gc) {
+        // int targetY = (canvas.getClientArea().height - IMAGE_SIZE) / 2;
+        Rectangle rect = canvas.getClientArea();
+        NScreenType type = model.getType();
+        if (type == NScreenType.COMMON || type == NScreenType.ORIENTATION
+                || type == NScreenType.PIXELRATIO) {
+            gc.setFont(getGroupFont(model));
+            String content = model.getName();
+            Point textWH = FontUtil.getTextArea(content, gc);
+            int x = rect.x + (rect.width - textWH.x) / 2;
+            int y = rect.y + (rect.height - textWH.y) / 2;
+            gc.drawText(content, x, y, true);
+        } else if (type == NScreenType.RESOLUTION) {
+            gc.setFont(getGroupFont(model));
+            String content1 = model.getName();
+            // String content2 =
+            // NScreenUtil.getResolutionText(model.getDeviceWidth(), model.getDeviceHeight(),
+            // false)
+            // + "  "
+            // + NScreenUtil.getRatioText(model.getDeviceWidth(),
+            // model.getDeviceHeight(), true);
+            Point content1WH = FontUtil.getTextArea(content1, gc);
+            // Point content2WH = FontUtil.getTextArea(content2, gc);
+            int x1 = rect.x + (rect.width - content1WH.x) / 2;
+            // int x2 = rect.x + (rect.width - content2WH.x) / 2;
+            // int y1 = rect.y + (rect.height - content1WH.y - content2WH.y) / 2;
+            int y1 = rect.y + (rect.height - content1WH.y) / 2;
+            // int y2 = y1 + content1WH.y;
+            gc.drawText(content1, x1, y1, true);
+            // gc.drawText(content2, x2, y2, true);
+        } else {
+
+        }
+    }
+}
diff --git a/org.tizen.webuibuilder/src/org/tizen/webuibuilder/ui/views/nscreen/NScreenUtil.java b/org.tizen.webuibuilder/src/org/tizen/webuibuilder/ui/views/nscreen/NScreenUtil.java
new file mode 100644 (file)
index 0000000..ff2b474
--- /dev/null
@@ -0,0 +1,193 @@
+
+
+package org.tizen.webuibuilder.ui.views.nscreen;
+
+import java.io.Closeable;
+import java.io.File;
+import java.io.FileInputStream;
+import java.io.FileNotFoundException;
+import java.io.FileOutputStream;
+import java.io.IOException;
+import java.net.ServerSocket;
+import java.net.Socket;
+
+import org.eclipse.swt.graphics.Image;
+import org.tizen.webuibuilder.BuilderConstants;
+import org.tizen.webuibuilder.model.nscreen.NScreenModel;
+import org.tizen.webuibuilder.model.nscreen.NScreenModel.NScreenType;
+import org.tizen.webuibuilder.model.nscreen.NScreenModel.Orientation;
+import org.tizen.webuibuilder.utility.ResourceManager;
+
+
+public class NScreenUtil {
+    public static boolean copyFile(String srcPath, String destPath) {
+        boolean success = false;
+        FileInputStream fi = null;
+        FileOutputStream fo = null;
+        try {
+            File src = new File(srcPath);
+            File dest = new File(destPath);
+            fi = new FileInputStream(src);
+            fo = new FileOutputStream(dest);
+            byte[] buffer = new byte[1024];
+            int readCount = 0;
+            while ((readCount = fi.read(buffer)) != -1) {
+                fo.write(buffer, 0, readCount);
+            }
+            success = true;
+        } catch (NullPointerException e) {
+            e.printStackTrace();
+        } catch (FileNotFoundException e) {
+            e.printStackTrace();
+        } catch (IOException e) {
+            e.printStackTrace();
+        } finally {
+            tryClose(fi, fo);
+        }
+        return success;
+    }
+
+    public static void tryClose(final Object... closeables) {
+        if (null == closeables) {
+            return;
+        }
+
+        for (Object obj : closeables) {
+            if (null == obj) {
+                continue;
+            }
+            try {
+                if (obj instanceof Closeable) {
+                    ((Closeable) obj).close();
+                } else if (obj instanceof Socket) {
+                    ((Socket) obj).close();
+                } else if (obj instanceof ServerSocket) {
+                    ((ServerSocket) obj).close();
+                }
+            } catch (final IOException e) {
+                e.printStackTrace();
+            }
+        }
+    }
+
+    public static String getResolutionText(int width, int height, boolean brace) {
+        StringBuffer buffer = new StringBuffer();
+        if (brace) {
+            buffer.append("(");
+        }
+        buffer.append(width).append("x").append(height);
+        if (brace) {
+            buffer.append(")");
+        }
+        return buffer.toString();
+    }
+
+    public static int getGCD(int a, int b) {
+        int i, j;
+        int gcd = 0;
+
+        if (a == b) {
+            return a;
+        }
+        j = (a < b) ? a : b;
+
+        for (i = 1; i < j; i++) {
+            if (a % i == 0 && b % i == 0) {
+                gcd = i;
+            }
+        }
+        return gcd;
+    }
+
+    public static int getLCM(int a, int b) {
+        int i, j;
+        int lcm = 0;
+
+        j = (a > b) ? a : b;
+
+        for (i = j;; i++) {
+            if (i % a == 0 && i % b == 0) {
+                lcm = i;
+                break;
+            }
+        }
+        return lcm;
+    }
+
+    public static String getRatioText(int a, int b, boolean brace) {
+        int gcd = getGCD(a, b);
+        int aValue = a / gcd;
+        int bValue = b / gcd;
+
+        StringBuffer buffer = new StringBuffer();
+        if (brace) {
+            buffer.append("(");
+        }
+        buffer.append(Integer.toString(aValue)).append("x").append(Integer.toString(bValue));
+        if (brace) {
+            buffer.append(")");
+        }
+        return buffer.toString();
+    }
+
+    public static Image getScreenImage(NScreenModel model) {
+        String imgName = null;
+        if (model.getType() == NScreenType.COMMON) {
+            imgName = "common.png";
+        } else if (model.getType() == NScreenType.ORIENTATION) {
+            if (model.getOrientation() == Orientation.LANDSCAPE) {
+                imgName = "orientation-landscape.png";
+            } else {
+                imgName = "orientation-portrait.png";
+            }
+        } else if (model.getType() == NScreenType.PIXELRATIO) {
+            if (model.getDevicePixelRatio() == 1.0) {
+                imgName = "pixel-ratio10.png";
+            } else if (model.getDevicePixelRatio() == 1.5) {
+                imgName = "pixel-ratio15.png";
+            } else if (model.getDevicePixelRatio() == 2.0) {
+                imgName = "pixel-ratio20.png";
+            } else if (model.getDevicePixelRatio() == 3.0) {
+                imgName = "pixel-ratio30.png";
+            }
+        } else if (model.getType() == NScreenType.RESOLUTION) {
+            String resolution =
+                    getRatioText(model.getDeviceWidth(), model.getDeviceHeight(), false);
+            if (resolution.equals("1x1")) {
+                imgName = "resoluion-1-1.png";
+            } else if (resolution.equals("2x3")) {
+                imgName = "resoluion-2-3.png";
+            } else if (resolution.equals("3x2")) {
+                imgName = "resoluion-3-2.png";
+            } else if (resolution.equals("3x4")) {
+                imgName = "resoluion-3-4.png";
+            } else if (resolution.equals("3x5")) {
+                imgName = "resoluion-3-5.png";
+            } else if (resolution.equals("4x3")) {
+                imgName = "resoluion-4-3.png";
+            } else if (resolution.equals("4x5")) {
+                imgName = "resoluion-4-5.png";
+            } else if (resolution.equals("5x3")) {
+                imgName = "resoluion-5-3.png";
+            } else if (resolution.equals("5x4")) {
+                imgName = "resoluion-5-4.png";
+            } else if (resolution.equals("9x16")) {
+                imgName = "resoluion-9-16.png";
+            } else if (resolution.equals("5x8") || resolution.equals("39x62")) {
+                imgName = "resoluion-10-16.png";
+            } else if (resolution.equals("16x9")) {
+                imgName = "resoluion-16-9.png";
+            } else if (resolution.equals("8x5") || resolution.equals("62x39")) {
+                imgName = "resoluion-16-10.png";
+            }
+        } else // custom
+        {
+            imgName = model.getImageName();
+        }
+
+        if (null != imgName) {
+            return ResourceManager.getImage(BuilderConstants.ICON_DIR, imgName);
+        }
+        return null;
+    }
+}
index da91ae0..e56b0a3 100644 (file)
@@ -76,11 +76,11 @@ public class NScreenView extends PageBookView {
      * @see org.eclipse.ui.part.PageBookView#createDefaultPage(org.eclipse.ui.part.PageBook)
      */
     protected IPage createDefaultPage(PageBook book) {
-        MessagePage page = new MessagePage();
-        initPage(page);
-        page.createControl(book);
-        page.setMessage(NScreenViewMessages.MESSAGE_DEFAULT);
-        return page;
+        MessagePage messagePage = new MessagePage();
+        initPage(messagePage);
+        messagePage.setMessage(NScreenViewMessages.MESSAGE_DEFAULT);
+        messagePage.createControl(book);
+        return messagePage;
     }
 
     @Override
diff --git a/org.tizen.webuibuilder/src/org/tizen/webuibuilder/ui/views/nscreen/command/NScreenDisableCommand.java b/org.tizen.webuibuilder/src/org/tizen/webuibuilder/ui/views/nscreen/command/NScreenDisableCommand.java
new file mode 100644 (file)
index 0000000..91f15cd
--- /dev/null
@@ -0,0 +1,94 @@
+
+
+package org.tizen.webuibuilder.ui.views.nscreen.command;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import org.eclipse.gef.commands.Command;
+import org.eclipse.swt.SWT;
+import org.tizen.webuibuilder.ui.views.nscreen.NScreenGroup;
+import org.tizen.webuibuilder.ui.views.nscreen.NScreenItem;
+
+
+public class NScreenDisableCommand extends Command {
+    private NScreenItem item = null;
+    private NScreenGroup group = null;
+
+    public NScreenDisableCommand(NScreenItem item) {
+        this.item = item;
+        group = (NScreenGroup) item.getParent();
+    }
+
+    @Override
+    public void execute() {
+        String pageId = group.getNScreenPageModel().getPageData().getName();
+
+        if (item.isLinked() || item.isRoot()) {
+            List<NScreenItem> source = new ArrayList<NScreenItem>();
+            List<NScreenItem> target = new ArrayList<NScreenItem>();
+
+            source.add(item);
+            List<NScreenItem> links = group.getLinkedItems(item);
+            int sourceIndex = links.indexOf(item);
+
+            if (sourceIndex != 0 && sourceIndex != links.size() - 1) {
+
+                for (int i = sourceIndex + 1; i < links.size(); i++) {
+                    target.add(links.get(i));
+                }
+
+                NScreenItem prev = null;
+                NScreenItem after = null;
+
+                int sourceFirstIndex = group.getItems().indexOf(source.get(0));
+                if (sourceFirstIndex != 0) {
+                    prev = group.getItems().get(sourceFirstIndex - 1);
+                }
+
+                int targetLastIndex = group.getItems().indexOf(target.get(target.size() - 1));
+                if (targetLastIndex < group.getItems().size() - 1) {
+                    after = group.getItems().get(targetLastIndex + 1);
+                }
+
+                group.changeOrder(prev, source, target, after);
+                group.changeItemIndex(source, target);
+                group.changeModelIndex(source, target);
+            }
+
+            if (!item.isRoot()) {
+                item.getReference().getLinkedList().remove(item);
+                item.getReference().redrawItem();
+            }
+
+            if (item.isRoot()) {
+                List<NScreenItem> linkeds = item.getLinkedList();
+                NScreenItem newRoot = linkeds.get(0);
+                newRoot.setLink(SWT.NONE);
+                newRoot.copyFile(item);
+                List<NScreenItem> newLinks = new ArrayList<NScreenItem>();
+                newLinks.addAll(linkeds);
+                item.getLinkedList().clear();
+                newRoot.getLinkedList().addAll(newLinks);
+                for (NScreenItem link : newLinks) {
+                    link.setReference(newRoot);
+                }
+                newRoot.redrawItem();
+            }
+        }
+        item.deleteFile();
+        item.setItemEnabled(false);
+        item.getModel().addDisablePage(pageId);
+        item.redrawItem();
+    }
+
+    @Override
+    public void redo() {
+        // execute();
+    }
+
+    @Override
+    public void undo() {
+
+    }
+}
diff --git a/org.tizen.webuibuilder/src/org/tizen/webuibuilder/ui/views/nscreen/command/NScreenEnableCommand.java b/org.tizen.webuibuilder/src/org/tizen/webuibuilder/ui/views/nscreen/command/NScreenEnableCommand.java
new file mode 100644 (file)
index 0000000..fb10209
--- /dev/null
@@ -0,0 +1,67 @@
+
+
+package org.tizen.webuibuilder.ui.views.nscreen.command;
+
+import java.io.File;
+import java.io.IOException;
+
+import org.eclipse.core.runtime.IPath;
+import org.eclipse.gef.commands.Command;
+import org.tizen.webuibuilder.model.css.CssFile;
+import org.tizen.webuibuilder.ui.views.nscreen.NScreenGroup;
+import org.tizen.webuibuilder.ui.views.nscreen.NScreenItem;
+
+
+public class NScreenEnableCommand extends Command {
+
+    private NScreenItem item = null;
+    private NScreenGroup group = null;
+
+    public NScreenEnableCommand(NScreenItem nscreenItem) {
+        item = nscreenItem;
+        group = (NScreenGroup) item.getParent();
+    }
+
+    @Override
+    public void execute() {
+//        String filePath = group.getNScreenPageModel().getAppManager().getCssFolder();
+//        CssFile cssFile = new CssFile(filePath + IPath.SEPARATOR + item.getFileName());
+//        File newCSSFile = new File(filePath + IPath.SEPARATOR + item.getFileName());
+//
+//        try {
+//            if (!newCSSFile.exists()) {
+//                File dir = newCSSFile.getParentFile();
+//                dir.mkdirs();
+//                newCSSFile.createNewFile();
+//            }
+//        } catch (IOException e) {
+//            e.printStackTrace();
+//        }
+//
+//        group.getNScreenPageModel().getPageData().addCssFile(cssFile);
+        item.createFile();
+        item.setItemEnabled(true);
+        
+//        String pageId = group.getNScreenPageModel().getPageData().getName();
+//        item.getModel().addEnablePage(pageId);
+    }
+
+    @Override
+    public void redo() {
+//        execute();
+    }
+
+    @Override
+    public void undo() {
+//        String filePath = group.getNScreenPageModel().getAppManager().getCssFolder();
+//        CssFile cssFile = new CssFile(filePath + IPath.SEPARATOR + item.getFileName());
+//        File newCSSFile = new File(filePath + IPath.SEPARATOR + item.getFileName());
+//
+//        if (newCSSFile.exists()) {
+//            newCSSFile.delete();
+//        }
+//
+//        group.getNScreenPageModel().getPageData().removeCssFile(cssFile);
+//        item.setEnabled(false);
+    }
+}
diff --git a/org.tizen.webuibuilder/src/org/tizen/webuibuilder/ui/views/nscreen/command/NScreenLinkCutCommand.java b/org.tizen.webuibuilder/src/org/tizen/webuibuilder/ui/views/nscreen/command/NScreenLinkCutCommand.java
new file mode 100644 (file)
index 0000000..048f065
--- /dev/null
@@ -0,0 +1,75 @@
+
+
+package org.tizen.webuibuilder.ui.views.nscreen.command;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import org.eclipse.gef.commands.Command;
+import org.eclipse.swt.SWT;
+import org.tizen.webuibuilder.ui.views.nscreen.NScreenGroup;
+import org.tizen.webuibuilder.ui.views.nscreen.NScreenItem;
+
+
+public class NScreenLinkCutCommand extends Command {
+    private NScreenItem item = null;
+    private NScreenGroup group = null;
+    private int direction = 0;
+
+    public NScreenLinkCutCommand(NScreenItem item) {
+        this.item = item;
+        group = (NScreenGroup) item.getParent();
+    }
+
+    @Override
+    public void execute() {
+
+        List<NScreenItem> source = new ArrayList<NScreenItem>();
+        List<NScreenItem> target = new ArrayList<NScreenItem>();
+
+        source.add(item);
+        List<NScreenItem> links = group.getLinkedItems(item);
+        int sourceIndex = links.indexOf(item);
+
+        if (sourceIndex != 0 && sourceIndex != links.size() - 1) {
+
+            for (int i = sourceIndex + 1; i < links.size(); i++) {
+                target.add(links.get(i));
+            }
+
+            NScreenItem prev = null;
+            NScreenItem after = null;
+
+            int sourceFirstIndex = group.getItems().indexOf(source.get(0));
+            if (sourceFirstIndex != 0) {
+                prev = group.getItems().get(sourceFirstIndex - 1);
+            }
+
+            int targetLastIndex = group.getItems().indexOf(target.get(target.size() - 1));
+            if (targetLastIndex < group.getItems().size() - 1) {
+                after = group.getItems().get(targetLastIndex + 1);
+            }
+
+            group.changeOrder(prev, source, target, after);
+            group.changeItemIndex(source, target);
+            group.changeModelIndex(source, target);
+        }
+
+        item.getReference().getLinkedList().remove(item);
+        item.getReference().redrawItem();
+        
+        direction = item.setLink(SWT.NONE);
+        item.createFile();
+    }
+
+    @Override
+    public void redo() {
+        execute();
+    }
+
+    @Override
+    public void undo() {
+//        item.deleteFile();
+//        item.setLink(direction);
+    }
+}
diff --git a/org.tizen.webuibuilder/src/org/tizen/webuibuilder/ui/views/nscreen/command/NScreenLinkDownCommand.java b/org.tizen.webuibuilder/src/org/tizen/webuibuilder/ui/views/nscreen/command/NScreenLinkDownCommand.java
new file mode 100644 (file)
index 0000000..96422b1
--- /dev/null
@@ -0,0 +1,30 @@
+package org.tizen.webuibuilder.ui.views.nscreen.command;
+
+import org.eclipse.gef.commands.Command;
+import org.eclipse.swt.SWT;
+import org.tizen.webuibuilder.ui.views.nscreen.NScreenItem;
+
+public class NScreenLinkDownCommand extends Command {
+    private NScreenItem item = null;
+
+    public NScreenLinkDownCommand(NScreenItem item) {
+        this.item = item;
+    }
+
+    @Override
+    public void execute() {
+        item.deleteFile();
+        item.setLink(SWT.DOWN);
+    }
+
+    @Override
+    public void redo() {
+        execute();
+    }
+
+    @Override
+    public void undo() {
+        item.setLink(SWT.NONE);
+        item.createFile();
+    }
+}
diff --git a/org.tizen.webuibuilder/src/org/tizen/webuibuilder/ui/views/nscreen/command/NScreenLinkUpCommand.java b/org.tizen.webuibuilder/src/org/tizen/webuibuilder/ui/views/nscreen/command/NScreenLinkUpCommand.java
new file mode 100644 (file)
index 0000000..e7d6a01
--- /dev/null
@@ -0,0 +1,33 @@
+
+
+package org.tizen.webuibuilder.ui.views.nscreen.command;
+
+import org.eclipse.gef.commands.Command;
+import org.eclipse.swt.SWT;
+import org.tizen.webuibuilder.ui.views.nscreen.NScreenItem;
+
+
+public class NScreenLinkUpCommand extends Command {
+    private NScreenItem item = null;
+
+    public NScreenLinkUpCommand(NScreenItem item) {
+        this.item = item;
+    }
+
+    @Override
+    public void execute() {
+        item.deleteFile();
+        item.setLink(SWT.UP);
+    }
+
+    @Override
+    public void redo() {
+        execute();
+    }
+
+    @Override
+    public void undo() {
+        item.setLink(SWT.NONE);
+        item.createFile();
+    }
+}
diff --git a/org.tizen.webuibuilder/src/org/tizen/webuibuilder/ui/views/nscreen/command/NScreenMoveDownCommand.java b/org.tizen.webuibuilder/src/org/tizen/webuibuilder/ui/views/nscreen/command/NScreenMoveDownCommand.java
new file mode 100644 (file)
index 0000000..528d33d
--- /dev/null
@@ -0,0 +1,76 @@
+
+
+package org.tizen.webuibuilder.ui.views.nscreen.command;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import org.eclipse.gef.commands.Command;
+import org.tizen.webuibuilder.ui.views.nscreen.NScreenGroup;
+import org.tizen.webuibuilder.ui.views.nscreen.NScreenItem;
+
+
+public class NScreenMoveDownCommand extends Command {
+    private NScreenItem item = null;
+
+    public NScreenMoveDownCommand(NScreenItem item) {
+        this.item = item;
+    }
+
+    @Override
+    public void execute() {
+        NScreenGroup group = (NScreenGroup) item.getParent();
+        // group.changeOrder(item, SWT.DOWN);
+
+        List<NScreenItem> source = new ArrayList<NScreenItem>();
+        List<NScreenItem> target = new ArrayList<NScreenItem>();
+
+        if (item.isLinked() || item.isRoot()) {
+            source = group.getLinkedItems(item);
+        } else {
+            source.add(item);
+        }
+
+        int index = group.getItems().indexOf(source.get(source.size() - 1));
+
+        if (index == group.getItems().size() - 1) {
+            return;
+        }
+
+        NScreenItem next = group.getItems().get(index + 1);
+
+        if (next.isLinked() || next.isRoot()) {
+            target = group.getLinkedItems(next);
+        } else {
+            target.add(next);
+        }
+
+        NScreenItem prev = null;
+        NScreenItem after = null;
+
+        int sourceFirstIndex = group.getItems().indexOf(source.get(0));
+        if (sourceFirstIndex != 0) {
+            prev = group.getItems().get(sourceFirstIndex - 1);
+        }
+        
+        int targetLastIndex = group.getItems().indexOf(target.get(target.size()-1));
+        if (targetLastIndex < group.getItems().size() - 1) {
+            after = group.getItems().get(targetLastIndex + 1);
+        }
+
+        group.changeOrder(prev, source, target, after);
+        group.changeItemIndex(source, target);
+        group.changeModelIndex(source, target);
+    }
+
+    @Override
+    public void redo() {
+        execute();
+    }
+
+    @Override
+    public void undo() {
+//        NScreenGroup group = (NScreenGroup) item.getParent();
+//        group.changeOrder(item, SWT.UP);
+    }
+}
diff --git a/org.tizen.webuibuilder/src/org/tizen/webuibuilder/ui/views/nscreen/command/NScreenMoveUpCommand.java b/org.tizen.webuibuilder/src/org/tizen/webuibuilder/ui/views/nscreen/command/NScreenMoveUpCommand.java
new file mode 100644 (file)
index 0000000..7b66680
--- /dev/null
@@ -0,0 +1,77 @@
+
+
+package org.tizen.webuibuilder.ui.views.nscreen.command;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import org.eclipse.gef.commands.Command;
+import org.eclipse.swt.SWT;
+import org.tizen.webuibuilder.ui.views.nscreen.NScreenGroup;
+import org.tizen.webuibuilder.ui.views.nscreen.NScreenItem;
+
+
+public class NScreenMoveUpCommand extends Command {
+    private NScreenItem item = null;
+
+    public NScreenMoveUpCommand(NScreenItem item) {
+        this.item = item;
+    }
+
+    @Override
+    public void execute() {
+        NScreenGroup group = (NScreenGroup) item.getParent();
+//        group.changeOrder(item, SWT.UP);
+
+        List<NScreenItem> source = new ArrayList<NScreenItem>();
+        List<NScreenItem> target = new ArrayList<NScreenItem>();
+
+        if (item.isLinked() || item.isRoot()) {
+            target = group.getLinkedItems(item);
+        } else {
+            target.add(item);
+        }
+
+        int index = group.getItems().indexOf(target.get(0));
+
+        if (index == 0) {
+            return;
+        }
+
+        NScreenItem front = group.getItems().get(index - 1);
+
+        if (front.isLinked() || front.isRoot()) {
+            source = group.getLinkedItems(front);
+        } else {
+            source.add(front);
+        }
+
+        NScreenItem prev = null;
+        NScreenItem after = null;
+
+        int sourceFirstIndex = group.getItems().indexOf(source.get(0));
+        if (sourceFirstIndex != 0) {
+            prev = group.getItems().get(sourceFirstIndex - 1);
+        }
+        
+        int targetLastIndex = group.getItems().indexOf(target.get(target.size()-1));
+        if (targetLastIndex < group.getItems().size() - 1) {
+            after = group.getItems().get(targetLastIndex + 1);
+        }
+
+        group.changeOrder(prev, source, target, after);
+        group.changeItemIndex(source, target);
+        group.changeModelIndex(source, target);
+    }
+
+    @Override
+    public void redo() {
+        execute();
+    }
+
+    @Override
+    public void undo() {
+//        NScreenGroup group = (NScreenGroup) item.getParent();
+//        group.changeOrder(item, SWT.DOWN);
+    }
+}
diff --git a/org.tizen.webuibuilder/src/org/tizen/webuibuilder/ui/views/nscreen/dialog/NScreenInputWizardPage.java b/org.tizen.webuibuilder/src/org/tizen/webuibuilder/ui/views/nscreen/dialog/NScreenInputWizardPage.java
new file mode 100644 (file)
index 0000000..7fd9661
--- /dev/null
@@ -0,0 +1,294 @@
+
+
+package org.tizen.webuibuilder.ui.views.nscreen.dialog;
+
+import org.eclipse.jface.resource.ImageDescriptor;
+import org.eclipse.jface.wizard.WizardPage;
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.events.ModifyEvent;
+import org.eclipse.swt.events.ModifyListener;
+import org.eclipse.swt.events.SelectionAdapter;
+import org.eclipse.swt.events.SelectionEvent;
+import org.eclipse.swt.layout.GridData;
+import org.eclipse.swt.layout.GridLayout;
+import org.eclipse.swt.widgets.Button;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.swt.widgets.Label;
+import org.eclipse.swt.widgets.Text;
+
+
+public class NScreenInputWizardPage extends WizardPage {
+    // private static Logger logger = LoggerFactory.getLogger(NScreenInputWizardPage.class);
+    public static final String NAME = NScreenInputWizardPage.class.getName();
+    public final String NAME_PATTERN = "^[a-zA-Z]+[a-zA-Z0-9]*$";
+    public final String SIZE_PATTERN = "^[0-9]*$";
+
+    // Parent part
+    private Composite parentComposite;
+
+    // Widget
+    private Text nscreenNameText;
+    private Text maxDeviceWidthText;
+    private Text maxDeviceHeightText;
+    private Button orientationButton;
+    private Button maxDeviceWidthCheckBox;
+    private Button maxDeviceHeightCheckBox;
+    private Button orientationCheckBox;
+
+    // preview
+    private Text previewText;
+
+    protected NScreenInputWizardPage(String pageName, String title, ImageDescriptor titleImage) {
+        super(pageName, title, titleImage);
+        setDescription(NScreenViewMessages.NSCREEN_INPUTWIZARD_PAGE_DESCRIPTION);
+    }
+
+    @Override
+    public void createControl(Composite parent) {
+        // Parent part
+        parentComposite = new Composite(parent, SWT.NONE);
+        parentComposite.setLayout(new GridLayout(1, true));
+        parentComposite.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
+        setControl(parentComposite);
+
+        // Children part
+        createNscreenNameComposite(parentComposite);
+        createDeviceListComposite(parentComposite);
+        createUserInputComposite(parentComposite);
+        createDetailInputComposite(parentComposite);
+        createPreviewComposite(parentComposite);
+
+        setPageComplete(false);
+    }
+
+    private void createNscreenNameComposite(Composite parent) {
+        Composite nscreenItemNameComposite = new Composite(parent, SWT.NONE);
+        nscreenItemNameComposite.setLayout(new GridLayout(8, true));
+        nscreenItemNameComposite.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
+
+        GridData gd = null;
+
+        Label label = new Label(nscreenItemNameComposite, SWT.NULL);
+        label.setText("NScreen Name : ");
+        gd = new GridData(GridData.FILL_BOTH);
+        gd.horizontalSpan = 2;
+        label.setLayoutData(gd);
+
+        nscreenNameText = new Text(nscreenItemNameComposite, SWT.BORDER | SWT.SINGLE);
+        gd = new GridData(GridData.FILL_BOTH);
+        gd.horizontalSpan = 6;
+        nscreenNameText.setLayoutData(gd);
+        nscreenNameText.addModifyListener(new ModifyListener() {
+            @Override
+            public void modifyText(ModifyEvent e) {
+                changeDialogText();
+            }
+        });
+    }
+
+    private void createDeviceListComposite(Composite parent) {
+        Composite deviceListComposite = new Composite(parent, SWT.NONE);
+        deviceListComposite.setLayout(new GridLayout(8, true));
+        deviceListComposite.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
+
+        for (int i = 1; i < 17; i++) {
+            Button button = new Button(deviceListComposite, SWT.NONE);
+            button.setText("device : " + i);
+        }
+
+    }
+
+    private void createUserInputComposite(Composite parent) {
+        Composite userInputComposite = new Composite(parent, SWT.NONE);
+        userInputComposite.setLayout(new GridLayout(8, true));
+        userInputComposite.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
+
+        GridData gd = null;
+
+        // Device width
+        maxDeviceWidthCheckBox = new Button(userInputComposite, SWT.CHECK);
+        maxDeviceWidthCheckBox.setText("Max-Device-Width : ");
+        gd = new GridData(GridData.FILL_HORIZONTAL);
+        gd.horizontalSpan = 2;
+        maxDeviceWidthCheckBox.setLayoutData(gd);
+        maxDeviceWidthCheckBox.setSelection(true);
+
+        maxDeviceWidthText = new Text(userInputComposite, SWT.BORDER);
+        gd = new GridData(GridData.FILL_HORIZONTAL);
+        gd.horizontalSpan = 6;
+        maxDeviceWidthText.setLayoutData(gd);
+
+        maxDeviceWidthCheckBox.addSelectionListener(new SelectionAdapter() {
+            @Override
+            public void widgetSelected(SelectionEvent e) {
+                if (maxDeviceWidthCheckBox.getSelection()) {
+                    maxDeviceWidthText.setEnabled(true);
+                } else {
+                    maxDeviceWidthText.setEnabled(false);
+                }
+            }
+        });
+
+        maxDeviceWidthText.addModifyListener(new ModifyListener() {
+            @Override
+            public void modifyText(ModifyEvent e) {
+                changeDialogText();
+            }
+        });
+
+        // Device Height
+        maxDeviceHeightCheckBox = new Button(userInputComposite, SWT.CHECK);
+        maxDeviceHeightCheckBox.setText("Max-Device-Height : ");
+        gd = new GridData(GridData.FILL_HORIZONTAL);
+        gd.horizontalSpan = 2;
+        maxDeviceHeightCheckBox.setLayoutData(gd);
+        maxDeviceHeightCheckBox.setSelection(true);
+
+        maxDeviceHeightText = new Text(userInputComposite, SWT.BORDER);
+        gd = new GridData(GridData.FILL_HORIZONTAL);
+        gd.horizontalSpan = 6;
+        maxDeviceHeightText.setLayoutData(gd);
+
+        maxDeviceHeightCheckBox.addSelectionListener(new SelectionAdapter() {
+            @Override
+            public void widgetSelected(SelectionEvent e) {
+                if (maxDeviceHeightCheckBox.getSelection()) {
+                    maxDeviceHeightText.setEnabled(true);
+                } else {
+                    maxDeviceHeightText.setEnabled(false);
+                }
+            }
+        });
+
+        maxDeviceHeightText.addModifyListener(new ModifyListener() {
+            @Override
+            public void modifyText(ModifyEvent e) {
+                changeDialogText();
+            }
+        });
+
+        // Orientation
+        orientationCheckBox = new Button(userInputComposite, SWT.CHECK);
+        orientationCheckBox.setText("Orientation : ");
+        gd = new GridData(GridData.FILL_HORIZONTAL);
+        gd.horizontalSpan = 2;
+        orientationCheckBox.setLayoutData(gd);
+        orientationCheckBox.setSelection(true);
+
+        orientationButton = new Button(userInputComposite, SWT.TOGGLE);
+        orientationButton.setText("Portrait");
+        gd = new GridData(GridData.FILL_HORIZONTAL);
+        gd.horizontalSpan = 6;
+        orientationButton.setLayoutData(gd);
+        orientationCheckBox.addSelectionListener(new SelectionAdapter() {
+            @Override
+            public void widgetSelected(SelectionEvent e) {
+                if (orientationCheckBox.getSelection()) {
+                    orientationButton.setEnabled(true);
+                } else {
+                    orientationButton.setEnabled(false);
+                }
+            }
+        });
+
+        orientationButton.addSelectionListener(new SelectionAdapter() {
+            @Override
+            public void widgetSelected(SelectionEvent e) {
+                if (orientationButton.getSelection()) {
+                    orientationButton.setText("Landscape");
+                } else {
+                    orientationButton.setText("Portrait");
+
+                }
+            }
+        });
+    }
+
+    private void createDetailInputComposite(Composite parent) {
+        Composite detailInputComposite = new Composite(parent, SWT.NONE);
+        detailInputComposite.setLayout(new GridLayout(8, true));
+        detailInputComposite.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
+
+        for (int i = 1; i < 17; i++) {
+            Button button = new Button(detailInputComposite, SWT.NONE);
+            button.setText("detail : " + i);
+        }
+    }
+
+    private void createPreviewComposite(Composite parent) {
+        Composite previewComposite = new Composite(parent, SWT.NONE);
+        previewComposite.setLayout(new GridLayout(8, true));
+        previewComposite.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
+
+        GridData gd = null;
+
+        Label label = new Label(previewComposite, SWT.NULL);
+        label.setText("MediaQueries : ");
+        gd = new GridData(GridData.FILL_BOTH);
+        gd.horizontalSpan = 2;
+        label.setLayoutData(gd);
+
+        previewText = new Text(previewComposite, SWT.BORDER | SWT.READ_ONLY | SWT.MULTI);
+        gd = new GridData(GridData.FILL_BOTH);
+        gd.horizontalSpan = 6;
+        previewText.setLayoutData(gd);
+        previewText.setEnabled(false);
+    }
+
+    private void makeMediaQueries() {
+        // logger.info("Make mediaqueries");
+    }
+
+    private void changeDialogText() {
+        // logger.info("change Text");
+        // check Validation.
+        if (nscreenNameText.getText().isEmpty()) {
+            setErrorMessage("Name is Empty.");
+            setPageComplete(false);
+            return;
+        }
+
+        if (!nscreenNameText.getText().matches(this.NAME_PATTERN)) {
+            setErrorMessage("Name is started width the first letter of the character.");
+            setPageComplete(false);
+            return;
+        }
+
+        if (maxDeviceWidthCheckBox.getSelection()) {
+            if (maxDeviceWidthText.getText().isEmpty()) {
+                setErrorMessage("Max-Device-Width is Empty.");
+                setPageComplete(false);
+                return;
+            }
+
+            if (!maxDeviceWidthText.getText().matches(this.SIZE_PATTERN)) {
+                setErrorMessage("Max-Device-Width use only numbers.");
+                setPageComplete(false);
+                return;
+            }
+        }
+
+        if (maxDeviceHeightCheckBox.getSelection()) {
+            if (maxDeviceHeightText.getText().isEmpty()) {
+                setErrorMessage("Max-Device-Height is Empty.");
+                setPageComplete(false);
+                return;
+            }
+
+            if (!maxDeviceHeightText.getText().matches(this.SIZE_PATTERN)) {
+                setErrorMessage("Max-Device-Height use only numbers.");
+                setPageComplete(false);
+                return;
+            }
+        }
+
+        makeMediaQueries();
+
+        {
+            setErrorMessage(null);
+            setMessage(NScreenViewMessages.NSCREEN_INPUTWIZARD_PAGE_DESCRIPTION);
+            setPageComplete(true);
+        }
+        return;
+    }
+}
diff --git a/org.tizen.webuibuilder/src/org/tizen/webuibuilder/ui/views/nscreen/dialog/NScreenViewMessages.java b/org.tizen.webuibuilder/src/org/tizen/webuibuilder/ui/views/nscreen/dialog/NScreenViewMessages.java
new file mode 100644 (file)
index 0000000..a492349
--- /dev/null
@@ -0,0 +1,50 @@
+/*
+ * UI Builder
+ *
+ * Copyright (c) 2000 - 2014 Samsung Electronics Co., Ltd. All rights reserved.
+ *
+ * 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.webuibuilder.ui.views.nscreen.dialog;
+
+import org.eclipse.osgi.util.NLS;
+
+
+/**
+ * The NScreenViewMessages class is a set of characters that are displayed on the screen .
+ */
+public class NScreenViewMessages {
+    private static final String BUNDLE_NAME = NScreenViewMessages.class.getName();
+
+    // Messages
+    public static String MESSAGE_DEFAULT;
+
+    // Dialog
+    public static String NSCREEN_INPUTWIZARD_TITLE;
+    public static String NSCREEN_INPUTWIZARD_PAGE_TITLE;
+    public static String NSCREEN_INPUTWIZARD_PAGE_DESCRIPTION;
+
+    static {
+        NLS.initializeMessages(BUNDLE_NAME, NScreenViewMessages.class);
+    }
+
+    private NScreenViewMessages() {
+    }
+
+}
diff --git a/org.tizen.webuibuilder/src/org/tizen/webuibuilder/ui/views/nscreen/dialog/NScreenViewMessages.properties b/org.tizen.webuibuilder/src/org/tizen/webuibuilder/ui/views/nscreen/dialog/NScreenViewMessages.properties
new file mode 100644 (file)
index 0000000..17bef98
--- /dev/null
@@ -0,0 +1,7 @@
+# Messages
+MESSAGE_DEFAULT=N-Screen are not available.
+
+# InputWizard Dialog
+NSCREEN_INPUTWIZARD_TITLE=New NScreen
+NSCREEN_INPUTWIZARD_PAGE_TITLE=NScreen Item
+NSCREEN_INPUTWIZARD_PAGE_DESCRIPTION=Add & Edit NScreen in App
\ No newline at end of file
diff --git a/org.tizen.webuibuilder/src/org/tizen/webuibuilder/ui/views/nscreen/dialog/NscreenInputWizard.java b/org.tizen.webuibuilder/src/org/tizen/webuibuilder/ui/views/nscreen/dialog/NscreenInputWizard.java
new file mode 100644 (file)
index 0000000..605410f
--- /dev/null
@@ -0,0 +1,46 @@
+
+
+package org.tizen.webuibuilder.ui.views.nscreen.dialog;
+
+import org.eclipse.jface.viewers.IStructuredSelection;
+import org.eclipse.jface.wizard.Wizard;
+import org.eclipse.ui.INewWizard;
+import org.eclipse.ui.IWorkbench;
+import org.tizen.webuibuilder.pagetemplate.ui.wizards.CreateWizardMessages;
+import org.tizen.webuibuilder.utility.ResourceManager;
+
+
+public class NscreenInputWizard extends Wizard implements INewWizard {
+    private NScreenInputWizardPage page;
+
+    public NscreenInputWizard() {
+        super();
+        setWindowTitle(NScreenViewMessages.NSCREEN_INPUTWIZARD_TITLE);
+    }
+
+    @Override
+    public void init(IWorkbench workbench, IStructuredSelection selection) {
+    }
+
+    @Override
+    public boolean performFinish() {
+        return false;
+    }
+
+    @Override
+    public boolean performCancel() {
+        return true;
+    }
+
+    @Override
+    public void addPages() {
+        super.addPages();
+        page =
+                new NScreenInputWizardPage(
+                                           NScreenInputWizardPage.NAME,
+                                           NScreenViewMessages.NSCREEN_INPUTWIZARD_PAGE_TITLE,
+                                           ResourceManager
+                                                   .getIconDescriptor(CreateWizardMessages.WIZARD_TITLE_IMAGE));
+        addPage(page);
+    }
+}
diff --git a/org.tizen.webuibuilder/src/org/tizen/webuibuilder/ui/views/nscreen/model/NScreenModel.java b/org.tizen.webuibuilder/src/org/tizen/webuibuilder/ui/views/nscreen/model/NScreenModel.java
deleted file mode 100644 (file)
index 11a9d7d..0000000
+++ /dev/null
@@ -1,75 +0,0 @@
-/*
- * UI Builder
- *
- * Copyright (c) 2000 - 2014 Samsung Electronics Co., Ltd. All rights reserved.
- *
- * 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.webuibuilder.ui.views.nscreen.model;
-
-public class NScreenModel {
-    private String mTitle;
-    private int mWidth;
-    private int mHeight;
-    private String mFileName;
-
-    public NScreenModel(String title, int width, int height, String fileName) {
-        mTitle = title;
-        mWidth = width;
-        mHeight = height;
-        mFileName = fileName;
-    }
-
-    public NScreenModel() {
-        this("Basic", 0, 0, "");
-    }
-
-    public String getTitle() {
-        return mTitle;
-    }
-
-    public void setTitle(String title) {
-        mTitle = title;
-    }
-
-    public int getWidth() {
-        return mWidth;
-    }
-
-    public void setWidth(int width) {
-        mWidth = width;
-    }
-
-    public int getHeight() {
-        return mHeight;
-    }
-
-    public void setHeight(int height) {
-        mHeight = height;
-    }
-
-    public String getFileName() {
-        return mFileName;
-    }
-
-    public void setFileName(String fileName) {
-        mFileName = fileName;
-    }
-
-}
index 6236e00..888f85a 100644 (file)
@@ -60,7 +60,6 @@ public class NScreenPageModel {
         }
         mRootPathUri = mIProject.getLocationURI().toString();
         mToolPathUri = ResourceManager.getFileURL(BuilderPlugin.PLUGIN_ID, null).toString();
-
     }
 
     public IProject getIProject() {