diff --git a/configuration_extractor/.classpath b/configuration_extractor/.classpath new file mode 100644 index 0000000000000000000000000000000000000000..e1a209794014846cc58e220b5c2936a88cda19a5 --- /dev/null +++ b/configuration_extractor/.classpath @@ -0,0 +1,8 @@ +<?xml version="1.0" encoding="UTF-8"?> +<classpath> + <classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.6"/> + <classpathentry kind="src" path="src"/> + <classpathentry kind="lib" path="C:/Users/Alexander/Desktop/jdom.jar"/> + <classpathentry kind="con" path="org.eclipse.pde.core.requiredPlugins"/> + <classpathentry kind="output" path="bin"/> +</classpath> diff --git a/configuration_extractor/.project b/configuration_extractor/.project new file mode 100644 index 0000000000000000000000000000000000000000..8e6cd58369f9256236a902abcc2f079965d2bb80 --- /dev/null +++ b/configuration_extractor/.project @@ -0,0 +1,34 @@ +<?xml version="1.0" encoding="UTF-8"?> +<projectDescription> + <name>Configuration Extractor</name> + <comment></comment> + <projects> + </projects> + <buildSpec> + <buildCommand> + <name>org.eclipse.jdt.core.javabuilder</name> + <arguments> + </arguments> + </buildCommand> + <buildCommand> + <name>org.eclipse.pde.ManifestBuilder</name> + <arguments> + </arguments> + </buildCommand> + <buildCommand> + <name>org.eclipse.pde.SchemaBuilder</name> + <arguments> + </arguments> + </buildCommand> + <buildCommand> + <name>org.maven.ide.eclipse.maven2Builder</name> + <arguments> + </arguments> + </buildCommand> + </buildSpec> + <natures> + <nature>org.maven.ide.eclipse.maven2Nature</nature> + <nature>org.eclipse.pde.PluginNature</nature> + <nature>org.eclipse.jdt.core.javanature</nature> + </natures> +</projectDescription> diff --git a/configuration_extractor/.settings/org.eclipse.jdt.core.prefs b/configuration_extractor/.settings/org.eclipse.jdt.core.prefs new file mode 100644 index 0000000000000000000000000000000000000000..f5f1916e5e70c7514650a0176eb62337808bc0c4 --- /dev/null +++ b/configuration_extractor/.settings/org.eclipse.jdt.core.prefs @@ -0,0 +1,8 @@ +#Wed Nov 24 15:17:29 CET 2010 +eclipse.preferences.version=1 +org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled +org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.6 +org.eclipse.jdt.core.compiler.compliance=1.6 +org.eclipse.jdt.core.compiler.problem.assertIdentifier=error +org.eclipse.jdt.core.compiler.problem.enumIdentifier=error +org.eclipse.jdt.core.compiler.source=1.6 diff --git a/configuration_extractor/.settings/org.maven.ide.eclipse.prefs b/configuration_extractor/.settings/org.maven.ide.eclipse.prefs new file mode 100644 index 0000000000000000000000000000000000000000..1cc577e8e26c673a8bfc8a08638a36f406616bf3 --- /dev/null +++ b/configuration_extractor/.settings/org.maven.ide.eclipse.prefs @@ -0,0 +1,8 @@ +#Fri Jan 07 14:15:23 CET 2011 +activeProfiles= +eclipse.preferences.version=1 +fullBuildGoals=process-test-resources +resolveWorkspaceProjects=true +resourceFilterGoals=process-resources resources\:testResources +skipCompilerPlugin=true +version=1 diff --git a/configuration_extractor/META-INF/MANIFEST.MF b/configuration_extractor/META-INF/MANIFEST.MF new file mode 100644 index 0000000000000000000000000000000000000000..15b7a3ca5d31dad6c8978266af062be6ff0e32ac --- /dev/null +++ b/configuration_extractor/META-INF/MANIFEST.MF @@ -0,0 +1,12 @@ +Manifest-Version: 1.0 +Bundle-ManifestVersion: 2 +Bundle-Name: Configuration_Extractor +Bundle-SymbolicName: Configuration_Extractor; singleton:=true +Bundle-Version: 1.0.0.qualifier +Bundle-Activator: configuration_extractor.Activator +Require-Bundle: org.eclipse.ui, + org.eclipse.core.runtime +Bundle-ActivationPolicy: lazy +Bundle-RequiredExecutionEnvironment: JavaSE-1.6 +Bundle-ClassPath: ., + lib/jdom.jar diff --git a/configuration_extractor/bin/configuration_extractor/Activator.class b/configuration_extractor/bin/configuration_extractor/Activator.class new file mode 100644 index 0000000000000000000000000000000000000000..2aa44183c676429fe0c6c7da9a1ee365fbe3c3ff Binary files /dev/null and b/configuration_extractor/bin/configuration_extractor/Activator.class differ diff --git a/configuration_extractor/bin/configuration_extractor/actions/SampleAction.class b/configuration_extractor/bin/configuration_extractor/actions/SampleAction.class new file mode 100644 index 0000000000000000000000000000000000000000..063b878be7d21106a3e32f771fd182530a81b087 Binary files /dev/null and b/configuration_extractor/bin/configuration_extractor/actions/SampleAction.class differ diff --git a/configuration_extractor/build.properties b/configuration_extractor/build.properties new file mode 100644 index 0000000000000000000000000000000000000000..0f269509aaa98011302ab5f80333e7af40d99f9c --- /dev/null +++ b/configuration_extractor/build.properties @@ -0,0 +1,7 @@ +source.. = src/ +output.. = bin/ +bin.includes = plugin.xml,\ + META-INF/,\ + .,\ + icons/,\ + lib/jdom.jar diff --git a/configuration_extractor/icons/config.gif b/configuration_extractor/icons/config.gif new file mode 100644 index 0000000000000000000000000000000000000000..a13c7fe708e7a7800dbe19383644b8ca4b05e57c Binary files /dev/null and b/configuration_extractor/icons/config.gif differ diff --git a/configuration_extractor/lib/jdom.jar b/configuration_extractor/lib/jdom.jar new file mode 100644 index 0000000000000000000000000000000000000000..65a1b3f737390b50a50fa24d17c5ca71a581f0bf Binary files /dev/null and b/configuration_extractor/lib/jdom.jar differ diff --git a/configuration_extractor/plugin.xml b/configuration_extractor/plugin.xml new file mode 100644 index 0000000000000000000000000000000000000000..d0782995f7675bb72f75f63f374a0127c18d83c4 --- /dev/null +++ b/configuration_extractor/plugin.xml @@ -0,0 +1,30 @@ +<?xml version="1.0" encoding="UTF-8"?> +<?eclipse version="3.4"?> +<plugin> + + <extension + point="org.eclipse.ui.actionSets"> + <actionSet + label="Sample Action Set" + visible="true" + id="Configuration_Extractor.actionSet"> + <menu + label="Konfiguration &" + id="sampleMenu"> + <separator + name="sampleGroup"> + </separator> + </menu> + <action + label="&Konfiguration extrahieren" + icon="icons/config.gif" + class="configuration_extractor.actions.SampleAction" + tooltip="Konfiguration extrahieren" + menubarPath="sampleMenu/sampleGroup" + toolbarPath="sampleGroup" + id="configuration_extractor.actions.SampleAction"> + </action> + </actionSet> + </extension> + +</plugin> diff --git a/configuration_extractor/src/configuration_extractor/Activator.java b/configuration_extractor/src/configuration_extractor/Activator.java new file mode 100644 index 0000000000000000000000000000000000000000..30d5e8e6331e4898d96289efa7df4362ec37e982 --- /dev/null +++ b/configuration_extractor/src/configuration_extractor/Activator.java @@ -0,0 +1,63 @@ +package configuration_extractor; + +import org.eclipse.jface.resource.ImageDescriptor; +import org.eclipse.ui.plugin.AbstractUIPlugin; +import org.osgi.framework.BundleContext; + + +/** + * The activator class controls the plug-in life cycle + */ +public class Activator extends AbstractUIPlugin { + + // The plug-in ID + public static final String PLUGIN_ID = "Configuration_Extractor"; //$NON-NLS-1$ + + // The shared instance + private static Activator plugin; + + /** + * The constructor + */ + public Activator() { + } + + /* + * (non-Javadoc) + * @see org.eclipse.ui.plugin.AbstractUIPlugin#start(org.osgi.framework.BundleContext) + */ + public void start(BundleContext context) throws Exception { + super.start(context); + plugin = this; + + } + + /* + * (non-Javadoc) + * @see org.eclipse.ui.plugin.AbstractUIPlugin#stop(org.osgi.framework.BundleContext) + */ + public void stop(BundleContext context) throws Exception { + plugin = null; + super.stop(context); + } + + /** + * Returns the shared instance + * + * @return the shared instance + */ + public static Activator getDefault() { + return plugin; + } + + /** + * Returns an image descriptor for the image file at the given + * plug-in relative path + * + * @param path the path + * @return the image descriptor + */ + public static ImageDescriptor getImageDescriptor(String path) { + return imageDescriptorFromPlugin(PLUGIN_ID, path); + } +} diff --git a/configuration_extractor/src/configuration_extractor/actions/SampleAction.java b/configuration_extractor/src/configuration_extractor/actions/SampleAction.java new file mode 100644 index 0000000000000000000000000000000000000000..da86924df45ce2e2a1b2ca9d01a101ab4b3bb428 --- /dev/null +++ b/configuration_extractor/src/configuration_extractor/actions/SampleAction.java @@ -0,0 +1,299 @@ +package configuration_extractor.actions; + +import java.io.File; +import java.io.FileWriter; +import java.io.IOException; + +import org.eclipse.core.runtime.Platform; +import org.eclipse.jface.action.IAction; +import org.eclipse.jface.viewers.ISelection; +import org.eclipse.ui.IWorkbenchWindow; +import org.eclipse.ui.IWorkbenchWindowActionDelegate; +//import org.eclipse.jface.dialogs.MessageDialog; +import org.jdom.Document; +import org.jdom.Element; +import org.jdom.output.Format; +import org.jdom.output.XMLOutputter; +import org.eclipse.swt.widgets.FileDialog; +import org.eclipse.swt.SWT; + + +/** + * Our sample action implements workbench action delegate. + * The action proxy will be created by the workbench and + * shown in the UI. When the user tries to use the action, + * this delegate will be created and execution will be + * delegated to it. + * @see IWorkbenchWindowActionDelegate + */ +public class SampleAction implements IWorkbenchWindowActionDelegate { + private IWorkbenchWindow window; + /** + * The constructor. + */ + public SampleAction() { + } + + /** + * The action has been activated. The argument of the + * method represents the 'real' action sitting + * in the workbench UI. + * @see IWorkbenchWindowActionDelegate#run + */ + public void run(IAction action) { + + //File Dialog: "Datei speichern unter" + FileDialog fd = new FileDialog(window.getShell(),SWT.SAVE); + fd.setText("XML-Konfiguration speichern unter"); + String[] filterText = {"*.xml"}; + fd.setFilterExtensions(filterText); + fd.setFilterPath("C:/"); + String selected = fd.open(); + System.out.println(selected); + + String dirName = fd.getFilterPath(); + String fileName = fd.getFileName(); + + + /* + * String fileName = fd.getFileName(); + * $- + * root; + * name:Vergessene Geräte; + * title:Einstellungen vergessene Geräte; + * info:Hier können sie ihre zu überwachenden Geräte konfigurieren + * -$ + * + * System.out.println(selected); + * + * $- + * listpanel; + * id:doors; + * title:Geräte + * -$ + * + * @param: testParam Describes something, doesn't matter what + * + * $- + * list; + * label:Geräte; + * title:Geräte auswählen; + * limit:-1; + * domain:www.domain.tld + * -$ + * + * fsdsdfsdf @ Sinnloser Kommentar + * + * + * $- + * element; + * id:label1; + * type:LABEL; + * label:Geräte Konfiguration; + * title:Geräte Konfiguration; + * standardValue:123" + * -$ + * + * + * $- + * element; + * id:label1; + * type:LABEL; + * label:Geräte Konfiguration; + * title:Geräte Konfiguration; + * standardValue: + * -$ + * + * $-panel;title:Einstellungen;-$ + * + * $-panel_element; + * id:notificationTimeout; + * type:TEXTBOX; + * label:Timeout bis zur Benachrichtigung + * title:Timeout bis zur Benachrichtigung; + * standardvalue:42 + * -$ + */ + + + Element root = new Element("root"); + Element panels = new Element("panels"); + Element listPanel = new Element("listpanel"); + Element panel = new Element("panel"); + + panels.addContent(listPanel); + panels.addContent(panel); + + + String allCode = "/* " + + "* $- "+ + "* root;" + + "* name:Vergessene Geräte; "+ + "* title:Einstellungen vergessene Geräte; "+ + "* info:Hier können sie ihre zu überwachenden Geräte konfigurieren "+ + "* -$"+ + "* "+ + "* callMeAFunction(String test) is a function that causes a commentary"+ + "* $-"+ + "* listpanel;"+ + "* id:doors;"+ + "* title:Geräte"+ + "* -$"+ + "* "+ + "@param: Ojidoifoifsd jks fjofs dij hsfo jsofd" + + "* $-"+ + "* list;"+ + "* label:Geräte;"+ + "* title:Geräte auswählen;"+ + "* limit:-1;"+ + "* domain:www.domain.tld"+ + "* -$"+ + "* "+ + "* fsdsdfsdf @"+ + "* "+ + "* $-"+ + "* element;"+ + "* id:label1;"+ + "* type:LABEL;"+ + "* label:Geräte Konfiguration;"+ + "* title:Geräte Konfiguration;"+ + "* standardValue:123"+ + "* -$"+ + "* "+ + "* "+ + "* $-"+ + "* element;"+ + "* id:label1;"+ + "* type:LABEL;"+ + "* label:Geräte Konfiguration;"+ + "* title:Geräte Konfiguration;"+ + "* standardValue:"+ + "* -$"+ + "$-panel;title:Einstellungen;-$"+ + "$-panel_element;"+ + "id:notificationTimeout;"+ + "type:TEXTBOX;"+ + "label:Timeout bis zur Benachrichtigung;"+ + "title:Timeout bis zur Benachrichtigung;"+ + "standardvalue:42-$"+ + "*/"; + + + String contentsReplace = allCode.replaceAll("([\\/][\\*]){1}([\\*][\\/]){1}", "").replaceAll("[ ]?[\\*]{1}[ ]?", "").replaceAll("([\\-][\\$]){1}[a-zA-Z 0-9\\@\\:\\-\\(\\)]+([\\$][\\-]){1}", "\\-\\$\\$\\-").replaceAll("([\\/][\\$][\\-]){1}", "").replaceAll("([\\-][\\$][\\/]){1}", ""); + + String[] contents = contentsReplace.split("\\-\\$\\$\\-"); + + + for (int k=0; k<contents.length; k++) { + + if (!contents[k].equals(null) && !contents[k].equals("")) { + + String[] content = contents[k].split(";"); + + String elementType = content[0]; + + if (elementType.equals("root")) { + for (int i=1; i<content.length; i++) { + if (i == 1) + root.setAttribute("id",fileName.replace(".xml", "")); + root.setAttribute(content[i].split(":")[0],content[i].split(":")[1]); + } + root.addContent(panels); + } + else if (elementType.equals("listpanel")) { + for (int i=1; i<content.length; i++) { + listPanel.setAttribute(content[i].split(":")[0],content[i].split(":")[1]); + } + + } + else if (elementType.equals("list")) { + Element list = new Element("list"); + for (int i=1; i<content.length; i++) { + Element listChild = new Element(content[i].split(":")[0]); + listChild.addContent(content[i].split(":")[1]); + list.addContent(listChild); + } + listPanel.addContent(list); + } + else if (elementType.equals("panel_element")) { + Element panel_element = new Element("element"); + for (int i=1; i<content.length; i++) { + if (content[i].split(":")[0].equals("id")) { + panel_element.setAttribute("id",content[i].split(":")[1]); + } + else { + Element panel_elementChild = new Element(content[i].split(":")[0]); + panel_elementChild.addContent(content[i].split(":")[1]); + panel_element.addContent(panel_elementChild); + } + } + panel.addContent(panel_element); + + } + + else if (elementType.equals("panel")) { + for (int i=1; i<content.length; i++) { + panel.setAttribute(content[i].split(":")[0],content[i].split(":")[1]); + } + + } + + } + } + + + + Document configurationDoc = new Document(root); + //File f = new File(Platform.getLocation().toFile().toURI()); + + + XMLOutputter outputter = new XMLOutputter(Format.getPrettyFormat().setIndent(" ").setExpandEmptyElements(true)); + + try { + + outputter.output(configurationDoc, System.out); + } + catch (java.io.IOException e) { + e.printStackTrace(); + } + + try { + FileWriter writer = new FileWriter(dirName + "\\" + fileName); + //writer. + outputter.output(configurationDoc, writer); + writer.close(); + } + catch (IOException i) { + System.out.print(i); + } + + } + + + /** + * Selection in the workbench has been changed. We + * can change the state of the 'real' action here + * if we want, but this can only happen after + * the delegate has been created. + * @see IWorkbenchWindowActionDelegate#selectionChanged + */ + public void selectionChanged(IAction action, ISelection selection) { + } + + /** + * We can use this method to dispose of any system + * resources we previously allocated. + * @see IWorkbenchWindowActionDelegate#dispose + */ + public void dispose() { + } + + /** + * We will cache window object in order to + * be able to provide parent shell for the message dialog. + * @see IWorkbenchWindowActionDelegate#init + */ + public void init(IWorkbenchWindow window) { + this.window = window; + } +} \ No newline at end of file