From 8bff03eb1959805168b8b2c46a561846455b16d7 Mon Sep 17 00:00:00 2001 From: "gyeongmin.ju" Date: Tue, 11 Mar 2014 10:44:25 +0900 Subject: [PATCH] UIB : rename tool package & add ToolConfig class Signed-off-by: gyeongmin.ju Change-Id: I4de22d7087ca12777b91a856d76ec5282207ebc4 --- .../gef/editparts/DesignerEditPart.java | 4 +- .../gef/editparts/HoverViewerEditPart.java | 2 +- .../tools/DesignDragAbsoluteEditPartsTracker.java | 2 +- .../tools/DesignDragEditPartsTracker.java | 2 +- .../tools/HoverViewerDragEditPartsTracker.java | 2 +- .../webuibuilder/model/project/ProjectManager.java | 83 +++------------------- .../org/tizen/webuibuilder/tool/ToolConfig.java | 83 ++++++++++++++++++++++ 7 files changed, 99 insertions(+), 79 deletions(-) rename org.tizen.webuibuilder/src/org/tizen/webuibuilder/{ => gef}/tools/DesignDragAbsoluteEditPartsTracker.java (98%) rename org.tizen.webuibuilder/src/org/tizen/webuibuilder/{ => gef}/tools/DesignDragEditPartsTracker.java (99%) rename org.tizen.webuibuilder/src/org/tizen/webuibuilder/{ => gef}/tools/HoverViewerDragEditPartsTracker.java (98%) create mode 100644 org.tizen.webuibuilder/src/org/tizen/webuibuilder/tool/ToolConfig.java diff --git a/org.tizen.webuibuilder/src/org/tizen/webuibuilder/gef/editparts/DesignerEditPart.java b/org.tizen.webuibuilder/src/org/tizen/webuibuilder/gef/editparts/DesignerEditPart.java index 7df3b04..4331980 100644 --- a/org.tizen.webuibuilder/src/org/tizen/webuibuilder/gef/editparts/DesignerEditPart.java +++ b/org.tizen.webuibuilder/src/org/tizen/webuibuilder/gef/editparts/DesignerEditPart.java @@ -39,10 +39,10 @@ import org.tizen.webuibuilder.gef.policies.DesignerAbsoluteDragEditPolicy; import org.tizen.webuibuilder.gef.policies.DesignerDragEditPolicy; import org.tizen.webuibuilder.gef.policies.DesignerSelectionEditPolicy; import org.tizen.webuibuilder.gef.policies.DesignerXYLayoutEditPolicy; +import org.tizen.webuibuilder.gef.tools.DesignDragAbsoluteEditPartsTracker; +import org.tizen.webuibuilder.gef.tools.DesignDragEditPartsTracker; import org.tizen.webuibuilder.model.Part; import org.tizen.webuibuilder.model.css.CssEvent; -import org.tizen.webuibuilder.tools.DesignDragAbsoluteEditPartsTracker; -import org.tizen.webuibuilder.tools.DesignDragEditPartsTracker; import org.tizen.webuibuilder.ui.editor.viewer.DesignerBrowserViewer; diff --git a/org.tizen.webuibuilder/src/org/tizen/webuibuilder/gef/editparts/HoverViewerEditPart.java b/org.tizen.webuibuilder/src/org/tizen/webuibuilder/gef/editparts/HoverViewerEditPart.java index f03f89b..3cf407b 100644 --- a/org.tizen.webuibuilder/src/org/tizen/webuibuilder/gef/editparts/HoverViewerEditPart.java +++ b/org.tizen.webuibuilder/src/org/tizen/webuibuilder/gef/editparts/HoverViewerEditPart.java @@ -48,12 +48,12 @@ 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.HoverViewerXYLayoutEditPolicy; +import org.tizen.webuibuilder.gef.tools.HoverViewerDragEditPartsTracker; import org.tizen.webuibuilder.model.IPartListener; import org.tizen.webuibuilder.model.Part; import org.tizen.webuibuilder.model.PartEvent; import org.tizen.webuibuilder.model.css.CssEvent; import org.tizen.webuibuilder.model.css.ICssListener; -import org.tizen.webuibuilder.tools.HoverViewerDragEditPartsTracker; import org.tizen.webuibuilder.ui.editor.ruler.DesignerGuide; import org.tizen.webuibuilder.ui.editor.viewer.HoverBrowserViewer; diff --git a/org.tizen.webuibuilder/src/org/tizen/webuibuilder/tools/DesignDragAbsoluteEditPartsTracker.java b/org.tizen.webuibuilder/src/org/tizen/webuibuilder/gef/tools/DesignDragAbsoluteEditPartsTracker.java similarity index 98% rename from org.tizen.webuibuilder/src/org/tizen/webuibuilder/tools/DesignDragAbsoluteEditPartsTracker.java rename to org.tizen.webuibuilder/src/org/tizen/webuibuilder/gef/tools/DesignDragAbsoluteEditPartsTracker.java index 67c6220..53c698f 100644 --- a/org.tizen.webuibuilder/src/org/tizen/webuibuilder/tools/DesignDragAbsoluteEditPartsTracker.java +++ b/org.tizen.webuibuilder/src/org/tizen/webuibuilder/gef/tools/DesignDragAbsoluteEditPartsTracker.java @@ -21,7 +21,7 @@ */ -package org.tizen.webuibuilder.tools; +package org.tizen.webuibuilder.gef.tools; import org.eclipse.gef.EditPart; import org.eclipse.gef.RequestConstants; diff --git a/org.tizen.webuibuilder/src/org/tizen/webuibuilder/tools/DesignDragEditPartsTracker.java b/org.tizen.webuibuilder/src/org/tizen/webuibuilder/gef/tools/DesignDragEditPartsTracker.java similarity index 99% rename from org.tizen.webuibuilder/src/org/tizen/webuibuilder/tools/DesignDragEditPartsTracker.java rename to org.tizen.webuibuilder/src/org/tizen/webuibuilder/gef/tools/DesignDragEditPartsTracker.java index b0c577d..68fe64a 100644 --- a/org.tizen.webuibuilder/src/org/tizen/webuibuilder/tools/DesignDragEditPartsTracker.java +++ b/org.tizen.webuibuilder/src/org/tizen/webuibuilder/gef/tools/DesignDragEditPartsTracker.java @@ -21,7 +21,7 @@ */ -package org.tizen.webuibuilder.tools; +package org.tizen.webuibuilder.gef.tools; import org.eclipse.draw2d.geometry.Point; import org.eclipse.gef.EditPart; diff --git a/org.tizen.webuibuilder/src/org/tizen/webuibuilder/tools/HoverViewerDragEditPartsTracker.java b/org.tizen.webuibuilder/src/org/tizen/webuibuilder/gef/tools/HoverViewerDragEditPartsTracker.java similarity index 98% rename from org.tizen.webuibuilder/src/org/tizen/webuibuilder/tools/HoverViewerDragEditPartsTracker.java rename to org.tizen.webuibuilder/src/org/tizen/webuibuilder/gef/tools/HoverViewerDragEditPartsTracker.java index 84923ee..2c8466c 100644 --- a/org.tizen.webuibuilder/src/org/tizen/webuibuilder/tools/HoverViewerDragEditPartsTracker.java +++ b/org.tizen.webuibuilder/src/org/tizen/webuibuilder/gef/tools/HoverViewerDragEditPartsTracker.java @@ -21,7 +21,7 @@ */ -package org.tizen.webuibuilder.tools; +package org.tizen.webuibuilder.gef.tools; import org.eclipse.gef.EditPart; import org.eclipse.gef.Request; diff --git a/org.tizen.webuibuilder/src/org/tizen/webuibuilder/model/project/ProjectManager.java b/org.tizen.webuibuilder/src/org/tizen/webuibuilder/model/project/ProjectManager.java index 24739e4..0ffa3d2 100644 --- a/org.tizen.webuibuilder/src/org/tizen/webuibuilder/model/project/ProjectManager.java +++ b/org.tizen.webuibuilder/src/org/tizen/webuibuilder/model/project/ProjectManager.java @@ -23,19 +23,9 @@ 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; @@ -44,24 +34,21 @@ import org.eclipse.core.runtime.IPath; 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; @@ -105,7 +92,9 @@ public class ProjectManager { 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() @@ -121,7 +110,7 @@ public class ProjectManager { + 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( @@ -200,62 +189,6 @@ public class ProjectManager { 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; } @@ -285,6 +218,10 @@ public class ProjectManager { public DescriptorManager getNewDescriptorManager() { return descriptorManager; } + + public ToolConfig getToolConfig() { + return toolConfig; + } public String getFileFullPath(String filename) { IFile file = project.getFile(filename); diff --git a/org.tizen.webuibuilder/src/org/tizen/webuibuilder/tool/ToolConfig.java b/org.tizen.webuibuilder/src/org/tizen/webuibuilder/tool/ToolConfig.java new file mode 100644 index 0000000..4acd27c --- /dev/null +++ b/org.tizen.webuibuilder/src/org/tizen/webuibuilder/tool/ToolConfig.java @@ -0,0 +1,83 @@ +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")) { + } + } + } + } + } + } + } +} -- 2.7.4