relative="org.eclipse.ui.views.ContentOutline">
</view>
<view
- id="org.tizen.injector.view.InjectorView"
- minimized="false"
- relationship="stack"
- relative="org.eclipse.ui.views.ContentOutline">
- </view>
- <view
id="org.eclipse.ui.views.PropertySheet"
minimized="false"
ratio=".7"
point="org.eclipse.ui.perspectiveExtensions">
<perspectiveExtension
targetID="org.tizen.web.ui.perspective.WebWidget">
+ <!--
<view
id="org.tizen.webuibuilder.ui.views.PagesView"
minimized="false"
relationship="stack"
relative="org.eclipse.ui.console.ConsoleView">
</view>
+ -->
</perspectiveExtension>
</extension>
<!--
<category name="dimension" displayName="Dimension" brief="%left%,%top%,%width%,%height%">
<property name="left" type="size" displayName="Left" default="auto" inline="true"></property>
<property name="top" type="size" displayName="Top" default="auto" inline="true"></property>
- <property name="width" type="size" displayName="Width" inline="true"></property>
- <property name="height" type="size" displayName="Height" inline="true"></property>
+ <property name="width" type="size" displayName="Width" inline="true" default="auto"></property>
+ <property name="height" type="size" displayName="Height" inline="true" default="auto"></property>
</category>
<category name="text" displayName="Text" brief="">
<constant value="foreach" displayName=""/>
</type>
+ <type id="slider@databinding">
+ <constant value="slider" displayName=""/>
+ </type>
+
<type id="textchecked@databinding">
<constant value="text" displayName=""/>
<constant value="checked" displayName=""/>
<constant value="text" displayName=""/>
</type>
- <type id="attr@databinding">
+ <type id="attrsrc@databinding">
<constant value="attr" displayName="src"/>
</type>
<constant value="attr" displayName="for"/>
<constant value="attr" displayName="form"/>
</type>
+
+ <type id="attrhref@databinding">
+ <constant value="text" displayName=""/>
+ <constant value="attr" displayName="href"/>
+ </type>
</types>
\ No newline at end of file
</property>
<property name="text" type="string" displayName="Text" default="" initValue="Heading5" xpath="text()"/>
+ <property name="data-bind" type="text@databinding" displayName="Data Binding" default="" initValue=""/>
+
<event name="ontap" displayName="Tap" eventType="event.defaultevent" />
<event name="ontaphold" displayName="TapHold" eventType="event.defaultevent" />
<event name="onswipe" displayName="Swipe" eventType="event.defaultevent" />
</property>
<property name="text" type="string" displayName="Text" default="" initValue="Heading4" xpath="text()"/>
+ <property name="data-bind" type="text@databinding" displayName="Data Binding" default="" initValue=""/>
+
<event name="ontap" displayName="Tap" eventType="event.defaultevent" />
<event name="ontaphold" displayName="TapHold" eventType="event.defaultevent" />
<event name="onswipe" displayName="Swipe" eventType="event.defaultevent" />
<condition name="disable-property-by-parent" value="tizen.header"/>
</property> -->
- <property name="data-bind" type="text@databinding" displayName="Data Binding" default="text" initValue=""/>
+ <property name="data-bind" type="text@databinding" displayName="Data Binding" default="" initValue=""/>
<event name="ontap" displayName="Tap" eventType="event.defaultevent" />
<event name="ontaphold" displayName="TapHold" eventType="event.defaultevent" />
</property>
<property name="text" type="string" displayName="Text" default="" initValue="Heading6" xpath="text()"/>
+ <property name="data-bind" type="text@databinding" displayName="Data Binding" default="" initValue=""/>
+
<event name="ontap" displayName="Tap" eventType="event.defaultevent" />
<event name="ontaphold" displayName="TapHold" eventType="event.defaultevent" />
<event name="onswipe" displayName="Swipe" eventType="event.defaultevent" />
</property>
<property name="text" type="string" displayName="Text" default="" initValue="Heading3" xpath="text()"/>
+ <property name="data-bind" type="text@databinding" displayName="Data Binding" default="" initValue=""/>
+
<event name="ontap" displayName="Tap" eventType="event.defaultevent" />
<event name="ontaphold" displayName="TapHold" eventType="event.defaultevent" />
<event name="onswipe" displayName="Swipe" eventType="event.defaultevent" />
</property>
<property name="text" type="string" displayName="Text" default="" initValue="Heading2" xpath="text()"/>
+ <property name="data-bind" type="text@databinding" displayName="Data Binding" default="" initValue=""/>
+
<event name="ontap" displayName="Tap" eventType="event.defaultevent" />
<event name="ontaphold" displayName="TapHold" eventType="event.defaultevent" />
<event name="onswipe" displayName="Swipe" eventType="event.defaultevent" />
<property name="border-style" type="border@style" displayName="Style" selector="#%id%"/>
</property> -->
- <property name="data-bind" type="attr@databinding" displayName="Data Binding" default="" initValue=""/>
+ <property name="data-bind" type="attrsrc@databinding" displayName="Data Binding" default="" initValue=""/>
<event name="ontap" displayName="Tap" eventType="event.defaultevent" />
<event name="ontaphold" displayName="TapHold" eventType="event.defaultevent" />
<!-- <property name="data-rel" type="html.link@rel" displayName="Rel" default=""/> -->
<property name="data-transition" type="html.link@transition" displayName="Transition" default=""/>
+ <property name="data-bind" type="attrhref@databinding" displayName="Data Binding" default="" initValue=""/>
+
<event name="ontap" displayName="Tap" eventType="event.defaultevent" />
<event name="ontaphold" displayName="TapHold" eventType="event.defaultevent" />
<event name="onswipe" displayName="Swipe" eventType="event.defaultevent" />
<property name="value" type="tizen.datetimepicker@value" displayName="Value" default=""
tooltip="Sets the picker date value"/>
+ <property name="data-bind" type="value@databinding" displayName="Data Binding" default="" initValue=""/>
+
<event name="onchange" displayName="Change" eventType="event.defaultevent" />
<xsl-for-output xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<property name="border-style" type="border@style" displayName="Style" selector="#%id%"/>
</property> -->
- <property name="data-bind" type="attr@databinding" displayName="Data Binding" default="" initValue=""/>
+ <property name="data-bind" type="attrsrc@databinding" displayName="Data Binding" default="" initValue=""/>
<event name="ontap" displayName="Tap" eventType="event.defaultevent" />
<event name="ontaphold" displayName="TapHold" eventType="event.defaultevent" />
tooltip="Enables or disables a pop-up showing the current value while the handle is dragged"/>
<property name="data-highlight" type="tizen@boolean1" displayName="Highlight" default=""/>
+ <property name="data-bind" type="slider@databinding" displayName="Data Binding" default="" initValue=""/>
+
<!-- <event name="ontap" displayName="Tap" eventType="event.defaultevent" />
<event name="ontaphold" displayName="TapHold" eventType="event.defaultevent" />
<event name="onswipe" displayName="Swipe" eventType="event.defaultevent" />
// Model IO
public static final String ATTRIBUTE_PID = "part-id"; //$NON-NLS-1$
public static final String ATTRIBUTE_STYLE = "style"; //$NON-NLS-1$
+ public static final String ATTRIBUTE_VALUE_POSITION = "position"; //$NON-NLS-1$
+ public static final String ATTRIBUTE_VALUE_LEFT = "left"; //$NON-NLS-1$
+ public static final String ATTRIBUTE_VALUE_TOP = "top"; //$NON-NLS-1$
public static final String ATTRIBUTE_VALUE_WIDTH = "width"; //$NON-NLS-1$
public static final String ATTRIBUTE_VALUE_HEIGHT = "height"; //$NON-NLS-1$
public static final String ATTRIBUTE_VALUE_PX = PX;
public static final String DATABINDING_TYPE_REMOTECALL = "Remote Call"; //$NON-NLS-1$
public static final String DATABINDING_ARRAY_ICON = "temp.png"; //$NON-NLS-1$
public static final String DATABINDING_BINDING_ICON = "binded.gif"; //$NON-NLS-1$
+ public static final String DATABINDING_STRING_ICON = "empty.png"; //$NON-NLS-1$
// HandlerCodeWriter
public static final String FILENAME = "%FileName%"; //$NON-NLS-1$
public static final String NSCREENPORTRAIT = "Portrait"; //$NON-NLS-1$
public static final String NSCREENLANDSCAPE = "Landscape"; //$NON-NLS-1$
+ // Profile
+ public static final String PROFILE_MOBILE = "mobile"; //$NON-NLS-1$
+ public static final String PROFILE_WEARABLE = "wearable"; //$NON-NLS-1$
+ public static final String PROFILE_TV = "tv"; //$NON-NLS-1$
+
+ public static final String PROFILE_MOBILE_2_3 = PROFILE_MOBILE + DASH + "2.3"; //$NON-NLS-1$
+ public static final String PROFILE_WEARABLE_2_3 = PROFILE_WEARABLE + DASH + "2.3"; //$NON-NLS-1$
+
}
import java.util.Map;
import org.eclipse.gef.commands.Command;
-import org.eclipse.wst.sse.core.internal.model.ModelManagerImpl;
import org.tizen.webuibuilder.animator.model.AnimatorFrame;
import org.tizen.webuibuilder.animator.model.AnimatorKeyframe;
import org.tizen.webuibuilder.animator.model.AnimatorModelEvent;
}
if (getUsedPropertiesInThisFrame().contains(key)) {
- if(!keyframe.getName().contains("custom")) {
- computedProperties.put(key, getComputedPropertyforPredefinedAnimationFromPreviousKeyframe(key, widgetProperties.get(key)));
+ if(isPredefined) {
+// computedProperties.put(key, getComputedPropertyforPredefinedAnimationFromPreviousKeyframe(key, widgetProperties.get(key)));
+ computedProperties.put(key, getComputedPropertyforPredefinedAnimationFromPreviousCustomFrame(selector.getPreviousComputedProperty(this, key), key, widgetProperties.get(key)));
} else {
computedProperties.put(key, properties.get(key));
}
return this.computedProperties;
}
+
+
/**
* Get value that as a percentage of the css3 value
*
}
String start = previousFrameProperties.get(key);
String end = nextFrameProperties.get(key);
- String interpolatedValue =
+ if(start != null && end != null) {
+ String interpolatedValue =
getInterpolatedValue(key, start, end, middle, easingProperty);
- addProperty(key, interpolatedValue);
+ addProperty(key, interpolatedValue);
+ }
}
if (previousFrame.getCurveFrames().size() > 0) {
Point p;
* @return
*/
public double calculateFramePercent(double frameTime) {
- return frameTime / duration * 100;
+ return frameTime / duration * 100.0;
}
/**
mergedFrame.addProperty(key,
mergedFrame.getComputedPropertyforPredefinedAnimationFromPreviousCustomFrame(
previousProperty, key, widgetProperties.get(key)));
-
} else {
String mergedFrameProperty = mergedFrame.getProperty(key);
if(mergedFrameProperty != null) {
return result;
}
-
+ /**
+ * Check with two keyframes that has same properties
+ * case 1. they have different properties and have same parent just keep going
+ * case 2. different properties and have different parent, merge to first keyframe's parent
+ * case 3. they have same properties and have same parent create other keyframe unit and move to last one to created keyframe unit
+ * case 4. they have same properties and have different parent just keep going *
+ *
+ * @param keyframe
+ * @return
+ */
public boolean mergeOrSplitKeyframe(AnimatorModelFactory modelFactory, List<AnimatorKeyframe> removedKeyframes) {
boolean result = false;
AnimatorFrame currentFrame = getNextAnimatorFrameByTime(null);
return result;
}
+ public String getPreviousComputedProperty(AnimatorFrame currentFrame, String key) {
+ AnimatorFrame frame = getPreviousAnimatorFrameByTime(currentFrame);
+ while(frame != null) {
+ if(!frame.isPredefined()) {
+ String value = frame.getProperty(key);
+ if(value != null) {
+ return value;
+ }
+ }
+ frame = getPreviousAnimatorFrameByTime(frame);
+ }
+ return null;
+ }
+
private AnimatorFrame getPreviousAnimatorFrameByTime(AnimatorFrame currentFrame) {
package org.tizen.webuibuilder.animator.model;
+import java.text.DecimalFormat;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import org.tizen.webuibuilder.model.css.CssFile;
import org.tizen.webuibuilder.model.css.CssSelector;
import org.tizen.webuibuilder.model.css.CssStyle;
+import org.tizen.webuibuilder.model.css.descriptors.CssCategoryDescriptor;
+import org.tizen.webuibuilder.model.css.descriptors.CssDescriptor;
+import org.tizen.webuibuilder.model.descriptors.DescriptorManager;
+import org.tizen.webuibuilder.model.descriptors.PropertyDescriptor;
import org.tizen.webuibuilder.model.page.PageData;
public class AnimatorWidget extends AnimatorModel {
private boolean visibility = true;
private boolean lock = false;
+ private Map<String, String> initializeProperties = new HashMap<String, String>();
public AnimatorWidget() {
// TODO Auto-generated constructor stub
*/
public Map<String, String> getWidgetProperties(Set<String> propertiesUsed, String selector) {
Map<String, String> properties = new HashMap<String, String>();
- initializeWithDefault(properties);
- properties.put("width", getPartLink().getPositionProperty().width + "px");
- properties.put("height", getPartLink().getPositionProperty().height + "px");
AnimatorWidgetPart widgetPart = (AnimatorWidgetPart)getPartLink();
AnimatorPagePart pagePart = (AnimatorPagePart)widgetPart.getOwnerPage();
if(!(pagePart.getOwnerRef() instanceof PageData)) {
}
PageData pageData = (PageData)pagePart.getOwnerRef();
+ if(initializeProperties.size() == 0) {
+ initializeWithDefault(pageData.getDescriptorManager());
+ }
+ properties.putAll(initializeProperties);
+ properties.put("width", getPartLink().getPositionProperty().width + "px");
+ properties.put("height", getPartLink().getPositionProperty().height + "px");
+
CssFile cssFile = pageData.getCurrentCssFile();
if(cssFile == null)
return properties;
}
}
- private void initializeWithDefault(Map<String, String> properties) {
- properties.put("background-color", "#ffffff");
- properties.put("opacity", "1");
- properties.put("translateX", "0px");
- properties.put("translateY", "0px");
- properties.put("rotateX", "0deg");
- properties.put("rotateY", "0deg");
- properties.put("rotateZ", "0deg");
- properties.put("scaleX", "1");
- properties.put("scaleY", "1");
- properties.put("skewX", "0deg");
- properties.put("skewY", "0deg");
- properties.put("perspective", "0px");
+ private void initializeWithDefault(DescriptorManager descriptorManager) {
+
+ CssDescriptor cssDescriptor = descriptorManager.getCssDescriptor();
+ for(CssCategoryDescriptor categoryDescriptor : cssDescriptor.getCssCategoryDescriptors()) {
+ initializeProperties.putAll(getCssPropertyDescriptor(categoryDescriptor.getCssPropertyDescriptors()));
+ }
+
+
+// properties.put("background-color", "#ffffff");
+// properties.put("opacity", "1");
+// properties.put("translateX", "0px");
+// properties.put("translateY", "0px");
+// properties.put("rotateX", "0deg");
+// properties.put("rotateY", "0deg");
+// properties.put("rotateZ", "0deg");
+// properties.put("scaleX", "1");
+// properties.put("scaleY", "1");
+// properties.put("skewX", "0deg");
+// properties.put("skewY", "0deg");
+// properties.put("perspective", "0px");
+ }
+
+
+ private <T extends PropertyDescriptor> Map<String, String> getCssPropertyDescriptor(List<T> cssPropertyDescriptor) {
+ Map<String, String> properties = new HashMap<String, String>();
+
+ for(PropertyDescriptor propertyDescriptor : cssPropertyDescriptor) {
+ String property = propertyDescriptor.getPropertyName();
+ String defaultValue = propertyDescriptor.getDefaultValue();
+ if(property != null && !property.equals("") && defaultValue != null && !defaultValue.equals("")) {
+ //change defaultValue or Property name... change not to hard coding
+ if(property.equals("opacity")) {
+ DecimalFormat format = new DecimalFormat("#.###");
+ defaultValue = format.format(Double.parseDouble(defaultValue) / 100);
+ } else if(property.equals("translate.x")) {
+ property = "translateX";
+ } else if(property.equals("translate.y")) {
+ property = "translateY";
+ } else if(property.equals("rotate.z")) {
+ property = "rotateZ";
+ } else if(property.equals("scale.x")) {
+ property = "scaleX";
+ } else if(property.equals("scale.y")) {
+ property = "scaleY";
+ } else if(property.equals("skew.x")) {
+ property = "skewX";
+ } else if(property.equals("skew.y")) {
+ property = "skewY";
+ }
+ properties.put(property, defaultValue);
+ }
+
+ properties.putAll(getCssPropertyDescriptor(propertyDescriptor.getChildPropertyDescriptors()));
+ }
+
+ return properties;
}
}
propertyTypeMap.put("skewY", PropertyType.Double);
propertyTypeMap.put("scaleX", PropertyType.Double);
propertyTypeMap.put("scaleY", PropertyType.Double);
+ propertyTypeMap.put("opacity", PropertyType.Double);
}
/**
}
private void parseValue(String value) {
- if (type == PropertyType.Int) {
- parseIntOrDouble(value);
- this.value = (double) Integer.parseInt(stringValue);
- } else if (type == PropertyType.Double) {
- parseIntOrDouble(value);
- this.value = Double.parseDouble(stringValue);
- } else {// Hexa case
- parseHexa(value);
- }
+ if(value != null) {
+ if (type == PropertyType.Int) {
+ parseIntOrDouble(value);
+ this.value = (double) Integer.parseInt(stringValue);
+ } else if (type == PropertyType.Double) {
+ parseIntOrDouble(value);
+ this.value = Double.parseDouble(stringValue);
+ } else {// Hexa case
+ parseHexa(value);
+ }
+ }
}
private void parseIntOrDouble(String value) {
AnimatorFrame frame = (AnimatorFrame)getModelFactory().createAnimatorModel(AnimatorModelType.FRAME);
for (Map.Entry<String, JsonElement> entry : jobject.entrySet()) {
String key = entry.getKey();
- if (key.equals("time"))
+ if (key.equals("time")) {
frame.setFrameTime(entry.getValue().getAsDouble());
- else if (key.equals("curveFrames")) {
+ } else if (key.equals("isPredefined") ){
+ frame.setPredefined(entry.getValue().getAsBoolean());
+ } else if (key.equals("curveFrames")) {
for (JsonElement curveFrame : jobject.get("curveFrames").getAsJsonArray()) {
frame.addCurveFrame((AnimatorCurveFrame) context
.deserialize(curveFrame, AnimatorCurveFrame.class));
}
- } else
+ } else {
frame.addProperty(key, entry.getValue().getAsString());
+ }
}
return frame;
final JsonObject json = new JsonObject();
json.addProperty("time", frame.getFrameTime());
+ json.addProperty("isPredefined", frame.isPredefined());
Iterator<Entry<String, String>> iterator = ((AnimatorFrame) frame).getPropertyIterator();
while (iterator.hasNext()) {
import org.tizen.webuibuilder.animator.model.AnimatorAnimation;
import org.tizen.webuibuilder.animator.model.part.AnimatorPagePart;
import org.tizen.webuibuilder.animator.ui.views.timeline.common.ColorResource;
+import org.tizen.webuibuilder.animator.ui.views.timeline.common.Formatter;
import org.tizen.webuibuilder.animator.ui.views.timeline.common.TimelineConstants;
import org.tizen.webuibuilder.animator.ui.views.timeline.header.PlayHeader;
import org.tizen.webuibuilder.animator.ui.views.timeline.header.TimeBar;
contentHeaderContainer = new TimelineContentHeaderContainer(this, SWT.NONE);
FormData contentHeaderContainerFormData = new FormData();
contentHeaderContainerFormData.top = new FormAttachment(0);
- contentHeaderContainerFormData.bottom = new FormAttachment(0, 30);
+ contentHeaderContainerFormData.bottom = new FormAttachment(0, TimelineConstants.DEFAULT_TIMEBAR_HEIGHT);
contentHeaderContainerFormData.left = new FormAttachment(0);
contentHeaderContainerFormData.right = new FormAttachment(100);
contentHeaderContainer.setLayoutData(contentHeaderContainerFormData);
// null check
TimeBar timeBar = contentHeaderContainer.getKeyframeHeader().getTimeBar();
- timeBar.setStartTime(sel);
+ timeBar.setStartTime(sel * TimelineConstants.DEFAULT_TIME_POSITION_INTERVAL);
timeBar.redraw();
// TimeMarker
int lineXpoint = treeX + marker.getBounds().x;
int lineHeight =
contentTreeContainer.getBounds().height
- + TimelineConstants.DEFAULT_TIMEBAR_MARGINE + 1;
+ + TimelineConstants.DEFAULT_TIMEBAR_HEIGHT;
playHeaderLine.setSize(1, lineHeight);
playHeaderLine.setLocation(lineXpoint, 0);
* @param scrollMove
* non move is 0, move is 1, have to move 2
*/
- public void refreshHScroll(double pointTime, int path, int incrementSize, int scrollMove) {
-
+ public void refreshHScroll(int pointTime, int path, int incrementSize, int scrollMove) {
+ int MINT_TIMEPOINT = 2000;
TimeBar timeBar = contentHeaderContainer.getKeyframeHeader().getTimeBar();
- double startTime = timeBar.getStartTime();
- double lastTime = 0.0;
+ int startTime = timeBar.getStartTime();
+ int lastTime = 0;
lastTime = getLastTimeInAnimationGroup();
}
ScrollBar hScroll = contentToolsContainer.gethScroll();
- int lastTimeSel = (int) (lastTime * TimelineConstants.DEFAULT_TIME_INTERVAL);
+ int lastTimeSel = (int) (lastTime / TimelineConstants.DEFAULT_TIME_POSITION_INTERVAL);
if (lastTimeSel <= TimelineConstants.DEFAULT_HSCROLL_SIZE) {
hScroll.setMaximum(TimelineConstants.DEFAULT_HSCROLL_SIZE);
int increment = lastTimeSel / TimelineConstants.DEFAULT_HSCROLL_SELECTION_INTERVAL;
hScroll.setSelection(increment * TimelineConstants.DEFAULT_HSCROLL_SELECTION_INTERVAL);
}
-
+
// start Time
- if ((path == 0 && (startTime <= 0.0)) || ((pointTime <= 2) && scrollMove == 2)) {
- startTime = 0.0;
+ if ((path == 0 && (startTime <= 0)) || ((pointTime <= MINT_TIMEPOINT) && scrollMove == 2)) {
+ startTime = 0;
hScroll.setSelection(0);
} else if (scrollMove == 2) {
// last Time
- startTime = (pointTime - 2) * 10.0;
+ startTime = (pointTime - MINT_TIMEPOINT);
} else {
// last Time
- startTime = startTime + (incrementSize / timeBar.getScale());
+ startTime = (int) (startTime + ((incrementSize / timeBar.getScale()) * TimelineConstants.DEFAULT_TIME_POSITION_INTERVAL));
}
if (scrollMove == 1 || scrollMove == 2) {
*
* @return
*/
- public double getLastTimeInAnimationGroup() {
- double lastTime = 0.0;
+ public int getLastTimeInAnimationGroup() {
+ int lastTime = 0;
String animationGroupId =
getContentHeaderContainer().getOutlineHeader().getSelectedAnimationGroupId();
animation.calculateAnimationDuration();
String timeString = animation.getDuration();
-
- lastTime = AnimatorUtils.convertTimeToDouble(timeString);
+ double converTime = AnimatorUtils.convertTimeToDouble(timeString);
+ lastTime = Formatter.timeToComputeTime(converTime);
return lastTime;
}
import org.eclipse.ui.actions.ActionFactory;\r
import org.tizen.webuibuilder.animator.model.descriptor.AnimatorDescriptorManager;\r
import org.tizen.webuibuilder.animator.model.descriptor.CssAnimationDescriptor;\r
+import org.tizen.webuibuilder.animator.ui.views.timeline.action.ZOrderKeyFrameAction;\r
import org.tizen.webuibuilder.animator.ui.views.timeline.common.TimelineMessages;\r
+import org.tizen.webuibuilder.animator.ui.views.timeline.widget.KeyFrameUnit;\r
import org.tizen.webuibuilder.animator.utils.AnimatorUtils;\r
import org.tizen.webuibuilder.model.app.AppManager;\r
import org.tizen.webuibuilder.ui.contextmenu.ContextMenu;\r
\r
action = getAction(TimelineMessages.PASTE_KEYFRAME);\r
menu.appendToGroup(GEFActionConstants.GROUP_COPY, action);\r
+\r
+ MenuManager zorder = buildContextZorderMenu();\r
+ menu.appendToGroup(GEFActionConstants.GROUP_REST, zorder);\r
+\r
}\r
\r
private MenuManager buildContextPredefineMenu() {\r
\r
return addPKeyframes;\r
}\r
+\r
+ private MenuManager buildContextZorderMenu() {\r
+ MenuManager zOderMenu = new MenuManager(TimelineMessages.Z_ORDER, TimelineMessages.Z_ORDER);\r
+\r
+ TimelineViewer treeViewer = (TimelineViewer) getViewer();\r
+ List<KeyFrameUnit> findStackKeyframeUnits = treeViewer.findStackKeyframeUnit();\r
+\r
+ if (findStackKeyframeUnits != null && findStackKeyframeUnits.size() > 1) {\r
+\r
+ for (final KeyFrameUnit keyFrameUnit : findStackKeyframeUnits) {\r
+ IAction action = new ZOrderKeyFrameAction(keyFrameUnit, getViewer());\r
+ zOderMenu.add(action);\r
+ }\r
+ }\r
+\r
+ return zOderMenu;\r
+ }\r
}\r
contentContainer.setLayout(new FormLayout());
FormData contentContainerFormData = new FormData();
- contentContainerFormData.top = new FormAttachment(toolbar, 3);
+ contentContainerFormData.top = new FormAttachment(toolbar, 1);
contentContainerFormData.bottom = new FormAttachment(100, -3);
contentContainerFormData.left = new FormAttachment(0, 7);
contentContainerFormData.right = new FormAttachment(100, -7);
getMainContainer().getContentContainer().getContentHeaderContainer()
.getOutlineHeader().initialize();
// refresh h-scroll
- getMainContainer().getContentContainer().refreshHScroll(0.0, 0, 0, 0);
+ getMainContainer().getContentContainer().refreshHScroll(0, 0, 0, 0);
// refresh filter
getMainContainer().getContentContainer().getContentToolsContainer()
.setFilter(false);
package org.tizen.webuibuilder.animator.ui.views.timeline;
import java.lang.reflect.Method;
+import java.util.ArrayList;
import java.util.List;
import org.eclipse.gef.EditPart;
import org.tizen.webuibuilder.animator.ui.views.timeline.editpart.TimelineEditPart;
import org.tizen.webuibuilder.animator.ui.views.timeline.tree.TimeTreeElement;
import org.tizen.webuibuilder.animator.ui.views.timeline.tree.TimelineOutlineElement;
+import org.tizen.webuibuilder.animator.ui.views.timeline.widget.KeyFrame;
import org.tizen.webuibuilder.animator.ui.views.timeline.widget.KeyFrameComponent;
+import org.tizen.webuibuilder.animator.ui.views.timeline.widget.KeyFrameUnit;
import org.tizen.webuibuilder.model.Part;
import org.tizen.webuibuilder.utility.Platform;
@Override
public void handleEvent(Event event) {
// int clientHeight = contentTree.getClientArea().height;
- event.height = TimelineConstants.DEFAULT_TIMELINE_TREE_HEIGHT;
-
+ if (Platform.getOS().equals(Platform.OS_WIN32)) {
+ event.height = TimelineConstants.DEFAULT_TIMELINE_TREE_HEIGHT;
+ } else if (Platform.getOS().equals(Platform.OS_LINUX)
+ || Platform.getOS().equals(Platform.OS_MACOSX)) {
+ event.height = TimelineConstants.DEFAULT_TIMELINE_TREE_HEIGHT_LINUX;
+ }
}
});
outlineColumn = new TreeColumn(contentTree, SWT.NONE);
seperatorColumn = new TreeColumn(contentTree, SWT.NONE);
keyframeColumn = new TreeColumn(contentTree, SWT.NONE);
- parent.setLayout(contentTreeContainerColumnLayout);
int SEPERATOR_WIDTH = 0;
int EXPANDCOLUMN_WIDTH = 0;
}
}
}
-
+
refreshTree();
refreshContextMenu();
}
* Refresh ContextMenu
*/
private void refreshContextMenu() {
- //refresh contextMenu
+ // refresh contextMenu
this.getControl().setMenu(getContextMenu().createContextMenu(this.getControl()));
- RootEditPart rootEditPart = getRootEditPart();
- List children = rootEditPart.getChildren();
- if (children != null) {
- List<TimelineEditPart> editParts = ((EditPart) children.get(0)).getChildren();
- for (TimelineEditPart editPart : editParts) {
- List<TimelineEditPart> childEditParts = editPart.getChildren();
- for(TimelineEditPart treeEditPart : childEditParts) {
- TimeTreeElement treeElement = treeEditPart.getTimeElement();
- if(treeElement != null) {
- treeElement.createContextMenu();
- }
- }
- }
- }
+ RootEditPart rootEditPart = getRootEditPart();
+ List children = rootEditPart.getChildren();
+ if (children != null) {
+ List<TimelineEditPart> editParts = ((EditPart) children.get(0)).getChildren();
+ for (TimelineEditPart editPart : editParts) {
+ List<TimelineEditPart> childEditParts = editPart.getChildren();
+ for (TimelineEditPart treeEditPart : childEditParts) {
+ TimeTreeElement treeElement = treeEditPart.getTimeElement();
+ if (treeElement != null) {
+ treeElement.createContextMenu();
+ }
+ }
+ }
+ }
}
/**
* applyNonFilter
*/
private void applyNonFilter() {
- //setContents(getPage().getModel());
+ // setContents(getPage().getModel());
TimelineEditPart pageEditPart = getPageEditPart();
pageEditPart.refresh();
Tree contentTree = (Tree) getControl();
contentTree.pack();
- //refreshTimelineViewer();
+ // refreshTimelineViewer();
}
/**
});
}
+ /**
+ * Find KeyFrameUnit in Stack for z-ordering
+ *
+ * @return {@link KeyFrameUnit}
+ */
+ public List<KeyFrameUnit> findStackKeyframeUnit() {
+ List<KeyFrameUnit> keyFrameUnits = new ArrayList<KeyFrameUnit>();
+
+ KeyFrameComponent selectedkeyFrameComponent = getLastSelectedKeyframeComponent();
+
+ if (selectedkeyFrameComponent != null) {
+ KeyFrameUnit selectKeyFrameUnit = null;
+ if (selectedkeyFrameComponent instanceof KeyFrameUnit) {
+ selectKeyFrameUnit = (KeyFrameUnit) selectedkeyFrameComponent;
+ } else if (selectedkeyFrameComponent instanceof KeyFrame) {
+ selectKeyFrameUnit = ((KeyFrame) selectedkeyFrameComponent).getKeyFrameUnit();
+ }
+
+ if (selectKeyFrameUnit != null) {
+ TimeTreeElement timeTreeElement = selectKeyFrameUnit.getTimeTreeElement();
+ keyFrameUnits.add((KeyFrameUnit) selectKeyFrameUnit);
+ timeTreeElement.addKeyFrameUnit(selectKeyFrameUnit, keyFrameUnits);
+ }
+ }
+ return keyFrameUnits;
+ }
+
/**********************************************************************************************
* Getter, Setter
**********************************************************************************************/
private TimelineEditPart getPageEditPart() {
return (TimelineEditPart) getRootEditPart().getChildren().get(0);
}
+
/*****************************************************************************************
* Listener , Event
*****************************************************************************************/
import org.tizen.webuibuilder.animator.ui.views.timeline.TimelineClipboard;\r
import org.tizen.webuibuilder.animator.ui.views.timeline.TimelinePage;\r
import org.tizen.webuibuilder.animator.ui.views.timeline.TimelineViewer;\r
+import org.tizen.webuibuilder.animator.ui.views.timeline.common.Formatter;\r
import org.tizen.webuibuilder.animator.ui.views.timeline.tree.TimelineOutlineElement;\r
import org.tizen.webuibuilder.animator.utils.AnimatorUtils;\r
import org.tizen.webuibuilder.model.Part;\r
String animationGroupId =\r
viewer.getMainContainer().getContentContainer().getContentHeaderContainer()\r
.getOutlineHeader().getSelectedAnimationGroupId();\r
- double pointTime =\r
- viewer.getMainContainer().getContentContainer().getContentHeaderContainer()\r
- .getKeyframeHeader().getTimeBar().getPlayHeader().getCurrentPointTime();\r
+ \r
+ int currentPointTime = viewer.getMainContainer().getContentContainer().getContentHeaderContainer()\r
+ .getKeyframeHeader().getTimeBar().getPlayHeader().getCurrentPointTime();\r
+ \r
+ double pointTime = Formatter.computeTimeTotime(currentPointTime);\r
+ \r
CompoundCommand command = new CompoundCommand();
for (AnimatorModel selectorModel : children) {\r
AnimatorSelector selector = (AnimatorSelector) selectorModel;\r
--- /dev/null
+\r
+\r
+package org.tizen.webuibuilder.animator.ui.views.timeline.action;\r
+\r
+import org.eclipse.gef.EditPartViewer;\r
+import org.eclipse.jface.action.Action;\r
+import org.tizen.webuibuilder.animator.model.AnimatorModelEvent;\r
+import org.tizen.webuibuilder.animator.model.AnimatorModelManager;\r
+import org.tizen.webuibuilder.animator.ui.views.timeline.TimelineViewer;\r
+import org.tizen.webuibuilder.animator.ui.views.timeline.tree.TimeTreeElement;\r
+import org.tizen.webuibuilder.animator.ui.views.timeline.widget.KeyFrameUnit;\r
+import org.tizen.webuibuilder.animator.utils.AnimatorUtils;\r
+\r
+\r
+public class ZOrderKeyFrameAction extends Action {\r
+\r
+ private EditPartViewer editPartViewer = null;\r
+ private KeyFrameUnit keyFrameUnit = null;\r
+\r
+ public ZOrderKeyFrameAction(KeyFrameUnit keyFrameUnit, EditPartViewer editPartViewer) {\r
+ super(null);\r
+\r
+ this.keyFrameUnit = keyFrameUnit;\r
+ this.editPartViewer = editPartViewer;\r
+\r
+ setText(keyFrameUnit.getModel().getName());\r
+ setId(keyFrameUnit.getModel().getName());\r
+ }\r
+\r
+ public void run() {\r
+\r
+ if (keyFrameUnit != null) {\r
+ TimelineViewer viewer = (TimelineViewer) editPartViewer;\r
+ keyFrameUnit.selected();\r
+ viewer.setLastSelectedKeyframeComponent(keyFrameUnit);\r
+\r
+ TimeTreeElement timeTreeElement = keyFrameUnit.getTimeTreeElement();\r
+ timeTreeElement.redraw();\r
+\r
+ AnimatorModelManager manager = AnimatorUtils.getAppManager().getAnimatorModelManager();\r
+ manager.fireEvent(AnimatorModelEvent.EventType.SELECTION_CHANGE,\r
+ AnimatorModelEvent.Origin.TIMELINE, keyFrameUnit.getModel());\r
+ }\r
+ }\r
+}\r
public static String toTimeFormat(double time) {
int mst = (int) time;
- int ms = (int) ((time - (double) mst) * 1000.00);
+ int ms = (int) ((time - (double) mst) * 1000.000);
int minute = mst / 60;
int second = mst % 60;
return output;
}
- public static double toStringTimeFormat(String timeText) {
+ /**
+ * compute time double to String
+ *
+ * @param time
+ * double time value
+ * @return String time value xx:yy.zzz
+ */
+ public static String toTimeFormatInt(int time) {
+ int mst = (int) time / 1000;
+
+ int ms = (int) ((time - mst * 1000));
+ int minute = mst / 60;
+ int second = mst % 60;
+
+ String strMinute = Long.toString(minute);
+ if (strMinute.length() == 1) {
+ strMinute = "0" + strMinute; //$NON-NLS-1$
+ }
+
+ String strSecond = Long.toString(second);
+ if (strSecond.length() == 1) {
+ strSecond = "0" + strSecond; //$NON-NLS-1$
+ }
+
+ String strMs = Long.toString(ms);
+ if (strMs.length() == 1) {
+ strMs = "00" + strMs; //$NON-NLS-1$
+ } else if (strMs.length() == 2) {
+ strMs = "0" + strMs; //$NON-NLS-1$
+ }
+
+ String output = strMinute + " : " + strSecond + " . " + strMs; //$NON-NLS-1$ //$NON-NLS-2$
+ return output;
+ }
+
+ /**
+ * convert String to time
+ *
+ * @param timeText
+ * String time value xx:yy.zzz
+ * @return
+ */
+ public static int toStringTimeFormat(String timeText) {
if (timeText == null) {
return 0;
String min = null;
String sec = null;
String mSec = null;
- double minTime = 0;
- double secTime = 0;
- double mSecTime = 0.0;
- double fullTime = 0.0;
+ int minTime = 0;
+ int secTime = 0;
+ int mSecTime = 0;
+ int fullTime = 0;
String[] firstSplit = timeText.split(":");
int firstSplitLength = firstSplit[0].length();
sec = firstSplit[1].substring(1, 3);
mSec = firstSplit[1].substring(6, 9);
- minTime = Double.valueOf(min) * 60;
- secTime = Double.valueOf(sec);
- mSecTime = Double.valueOf(mSec) / 1000;
+ minTime = Integer.valueOf(min) * 60000;
+ secTime = Integer.valueOf(sec) * 1000;
+ mSecTime = Integer.valueOf(mSec);
fullTime = minTime + secTime + mSecTime;
return fullTime;
}
+
+ /**
+ * Time to ComputeTime
+ */
+ public static int timeToComputeTime(double time) {
+ return (int) (time * 1000);
+ }
+
+ /**
+ * CompouteTime to Time
+ * @param time
+ * @return
+ */
+ public static double computeTimeTotime(int time) {
+ return time / 1000.000;
+ }
+
}
public class TimelineConstants {
public static final int DEFAULT_TIMELINE_TIMEBAR_0 = 0;
- public static final int DEFAULT_KEYFRAME_MARGINE = 3;
+ public static final int DEFAULT_KEYFRAME_MARGIN_LINUX = 5;
+ public static final int DEFAULT_KEYFRAME_MARGIN = 4;
public static final int DEFAULT_START_KEYFRAME_POINT = -3;
- public static final int DEFAULT_LIFE_WIGET_HEIGHT = 20;
+ public static final int DEFAULT_LIFE_WIGET_HEIGHT = 14;
public static final int DEFAULT_LIFE_WIDGET_WIDTH = 100;
public static final int DEFAULT_LIFE_WIDGET_MIN_WIDTH = 10;
public static final int DEFAULT_FRAME_WIDGET_HEIGHT = 13;
public static final int DEFAULT_FRAME_WIDGET_HALF_WIDTH = 6;
public static final int DEFAULT_FRAME_WIDGET_CENTER_POINT = 7;
-
+ public static final int DEFAULT_FRAME_WIDGET_MARGIN = DEFAULT_KEYFRAME_MARGIN + 1 ;
+ public static final int DEFAULT_FRAME_WIDGET_MARGIN_LINUX = DEFAULT_KEYFRAME_MARGIN_LINUX + 1 ;
+
public static final int DEFAULT_TIMELINE_LEFT_MARGIN = 3;
- public static final int DEFAULT_TIMEBAR_HEIGHT = 20;
+ public static final int DEFAULT_TIMEBAR_HEIGHT = 26;
public static final int DEFAULT_SECOND_CELL_WIDTH = 100;
public static final int DEFAULT_TIMEELEMENT_ZOOMIN_HEIGHT = 30;
public static final int DEFAULT_TIMELINE_MARKER_WIDTH = 9;
public static final int DEFAULT_TIMELINE_MARKER_HEIGHT = 13;
- public static final int DEFAULT_TIMELINE_MARKER_Y = 12;
+ public static final int DEFAULT_TIMELINE_MARKER_Y = 9;
public static final int DEFAULT_TIMELINE_MARKER_LINE_OFFSET = 6;
public static final int DEFAULT_HSCROLL_SELECTION_INTERVAL = 50;
public static final int DEFAULT_TIME_INTERVAL = 10;
- public static final int DEFAULT_TIME_MILLISECOND = 100;
+ public static final int DEFAULT_TIME_POSITION_INTERVAL = 100;
+ public static final int DEFAULT_CONVERTTIME_POSITION_INTERVAL = 10;
+ public static final int DEFAULT_TIME_MILLISECOND = 1000;
- public static final int DEFAULT_TIMEBAR_MARGINE = 30;
-
public static final int DEFAULT_TIMELINE_SASH_WIDTH = 5;
public static final int DEFAULT_TREE_EXPANDCOLUMN_WIDTH = 1;
public static final int DEFAULT_TREE_OUTLINECOLUMN_WIDTH = 217;
public static final int DEFAULT_SASH_SEPERATOR_MARGIN_WIDTH = 11;
- public static final int DEFAULT_TIMELINE_TREE_HEIGHT = 26;
+ public static final int DEFAULT_TIMELINE_TREE_HEIGHT = 23;
+ public static final int DEFAULT_TIMELINE_TREE_HEIGHT_LINUX = 22;
+ public static final int DEFAULT_TIMELINE_TREEITEM_HEIGHT = 21;
}
public static String CUT_KEYFRAME;
public static String PASTE_KEYFRAME;
+ public static String Z_ORDER;
+
public static String NEW_ANIMATION_GROUP;
public static String DELETE_ANIMATION_GROUP;
public static String EDIT_ANIMATION_GROUP;
CUT_KEYFRAME = &Cut\tCtrl+X
PASTE_KEYFRAME = &Paste\tCtrl+V
+Z_ORDER = Bring to front
+
NEW_ANIMATION_GROUP = New animation group
DELETE_ANIMATION_GROUP = Delete animation group
EDIT_ANIMATION_GROUP = Show and Edit animation group
import org.tizen.webuibuilder.BuilderConstants;
import org.tizen.webuibuilder.animator.ui.views.timeline.TimelineContentContainer;
import org.tizen.webuibuilder.animator.ui.views.timeline.common.ColorResource;
+import org.tizen.webuibuilder.animator.ui.views.timeline.common.Formatter;
import org.tizen.webuibuilder.animator.ui.views.timeline.common.TimelineConstants;
import org.tizen.webuibuilder.animator.ui.views.timeline.tool.TimelineToolbar;
import org.tizen.webuibuilder.animator.utils.AnimatorUtils;
private int mouseDownPoint = 0;
private int positionMarker = TimelineConstants.DEFAULT_TIMELINE_TIMEBAR_0;
- private double currentPointTime = 0.0;
+ private int currentPointTime = 0;
private TimelineToolbar toolbar = null;
public void paintControl(PaintEvent e) {
Rectangle clientArea = getClientArea();
-
+ Rectangle bounds = getBounds();
+
e.gc.setBackground(ColorResource.TIMEBAR_BOTTOM);
e.gc.setForeground(ColorResource.TIMEBAR_TOP);
- e.gc.fillGradientRectangle(0, 0, getBounds().width, getBounds().height, true);
+ e.gc.fillGradientRectangle(0, 0, bounds.width, bounds.height, true);
e.gc.setForeground(ColorResource.LATTICE);
e.gc.drawImage(ResourceManager.getImage(BuilderConstants.ICON_DIR,
markerflag = false;
mouseDownPoint = 0;
- double pointTime = getPlayHeaderTime();
- if (pointTime < 0.0) {
- pointTime = 0.0;
+ int pointTime = getPlayHeaderTime();
+ if (pointTime < 0) {
+ pointTime = 0;
}
beforePoint = 0;
Rectangle rMarker = getBounds();
TimeBar timebar = (TimeBar) getParent();
- double startTime = timebar.getStartTime();
+ int startTime = timebar.getStartTime();
Point timeBarsize = timebar.getSize();
- if (startTime == 0.0
+ if (startTime == 0
&& rMarker.x < TimelineConstants.DEFAULT_TIMELINE_TIMEBAR_0) {
markerflag = false;
setLocation(TimelineConstants.DEFAULT_TIMELINE_TIMEBAR_0,
TimelineConstants.DEFAULT_TIMELINE_MARKER_Y);
setPositionMarker(TimelineConstants.DEFAULT_TIMELINE_TIMEBAR_0);
- setCurrentPointTime(0.0);
+ setCurrentPointTime(0);
} else {
- setPositionMarker(rMarker.x - mouseDownPoint + e.x);
- setLocation(getPositionMarker(),
+ setPositionMarker((rMarker.x - mouseDownPoint + e.x) * TimelineConstants.DEFAULT_CONVERTTIME_POSITION_INTERVAL);
+ setLocation(getPositionMarker() / TimelineConstants.DEFAULT_CONVERTTIME_POSITION_INTERVAL,
TimelineConstants.DEFAULT_TIMELINE_MARKER_Y);
}
// update marker point time
- double pointTime = getPlayHeaderTime();
- if (pointTime < 0.0) {
- pointTime = 0.0;
+ int pointTime = getPlayHeaderTime();
+ if (pointTime < 0) {
+ pointTime = 0;
}
sendPointTime(pointTime);
refreshPlayHeaderLine();
int incresementPoint =
- timeBarsize.x - TimelineConstants.DEFAULT_TIMEBAR_MARGINE;
+ timeBarsize.x - TimelineConstants.DEFAULT_TIMEBAR_HEIGHT;
// Logger.trace("marker : " + rMarker.x);
if (rMarker.x > incresementPoint) {
}
beforePoint = rMarker.x;
- } else if (rMarker.x < TimelineConstants.DEFAULT_TIMEBAR_MARGINE) {
+ } else if (rMarker.x < TimelineConstants.DEFAULT_TIMEBAR_HEIGHT) {
if (beforePoint > rMarker.x) {
TimelineContentContainer contentContainer =
(TimelineContentContainer) ((TimelineContentHeaderContainer) (((SashForm) ((TimelineKeyframeHeader) (timebar
*/
public void draw(boolean isPlayHeaderLine) {
double scale = ((TimeBar) getParent()).getScale();
-
- double startTime = ((TimeBar) getParent()).getStartTime();
+ int startTime = ((TimeBar) getParent()).getStartTime();
if (startTime == 0 && getCurrentPointTime() <= TimelineConstants.DEFAULT_TIMELINE_TIMEBAR_0) {
this.setLocation(TimelineConstants.DEFAULT_TIMELINE_TIMEBAR_0,
TimelineConstants.DEFAULT_TIMELINE_MARKER_Y);
} else {
- int timelineMarkerX =
- (int) ((getCurrentPointTime() * scale * TimelineConstants.DEFAULT_TIME_MILLISECOND) - (startTime
- * scale * TimelineConstants.DEFAULT_TIME_INTERVAL));
+ int timelineMarkerX = (int) ((getCurrentPointTime() * scale) - (startTime * scale)) / TimelineConstants.DEFAULT_CONVERTTIME_POSITION_INTERVAL ;
this.setLocation(timelineMarkerX, TimelineConstants.DEFAULT_TIMELINE_MARKER_Y);
}
*
* @return {@link PlayHeader} TimeMarker current Time value
*/
- public double getPlayHeaderTime() {
+ public int getPlayHeaderTime() {
double scale = ((TimeBar) getParent()).getScale();
double startTime = ((TimeBar) getParent()).getStartTime();
- return (((positionMarker / scale) + (startTime * TimelineConstants.DEFAULT_TIME_INTERVAL)))
- / TimelineConstants.DEFAULT_TIME_MILLISECOND;
+ return (int) (((positionMarker / scale) + (startTime)));
+ /// TimelineConstants.DEFAULT_TIME_MILLISECOND;
}
/**
* @param pointTime
* current Time value
*/
- public void sendPointTime(final double pointTime) {
+ public void sendPointTime(int pointTime) {
this.setCurrentPointTime(pointTime);
- String timeText = AnimatorUtils.convertTimetoTimeText(pointTime);
+ String timeText = AnimatorUtils.convertTimetoTimeIntText(pointTime);
boolean isToolbar = searchToolBar();
if (isToolbar == true) {
public void run() {
String animationGroupId =
AnimatorUtils.getActiveAnimatorBrowserViewer().getCurrentAnimationGroupId();
+
+ int currentPointTime = getCurrentPointTime();
+ double pointTime = Formatter.computeTimeTotime(currentPointTime);
+
AnimatorUtils.getActiveAnimatorBrowserViewer()
- .showAnimationAtMoment(animationGroupId, getCurrentPointTime());
+ .showAnimationAtMoment(animationGroupId, pointTime);
}
});
}
*
* @return current point Time
*/
- public double getCurrentPointTime() {
+ public int getCurrentPointTime() {
return currentPointTime;
}
* @param currentPointTime
* current point time
*/
- public void setCurrentPointTime(double currentPointTime) {
+ public void setCurrentPointTime(int currentPointTime) {
this.currentPointTime = currentPointTime;
}
import org.eclipse.swt.widgets.Composite;
import org.tizen.webuibuilder.animator.ui.views.timeline.TimelineContentContainer;
import org.tizen.webuibuilder.animator.ui.views.timeline.TimelineMainContainer;
+import org.tizen.webuibuilder.animator.ui.views.timeline.common.TimelineConstants;
import org.tizen.webuibuilder.animator.ui.views.timeline.tool.TimelineToolbar;
public final static double SCALE_400 = 4.0d;
private double scale = SCALE_100;
- private double startTime = 0.0;
+ private int startTime = 0;
private TimeBarRenderer timelineRenderer = null;
@Override
public void mouseDown(MouseEvent e) {
- setPosition(e.x);
+ setPosition(e.x * TimelineConstants.DEFAULT_CONVERTTIME_POSITION_INTERVAL);
TimelineContentContainer container =
(TimelineContentContainer) ((((getParent()).getParent()).getParent())
*
* @return double time value
*/
- public double getStartTime() {
+ public int getStartTime() {
return startTime;
}
* @param startTime
* double time value
*/
- public void setStartTime(double startTime) {
+ public void setStartTime(int startTime) {
this.startTime = startTime;
}
TimelineToolbar toolBar = mainContainer.getTimelineToolbar();
toolBar.stopPlaying();
-/* if (positionTime < 0) {
- playHeader.setLocation(0, playHeader.getBounds().y);
- playHeader.setPositionMarker(0);
- } else {*/
- playHeader.setLocation(positionTime, playHeader.getBounds().y);
- playHeader.setPositionMarker(positionTime);
- //}
+ playHeader.setLocation(positionTime / TimelineConstants.DEFAULT_CONVERTTIME_POSITION_INTERVAL, playHeader.getBounds().y);
+ playHeader.setPositionMarker(positionTime);
- double pointTime = playHeader.getPlayHeaderTime();
+ int pointTime = playHeader.getPlayHeaderTime();
playHeader.setCurrentPointTime(pointTime);
// update marker point time
*/
public class TimeBarRenderer {
- private double startTime = 0.0;
+ private int startTime = 0;
private double scale = 1.0;
/**
int xPixel = TimelineConstants.DEFAULT_TIMELINE_TIMEBAR_0;
scale = timeline.getScale();
double secondInterval = scale * TimelineConstants.DEFAULT_TIME_INTERVAL;
- startTime = (int) timeline.getStartTime();
- xPixel -= (timeline.getStartTime() - (double) startTime) * ((double) secondInterval);
+ startTime = (int) timeline.getStartTime() / TimelineConstants.DEFAULT_TIME_POSITION_INTERVAL;
+ xPixel -= ((timeline.getStartTime() / TimelineConstants.DEFAULT_TIME_POSITION_INTERVAL) - (int) startTime) * ((double) secondInterval);
for (; xPixel < rt.width; startTime++, xPixel += secondInterval) {
if (startTime % 10 == 0) {
import org.tizen.webuibuilder.animator.ui.views.timeline.TimelineViewer;
import org.tizen.webuibuilder.animator.ui.views.timeline.common.ColorResource;
import org.tizen.webuibuilder.animator.ui.views.timeline.common.Formatter;
+import org.tizen.webuibuilder.animator.ui.views.timeline.common.TimelineConstants;
import org.tizen.webuibuilder.animator.ui.views.timeline.common.TimelineMessages;
import org.tizen.webuibuilder.animator.ui.views.timeline.header.PlayHeader;
import org.tizen.webuibuilder.animator.ui.views.timeline.header.TimeBar;
.getKeyframeHeader().getTimeBar().getPlayHeader();
marker.setPositionMarker(0);
- marker.setCurrentPointTime(0.0);
+ marker.setCurrentPointTime(0);
marker.draw(true);
setCurrentTime("00 : 00 . 000");
.getKeyframeHeader().getTimeBar();
PlayHeader marker = timeBar.getPlayHeader();
- marker.setPositionMarker((int) (lastTime * timeBar.getScale() * 100));
- marker.setCurrentPointTime(lastTime);
+
+ int timelinePoint = (int) (lastTime * timeBar.getScale() * TimelineConstants.DEFAULT_TIME_POSITION_INTERVAL);
+ int timePoint = Formatter.timeToComputeTime(lastTime);
+
+ marker.setPositionMarker(timelinePoint);
+ marker.setCurrentPointTime(timePoint);
marker.draw(true);
double markerTime = marker.getPlayHeaderTime();
.getKeyframeHeader().getTimeBar();
PlayHeader marker = timeBar.getPlayHeader();
- marker.setPositionMarker((int) (((double) millSecond / 1000) * timeBar.getScale() * 100));
- marker.setCurrentPointTime((double) millSecond / 1000);
+
+ int timelinePoint = (int) (timeBar.getScale() * TimelineConstants.DEFAULT_TIME_POSITION_INTERVAL);
+ double pointTime = Formatter.computeTimeTotime(millSecond);
+ int timePoint = Formatter.timeToComputeTime(millSecond);
+
+ marker.setPositionMarker((int) (pointTime * timelinePoint));
+ marker.setCurrentPointTime(millSecond);
+
if (Platform.getOS().equals(Platform.OS_WIN32)) {
marker.draw(false);
} else if (Platform.getOS().equals(Platform.OS_LINUX)
/**
* set TimeTextPoint
*/
+
private void setTimeTextPoint() {
TimelineContentContainer contentContainer =
((TimelineMainContainer) getParent()).getContentContainer();
contentContainer.getContentHeaderContainer().getKeyframeHeader().getTimeBar();
double scale = timeBar.getScale();
- double newTime = Formatter.toStringTimeFormat(currentTime);
+ int newTime = Formatter.toStringTimeFormat(currentTime);
contentContainer.refreshHScroll(newTime, 1, 0, 2);
double startTime = timeBar.getStartTime();
- int positionTime = (int) ((newTime * (scale * 100.0)) - startTime * (scale * 10.0));
-
+
+ int currentPositionTime = (int) (newTime * (scale));
+ int startPositionTime = (int) (startTime * (scale));
+
+ int positionTime = (currentPositionTime - startPositionTime);
timeBar.setPosition(positionTime);
contentContainer.refreshPlayHeader(true);
.getTimeBar();
PlayHeader marker = timeBar.getPlayHeader();
- marker.setPositionMarker((int) (lastTime * timeBar.getScale() * 100));
- marker.setCurrentPointTime(lastTime);
+
+ int timelinePoint = (int) (lastTime * timeBar.getScale() * TimelineConstants.DEFAULT_TIME_POSITION_INTERVAL);
+ int timePoint = Formatter.timeToComputeTime(timelinePoint);
+
+ marker.setPositionMarker(timelinePoint);
+ marker.setCurrentPointTime(timePoint);
marker.draw(true);
import org.tizen.webuibuilder.animator.ui.views.timeline.command.TimelineFrameEditCommand;
import org.tizen.webuibuilder.animator.ui.views.timeline.command.TimelineKeyframeEditCommand;
import org.tizen.webuibuilder.animator.ui.views.timeline.common.ColorResource;
+import org.tizen.webuibuilder.animator.ui.views.timeline.common.Formatter;
import org.tizen.webuibuilder.animator.ui.views.timeline.common.TimelineConstants;
import org.tizen.webuibuilder.animator.ui.views.timeline.editpart.TimelineEditPart;
import org.tizen.webuibuilder.animator.ui.views.timeline.header.TimeBar;
import org.tizen.webuibuilder.animator.ui.views.timeline.widget.KeyFrame;
import org.tizen.webuibuilder.animator.ui.views.timeline.widget.KeyFrameComponent;
import org.tizen.webuibuilder.animator.ui.views.timeline.widget.KeyFrameUnit;
+import org.tizen.webuibuilder.utility.Platform;
/**
*/
public class TimeTreeElement extends Canvas implements ISelectionProvider {
- private double visibleStartTime = 0.0;
+ private int DEFAULT_KEYFRAME_MARGINE = 4;
+ private int visibleStartTime = 0;
private Composite treeContainer = null;
private Tree tree = null;
addListener(SWT.MouseMove, mouseListener);
addListener(SWT.MouseDoubleClick, mouseListener);
+ if (Platform.getOS().equals(Platform.OS_WIN32)) {
+ DEFAULT_KEYFRAME_MARGINE = TimelineConstants.DEFAULT_KEYFRAME_MARGIN;
+ } else if (Platform.getOS().equals(Platform.OS_LINUX)
+ || Platform.getOS().equals(Platform.OS_MACOSX)) {
+ DEFAULT_KEYFRAME_MARGINE = TimelineConstants.DEFAULT_KEYFRAME_MARGIN_LINUX;
+ }
}
/*
TimelineConstants.DEFAULT_TIMEELEMENT_ZOOMIN_HEIGHT);
}
-
@Override
public void addSelectionChangedListener(ISelectionChangedListener listener) {
// TODO Auto-generated method stub
}
-
/*******************************************************************************
* Class Method
*******************************************************************************/
if (keyframeUnit.getModel().getId().equals(keyframe.getId())) {
keyframeUnit.deleteChild(model);
int size = keyframeUnit.getKeyframelist().size();
- if(size == 0) {
+ if (size == 0) {
keyframeUnits.remove(keyframeUnit);
}
break;
/**
* Move CurrentTimeMarker
*/
- private void moveCurrentTimeMarker() {
+ private void moveCurrentTimeMarker(boolean isSelected) {
TimelineContentContainer timelineContentContainer = findTimelineContentContainer();
TimelineContentHeaderContainer contentHeaderContainer =
timelineContentContainer.getContentHeaderContainer();
TimeBar timebar = contentHeaderContainer.getKeyframeHeader().getTimeBar();
- int positionTime =
- selectedKeyFrame.getKeyFrameUnit().getKeyFrameUnitModelXpoint()
- + selectedKeyFrame.getKeyFrameModelXpoint()
- - TimelineConstants.DEFAULT_TIMELINE_LEFT_MARGIN
- - getVisibleStartTimePoint();
-
- timebar.setPosition(positionTime);
+ int positionTime = 0;
+ if (isSelected == true) {
+ positionTime =
+ selectedKeyFrame.getKeyFrameUnit().getKeyFrameUnitModelXpoint()
+ + selectedKeyFrame.getKeyFrameModelXpoint()
+ - TimelineConstants.DEFAULT_TIMELINE_LEFT_MARGIN;
+ // - getVisibleStartTimePoint();
+ } else {
+ positionTime = mouseDownPoint - TimelineConstants.DEFAULT_TIMELINE_LEFT_MARGIN;
+ // + getVisibleStartTimePoint();
+ }
+ timebar.setPosition(positionTime * TimelineConstants.DEFAULT_CONVERTTIME_POSITION_INTERVAL);
timebar.redraw();
timebar.getPlayHeader().draw(true);
private void updateKeyFrameUnitModel(KeyFrameUnit keyframeUnit) {
TimelineViewer viewer = getEditpart().getViewer();
- double visibleStartTime = getVisibleStartTime();
+ int visibleStartTime = getVisibleStartTime();
Rectangle keyframeBounds = keyframeUnit.getKeyframeUnit();
double scale = getScale();
* keyframeBounds.width);
*/
double startTime = 0.0;
+ double timelinePoint = scale * TimelineConstants.DEFAULT_TIME_POSITION_INTERVAL;
+ double pointTime = Formatter.computeTimeTotime(visibleStartTime);
startTime =
- (double) (((keyframeBounds.x - TimelineConstants.DEFAULT_TIMELINE_LEFT_MARGIN) / (scale * TimelineConstants.DEFAULT_TIME_MILLISECOND)) + (visibleStartTime / TimelineConstants.DEFAULT_TIME_INTERVAL));
+ (double) (((keyframeBounds.x - TimelineConstants.DEFAULT_TIMELINE_LEFT_MARGIN) / timelinePoint) + pointTime);
double durationTime = 0.0;
if (keyframeUnit.getModel().getChildrenSize() > 1) {
- durationTime =
- (double) keyframeBounds.width
- / (scale * TimelineConstants.DEFAULT_TIME_MILLISECOND);
+ durationTime = (double) keyframeBounds.width / timelinePoint;
}
keyframeUnit.setKeyframeUnitStartTime(startTime);
// System.out.println("startTime " + startTime + " durationTime " + durationTime);
Command animationPropertyChange =
- new TimelineKeyframeEditCommand(keyframeUnit.getModel(), startTime,
- durationTime);
+ new TimelineKeyframeEditCommand(keyframeUnit.getModel(), startTime, durationTime);
viewer.getEditDomain().getCommandStack().execute(animationPropertyChange);
private void updateKeyFrameModel(KeyFrame keyframe) {
double scale = getScale();
+ double timelineScalePoint = scale * TimelineConstants.DEFAULT_TIME_POSITION_INTERVAL;
double currentSecond =
(double) (keyframe.getAfterPoint() - keyframe.getKeyFrameUnit().getKeyframeUnit().x + TimelineConstants.DEFAULT_FRAME_WIDGET_HALF_WIDTH)
- / ((double) TimelineConstants.DEFAULT_TIME_MILLISECOND * scale);
+ / (timelineScalePoint);
// System.out.println("current Second " + currentSecond);
AnimatorFrame model = keyframe.getModel();
TimelineViewer viewer = getEditpart().getViewer();
viewer.getEditDomain().getCommandStack().execute(animationPropertyChange);
+ }
+ /**
+ * Add KeyFrameUnit in sameTime
+ *
+ * @param selectKeyFrameUnit
+ * {@link KeyFrameUnit}
+ *
+ * @param keyFrameUnits
+ * {@link KeyFrameUnit}
+ */
+ public void addKeyFrameUnit(KeyFrameUnit selectKeyFrameUnit, List<KeyFrameUnit> keyFrameUnits) {
+ double selectKeyFrameStart = selectKeyFrameUnit.getKeyframeUnitStartTime();
+ double selectKeyFrameDuration = selectKeyFrameUnit.getKeyframeUnitDurationTime();
+ List<KeyFrameUnit> childrenKeyframeWidget = getKeyframeUnits();
+ for (KeyFrameUnit childKeyframeWidget : childrenKeyframeWidget) {
+ if (!childKeyframeWidget.equals(selectKeyFrameUnit)) {
+
+ KeyFrameUnit currentKeyframeWidget = (KeyFrameUnit) childKeyframeWidget;
+ double currentKeyFrameStart = currentKeyframeWidget.getKeyframeUnitStartTime();
+ double currentKeyFrameDuration =
+ currentKeyframeWidget.getKeyframeUnitDurationTime();
+
+ if (selectKeyFrameStart <= currentKeyFrameStart) {
+ if (selectKeyFrameStart + selectKeyFrameDuration >= currentKeyFrameStart
+ + currentKeyFrameDuration) {
+ keyFrameUnits.add((KeyFrameUnit) childKeyframeWidget);
+ }
+ }
+ }
+ }
}
/*******************************************************************************
*
* @return visibleStartTime
*/
- public double getVisibleStartTime() {
+ public int getVisibleStartTime() {
return visibleStartTime;
}
* @param visibleStartTime
* visibleStartTime
*/
- public void setVisibleStartTime(double visibleStartTime) {
+ public void setVisibleStartTime(int visibleStartTime) {
this.visibleStartTime = visibleStartTime;
}
*/
public int getVisibleStartTimePoint() {
double scale = getScale();
- return (int) (visibleStartTime * scale * TimelineConstants.DEFAULT_TIME_INTERVAL);
+ return (int) (visibleStartTime * scale / TimelineConstants.DEFAULT_TIME_INTERVAL);
}
/**
* @param point
* @return
*/
- public double getPointToTime(int point) {
+ public int getPointToTime(int point) {
double scale = getScale();
- return (((point / scale) + (visibleStartTime * TimelineConstants.DEFAULT_TIME_INTERVAL)))
- / TimelineConstants.DEFAULT_TIME_MILLISECOND;
+ return (int) (((point / scale) + (visibleStartTime / TimelineConstants.DEFAULT_TIME_INTERVAL)));// /
+ // TimelineConstants.DEFAULT_TIME_MILLISECOND;
}
/**
*/
public int getTimeToPoint(double time) {
double scale = getScale();
- return (int) ((((time * TimelineConstants.DEFAULT_TIME_MILLISECOND) - (visibleStartTime * TimelineConstants.DEFAULT_TIME_INTERVAL))) * scale);
+ return (int) ((((time * TimelineConstants.DEFAULT_TIME_POSITION_INTERVAL) - (visibleStartTime / TimelineConstants.DEFAULT_CONVERTTIME_POSITION_INTERVAL))) * scale);
}
/**
int pixcelX = TimelineConstants.DEFAULT_TIMELINE_LEFT_MARGIN;
double scale = getScale();
double secondInterval = scale * TimelineConstants.DEFAULT_TIME_INTERVAL;
- int startTime = (int) visibleStartTime;
- pixcelX -= (visibleStartTime - (double) startTime) * ((double) secondInterval);
+ int startTime =
+ (int) visibleStartTime / TimelineConstants.DEFAULT_TIME_POSITION_INTERVAL;
+ pixcelX -=
+ (visibleStartTime / TimelineConstants.DEFAULT_TIME_POSITION_INTERVAL - (double) startTime)
+ * ((double) secondInterval);
for (; pixcelX < timeElementClientArea.width; startTime++, pixcelX += secondInterval) {
- if (startTime % TimelineConstants.DEFAULT_TIME_INTERVAL == 0) {
+ if (startTime % 10 == 0) {
e.gc.drawLine(pixcelX, 0, pixcelX, timeElementClientArea.height - 1);
}
}
}
}
+ mouseDownPoint = event.x;
+ beforeMouseDownPoint = event.x;
if (isKeyFrameMouseDown == true || isKeyFrameUnitMouseDown == true) {
- // System.out.println("mouseDown " +event.x);
- mouseDownPoint = event.x;
- beforeMouseDownPoint = event.x;
if (isKeyFrameMouseDown == true) {
int currentPoint = (int) (selectedKeyFrame.getKeyframe().x);
selectedKeyFrame.setBeforePoint(currentPoint);
selectedKeyFrame.setAfterPoint(currentPoint);
extendsPoint = mouseDownPoint - selectedKeyFrame.getKeyframe().x;
+ moveCurrentTimeMarker(true);
} else {
extendsPoint = mouseDownPoint - selectedKeyFrameUnit.getKeyframeUnit().x;
+ moveCurrentTimeMarker(false);
}
+ } else {
+ moveCurrentTimeMarker(false);
}
// Mouse Up
KeyFrameUnit keyframeUnit = selectedKeyFrame.getKeyFrameUnit();
double exPoint = getPointToTime(keyframeUnit.getKeyframeUnit().x);
if (exPoint < 0) {
- keyframeUnit.getKeyframeUnit().x =
- TimelineConstants.DEFAULT_KEYFRAME_MARGINE;
+ keyframeUnit.getKeyframeUnit().x = DEFAULT_KEYFRAME_MARGINE;
int beforekeyframeEndPoint =
keyframeUnit.getKeyFrameUnitModelXpoint()
- + keyframeUnit.getKeyFrameUnitModelWidth()
- - getVisibleStartTimePoint();
+ + keyframeUnit.getKeyFrameUnitModelWidth();
+ // - getVisibleStartTimePoint();
keyframeUnit.refresh(keyframeUnit.getKeyframeUnit().x,
beforekeyframeEndPoint);
redraw();
} else if (selectedKeyFrameUnit != null) {
double exPoint = getPointToTime(selectedKeyFrameUnit.getKeyframeUnit().x);
if (exPoint < 0) {
- selectedKeyFrameUnit.getKeyframeUnit().x =
- TimelineConstants.DEFAULT_KEYFRAME_MARGINE;
- }
+ selectedKeyFrameUnit.getKeyframeUnit().x = DEFAULT_KEYFRAME_MARGINE;
+ }
if (mouseMoveReleasePoint != 0
&& selectedKeyFrameUnit.getKeyFrameUnitModelXpoint() != mouseMoveReleasePoint) {
// System.out.println("mouseMoveReleasePoint " + mouseMoveReleasePoint);
// Just one Keyframe
if (parentUnit.getModel().getChildrenSize() == 1) {
double exPoint = getPointToTime(parentArea.x);
- if (exPoint < 0.0 && getVisibleStartTime() == 0.0) {
- parentArea.x = TimelineConstants.DEFAULT_KEYFRAME_MARGINE;
+ if (exPoint < 0.0 && getVisibleStartTime() == 0) {
+ parentArea.x = DEFAULT_KEYFRAME_MARGINE;
+
selectedKeyFrame
.setAfterPoint(TimelineConstants.DEFAULT_TIMELINE_TIMEBAR_0);
isKeyFrameUnitMouseDown = false;
return;
} else if (exPoint < 0.0) {
- parentArea.x = TimelineConstants.DEFAULT_KEYFRAME_MARGINE;
+ parentArea.x = DEFAULT_KEYFRAME_MARGINE;
+
selectedKeyFrame
.setAfterPoint(TimelineConstants.DEFAULT_START_KEYFRAME_POINT);
afterkeyframeWidth =
- beforekeyframeEndPoint
- - TimelineConstants.DEFAULT_KEYFRAME_MARGINE;
+ beforekeyframeEndPoint - DEFAULT_KEYFRAME_MARGINE;
parentUnit.refresh(parentArea.x, afterkeyframeWidth);
- if (getVisibleStartTime() == 0.0) {
+ if (getVisibleStartTime() == 0) {
isKeyFrameMouseDown = false;
isKeyFrameUnitMouseDown = false;
updateModel(selectedKeyFrame);
}
} else {
double exPoint = getPointToTime(selectedKeyFrameUnit.getKeyframeUnit().x);
- if (exPoint < 0.0 && getVisibleStartTime() == 0.0) {
- selectedKeyFrameUnit.getKeyframeUnit().x =
- TimelineConstants.DEFAULT_KEYFRAME_MARGINE;
+ if (exPoint < 0.0 && getVisibleStartTime() == 0) {
+ selectedKeyFrameUnit.getKeyframeUnit().x = DEFAULT_KEYFRAME_MARGINE;
isKeyFrameMouseDown = false;
isKeyFrameUnitMouseDown = false;
// refresh scroll
Rectangle parent = getBounds();
- double currentTime = getPointToTime(mouseDownPoint);
- if ((parent.width - TimelineConstants.DEFAULT_TIME_INTERVAL < mouseDownPoint)
+ int currentTime = getPointToTime(mouseDownPoint);
+ if ((parent.width - 10 < mouseDownPoint)
&& (beforeMouseDownPoint < mouseDownPoint)) {
TimelineContentContainer container = findTimelineContentContainer();
container.refreshHScroll(currentTime, 1, 1, 1);
- } else if ((TimelineConstants.DEFAULT_TIME_INTERVAL > mouseDownPoint)
- && (beforeMouseDownPoint > mouseDownPoint)) {
+ } else if ((10 > mouseDownPoint) && (beforeMouseDownPoint > mouseDownPoint)) {
TimelineContentContainer container = findTimelineContentContainer();
container.refreshHScroll(currentTime, 0, -1, 1);
}
}
} else if (event.type == SWT.MouseDoubleClick) {
if (isKeyFrameMouseDown == true) {
- moveCurrentTimeMarker();
+ moveCurrentTimeMarker(true);
}
}
}
};
-
}
private void createControls() {
if (Platform.getOS().equals(Platform.OS_WIN32)) {
- imageHeight = 5;
- textHeight = 6;
+ imageHeight = 4;
+ textHeight = 5;
} else if (Platform.getOS().equals(Platform.OS_LINUX)
|| Platform.getOS().equals(Platform.OS_MACOSX)) {
- imageHeight = 6;
- textHeight = 6;
+ imageHeight = 5;
+ textHeight = 5;
}
// Widget Name
if (getElementType() == 0) {
// ExpandArrow
- treeExpandArrowImage = new Rectangle(5, 9, 7, 7);
+ treeExpandArrowImage = new Rectangle(5, 8, 7, 7);
// Widget Icon
widgetIconFile = "page_16.png";
private int imageHeight = 5;
private int textHeight = 6;
-
+
private Image animationsCountImage = null;
private String animationsCountText = null;
private Image playTimeImage = null;
*/
private void createControls() {
if (Platform.getOS().equals(Platform.OS_WIN32)) {
- imageHeight = 5;
- textHeight = 6;
+ imageHeight = 4;
+ textHeight = 5;
} else if (Platform.getOS().equals(Platform.OS_LINUX)
|| Platform.getOS().equals(Platform.OS_MACOSX)) {
- imageHeight = 6;
- textHeight = 6;
+ imageHeight = 5;
+ textHeight = 5;
}
animationsCountImage =
animationsCountText = TimelineMessages.ANIMATIONS + "0EA";
playTimeText = TimelineMessages.PLAY_TIME + "0.000s";
startTimeText = TimelineMessages.START_TIME + "0.000s";
- endTimeText = TimelineMessages.END_TIME + "0.000s";
+ endTimeText = TimelineMessages.END_TIME + "0.000s";
}
/**
double totalPlayTime = currentEndTime - currentStartTime;
animationsCountText = TimelineMessages.ANIMATIONS + totalAnimationCount + "EA";
- playTimeText = TimelineMessages.PLAY_TIME + String.format("%.3f", totalPlayTime) + "s";
- startTimeText = TimelineMessages.START_TIME + String.format("%.3f", currentStartTime) + "s";
- endTimeText = TimelineMessages.END_TIME + String.format("%.3f", currentEndTime) + "s";
+ playTimeText = TimelineMessages.PLAY_TIME + String.format("%.1f", totalPlayTime) + "s";
+ startTimeText = TimelineMessages.START_TIME + String.format("%.1f", currentStartTime) + "s";
+ endTimeText = TimelineMessages.END_TIME + String.format("%.1f", currentEndTime) + "s";
redraw();
}
}
private void drawImageAndText(GC gc) {
- gc.drawImage(animationsCountImage, 10, imageHeight);
- gc.drawImage(playTimeImage, 140, imageHeight);
- gc.drawImage(startTimeImage, 280, imageHeight);
- gc.drawImage(endTimeImage, 420, imageHeight);
+ int animationsMargine = 10;
+ int playTimeImageMargine = 140;
+ int startTimeImageMargine = 260;
+ int endTimeImageMargine = 385;
+ int textMargine = 20;
+
+ if (Platform.getOS().equals(Platform.OS_WIN32)) {
+ // do nothing
+ } else if (Platform.getOS().equals(Platform.OS_LINUX)
+ || Platform.getOS().equals(Platform.OS_MACOSX)) {
+ animationsMargine = 10;
+ playTimeImageMargine = 150;
+ startTimeImageMargine = 280;
+ endTimeImageMargine = 415;
+ }
+ gc.drawImage(animationsCountImage, animationsMargine, imageHeight);
+ gc.drawImage(playTimeImage, playTimeImageMargine, imageHeight);
+ gc.drawImage(startTimeImage, startTimeImageMargine, imageHeight);
+ gc.drawImage(endTimeImage, endTimeImageMargine, imageHeight);
gc.setForeground(ColorResource.KEYFRAMEWIDGET_TEXT);
- gc.drawText(animationsCountText, 30, textHeight, true);
- gc.drawText(playTimeText, 160, textHeight, true);
- gc.drawText(startTimeText, 300, textHeight, true);
- gc.drawText(endTimeText, 440, textHeight, true);
+ gc.drawText(animationsCountText, animationsMargine + textMargine, textHeight, true);
+ gc.drawText(playTimeText, playTimeImageMargine + textMargine, textHeight, true);
+ gc.drawText(startTimeText, startTimeImageMargine + textMargine, textHeight, true);
+ gc.drawText(endTimeText, endTimeImageMargine + textMargine, textHeight, true);
gc.setForeground(ColorResource.LATTICE);
}
};
import org.tizen.webuibuilder.animator.ui.views.timeline.TimelineViewer;
import org.tizen.webuibuilder.animator.ui.views.timeline.common.TimelineConstants;
import org.tizen.webuibuilder.animator.ui.views.timeline.tree.TimeTreeElement;
+import org.tizen.webuibuilder.utility.Platform;
import org.tizen.webuibuilder.utility.ResourceManager;
@Override
public void selected() {
keyFrameUnit.selected();
-
+
}
/**
* Re Location
*/
public void reLocation() {
- double startPoint = getKeyFrameUnit().getKeyframeUnit().x;
- double delayPoint = getKeyFrameModelXpoint();
+ int startPoint = getKeyFrameUnit().getKeyframeUnit().x;
+ int delayPoint = getKeyFrameModelXpoint();
getKeyframe().x =
(int) (startPoint + delayPoint - TimelineConstants.DEFAULT_FRAME_WIDGET_HALF_WIDTH);
- getKeyframe().y = TimelineConstants.DEFAULT_KEYFRAME_MARGINE * 2;
+ if (Platform.getOS().equals(Platform.OS_WIN32)) {
+ getKeyframe().y = TimelineConstants.DEFAULT_FRAME_WIDGET_MARGIN;
+ } else if (Platform.getOS().equals(Platform.OS_LINUX)
+ || Platform.getOS().equals(Platform.OS_MACOSX)) {
+ getKeyframe().y = TimelineConstants.DEFAULT_FRAME_WIDGET_MARGIN_LINUX;
+ }
+
}
/**
*/
public int getKeyFrameModelXpoint() {
double scale = getKeyFrameUnit().getTimeTreeElement().getScale();
- return (int) (getModel().getFrameTime() * scale * (double) TimelineConstants.DEFAULT_TIME_MILLISECOND);
+ return (int) (getModel().getFrameTime() * scale * (double) TimelineConstants.DEFAULT_TIME_POSITION_INTERVAL);
}
/*******************************************************************************
return keyFrameUnit.getTimeTreeElement();
}
-
-
}
import org.tizen.webuibuilder.animator.ui.views.timeline.common.ColorResource;
import org.tizen.webuibuilder.animator.ui.views.timeline.common.TimelineConstants;
import org.tizen.webuibuilder.animator.ui.views.timeline.tree.TimeTreeElement;
+import org.tizen.webuibuilder.utility.Platform;
/**
*/
private void reLocation() {
getKeyframeUnit().x = getKeyFrameUnitModelXpoint();
- getKeyframeUnit().y = TimelineConstants.DEFAULT_KEYFRAME_MARGINE;
+ if (Platform.getOS().equals(Platform.OS_WIN32)) {
+ getKeyframeUnit().y = TimelineConstants.DEFAULT_KEYFRAME_MARGIN;
+ } else if (Platform.getOS().equals(Platform.OS_LINUX)
+ || Platform.getOS().equals(Platform.OS_MACOSX)) {
+ getKeyframeUnit().y = TimelineConstants.DEFAULT_KEYFRAME_MARGIN_LINUX;
+ }
getKeyframeUnit().width = getKeyFrameUnitModelWidth();
getKeyframeUnit().height = TimelineConstants.DEFAULT_LIFE_WIGET_HEIGHT;
}
* @param width
*/
public void refresh(int startPoint, int width) {
- //System.out.println("unit start " + startPoint + " unit width " + width);
+ // System.out.println("unit start " + startPoint + " unit width " + width);
getKeyframeUnit().x = startPoint;
getKeyframeUnit().width = width;
double percent =
((AnimatorKeyframe) frameModel.getParent()).calculateFramePercent(frameTime);
- int xPoint = (int) (width * percent / TimelineConstants.DEFAULT_TIME_MILLISECOND);
+ int xPoint = (int) (width * percent / TimelineConstants.DEFAULT_TIME_POSITION_INTERVAL);
// System.out.println("psercent " + percent + " framePoint " + xPoint);
keyFrame.getKeyframe().x =
*/
public int getKeyFrameUnitModelXpoint() {
double scale = getTimeTreeElement().getScale();
- return (int) (getModel().getDelay() * scale * (double) TimelineConstants.DEFAULT_TIME_MILLISECOND)
+ return (int) (getModel().getDelay() * scale * (double) TimelineConstants.DEFAULT_TIME_POSITION_INTERVAL)
+ TimelineConstants.DEFAULT_TIMELINE_LEFT_MARGIN;
}
*/
public int getKeyFrameUnitModelWidth() {
double scale = getTimeTreeElement().getScale();
- return (int) (getModel().getDuration() * scale * (double) TimelineConstants.DEFAULT_TIME_MILLISECOND);
+ return (int) (getModel().getDuration() * scale * (double) TimelineConstants.DEFAULT_TIME_POSITION_INTERVAL);
}
/**
public void selected() {
moveToBottom();
}
-
+
/**
* Move to bottom
*/
timeTreeElement.getKeyframeUnits().remove(this);
timeTreeElement.getKeyframeUnits().add(this);
}
+
/*******************************************************************************
* Getter, Setter
*******************************************************************************/
import org.tizen.webuibuilder.animator.ui.views.timeline.command.TimelineFrameCreateCommand;
import org.tizen.webuibuilder.animator.ui.views.timeline.command.TimelineFrameDeleteCommand;
import org.tizen.webuibuilder.animator.ui.views.timeline.command.TimelineKeyframeDeleteCommand;
+import org.tizen.webuibuilder.animator.ui.views.timeline.common.Formatter;
import org.tizen.webuibuilder.animator.ui.views.timeline.editpart.TimelineEditPart;
import org.tizen.webuibuilder.animator.ui.views.timeline.tree.TimeTreeElement;
import org.tizen.webuibuilder.animator.ui.views.timeline.tree.TimelineOutlineElement;
viewer.getMainContainer().getContentContainer()
.getContentHeaderContainer().getOutlineHeader()
.getSelectedAnimationGroupId();
- double pointTime =
- viewer.getMainContainer().getContentContainer()
- .getContentHeaderContainer().getKeyframeHeader()
- .getTimeBar().getPlayHeader().getCurrentPointTime();
+ int currentPointTime = viewer.getMainContainer().getContentContainer()
+ .getContentHeaderContainer().getKeyframeHeader()
+ .getTimeBar().getPlayHeader().getCurrentPointTime();
+
+ double pointTime = Formatter.computeTimeTotime(currentPointTime);
+
Command command =
new AnimationCreateCommand(animationGroupId, cssAnimation,
appManager,
}
/**
+ * Convert time int to string
+ *
+ * @param pointTime
+ * @return
+ */
+ public static String convertTimetoTimeIntText(int pointTime) {
+ return Formatter.toTimeFormatInt(pointTime);
+ }
+ /**
* Convert percent to target time
*
* @param percent
}
/**
- * Get viewer
- *
- * @param keyframeWidget
- * @return
- */
- /*public static TimelineViewer getViewer(KeyFrameWidget keyframeWidget) {
-
- TimeTreeElement timeTreeElement = (TimeTreeElement) keyframeWidget.getParent();
- TreeItem treeItem = (TreeItem) timeTreeElement.getData("RefrenceTreeItem");
-
- Object data = treeItem.getData();
- if (data instanceof TimelineEditPart) {
- TimelineViewer viewer = ((TimelineEditPart) data).getViewer();
-
- return viewer;
- }
-
- return null;
- }*/
-
-
- /**
* ex) input : "translate(100px, 0px) rotate(0deg)", 200, 50 output :
* "translate(200px, 50px) rotate(0deg)"
*
call("modifyStyle", new Jsonizable[] { new JsString(result) });
}
+
+ public void modifyStyle(String style) {
+ call("modifyStyle", new Jsonizable[] { new JsString(style) });
+ }
}
}
protected Object call(String funcName, Jsonizable[] arguments) {
+ if (browser == null) {
+ return null;
+ }
+
StringBuffer script = new StringBuffer();
script.append(funcName);
--- /dev/null
+/*
+ * 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.gef.commands;
+
+import java.util.List;
+import java.util.Map;
+
+import org.eclipse.gef.commands.Command;
+import org.tizen.webuibuilder.model.Part;
+import org.tizen.webuibuilder.model.css.CssFile;
+import org.tizen.webuibuilder.model.css.CssSelector;
+import org.tizen.webuibuilder.model.css.CssStyle;
+import org.tizen.webuibuilder.model.page.PageData;
+import org.tizen.webuibuilder.ui.views.nscreen.NScreenUtil;
+
+
+abstract public class ChangeCssSelectorCommand extends Command {
+
+ private Part model;
+ private String selectorName;
+ private PageData pageData;
+ private CssFile appliedCssFile;
+ private CssSelector newSelector = null;
+
+ public ChangeCssSelectorCommand(Object model, PageData pageData, String selectorName) {
+ setModel(model);
+ this.pageData = pageData;
+ this.selectorName = selectorName;
+ }
+
+ public void setModel(Object model) {
+ this.model = (Part) model;
+ }
+
+ abstract public void execute2();
+
+ abstract public void undo2();
+
+ /**
+ * Do not override this method. You must override execute2().
+ */
+ @Override
+ public void execute() {
+ // prepare selector
+ Map<String, CssSelector> selectorMap = model.getEditSelectorMap();
+ CssSelector selector = selectorMap.get(selectorName);
+ if (selector == null) {
+ // create selector
+ selector = new CssSelector(selectorName);
+ selectorMap.put(selectorName, selector);
+ appliedCssFile = pageData.getCurrentCssFile();
+ appliedCssFile.addCssSelector(selector);
+ newSelector = selector;
+
+ }
+
+ // Setting all selector of Part
+ // List<CssFile> appliedCssFileList = pageData.getAppliedCssFiles();
+ // int index = appliedCssFileList.indexOf(appliedCssFile);
+ // int size = appliedCssFileList.size();
+ // Map<String, CssSelector> allMap = model.getAllSelectorMap();
+ // boolean skip = false;
+ // CssSelector cloneSelector = selector.cloneCssSelector(selectorName);
+ // if (size - 1 == index) {
+ // allMap.put(selectorName, cloneSelector);
+ // } else {
+ // for (int i = index + 1; i <= size - 1; i++) {
+ // CssSelector targetSelector = allMap.get(selectorName);
+ // if (targetSelector != null) {
+ // for (CssStyle style : selector.getStyles()) {
+ // targetSelector.getStyleMap().put(style.getKey(), style);
+ // }
+ // skip = true;
+ // break;
+ // }
+ // }
+ // if (!skip) {
+ // allMap.put(selectorName, cloneSelector);
+ // }
+ // }
+
+ execute2();
+
+ if (NScreenUtil.isLogEnabled()) {
+ NScreenUtil.nscreen_log("=====================Edit code=======================\n" + NScreenUtil.selectorCodeGen(selector));
+ }
+ }
+
+ /**
+ * Do not override this method. You must override undo2().
+ */
+ @Override
+ public void undo() {
+ undo2();
+ if (newSelector != null) {
+ model.getEditSelectorMap().remove(newSelector);
+ model.getAllSelectorMap().remove(newSelector);
+ appliedCssFile.removeCssSelector(newSelector);
+ }
+ }
+
+ public Part getModel() {
+ return model;
+ }
+
+ public String getSelectorName() {
+ return selectorName;
+ }
+}
import org.tizen.webuibuilder.model.Part;
import org.tizen.webuibuilder.model.css.CssFile;
import org.tizen.webuibuilder.model.css.CssSelector;
+import org.tizen.webuibuilder.model.page.PageData;
-public class CreateCssSelectorCommand extends Command {
+public class CreateCssSelectorCommand extends ChangeCssSelectorCommand {
- private CssFile cssFile;
- private CssSelector selector;
- private Part part;
- private String selectorName;
-
- public CreateCssSelectorCommand(CssFile cssFile, Part part, CssSelector selector) {
- this.cssFile = cssFile;
- this.part = part;
- this.selector = selector;
- }
-
- public CreateCssSelectorCommand(CssFile cssFile, Part part, String selectorName) {
- this.cssFile = cssFile;
- this.part = part;
- this.selectorName = selectorName;
+ public CreateCssSelectorCommand(PageData pageData, Part model, String selectorName) {
+ super(model, pageData, selectorName);
}
@Override
public boolean canExecute() {
- if (cssFile == null || part == null || selectorName == null || selectorName.isEmpty()) {
- return false;
- } else if (cssFile.getSelector(selectorName) != null) {
- return false;
- } else {
+ Part model = getModel();
+ if (getSelectorName() != null && !getSelectorName().isEmpty() && model != null) {
return true;
+ } else {
+ return false;
}
}
- @Override
- public void execute() {
- if (selector == null) {
- selector = new CssSelector(selectorName);
- }
+// @Override
+// public void execute() {
+// if (selector == null) {
+// selector = new CssSelector(selectorName);
+// }
+//
+// cssFile.addCssSelector(selector);
+// part.addSelector(selector.getSelectorName(), selector);
+// }
+//
+// @Override
+// public void undo() {
+// cssFile.removeCssSelector(selector);
+// part.removeSelector(selector.getSelectorName());
+// }
- cssFile.addCssSelector(selector);
- part.addSelector(selector.getSelectorName(), selector);
+ @Override
+ public void execute2() {
+ String selectorName = getSelectorName();
+ CssSelector selector = new CssSelector(selectorName);
+ Part model = getModel();
+ model.addSelector(selectorName, selector);
}
@Override
- public void undo() {
- cssFile.removeCssSelector(selector);
- part.removeSelector(selector.getSelectorName());
+ public void undo2() {
+ // TODO Auto-generated method stub
+ String selectorName = getSelectorName();
+ Part model = getModel();
+ model.removeSelector(selectorName);
}
}
import org.eclipse.gef.commands.Command;
import org.tizen.webuibuilder.BuilderConstants;
+import org.tizen.webuibuilder.model.Part;
import org.tizen.webuibuilder.model.app.AppManagerForHTML;
import org.tizen.webuibuilder.model.filedata.PageFileData;
import org.tizen.webuibuilder.model.page.PageData;
import org.tizen.webuibuilder.model.page.PageDataForHTML;
import org.tizen.webuibuilder.utility.DomUtil;
-import org.w3c.dom.Node;
+import org.w3c.dom.Element;
public class CreatePageCommand extends Command {
private AppManagerForHTML appManager;
private List<PageData> pageDatas;
- private Node pageNode;
-
- private final String BODY_ELEMENT = "//BODY";
- private final String BODY_ELEMENT_LOWER = "//body";
public CreatePageCommand(AppManagerForHTML appManager, String html, String name) {
this.appManager = appManager;
for(int i = 0; i < size; i++) {
PageData pageData = new PageDataForHTML(BuilderConstants.EMPTY,
- pageFileData, i, pageFileData.getDocument(),
+ pageFileData, i, appManager.getDocument(),
appManager.getDescriptorManager(), null);
if(pageData != null) {
pageDatas.add(pageData);
+ Part pagePart = pageData.getPagePart();
+ pagePart.setElement((Element)DomUtil.importedNode(appManager.getDocument(), pagePart.getElement()));
}
}
-
- Node bodyNode = DomUtil.getBodyNode(pageFileData.getDocument(), BODY_ELEMENT);
- pageNode = DomUtil.importedNode(appManager.getDocument(), bodyNode.getFirstChild());
}
@Override
public boolean canExecute() {
- return (pageDatas != null && pageNode != null) ? true : false;
+ return (pageDatas != null) ? true : false;
}
@Override
return;
}
- DomUtil.appendPageNode(appManager.getDocument(), BODY_ELEMENT_LOWER, pageNode);
-
for(PageData pagaData : pageDatas) {
appManager.addPage(pagaData, true);
}
@Override
public void undo() {
- DomUtil.removePageNode(this.appManager.getDocument(), BODY_ELEMENT_LOWER, pageNode);
-
for(PageData pagaData : pageDatas) {
- appManager.removePage(pagaData);
+ appManager.removePage(appManager.getPageIndex(pagaData));
}
-
}
}
--- /dev/null
+/*
+ * 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.gef.commands;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import org.eclipse.gef.EditPart;
+import org.eclipse.gef.commands.Command;
+import org.eclipse.gef.ui.actions.SelectionAction;
+import org.eclipse.ui.ISharedImages;
+import org.eclipse.ui.IWorkbenchPart;
+import org.eclipse.ui.PlatformUI;
+import org.tizen.webuibuilder.model.Part;
+import org.tizen.webuibuilder.model.app.AppManager;
+import org.tizen.webuibuilder.ui.actions.WebUIBuilderActionConstants;
+import org.tizen.webuibuilder.ui.contextmenu.Messages;
+import org.tizen.webuibuilder.ui.editor.PageDesigner;
+
+
+/**
+ * An action to delete selected page.
+ */
+public class DeletePageAction extends SelectionAction {
+
+ /**
+ * Creates a {@link DeletePageAction} and associates it with the given workbench part.
+ *
+ * @param part
+ * the workbench part
+ */
+ public DeletePageAction(IWorkbenchPart part) {
+ super(part);
+ setLazyEnablementCalculation(false);
+ }
+
+ /**
+ * Returns <code>true</code> if the selected objects can be deleted.
+ *
+ * @return <code>true</code> if the command should be enabled, and <code>false</code> otherwise
+ */
+ @Override
+ protected boolean calculateEnabled() {
+ Command command = createDeletePageCommand(getSelectedObjects());
+ if (command == null) {
+ return false;
+ }
+
+ return command.canExecute();
+ }
+
+ /**
+ * Creates a {@link DeletePageCommand}.
+ *
+ * @param selectedObjects
+ * a List containing the currently selected objects
+ * @return a {@link DeletePageCommand}
+ */
+ private Command createDeletePageCommand(List<?> selectedObjects) {
+ if (selectedObjects == null || selectedObjects.isEmpty()) {
+ return null;
+ }
+
+ List<Part> parts = new ArrayList<Part>();
+ for (Object obj : selectedObjects) {
+ if ((obj instanceof EditPart)) {
+ Object model = ((EditPart) obj).getModel();
+ if (model instanceof Part) {
+ Part part = (Part) model;
+ if(!part.isPagePart()) {
+ return null;
+ }
+ parts.add(part);
+ }
+ }
+ }
+
+ IWorkbenchPart workbenchPart = getWorkbenchPart();
+ if(!(workbenchPart instanceof PageDesigner)) {
+ return null;
+ }
+ PageDesigner pageDesigner = (PageDesigner) workbenchPart;
+ AppManager appManager = pageDesigner.getAppManager();
+
+ DeletePageCommand command = new DeletePageCommand(appManager, parts);
+
+ return command;
+ }
+
+ /**
+ * Initializes the delete action's text and images.
+ */
+ @Override
+ protected void init() {
+ super.init();
+
+ ISharedImages images = PlatformUI.getWorkbench().getSharedImages();
+
+ setId(WebUIBuilderActionConstants.DELETE_PAGE);
+ setText(Messages.DELETE_PAGE);
+// setText(Messages.ACTION_DELETE);
+// setId(ActionFactory.DELETE.getId());
+ setHoverImageDescriptor(images.getImageDescriptor(ISharedImages.IMG_TOOL_DELETE));
+ setImageDescriptor(images.getImageDescriptor(ISharedImages.IMG_TOOL_DELETE));
+ setDisabledImageDescriptor(images
+ .getImageDescriptor(ISharedImages.IMG_TOOL_DELETE_DISABLED));
+ setEnabled(false);
+ }
+
+ /**
+ * Performs the delete action on the selected objects.
+ */
+ @Override
+ public void run() {
+ Command command = createDeletePageCommand(getSelectedObjects());
+ if (command != null && command.canExecute()) {
+ execute(command);
+ }
+ }
+
+}
--- /dev/null
+/*
+ * 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.gef.commands;
+
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.Iterator;
+import java.util.List;
+import java.util.Map;
+import java.util.TreeSet;
+
+import org.eclipse.gef.commands.Command;
+import org.tizen.webuibuilder.animator.utils.AnimatorUtils;
+import org.tizen.webuibuilder.model.Part;
+import org.tizen.webuibuilder.model.app.AppManager;
+import org.tizen.webuibuilder.model.page.PageData;
+
+
+/**
+ * The command to delete {@link Part}s.
+ */
+public class DeletePageCommand extends Command {
+
+
+ private AppManager appManager;
+ private Map<Integer, PageData> pageDatas;
+ private TreeSet<Integer> indexes;
+
+ /**
+ * A List containing {@link Part} which is removed.
+ */
+ protected List<Part> pages = new ArrayList<Part>();
+
+ /**
+ * Constructs a {@link DeletePageCommand}.
+ * @param appManager
+ *
+ * @param child
+ * a List containing {@link Part} which is removed
+ */
+ public DeletePageCommand(AppManager appManager, List<Part> parts) {
+ this.appManager = appManager;
+ this.pages = parts;
+ }
+
+ /**
+ * Checks whether a {@link DeletePageCommand} can be executed.
+ *
+ * @return <code>true</code> if a {@link DeletePageCommand} can be executed, and
+ * <code>false</code> otherwise
+ */
+ @Override
+ public boolean canExecute() {
+ if (AnimatorUtils.getActivePageDesigner().isAnimatorMode()) {
+ return false;
+ }
+
+ if (pages == null || pages.isEmpty() || appManager.getPages().size() <= 1) {
+ return false;
+ }
+
+ return true;
+ }
+
+ /**
+ * Executes a {@link DeletePageCommand}.
+ */
+ @Override
+ public void execute() {
+ if (!canExecute()) {
+ return;
+ }
+
+ init();
+
+ // Deletes parts.
+ redo();
+ }
+
+ /**
+ * Initializes {@link PageData list}.
+ */
+ private void init() {
+ for(Part part : pages) {
+ if(part.getOwnerRef() instanceof PageData) {
+ if(pageDatas == null) {
+ pageDatas = new HashMap<Integer, PageData>(pages.size());
+ }
+ PageData pageData = (PageData) part.getOwnerRef();
+ int index = appManager.getPageIndex(pageData);
+ pageDatas.put(index, pageData);
+ }
+ }
+ indexes = new TreeSet<Integer>(pageDatas.keySet());
+ }
+
+ /**
+ * Re-executes a {@link DeletePageCommand}
+ */
+ @Override
+ public void redo() {
+ Iterator<Integer> iter = indexes.descendingIterator();
+ while(iter.hasNext()) {
+ int index = iter.next();
+ appManager.removePage(index);
+ }
+ }
+
+ /**
+ * Undoes a {@link DeletePageCommand}.
+ */
+ @Override
+ public void undo() {
+ Iterator<Integer> iter = indexes.iterator();
+ while(iter.hasNext()) {
+ int index = iter.next();
+ appManager.addPage(index, pageDatas.get(index), true);
+ }
+ }
+}
\ No newline at end of file
package org.tizen.webuibuilder.gef.commands;
+import java.util.List;
+import java.util.Map;
+
import org.eclipse.draw2d.geometry.Point;
import org.eclipse.draw2d.geometry.Rectangle;
import org.eclipse.gef.commands.Command;
import org.tizen.webuibuilder.model.Part;
+import org.tizen.webuibuilder.model.css.CssFile;
+import org.tizen.webuibuilder.model.css.CssSelector;
+import org.tizen.webuibuilder.model.page.PageData;
-public class DesignerMoveLayoutCommand extends Command {
-
- private Part model;
+public class DesignerMoveLayoutCommand extends ChangeCssSelectorCommand {
private Point delta;
private Point oldPosition;
+
- public DesignerMoveLayoutCommand(Object model, Point delta) {
- setModel(model);
+ public DesignerMoveLayoutCommand(Object model, Point delta, PageData pageData, String selectorName) {
+ super(model, pageData, selectorName);
setDelta(delta);
}
this.delta = delta;
}
- public void setModel(Object model) {
- this.model = (Part) model;
- }
+// public void setModel(Object model) {
+// this.model = (Part) model;
+// }
+
+// @Override
+// public void execute() {
+// Map<String, CssSelector> selectorMap = model.getEditSelectorMap();
+// // create new selector
+// CssSelector selector = selectorMap.get(selectorName);
+// if (selector == null) {
+// selector = new CssSelector(selectorName);
+// selectorMap.put(selectorName, selector);
+// pageData.getCurrentCssFile().addCssSelector(selector);
+// newSelector = selector;
+// }
+//
+// Rectangle pos = model.getPositionProperty();
+// oldPosition = new Point(pos.x, pos.y);
+// model.setPosition(new Point(oldPosition.x + delta.x, oldPosition.y + delta.y));
+//
+// List<CssFile> appliedCssFileList = pageData.getAppliedCssFiles();
+// int index = appliedCssFileList.indexOf(pageData.getCurrentCssFile());
+// int size = appliedCssFileList.size();
+// Map<String, CssSelector> allMap = model.getAllSelectorMap();
+// boolean skip = false;
+// if (size - 1 == index) {
+// allMap.put(selectorName, selector);
+// } else {
+// for (int i = index + 1; i <= size - 1; i++) {
+// if (allMap.get(selectorName) != null) {
+// skip = true;
+// break;
+// }
+// }
+// if (!skip) {
+// allMap.put(selectorName, selector);
+// }
+// }
+// }
+//
+// @Override
+// public void undo() {
+// if (oldPosition != null) {
+// model.setPosition(new Point(oldPosition.x, oldPosition.y));
+// if (newSelector != null) {
+// model.getEditSelectorMap().remove(newSelector);
+// model.getAllSelectorMap().remove(newSelector);
+// appliedCssFile.removeCssSelector(newSelector);
+// }
+// }
+// }
@Override
- public void execute() {
+ public void execute2() {
+ Part model = getModel();
Rectangle pos = model.getPositionProperty();
oldPosition = new Point(pos.x, pos.y);
model.setPosition(new Point(oldPosition.x + delta.x, oldPosition.y + delta.y));
}
@Override
- public void undo() {
+ public void undo2() {
+ Part model = getModel();
if (oldPosition != null) {
model.setPosition(new Point(oldPosition.x, oldPosition.y));
}
import org.eclipse.draw2d.geometry.Point;
import org.eclipse.draw2d.geometry.Rectangle;
-import org.eclipse.gef.commands.Command;
import org.tizen.webuibuilder.model.Part;
+import org.tizen.webuibuilder.model.page.PageData;
-public class DesignerResizeAndMoveLayoutCommand extends Command {
+public class DesignerResizeAndMoveLayoutCommand extends ChangeCssSelectorCommand {
- private Part model;
private Rectangle delta;
private Rectangle oldLayout;
- public DesignerResizeAndMoveLayoutCommand(Object model, Rectangle delta) {
- this.model = (Part)model;
+ public DesignerResizeAndMoveLayoutCommand(Object model, Rectangle delta, PageData pageData, String selectorName) {
+ super(model, pageData, selectorName);
this.delta = delta;
}
+// @Override
+// public void execute() {
+// Map<String, CssSelector> selectorMap = model.getEditSelectorMap();
+// // create new selector
+// if (selectorMap.get(selectorName) == null) {
+// CssSelector selector = new CssSelector(selectorName);
+// selectorMap.put(selectorName, selector);
+// }
+// if (model.getPositionMode() == Part.PositionMode.ABSOLUTE_POSITION) {
+// oldLayout = new Rectangle(model.getPositionProperty());
+// if (delta.x != 0 || delta.y != 0) {
+// model.setPosition(new Point(oldLayout.x + delta.x, oldLayout.y + delta.y));
+// }
+// if (delta.width != 0 || delta.height != 0) {
+// model.setSize(new Point(oldLayout.width + delta.width, oldLayout.height + delta.height));
+// }
+// } else if (model.getPositionMode() == Part.PositionMode.RELATIVE_POSITION) {
+// oldLayout = new Rectangle(model.getPositionProperty());
+// if (delta.x != 0 || delta.y != 0) {
+// model.setPosition(new Point(oldLayout.x + delta.x, oldLayout.y + delta.y));
+// }
+// if (delta.width != 0 || delta.height != 0) {
+// model.setSize(new Point(oldLayout.width + delta.width, oldLayout.height + delta.height));
+// }
+// }
+// }
+//
+// @Override
+// public void undo() {
+// if (oldLayout != null) {
+// model.setPosition(oldLayout);
+// }
+// }
+
@Override
- public void execute() {
+ public void execute2() {
+ Part model = getModel();
if (model.getPositionMode() == Part.PositionMode.ABSOLUTE_POSITION) {
oldLayout = new Rectangle(model.getPositionProperty());
if (delta.x != 0 || delta.y != 0) {
}
@Override
- public void undo() {
+ public void undo2() {
+ Part model = getModel();
if (oldLayout != null) {
model.setPosition(oldLayout);
}
import org.eclipse.draw2d.geometry.Dimension;
import org.eclipse.draw2d.geometry.Point;
-import org.eclipse.gef.commands.Command;
import org.tizen.webuibuilder.model.Part;
+import org.tizen.webuibuilder.model.page.PageData;
-public class DesignerResizeLayoutCommand extends Command {
+public class DesignerResizeLayoutCommand extends ChangeCssSelectorCommand {
- private Part model;
private Dimension delta;
private Dimension oldSize;
- public DesignerResizeLayoutCommand(Object model, Dimension delta) {
- setModel(model);
+ public DesignerResizeLayoutCommand(Object model, Dimension delta, PageData pageData, String selectorName) {
+ super(model, pageData, selectorName);
setDelta(delta);
}
this.delta = delta;
}
- public void setModel(Object model) {
- this.model = (Part) model;
- }
+// public void setModel(Object model) {
+// this.model = (Part) model;
+// }
+//
+// @Override
+// public void execute() {
+// Map<String, CssSelector> selectorMap = model.getEditSelectorMap();
+// // create new selector
+// if (selectorMap.get(selectorName) == null) {
+// CssSelector selector = new CssSelector(selectorName);
+// selectorMap.put(selectorName, selector);
+// }
+//
+// oldSize = new Dimension(model.getPositionProperty().width, model.getPositionProperty().height);
+// model.setSize(new Point(oldSize.width + delta.width, oldSize.height + delta.height));
+// }
+//
+// @Override
+// public void undo() {
+// if (oldSize != null) {
+// model.setSize(new Point(oldSize.width, oldSize.height));
+// }
+// }
@Override
- public void execute() {
+ public void execute2() {
+ Part model = getModel();
oldSize = new Dimension(model.getPositionProperty().width, model.getPositionProperty().height);
- model.setSize(new Point(oldSize.width + delta.width, oldSize.height + delta.height));
+ model.setSize(new Point(oldSize.width + delta.width, oldSize.height + delta.height));
}
@Override
- public void undo() {
+ public void undo2() {
+ Part model = getModel();
if (oldSize != null) {
model.setSize(new Point(oldSize.width, oldSize.height));
}
*/
public class MoveAbsolutePartAction extends SelectionAction {
+ public static int MOVE_DIST = 6;
+
private int direct = 0;
private int dist = 0;
private void initUi() {
switch (direct) {
case PositionConstants.LEFT:
- if(dist == 10){
+ if(dist == MOVE_DIST){
setId(Messages.ACTION_MOVE_LEFT);
} else if(dist == 1){
setId(Messages.ACTION_MOVE_LEFT_DETAIL);
}
break;
case PositionConstants.RIGHT:
- if(dist == 10){
+ if(dist == MOVE_DIST){
setId(Messages.ACTION_MOVE_RIGHT);
} else if(dist == 1){
setId(Messages.ACTION_MOVE_RIGHT_DETAIL);
}
break;
case PositionConstants.TOP:
- if(dist == 10){
+ if(dist == MOVE_DIST){
setId(Messages.ACTION_MOVE_UP);
} else if(dist == 1){
setId(Messages.ACTION_MOVE_UP_DETAIL);
}
break;
case PositionConstants.BOTTOM:
- if(dist == 10){
+ if(dist == MOVE_DIST){
setId(Messages.ACTION_MOVE_DOWN);
} else if(dist == 1){
setId(Messages.ACTION_MOVE_DOWN_DETAIL);
*/
public class ResizeAbsolutePartAction extends SelectionAction {
+ public static int RESIZE_DIST = 6;
+
private int direct = 0;
private int dist = 0;
private void initUi() {
switch (direct) {
case PositionConstants.LEFT:
- if(dist == 10){
+ if(dist == RESIZE_DIST){
setId(Messages.ACTION_DEC_WIDTH);
} else if(dist == 1){
setId(Messages.ACTION_DEC_WIDTH_DETAIL);
}
break;
case PositionConstants.RIGHT:
- if(dist == 10){
+ if(dist == RESIZE_DIST){
setId(Messages.ACTION_INC_WIDTH);
} else if(dist == 1){
setId(Messages.ACTION_INC_WIDTH_DETAIL);
}
break;
case PositionConstants.TOP:
- if(dist == 10){
+ if(dist == RESIZE_DIST){
setId(Messages.ACTION_DEC_HEIGHT);
} else if(dist == 1){
setId(Messages.ACTION_DEC_HEIGHT_DETAIL);
}
break;
case PositionConstants.BOTTOM:
- if(dist == 10){
+ if(dist == RESIZE_DIST){
setId(Messages.ACTION_INC_HEIGHT);
} else if(dist == 1){
setId(Messages.ACTION_INC_HEIGHT_DETAIL);
package org.tizen.webuibuilder.gef.commands;
-import org.eclipse.gef.commands.Command;
+import org.tizen.webuibuilder.BuilderConstants;
import org.tizen.webuibuilder.model.Part;
import org.tizen.webuibuilder.model.css.CssFile;
import org.tizen.webuibuilder.model.css.CssSelector;
+import org.tizen.webuibuilder.model.page.PageData;
/**
* The command to set css style.
*/
-public class SetCssStyleCommand extends Command {
-
- /**
- * A {@link CssFile}.
- */
- private CssFile cssFile;
-
- /**
- * A {@link Part}.
- */
- private Part part;
-
- /**
- * A {@link CssSelector}.
- */
- private CssSelector selector;
+public class SetCssStyleCommand extends ChangeCssSelectorCommand {
/**
* A css style name.
* @param value
* css style value
*/
- public SetCssStyleCommand(CssFile cssFile, Part part, CssSelector selector, String key,
+ public SetCssStyleCommand(PageData pageData, Part part, String selectorName, String key,
String value) {
- this.cssFile = cssFile;
- this.part = part;
- this.selector = selector;
+ super(part, pageData, selectorName);
this.key = key;
this.value = value;
}
/**
* Checks whether a {@link SetCssStyleCommand} can be executed.
*
- * @return <code>true</code> if a {@link SetCssStyleCommand} can be executed, and
- * <code>false</code> otherwise
+ * @return <code>true</code> if a {@link SetCssStyleCommand} can be
+ * executed, and <code>false</code> otherwise
*/
- @Override
- public boolean canExecute() {
- if (cssFile == null || part == null || selector == null) {
- return false;
- } else {
- if (part.getIdPropertyValue().equals(selector.getPartId())) {
- return true;
- } else {
- return false;
- }
- }
- }
+ // @Override
+ // public boolean canExecute() {
+ // if (cssFile == null || part == null || selector == null) {
+ // return false;
+ // } else {
+ // if (part.getIdPropertyValue().equals(selector.getPartId())) {
+ // return true;
+ // } else {
+ // return false;
+ // }
+ // }
+ // }
+ //
+ // /**
+ // * Executes a {@link SetCssStyleCommand}.
+ // */
+ // @Override
+ // public void execute() {
+ // if (canExecute()) {
+ // if (oldValue == null) {
+ // oldValue = selector.getPropertyValue(key);
+ // }
+ //
+ // if (cssFile.getSelector(selector.getSelectorName()) == null) {
+ // cssFile.addCssSelector(selector);
+ // }
+ // selector.setStyle(key, value);
+ // String selectorName = selector.getSelectorName();
+ //
+ // if (part.getSelector(selectorName) == null) {
+ // part.addSelector(selectorName, selector);
+ // }
+ // part.setSelectorPropertyValue(selectorName, key, value);
+ // }
+ // }
+ //
+ // /**
+ // * Undoes a {@link SetCssStyleCommand}.
+ // */
+ // @Override
+ // public void undo() {
+ // selector.setStyle(key, oldValue);
+ // part.setSelectorPropertyValue(selector.getSelectorName(), key, oldValue);
+ // }
- /**
- * Executes a {@link SetCssStyleCommand}.
- */
@Override
- public void execute() {
- if (canExecute()) {
- if (oldValue == null) {
- oldValue = selector.getPropertyValue(key);
- }
-
- if (cssFile.getSelector(selector.getSelectorName()) == null) {
- cssFile.addCssSelector(selector);
- }
- selector.setStyle(key, value);
- String selectorName = selector.getSelectorName();
-
- if (part.getSelector(selectorName) == null) {
- part.addSelector(selectorName, selector);
- }
- part.setSelectorPropertyValue(selectorName, key, value);
+ public void execute2() {
+ Part part = getModel();
+ String selectorName = getSelectorName();
+ CssSelector selector = part.getSelector(selectorName);
+ if (selector != null) {
+ oldValue = selector.getPropertyValue(key);
+ }
+
+ if (oldValue == null) {
+ oldValue = BuilderConstants.EMPTY;
}
+ part.setSelectorPropertyValue(selectorName, key, value);
}
- /**
- * Undoes a {@link SetCssStyleCommand}.
- */
@Override
- public void undo() {
- selector.setStyle(key, oldValue);
- part.setSelectorPropertyValue(selector.getSelectorName(), key, oldValue);
+ public void undo2() {
+ Part part = getModel();
+ part.setSelectorPropertyValue(getSelectorName(), key, oldValue);
}
}
package org.tizen.webuibuilder.gef.editparts;
import java.util.ArrayList;
+import java.util.Iterator;
import java.util.List;
+import java.util.Map;
import org.eclipse.gef.CompoundSnapToHelper;
import org.eclipse.gef.DragTracker;
import org.tizen.webuibuilder.gef.tools.DesignDragAbsoluteEditPartsTracker;
import org.tizen.webuibuilder.gef.tools.DesignDragEditPartsTracker;
import org.tizen.webuibuilder.gef.viewer.DesignerBrowserViewer;
+import org.tizen.webuibuilder.gef.viewer.HoverBrowserViewer;
import org.tizen.webuibuilder.model.Part;
import org.tizen.webuibuilder.model.css.CssEvent;
+import org.tizen.webuibuilder.model.css.CssFile;
+import org.tizen.webuibuilder.model.css.CssSelector;
+import org.tizen.webuibuilder.model.css.CssStyle;
+import org.tizen.webuibuilder.model.page.PageData;
public class DesignerEditPart extends HoverViewerEditPart {
@Override
public void cssPropertyChanged(CssEvent event) {
- if (event.getPropertyKey().equals("position")) {
+ String selectorName = event.getSelectorName();
+ String key = event.getPropertyKey();
+ String value = event.getPropertyValue();
+
+ if (key.equals("position")) {
if (((Part) getModel()).getPositionMode() == Part.PositionMode.ABSOLUTE_POSITION) {
installEditPolicy(EditPolicy.PRIMARY_DRAG_ROLE,
new DesignerAbsoluteDragEditPolicy());
}
refreshVisuals();
}
+
+ //delete style
+ if (selectorName != null && key != null && value != null && value.isEmpty()) {
+ Part model = (Part) getModel();
+ Map<String, CssSelector> allMap = model.getAllSelectorMap();
+ CssSelector selector = allMap.get(selectorName);
+ selector.setStyle(key, value);
+
+ PageData pageData = ((HoverBrowserViewer) getViewer()).getPageData();
+ List<CssFile> appliedCssFileList = pageData.getAppliedCssFiles();
+
+ for (CssFile cssFile : appliedCssFileList) {
+ CssSelector tempSelector = cssFile.getSelector(selectorName);
+ if (tempSelector != null) {
+ CssStyle style = tempSelector.getCssStyle(key);
+ if (style != null) {
+ selector.setStyle(style, false);
+ }
+ }
+ }
+ }
super.cssPropertyChanged(event);
}
figure.setBinded(false);
}
}
+
+ @Override
+ public void needRefresh(CssEvent event) {
+ // called needRefresh(e) in HoverVrowserViewer()
+ String selectorName = event.getSelectorName();
+ if (selectorName != null) {
+ PageData pageData = ((HoverBrowserViewer) getViewer()).getPageData();
+ Part model = (Part) getModel();
+ CssSelector selector = model.getSelector(selectorName);
+ List<CssFile> appliedCssFileList = pageData.getAppliedCssFiles();
+ int index = appliedCssFileList.indexOf(pageData.getCurrentCssFile());
+ int size = appliedCssFileList.size();
+ Map<String, CssSelector> allMap = model.getAllSelectorMap();
+ CssSelector cloneSelector = selector.cloneCssSelector(selectorName);
+
+ for (int i = index + 1; i < size; i++) {
+ CssFile cssFile = appliedCssFileList.get(i);
+ CssSelector skipSelector = cssFile.getSelector(selectorName);
+ if (skipSelector == null) {
+ continue;
+ }
+ Map<String, CssStyle> skipStyleMap = skipSelector.getStyleMap();
+
+ for (Iterator<CssStyle> iter = cloneSelector.getStyles().iterator(); iter.hasNext();) {
+ CssStyle style = iter.next();
+ String key = style.getKey();
+ if (skipStyleMap.get(key) != null) {
+ iter.remove();
+ }
+ }
+ }
+ CssSelector cssSelector = allMap.get(selectorName);
+ if (cssSelector == null) {
+ allMap.put(selectorName, cloneSelector);
+ } else {
+ for (CssStyle style : cloneSelector.getStyles()) {
+ cssSelector.setStyle(style);
+ }
+ }
+ }
+ super.needRefresh(event);
+ }
}
\ No newline at end of file
import org.eclipse.gef.SnapToHelper;
import org.eclipse.gef.editparts.AbstractGraphicalEditPart;
import org.eclipse.gef.rulers.RulerProvider;
-import org.tizen.webuibuilder.BuilderConstants;
import org.tizen.webuibuilder.animator.model.part.AnimatorWidgetPart;
import org.tizen.webuibuilder.bridge.DesignerGoingBridge.WidgetPosition;
import org.tizen.webuibuilder.gef.figure.PageFigure;
import org.tizen.webuibuilder.gef.figure.PartFigure;
import org.tizen.webuibuilder.gef.figure.WidgetFigure;
+import org.tizen.webuibuilder.gef.policies.DesignerAbsoluteDragEditPolicy;
+import org.tizen.webuibuilder.gef.policies.DesignerDragEditPolicy;
import org.tizen.webuibuilder.gef.policies.HoverViewerXYLayoutEditPolicy;
import org.tizen.webuibuilder.gef.tools.HoverViewerDragEditPartsTracker;
import org.tizen.webuibuilder.gef.viewer.HoverBrowserViewer;
WidgetPosition position = model.getWidgetPosition();
if (position != null) {
// figure.setLayout(model.getWidgetPosition());
- figure.setLayout(new Rectangle(position.x, position.y, position.width,
- position.height));
+ figure.setLayout(new Rectangle(position.x, position.y, position.width, position.height));
if (model.getPolygonPoints() != null) {
figure.setLayout(model.getPolygonPoints());
}
@Override
public void cssPropertyChanged(CssEvent event) {
- // called cssPropertyChanged(e) in HoverBrowserViewer()
- String key = event.getPropertyKey();
- if (key.equals(BuilderConstants.ATTRIBUTE_VALUE_WIDTH) || key.equals(BuilderConstants.ATTRIBUTE_VALUE_HEIGHT)) {
- ((HoverBrowserViewer) getViewer()).updateModel();
- }
}
@Override
public void needRefresh(CssEvent event) {
// called needRefresh(e) in HoverVrowserViewer()
((HoverBrowserViewer) getViewer()).updateStyle();
+
+ String key = event.getPropertyKey();
+ if (key != null && key.equals("position")) {
+ // FIXME : call setPositionMode() function
+ if (((Part) getModel()).getPositionMode() == Part.PositionMode.ABSOLUTE_POSITION) {
+ installEditPolicy(EditPolicy.PRIMARY_DRAG_ROLE,
+ new DesignerAbsoluteDragEditPolicy());
+ }
+ if (((Part) getModel()).getPositionMode() == Part.PositionMode.RELATIVE_POSITION) {
+ installEditPolicy(EditPolicy.PRIMARY_DRAG_ROLE, new DesignerDragEditPolicy());
+ }
+ refreshVisuals();
+ }
}
@SuppressWarnings("rawtypes")
import org.eclipse.gef.requests.AlignmentRequest;
import org.eclipse.gef.requests.ChangeBoundsRequest;
import org.eclipse.swt.graphics.Color;
-import org.tizen.webuibuilder.gef.commands.DesignerChangeLayoutCommand;
import org.tizen.webuibuilder.gef.commands.DesignerMoveLayoutCommand;
import org.tizen.webuibuilder.gef.commands.DesignerResizeAndMoveLayoutCommand;
import org.tizen.webuibuilder.gef.commands.DesignerResizeLayoutCommand;
import org.tizen.webuibuilder.gef.editparts.DesignerRootEditPart;
import org.tizen.webuibuilder.gef.editparts.HoverViewerEditPart;
import org.tizen.webuibuilder.gef.figure.SelectionBorder;
+import org.tizen.webuibuilder.gef.viewer.HoverBrowserViewer;
import org.tizen.webuibuilder.model.Part;
+import org.tizen.webuibuilder.model.page.PageData;
public class DesignerAbsoluteDragEditPolicy extends ResizableEditPolicy {
@Override
public Command getCommand(Request request) {
+ HoverBrowserViewer viewer = (HoverBrowserViewer) getHost().getViewer();
+ PageData pageData = viewer.getPageData();
+ Part part = (Part) getHost().getModel();
+ String selectorName = part.getDefaultSelectorName();
+
if (REQ_RESIZE.equals(request.getType())) {
Dimension sizeDelta = ((ChangeBoundsRequest) request).getSizeDelta();
sizeDelta.width /=
if((direct & PositionConstants.NORTH) != 0){
layoutDelta.y -= sizeDelta.height;
}
+
+
if(layoutDelta.x != 0 || layoutDelta.y != 0){
layoutDelta.width = sizeDelta.width;
layoutDelta.height = sizeDelta.height;
- return new DesignerResizeAndMoveLayoutCommand(getHost().getModel(), layoutDelta);
+ return new DesignerResizeAndMoveLayoutCommand(part, layoutDelta, pageData, selectorName);
} else {
- return new DesignerResizeLayoutCommand(getHost().getModel(), sizeDelta);
+ return new DesignerResizeLayoutCommand(part, sizeDelta, pageData, selectorName);
}
// return new DesignerChangeLayoutCommand(getHost().getModel(),
// ((ChangeBoundsRequest) request)
// .getTransformedRectangle(rect));
}
if (REQ_MOVE.equals(request.getType())) {
+
+
Point moveDelta = ((ChangeBoundsRequest) request).getMoveDelta();
moveDelta.x /= ((DesignerRootEditPart) getHost().getRoot()).getZoomManager().getZoom();
moveDelta.y /= ((DesignerRootEditPart) getHost().getRoot()).getZoomManager().getZoom();
// return new DesignerChangeLayoutCommand(getHost().getModel(),
// ((ChangeBoundsRequest) request)
// .getTransformedRectangle(rect), 0);
- return new DesignerMoveLayoutCommand(getHost().getModel(), moveDelta);
+// CssFile cssFile = viewer.getPageData().getCurrentCssFile();
+
+ return new DesignerMoveLayoutCommand(part, moveDelta, pageData, selectorName);
}
if (REQ_ALIGN.equals(request.getType())) {
return getAlignCommand((AlignmentRequest) request);
import org.tizen.webuibuilder.gef.editparts.DesignerRootEditPart;
import org.tizen.webuibuilder.gef.editparts.HoverViewerEditPart;
import org.tizen.webuibuilder.gef.figure.SelectionBorder;
+import org.tizen.webuibuilder.gef.viewer.HoverBrowserViewer;
import org.tizen.webuibuilder.model.Part;
import org.tizen.webuibuilder.model.PartProperty;
import org.tizen.webuibuilder.model.descriptors.ConstantDescriptor;
+import org.tizen.webuibuilder.model.page.PageData;
import org.tizen.webuibuilder.request.MoveRequest;
// return new DesignerChangeLayoutCommand(getHost().getModel(),
// ((ChangeBoundsRequest) request)
// .getTransformedRectangle(rect));
- return new DesignerResizeLayoutCommand(getHost().getModel(), sizeDelta);
+
+ HoverBrowserViewer viewer = (HoverBrowserViewer) getHost().getViewer();
+ PageData pageData = viewer.getPageData();
+ Part part = (Part) getHost().getModel();
+ String selectorName = part.getDefaultSelectorName();
+ return new DesignerResizeLayoutCommand(getHost().getModel(), sizeDelta, pageData, selectorName);
}
if (REQ_MOVE.equals(request.getType())) {
if (request instanceof MoveRequest) {
final String value = list.get(i).getValue();
final String displayName = list.get(i).getDisplayName();
if ((displayName != null) && (!displayName.isEmpty())) {
- item.setText(displayName);
+ item.setText(value + "[" + displayName + "]");
} else {
item.setText(value);
}
item.addListener(SWT.Selection, new Listener() {
public void handleEvent(Event e) {
String str = targetPart.getProperty(BuilderConstants.ATTRIBUTE_DATA_BIND).getValue();
- final String info = makeInfoString(targetPart, property2, displayName, value, str);
+ final String info = DataBindingTooltipParser.makeInfoString(targetPart, property2.getValue(), displayName, value, str);
command =
new SetPartPropertyCommand(targetPart, BuilderConstants.ATTRIBUTE_DATA_BIND,
info);
return command;
}
-
- private String makeInfoString(Part targetPart, PartProperty property2, String displayName, String value, String str) {
- String string = "";
-
- if ((str != null) && (!str.isEmpty())) {
- Map<String, String> bindingInfos = DataBindingTooltipParser.parseToMap(str);
-
- if (bindingInfos.containsKey(value)) {
- bindingInfos.remove(value);
- } else if (bindingInfos.containsKey("attr-"+displayName)) {
- bindingInfos.remove("attr-"+displayName);
- }
-
- if ((displayName != null) && (!displayName.isEmpty())) {
- bindingInfos.put("attr-"+displayName, property2.getValue());
- } else {
- bindingInfos.put(value, property2.getValue());
- }
-
- string = DataBindingTooltipParser.makeStringFromMap(bindingInfos);
- } else {
- if ((displayName != null) && (!displayName.isEmpty())) {
- string = value + ": { " + displayName + ": " + property2.getValue() + " }";
- } else {
- if (targetPart.getDescriptorId().equals("tizen.listitem")) {
- string = value + ": " + property2.getValue() + BuilderConstants.DATABINDING_ARRAYITEM_VALUE_SUFFIX;
- } else {
- string = value + ": " + property2.getValue();
- }
- }
- }
-
- return string;
- }
-
private boolean hasProperty(EditPart editPart, String name) {
if (editPart == null) {
return false;
@Override
public void keyReleased(KeyEvent e) {
- designEditPartViewer.getEditDomain().keyDown(e, designEditPartViewer);
+ //designEditPartViewer.getEditDomain().keyDown(e, designEditPartViewer);
}
@Override
import org.eclipse.swt.widgets.Control;
import org.eclipse.swt.widgets.ToolTip;
import org.eclipse.ui.IEditorInput;
+import org.tizen.webuibuilder.BuilderConstants;
import org.tizen.webuibuilder.bridge.DesignerGoingBridge;
import org.tizen.webuibuilder.bridge.DesignerGoingBridge.WidgetPosition;
import org.tizen.webuibuilder.browserwidget.ImageBufferedBrowserWidget.ContentsAreaChangedListener;
private ImageBufferedBrowserProvider createBrowser(Composite parent) {
ImageBufferedBrowserProvider webBrowser =
new ImageBufferedBrowserProvider(parent.getDisplay(), this);
+ goingBridge = new DesignerGoingBridge(webBrowser.getBrowser());
+
zoomScale = 1.0f;
webBrowser.getBrowser().addProgressListener(new ProgressListener() {
@Override
}
});
- goingBridge = new DesignerGoingBridge(webBrowser.getBrowser());
+ //goingBridge = new DesignerGoingBridge(webBrowser.getBrowser());
setBasePath();
resizeBrowser();
updateModel();
private void setCssStyle(String cssStyle) {
// Logger.trace("setCssStyle : " + cssStyle.substring(0, 40));
+ goingBridge.modifyStyle(BuilderConstants.EMPTY);
goingBridge.setCssStyle(cssStyle);
}
/**
* A Map containing css selector.
*/
- private Map<String, CssSelector> selectors = new HashMap<String, CssSelector>();
+ private Map<String, CssSelector> allSelectorMap = new HashMap<String, CssSelector>();
+
+ private Map<String, CssSelector> editSelectorMap = new HashMap<String, CssSelector>();
private AbsolutePositionProvider absolutePositionProvider = null;
private Map<String, GotoPageProperty> gotoPageProperties =
lockRefresh();
//Point newPosition = ScreenToPage(new Point(position.x, position.y));
Point newPosition = new Point(position.x, position.y);
- Part page = getOwnerPage();
- String selectorName = EMPTY;
- if (page == null) {
- selectorName = SHARP + getIdPropertyValue();
- } else {
- selectorName =
- SHARP + page.getIdPropertyValue() + SPACE + SHARP + getIdPropertyValue();
- }
+ String selectorName = getDefaultSelectorName();
// String parentName = TypeDescriptor.ID_OF_GROUP_POSITION;
setSelectorPropertyValue(selectorName, LEFT, String.valueOf(newPosition.x) + PX, null);
return;
}
- selectors.put(selectorName, cssSelector);
+ editSelectorMap.put(selectorName, cssSelector);
fireEvent(new CssEvent(EventType.CSS_SELECTOR_ADDED, this, cssSelector.getSelectorName(),
null, null));
if (cssSelector == null) {
return;
}
+
+ String selectorName = cssSelector.getSelectorName();
+
+ CssSelector prevSelector = allSelectorMap.get(selectorName);
+ if (prevSelector == null) {
+ CssSelector cloneSelector = cssSelector.cloneCssSelector(selectorName);
+ allSelectorMap.put(selectorName, cloneSelector);
+ } else {
+ for (CssStyle style : cssSelector.getStyles()) {
+ prevSelector.getStyleMap().put(style.getKey(), style);
+ }
+ }
+ }
+
+ public void addEditSelectorWhenReadCss(CssSelector cssSelector) {
+ if (cssSelector == null) {
+ return;
+ }
- selectors.put(cssSelector.getSelectorName(), cssSelector);
+ editSelectorMap.put(cssSelector.getSelectorName(), cssSelector);
}
/**
* @return Collection containing css selector
*/
public Collection<CssSelector> getSelectors() {
- return selectors.values();
+ return allSelectorMap.values();
+ }
+
+ public Map<String, CssSelector> getAllSelectorMap() {
+ return allSelectorMap;
}
/**
* @return List containing css selector name
*/
public List<String> getSelectorNameList() {
- return new ArrayList<String>(selectors.keySet());
+ return new ArrayList<String>(editSelectorMap.keySet());
}
/**
* otherwise
*/
public CssSelector getSelector(String selectorName) {
- return selectors.get(selectorName);
+ return editSelectorMap.get(selectorName);
}
/**
* exist, and <code>null</code> otherwise
*/
public String getSelectorPropertyValue(String selectorName, String propertyKey) {
- CssSelector selector = selectors.get(selectorName);
+ CssSelector selector = allSelectorMap.get(selectorName);
if (selector != null) {
return selector.getPropertyValue(propertyKey);
} else {
}
public void clearAllSelector() {
- if (selectors.size() > 0) {
- selectors.clear();
+ if (allSelectorMap.size() > 0) {
+ allSelectorMap.clear();
+ }
+ if (editSelectorMap.size() > 0) {
+ editSelectorMap.clear();
}
if (getChildren().size() > 0) {
for (Part child : getChildren()) {
}
CssSelector cssSelector = getSelector(selectorName);
- selectors.remove(selectorName);
+ editSelectorMap.remove(selectorName);
+ allSelectorMap.remove(selectorName);
fireEvent(new CssEvent(EventType.CSS_SELECTOR_REMOVED, this, cssSelector.getSelectorName(),
null, null));
} else if (isFireEvent) {
removeSelector(selectorName);
} else {
- selectors.remove(selectorName);
+ editSelectorMap.remove(selectorName);
+ allSelectorMap.remove(selectorName);
}
}
*/
public void setSelectorNameAndPartId(String selectorName, String newSelectorName,
String newPartId) {
- CssSelector cssSelector = selectors.get(selectorName);
+ CssSelector cssSelector = editSelectorMap.get(selectorName);
if (cssSelector != null) {
cssSelector.setSelectorName(newSelectorName);
cssSelector.setPartId(newPartId);
return;
}
- CssSelector selector = selectors.get(selectorName);
+// CssSelector selector = selectors.get(selectorName);
+ CssSelector selector = editSelectorMap.get(selectorName);
if (selector == null) {
return;
}
public void deserialize(String text) {
// TODO : Implementation
}
+
+ public Map<String, CssSelector> getEditSelectorMap() {
+ return editSelectorMap;
+ }
}
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.utility.DomUtil;
import org.w3c.dom.Document;
import org.w3c.dom.Element;
import org.w3c.dom.Node;
new ByteArrayInputStream(newHtml.getBytes())) : null;
}
+ @Override
+ public void addPage(PageData page, boolean isExistsPagePart) {
+ String path = null;
+ if (page.getPagePath() != null) {
+ path =
+ getProjectManager().getProject().getFile(page.getPagePath())
+ .getProjectRelativePath().toString();
+ } else {
+ path = pageFileName.substring(0,
+ pageFileName.lastIndexOf("/", pageFileName.length()-1));
+ }
+
+ pageDataSet.addPage(page, path, isExistsPagePart);
+
+ if(isExistsPagePart) {
+ DomUtil.appendPageNode(document, DomUtil.BODY_ELEMENT, page.getPagePart().getElement());
+ }
+ }
+
+ @Override
+ public void addPage(int index, PageData page, boolean isExistsPagePart) {
+ String path = null;
+ if (page.getPagePath() != null) {
+ path =
+ getProjectManager().getProject().getFile(page.getPagePath())
+ .getProjectRelativePath().toString();
+ } else {
+ path = pageFileName.substring(0,
+ pageFileName.lastIndexOf('/', pageFileName.length()-1));
+ }
+
+ if(isExistsPagePart) {
+ PageData refPageData = getPageByIndex(index);
+ DomUtil.insertBeforePageNode(document, DomUtil.BODY_ELEMENT, page.getPagePart().getElement(),
+ (refPageData != null) ? refPageData.getPagePart().getElement() : null);
+ }
+ pageDataSet.addPage(index, page, path, isExistsPagePart);
+ }
+
public void addPage(String html, String pageName) {
if (html == null || pageName == null) {
return;
@Override
public void removePage(int index) {
-
- }
-
- /*
- * (non-Javadoc)
- *
- * @see
- * org.tizen.webuibuilder.model.app.AppManager#removePage(org.tizen.webuibuilder
- * .model.page.PageData)
- */
- @Override
- public void removePage(PageData page) {
- int index = getPageIndex(page);
-
- pageDataSet.removePageWithPart(page);
+
+ DomUtil.removePageNode(document, DomUtil.BODY_ELEMENT, getPageData(index).getPagePart().getElement());
+
+ pageDataSet.removePageWithPart(index);
if (index == startupPage) {
if (getPages().size() > 0) {
setStartupPage(-1);
}
}
- }
+ }
private void addPageDocument(PageFileData pageFileData) {
if (pageFileData == null) {
fireEvent(new NewCssEvent(EventType.CSS_STYLE_CHANGED, null, this, style.getKey(),
style.getValue()));
}
+
+ public Map<String, CssStyle> getStyleMap() {
+ return styles;
+ }
/**
* Sets a {@link CssStyle}. If not exist style in this {@link CssSelector},
addTypeDescriptor(new TypeDescriptor(TypeDescriptor.ID_OF_DATABINDING_TEXT));
addTypeDescriptor(new TypeDescriptor(TypeDescriptor.ID_OF_DATABINDING_VALUE));
addTypeDescriptor(new TypeDescriptor(TypeDescriptor.ID_OF_DATABINDING_FOREACH));
+ addTypeDescriptor(new TypeDescriptor(TypeDescriptor.ID_OF_DATABINDING_SLIDER));
addTypeDescriptor(new TypeDescriptor(TypeDescriptor.ID_OF_DATABINDING_TEXT_CHECK));
addTypeDescriptor(new TypeDescriptor(TypeDescriptor.ID_OF_DATABINDING_FOREACH_TEXT));
addTypeDescriptor(new TypeDescriptor(TypeDescriptor.ID_OF_DATABINDING_VALUE_TEXT));
- addTypeDescriptor(new TypeDescriptor(TypeDescriptor.ID_OF_DATABINDING_ATTR));
+ addTypeDescriptor(new TypeDescriptor(TypeDescriptor.ID_OF_DATABINDING_ATTR_SRC));
addTypeDescriptor(new TypeDescriptor(TypeDescriptor.ID_OF_DATABINDING_ATTR_TEXT));
+ addTypeDescriptor(new TypeDescriptor(TypeDescriptor.ID_OF_DATABINDING_ATTR_HREF));
addTypeDescriptor(new TypeDescriptor(TypeDescriptor.ID_OF_OPACITY));
addTypeDescriptor(new TypeDescriptor(TypeDescriptor.ID_OF_ICON));
addTypeDescriptor(new TypeDescriptor(TypeDescriptor.ID_OF_GROUP_TRANSFORM));
* A property type.
*/
public enum Types {
- UNKNOWN, STRING, BOOLEAN, INTEGER, URL, IMAGE, COLOR, COLOR2, DATE, TIME, AUDIO, VIDEO, HTMLSTRING, GROUP, GROUP_TEXT, GROUP_POSITION, CSS_COLOR, CSS_FONT_SIZE, CSS_FONT_STYLE, CSS_FONT_WEIGHT, CSS_TEXT_ALIGN, CSS_TEXT_DECORATION, SIZE_INTEGER, SIZE_PERCENT, SIZE_REAL, SIZE, SIZE_PIXEL, SIZE_ANGLE, ENUM, OPACITY, ICON, ICON_TEXT_ALIGN, ICON_FONT_WEIGHT, ICON_FONT_STYLE, ICON_TEXT_DECORATION, ICON_TEXT_TRANSFORM, TEXT_LETTER_SPACING, TEXT_LINE_HEIGHT, GROUP_TRANSFORM, GROUP_BORDER, SEPARATOR, EMPTY, CHECK, NEW_COLOR, COLOR_FILL, SCALE, SCALE_PIXEL, SCALE_PERCENT, SCALE_ANGLE, LISTITEM_CLASS, GROUP_FILTER, GROUP_VALUE, METRICS, CUSTOM_CSS, CLIP, GROUP_ICON, DATABINDING_TEXT, DATABINDING_VALUE, DATABINDING_FOREACH, DATABINDING_TEXT_CHECK, DATABINDING_FOREACH_TEXT, DATABINDING_VALUE_TEXT, DATABINDING_ATTR, DATABINDING_ATTR_TEXT
+ UNKNOWN, STRING, BOOLEAN, INTEGER, URL, IMAGE, COLOR, COLOR2, DATE, TIME, AUDIO, VIDEO, HTMLSTRING, GROUP, GROUP_TEXT, GROUP_POSITION, CSS_COLOR, CSS_FONT_SIZE, CSS_FONT_STYLE, CSS_FONT_WEIGHT, CSS_TEXT_ALIGN, CSS_TEXT_DECORATION, SIZE_INTEGER, SIZE_PERCENT, SIZE_REAL, SIZE, SIZE_PIXEL, SIZE_ANGLE, ENUM, OPACITY, ICON, ICON_TEXT_ALIGN, ICON_FONT_WEIGHT, ICON_FONT_STYLE, ICON_TEXT_DECORATION, ICON_TEXT_TRANSFORM, TEXT_LETTER_SPACING, TEXT_LINE_HEIGHT, GROUP_TRANSFORM, GROUP_BORDER, SEPARATOR, EMPTY, CHECK, NEW_COLOR, COLOR_FILL, SCALE, SCALE_PIXEL, SCALE_PERCENT, SCALE_ANGLE, LISTITEM_CLASS, GROUP_FILTER, GROUP_VALUE, METRICS, CUSTOM_CSS, CLIP, GROUP_ICON, DATABINDING_TEXT, DATABINDING_VALUE, DATABINDING_FOREACH, DATABINDING_SLIDER, DATABINDING_TEXT_CHECK, DATABINDING_FOREACH_TEXT, DATABINDING_VALUE_TEXT, DATABINDING_ATTR_SRC, DATABINDING_ATTR_TEXT, DATABINDING_ATTR_HREF
}
// Id of type
public static final String ID_OF_DATABINDING_TEXT = "text@databinding"; //$NON-NLS-1$
public static final String ID_OF_DATABINDING_VALUE = "value@databinding"; //$NON-NLS-1$
public static final String ID_OF_DATABINDING_FOREACH = "foreach@databinding"; //$NON-NLS-1$
+ public static final String ID_OF_DATABINDING_SLIDER = "slider@databinding"; //$NON-NLS-1$
public static final String ID_OF_DATABINDING_TEXT_CHECK = "textchecked@databinding"; //$NON-NLS-1$
public static final String ID_OF_DATABINDING_FOREACH_TEXT = "foreachtext@databinding"; //$NON-NLS-1$
public static final String ID_OF_DATABINDING_VALUE_TEXT = "valuetext@databinding"; //$NON-NLS-1$
- public static final String ID_OF_DATABINDING_ATTR = "attr@databinding"; //$NON-NLS-1$
+ public static final String ID_OF_DATABINDING_ATTR_SRC = "attrsrc@databinding"; //$NON-NLS-1$
public static final String ID_OF_DATABINDING_ATTR_TEXT = "attrtext@databinding"; //$NON-NLS-1$
+ public static final String ID_OF_DATABINDING_ATTR_HREF = "attrhref@databinding"; //$NON-NLS-1$
+
/**
* A property type.
} else if (ID_OF_CSS_FONT_SIZE.equals(id)) {
type = Types.CSS_FONT_SIZE;
} else if (ID_OF_DATABINDING_TEXT.equals(id)) {
- type = Types.CSS_FONT_SIZE;
+ type = Types.DATABINDING_TEXT;
} else if (ID_OF_DATABINDING_VALUE.equals(id)) {
- type = Types.CSS_FONT_SIZE;
+ type = Types.DATABINDING_VALUE;
} else if (ID_OF_DATABINDING_FOREACH.equals(id)) {
- type = Types.CSS_FONT_SIZE;
+ type = Types.DATABINDING_FOREACH;
+ } else if (ID_OF_DATABINDING_SLIDER.equals(id)) {
+ type = Types.DATABINDING_SLIDER;
} else if (ID_OF_DATABINDING_TEXT_CHECK.equals(id)) {
- type = Types.CSS_FONT_SIZE;
+ type = Types.DATABINDING_TEXT_CHECK;
} else if (ID_OF_DATABINDING_FOREACH_TEXT.equals(id)) {
- type = Types.CSS_FONT_SIZE;
+ type = Types.DATABINDING_FOREACH_TEXT;
} else if (ID_OF_DATABINDING_VALUE_TEXT.equals(id)) {
- type = Types.CSS_FONT_SIZE;
- } else if (ID_OF_DATABINDING_ATTR.equals(id)) {
- type = Types.CSS_FONT_SIZE;
+ type = Types.DATABINDING_VALUE_TEXT;
+ } else if (ID_OF_DATABINDING_ATTR_SRC.equals(id)) {
+ type = Types.DATABINDING_ATTR_SRC;
} else if (ID_OF_DATABINDING_ATTR_TEXT.equals(id)) {
- type = Types.CSS_FONT_SIZE;
+ type = Types.DATABINDING_ATTR_TEXT;
+ } else if (ID_OF_DATABINDING_ATTR_HREF.equals(id)) {
+ type = Types.DATABINDING_ATTR_HREF;
} else if (ID_OF_GROUP_TRANSFORM.equals(id)) {
type = Types.GROUP_TRANSFORM;
} else if (ID_OF_SEPARATOR.equals(id)) {
import java.util.List;
import org.eclipse.core.resources.IFile;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
import org.tizen.webuibuilder.BuilderConstants;
import org.tizen.webuibuilder.model.app.AppManager;
import org.tizen.webuibuilder.model.nscreen.NScreenModel;
public class NScreenDescriptor {
+ Logger logger = LoggerFactory.getLogger(NScreenDescriptor.class);
+
private AppManager appManger = null;
private List<NScreenModel> list = null;
}
createCommonNscreen();
- //createOrientationNscreen();
- //createPixelRatioNscreen();
+ // createOrientationNscreen();
+ // createPixelRatioNscreen();
createDeviceNscreen();
}
}
public void createDeviceNscreen() {
- addNscreenModel("Wearable 320x320 (1:1)", NScreenType.RESOLUTION, null, 0, 320, 320);
- addNscreenModel("Wearable 360x480 (3:4)", NScreenType.RESOLUTION, null, 0, 360, 480);
- addNscreenModel("Wearable 480x360 (4:3)", NScreenType.RESOLUTION, null, 0, 480, 360);
- addNscreenModel("Mobile 320x480 (2:3)", NScreenType.RESOLUTION, null, 0, 320, 480);
- addNscreenModel("Mobile 480x320 (3:2)", NScreenType.RESOLUTION, null, 0, 480, 320);
- addNscreenModel("Mobile 360x640 (9:16)", NScreenType.RESOLUTION, null, 0, 720, 1280);
- addNscreenModel("Mobile 640x360 (16:9)", NScreenType.RESOLUTION, null, 0, 1280, 720);
- addNscreenModel("Mobile 800x1280 (10:16)", NScreenType.RESOLUTION, null, 0, 800, 1280);
- addNscreenModel("Mobile 1280x800 (16:10)", NScreenType.RESOLUTION, null, 0, 1280, 800);
+ if (BuilderConstants.PROFILE_WEARABLE_2_3.equalsIgnoreCase(appManger.getProjectManager()
+ .getPlatform())) {
+ addNscreenModel("Wearable 320x320 (1:1)", NScreenType.RESOLUTION, null, 0, 320, 320);
+ addNscreenModel("Wearable 360x480 (3:4)", NScreenType.RESOLUTION, null, 0, 360, 480);
+ addNscreenModel("Wearable 480x360 (4:3)", NScreenType.RESOLUTION, null, 0, 480, 360);
+
+ } else if (BuilderConstants.PROFILE_MOBILE_2_3.equalsIgnoreCase(appManger
+ .getProjectManager().getPlatform())) {
+ // addNscreenModel("Mobile 320x480 (2:3)", NScreenType.RESOLUTION, null, 0, 320, 480);
+ // addNscreenModel("Mobile 480x320 (3:2)", NScreenType.RESOLUTION, null, 0, 480, 320);
+
+ addNscreenModel("Mobile 360x640 (9:16)", NScreenType.RESOLUTION, null, 0, 720, 1280);
+ addNscreenModel("Mobile 640x360 (16:9)", NScreenType.RESOLUTION, null, 0, 1280, 720);
+ addNscreenModel("Mobile 800x1280 (10:16)", NScreenType.RESOLUTION, null, 0, 800, 1280);
+ addNscreenModel("Mobile 1280x800 (16:10)", NScreenType.RESOLUTION, null, 0, 1280, 800);
+
+ } else {
+ logger.info("Not support profile :" + appManger.getProjectManager().getPlatform());
+ }
}
public void addNscreenModel(String name, NScreenType type, Orientation orientation,
import org.eclipse.core.resources.IResource;
import org.eclipse.core.resources.ResourcesPlugin;
import org.eclipse.core.runtime.Path;
-import org.eclipse.draw2d.geometry.Rectangle;
import org.eclipse.swt.widgets.Display;
import org.tizen.webuibuilder.BuilderConstants;
import org.tizen.webuibuilder.model.IPartListener;
import org.tizen.webuibuilder.model.page.PageDataEvent.PageDataEventType;
import org.w3c.dom.Attr;
import org.w3c.dom.Element;
-import org.w3c.dom.Node;
import org.w3c.dom.Text;
public class PageData implements IPartListener, ICssListener {
public void setPagePath(String path) {
if (path != null) {
- if (pageDataPaths != null) {
- pageDataPaths.setPagePath(path);
+ if (pageDataPaths == null) {
+ pageDataPaths = new PageDataPaths();
}
+ pageDataPaths.setPagePath(path);
IFile iFile = ResourcesPlugin.getWorkspace().getRoot()
.getFile(new Path(path));
setResource(iFile);
private String animatorManagedJsPath;
private String animatorManagedCssPath;
+
+ public PageDataPaths() {
+
+ }
public PageDataPaths(String pagePath, String jsPath, String managedJsPath, String htmlPath,
String cssPath, String managedCssPath) {
return;
}
- page.setPagePath(path);
- pages.add(index, page);
if (isExistsPagePart) {
- Part docPart = baseRootPart.getChildOfId("tizen.doc");
- if (docPart != null) {
- docPart.addChild(page.getPagePart(), true);
- }
+ PageData refPageData = getPageData(index);
+ baseRootPart.insertChildBefore(page.getPagePart(),
+ (refPageData != null) ? refPageData.getPagePart() : null, false);
+// Part docPart = baseRootPart.getChildOfId("tizen.doc");
+// if (docPart != null) {
+// docPart.addChild(page.getPagePart(), true);
+// }
}
+ page.setPagePath(path);
+ pages.add(index, page);
+
fireEvent(new PageDataSetEvent(PageDataSetEventType.PAGE_ADDED, page,
index, null));
}
}
public PageData getPageByIndex(int index) {
+ if(index < 0 || index >= getPages().size()) {
+ return null;
+ }
return getPages().get(index);
}
return null;
}
-
+
public void removePage(int index) {
PageData page = getPages().get(index);
removePage(index);
}
- public void removePageWithPart(PageData page) {
- int index = getPages().indexOf(page);
- baseRootPart.removeChild(page.getPagePart(), true);
+ public void removePageWithPart(int index) {
+ baseRootPart.removeChild(getPageByIndex(index).getPagePart(), false);
removePage(index);
}
CommandStack commandStack = designEditPartViewer.getEditDomain().getCommandStack();
Command command =
- new CreateCssSelectorCommand(designEditPartViewer.getPageData()
- .getCurrentCssFile(), part, result);
+ new CreateCssSelectorCommand(designEditPartViewer.getPageData(),
+ part, result);
commandStack.execute(command);
}
}
*/
@Override
public boolean run() {
-// if (!(model instanceof AppManagerForHTML)) {
-// return false;
-// }
-// AppManagerForHTML manager = (AppManagerForHTML) model;
-// manager.addPage(template.getDescriptor().getText(), name);
-// PageFileData pageFileData = PageReader.readPage(template.getDescriptor().getText(), manager.getPartFactory());
-// PageData pageData = new PageDataForHTML(BuilderConstants.EMPTY, pageFileData, 0,
-// pageFileData.getDocument(), manager.getDescriptorManager(),
-// null);
-// manager.addPage(pageData, true);
-// manager.addPage(pageFileData);
-// manager.addPage(template.getDescriptor().getText(), name);
-
+ if (!(model instanceof AppManagerForHTML)) {
+ return false;
+ }
+ AppManagerForHTML manager = (AppManagerForHTML) model;
+
return (template != null &&
template.getDescriptor() != null &&
template.getDescriptor().getText() != null &&
- !template.getDescriptor().getText().isEmpty());
+ !template.getDescriptor().getText().isEmpty() &&
+ manager.getPageData(name) == null);
}
}
\ No newline at end of file
public static final String NEW_PAGE = "org.tizen.webuibuilder.newPage"; //$NON-NLS-1$
/**
+ * Delete Page action id. Value: <code>"org.tizen.webuibuilder.deletePage"</code>
+ */
+ public static final String DELETE_PAGE = "org.tizen.webuibuilder.deletePage"; //$NON-NLS-1$
+
+ /**
* Create Template action id. Value: <code>"org.tizen.webuibuilder.createTemplate"</code>
*/
public static final String CREATE_TEMPLATE = "org.tizen.webuibuilder.createTemplate";//$NON-NLS-1$
public static String DELETE_SNIPPET;
public static String RENAME_SNIPPET;
+ public static String DELETE_PAGE;
public static String NEW_PAGE;
public static String CREATE_TEMPLATE;
public static String IMPORT_TEMPLATE;
DELETE_SNIPPET = Delete Snippet
RENAME_SNIPPET = Rename Snippet
+DELETE_PAGE = Delete Page
NEW_PAGE = New Page
CREATE_TEMPLATE = Create Template
IMPORT_TEMPLATE = Import Template
import org.eclipse.swt.SWT;
import org.eclipse.swt.custom.CTabFolder;
import org.eclipse.swt.custom.CTabItem;
+import org.eclipse.swt.events.KeyEvent;
import org.eclipse.swt.events.SelectionAdapter;
import org.eclipse.swt.events.SelectionEvent;
import org.eclipse.swt.layout.GridData;
import org.tizen.webuibuilder.extintrf.DeclarationViewInfoProvider;
import org.tizen.webuibuilder.gef.commands.CopyPartAction;
import org.tizen.webuibuilder.gef.commands.CutPartAction;
+import org.tizen.webuibuilder.gef.commands.DeletePageAction;
import org.tizen.webuibuilder.gef.commands.DeletePartAction;
import org.tizen.webuibuilder.gef.commands.Messages;
import org.tizen.webuibuilder.gef.commands.MoveAbsolutePartAction;
import org.tizen.webuibuilder.model.page.IPageDataListener;
import org.tizen.webuibuilder.model.page.PageData;
import org.tizen.webuibuilder.model.page.PageDataEvent;
-import org.tizen.webuibuilder.model.page.PageDataSet.DataDataValidateType;
import org.tizen.webuibuilder.model.project.ProjectManager;
import org.tizen.webuibuilder.nl.BuilderMessages;
import org.tizen.webuibuilder.outline.OutlinePage;
// private DesignerEditPartFactory factory;
private SelectionSynchronizer synchronizer;
- private PageDesignerToolbar toolbar;
+ protected PageDesignerToolbar toolbar;
private CTabFolder tabs = null;
protected Preview preview = null;
}
}
- NScreenUtil.nscreen_log("current page css : "
- + pageData.getCurrentCssFile().getCssFilePath());
- getViewer().updateStyle();
+ setCurrentCssFileToModel(pageData.getCurrentCssFile());
+
+ if (NScreenUtil.isLogEnabled()) {
+ List<CssFile> applied = pageData.getAppliedCssFiles();
+ int current = applied.indexOf(pageData.getCurrentCssFile());
+ NScreenUtil.nscreen_log("================= CSS Layer (" + applied.size()
+ + ") =====================");
+ CssFile appliedCssFile = null;
+ for (int i = 0; i < applied.size(); i++) {
+ appliedCssFile = applied.get(i);
+ if (i == current) {
+ NScreenUtil.nscreen_log(i + ". <Current> "
+ + new File(appliedCssFile.getCssFilePath()).getName());
+ } else {
+ NScreenUtil.nscreen_log(i + ". "
+ + new File(appliedCssFile.getCssFilePath()).getName());
+ }
+
+ }
+
+ NScreenUtil.nscreen_log("=====================================================");
+ }
+ if (getViewer() != null) {
+ getViewer().updateStyle();
+ }
}
protected void setCssFileToModel(CssFile cssFile) {
- if (getPageData() != null) {
- getPageData().getAppliedCssFiles().clear();
- }
if (rootPart != null && cssFile != null) {
for (CssSelector selector : cssFile.getSelectors()) {
String pageId = selector.getPageId();
}
}
+ pageData.getAppliedCssFiles().add(cssFile);
+ }
+ }
+
+ protected void setCurrentCssFileToModel(CssFile cssFile) {
+ if (rootPart != null && cssFile != null) {
+ for (CssSelector selector : cssFile.getSelectors()) {
+ String pageId = selector.getPageId();
+ Part pagePart = rootPart.getChildOfIdPropertyValue(pageId, true);
+ if (pagePart != null) {
+ String partId = selector.getPartId();
+ Part part = pagePart.getChildOfIdPropertyValue(partId, true);
+ if (part != null) {
+ part.addEditSelectorWhenReadCss(selector);
+ }
+ }
+ }
}
}
protected void clearSelectorsOfRootPart() {
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() {
actionRegistry.registerAction(action);
getSelectionActions().add(action.getId());
- action = new MoveAbsolutePartAction(this, PositionConstants.LEFT, 10);
+ action =
+ new MoveAbsolutePartAction(this, PositionConstants.LEFT,
+ MoveAbsolutePartAction.MOVE_DIST);
actionRegistry.registerAction(action);
getSelectionActions().add(action.getId());
- action = new MoveAbsolutePartAction(this, PositionConstants.RIGHT, 10);
+ action =
+ new MoveAbsolutePartAction(this, PositionConstants.RIGHT,
+ MoveAbsolutePartAction.MOVE_DIST);
actionRegistry.registerAction(action);
getSelectionActions().add(action.getId());
- action = new MoveAbsolutePartAction(this, PositionConstants.TOP, 10);
+ action =
+ new MoveAbsolutePartAction(this, PositionConstants.TOP,
+ MoveAbsolutePartAction.MOVE_DIST);
actionRegistry.registerAction(action);
getSelectionActions().add(action.getId());
- action = new MoveAbsolutePartAction(this, PositionConstants.BOTTOM, 10);
+ action =
+ new MoveAbsolutePartAction(this, PositionConstants.BOTTOM,
+ MoveAbsolutePartAction.MOVE_DIST);
actionRegistry.registerAction(action);
getSelectionActions().add(action.getId());
actionRegistry.registerAction(action);
getSelectionActions().add(action.getId());
- action = new ResizeAbsolutePartAction(this, PositionConstants.LEFT, 10);
+ action =
+ new ResizeAbsolutePartAction(this, PositionConstants.LEFT,
+ ResizeAbsolutePartAction.RESIZE_DIST);
actionRegistry.registerAction(action);
getSelectionActions().add(action.getId());
- action = new ResizeAbsolutePartAction(this, PositionConstants.RIGHT, 10);
+ action =
+ new ResizeAbsolutePartAction(this, PositionConstants.RIGHT,
+ ResizeAbsolutePartAction.RESIZE_DIST);
actionRegistry.registerAction(action);
getSelectionActions().add(action.getId());
- action = new ResizeAbsolutePartAction(this, PositionConstants.TOP, 10);
+ action =
+ new ResizeAbsolutePartAction(this, PositionConstants.TOP,
+ ResizeAbsolutePartAction.RESIZE_DIST);
actionRegistry.registerAction(action);
getSelectionActions().add(action.getId());
- action = new ResizeAbsolutePartAction(this, PositionConstants.BOTTOM, 10);
+ action =
+ new ResizeAbsolutePartAction(this, PositionConstants.BOTTOM,
+ ResizeAbsolutePartAction.RESIZE_DIST);
actionRegistry.registerAction(action);
getSelectionActions().add(action.getId());
actionRegistry.registerAction(action);
getSelectionActions().add(action.getId());
+ action = new DeletePageAction(this);
+ actionRegistry.registerAction(action);
+ getSelectionActions().add(action.getId());
+
action = new NewPageAction(this);
actionRegistry.registerAction(action);
getSelectionActions().add(action.getId());
}
private void configureKeyHandler(GraphicalViewer viewer) {
- KeyHandler keyHandler = new KeyHandler();
+ KeyHandler keyHandler = new KeyHandler() {
+ @Override
+ public boolean keyPressed(KeyEvent event) {
+ return super.keyPressed(event);
+ }
+
+ @Override
+ public boolean keyReleased(KeyEvent event) {
+ return super.keyReleased(event);
+ }
+ };
+
// GraphicalViewerKeyHandler keyHandler = new GraphicalViewerKeyHandler(viewer);
keyHandler.put(KeyStroke.getPressed(SWT.DEL, 127, SWT.NONE),
getActionRegistry().getAction(ActionFactory.DELETE.getId()));
- keyHandler.put(KeyStroke.getPressed((char)26, 122, SWT.CTRL), // Ctrl+z
+ keyHandler.put(KeyStroke.getReleased((char) 26, 122, SWT.CTRL), // Ctrl+z
getActionRegistry().getAction(ActionFactory.UNDO.getId()));
- keyHandler.put(KeyStroke.getPressed((char)25, 121, SWT.CTRL), // Ctrl+y
+ keyHandler.put(KeyStroke.getReleased((char) 25, 121, SWT.CTRL), // Ctrl+y
getActionRegistry().getAction(ActionFactory.REDO.getId()));
keyHandler.put(KeyStroke.getPressed(SWT.ARROW_LEFT, SWT.NONE), getActionRegistry()
.getAction(Messages.ACTION_MOVE_LEFT));
@Override
public void pageChanged(PageDataEvent e) {
- getViewer().updateStyle();
+ if (getViewer() != null) {
+ getViewer().updateStyle();
+ }
}
FilenameFilterEndsWith filter = new FilenameFilterEndsWith(".css");
File[] files = cssDir.listFiles(filter);
if (!appManager.getPageDataSet().getPages().isEmpty()) {
+ pageData = appManager.getPageDataSet().getPages().get(0);
for (PageData page : appManager.getPageDataSet().getPages()) {
String pageId = page.getName();
List<File> pageCssFile = new ArrayList<File>();
setCssFileToModel(applyList.get(i));
}
}
- pageData = appManager.getPageDataSet().getPages().get(0);
+
} else {
rootPart = null;
}
}
}
-
+ toolbar.setScreeSizesFromNScreen();
GraphicalViewer viewer = getGraphicalViewer();
// viewer.setContents(appManager.getRootPart(currentPageIndex));
package org.tizen.webuibuilder.ui.editor;
+import java.util.ArrayList;
import java.util.List;
import org.eclipse.gef.commands.Command;
}
public void setResolution(List<Device> devices) {
+ NScreenUtil.nscreen_log("View port : " + mainEditor.getAppManager().getFrameworkScale());
+
Device device = null;
- NScreenUtil.nscreen_log(mainEditor.getAppManager().getFrameworkScale());
resolution
.setScreeSizesFromNScreen(devices, mainEditor.getAppManager().getFrameworkScale());
screenSize.setEnabled(resolution.getEnable());
- String profile = appManager.getPlatform();
+ String profile = appManager.getPlatform().toLowerCase();
if (profile.contains("mobile")) {
device = devices.get(1);
} else if (profile.contains("wearable")) {
device = devices.get(0);
+ } else {
+ device = devices.get(1);
}
nscreen = new NScreenHistory();
nscreen.setLastResolution(device.getDisplayName());
+ nscreen.setModelName(BuilderConstants.NSCREENCOMMON);
nscreen.setScale(1f);
currentScreen = resolution.getScreenSize(device.getDisplayName());
screenSizeText.setText(currentScreen.getScreenSize());
+ mainEditor.setNscreenIndex2(device, nscreen);
}
public void setResolution(List<Device> devices, NScreenItem nsItem) {
devices.add(defaultWearableDevice);
}
}
- NScreenUtil.nscreen_log(mainEditor.getAppManager().getFrameworkScale());
+ NScreenUtil.nscreen_log("View port : " + mainEditor.getAppManager().getFrameworkScale());
resolution
.setScreeSizesFromNScreen(devices, mainEditor.getAppManager().getFrameworkScale());
screenSize.setEnabled(resolution.getEnable());
public void setCommandStack(CommandStack commandStack) {
this.commandStack = commandStack;
}
+
+ public void setScreeSizesFromNScreen() {
+ NScreenUtil.nscreen_log("start time : " + appManager.getFrameworkScale());
+ List<Device> devices = new ArrayList<Device>();
+ devices.addAll(resolution.getCurrentFeatureDevices());
+ resolution
+ .setScreeSizesFromNScreen(devices, mainEditor.getAppManager().getFrameworkScale());
+ currentScreen = resolution.getScreenSize(nscreen.getLastResolution());
+ mainEditor.setShowingSize(currentScreen.getWidth(), currentScreen.getHeight());
+ }
}
public void removeAll() {
mList.clear();
+ devices.clear();
}
public int size() {
int fixedWidth = -1;
try {
fixedWidth = Integer.parseInt(deviceMode.trim());
- removeAll();
+// removeAll();
for (Device device : devices) {
int width = device.getDeviceWidth();
int height = device.getDeviceHeight();
}
return null;
}
+
+ public List<Device> getCurrentFeatureDevices() {
+ return devices;
+ }
}
});
}
- /**
- * Creates a view model information.
- *
- * @param treeItem
- * @return view model information
- */
- private static String makeViewModelInfo(TreeItem treeItem) {
- String str = "";
- while ((treeItem.getParentItem() != null)) {
- if (str.isEmpty()) {
- str = treeItem.getText();
- } else {
- str = treeItem.getText() + "." + str;
- }
- treeItem = treeItem.getParentItem();
- }
- TreeItemData treeItemData = (TreeItemData) treeItem.getData("TREEITEMDATA");
- str = treeItemData.getOriginModelName() + "." + str;
- return str;
- }
+
/**
* Adds a drag and drop listener to the view model tree.
event.doit = true;
dragSourceItem[0] = selection[0]; // TODO multiselect
TreeItemData treeItemData = (TreeItemData) selection[0].getData("TREEITEMDATA");
- String viewModelInfo;
String dataType = null;
if ((treeItemData != null) && (treeItemData.getObjectType() != null)
dataType = treeItemData.getObjectType();
}
- if ((selection[0].getParentItem() != null)
- && (selection[0].getParentItem().getData("TREEITEMDATA") != null)
- && (((TreeItemData) selection[0].getParentItem()
- .getData("TREEITEMDATA")).getObjectType() != null)
- && (((TreeItemData) selection[0].getParentItem()
- .getData("TREEITEMDATA")).getObjectType().equals("Array"))) {
- viewModelInfo = BuilderConstants.DATABINDING_ARRAYITEM_VALUE_PREFIX + selection[0].getText();
- } else {
- viewModelInfo = makeViewModelInfo(selection[0]);
- }
+ String viewModelInfo = DataBindingTooltipParser.makeViewModelInfo(selection[0]);
+
// FIXME "id"
DataBindingTemplate dataBindingTemplate =
new DataBindingTemplate("id", viewModelInfo, dataType);
dragSourceItem[0].dispose();
}
- DataBindingPage dataBindingPage = getDataBindingPage(dataBindingView);
- if (dataBindingPage != null) {
- dataBindingPage.refresh();
- }
-
dragSourceItem[0] = null;
TemplateTransfer.getInstance().setTemplate(null);
}
} else if ((sourceTreeItemData.getObjectType() != null)
&& (sourceTreeItemData.getObjectType().equals("Object"))) {
treeItemData.setObjectType(sourceTreeItemData.getObjectType());
- }
-
+ }
+
item.setData("TREEITEMDATA", treeItemData);
TreeItem[] treeSubItems = treeItem.getItems();
private List<Part> pageList = new ArrayList<Part>();
private IAction undoHandler;
private IAction redoHandler;
-
+ private Part selectedPart = null;
private boolean showBindInfo = false;
-
+
// private List<String> itemPath;
public DataBindingPage(DataBindingView dataBindingView) {
if (modelValue.startsWith(BuilderConstants.DATABINDING_ARRAYITEM_VALUE_PREFIX)) {
String parentPropertyValue = getParentPropertyValue(part, modelValue);
if (parentPropertyValue != null) {
- addInfoTableItem(part, parentPropertyValue, part.getIdPropertyValue(),
+ addInfoTableItem(part, parentPropertyValue, part.getOwnerPage().getIdPropertyValue() + "." + part.getIdPropertyValue(),
key);
break;
}
} else {
- addInfoTableItem(part, modelValue, part.getIdPropertyValue(), key);
+ addInfoTableItem(part, modelValue, part.getOwnerPage().getIdPropertyValue() + "." + part.getIdPropertyValue(), key);
}
}
}
}
// data.setViewModelCount(i + 1);
viewModelTree.setData("TREEITEMDATA", data);
+
+ treeItem.setImage(ResourceManager.getImage(BuilderConstants.ICON_DIR, BuilderConstants.DATABINDING_STRING_ICON));
}
}
}
}
// data.setViewModelCount(i + 1);
dataSourceTree.setData("TREEITEMDATA", data);
+
+ treeItem.setImage(ResourceManager.getImage(BuilderConstants.ICON_DIR, BuilderConstants.DATABINDING_STRING_ICON));
}
}
}
if ((treeItemData.getObjectType() != null)
&& (treeItemData.getObjectType().equals("Array"))) {
treeItem.setImage(ResourceManager.getImage(BuilderConstants.ICON_DIR, BuilderConstants.DATABINDING_ARRAY_ICON));
+ } else {
+ treeItem.setImage(ResourceManager.getImage(BuilderConstants.ICON_DIR, BuilderConstants.DATABINDING_STRING_ICON));
}
if (dataSource != null) {
public void renameViewModel(TreeItem treeItem, String newName) {
if (treeItem.getParentItem() == null) {
+ if (!checkModelName(newName)) {
+ return;
+ }
BindingData bindingData = pageDesigner.getAppManager().getViewModel(treeItem.getText());
Command command =
new SetViewModelCommand(BindingDataSetEventType.VIEWMODEL_RENAMED,
List<String> itemPath = makeItemPath(treeItem);
BindingData bindingData =
pageDesigner.getAppManager().getViewModel(itemPath.get(itemPath.size() - 1));
+ if (!checkModelItemName(bindingData, itemPath, newName)) {
+ return;
+ }
Command command =
new SetViewModelCommand(BindingDataSetEventType.VIEWMODEL_ITEM_RENAMED,
pageDesigner.getAppManager(), bindingData, itemPath,
}
public void renameDataSource(TreeItem treeItem, String newName) {
- if (treeItem.getParentItem() == null) {
- BindingData bindingData =
- pageDesigner.getAppManager().getDataSource(treeItem.getText());
- Command command =
- new SetDataSourceCommand(BindingDataSetEventType.DATASOURCE_RENAMED,
- pageDesigner.getAppManager(), bindingData, newName, 0);
- getCommandStackFromPageDesigner().execute(command);
+ if (treeItem.getParentItem() != null) {
+ return;
+ }
+
+ if (!checkSourceName(newName)) {
+ return;
+ }
+
+ BindingData bindingData =
+ pageDesigner.getAppManager().getDataSource(treeItem.getText());
+ Command command =
+ new SetDataSourceCommand(BindingDataSetEventType.DATASOURCE_RENAMED,
+ pageDesigner.getAppManager(), bindingData, newName, 0);
+ getCommandStackFromPageDesigner().execute(command);
+ }
+
+ private boolean checkSourceName(String newName) {
+ List<BindingData> dataSources = pageDesigner.getAppManager().getDataSources();
+ if (dataSources == null) {
+ return false;
+ }
+ for (BindingData dataSource : dataSources) {
+ if (dataSource.getSourceName().equals(newName)) {
+ return false;
+ }
+ }
+ return true;
+ }
+
+ private boolean checkModelName(String newName) {
+ List<BindingData> viewModels = pageDesigner.getAppManager().getViewModels();
+ if (viewModels == null) {
+ return false;
+ }
+ for (BindingData viewModel : viewModels) {
+ if (viewModel.getModelName().equals(newName)) {
+ return false;
+ }
+ }
+ return true;
+ }
+
+ private boolean checkModelItemName(BindingData bindingData, List<String> itemPath, String newName) {
+ if ((itemPath == null) || (itemPath.size() < 2)) {
+ return false;
+ }
+
+ List<String> parentItemPath = new ArrayList<String>();
+ List<BindingObject> childObjects = null;
+
+ for (int i=1; i < itemPath.size(); i++) {
+ parentItemPath.add(itemPath.get(i));
+ }
+
+ if (parentItemPath.size() == 1) {
+ childObjects = bindingData.getViewModelObjects();
+ } else {
+ BindingObject bindingObject = pageDesigner.getAppManager().getViewModelObject(bindingData, parentItemPath);
+ if (bindingObject == null) {
+ return false;
+ }
+ childObjects = bindingObject.getItems();
+ }
+
+ if (childObjects == null) {
+ return false;
+ }
+
+ for (BindingObject childObject : childObjects) {
+ if (childObject.getName().equals(newName)) {
+ return false;
+ }
}
+ return true;
+ }
+
+ public void setBindingInfoToPart(Part targetPart, String viewModelInfo, String infoDisplayName,
+ String infoValue) {
+ String str = targetPart.getProperty(BuilderConstants.ATTRIBUTE_DATA_BIND).getValue();
+ final String info = DataBindingTooltipParser.makeInfoString(targetPart, viewModelInfo, infoDisplayName, infoValue, str);
+ getCommandStackFromPageDesigner().execute(new SetPartPropertyCommand(targetPart, BuilderConstants.ATTRIBUTE_DATA_BIND, info));
+
}
/**
private void renameBindingProperties(String newValue, String oldValue) {
TableItem[] tableItems = infoTableViewer.getTable().getItems();
+ List<Part> parts = new ArrayList<Part>();
+
for (TableItem tableItem : tableItems) {
Part part = (Part) tableItem.getData("PART");
if (part != null) {
- String propertyValue =
- part.getProperty(BuilderConstants.ATTRIBUTE_DATA_BIND).getValue();
- if ((propertyValue != null) && (!propertyValue.isEmpty())) {
- Map<String, String> bindingInfos = DataBindingTooltipParser.parseToMap(propertyValue);
- Object[] bindingTypes = bindingInfos.keySet().toArray();
- for (Object bindingType : bindingTypes) {
- String value = bindingInfos.get(bindingType);
- if ((value != null) && (value.startsWith(oldValue))) {
- value = value.replace(oldValue, newValue);
- bindingInfos.remove(bindingType.toString());
- bindingInfos.put(bindingType.toString(), value);
- String bindingInfo = DataBindingTooltipParser.makeStringFromMap(bindingInfos);
- part.setPropertyValue(BuilderConstants.ATTRIBUTE_DATA_BIND, bindingInfo);
- }
+ parts.add(part);
+ }
+ }
+
+ for (Part part : parts) {
+ String propertyValue =
+ part.getProperty(BuilderConstants.ATTRIBUTE_DATA_BIND).getValue();
+ if ((propertyValue != null) && (!propertyValue.isEmpty())) {
+ Map<String, String> bindingInfos = DataBindingTooltipParser.parseToMap(propertyValue);
+ Object[] bindingTypes = bindingInfos.keySet().toArray();
+ for (Object bindingType : bindingTypes) {
+ String value = bindingInfos.get(bindingType);
+ if ((value != null) && (value.startsWith(oldValue))) {
+ value = value.replace(oldValue, newValue);
+ bindingInfos.remove(bindingType.toString());
+ bindingInfos.put(bindingType.toString(), value);
+ String bindingInfo = DataBindingTooltipParser.makeStringFromMap(bindingInfos);
+ part.setPropertyValue(BuilderConstants.ATTRIBUTE_DATA_BIND, bindingInfo);
}
}
}
return projectManager;
}
+
+ /**
+ * Gets a page designer
+ *
+ * @return page designer
+ */
+ public PageDesigner getPageDesigner() {
+ return pageDesigner;
+
+ }
private CommandStack getCommandStackFromPageDesigner() {
// if (dataBindingView.getSite().getPage().getActiveEditor() instanceof PageDesigner) {
getActionRegistryFromPageDesigner().getAction(ActionFactory.REDO.getId());
}
- pageDesigner.getAppManager().getBindingDataSet().addBindingDataListener(this);
-
+ if (pageDesigner != null) {
+ pageDesigner.getAppManager().getBindingDataSet().addBindingDataListener(this);
+
+ //TODO addListener only current page
+ List<PageData> pageData = pageDesigner.getAppManager().getPages();
+ for (int i = 0; i < pageData.size(); i++) {
+ List<Part> childParts = pageData.get(i).getRootPart().getChildren();
+ for (Part childPart : childParts) {
+ if (childPart.getOwnerPage() != null) {
+ if (!pageList.contains(childPart.getOwnerPage())) {
+ pageList.add(childPart.getOwnerPage());
+ addListeners(childPart.getOwnerPage());
+ }
+ }
+ }
+ }
+ }
}
public PageDesigner getInput() {
if (editPart.getModel() instanceof Part) {
Part model = (Part) editPart.getModel();
selModels.add(model);
+ setSelectedPart(model);
}
}
}
}
}
}
+
+ public Part getSelectedPart() {
+ return selectedPart;
+ }
+
+ public void setSelectedPart(Part selectedPart) {
+ this.selectedPart = selectedPart;
+ }
public void updateDataSourceMenus() {
if (removeDataSourceAction != null) {
import java.util.List;
import java.util.Map;
-import javax.activation.CommandInfo;
-
+import org.eclipse.swt.widgets.TreeItem;
+import org.tizen.webuibuilder.BuilderConstants;
+import org.tizen.webuibuilder.model.Part;
import org.tizen.webuibuilder.ui.views.databinding.model.DataBindingTooltipData;
+import org.tizen.webuibuilder.ui.views.databinding.model.TreeItemData;
public class DataBindingTooltipParser {
}
return bindingInfos;
}
-
+
private static void put(Map<String, String> bindingInfos, String string) {
String[] infos = string.split(": ");
- if ((infos[0] != null) && (!infos[0].isEmpty())) {
- if ((infos[1] != null) && (!infos[1].isEmpty())) {
- bindingInfos.put(infos[0], infos[1]);
- }
+ if (infos.length == 2) {
+ if ((infos[0] != null) && (!infos[0].isEmpty())) {
+ if ((infos[1] != null) && (!infos[1].isEmpty())) {
+ bindingInfos.put(infos[0], infos[1]);
+ }
+ }
}
-
}
public static String makeStringFromMap(Map<String, String> bindingInfos) {
return string;
}
+
+ public static String makeInfoString(Part targetPart, String viewModelInfo, String displayName, String value, String str) {
+ String string = "";
+
+ if ((str != null) && (!str.isEmpty())) {
+ Map<String, String> bindingInfos = DataBindingTooltipParser.parseToMap(str);
+
+ if (bindingInfos.containsKey(value)) {
+ bindingInfos.remove(value);
+ } else if (bindingInfos.containsKey("attr-"+displayName)) {
+ bindingInfos.remove("attr-"+displayName);
+ }
+
+ if ((displayName != null) && (!displayName.isEmpty())) {
+ bindingInfos.put("attr-"+displayName, viewModelInfo);
+ } else {
+ bindingInfos.put(value, viewModelInfo);
+ }
+
+ string = DataBindingTooltipParser.makeStringFromMap(bindingInfos);
+ } else {
+ if ((displayName != null) && (!displayName.isEmpty())) {
+ string = value + ": { " + displayName + ": " + viewModelInfo + " }";
+ } else {
+ if (targetPart.getDescriptorId().equals("tizen.listitem")) {
+ string = value + ": " + viewModelInfo + BuilderConstants.DATABINDING_ARRAYITEM_VALUE_SUFFIX;
+ } else {
+ string = value + ": " + viewModelInfo;
+ }
+ }
+ }
+
+ return string;
+ }
+
+ /**
+ * Creates a view model information.
+ *
+ * @param treeItem
+ * @return view model information
+ */
+ public static String makeViewModelInfoString(TreeItem treeItem) {
+ String str = "";
+ while ((treeItem.getParentItem() != null)) {
+ if (str.isEmpty()) {
+ str = treeItem.getText();
+ } else {
+ str = treeItem.getText() + "." + str;
+ }
+ treeItem = treeItem.getParentItem();
+ }
+ TreeItemData treeItemData = (TreeItemData) treeItem.getData("TREEITEMDATA");
+ str = treeItemData.getOriginModelName() + "." + str;
+ return str;
+ }
+
+ public static String makeViewModelInfo(TreeItem treeItem) {
+ String viewModelInfo;
+ if ((treeItem.getParentItem() != null)
+ && (treeItem.getParentItem().getData("TREEITEMDATA") != null)
+ && (((TreeItemData) treeItem.getParentItem()
+ .getData("TREEITEMDATA")).getObjectType() != null)
+ && (((TreeItemData) treeItem.getParentItem()
+ .getData("TREEITEMDATA")).getObjectType().equals("Array"))) {
+ viewModelInfo = BuilderConstants.DATABINDING_ARRAYITEM_VALUE_PREFIX + treeItem.getText();
+ } else {
+ viewModelInfo = DataBindingTooltipParser.makeViewModelInfoString(treeItem);
+ }
+ return viewModelInfo;
+ }
}
import org.eclipse.ui.PlatformUI;
import org.eclipse.ui.dialogs.ElementListSelectionDialog;
import org.eclipse.ui.part.IPage;
-import org.tizen.webuibuilder.model.Part;
-import org.tizen.webuibuilder.model.page.PageData;
-import org.tizen.webuibuilder.model.project.ProjectManager;
+import org.tizen.webuibuilder.ui.editor.PageDesigner;
import org.tizen.webuibuilder.ui.views.databinding.DataBindingPage;
import org.tizen.webuibuilder.ui.views.databinding.DataBindingView;
+import org.tizen.webuibuilder.ui.views.databinding.model.BindingData;
public class GetSourceAction extends SelectionAction {
protected DataBindingView view;
- private ProjectManager projectManager;
- List<String> idList = new ArrayList<String>();
- List<Part> partList = new ArrayList<Part>();
+ private PageDesigner pageDesigner;
/**
* Constructor.
return false;
}
- //return true;
- return false;
+ if (getSelectedTreeItem() == null) {
+ return false;
+ }
+
+ return true;
}
public void refresh() {
setEnabled(calculateEnabled());
}
- // private CommandStack getCommandStackFromPageDesigner() {
- // PageDesigner pageDesigner =
- // (PageDesigner)view.getSite().getPage().getActiveEditor();
- // return (CommandStack) pageDesigner.getAdapter(CommandStack.class);
- // }
-
- private void makeWidgetList() {
- List<Part> subSubPart = null;
- List<Part> part = null;
-
- idList.clear();
- partList.clear();
-
- IPage page = view.getCurrentPage();
- if (!(page instanceof DataBindingPage)) {
- return;
- }
- DataBindingPage dataBindingPage = (DataBindingPage) page;
- projectManager = dataBindingPage.getProjectManager();
- List<PageData> pageData = projectManager.getDefaultAppManager().getPages();
-
- for (int i = 0; i < pageData.size(); i++) {
- part = pageData.get(i).getRootPart().getChildren();
- for (int j = 0; j < part.size(); j++) {
- List<Part> subPart = part.get(j).getChildren();
- for (int k = 0; k < subPart.size(); k++) {
- subSubPart = subPart.get(k).getChildren();
- for (int l = 0; l < subSubPart.size(); l++) {
- idList.add(subSubPart.get(l).getIdPropertyValue());
- partList.add(subSubPart.get(l));
- }
- }
- }
- }
- }
-
private TreeItem getSelectedTreeItem() {
IPage page = view.getCurrentPage();
if (!(page instanceof DataBindingPage)) {
return null;
}
DataBindingPage dataBindingPage = (DataBindingPage) page;
+
Tree tree = dataBindingPage.getViewModelTree();
TreeItem[] treeItem = tree.getSelection();
+
+ if ((treeItem == null) || (treeItem.length < 1)) {
+ return null;
+ }
- if (treeItem[0].getParentItem() == null) {
+ if (treeItem[0].getParentItem() != null) {
return null;
}
return treeItem[0];
}
- /*
- * private Tree getTree() { IPage page = view.getCurrentPage(); if (!(page instanceof
- * DataBindingPage)) { return null; } DataBindingPage dataBindingPage = (DataBindingPage) page;
- * Tree tree = dataBindingPage.getTree();
- *
- * return tree; }
- *
- *
- * //TODO private static String readAll(Reader rd) throws IOException { StringBuilder sb = new
- * StringBuilder(); int cp; while ((cp = rd.read()) != -1) { sb.append((char) cp); } return
- * sb.toString(); }
- *
- *
- * public static JSONObject readJsonFromUrl(String url) throws IOException { InputStream is =
- * null; try { is = new URL(url).openStream(); //BufferedReader rd = new BufferedReader(new
- * InputStreamReader(is, Charset.forName("EUC-KR"))); BufferedReader rd = new BufferedReader(new
- * InputStreamReader(is, "utf-8")); String jsonText = readAll(rd); //JSONObject json = new
- * JSONObject(jsonText); JSONObject json = (JSONObject)JSONValue.parse(jsonText); return json; }
- * finally { is.close(); } }
- */
-
- /*
- * public Object getJSON(String json, String searchWord, Map<String, Object> resultMap) { //Json
- * DATA 전 영역 탐사 및 원하는 데이터를 Map 형태로 리턴시킴 JSONObject jsonObj = null; try { jsonObj = new
- * JSONObject(json); Iterator itr = jsonObj.keys(); int countJSON = 0; while (itr.hasNext()) {
- *
- * String key = (String)itr.next(); Object value = jsonObj.get(key); String selecter =
- * (String)value.toString();
- *
- * if(key.equals(searchWord)){ // 조건에 걸린 word 값을 찾아서 map 형태로 리턴 resultMap.put(key, value); }
- *
- * if(selecter != null && !selecter.equals("") && !selecter.equals("null") && jsonObj.get(key)
- * instanceof JSONArray){ if((JSONArray)jsonObj.get(key) instanceof JSONArray){ JSONArray
- * jsonArray = (JSONArray)jsonObj.get(key); //this.logger.debug(jsonArray.toString()); for(int i
- * = 0 ; i<jsonArray.length() ; i++){ jsonArray.get(i); JSONObject jsonObj2 = new
- * JSONObject(jsonArray.get(i).toString()); getJSON(jsonObj2.toString(), searchWord, resultMap);
- * } } } } } catch (JSONException e) { // TODO Auto-generated catch block e.printStackTrace(); }
- * return resultMap; }
- */
-
- /*
- * private void makeDataModel(JSONObject json, String str, TreeItem parentTreeItem, int index) {
- *
- *
- *
- * if ( (json.get(str) != null) && (
- * json.get(str).getClass().getName().equals("org.json.simple.JSONArray") )) { JSONArray array =
- * (JSONArray)json.get(str); TreeItem treeItem; if (parentTreeItem == null) { treeItem = new
- * TreeItem(getTree(), 0); } else { treeItem = new TreeItem(parentTreeItem, 0); }
- * treeItem.setText(str); treeItem.setData("TYPE", "Array");
- * treeItem.setImage(newItem.setImage( ResourceManager.getImage(BuilderConstants.ICON_DIR,
- * "temp.png"));
- *
- * if (array.get(0).getClass().getName().equals("org.json.simple.JSONObject")) { for (int j=0; j
- * < ((JSONObject)array.get(0)).size(); j++) { Object[] obj =
- * ((JSONObject)array.get(0)).keySet().toArray(); makeDataModel((JSONObject) array.get(0),
- * (String)obj[j], treeItem, 0); } } else {
- *
- * }
- *
- * } else if ( (json.get(str) != null) && (json.get(str).getClass().getName()
- * .equals("org.json.simple.JSONObject"))) { JSONObject jsonTest = (JSONObject)json.get(str);
- * TreeItem treeItem; if (parentTreeItem == null) { treeItem = new TreeItem(getTree(), 0); }
- * else { treeItem = new TreeItem(parentTreeItem, 0); } treeItem.setText(str);
- *
- * if (jsonTest.size() > 0) { for (int j=0; j < jsonTest.size(); j++) { Object[] obj =
- * jsonTest.keySet().toArray(); makeDataModel(jsonTest, (String)obj[j], treeItem, j); //TODO //
- * subTreeItem.setData((String)json.get((String)obj[j])); } } else {
- *
- * //TODO treeItem.setData((String)json.get(str)); } } else { TreeItem treeItem; if
- * (parentTreeItem == null) { treeItem = new TreeItem(getTree(), index); } else { treeItem = new
- * TreeItem(parentTreeItem, index); } treeItem.setText((String)str);
- * treeItem.setData(json.get(str)); } }
- */
-
@Override
public void run() {
-
- makeWidgetList();
-
+ IPage page = view.getCurrentPage();
+ if (!(page instanceof DataBindingPage)) {
+ return;
+ }
+ DataBindingPage dataBindingPage = (DataBindingPage) page;
+ pageDesigner = dataBindingPage.getPageDesigner();
+ if (pageDesigner == null) {
+ return;
+ }
+
+ TreeItem treeItem = getSelectedTreeItem();
+ if (treeItem == null) {
+ return;
+ }
+
+ List<BindingData> sources = pageDesigner.getAppManager().getDataSources();
+ List<String> sourceNames = new ArrayList<String>();
+ for (BindingData source : sources) {
+ sourceNames.add(source.getSourceName());
+ }
ElementListSelectionDialog dialog =
new ElementListSelectionDialog(Display.getCurrent().getActiveShell(),
new LabelProvider());
- dialog.setElements(idList.toArray());
- dialog.setTitle("Which operating system are you using");
- // User pressed cancel
+ dialog.setElements(sourceNames.toArray());
+ dialog.setTitle("");
+
if (dialog.open() != Window.OK) {
return;
}
Object[] result = dialog.getResult();
- for (int i = 0; i < partList.size(); i++) {
- if (partList.get(i).getIdPropertyValue().equals((String) result[0])) {
- // getCommandStackFromPageDesigner().execute(new
- // SetPartPropertyCommand(partList.get(i), "data-bind",
- // "value: MYOBJ.models.model0.temp", false));
- TreeItem treeItem = getSelectedTreeItem();
- if (treeItem == null) {
- return;
- }
- treeItem.setData(partList.get(i).getPropertyValue("text"));
-
- IPage page = view.getCurrentPage();
- if (!(page instanceof DataBindingPage)) {
- return;
- }
- DataBindingPage dataBindingPage = (DataBindingPage) page;
- //dataBindingPage.updateModel();
- }
- }
-
- /*
- * InputDialog dlg = new InputDialog(Display.getCurrent().getActiveShell(), "", "Enter URL",
- * "http://apis.daum.net/search/blog?apikey=DAUM_SEARCH_DEMO_APIKEY&q=love&result=20&pageno=1&output=json"
- * , null);
- *
- * if (dlg.open() == Window.OK) { // User clicked OK; update the label with the input
- *
- * IPage page = view.getCurrentPage(); if (!(page instanceof DataBindingPage)) { return; }
- * DataBindingPage dataBindingPage = (DataBindingPage) page; TreeItem item =
- * dataBindingPage.addTreeItem2(); item.setData("URL", dlg.getValue());
- *
- * try { JSONObject json = readJsonFromUrl(dlg.getValue());
- *
- * Object[] str = json.keySet().toArray(); for (int i=0; i < str.length; i++) {
- * makeDataModel(json, (String)str[i], item, 0); //jsonTest.getClass(); }
- *
- * } catch (IOException e) { // TODO Auto-generated catch block e.printStackTrace(); }
- *
- * dataBindingPage.updateModel(); }
- */
-
+ dataBindingPage.setDataSourceToViewModel(pageDesigner.getAppManager().getDataSource(result[0].toString()), pageDesigner.getAppManager().getViewModel(treeItem.getText()));
}
}
package org.tizen.webuibuilder.ui.views.databinding.actions;
-import java.util.ArrayList;
-import java.util.List;
-
-import org.eclipse.gef.commands.CommandStack;
import org.eclipse.gef.ui.actions.SelectionAction;
-import org.eclipse.jface.viewers.LabelProvider;
-import org.eclipse.jface.window.Window;
import org.eclipse.swt.widgets.Display;
import org.eclipse.swt.widgets.Tree;
import org.eclipse.swt.widgets.TreeItem;
import org.eclipse.ui.ISharedImages;
import org.eclipse.ui.PlatformUI;
-import org.eclipse.ui.dialogs.ElementListSelectionDialog;
import org.eclipse.ui.part.IPage;
-import org.tizen.webuibuilder.BuilderConstants;
-import org.tizen.webuibuilder.gef.commands.SetPartPropertyCommand;
import org.tizen.webuibuilder.model.Part;
-import org.tizen.webuibuilder.model.descriptors.ConstantDescriptor;
-import org.tizen.webuibuilder.model.page.PageData;
-import org.tizen.webuibuilder.model.project.ProjectManager;
-import org.tizen.webuibuilder.ui.editor.PageDesigner;
import org.tizen.webuibuilder.ui.views.databinding.DataBindingPage;
+import org.tizen.webuibuilder.ui.views.databinding.DataBindingTooltipParser;
import org.tizen.webuibuilder.ui.views.databinding.DataBindingView;
+import org.tizen.webuibuilder.ui.views.databinding.dialog.SetTargetPage;
+import org.tizen.webuibuilder.ui.views.databinding.model.BindingInfo;
public class SetTargetAction extends SelectionAction {
protected DataBindingView view;
- private ProjectManager projectManager;
- List<String> idList = new ArrayList<String>();
- List<Part> partList = new ArrayList<Part>();
-
+ private DataBindingPage dataBindingPage;
+
/**
* Constructor.
*
if (view == null) {
return false;
}
+
+ if (getSelectedTreeItem() == null) {
+ return false;
+ }
- //return true;
- return false;
+ return true;
}
public void refresh() {
setEnabled(calculateEnabled());
}
- // FIXME remove? move to databindingPage?
- private CommandStack getCommandStackFromPageDesigner() {
- PageDesigner pageDesigner = (PageDesigner) view.getSite().getPage().getActiveEditor();
- return (CommandStack) pageDesigner.getAdapter(CommandStack.class);
- }
-
- private void makeWidgetList() {
- List<Part> part = null;
-
- idList.clear();
- partList.clear();
-
- IPage page = view.getCurrentPage();
- if (!(page instanceof DataBindingPage)) {
- return;
- }
- DataBindingPage dataBindingPage = (DataBindingPage) page;
- projectManager = dataBindingPage.getProjectManager();
- List<PageData> pageData = projectManager.getDefaultAppManager().getPages();
-
- for (int i = 0; i < pageData.size(); i++) {
- part = pageData.get(i).getRootPart().getChildren();
-
- makeSubWidgetList(part, idList, partList);
- }
- }
-
- private void makeSubWidgetList(List<Part> part, List<String> idList2, List<Part> partList2) {
-
- if (part.size() == 0) {
- return;
- } else {
- for (int j = 0; j < part.size(); j++) {
- idList.add(part.get(j).getIdPropertyValue());
- partList.add(part.get(j));
- List<Part> subPart = part.get(j).getChildren();
- makeSubWidgetList(subPart, idList, partList);
- }
- }
- }
-
- private DataBindingPage getDataBindingPage() {
+ private TreeItem getSelectedTreeItem() {
IPage page = view.getCurrentPage();
if (!(page instanceof DataBindingPage)) {
return null;
}
- return (DataBindingPage) page;
- }
-
- private TreeItem getSelectedTreeItem() {
- DataBindingPage dataBindingPage = getDataBindingPage();
- if (dataBindingPage == null) {
- return null;
- }
+ DataBindingPage dataBindingPage = (DataBindingPage) page;
Tree tree = dataBindingPage.getViewModelTree();
TreeItem[] treeItem = tree.getSelection();
+
+ if ((treeItem == null) || (treeItem.length < 1)) {
+ return null;
+ }
if (treeItem[0].getParentItem() == null) {
return null;
}
- // 0 .. multi select
return treeItem[0];
}
- private void addInfoTableItem(Part part, String modelName, String widgetName,
- String bindingInfoStr) {
-
- DataBindingPage dataBindingPage = getDataBindingPage();
- if (dataBindingPage != null) {
- if (dataBindingPage.checkDuplicatedTableItem(modelName, widgetName, bindingInfoStr)) {
- dataBindingPage.addInfoTableItem(part, modelName, widgetName, bindingInfoStr);
- //dataBindingPage.updateModel();
- }
- }
- }
-
@Override
public void run() {
IPage page = view.getCurrentPage();
if (!(page instanceof DataBindingPage)) {
return;
}
+ dataBindingPage = (DataBindingPage) page;
TreeItem treeItem = getSelectedTreeItem();
if (treeItem == null) {
return;
}
-
- makeWidgetList();
-
- ElementListSelectionDialog dialog =
- new ElementListSelectionDialog(Display.getCurrent().getActiveShell(),
- new LabelProvider());
- dialog.setElements(idList.toArray());
- dialog.setTitle("Which operating system are you using");
- // User pressed cancel
- if (dialog.open() != Window.OK) {
+
+ SetTargetPage dialog = new SetTargetPage(Display.getCurrent().getActiveShell(), dataBindingPage);
+ BindingInfo bindingInfo = dialog.open();
+
+ if (bindingInfo == null) {
return;
}
- Object[] result = dialog.getResult();
-
- for (int i = 0; i < partList.size(); i++) {
-
- // TODO partList.get(i).getPartId()
- if (partList.get(i).getIdPropertyValue().equals(result[0].toString())) {
-
- // treeItem.getText(); //temp
- // treeItem.getParentItem().getText(); //model
-
- String str = makePropertyValue(treeItem);
-
- // FIXME testCode
- List<ConstantDescriptor> enums =
- partList.get(i).getPartDescriptor().getPropertyDescriptor(BuilderConstants.ATTRIBUTE_DATA_BIND)
- .getTypeDescriptor().getAvailableConstant();
- // String defaultBindingType =
- // partList.get(i).getPartDescriptor().getPropertyDescriptor(BuilderConstants.ATTRIBUTE_DATA_BIND).getDefaultValue();
-
- // TODO 0 == defaultvalue
- String defaultBindingType = enums.get(0).getValue();
- String bindingInfoStr;
- if ((partList.get(i).getParent() != null)
- && (partList.get(i).getParent().getPartDescriptor()
- .getPropertyDescriptor(BuilderConstants.ATTRIBUTE_DATA_BIND) != null)
- && (partList.get(i).getParent().getPartDescriptor()
- .getPropertyDescriptor(BuilderConstants.ATTRIBUTE_DATA_BIND).getTypeDescriptor()
- .getAvailableConstant().get(0).getValue().equals("foreach"))) {
- bindingInfoStr = defaultBindingType + ": $data." + treeItem.getText();
- } else {
- bindingInfoStr = defaultBindingType + ": " + str;
- }
-
- //TODO add -> refresh
- addInfoTableItem(partList.get(i), str, result[0].toString(), bindingInfoStr);
- getCommandStackFromPageDesigner()
- .execute(new SetPartPropertyCommand(partList.get(i), BuilderConstants.ATTRIBUTE_DATA_BIND,
- bindingInfoStr, false));
-
- /*
- * //FIXME //move this code if( (treeItem.getData("TYPE") != null) &&
- * (treeItem.getData("TYPE").equals("Array")) ) {
- * getCommandStackFromPageDesigner().execute(new
- * SetPartPropertyCommand(partList.get(i), BuilderConstants.ATTRIBUTE_DATA_BIND,
- * "foreach: MYOBJ.models."+str, false)); } else if(
- * (treeItem.getParentItem().getData("TYPE") != null) && (treeItem
- * .getParentItem().getData("TYPE").equals("Array")) ) {
- * getCommandStackFromPageDesigner().execute(new
- * SetPartPropertyCommand(partList.get(i), BuilderConstants.ATTRIBUTE_DATA_BIND, "text: "+treeItem.getText(),
- * false)); } else { getCommandStackFromPageDesigner().execute(new
- * SetPartPropertyCommand(partList.get(i), BuilderConstants.ATTRIBUTE_DATA_BIND, bindingInfoStr, false)); }
- */
- }
- }
-
- }
-
- private String makePropertyValue(TreeItem treeItem) {
- String str = "";
- while ((treeItem.getParentItem() != null)) {
- if (str == "") {
- str = treeItem.getText();
- } else {
- str = treeItem.getText() + "." + str;
- }
- treeItem = treeItem.getParentItem();
+
+ Part targetPart = bindingInfo.getTargetPart();
+ String infoValue = bindingInfo.getInfoValue();
+ String infoDisplayName = bindingInfo.getInfoDisplayName();
+
+ String viewModelInfo = DataBindingTooltipParser.makeViewModelInfo(treeItem);
+
+ if (targetPart != null) {
+ dataBindingPage.setBindingInfoToPart(targetPart, viewModelInfo, infoDisplayName, infoValue);
}
- str = treeItem.getData("DEFAULTTEXT") + "." + str;
- return str;
}
-
}
--- /dev/null
+package org.tizen.webuibuilder.ui.views.databinding.dialog;
+
+import java.util.List;
+
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.custom.SashForm;
+import org.eclipse.swt.events.MouseAdapter;
+import org.eclipse.swt.events.MouseEvent;
+import org.eclipse.swt.events.SelectionAdapter;
+import org.eclipse.swt.events.SelectionEvent;
+import org.eclipse.swt.graphics.Image;
+import org.eclipse.swt.graphics.Point;
+import org.eclipse.swt.layout.FormAttachment;
+import org.eclipse.swt.layout.FormData;
+import org.eclipse.swt.layout.FormLayout;
+import org.eclipse.swt.widgets.Button;
+import org.eclipse.swt.widgets.Dialog;
+import org.eclipse.swt.widgets.Display;
+import org.eclipse.swt.widgets.Group;
+import org.eclipse.swt.widgets.Shell;
+import org.eclipse.swt.widgets.Tree;
+import org.eclipse.swt.widgets.TreeItem;
+import org.tizen.webuibuilder.BuilderConstants;
+import org.tizen.webuibuilder.model.Part;
+import org.tizen.webuibuilder.model.descriptors.ConstantDescriptor;
+import org.tizen.webuibuilder.model.page.PageData;
+import org.tizen.webuibuilder.ui.views.databinding.DataBindingPage;
+import org.tizen.webuibuilder.ui.views.databinding.model.BindingInfo;
+import org.tizen.webuibuilder.utility.ResourceManager;
+
+public class SetTargetPage extends Dialog {
+
+ private Shell shell;
+ private SashForm sashForm;
+ private DataBindingPage dataBindingPage;
+ private Tree widgetTree;
+ private Tree bindingInfoTree;
+ private Button okButton;
+ private BindingInfo bindingInfo = new BindingInfo();
+
+ public SetTargetPage(Shell parent, DataBindingPage dataBindingPage) {
+ super( parent, SWT.DIALOG_TRIM | SWT.APPLICATION_MODAL );
+ setText( "Set Target" );
+ this.dataBindingPage = dataBindingPage;
+ }
+
+ /**
+ * Opens the dialog and returns the input
+ *
+ * @return message
+ */
+ public BindingInfo open() {
+ // Create the dialog window
+ shell = new Shell( getParent(), SWT.TITLE | SWT.CLOSE | SWT.BORDER | SWT.RESIZE );
+ shell.setText( getText() );
+ //shell.setMinimumSize(400, 500);
+ createContents();
+ shell.pack();
+
+ shell.open();
+ Display display = getParent().getDisplay();
+ while ( !shell.isDisposed() ) {
+ if (!display.readAndDispatch()) {
+ display.sleep();
+ }
+ }
+ return bindingInfo;
+ }
+
+ private void createContents() {
+ FormLayout layout = new FormLayout();
+ shell.setLayout(layout);
+ layout.marginWidth = 5;
+ layout.marginHeight = 5;
+
+ sashForm = new SashForm(shell, SWT.HORIZONTAL);
+
+ FormData sashData = new FormData();
+ sashData.top = new FormAttachment( 0, 0);
+ sashData.bottom = new FormAttachment(100, -35);
+ sashData.left = new FormAttachment(0, 0);
+ sashData.right = new FormAttachment(100, -5);
+ sashForm.setLayoutData( sashData );
+
+ Group widgetTreeGroup = new Group(sashForm, SWT.NONE);
+ Group bindingInfoGroup = new Group(sashForm, SWT.NONE);
+
+ sashForm.setWeights(new int[] {3, 1});
+
+ makeBindingInfoGroup( bindingInfoGroup );
+ makeWidgetTreeGroup( widgetTreeGroup );
+
+ // Create the cancel button and add a handler
+ // so that pressing it will set input to null
+ Button cancelButton = new Button( shell, SWT.PUSH );
+ cancelButton.setText( "CANCEL" );
+
+ FormData data = new FormData( 100, 30 );
+ data.top = new FormAttachment( sashForm, 5 );
+ data.right = new FormAttachment( 100, -5 );
+ data.bottom = new FormAttachment( 100, -5 );
+
+ cancelButton.setLayoutData( data );
+
+ cancelButton.addSelectionListener( new SelectionAdapter() {
+ public void widgetSelected( SelectionEvent event ) {
+ bindingInfo = null;
+ shell.close();
+ }
+ } );
+
+ // Create the OK button and add a handler
+ // so that pressing it will set input
+ // to the entered value
+ okButton = new Button( shell, SWT.PUSH );
+ okButton.setText( "OK" );
+
+ data = new FormData( 100, 30 );
+ data.top = new FormAttachment( sashForm, 5 );
+ data.right = new FormAttachment( cancelButton, -5 );
+ data.bottom = new FormAttachment( 100, -5 );
+
+ okButton.setLayoutData( data );
+ okButton.setEnabled(false);
+
+ okButton.addSelectionListener( new SelectionAdapter() {
+ public void widgetSelected( SelectionEvent event ) {
+ TreeItem[] widetTreeItem = widgetTree.getSelection();
+ TreeItem[] bindingInfoTreeItem = bindingInfoTree.getSelection();
+
+ if ((widetTreeItem != null) && (bindingInfoTreeItem != null)) {
+ if ((widetTreeItem.length > 0) && (bindingInfoTreeItem.length > 0)) {
+ if ((widetTreeItem[0] != null) && (bindingInfoTreeItem[0] != null)) {
+ bindingInfo.setTargetPart((Part) widetTreeItem[0].getData("PART"));
+ bindingInfo.setInfoValue((String) bindingInfoTreeItem[0].getData("INFOVALUE"));
+ bindingInfo.setInfoDisplayName((String) bindingInfoTreeItem[0].getData("INFODISPLAYNAME"));
+ }
+ }
+ }
+ shell.close();
+ }
+ });
+
+ }
+
+ private void makeBindingInfoGroup(Group bindingInfoGroup) {
+ FormLayout layout = new FormLayout();
+ bindingInfoGroup.setLayout(layout);
+
+ bindingInfoTree = new Tree(bindingInfoGroup, SWT.BORDER | SWT.H_SCROLL | SWT.V_SCROLL | SWT.FULL_SELECTION );
+
+ bindingInfoTree.setLinesVisible(true);
+ //dialogTree.setHeaderVisible(true);
+
+ FormData data = new FormData(150, 300);
+ data.top = new FormAttachment(0, 2);
+ data.left = new FormAttachment(0, 0);
+ data.right = new FormAttachment(100, 0);
+ data.bottom = new FormAttachment(100, 0);
+ bindingInfoTree.setLayoutData(data);
+
+ bindingInfoGroup.layout();
+
+ bindingInfoTree.addMouseListener(new MouseAdapter() {
+ public void mouseUp(MouseEvent e) {
+ setVisibleToOkButton();
+ }
+ });
+ }
+
+ private void makeWidgetTreeGroup(Group widgetTreeGroup) {
+ FormLayout layout = new FormLayout();
+ widgetTreeGroup.setLayout(layout);
+
+ widgetTree = new Tree(widgetTreeGroup, SWT.BORDER | SWT.H_SCROLL | SWT.V_SCROLL | SWT.FULL_SELECTION );
+
+ FormData data = new FormData(250, 300);
+ data.top = new FormAttachment(0, 2);
+ data.left = new FormAttachment(0, 0);
+ data.right = new FormAttachment(100, 0);
+ data.bottom = new FormAttachment(100, 0);
+ widgetTree.setLayoutData(data);
+
+ makeTreeItems(widgetTree);
+ widgetTreeGroup.layout();
+
+ widgetTree.addMouseListener(new MouseAdapter() {
+ public void mouseUp(MouseEvent e) {
+ Point point = new Point(e.x, e.y);
+ final TreeItem treeItem = widgetTree.getItem(point);
+ makeBindingInfoList(treeItem);
+ setVisibleToOkButton();
+ }
+ });
+ }
+
+ private void setVisibleToOkButton() {
+ boolean enable = false;
+ if ((widgetTree.getSelection() != null) && (widgetTree.getSelection().length > 0)) {
+ if ((bindingInfoTree.getSelection() != null) && (bindingInfoTree.getSelection().length > 0)) {
+ enable = true;
+ }
+ }
+ okButton.setEnabled(enable);
+ }
+
+ private void makeBindingInfoList(TreeItem treeItem) {
+ if (treeItem == null) {
+ widgetTree.deselectAll();
+ return;
+ }
+ Part part = (Part) treeItem.getData("PART");
+ if (part == null) {
+ return;
+ }
+
+ if (bindingInfoTree == null) {
+ return;
+ }
+
+ bindingInfoTree.removeAll();
+
+ if (part.getPartDescriptor().getPropertyDescriptor(BuilderConstants.ATTRIBUTE_DATA_BIND) == null) {
+ return;
+ }
+
+ List<ConstantDescriptor> list =
+ part.getPartDescriptor().getPropertyDescriptor(BuilderConstants.ATTRIBUTE_DATA_BIND)
+ .getTypeDescriptor().getAvailableConstant();
+
+ if ((list == null) || (list.size() <= 0)) {
+ return;
+ }
+ for (int i = 0; i < list.size(); i++) {
+ TreeItem subItem = new TreeItem(bindingInfoTree, SWT.NONE);
+ final String value = list.get(i).getValue();
+ final String displayName = list.get(i).getDisplayName();
+ subItem.setData("INFOVALUE", value);
+ if ((displayName != null) && (!displayName.isEmpty())) {
+ subItem.setText(value + "[" + displayName + "]");
+ subItem.setData("INFODISPLAYNAME", displayName);
+ } else {
+ subItem.setText(value);
+ }
+ }
+ }
+
+ private void makeTreeItems(Tree widgetTree) {
+ List<PageData> pageData = dataBindingPage.getPageDesigner().getAppManager().getPages();
+ List<Part> childParts = null;
+
+ for (int i = 0; i < pageData.size(); i++) {
+ childParts = pageData.get(i).getRootPart().getChildren();
+ makeSubWidgetList(null, childParts);
+ }
+ }
+
+ private void makeSubWidgetList(TreeItem parentItem, List<Part> childParts) {
+ if (childParts.size() == 0) {
+ return;
+ }
+
+ TreeItem subItem;
+ for (int i = 0; i < childParts.size(); i++) {
+ if (parentItem == null) {
+ subItem = new TreeItem(widgetTree, SWT.NONE);
+ } else {
+ subItem = new TreeItem(parentItem, SWT.NONE);
+ }
+ subItem.setText(childParts.get(i).getIdPropertyValue() + " <" + childParts.get(i).getPartDescriptor().getDisplayName()+ ">");
+ subItem.setData("PART", childParts.get(i));
+ String iconPath = childParts.get(i).getPartDescriptor().getIcon16();
+ Image image = ResourceManager.getImage(BuilderConstants.ICON_DIR, iconPath);
+ subItem.setImage(image);
+ if ((dataBindingPage.getSelectedPart() != null) && (childParts.get(i).equals(dataBindingPage.getSelectedPart()))) {
+ subItem.setExpanded(true);
+ widgetTree.setSelection(subItem);
+ makeBindingInfoList(subItem);
+ }
+
+ List<Part> subPart = childParts.get(i).getChildren();
+ makeSubWidgetList(subItem, subPart);
+ }
+
+ }
+
+
+}
--- /dev/null
+package org.tizen.webuibuilder.ui.views.databinding.model;
+
+import org.tizen.webuibuilder.model.Part;
+
+public class BindingInfo {
+ private Part targetPart;
+ private String infoValue;
+ private String infoDisplayName;
+
+ public Part getTargetPart() {
+ return targetPart;
+ }
+ public void setTargetPart(Part targetPart) {
+ this.targetPart = targetPart;
+ }
+ public String getInfoValue() {
+ return infoValue;
+ }
+ public void setInfoValue(String infoValue) {
+ this.infoValue = infoValue;
+ }
+ public String getInfoDisplayName() {
+ return infoDisplayName;
+ }
+ public void setInfoDisplayName(String infoDisplayName) {
+ this.infoDisplayName = infoDisplayName;
+ }
+}
\ No newline at end of file
package org.tizen.webuibuilder.ui.views.nscreen;
+import java.io.ByteArrayInputStream;
import java.io.File;
-import java.io.IOException;
+import java.io.InputStream;
import java.util.ArrayList;
import java.util.List;
+import org.eclipse.core.resources.IFile;
+import org.eclipse.core.resources.IProject;
+import org.eclipse.core.resources.IResource;
+import org.eclipse.core.runtime.CoreException;
import org.eclipse.core.runtime.IPath;
import org.eclipse.gef.commands.Command;
import org.eclipse.swt.SWT;
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.databinding.actions.EditDataSourceAction;
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 void LinkCutAction() {
-// Command command = new NScreenLinkCutCommand(this);
-// parent.getNScreenPageModel().getPageDesigner().getCommandStack().execute(command);
+ // 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);
+ // 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);
+ // Command command = new NScreenLinkDownCommand(this);
+ // parent.getNScreenPageModel().getPageDesigner().getCommandStack().execute(command);
}
public void redrawItem() {
}
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();
+ IProject project =
+ parent.getNScreenPageModel().getAppManager().getProjectManager().getProject();
+ IFile ifile = project.getFile(getFileName());
+
+ try {
+ ifile.delete(true, null);
+ } catch (CoreException e) {
+ e.printStackTrace();
}
- parent.getNScreenPageModel().getPageData().removeCssFileByPath(filePath);
+ String cssFolderPath = parent.getNScreenPageModel().getAppManager().getCssFolder();
+ String cssFilePath = cssFolderPath + IPath.SEPARATOR + getFileName();
+ parent.getNScreenPageModel().getPageData().removeCssFileByPath(cssFilePath);
}
public void copyFile(NScreenItem source) {
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()
}
public void createFile() {
+ IProject project =
+ parent.getNScreenPageModel().getAppManager().getProjectManager().getProject();
String filePath = parent.getNScreenPageModel().getAppManager().getCssFolder();
CssFile cssFile = new CssFile(filePath + IPath.SEPARATOR + getFileName());
- File newCSSFile = new File(filePath + IPath.SEPARATOR + getFileName());
-
+ IFile ifile = project.getFile(getFileName());
try {
- if (!newCSSFile.exists()) {
- File dir = newCSSFile.getParentFile();
- dir.mkdirs();
- newCSSFile.createNewFile();
+ if (ifile.exists()) {
+ ifile.delete(true, null);
}
- } catch (IOException e) {
+ byte[] bytes = new byte[0];
+ InputStream source = new ByteArrayInputStream(bytes);
+ ifile.create(source, IResource.FORCE, null);
+ } catch (CoreException e) {
e.printStackTrace();
}
List<Device> devices = DeviceManager.getDeviceManager().getDevices();
Device device = null;
- String profile = mNScreenPageModel.getAppManager().getPlatform();
+ String profile = mNScreenPageModel.getAppManager().getPlatform().toLowerCase();
if (profile.contains("mobile")) {
device = devices.get(1);
} else if (profile.contains("wearable")) {
device = devices.get(0);
+ } else {
+ device = devices.get(1);
}
commonHistory.setModelName(model.getName());
commonHistory.setLastResolution(device.getDisplayName());
import java.io.IOException;
import java.net.ServerSocket;
import java.net.Socket;
+import java.util.Iterator;
+import java.util.Map.Entry;
import org.eclipse.swt.graphics.Image;
+import org.tizen.common.ui.view.console.ConsoleManager;
import org.tizen.webuibuilder.BuilderConstants;
+import org.tizen.webuibuilder.model.css.CssSelector;
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 NScreenUtil {
private static boolean logEnabled = false;
+ private static ConsoleManager console;
public static void enableNScreenLog(boolean enabled) {
logEnabled = enabled;
+
+ if (logEnabled && null == console) {
+ console = new ConsoleManager("NScreen view", false);
+ }
}
public static boolean isLogEnabled() {
public static void nscreen_log(String log) {
if (logEnabled) {
+ console.println("[NSCREEN_LOG] " + log);
System.out.println("[NSCREEN_LOG] " + log);
}
}
}
return null;
}
+
+ public static String selectorCodeGen(CssSelector selector) {
+ StringBuilder css = new StringBuilder();
+ css.append(selector.getSelectorName());
+ css.append(BuilderConstants.SPACE);
+ css.append(BuilderConstants.OPEN_CURLY_BRACKET);
+ css.append(BuilderConstants.NEW_LINE);
+ Iterator<Entry<String, String>> properties = selector.getProperties().iterator();
+
+ while (properties.hasNext()) {
+ // Generates property.
+ Entry<String, String> property = properties.next();
+ css.append(BuilderConstants.TAB);
+ css.append(property.getKey());
+ css.append(BuilderConstants.SPACE);
+ css.append(BuilderConstants.COLON);
+ css.append(BuilderConstants.SPACE);
+ css.append(property.getValue());
+ css.append(BuilderConstants.SEMICOLON);
+ css.append(BuilderConstants.NEW_LINE);
+ }
+ css.append(BuilderConstants.CLOSE_CURLY_BRACKET);
+ css.append(BuilderConstants.NEW_LINE);
+
+ return css.toString();
+ }
+
}
package org.tizen.webuibuilder.ui.views.pages;
+import java.util.List;
+
import org.eclipse.draw2d.ColorConstants;
import org.eclipse.gef.EditDomain;
+import org.eclipse.gef.EditPart;
+import org.eclipse.gef.RootEditPart;
import org.eclipse.gef.ui.actions.ActionRegistry;
import org.eclipse.gef.ui.parts.SelectionSynchronizer;
import org.eclipse.jface.action.IAction;
import org.eclipse.ui.IActionBars;
import org.eclipse.ui.actions.ActionFactory;
import org.eclipse.ui.part.Page;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
import org.tizen.webuibuilder.model.app.AppEvent;
import org.tizen.webuibuilder.model.app.AppManager;
import org.tizen.webuibuilder.model.app.IAppListener;
private SelectionSynchronizer selectionSyncronizer;
// actions
private ActionRegistry actionRegistry;
+ private static Logger logger = LoggerFactory.getLogger(PagesPage.class);
public PagesPage(SelectionSynchronizer selectionSyncronizer,
EditDomain editDomain, ActionRegistry actionRegistry) {
*/
@Override
public void pageRemoved(PageDataSetEvent e) {
- Object model = appManager.getPageDataSet().getBaseRootPart();
+ RootEditPart rootEditPart = viewer.getRootEditPart();
+ List<?> children = rootEditPart.getChildren();
+ EditPart a = (EditPart) children.get(0);
+
+
+ Object model = appManager.getPageDataSet().getBaseRootPart();
viewer.setContents(model);
+ int index = 0;
+ if(e.getIndex() == 0) {
+ index = 1;
+ } else {
+ index = e.getIndex() - 1;
+ }
+
+ viewer.select((EditPart) a.getChildren().get(index));
+
}
/*
action = getAction(ActionFactory.REDO.getId());
menu.appendToGroup(GEFActionConstants.GROUP_UNDO, action);
+
+ action = getAction(WebUIBuilderActionConstants.DELETE_PAGE);
+ menu.appendToGroup(GEFActionConstants.GROUP_REST, action);
action = getAction(WebUIBuilderActionConstants.NEW_PAGE);
menu.appendToGroup(GEFActionConstants.GROUP_REST, action);
case STYLE:
CssStyleTab styleTab =
new CssStyleTab(tabFolder, commandStack,
- descriptorManager.getCssDescriptor(),
+ descriptorManager.getCssDescriptor(), pageData,
pageData.getCurrentCssFile(), goingBridge);
// temp end
pageData.addPageListener(styleTab);
}
} else if (value.toLowerCase().contains("auto")) {
// do nothing !!
- Logger logger = LoggerFactory.getLogger(getClass());
- logger.debug("Do nothing on setViewData");
+// Logger logger = LoggerFactory.getLogger(getClass());
+// logger.debug("Do nothing on setViewData");
}
}
}
setViewData(key, value);
} else if (key.equals(CLIP_WIDTH)) {
if (!originWidth.isDisposed() && !rightTextEditor.getLabel().isDisposed()) {
- if (Integer.parseInt(originWidth.getText()) == Integer.parseInt(rightTextEditor
- .getLabel().getText())) {
+ if (originWidth.getText().equals(rightTextEditor.getLabel().getText())) {
rightTextEditor.setLabel(getRealValue(value));
- // setClipValue();
}
+// if (Integer.parseInt(originWidth.getText()) == Integer.parseInt(rightTextEditor
+// .getLabel().getText())) {
+// rightTextEditor.setLabel(getRealValue(value));
+// // setClipValue();
+// }
originWidth.setText(getRealValue(value));
} else {
return;
}
} else if (key.equals(CLIP_HEIGHT)) {
if (!originHeight.isDisposed() && !bottomTextEditor.getLabel().isDisposed()) {
- if (Integer.parseInt(originHeight.getText()) == Integer
- .parseInt(bottomTextEditor.getLabel().getText())) {
+ if (originHeight.getText().equals(bottomTextEditor.getLabel().getText())) {
bottomTextEditor.setLabel(getRealValue(value));
- // setClipValue();
}
+// if (Integer.parseInt(originHeight.getText()) == Integer
+// .parseInt(bottomTextEditor.getLabel().getText())) {
+// bottomTextEditor.setLabel(getRealValue(value));
+// // setClipValue();
+// }
originHeight.setText(getRealValue(value));
} else {
return;
createPaddingSection();
createContentSection();
- position.addMouseTrackListener(createCurrentPositionListener(null, position, margin));
- margin.addMouseTrackListener(createCurrentPositionListener(position, margin, border));
- border.addMouseTrackListener(createCurrentPositionListener(position, border, padding));
- padding.addMouseTrackListener(createCurrentPositionListener(position, padding, content));
- content.addMouseTrackListener(createCurrentPositionListener(position, content, null));
+
+ composite.addMouseTrackListener(createCurrentPositionListener(null));
+ position.addMouseTrackListener(createCurrentPositionListener(position));
+ margin.addMouseTrackListener(createCurrentPositionListener(margin));
+ border.addMouseTrackListener(createCurrentPositionListener(border));
+ padding.addMouseTrackListener(createCurrentPositionListener(padding));
+ content.addMouseTrackListener(createCurrentPositionListener(content));
return composite;
}
* parent {@link Composite}
*/
private void createPositionSection(Composite parent) {
- position = new Composite(parent, SWT.CENTER | SWT.BORDER);
+ position = new Composite(parent, SWT.BORDER);
position.setLayout(new FormLayout());
position.setBackgroundMode(SWT.INHERIT_FORCE);
* This method creates a margin section of the 'Metrics component'.
*/
private void createMarginSection() {
- margin = new Composite(position, SWT.CENTER | SWT.BORDER);
+ margin = new Composite(position, SWT.BORDER);
margin.setLayout(new FormLayout());
margin.setBackgroundMode(SWT.INHERIT_FORCE);
* This method creates a border section of the 'Metrics component'.
*/
private void createBorderSection() {
- border = new Composite(margin, SWT.CENTER | SWT.BORDER);
+ border = new Composite(margin, SWT.BORDER);
border.setLayout(new FormLayout());
border.setBackgroundMode(SWT.INHERIT_FORCE);
* This method creates a padding section of the 'Metrics component'.
*/
private void createPaddingSection() {
- padding = new Composite(border, SWT.CENTER | SWT.BORDER);
+ padding = new Composite(border, SWT.BORDER);
padding.setLayout(new FormLayout());
padding.setBackgroundMode(SWT.INHERIT_FORCE);
* This method creates a content section of the 'Metrics component'.
*/
private void createContentSection() {
- content = new Composite(padding, SWT.CENTER | SWT.BORDER);
+ content = new Composite(padding, SWT.BORDER);
content.setLayout(new FormLayout());
content.setBackgroundMode(SWT.INHERIT_FORCE);
* child {@link Composite}
* @return a {@link MouseTrackListener}
*/
- private MouseTrackListener createCurrentPositionListener(final Composite parent,
- final Composite i,
- final Composite child) {
+ private MouseTrackListener createCurrentPositionListener(final Composite composite) {
MouseTrackListener listener = new MouseTrackListener() {
@Override
public void mouseEnter(MouseEvent e) {
- if (parent != null) {
- parent.setBackground(null);
+ if (composite != null && !composite.isDisposed()) {
+ composite.setBackground(SELECTED_COLOR);
}
- if (child != null) {
- child.setBackground(DEFAULT_COLOR);
- }
- i.setBackground(SELECTED_COLOR);
}
@Override
public void mouseExit(MouseEvent e) {
- i.setBackground(DEFAULT_COLOR);
- // boolean isChild = false;
- // Point p = new Point(e.x, e.y);
- //
- // for (Control control : composite.getChildren()) {
- // if (control instanceof Label || control instanceof Text) {
- // if (!(control.getBounds().contains(p))) {
- // isChild = false;
- // } else {
- // isChild = true;
- // break;
- // }
- // } else if (control instanceof Composite){
- // i.setBackground(null);
- // return;
- // }
- // }
- //
- // if (!isChild) {
- // i.setBackground(null);
- // }
+ getDisplay().asyncExec(new Runnable() {
+
+ @Override
+ public void run() {
+ if (!position.getBackground().equals(DEFAULT_COLOR)) {
+ position.setBackground(DEFAULT_COLOR);
+ }
+ if (!margin.getBackground().equals(DEFAULT_COLOR)) {
+ margin.setBackground(DEFAULT_COLOR);
+ }
+ if (!border.getBackground().equals(DEFAULT_COLOR)) {
+ border.setBackground(DEFAULT_COLOR);
+ }
+ if (!padding.getBackground().equals(DEFAULT_COLOR)) {
+ padding.setBackground(DEFAULT_COLOR);
+ }
+ if (!content.getBackground().equals(DEFAULT_COLOR)) {
+ content.setBackground(DEFAULT_COLOR);
+ }
+ }
+ });
}
@Override
package org.tizen.webuibuilder.ui.views.properties.method;
+import java.text.DecimalFormat;
import java.util.List;
import org.eclipse.swt.SWT;
}
private String convertFloatString(String value) {
- int intValue = Integer.parseInt(value);
- float opacityValue = (float) intValue / 100;
- return String.format("%.2f", opacityValue);
+// int intValue = Integer.parseInt(value);
+// float opacityValue = (float) intValue / 100;
+// return String.format("%.2f", opacityValue);
+ DecimalFormat format = new DecimalFormat("#.###");
+ return format.format(Double.parseDouble(value) / 100);
}
@Override
import java.util.Collection;
import org.eclipse.gef.commands.CommandStack;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
import org.tizen.webuibuilder.BuilderConstants;
import org.tizen.webuibuilder.bridge.DesignerGoingBridge;
import org.tizen.webuibuilder.gef.commands.CreateCssSelectorCommand;
import org.tizen.webuibuilder.model.Part;
import org.tizen.webuibuilder.model.PartEvent;
import org.tizen.webuibuilder.model.WidgetValidator;
+import org.tizen.webuibuilder.model.css.CssEvent;
import org.tizen.webuibuilder.model.css.CssFile;
import org.tizen.webuibuilder.model.css.CssSelector;
import org.tizen.webuibuilder.model.css.CssStyle;
+import org.tizen.webuibuilder.model.css.ICssListener;
import org.tizen.webuibuilder.model.css.ICssSelectorListener;
import org.tizen.webuibuilder.model.css.NewCssEvent;
import org.tizen.webuibuilder.model.css.descriptors.CssDescriptor;
import org.tizen.webuibuilder.model.css.descriptors.CssPropertyDescriptor;
+import org.tizen.webuibuilder.model.page.PageData;
import org.tizen.webuibuilder.ui.views.properties.method.IValueChangeListener;
import org.tizen.webuibuilder.ui.views.properties.method.Method;
import org.tizen.webuibuilder.ui.views.properties.method.MethodEvent;
/**
* Delegater class for {@link CssStyleTab}.
*/
-public class CssStyleEventDelegater implements ICssSelectorListener, IValueChangeListener, IPartListener {
+public class CssStyleEventDelegater implements ICssSelectorListener, IValueChangeListener, IPartListener, ICssListener {
private CssStyleTab styleTab;
private CommandStack commandStack;
private CssDescriptor cssDescriptor;
private CssFile cssFile;
private CssSelector selector;
+ private PageData pageData;
/**
* Constructs a new instance of this class given its {@link CommandStack},
* a {@link CssStyle}
*/
public CssStyleEventDelegater(CommandStack commandStack, CssDescriptor cssDescriptor,
- CssStyleTab styleTab, DesignerGoingBridge goingBridge) {
+ CssStyleTab styleTab, PageData pageData, DesignerGoingBridge goingBridge) {
this.styleTab = styleTab;
this.commandStack = commandStack;
this.cssDescriptor = cssDescriptor;
+ this.pageData = pageData;
this.goingBridge = goingBridge;
}
Part part = styleTab.getModel();
SetCssStyleCommand command =
- new SetCssStyleCommand(cssFile, part, selector, key, value);
+ new SetCssStyleCommand(pageData, part, selector.getSelectorName(), key, value);
commandStack.execute(command);
}
}
return;
} else {
CreateCssSelectorCommand command =
- new CreateCssSelectorCommand(cssFile, styleTab.getModel(), selectorName);
+ new CreateCssSelectorCommand(pageData, styleTab.getModel(), selectorName);
commandStack.execute(command);
}
}
- public void addCssSelector(CssSelector selector) {
- if (selector == null) {
- return;
- } else {
- CreateCssSelectorCommand command =
- new CreateCssSelectorCommand(cssFile, styleTab.getModel(), selector);
- commandStack.execute(command);
- }
- }
public void removeCssSelector(CssSelector selector) {
if (selector == null) {
@Override
public void needRefresh(PartEvent event) {
+ }
+
+ @Override
+ public void cssSelectorAdded(CssEvent event) {
// TODO Auto-generated method stub
- styleTab.refreshPositionMethods();
+
+ }
+
+ @Override
+ public void cssSelectorRemoved(CssEvent event) {
+ // TODO Auto-generated method stub
+
+ }
+
+ @Override
+ public void cssPropertyChanged(CssEvent event) {
+ String key = event.getPropertyKey();
+ if (key != null) {
+ String value = event.getPropertyValue();
+ refreshStyleTab(key, value);
+ }
+ }
+
+ @Override
+ public void needRefresh(CssEvent event) {
}
}
import org.tizen.webuibuilder.model.descriptors.TypeDescriptor;
import org.tizen.webuibuilder.model.descriptors.TypeDescriptor.Types;
import org.tizen.webuibuilder.model.page.IPageDataListener;
+import org.tizen.webuibuilder.model.page.PageData;
import org.tizen.webuibuilder.model.page.PageDataEvent;
import org.tizen.webuibuilder.ui.views.properties.CategoryComposite;
import org.tizen.webuibuilder.ui.views.properties.PropertiesConstant;
* a {@link CssFile}
*/
public CssStyleTab(CTabFolder tabFolder, CommandStack commandStack,
- CssDescriptor cssDescriptor, CssFile cssFile, DesignerGoingBridge goingBridge) {
+ CssDescriptor cssDescriptor, PageData pageData, CssFile cssFile, DesignerGoingBridge goingBridge) {
super(tabFolder, SWT.NONE, TabIndex.STYLE.getIndex(), goingBridge);
setText(PropertiesConstant.STYLE);
this.commandStack = commandStack;
this.cssDescriptor = cssDescriptor;
- cssDelegater = new CssStyleEventDelegater(commandStack, cssDescriptor, this, goingBridge);
+ cssDelegater = new CssStyleEventDelegater(commandStack, cssDescriptor, this, pageData, goingBridge);
animDelegater = new CssStyleAnimationEventDelegater(commandStack, this);
setCssFile(cssFile);
/* TODO Log */
cssDelegater.setCssFile(cssFile);
setDefaultSelector();
- removeListeners();
- addListeners();
return true;
} else {
return false;
}
}
- /**
- * addListeners
- */
- private void addListeners() {
+
+ private void addModelListener() {
Part model = getModel();
if (model != null) {
model.addCssListener(animDelegater);
model.addPartListener(cssDelegater);
-// model.addCssListener(cssDelegater);
-
- addCssListener();
+ model.addCssListener(cssDelegater);
+ }
+ }
+
+ private void removeModelListener() {
+ Part model = getModel();
+ if (model != null) {
+ model.removeCssListener(animDelegater);
+ model.removePartListener(cssDelegater);
+ model.removeCssListener(cssDelegater);
}
-
}
/**
}
/**
- * removeListeners
- */
- private void removeListeners() {
- Part model = getModel();
- if (model != null) {
- model.removeCssListener(animDelegater);
- model.removePartListener(cssDelegater);
-// model.removeCssListener(cssDelegater);
- }
-
- removeCssListener();
-
- }
-
- /**
* removeCssListener
*/
private void removeCssListener() {
*/
@Override
public void dispose() {
- removeListeners();
+ removeModelListener();
+ removeCssListener();
clear();
noContent.dispose();
multiContent.dispose();
clip.setInitialData(getModel());
setDefaultSelector();
- removeListeners();
- addListeners();
+ removeModelListener();
+ addModelListener();
+
+// removeListeners();
+// addListeners();
// delegater.setModel(models);
}
// CSS Delegater
cssDelegater.setCssSelector(currentSelector);
- removeListeners();
- addListeners();
// if (cssCategory != null && !cssCategory.isDisposed()) {
// cssCategory.setSelector(selectorName);
}
public void refreshPositionMethods() {
- Part model = getModel();
- if (model.getWidgetPosition() != null) {
- String width , height;
- width = model.getWidgetPosition().width + "px";
- height = model.getWidgetPosition().height + "px";
-
- if (checkMethod(widthMethod)) {
- widthMethod.refreshValue(widthMethod.getMethodName(), width);
- }
-
- if (checkMethod(heightMethod)) {
- heightMethod.refreshValue(heightMethod.getMethodName(), height);
- }
-
- if (checkMethod(metrics)) {
- metrics.setInitialData(model);
- }
-
- if (checkMethod(clip)) {
- clip.setInitialData(model);
- }
-
- for (CategoryComposite category : categories) {
- category.refreshBrief();
- }
- }
+// Part model = getModel();
+// if (model.getWidgetPosition() != null) {
+// String width , height;
+// width = model.getWidgetPosition().width + "px";
+// height = model.getWidgetPosition().height + "px";
+//
+// if (checkMethod(widthMethod)) {
+// widthMethod.refreshValue(widthMethod.getMethodName(), width);
+// }
+//
+// if (checkMethod(heightMethod)) {
+// heightMethod.refreshValue(heightMethod.getMethodName(), height);
+// }
+//
+// if (checkMethod(metrics)) {
+// metrics.setInitialData(model);
+// }
+//
+// if (checkMethod(clip)) {
+// clip.setInitialData(model);
+// }
+//
+// for (CategoryComposite category : categories) {
+// category.refreshBrief();
+// }
+// }
}
private boolean checkMethod(Method method) {
public void pageChanged(PageDataEvent e) {
if (setCssFile(e.getPage().getCurrentCssFile())) {
refresh();
+ removeCssListener();
+ addCssListener();
+// addListeners();
}
}
import org.w3c.dom.Node;
public class DomUtil {
-
+
+ public static final String BODY_ELEMENT = "//body";
/**
* @param doc
targetBodyNode.appendChild(pageNode);
}
+ public static void insertBeforePageNode(Document targetDocument, String xpath, Node pageNode, Node refPageNode) {
+ Node targetBodyNode = getBodyNode(targetDocument, xpath);
+
+ if(targetBodyNode == null) {
+ return;
+ }
+
+ targetBodyNode.insertBefore(pageNode, refPageNode);
+ }
+
public static void removePageNode(Document targetDocument, String xpath, Node pageNode) {
Node targetBodyNode = getBodyNode(targetDocument, xpath);
+* 0.1.437
+- [Title] update version.
+== yonghwan.jeon <yonghwan82.jeon@samsung.com> 2014-05-19
+* 0.1.436
+- [Title] update version.
+== yonghwan.jeon <yonghwan82.jeon@samsung.com> 2014-05-19
+* 0.1.435
+- [Title] Remove duplicate pageView code in TizeIDE perspective.
+== yonghwan.jeon <yonghwan82.jeon@samsung.com> 2014-05-17
+* 0.1.434
+- [Title] Fix CssSelector managing on Part
+== nakyoung2.choi <nakyoung2.choi@samsung.com> 2014-05-17
+* 0.1.433
+- [Title] Modify QT library path in MACOS.
+== yonghwan.jeon <yonghwan82.jeon@samsung.com> 2014-05-16
+* 0.1.432
+- [Title] update version
+== yonghwan.jeon <yonghwan82.jeon@samsung.com> 2014-05-16
* 0.1.431
- [Title] update version
== yonghwan.jeon <yonghwan82.jeon@samsung.com> 2014-05-15
Package : web-ui-builder-eplugin
-Version :0.1.431
+Version :0.1.437
OS : ubuntu-32
Build-host-os : ubuntu-32
Maintainer : Hoon Kang <h245.kang@samsung.com>
Description :
Package : web-ui-builder-eplugin
-Version :0.1.431
+Version :0.1.437
OS : ubuntu-64
Build-host-os : ubuntu-64
Maintainer : Hoon Kang <h245.kang@samsung.com>
Description :
Package : web-ui-builder-eplugin
-Version :0.1.431
+Version :0.1.437
OS : windows-32
Build-host-os : ubuntu-32
Maintainer : Hoon Kang <h245.kang@samsung.com>
Description :
Package : web-ui-builder-eplugin
-Version :0.1.431
+Version :0.1.437
OS : windows-64
Build-host-os : ubuntu-64
Maintainer : Hoon Kang <h245.kang@samsung.com>
Description :
Package : web-ui-builder-eplugin
-Version :0.1.431
+Version :0.1.437
OS : macos-64
Build-host-os : ubuntu-64
Maintainer : Hoon Kang <h245.kang@samsung.com>