Author: penyaskito
Date: 2008-06-13 06:25:24-0700
New Revision: 14920
Added:
branches/xmlpropertypanels-penyaskito-soc08/argouml-core-propertypanels-scratch/src/org/argouml/core/propertypanels/panel/UIFactory.java (contents, props changed)
branches/xmlpropertypanels-penyaskito-soc08/argouml-core-propertypanels-scratch/src/org/argouml/core/propertypanels/xml/
branches/xmlpropertypanels-penyaskito-soc08/argouml-core-propertypanels-scratch/src/org/argouml/core/propertypanels/xml/UmlClass.xml (contents, props changed)
Modified:
branches/xmlpropertypanels-penyaskito-soc08/argouml-core-propertypanels-scratch/src/org/argouml/core/propertypanels/panel/XmlPropertyPanel.java
Log:
Added an sketch of how the logic for parsing XML will be.
Added: branches/xmlpropertypanels-penyaskito-soc08/argouml-core-propertypanels-scratch/src/org/argouml/core/propertypanels/panel/UIFactory.java
Url: http://argouml.tigris.org/source/browse/argouml/branches/xmlpropertypanels-penyaskito-soc08/argouml-core-propertypanels-scratch/src/org/argouml/core/propertypanels/panel/UIFactory.java?view=auto&rev=14920
==============================================================================
--- (empty file)
+++ branches/xmlpropertypanels-penyaskito-soc08/argouml-core-propertypanels-scratch/src/org/argouml/core/propertypanels/panel/UIFactory.java 2008-06-13 06:25:24-0700
@@ -0,0 +1,92 @@
+// $Id$
+// Copyright (c) 2008 The Regents of the University of California. All
+// Rights Reserved. Permission to use, copy, modify, and distribute this
+// software and its documentation without fee, and without a written
+// agreement is hereby granted, provided that the above copyright notice
+// and this paragraph appear in all copies. This software program and
+// documentation are copyrighted by The Regents of the University of
+// California. The software program and documentation are supplied "AS
+// IS", without any accompanying services from The Regents. The Regents
+// does not warrant that the operation of the program will be
+// uninterrupted or error-free. The end-user understands that the program
+// was developed for research purposes and is advised not to rely
+// exclusively on the program for any reason. IN NO EVENT SHALL THE
+// UNIVERSITY OF CALIFORNIA BE LIABLE TO ANY PARTY FOR DIRECT, INDIRECT,
+// SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES, INCLUDING LOST PROFITS,
+// ARISING OUT OF THE USE OF THIS SOFTWARE AND ITS DOCUMENTATION, EVEN IF
+// THE UNIVERSITY OF CALIFORNIA HAS BEEN ADVISED OF THE POSSIBILITY OF
+// SUCH DAMAGE. THE UNIVERSITY OF CALIFORNIA SPECIFICALLY DISCLAIMS ANY
+// WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
+// MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE SOFTWARE
+// PROVIDED HEREUNDER IS ON AN "AS IS" BASIS, AND THE UNIVERSITY OF
+// CALIFORNIA HAS NO OBLIGATIONS TO PROVIDE MAINTENANCE, SUPPORT,
+// UPDATES, ENHANCEMENTS, OR MODIFICATIONS.
+
+package org.argouml.core.propertypanels.panel;
+
+import java.awt.Panel;
+import java.io.FileInputStream;
+import java.io.FileNotFoundException;
+import java.io.IOException;
+
+import javax.swing.JLabel;
+import javax.swing.JPanel;
+
+import org.apache.log4j.Logger;
+import org.xml.sax.InputSource;
+import org.xml.sax.SAXException;
+import org.xml.sax.XMLReader;
+import org.xml.sax.helpers.XMLReaderFactory;
+
+// TODO: This class will be an interface or abstract class
+// and will be implemented by SwingUIFactory and SwtUIFactory.
+public class UIFactory {
+
+ /**
+ * Logger.
+ */
+ private static final Logger LOG = Logger.getLogger(UIFactory.class);
+
+ private static UIFactory INSTANCE = new UIFactory();
+
+ public UIFactory() {
+
+ }
+
+ public static UIFactory getInstance() {
+ return INSTANCE;
+ }
+
+ // TODO: This will be a template method, where there will be two
+ // implementations, for Swing and for SWT.
+ public JPanel createGUI (Object target) throws Exception {
+ JPanel p = new JPanel();
+ p.add(new JLabel("Test label from code"));
+ String filename = getXMLFileName(target);
+ LOG.info("[XMLPP] filename is:" + filename);
+ // parseXML(filename);
+ return p;
+ }
+
+ private String getXMLFileName(Object target) {
+ String classname = target.getClass().getSimpleName();
+ // TODO: I don't like this hack, it may exist a better way.
+ return classname.replace("$Impl", "");
+ }
+
+ public void parseXML(String filename)
+ throws Exception {
+ // TODO: I have to investigate how to read the XML.
+ // There are some different APIs available, but
+ // I'll choose SAX because it's the one API used in
+ // PGML, so we don't have different APIs in Argo.
+ XMLReader parser = XMLReaderFactory.createXMLReader(
+ "org.apache.xerces.parsers.SAXParser"
+ );
+ String file = "/org/argouml/core/propertypanels/xml/"
+ + filename;
+ FileInputStream stream = new FileInputStream(file);
+ InputSource source = new InputSource(stream);
+ parser.parse(source);
+ }
+}
Modified: branches/xmlpropertypanels-penyaskito-soc08/argouml-core-propertypanels-scratch/src/org/argouml/core/propertypanels/panel/XmlPropertyPanel.java
Url: http://argouml.tigris.org/source/browse/argouml/branches/xmlpropertypanels-penyaskito-soc08/argouml-core-propertypanels-scratch/src/org/argouml/core/propertypanels/panel/XmlPropertyPanel.java?view=diff&rev=14920&p1=branches/xmlpropertypanels-penyaskito-soc08/argouml-core-propertypanels-scratch/src/org/argouml/core/propertypanels/panel/XmlPropertyPanel.java&p2=branches/xmlpropertypanels-penyaskito-soc08/argouml-core-propertypanels-scratch/src/org/argouml/core/propertypanels/panel/XmlPropertyPanel.java&r1=14919&r2=14920
==============================================================================
--- branches/xmlpropertypanels-penyaskito-soc08/argouml-core-propertypanels-scratch/src/org/argouml/core/propertypanels/panel/XmlPropertyPanel.java (original)
+++ branches/xmlpropertypanels-penyaskito-soc08/argouml-core-propertypanels-scratch/src/org/argouml/core/propertypanels/panel/XmlPropertyPanel.java 2008-06-13 06:25:24-0700
@@ -25,6 +25,8 @@
package org.argouml.core.propertypanels.panel;
import javax.swing.ImageIcon;
+import javax.swing.JPanel;
+import javax.swing.JScrollPane;
import org.apache.log4j.Logger;
import org.argouml.ui.TabFigTarget;
@@ -36,10 +38,9 @@
* Logger.
*/
private static final Logger LOG = Logger.getLogger(XmlPropertyPanel.class);
-
public XmlPropertyPanel(String label, ImageIcon icon) {
- super(label, icon);
+ super(label, icon);
}
/**
@@ -70,5 +71,14 @@
// Our XML can be called Class.xml or if we split the
// UI and the model info, Class.ui.xml and Class.model.xml
LOG.info("[XMLPP] t is type:" + t.getClass());
+
+ JPanel panel;
+ try {
+ panel = UIFactory.getInstance().createGUI(t);
+ this.add(panel);
+ } catch (Exception e) {
+ // TODO: Auto-generated catch block
+ LOG.error("Exception", e);
+ }
}
}
Added: branches/xmlpropertypanels-penyaskito-soc08/argouml-core-propertypanels-scratch/src/org/argouml/core/propertypanels/xml/UmlClass.xml
Url: http://argouml.tigris.org/source/browse/argouml/branches/xmlpropertypanels-penyaskito-soc08/argouml-core-propertypanels-scratch/src/org/argouml/core/propertypanels/xml/UmlClass.xml?view=auto&rev=14920
==============================================================================
--- (empty file)
+++ branches/xmlpropertypanels-penyaskito-soc08/argouml-core-propertypanels-scratch/src/org/argouml/core/propertypanels/xml/UmlClass.xml 2008-06-13 06:25:24-0700
@@ -0,0 +1,4 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<panel>
+ <label text="This is a test from XML" />
+</panel>
lmpx.com only provides a reader for public news (NNTP) servers. It is not
affiliated with the servers or forums shown here and is not responsible for
the content of articles, which is written by their respective authors.