Skip to content
Snippets Groups Projects
Commit fa36a5b0 authored by Tom Zentek's avatar Tom Zentek
Browse files

initial import

parent 410d7385
No related branches found
No related tags found
No related merge requests found
Showing
with 469 additions and 0 deletions
<?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>
<?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>
#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
#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
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
File added
File added
source.. = src/
output.. = bin/
bin.includes = plugin.xml,\
META-INF/,\
.,\
icons/,\
lib/jdom.jar
configuration_extractor/icons/config.gif

1014 B

File added
<?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 &amp;"
id="sampleMenu">
<separator
name="sampleGroup">
</separator>
</menu>
<action
label="&amp;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>
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);
}
}
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 Gerte;
* title:Einstellungen vergessene Gerte;
* info:Hier knnen sie ihre zu berwachenden Gerte konfigurieren
* -$
*
* System.out.println(selected);
*
* $-
* listpanel;
* id:doors;
* title:Gerte
* -$
*
* @param: testParam Describes something, doesn't matter what
*
* $-
* list;
* label:Gerte;
* title:Gerte auswhlen;
* limit:-1;
* domain:www.domain.tld
* -$
*
* fsdsdfsdf @ Sinnloser Kommentar
*
*
* $-
* element;
* id:label1;
* type:LABEL;
* label:Gerte Konfiguration;
* title:Gerte Konfiguration;
* standardValue:123"
* -$
*
*
* $-
* element;
* id:label1;
* type:LABEL;
* label:Gerte Konfiguration;
* title:Gerte 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 Gerte; "+
"* title:Einstellungen vergessene Gerte; "+
"* info:Hier knnen sie ihre zu berwachenden Gerte konfigurieren "+
"* -$"+
"* "+
"* callMeAFunction(String test) is a function that causes a commentary"+
"* $-"+
"* listpanel;"+
"* id:doors;"+
"* title:Gerte"+
"* -$"+
"* "+
"@param: Ojidoifoifsd jks fjofs dij hsfo jsofd" +
"* $-"+
"* list;"+
"* label:Gerte;"+
"* title:Gerte auswhlen;"+
"* limit:-1;"+
"* domain:www.domain.tld"+
"* -$"+
"* "+
"* fsdsdfsdf @"+
"* "+
"* $-"+
"* element;"+
"* id:label1;"+
"* type:LABEL;"+
"* label:Gerte Konfiguration;"+
"* title:Gerte Konfiguration;"+
"* standardValue:123"+
"* -$"+
"* "+
"* "+
"* $-"+
"* element;"+
"* id:label1;"+
"* type:LABEL;"+
"* label:Gerte Konfiguration;"+
"* title:Gerte 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
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment