Commit 531fa289 authored by Marco Konersmann's avatar Marco Konersmann

Refactoring and replaces modals with messages.

parent 483f46b9
Pipeline #1313 failed with stage
in 50 seconds
......@@ -2,9 +2,9 @@
<classpath>
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.8"/>
<classpathentry kind="con" path="org.eclipse.pde.core.requiredPlugins"/>
<classpathentry kind="src" path="src"/>
<classpathentry kind="src" path="templates"/>
<classpathentry kind="src" path="res"/>
<classpathentry kind="lib" path="xstream-1.4.9.jar"/>
<classpathentry kind="src" path="src/"/>
<classpathentry kind="src" path="templates/"/>
<classpathentry kind="src" path="res/"/>
<classpathentry exported="true" kind="lib" path="xstream-1.4.9.jar"/>
<classpathentry kind="output" path="target/classes"/>
</classpath>
......@@ -5,3 +5,4 @@ org.eclipse.jdt.core.compiler.compliance=1.8
org.eclipse.jdt.core.compiler.problem.assertIdentifier=error
org.eclipse.jdt.core.compiler.problem.enumIdentifier=error
org.eclipse.jdt.core.compiler.source=1.8
org.eclipse.objectteams.otdt.compiler.option.pure_java=enabled
......@@ -43,6 +43,7 @@ import javax.swing.event.TreeWillExpandListener;
import javax.swing.filechooser.FileNameExtensionFilter;
import javax.swing.tree.DefaultMutableTreeNode;
import javax.swing.tree.DefaultTreeModel;
import javax.swing.tree.MutableTreeNode;
import javax.swing.tree.TreeNode;
import javax.swing.tree.TreePath;
......@@ -52,7 +53,7 @@ import org.codeling.mechanisms.classes.MarkerInterfaceMechanism;
import org.codeling.mechanisms.classes.TypeAnnotationMechanism;
import org.codeling.mechanisms.containment.ContainmentOperationMechanism;
import org.codeling.mechanisms.references.AnnotatedMemberReferenceMechanism;
import org.codeling.mechanisms.references.ReferenceParameterMechanism;
import org.codeling.mechanisms.references.ContainmentOperationReferenceMechanism;
import org.eclipse.core.runtime.CoreException;
import org.eclipse.emf.ecore.EAttribute;
import org.eclipse.emf.ecore.EClass;
......@@ -85,8 +86,8 @@ public class MechanismSelectionGUI extends JFrame {
private final JFrame thisFrame = this;
DefaultMutableTreeNode root;
DefaultMutableTreeNode invisibleRoot;
JList list;
DefaultListModel model;
JList<String> list;
DefaultListModel<String> model;
JScrollPane listpane;
String deselect;
boolean output = false;
......@@ -135,8 +136,8 @@ public class MechanismSelectionGUI extends JFrame {
}
private void createErrorList() {
model = new DefaultListModel();
list = new JList(model);
model = new DefaultListModel<String>();
list = new JList<String>(model);
listpane = new JScrollPane(list);
contentPane.add(listpane);
}
......@@ -169,7 +170,7 @@ public class MechanismSelectionGUI extends JFrame {
chkInheritance.setEnabled(true);
chkInheritance.setSelected(true);
chkInheritance.setBounds(10, 405, 25, 25);
contentPane.add(chkInheritance);
contentPane.add(chkInheritance);
lblInheritance = new JLabel();
lblInheritance.setText("create inherited attributes");
......@@ -179,13 +180,16 @@ public class MechanismSelectionGUI extends JFrame {
private void createScrollPane() {
scrollPane = new JScrollPane();
scrollPane.getViewport().addChangeListener(e -> {
hideSelectionBoxes();
addSelectionBoxes();
});
scrollPane.getViewport().addChangeListener(
e -> {
hideSelectionBoxes();
addSelectionBoxes();
});
scrollPane.setBounds(10, 10, width - 260, heigth - 100);
contentPane.add(scrollPane);
}
private void createJTRee() {
......@@ -376,27 +380,6 @@ public class MechanismSelectionGUI extends JFrame {
}
private void showFinishedDialog() {
JOptionPane.showMessageDialog(this, "Fininshed creating Code", "Inane warning",
JOptionPane.INFORMATION_MESSAGE);
}
private void showSaveDialog() {
JOptionPane.showMessageDialog(this, "Fininshed saving selection!", "Inane warning",
JOptionPane.INFORMATION_MESSAGE);
}
private void showLoadedDialog() {
JOptionPane.showMessageDialog(this, "Fininshed loading selection!", "Inane warning",
JOptionPane.INFORMATION_MESSAGE);
}
// ------------------------Ende der GUI
// Elemente---------------------------//
// ------------------------Listener &
......@@ -426,6 +409,7 @@ public class MechanismSelectionGUI extends JFrame {
public void mouseClicked(MouseEvent e) {
setMechanisms();
try {
generatorClass.fillMechanismsMap(tree);
generatorClass.generateCode(tree, chkInheritance.isSelected());
} catch (final CoreException e1) {
e1.printStackTrace();
......@@ -433,7 +417,7 @@ public class MechanismSelectionGUI extends JFrame {
"Inane warning", JOptionPane.ERROR_MESSAGE);
}
showFinishedDialog();
model.addElement("Fininshed to create code");
}
};
......@@ -463,7 +447,7 @@ public class MechanismSelectionGUI extends JFrame {
}
createMappingXML(f, mapping);
// showSaveDialog();
model.addElement("Saved to file " + f.getAbsolutePath());
}
};
......@@ -496,7 +480,7 @@ public class MechanismSelectionGUI extends JFrame {
}
}
}
showLoadedDialog();
model.addElement("Loaded from file " + f.getAbsolutePath());
}
};
......@@ -993,7 +977,7 @@ public class MechanismSelectionGUI extends JFrame {
listOfAttributeMechanisms.add(noop);
listOfReferenceMechanisms.add(new AnnotatedMemberReferenceMechanism());
listOfReferenceMechanisms.add(new ReferenceParameterMechanism());
listOfReferenceMechanisms.add(new ContainmentOperationReferenceMechanism());
listOfReferenceMechanisms.add(noop);
listOfContainmentMechanisms.add(new AnnotatedMemberReferenceMechanism());
......
......@@ -20,6 +20,8 @@ import javax.swing.tree.TreeNode;
import org.codeling.mechanisms.ClassMechanism;
import org.codeling.mechanisms.Mechanism;
import org.codeling.mechanisms.MechanismsMapping;
import org.codeling.mechanisms.containment.ContainmentOperationMechanism;
import org.eclipse.core.resources.IFile;
import org.eclipse.core.resources.IFolder;
import org.eclipse.core.resources.IProject;
......@@ -196,6 +198,32 @@ public class IntegrationMechanismCodeGenerator {
}
}
public void fillMechanismsMap(JTree tree) {
final MutableTreeNode rootNode = (MutableTreeNode) tree.getModel().getRoot();
if (rootNode == null)
return;
queue.clear();
queue.add(rootNode);
while (!queue.isEmpty()) {
final TreeNode node = queue.remove();
// Process node
if (node instanceof EObjectTreeNode) {
final EObjectTreeNode eNode = (EObjectTreeNode) node;
final ENamedElement heldObject = (ENamedElement) eNode.getObjectToHold();
final Mechanism mechanism = eNode.getTargetMechanism();
MechanismsMapping.getInstance().put(heldObject, mechanism.getClass());
}
if (node.getAllowsChildren()) {
for (int i = 0; i < node.getChildCount(); i++) {
queue.add(node.getChildAt(i));
}
}
}
}
private void generateMechanisms(TreeNode node, final IPackageFragmentRoot mm_srcFolder,
IPackageFragmentRoot transformation_srcFolder, IPackageFragmentRoot runtime_srcFolder,
Map<ENamedElement, IJavaElement> modelToCodeMap) throws JavaModelException, URISyntaxException, IOException,
......@@ -203,11 +231,18 @@ public class IntegrationMechanismCodeGenerator {
if (node instanceof EObjectTreeNode) {
final EObjectTreeNode eNode = (EObjectTreeNode) node;
final EObject heldObject = eNode.getObjectToHold();
final ENamedElement heldObject = (ENamedElement) eNode.getObjectToHold();
final Mechanism mechanism = eNode.getTargetMechanism();
if (mechanism instanceof ClassMechanism)
((ClassMechanism) mechanism).setEClass((EClass) heldObject);
MechanismsMapping.getInstance().put(heldObject, mechanism.getClass());
if (mechanism instanceof ClassMechanism) {
ENamedElement target = heldObject;
if (mechanism instanceof ContainmentOperationMechanism)
target = ((EReference) heldObject).getEType();
// The containment operation mechanism is special, because it
// represents a reference *and* the target
((ClassMechanism) mechanism).setEClass((EClass) target);
}
mechanism.setModelToCodeMap(modelToCodeMap);
mechanism.setLanguageName(modelName);
......@@ -216,15 +251,14 @@ public class IntegrationMechanismCodeGenerator {
if (!(heldObject instanceof EAttribute && ("name".equals(((EAttribute) heldObject).getName())
|| "id".equals(((EAttribute) heldObject).getName())))) {
IPackageFragment fragment = createPackageFragment("mm", heldObject, mm_srcFolder);
final IJavaElement mmCodeElement = mechanism.createMetaModelLibrary(fragment,
(ENamedElement) heldObject);
modelToCodeMap.put((ENamedElement) heldObject, mmCodeElement);
final IJavaElement mmCodeElement = mechanism.createMetaModelLibrary(fragment, heldObject);
modelToCodeMap.put(heldObject, mmCodeElement);
fragment = createPackageFragment("transformation", heldObject, transformation_srcFolder);
mechanism.createTransformation(fragment, (ENamedElement) heldObject);
mechanism.createTransformation(fragment, heldObject);
fragment = createPackageFragment("runtime", heldObject, runtime_srcFolder);
mechanism.createRuntime(fragment, (ENamedElement) heldObject);
mechanism.createRuntime(fragment, heldObject);
}
}
......
......@@ -16,9 +16,10 @@ Require-Bundle: org.eclipse.ui,
org.eclipse.gmf.runtime.notation;bundle-version="1.8.0",
org.eclipse.emf.ecore,
com.google.guava,
utils;bundle-version="1.0.0",
java.embed.transformation;bundle-version="1.0.0",
utils,
java.embed.transformation,
mechanisms,
codeling.test.common
%s;bundle-version="%s"
Bundle-RequiredExecutionEnvironment: JavaSE-1.8
Bundle-ActivationPolicy: lazy
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment