package org.tizen.webuibuilder.model.project;
import java.io.File;
-import java.io.IOException;
import java.util.ArrayList;
import java.util.List;
-import javax.xml.parsers.DocumentBuilder;
-import javax.xml.parsers.DocumentBuilderFactory;
-import javax.xml.parsers.ParserConfigurationException;
-
-import org.w3c.dom.Document;
-import org.w3c.dom.Element;
-import org.w3c.dom.Node;
-import org.w3c.dom.NodeList;
-import org.xml.sax.SAXException;
import org.eclipse.core.resources.IFile;
import org.eclipse.core.resources.IProject;
import org.eclipse.core.resources.IProjectNature;
import org.eclipse.core.runtime.Path;
import org.eclipse.ui.IWorkbenchWindow;
import org.eclipse.ui.PlatformUI;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
import org.tizen.webuibuilder.BuilderConstants;
import org.tizen.webuibuilder.animator.model.part.AnimatorPartFactory;
import org.tizen.webuibuilder.animator.perspective.AnimatorPerspectiveListener;
-import org.tizen.webuibuilder.model.PartFactory;
import org.tizen.webuibuilder.model.app.AppManager;
import org.tizen.webuibuilder.model.app.AppManagerForAppXML;
import org.tizen.webuibuilder.model.descriptors.DescriptorManager;
-import org.tizen.webuibuilder.model.io.FileReader;
import org.tizen.webuibuilder.nature.WebUIBuilderNature;
+import org.tizen.webuibuilder.tool.ToolConfig;
import org.tizen.webuibuilder.utility.ResourceManager;
public class ProjectManager {
private DevicePreset device;
- private String descriptorFilePath;
+ private ToolConfig toolConfig;
private DescriptorManager descriptorManagerOld = null;
private DescriptorManager descriptorManager = null;
BuilderConstants.DESCRIPTOR_DIR_OLD).toString());
}
- loadToolPath(projectPath.toOSString() + BuilderConstants.SLASH
+ toolConfig = new ToolConfig();
+
+ toolConfig.loadToolPath(projectPath.toOSString() + BuilderConstants.SLASH
+ BuilderConstants.TIZEN_UI_BUILDER_TOOL_FILE);
IPath descriptorPathOld = new Path(projectPath.toOSString()
+ BuilderConstants.SLASH
+ BuilderConstants.TIZEN_UI_BUILDER_TOOL_DIR
+ BuilderConstants.SLASH
- + /* BuilderConstants.DESCRIPTOR_DIR */descriptorFilePath);
+ + /* BuilderConstants.DESCRIPTOR_DIR */toolConfig.getDescriptorFilePath());
File descriptorFile = descriptorPath.append(
BuilderConstants.DESCRIPTOR_FILE).toFile();
File cssDescriptorFile = descriptorPath.append(
return ((WebUIBuilderNature) projectNature).getProjectManager();
}
- private void loadToolPath(String filePath) {
- DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance();
- DocumentBuilder builder = null;
- Document doc = null;
-
- try {
- builder = factory.newDocumentBuilder();
- doc = builder.parse(new File(filePath));
- } catch (ParserConfigurationException e) {
- e.printStackTrace();
- } catch (SAXException e) {
- e.printStackTrace();
- } catch (IOException e) {
- Logger logger = LoggerFactory.getLogger(PartFactory.class);
- logger.error(BuilderConstants.LOG_READ_PAGE_ERROR);
- if (doc == null) {
- return;
- }
- }
-
- if (doc != null && doc.getDocumentElement() != null) {
- Element root = doc.getDocumentElement();
- FileReader fileReader = new FileReader(root);
- if (!fileReader.isValidate()) {
- return;
- }
- if (!fileReader.getType().equals("tizen-ui-builder-tool")) {
- return;
- }
- if (!fileReader.getVersion().equals("0.0.1")) {
- return;
- }
-
- NodeList elemList = root.getElementsByTagName("tizenToolPath");
- if (elemList.getLength() > 0) {
- Node firstChild = elemList.item(0);
- if (firstChild instanceof Element) {
- elemList = firstChild.getChildNodes();
- for (int i = 0; i < elemList.getLength(); i++) {
- Node childNode = elemList.item(i);
- if (childNode instanceof Element) {
- if (childNode.getNodeName().equals("descriptor")) {
- descriptorFilePath = ((Element) childNode)
- .getTextContent().trim();
- } else if (childNode.getNodeName().equals(
- "descriptorIcons")) {
- } else if (childNode.getNodeName().equals(
- "buildXslt")) {
- }
- }
- }
- }
- }
- }
- }
-
public AppManager getDefaultAppManager() {
return defaultAppManager;
}
public DescriptorManager getNewDescriptorManager() {
return descriptorManager;
}
+
+ public ToolConfig getToolConfig() {
+ return toolConfig;
+ }
public String getFileFullPath(String filename) {
IFile file = project.getFile(filename);
--- /dev/null
+package org.tizen.webuibuilder.tool;
+
+import java.io.File;
+import java.io.IOException;
+
+import javax.xml.parsers.DocumentBuilder;
+import javax.xml.parsers.DocumentBuilderFactory;
+import javax.xml.parsers.ParserConfigurationException;
+
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import org.tizen.webuibuilder.BuilderConstants;
+import org.tizen.webuibuilder.model.PartFactory;
+import org.tizen.webuibuilder.model.io.FileReader;
+import org.w3c.dom.Document;
+import org.w3c.dom.Element;
+import org.w3c.dom.Node;
+import org.w3c.dom.NodeList;
+import org.xml.sax.SAXException;
+
+public class ToolConfig {
+ private String descriptorFilePath;
+
+ public String getDescriptorFilePath() {
+ return descriptorFilePath;
+ }
+
+ public void loadToolPath(String filePath) {
+ DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance();
+ DocumentBuilder builder = null;
+ Document doc = null;
+
+ try {
+ builder = factory.newDocumentBuilder();
+ doc = builder.parse(new File(filePath));
+ } catch (ParserConfigurationException e) {
+ e.printStackTrace();
+ } catch (SAXException e) {
+ e.printStackTrace();
+ } catch (IOException e) {
+ Logger logger = LoggerFactory.getLogger(PartFactory.class);
+ logger.error(BuilderConstants.LOG_READ_PAGE_ERROR);
+ if (doc == null) {
+ return;
+ }
+ }
+
+ if (doc != null && doc.getDocumentElement() != null) {
+ Element root = doc.getDocumentElement();
+ FileReader fileReader = new FileReader(root);
+ if (!fileReader.isValidate()) {
+ return;
+ }
+ if (!fileReader.getType().equals("tizen-ui-builder-tool")) {
+ return;
+ }
+ if (!fileReader.getVersion().equals("0.0.1")) {
+ return;
+ }
+
+ NodeList elemList = root.getElementsByTagName("tizenToolPath");
+ if (elemList.getLength() > 0) {
+ Node firstChild = elemList.item(0);
+ if (firstChild instanceof Element) {
+ elemList = firstChild.getChildNodes();
+ for (int i = 0; i < elemList.getLength(); i++) {
+ Node childNode = elemList.item(i);
+ if (childNode instanceof Element) {
+ if (childNode.getNodeName().equals("descriptor")) {
+ descriptorFilePath = ((Element) childNode)
+ .getTextContent().trim();
+ } else if (childNode.getNodeName().equals(
+ "descriptorIcons")) {
+ } else if (childNode.getNodeName().equals(
+ "buildXslt")) {
+ }
+ }
+ }
+ }
+ }
+ }
+ }
+}