package org.tizen.webuibuilder.gef.dnd.model;
import org.eclipse.gef.requests.CreationFactory;
-import org.tizen.webuibuilder.model.Part;
import org.tizen.webuibuilder.model.descriptors.DescriptorManager;
import org.tizen.webuibuilder.snippet.converter.Converter;
import org.tizen.webuibuilder.snippet.model.ISnippet;
this.snippet = snippet;
this.descriptorManager = descriptorManager;
setType(SNIPPET);
- SnippetCreationFactory factory =
- new SnippetCreationFactory();
+ SnippetCreationFactory factory = new SnippetCreationFactory();
setFactory(factory);
}
@Override
public Object getNewObject() {
String text = snippet.getDescriptor().getText();
- Converter converter = new Converter(descriptorManager);
- Part part = converter.convert(text);
- return part;
+ Converter converter = new Converter();
+ return converter.convert(text);
}
/*
--- /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.model;
+
+
+
+public interface ISerializer {
+ /**
+ *
+ * @return
+ */
+ public String serialize();
+
+ /**
+ *
+ * @param text
+ */
+ public void deserialize(String text);
+}
\ No newline at end of file
/**
* A model class.
*/
-public class Part {
+public class Part implements ISerializer {
public enum PartClass {
DUMMY_PART, DOCUMENT_PART, PAGE_PART, WIDGET_PART
* An unique part-id.
*/
private static int uniquePartId = 1;
-
+
// private PositionMode positionMode = PositionMode.RELATIVE_POSITION;
private Rectangle position = null;
private Rectangle originalPosition = null;
* a descriptor of a {@link Part}
*/
public Part(Object ownerRef, PartDescriptor descriptor) {
- this(ownerRef, descriptor, PartClass.DUMMY_PART);
+ this(ownerRef, descriptor, PartClass.DUMMY_PART);
}
-
+
/**
* Generates an unique part-id within this Document.
*
return id;
}
-
+
/**
* Gets a owner reference of a {@link Part}.
*
}
}
}
-
+
/**
* Sets a partClass of a {@link Part}.
*
* a partClass of a {@link Part}
*/
public void setPartClass(PartClass partClass) {
- this.partClass = partClass;
+ this.partClass = partClass;
}
-
+
/**
* Gets a documentPart of a {@link Part}.
*
* a owner reference of a {@link Part}
*/
public boolean isDocumentPart() {
- return partClass == PartClass.DOCUMENT_PART;
+ return partClass == PartClass.DOCUMENT_PART;
}
/**
* a owner reference of a {@link Part}
*/
public boolean isPagePart() {
- return partClass == PartClass.PAGE_PART;
+ return partClass == PartClass.PAGE_PART;
}
/**
* a owner reference of a {@link Part}
*/
public boolean isWidgetPart() {
- return partClass == PartClass.WIDGET_PART;
+ return partClass == PartClass.WIDGET_PART;
}
/**
* @param docHavingIdGenerator
* a {@link DocumentPart}
*/
- private void setUniqueId(/*DocumentPart docHavingIdGenerator*/) {
-// if (docHavingIdGenerator == null) {
-// return;
-// }
+ private void setUniqueId(/* DocumentPart docHavingIdGenerator */) {
+ // if (docHavingIdGenerator == null) {
+ // return;
+ // }
String thisId = getPartId();
String uniquePartId = getUniquePartId();
if (thisId.isEmpty()) {
setPartId(uniquePartId);
- } else if (getOwnerDocument() != null){
- if(getOwnerDocument().getChildOfId(thisId, true) != null) {
- // if doc has part with id already
- setPartId(uniquePartId);
- }
+ } else if (getOwnerDocument() != null) {
+ if (getOwnerDocument().getChildOfId(thisId, true) != null) {
+ // if doc has part with id already
+ setPartId(uniquePartId);
+ }
}
Iterator<Part> itr = children.iterator();
}
}
}
-
+
@Override
public String toString() {
return descriptor.getDescriptorId() + SPACE + getIdPropertyValue();
}
-
+
/**
* Gets default selector name. (e.g. #pageDd #widgetId).
*
return builder.toString();
}
}
-
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see org.tizen.webuibuilder.model.ISerializer#serialize()
+ */
+ @Override
+ public String serialize() {
+ // TODO : Implementation
+ return null;
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see org.tizen.webuibuilder.model.ISerializer#deserialize(java.lang.String)
+ */
+ @Override
+ public void deserialize(String text) {
+ // TODO : Implementation
+ }
+
}
package org.tizen.webuibuilder.nature;
import org.eclipse.core.resources.IProject;
-import org.eclipse.core.resources.IProjectDescription;
import org.eclipse.core.resources.IProjectNature;
import org.eclipse.core.runtime.CoreException;
import org.tizen.webuibuilder.BuilderPlugin;
package org.tizen.webuibuilder.pagetemplate.converter;
-import org.tizen.webuibuilder.model.Part;
-import org.tizen.webuibuilder.model.descriptors.DescriptorManager;
-import org.tizen.webuibuilder.model.io.CodeGenerator;
-import org.tizen.webuibuilder.snippet.converter.IConverter;
+import org.tizen.webuibuilder.model.ISerializer;
+import org.tizen.webuibuilder.snippet.converter.AbstractConverter;
-public class Converter implements IConverter {
- private DescriptorManager descriptorManager;
-
- private Converter() {
+public class Converter extends AbstractConverter {
+ public Converter() {
super();
}
- public Converter(DescriptorManager descriptorManager) {
- this();
- this.descriptorManager = descriptorManager;
- }
-
- /*
- * (non-Javadoc)
- *
- * @see
- * org.tizen.webuibuilder.feature.snippet.converter.IConverter#convert(org.tizen.webuibuilder
- * .model.Part)
- */
- @Override
- public String convert(Part part) {
- String html =
- CodeGenerator.generateCode(part, false, descriptorManager.getXsltDocument(), false);
- return html;
- }
-
/*
* (non-Javadoc)
- *
* @see org.tizen.webuibuilder.snippet.converter.IConverter#convert(java.lang.String)
*/
@Override
- public Part convert(String text) {
+ public ISerializer convert(String text) {
return null;
}
// Create Descriptor
template.setImageDescriptor(imageDescriptor);
IDescriptor descriptor = new Descriptor();
- Converter converter = new Converter(descriptorManager);
+ Converter converter = new Converter();
String text = converter.convert(parts.get(0));
descriptor.setText(text);
template.setDescriptor(descriptor);
--- /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.snippet.converter;
+
+import org.tizen.webuibuilder.model.ISerializer;
+
+
+
+public abstract class AbstractConverter implements IConverter {
+ /*
+ * (non-Javadoc)
+ * @see org.tizen.webuibuilder.snippet.converter.IConverter#convert(java.lang.Object)
+ */
+ @Override
+ public String convert(ISerializer model) {
+ return model.serialize();
+ }
+
+}
package org.tizen.webuibuilder.snippet.converter;
-import java.io.FileWriter;
-import java.io.IOException;
-import java.io.StringBufferInputStream;
-import java.io.StringWriter;
-import java.util.List;
+import org.tizen.webuibuilder.model.ISerializer;
-import javax.xml.parsers.DocumentBuilder;
-import javax.xml.parsers.DocumentBuilderFactory;
-import javax.xml.parsers.ParserConfigurationException;
-import javax.xml.transform.OutputKeys;
-import javax.xml.transform.Transformer;
-import javax.xml.transform.TransformerConfigurationException;
-import javax.xml.transform.TransformerException;
-import javax.xml.transform.TransformerFactory;
-import javax.xml.transform.dom.DOMSource;
-import javax.xml.transform.stream.StreamResult;
-
-import org.w3c.dom.Attr;
-import org.w3c.dom.Document;
-import org.w3c.dom.Element;
-import org.w3c.dom.NamedNodeMap;
-import org.w3c.dom.Node;
-import org.w3c.dom.NodeList;
-import org.xml.sax.SAXException;
-import org.tizen.webuibuilder.BuilderConstants;
-import org.tizen.webuibuilder.model.Part;
-import org.tizen.webuibuilder.model.Part.PartClass;
-import org.tizen.webuibuilder.model.css.CssSelector;
-import org.tizen.webuibuilder.model.descriptors.DescriptorManager;
-import org.tizen.webuibuilder.model.descriptors.PagePartDescriptor;
-import org.tizen.webuibuilder.model.descriptors.PartDescriptor;
-import org.tizen.webuibuilder.model.descriptors.PropertyDescriptor;
-import org.tizen.webuibuilder.model.descriptors.TypeDescriptor;
-import org.tizen.webuibuilder.model.descriptors.WidgetPartDescriptor;
-import org.tizen.webuibuilder.model.io.PageReader_ver_2;
-import org.tizen.webuibuilder.model.io.PageWriter_ver_2;
-
-
-public class Converter implements IConverter {
- private static int INDENT_SIZE = 4;
- private DescriptorManager descriptorManager;
+public class Converter extends AbstractConverter {
public Converter() {
super();
}
- public Converter(DescriptorManager descriptorManager) {
- this();
- this.descriptorManager = descriptorManager;
- }
-
/*
* (non-Javadoc)
- *
- * @see
- * org.tizen.webuibuilder.feature.snippet.converter.IConverter#convert(org.tizen.webuibuilder
- * .model.Part)
+ * @see org.tizen.webuibuilder.snippet.converter.IConverter#convert(java.lang.String)
*/
@Override
- public String convert(Part part) {
- DocumentBuilderFactory docFactory = DocumentBuilderFactory.newInstance();
- DocumentBuilder builder = null;
- try {
- builder = docFactory.newDocumentBuilder();
- } catch (ParserConfigurationException e1) {
- // TODO Auto-generated catch block
- e1.printStackTrace();
- }
-
- Document document = builder.newDocument();
-
- Element rootElement = document.createElement("descriptor");
- Element cssElement = document.createElement("tizen.css");
- Element partElement = document.createElement("tizen.part");
- partElement.appendChild(PageWriter_ver_2.writePart(document, part, false));
- rootElement.appendChild(PageWriter_ver_2.writeCss(document, cssElement, part));
- rootElement.appendChild(partElement);
- document.appendChild(rootElement);
-
- StringWriter stringWriter = new StringWriter();
-
- DOMSource source = new DOMSource(document);
- StreamResult result = new StreamResult(stringWriter);
-
- TransformerFactory factory = TransformerFactory.newInstance();
- Transformer transformer = null;
- try {
- transformer = factory.newTransformer();
- transformer.setOutputProperty(OutputKeys.OMIT_XML_DECLARATION,
- BuilderConstants.YES);
- transformer.setOutputProperty(OutputKeys.ENCODING,
- BuilderConstants.ENCODING);
- transformer.setOutputProperty(OutputKeys.METHOD,
- BuilderConstants.XML);
- } catch (TransformerConfigurationException e) {
- e.printStackTrace();
- }
-
- try {
- transformer.transform(source, result);
- } catch (TransformerException e) {
- e.printStackTrace();
- }
-
-// OutputFormat prettyFormat = OutputFormat.createPrettyPrint();
-// prettyFormat.setIndentSize(INDENT_SIZE);
-//
-// XMLWriter xmlwriter = new XMLWriter(stringWriter, prettyFormat);
-// try {
-// xmlwriter.write(document);
-// xmlwriter.close();
-// } catch (IOException e) {
-// e.printStackTrace();
-// }
-
- return stringWriter.getBuffer().toString();
- }
-
- public Part convert(String text) {
- DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance();
- DocumentBuilder builder = null;
- Document doc = null;
-
- try {
- builder = factory.newDocumentBuilder();
- doc = builder.parse(new StringBufferInputStream(text));
- } catch (ParserConfigurationException e) {
- e.printStackTrace();
- } catch (SAXException e) {
- e.printStackTrace();
- } catch (IOException e) {
- e.printStackTrace();
- }
-
- Element rootElement = doc.getDocumentElement();
- List<CssSelector> selectors = null;
- NodeList elemList = rootElement.getElementsByTagName("tizen.css");
- for (int i = 0; i < elemList.getLength(); i++) {
- Element childElement = (Element) elemList.item(i);
- selectors = PageReader_ver_2.parseStyle((Element) childElement);
- }
-
- elemList = rootElement.getElementsByTagName("tizen.part");
- if(elemList.getLength() > 0) {
- Element childElement = (Element) elemList.item(0);
- Part part = parse(childElement, descriptorManager, selectors);
- return part;
- } else {
- return null;
- }
- }
-
- private static Part parse(Element element, DescriptorManager descriptorManager,
- List<CssSelector> selectors) {
- Part part = null;
- PartDescriptor descriptor = descriptorManager.getPartDescriptor(element.getNodeName());
- if (descriptor == null) {
- } else {
- if (descriptor instanceof WidgetPartDescriptor) {
- part = new Part(null, (WidgetPartDescriptor) descriptor);
- } else if (descriptor instanceof PagePartDescriptor) {
- part = new Part(null, (PagePartDescriptor) descriptor);
- part.setPartClass(PartClass.PAGE_PART);
- } else {
- // cannot be here
- assert (false);
- }
-
- // Sets events and properties.
- Attr attr = null;
- NamedNodeMap attrList = element.getAttributes();
- for (int i = 0; i < attrList.getLength(); i++) {
- attr = (Attr) attrList.item(i);
- if (BuilderConstants.ATTRIBUTE_EVENT_PREFIX.equals((attr.getName())
- .substring(0, BuilderConstants.ATTRIBUTE_EVENT_PREFIX.length()))) {
- part.setEventValue(attr.getName(), attr.getValue());
- } else {
- part.setPropertyValueWhenPageRead(attr.getName(), attr.getValue());
- }
- }
- String text = element.getTextContent();
- if (!text.isEmpty()) {
- PropertyDescriptor prop = null;
- for (Object attrObj : descriptor.getPropertyDescriptors()) {
- prop = (PropertyDescriptor) attrObj;
- if (prop.getPropertyType().equals(TypeDescriptor.ID_OF_HTMLSTRING)) {
- part.setPropertyValueWhenPageRead(prop.getPropertyName(), text);
- break;
- }
- }
- }
-
- // Sets selectors.
- int size = selectors.size();
- for (int i = 0; i < size; i++) {
- CssSelector selector = selectors.get(i);
- if (part.getIdPropertyValue().equals(selector.getPartId())) {
- part.addSelector(selector.getSelectorName(), selector);
- }
- }
-
- // Adds children.
- NodeList elemList = element.getChildNodes();
- for (int i = 0; i < elemList.getLength(); i++) {
- Node childNode = elemList.item(i);
- if(childNode instanceof Element){
- Part childpart = parse((Element)childNode, descriptorManager, selectors);
- part.addChildWhenPageRead(childpart);
- }
- }
- }
-
- return part;
+ public ISerializer convert(String text) {
+ return null;
}
-}
+}
\ No newline at end of file
package org.tizen.webuibuilder.snippet.converter;
-import org.tizen.webuibuilder.model.Part;
-
+import org.tizen.webuibuilder.model.ISerializer;
public interface IConverter {
- public Part convert(String text);
+ public ISerializer convert(String text);
- public String convert(Part part);
+ public String convert(ISerializer model);
}
\ No newline at end of file
package org.tizen.webuibuilder.snippet.manager;
-import java.util.List;
+import java.util.Collection;
import org.tizen.webuibuilder.snippet.model.ISnippet;
-
+/**
+ * Interface for a snippet manager
+ * <p>
+ * The class <code>SnippetManager</code> provides an implementation of this interface.
+ * </p>
+ *
+ * @see SnippetManager
+ */
public interface ISnippetManager {
- public List<?> getSnippets();
+ public Collection<?> getSnippets();
public boolean create(ISnippet snippet);
package org.tizen.webuibuilder.snippet.manager;
import java.io.File;
-import java.util.ArrayList;
-import java.util.List;
+import java.util.Collection;
+import java.util.HashMap;
+import java.util.Map;
import org.eclipse.core.runtime.IPath;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
import org.tizen.common.util.FileUtil;
import org.tizen.webuibuilder.snippet.InternalMessages;
import org.tizen.webuibuilder.snippet.loader.ISnippetLoader;
public class SnippetManager implements ISnippetManager {
- private List<ISnippet> snippets;
+ private Map<Integer, ISnippet> snippets = null;
+ private Logger logger = LoggerFactory.getLogger(getClass());
public SnippetManager() {
super();
+ snippets = new HashMap<Integer, ISnippet>();
load();
}
* @see org.tizen.webuibuilder.feature.snippet.manager.ISnippetManager#getSnippets()
*/
@Override
- public List<ISnippet> getSnippets() {
- return snippets;
+ public Collection<ISnippet> getSnippets() {
+ return snippets.values();
}
/*
snippets = load(getDefaultPath());
}
- private List<ISnippet> load(String path) {
+ private Map<Integer, ISnippet> load(String path) {
File folder = new File(path);
if (!folder.exists()) {
return null;
if (!folder.isDirectory()) {
return null;
}
- List<ISnippet> snippets = new ArrayList<ISnippet>();
+
+ Map<Integer, ISnippet> snippets = new HashMap<Integer, ISnippet>();
File[] files = folder.listFiles();
for (File file : files) {
+ // snippet directory has file
if (!file.isDirectory()) {
+ logger.warn("snippet directory has file");
continue;
}
String snippetPath = path + IPath.SEPARATOR + file.getName();
ISnippetLoader loader = new SnippetLoader();
+ // snippet load fail
ISnippet snippet = loader.load(snippetPath);
if (snippet == null) {
+ logger.warn("snippet load fail");
continue;
}
- snippets.add(snippet);
+
+ // snippet id consistency broken
+ Integer key = Integer.parseInt(snippet.getId());
+ if (snippets.containsKey(key)) {
+ logger.warn("snippet id consistency broken");
+ return null;
+ }
+ snippets.put(key, snippet);
}
return snippets;
}
- private String createId() {
- Integer id = null;
- if (snippets.size() > 0) {
- String lastId = snippets.get(snippets.size() - 1).getId();
- id = Integer.valueOf(lastId) + 1;
- } else {
- id = Integer.valueOf(1);
+ protected String createId() {
+ // initialize id
+ Integer id = Integer.valueOf(1);
+ logger.info("id : " + id);
+ while (snippets.containsKey(id)) {
+ id = id + 1;
}
return id.toString();
}
package org.tizen.webuibuilder.snippet.model;
public class Descriptor implements IDescriptor {
- private String text;
+ private String text = null;
public Descriptor() {
super();
}
+ /*
+ * (non-Javadoc)
+ *
+ * @see org.tizen.webuibuilder.snippet.model.IDescriptor#setText(java.lang.String)
+ */
+ @Override
public void setText(String text) {
this.text = text;
}
+ /*
+ * (non-Javadoc)
+ *
+ * @see org.tizen.webuibuilder.snippet.model.IDescriptor#getText()
+ */
+ @Override
public String getText() {
return text;
}
package org.tizen.webuibuilder.snippet.model;
+/**
+ * Interface for a descriptor.
+ * <p>
+ * The class <code>Descriptor</code> provides an implementation of this interface.
+ * </p>
+ *
+ * @see Descriptor
+ */
public interface IDescriptor {
+ /**
+ * Sets the descriptor text.
+ */
public void setText(String text);
+ /**
+ * Gets the descriptor text.
+ *
+ * @return descriptor text.
+ */
public String getText();
}
\ No newline at end of file
import org.eclipse.jface.resource.ImageDescriptor;
+/**
+ * Interface for a snippet.
+ * <p>
+ * The class <code>Snippet</code> provides an implementation of this interface.
+ * </p>
+ *
+ * @see Snippet
+ */
public interface ISnippet {
+ /**
+ * Sets the snippet id.
+ */
public void setId(String id);
+ /**
+ * Gets the snippet's id.
+ *
+ * @return snippet id.
+ */
public String getId();
+ /**
+ * Sets the snippet name.
+ */
public void setName(String name);
+ /**
+ * Gets the snippet's name.
+ *
+ * @return snippet name.
+ */
public String getName();
+ /**
+ * Sets the snippet description.
+ */
public void setDescription(String description);
+ /**
+ * Gets the snippet's description.
+ *
+ * @return snippet description.
+ */
public String getDescription();
+ /**
+ * Sets the image descriptor.
+ */
public void setImageDescriptor(ImageDescriptor imageDescriptor);
+ /**
+ * Gets the image descriptor.
+ *
+ * @return image descriptor.
+ */
public ImageDescriptor getImageDescriptor();
+ /**
+ * Sets the descriptor.
+ */
public void setDescriptor(IDescriptor descriptor);
+ /**
+ * Gets the descriptor.
+ *
+ * @return descriptor.
+ */
public IDescriptor getDescriptor();
}
\ No newline at end of file
public class Snippet implements ISnippet {
- private String id;
- private String name;
- private String description;
- private ImageDescriptor imageDescriptor;
- private IDescriptor descriptor;
+ private String id = null;
+ private String name = null;
+ private String description = null;
+ private ImageDescriptor imageDescriptor = null;
+ private IDescriptor descriptor = null;
public Snippet() {
super();
public class CreateWizard extends Wizard {
- private List<Part> parts;
- private CreateWizardFirstPage firstPage;
+ private List<Part> parts = null;
+ private CreateWizardFirstPage firstPage = null;
public CreateWizard(List<Part> parts) {
super();
public static final String NAME = CreateWizardFirstPage.class.getName();
// controls
- private Composite rootComposite;
+ private Composite rootComposite = null;
- private Composite imageComposite;
- private Label imageLabel;
- private Text imageText;
- private Button imageBrowseButton;
+ private Composite imageComposite = null;
+ private Label imageLabel = null;
+ private Text imageText = null;
+ private Button imageBrowseButton = null;
- private Composite nameComposite;
- private Label nameLabel;
- private Text nameText;
+ private Composite nameComposite = null;
+ private Label nameLabel = null;
+ private Text nameText = null;
- private Composite descriptionComposite;
- private Label descriptionLabel;
- private Text descriptionText;
+ private Composite descriptionComposite = null;
+ private Label descriptionLabel = null;
+ private Text descriptionText = null;
protected CreateWizardFirstPage(String pageName, String title, ImageDescriptor titleImage) {
super(pageName, title, titleImage);
public class ExportWizard extends Wizard implements IExportWizard {
- private ExportWizardFirstPage fFirstPage;
+ private ExportWizardFirstPage fFirstPage = null;
/*
* (non-Javadoc)
package org.tizen.webuibuilder.snippet.ui.wizards;
+import java.util.Collection;
import java.util.List;
import org.eclipse.jface.resource.ImageDescriptor;
public static final String NAME = ExportWizardFirstPage.class.getName();
// controls
- private Composite rootComposite;
+ private Composite rootComposite = null;
- private Composite snippetComposite;
- private Label snippetLabel;
- private Text snippetText;
- private TableViewer viewer;
+ private Composite snippetComposite = null;
+ private Label snippetLabel = null;
+ private Text snippetText = null;
+ private TableViewer viewer = null;
- private Composite pathComposite;
- private Label pathLabel;
- private Text pathText;
- private Button pathBrowseButton;
+ private Composite pathComposite = null;
+ private Label pathLabel = null;
+ private Text pathText = null;
+ private Button pathBrowseButton = null;
- private Composite nameComposite;
- private Label nameLabel;
- private Text nameText;
+ private Composite nameComposite = null;
+ private Label nameLabel = null;
+ private Text nameText = null;
- private ISnippet snippet;
+ private ISnippet snippet = null;
public ISnippet getSnippet() {
return snippet;
*/
@Override
public Object[] getElements(Object inputElement) {
- if (inputElement instanceof List) {
- List<?> descriptors = (List<?>) inputElement;
+ if (inputElement instanceof Collection) {
+ Collection<?> descriptors = (Collection<?>) inputElement;
return descriptors.toArray();
}
return null;
public class ImportWizard extends Wizard {
- private ImportWizardFirstPage firstPage;
+ private ImportWizardFirstPage firstPage = null;
public ImportWizard() {
super();
public static final String NAME = ImportWizardFirstPage.class.getName();
// controls
- private Composite rootComposite;
+ private Composite rootComposite = null;
- private Composite importComposite;
- private Label importLabel;
- private Text importText;
- private Button importBrowseButton;
+ private Composite importComposite = null;
+ private Label importLabel = null;
+ private Text importText = null;
+ private Button importBrowseButton = null;
- private Composite nameComposite;
- private Label nameLabel;
- private Text nameText;
+ private Composite nameComposite = null;
+ private Label nameLabel = null;
+ private Text nameText = null;
- private Composite descriptionComposite;
- private Label descriptionLabel;
- private Text descriptionText;
+ private Composite descriptionComposite = null;
+ private Label descriptionLabel = null;
+ private Text descriptionText = null;
- private ISnippet snippet;
+ private ISnippet snippet = null;
protected ImportWizardFirstPage(String pageName, String title, ImageDescriptor titleImage) {
super(pageName, title, titleImage);
package org.tizen.webuibuilder.snippet.ui.wizards.policy;
import java.io.File;
-import java.util.List;
import org.eclipse.jface.resource.ImageDescriptor;
import org.eclipse.swt.graphics.ImageData;
import org.eclipse.swt.graphics.ImageLoader;
import org.tizen.webuibuilder.model.Part;
-import org.tizen.webuibuilder.snippet.converter.Converter;
import org.tizen.webuibuilder.snippet.manager.ISnippetManager;
import org.tizen.webuibuilder.snippet.manager.SnippetManager;
import org.tizen.webuibuilder.snippet.model.Descriptor;
public class CreatePolicy implements IWizardPolicy {
- private List<Part> parts;
- private String name;
- private String description;
- private String imagePath;
+ private Object model = null;
+ private String name = null;
+ private String description = null;
+ private String imagePath = null;
@SuppressWarnings("unused")
private CreatePolicy() {
super();
}
- public CreatePolicy(List<Part> parts, String name, String description, String imagePath) {
- this.parts = parts;
+ public CreatePolicy(Object model, String name, String description, String imagePath) {
+ this.model = model;
this.name = name;
this.description = description;
this.imagePath = imagePath;
ImageLoader imageLoader = new ImageLoader();
ImageData[] imageData = imageLoader.load(imageFile.getPath());
ImageDescriptor imageDescriptor = ImageDescriptor.createFromImageData(imageData[0]);
- // Create Descriptor
snippet.setImageDescriptor(imageDescriptor);
+ // Create Descriptor
IDescriptor descriptor = new Descriptor();
- Converter converter = new Converter();
- String text = converter.convert(parts.get(0));
+ if (!(model instanceof Part)) {
+ return false;
+ }
+ // TODO : implementation Model -> String serialization
+// Converter converter = new Converter();
+// String text = converter.convert(parts.get(0));
+ String text = "";
descriptor.setText(text);
snippet.setDescriptor(descriptor);
public class ExportPolicy implements IWizardPolicy {
- private ISnippet snippet;
- private String exportPath;
- private String name;
+ private ISnippet snippet = null;
+ private String exportPath = null;
+ private String name = null;
private ExportPolicy() {
super();
public class ImportPolicy implements IWizardPolicy {
- private ISnippet snippet;
+ private ISnippet snippet = null;
private ImportPolicy() {
super();
private void addSnippetEntry(PaletteRoot root) {
PaletteDrawer snippetDrawer = createPaletteDrawer(DesignerMessages.ComponentsCreator_0);
SnippetManager snippetManager = new SnippetManager();
- List<ISnippet> snippets = snippetManager.getSnippets();
+ Collection<ISnippet> snippets = snippetManager.getSnippets();
if (snippets == null) {
return;
}