Add the brief message to category on StyleTab. And modify layout of border style.
Change-Id: I148af257c747c159b9893fd742a4073e792eb7f3
Signed-off-by: mucikan <nakyoung2.choi@samsung.com>
]>
-->
<style>
- <category name="layout" displayName="Layout" brief="">
+ <category name="layout" displayName="Layout" brief="%position%">
<property name="position" type="position@position" displayName="Position" deafult=""></property>
</category>
- <category name="dimension" displayName="Dimension" brief="">
+ <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>
</category>
- <category name="background" displayName="Background" brief="">
+ <category name="background" displayName="Background" brief="%background-color%">
<property name="background-color" type="color-fill" displayName="Color"></property>
<property name="opacity" type="scale@per" displayName="Opacity" default="100">
<condition name="integer-min" value="0" error="integer-min"/>
<property name="background-position.y" type="size" displayName="Y" default="0"></property>
</property>
</category>
- <category name="border" displayName="Border" brief="">
+ <category name="border" displayName="Border" brief="%border%">
<property name="border" type="group-border" displayName="All">
<property name="border.color" type="color"></property>
<property name="border.width" type="size"></property>
fireEvent(new NewCssEvent(EventType.CSS_STYLE_CHANGED, null, this, key, null));
} else {
CssStyle style = styles.get(key);
- if (style != null) {
- style.setValue(value);
- } else {
+
+ if (style == null) {
style = new CssStyle(key, value, null);
styles.put(key, style);
+ } else if (style.getStringValue().equals(value)) {
+ return;
+ } else {
+ style.setValue(value);
}
-
+
fireEvent(new NewCssEvent(EventType.CSS_STYLE_CHANGED, null, this, style.getKey(),
style.getValue()));
}
package org.tizen.webuibuilder.ui.views.properties;
+import java.util.ArrayList;
+import java.util.List;
+
import org.eclipse.swt.SWT;
+import org.eclipse.swt.graphics.Font;
+import org.eclipse.swt.graphics.FontData;
import org.eclipse.swt.layout.FormAttachment;
import org.eclipse.swt.layout.FormData;
import org.eclipse.swt.layout.FormLayout;
import org.eclipse.swt.widgets.Composite;
import org.eclipse.swt.widgets.Control;
+import org.eclipse.swt.widgets.Label;
import org.eclipse.ui.forms.events.IExpansionListener;
import org.eclipse.ui.forms.widgets.ExpandableComposite;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import org.tizen.webuibuilder.ui.views.properties.method.Method;
/**
public class CategoryComposite extends Composite {
private ExpandableComposite expandableComposite;
+ private Label briefLabel;
+ private String brief = null;
+ private List<Method> methods = new ArrayList<Method>();
/**
* Constructs a new instance of this class given its parent and category name.
super(parent, SWT.NONE);
init();
createExpandableComposite(name);
+ setBriefLabel();
+
+ }
+
+ public CategoryComposite(Composite parent, String name, String brief) {
+ this(parent, name);
+ this.brief = brief;
}
private void init() {
data.right = new FormAttachment(100, 0);
expandableComposite.setLayoutData(data);
}
+
+ private void setBriefLabel() {
+ briefLabel = new Label(expandableComposite, SWT.NONE);
+ briefLabel.setForeground(getDisplay().getSystemColor(SWT.COLOR_BLUE));
+
+ FontData fontData = briefLabel.getFont().getFontData()[0];
+ Font font = new Font(getDisplay(), new FontData(fontData.getName(), fontData
+ .getHeight(), SWT.BOLD));
+ briefLabel.setFont(font);
+
+ expandableComposite.setTextClient(briefLabel);
+ }
/**
* Sets the client to expandable composite. The client must not be null and must be a direct
expandableComposite.setClient(client);
}
+ /**
+ * Gets a client of expandable composite.
+ *
+ * @return a client {@link Composite}
+ */
public Composite getClient() {
return (Composite) expandableComposite.getClient();
}
+ /**
+ * Adds the listener that will be notified when the expansion state changes.
+ *
+ * @param listener the listener to add
+ */
public void addExpansionListener(IExpansionListener listener) {
expandableComposite.addExpansionListener(listener);
}
+
+ public void setBriefMessage(String key, String value) {
+ String msg = brief.replaceAll("%" + key + "%", value);
+
+ for (Method method : methods) {
+ String methodName = method.getMethodName();
+ String methodValue = method.getValue();
+ if (methodValue == null || methodValue.isEmpty()) {
+ methodValue = method.getDefaultValue();
+ }
+
+ msg = msg.replaceAll("%" + methodName + "%", methodValue);
+ }
+
+ if (briefLabel != null && !briefLabel.isDisposed()) {
+ briefLabel.dispose();
+ briefLabel = null;
+ }
+ setBriefLabel();
+ briefLabel.setText(msg);
+ expandableComposite.layout();
+
+ Logger logger = LoggerFactory.getLogger(CategoryComposite.class);
+ logger.info("brief : " + msg);
+ }
+
+ /**
+ * Sets a method to list.
+ *
+ * @param method a {@link Method}
+ */
+ public void setMethod(Method method) {
+ if (method != null) {
+ methods.add(method);
+ }
+ }
+
+ /**
+ * Returns true if this {@link CategoryComposite} contains a specified {@link Method}.
+ *
+ * @param method a specified {@link Method}
+ * @return true if this {@link CategoryComposite} contains a specified {@link Method}
+ */
+ public boolean hasMethod(Method method) {
+ return methods.contains(method);
+ }
+
+ /**
+ * Refreshes brief message on this {@link CategoryComposite}.
+ */
+ public void refreshBrief() {
+ String msg = null;
+ if (brief == null || brief.isEmpty()) {
+ return;
+ } else {
+ msg = brief;
+ }
+
+ for (Method method : methods) {
+ String methodName = method.getMethodName();
+ String methodValue = method.getValue();
+ if (methodValue == null || methodValue.isEmpty()) {
+ methodValue = method.getDefaultValue();
+ }
+
+ msg = msg.replaceAll("%" + methodName + "%", methodValue);
+ }
+
+ if (briefLabel != null && !briefLabel.isDisposed()) {
+ briefLabel.dispose();
+ briefLabel = null;
+ }
+ setBriefLabel();
+ briefLabel.setText(msg);
+ expandableComposite.layout();
+ }
+
}
} else if (index == 1) {
data.left = new FormAttachment(methods.get(0), 3);
data.right = new FormAttachment(50, 0);
- method.setControlRightData(100, 0);
+ method.setControlRightData(75, 0);
} else if (index == 2) {
data.left = new FormAttachment(methods.get(1), 3);
// data.width = 80;
import org.eclipse.swt.widgets.Combo;
import org.eclipse.swt.widgets.Composite;
import org.eclipse.swt.widgets.Control;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
import org.tizen.webuibuilder.BuilderConstants;
import org.tizen.webuibuilder.model.descriptors.ConstantDescriptor;
import org.tizen.webuibuilder.model.descriptors.TypeDescriptor;
* @return the default value of this {@link Method}
*/
public String getDefaultValue() {
- return defaultValue;
+ return defaultValue == null ? BuilderConstants.EMPTY : defaultValue;
}
/**
package org.tizen.webuibuilder.ui.views.properties.style;
import org.eclipse.gef.commands.CommandStack;
+import org.eclipse.swt.widgets.Composite;
import org.tizen.webuibuilder.BuilderConstants;
import org.tizen.webuibuilder.commands.SetCssStyleCommand;
import org.tizen.webuibuilder.model.Part;
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.ui.views.properties.CategoryComposite;
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;
Method method = styleTab.getMethod(key);
if (method != null) {
method.refreshValue(key, value);
+ styleTab.setCategoryBrief(method, key, value);
}
styleTab.refreshManagedMethods(key, value, true);
}
import org.eclipse.swt.widgets.Composite;
import org.eclipse.ui.forms.events.ExpansionAdapter;
import org.eclipse.ui.forms.events.ExpansionEvent;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
import org.tizen.webuibuilder.BuilderConstants;
import org.tizen.webuibuilder.animator.model.AnimatorFrame;
import org.tizen.webuibuilder.animator.model.AnimatorKeyframe;
for (CssCategoryDescriptor descriptor : descriptors) {
String categoryName = descriptor.getDisplayName();
- CategoryComposite categoryComposite = getCategory(categoryName);
+ CategoryComposite categoryComposite = getCategory(descriptor);
for (CssPropertyDescriptor property : descriptor.getCssPropertyDescriptors()) {
String value = BuilderConstants.EMPTY;
method.setLabelTooltipText(property.getPropertyDisplayName());
// method.refresh();
methods.add(method);
+ categoryComposite.setMethod(method);
}
}
if (methodName.equals(style.getKey())) {
String styleValue = style.getStringValue();
method.refreshValue(methodName, styleValue);
+// setCategoryBrief(method, methodName, styleValue);
refreshManagedMethods(methodName, styleValue, true);
}
}
+ for (CategoryComposite category : categories) {
+ category.refreshBrief();
+ }
// content.layout();
resizeScrolledComposite();
}
childDescriptor = getFakeDescriptor(descriptor);
}
- CategoryComposite categoryComposite = getCategory(categoryName);
+ CategoryComposite categoryComposite = getCategory(descriptor);
for (CssPropertyDescriptor property : childDescriptor.getCssPropertyDescriptors()) {
* @param categoryName
* @return
*/
- private CategoryComposite getCategory(String categoryName) {
+ private CategoryComposite getCategory(CssCategoryDescriptor descriptor) {
+ String categoryName = descriptor.getDisplayName();
if (categoryName == null) {
return null;
}
}
// create new category
- return createCategory(categoryName);
+ return createCategory(categoryName, descriptor.getBrief());
}
/**
* @param CategoryName
* @return
*/
- private CategoryComposite createCategory(String CategoryName) {
+ private CategoryComposite createCategory(String CategoryName, String brief) {
CategoryComposite categoryComposite =
- new CategoryComposite(categoryContainer, CategoryName);
+ new CategoryComposite(categoryContainer, CategoryName, brief);
categoryComposite.setLayoutData(new GridData(GridData.FILL, GridData.FILL, true, false));
categoryComposite.addExpansionListener(new ExpansionAdapter() {
categories.add(categoryComposite);
return categoryComposite;
}
+
+ public void setCategoryBrief(Method method, String key, String value) {
+ for (CategoryComposite category : categories) {
+ if (category.hasMethod(method)) {
+ // refresh position
+ String methodName = method.getMethodName();
+ if (methodName.equals("width") && (value == null || value.isEmpty())) {
+ Part model = getModel();
+ value = model.getPosition().width + "px";
+ } else if (methodName.equals("height") && (value == null || value.isEmpty())) {
+ Part model = getModel();
+ value = model.getPosition().height + "px";
+ }
+
+ category.setBriefMessage(key, value);
+ }
+ }
+ }
/**
* addListenerToMethod2