better gui and can now extend other class in the class name

This commit is contained in:
nora 2020-11-20 18:28:01 +01:00
parent 6d76166b3c
commit c970867916
4 changed files with 24 additions and 20 deletions

View file

@ -15,7 +15,7 @@ public class UMLClass {
String[] lines = classDiagram.split("\n"); String[] lines = classDiagram.split("\n");
String[] linesBeheaded = new String[lines.length-1]; String[] linesBeheaded = new String[lines.length-1];
this.name = lines[0]; this.name = lines[0].split(" ")[0];
System.arraycopy(lines, 1, linesBeheaded, 0, linesBeheaded.length); System.arraycopy(lines, 1, linesBeheaded, 0, linesBeheaded.length);

View file

@ -17,7 +17,7 @@
<properties/> <properties/>
<border type="none"/> <border type="none"/>
<children> <children>
<grid id="fc27a" layout-manager="GridLayoutManager" row-count="3" column-count="2" same-size-horizontally="false" same-size-vertically="false" hgap="-1" vgap="-1"> <grid id="fc27a" layout-manager="GridLayoutManager" row-count="4" column-count="2" same-size-horizontally="false" same-size-vertically="false" hgap="-1" vgap="-1">
<margin top="0" left="0" bottom="0" right="0"/> <margin top="0" left="0" bottom="0" right="0"/>
<constraints> <constraints>
<tabbedpane title="File Mode"/> <tabbedpane title="File Mode"/>
@ -33,11 +33,6 @@
<text value=" .uxf File Path:"/> <text value=" .uxf File Path:"/>
</properties> </properties>
</component> </component>
<vspacer id="8c974">
<constraints>
<grid row="2" column="0" row-span="1" col-span="1" vsize-policy="6" hsize-policy="1" anchor="0" fill="2" indent="0" use-parent-layout="false"/>
</constraints>
</vspacer>
<component id="a9bfd" class="javax.swing.JTextField" binding="pathField"> <component id="a9bfd" class="javax.swing.JTextField" binding="pathField">
<constraints> <constraints>
<grid row="0" column="1" row-span="1" col-span="1" vsize-policy="0" hsize-policy="6" anchor="8" fill="1" indent="0" use-parent-layout="false"> <grid row="0" column="1" row-span="1" col-span="1" vsize-policy="0" hsize-policy="6" anchor="8" fill="1" indent="0" use-parent-layout="false">
@ -48,7 +43,7 @@
</component> </component>
<component id="fa74" class="javax.swing.JButton" binding="convertFileButton"> <component id="fa74" class="javax.swing.JButton" binding="convertFileButton">
<constraints> <constraints>
<grid row="2" column="1" row-span="1" col-span="1" vsize-policy="0" hsize-policy="3" anchor="0" fill="1" indent="0" use-parent-layout="false"/> <grid row="2" column="0" row-span="1" col-span="2" vsize-policy="0" hsize-policy="3" anchor="0" fill="1" indent="0" use-parent-layout="false"/>
</constraints> </constraints>
<properties> <properties>
<text value="convert"/> <text value="convert"/>
@ -59,6 +54,7 @@
<grid row="1" column="0" row-span="1" col-span="1" vsize-policy="0" hsize-policy="0" anchor="8" fill="0" indent="0" use-parent-layout="false"/> <grid row="1" column="0" row-span="1" col-span="1" vsize-policy="0" hsize-policy="0" anchor="8" fill="0" indent="0" use-parent-layout="false"/>
</constraints> </constraints>
<properties> <properties>
<labelFor value="96709"/>
<text value="Package Destination Path"/> <text value="Package Destination Path"/>
</properties> </properties>
</component> </component>
@ -70,6 +66,11 @@
</constraints> </constraints>
<properties/> <properties/>
</component> </component>
<vspacer id="1a17d">
<constraints>
<grid row="3" column="0" row-span="1" col-span="2" vsize-policy="6" hsize-policy="1" anchor="0" fill="2" indent="0" use-parent-layout="false"/>
</constraints>
</vspacer>
</children> </children>
</grid> </grid>
<grid id="425fa" layout-manager="GridLayoutManager" row-count="2" column-count="1" same-size-horizontally="false" same-size-vertically="false" hgap="-1" vgap="-1"> <grid id="425fa" layout-manager="GridLayoutManager" row-count="2" column-count="1" same-size-horizontally="false" same-size-vertically="false" hgap="-1" vgap="-1">

View file

@ -9,8 +9,7 @@ public class UMLConverterMain {
new UMLManager(view); new UMLManager(view);
frame.setContentPane(view.getPanel1()); frame.setContentPane(view.getPanel1());
frame.setDefaultCloseOperation(WindowConstants.EXIT_ON_CLOSE); frame.setDefaultCloseOperation(WindowConstants.EXIT_ON_CLOSE);
frame.pack(); frame.setSize(700, 500);
//frame.setExtendedState(Frame.MAXIMIZED_BOTH);
frame.setVisible(true); frame.setVisible(true);
} }

View file

@ -14,6 +14,7 @@ import java.util.ArrayList;
public class XMLParser { public class XMLParser {
private Document doc; private Document doc;
private boolean valid;
public XMLParser(String path) { public XMLParser(String path) {
try { try {
@ -21,8 +22,8 @@ public class XMLParser {
DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance(); DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance();
DocumentBuilder builder = factory.newDocumentBuilder(); DocumentBuilder builder = factory.newDocumentBuilder();
doc = builder.parse(inputFile); doc = builder.parse(inputFile);
} catch (ParserConfigurationException | SAXException | IOException e){ valid = true;
e.printStackTrace(); } catch (ParserConfigurationException | SAXException | IOException ignored){
} }
} }
@ -30,20 +31,23 @@ public class XMLParser {
ArrayList<String> classes = new ArrayList<>(); ArrayList<String> classes = new ArrayList<>();
NodeList nList = doc.getDocumentElement().getElementsByTagName("element"); if(valid) {
for (int i = 0; i < nList.getLength(); i++) { NodeList nList = doc.getDocumentElement().getElementsByTagName("element");
Node node = nList.item(i);
if (node.getNodeType() == Node.ELEMENT_NODE){ for (int i = 0; i < nList.getLength(); i++) {
Node node = nList.item(i);
Element element = (Element) node; if (node.getNodeType() == Node.ELEMENT_NODE) {
if(element.getElementsByTagName("id").item(0).getTextContent().equals("UMLClass")){ Element element = (Element) node;
String classBody = element.getElementsByTagName("panel_attributes").item(0).getTextContent(); if (element.getElementsByTagName("id").item(0).getTextContent().equals("UMLClass")) {
classes.add(classBody);
String classBody = element.getElementsByTagName("panel_attributes").item(0).getTextContent();
classes.add(classBody);
}
} }
} }
} }