commit
e458d248bc
@ -0,0 +1,9 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<classpath>
|
||||
<classpathentry kind="src" path="src"/>
|
||||
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.8"/>
|
||||
<classpathentry exported="true" kind="lib" path="libs/jxl.jar"/>
|
||||
<classpathentry kind="con" path="org.eclipse.pde.core.requiredPlugins"/>
|
||||
<classpathentry exported="true" kind="lib" path="libs/cfr-0.152.jar"/>
|
||||
<classpathentry kind="output" path="bin"/>
|
||||
</classpath>
|
||||
@ -0,0 +1,28 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<projectDescription>
|
||||
<name>GeisPlugin</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>
|
||||
</buildSpec>
|
||||
<natures>
|
||||
<nature>org.eclipse.pde.PluginNature</nature>
|
||||
<nature>org.eclipse.jdt.core.javanature</nature>
|
||||
</natures>
|
||||
</projectDescription>
|
||||
@ -0,0 +1,15 @@
|
||||
eclipse.preferences.version=1
|
||||
org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled
|
||||
org.eclipse.jdt.core.compiler.codegen.methodParameters=do not generate
|
||||
org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8
|
||||
org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve
|
||||
org.eclipse.jdt.core.compiler.compliance=1.8
|
||||
org.eclipse.jdt.core.compiler.debug.lineNumber=generate
|
||||
org.eclipse.jdt.core.compiler.debug.localVariable=generate
|
||||
org.eclipse.jdt.core.compiler.debug.sourceFile=generate
|
||||
org.eclipse.jdt.core.compiler.problem.assertIdentifier=error
|
||||
org.eclipse.jdt.core.compiler.problem.enablePreviewFeatures=disabled
|
||||
org.eclipse.jdt.core.compiler.problem.enumIdentifier=error
|
||||
org.eclipse.jdt.core.compiler.problem.reportPreviewFeatures=warning
|
||||
org.eclipse.jdt.core.compiler.release=disabled
|
||||
org.eclipse.jdt.core.compiler.source=1.8
|
||||
@ -0,0 +1,2 @@
|
||||
eclipse.preferences.version=1
|
||||
org.eclipse.ltk.core.refactoring.enable.project.refactoring.history=false
|
||||
@ -0,0 +1,16 @@
|
||||
Manifest-Version: 1.0
|
||||
Bundle-ManifestVersion: 2
|
||||
Bundle-Name: Geis Plugin
|
||||
Bundle-SymbolicName: GeisPlugin;singleton:=true
|
||||
Bundle-Version: 5.0.1
|
||||
Bundle-Activator: geisplugin.Activator
|
||||
Require-Bundle: org.eclipse.ui,
|
||||
org.eclipse.core.runtime,
|
||||
org.eclipse.core.resources,
|
||||
org.eclipse.jdt.core;bundle-version="3.9.1"
|
||||
Bundle-RequiredExecutionEnvironment: JavaSE-1.8
|
||||
Bundle-ActivationPolicy: lazy
|
||||
Bundle-ClassPath: libs/jxl.jar,
|
||||
libs/cfr-0.152.jar,
|
||||
.
|
||||
Bundle-Vendor: Geis GmbH
|
||||
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
|
After Width: | Height: | Size: 1.1 KiB |
|
After Width: | Height: | Size: 1.1 KiB |
|
After Width: | Height: | Size: 601 B |
@ -0,0 +1,14 @@
|
||||
|
||||
bin.includes = plugin.xml,\
|
||||
META-INF/,\
|
||||
.,\
|
||||
libs/,\
|
||||
libs/cfr-0.152.jar
|
||||
|
||||
jars.compile.order = .
|
||||
|
||||
jre.compilation.profile = JavaSE-1.8
|
||||
|
||||
output.. = bin/
|
||||
|
||||
source.. = src/
|
||||
Binary file not shown.
Binary file not shown.
@ -0,0 +1,134 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<?eclipse version="3.4"?>
|
||||
<plugin>
|
||||
<extension point="org.eclipse.ui.menus">
|
||||
<menuContribution locationURI="popup:org.eclipse.jdt.ui.PackageExplorer">
|
||||
<menu label="Geis Tools" icon="icons/geis.gif">
|
||||
<menu label="General">
|
||||
<command commandId="checksumlfsid" label="Calculate LFS checksum" name="lfschecksum" style="push">
|
||||
</command>
|
||||
<command commandId="checksumsinglefigureid" label="Calculate single figure checksum" name="singlechecksum" style="push">
|
||||
</command>
|
||||
<command commandId="removewhitespaceid" label="Remove Trailing Whitespace" name="removewhitespace" style="push">
|
||||
</command>
|
||||
</menu>
|
||||
<menu label="SQL/Hibernate" icon="icons/db.gif">
|
||||
<command commandId="generatemappingid" label="Generate Hibernate Mapping" name="generatemapping" style="push">
|
||||
<visibleWhen checkEnabled="false">
|
||||
<with variable="activeMenuSelection">
|
||||
<iterate ifEmpty="false" operator="or">
|
||||
<adapt type="org.eclipse.jdt.internal.core.JavaProject" />
|
||||
</iterate>
|
||||
</with>
|
||||
</visibleWhen>
|
||||
</command>
|
||||
<command commandId="generatemmetaid" label="Generate tables metadata for whole DB .xls" name="tablemetawholedb" style="push">
|
||||
</command>
|
||||
<command commandId="generatemmetasingleid" label="Generate single table metadata info .xls" name="singletablemeta" style="push">
|
||||
</command>
|
||||
<command commandId="generatemmetadbid" label="Generate DB tables metadata info .xls" name="tablesmetadata" style="push">
|
||||
</command>
|
||||
</menu>
|
||||
<menu label="Java" icon="icons/java.gif">
|
||||
<command commandId="addheaderid" label="Add header" name="addclassheader" style="push">
|
||||
<visibleWhen checkEnabled="false">
|
||||
<with variable="activeMenuSelection">
|
||||
<iterate ifEmpty="false" operator="or">
|
||||
<adapt type="org.eclipse.jdt.core.ICompilationUnit" />
|
||||
</iterate>
|
||||
</with>
|
||||
</visibleWhen>
|
||||
</command>
|
||||
<command commandId="jspgenid" label="Generate CC .jsp" name="generateccjsp" style="push">
|
||||
<visibleWhen checkEnabled="false">
|
||||
<with variable="activeMenuSelection">
|
||||
<iterate ifEmpty="false" operator="or">
|
||||
<adapt type="org.eclipse.jdt.internal.core.JavaProject" />
|
||||
</iterate>
|
||||
</with>
|
||||
</visibleWhen>
|
||||
</command>
|
||||
<command commandId="generatereflectiongetsetid" label="Generate Refletion Get/Set" name="reflectiongetset" style="push">
|
||||
<visibleWhen checkEnabled="false">
|
||||
<with variable="activeMenuSelection">
|
||||
<iterate ifEmpty="false" operator="or">
|
||||
<adapt type="org.eclipse.jdt.core.ICompilationUnit" />
|
||||
</iterate>
|
||||
</with>
|
||||
</visibleWhen>
|
||||
</command>
|
||||
<command commandId="linkccid" label="Link with mangedbeans" name="linkwithmanagedbeans" style="push">
|
||||
</command>
|
||||
<command commandId="removereflectgetsetid" label="Remove Refletion Getter/Setter" name="removereflectgetset" style="push">
|
||||
<visibleWhen checkEnabled="false">
|
||||
<with variable="activeMenuSelection">
|
||||
<iterate ifEmpty="false" operator="or">
|
||||
<adapt type="org.eclipse.jdt.core.ICompilationUnit" />
|
||||
</iterate>
|
||||
</with>
|
||||
</visibleWhen>
|
||||
</command>
|
||||
<command commandId="converttoutf8id" label="Convert to UTF-8" name="converttoutf8" style="push">
|
||||
<visibleWhen checkEnabled="false">
|
||||
<with variable="activeMenuSelection">
|
||||
<iterate ifEmpty="false" operator="or">
|
||||
<adapt type="org.eclipse.jdt.core.ICompilationUnit" />
|
||||
</iterate>
|
||||
</with>
|
||||
</visibleWhen>
|
||||
</command>
|
||||
</menu>
|
||||
</menu>
|
||||
</menuContribution>
|
||||
<menuContribution
|
||||
locationURI="menu:org.eclipse.ui.main.menu?after=additions">
|
||||
<menu
|
||||
id="GeisPlugin.menus.sampleMenu"
|
||||
label="Geis Tools"
|
||||
mnemonic="M">
|
||||
<command
|
||||
commandId="generatemmetaid"
|
||||
label="Generate tables metadata for whole DB .xls"
|
||||
style="push">
|
||||
</command>
|
||||
<command
|
||||
commandId="generatemmetasingleid"
|
||||
label="Generate single table metadata info .xls"
|
||||
style="push">
|
||||
</command>
|
||||
<command
|
||||
commandId="generatemmetadbid"
|
||||
label="Generate DB tables metadata info .xls"
|
||||
style="push">
|
||||
</command>
|
||||
<command
|
||||
commandId="decompileid"
|
||||
label="Decompile .jar"
|
||||
style="push">
|
||||
</command>
|
||||
<command
|
||||
commandId="nesas107"
|
||||
label="NESAS107 log"
|
||||
style="push">
|
||||
</command>
|
||||
</menu>
|
||||
</menuContribution>
|
||||
</extension>
|
||||
<extension point="org.eclipse.ui.commands">
|
||||
<command defaultHandler="geisplugin.popup.actions.ConvertToUTF8" id="converttoutf8id"/>
|
||||
<command defaultHandler="geisplugin.popup.actions.GenerateReflectionGetSet" id="generatereflectiongetsetid"/>
|
||||
<command defaultHandler="geisplugin.popup.actions.RemoveGenerateReflectionGetSet" id="removereflectgetsetid"/>
|
||||
<command defaultHandler="geisplugin.popup.actions.AddHeaderAction" id="addheaderid"/>
|
||||
<command defaultHandler="geisplugin.popup.actions.WhiteSpaceAction" id="removewhitespaceid"/>
|
||||
<command defaultHandler="geisplugin.popup.actions.GenerateMapping" id="generatemappingid"/>
|
||||
<command defaultHandler="geisplugin.popup.actions.ChecksumLFS" id="checksumlfsid"/>
|
||||
<command defaultHandler="geisplugin.popup.actions.ChecksumSingleFigure" id="checksumsinglefigureid"/>
|
||||
<command defaultHandler="geisplugin.popup.actions.GetMetaData" id="generatemmetaid"/>
|
||||
<command defaultHandler="geisplugin.popup.actions.GetMetaDataTable" id="generatemmetasingleid"/>
|
||||
<command defaultHandler="geisplugin.popup.actions.GetTableMetaData" id="generatemmetadbid"/>
|
||||
<command defaultHandler="geisplugin.popup.actions.Decompile" id="decompileid"/>
|
||||
<command defaultHandler="geisplugin.popup.actions.NESAS107" id="nesas107"/>
|
||||
<command defaultHandler="geisplugin.popup.actions.CCJspGenerator" id="jspgenid"/>
|
||||
<command defaultHandler="geisplugin.popup.actions.LinkClassWithManagedbeans" id="linkccid"/>
|
||||
</extension>
|
||||
</plugin>
|
||||
@ -0,0 +1,81 @@
|
||||
package geisplugin;
|
||||
|
||||
//import java.io.File;
|
||||
//import java.io.FileNotFoundException;
|
||||
//import java.io.FileOutputStream;
|
||||
//import java.io.PrintStream;
|
||||
//import java.util.Date;
|
||||
|
||||
import javax.swing.JFrame;
|
||||
import javax.swing.UIManager;
|
||||
|
||||
import org.eclipse.jface.resource.ImageDescriptor;
|
||||
import org.eclipse.ui.plugin.AbstractUIPlugin;
|
||||
import org.osgi.framework.BundleContext;
|
||||
|
||||
/**
|
||||
* DE:
|
||||
*
|
||||
* EN:
|
||||
*
|
||||
*
|
||||
* Program changes
|
||||
* **************************************************************************************
|
||||
* Date * Ticket * KonzFirm * Responsible * programmer *
|
||||
* Change *
|
||||
* **************************************************************************************
|
||||
*
|
||||
* @author Huellmante
|
||||
* @version 1.0
|
||||
*
|
||||
*/
|
||||
|
||||
|
||||
public class Activator extends AbstractUIPlugin {
|
||||
|
||||
//Logging zum Testen
|
||||
// static {
|
||||
// try {
|
||||
// System.setOut(new PrintStream(new FileOutputStream("C:/output.txt"), true));
|
||||
// } catch (FileNotFoundException e) {
|
||||
// e.printStackTrace();
|
||||
// }
|
||||
// try {
|
||||
// System.setErr(new PrintStream(new FileOutputStream("C:/err.txt"), true));
|
||||
// } catch (FileNotFoundException e) {
|
||||
// e.printStackTrace();
|
||||
// }
|
||||
// }
|
||||
|
||||
public static final String PLUGIN_ID = "hbmToPoJoPlugIn";
|
||||
|
||||
public final static JFrame frame = createPluginFrame();
|
||||
|
||||
private static JFrame createPluginFrame() {
|
||||
try {UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName());} catch (Exception e){}
|
||||
JFrame.setDefaultLookAndFeelDecorated(true);
|
||||
JFrame frame = new JFrame("Geis Tools");
|
||||
frame.setLocationRelativeTo(null);
|
||||
frame.pack();
|
||||
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
|
||||
return frame;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void start(final BundleContext context) throws Exception {
|
||||
super.start(context);
|
||||
//JOptionPane.showMessageDialog(null, "start");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void stop(final BundleContext context) throws Exception {
|
||||
//JOptionPane.showMessageDialog(null, "stop");
|
||||
frame.dispose();
|
||||
super.stop(context);
|
||||
}
|
||||
|
||||
@SuppressWarnings("deprecation")
|
||||
public static ImageDescriptor getImageDescriptor(String path) {
|
||||
return imageDescriptorFromPlugin(PLUGIN_ID, path);
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,409 @@
|
||||
package geisplugin;
|
||||
|
||||
import java.awt.Desktop;
|
||||
import java.io.BufferedReader;
|
||||
import java.io.BufferedWriter;
|
||||
import java.io.File;
|
||||
import java.io.FileInputStream;
|
||||
import java.io.FileOutputStream;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStreamReader;
|
||||
import java.io.OutputStreamWriter;
|
||||
import java.net.URL;
|
||||
import java.net.URLClassLoader;
|
||||
import java.sql.Connection;
|
||||
import java.sql.Driver;
|
||||
import java.sql.DriverManager;
|
||||
import java.sql.DriverPropertyInfo;
|
||||
import java.sql.ResultSet;
|
||||
import java.sql.SQLException;
|
||||
import java.sql.SQLFeatureNotSupportedException;
|
||||
import java.sql.Statement;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Properties;
|
||||
import java.util.logging.Logger;
|
||||
|
||||
import javax.swing.JOptionPane;
|
||||
|
||||
import org.eclipse.core.resources.IProject;
|
||||
import org.eclipse.core.resources.IResource;
|
||||
import org.eclipse.core.runtime.Platform;
|
||||
import org.eclipse.jdt.core.IJavaElement;
|
||||
import org.eclipse.jdt.core.IJavaProject;
|
||||
import org.eclipse.jdt.internal.core.PackageFragmentRoot;
|
||||
import org.eclipse.jface.viewers.ISelection;
|
||||
import org.eclipse.jface.viewers.IStructuredSelection;
|
||||
import org.eclipse.ui.PlatformUI;
|
||||
|
||||
/**
|
||||
* DE:
|
||||
*
|
||||
* EN:
|
||||
*
|
||||
*
|
||||
* Program changes
|
||||
* **************************************************************************************
|
||||
* Date * Ticket * KonzFirm * Responsible * programmer *
|
||||
* Change *
|
||||
* **************************************************************************************
|
||||
*
|
||||
* @author huellmante
|
||||
* @version 1.0
|
||||
*
|
||||
*/
|
||||
|
||||
//Cp1252 -> Default Eclipse Sourceencoding
|
||||
|
||||
@SuppressWarnings("restriction")
|
||||
public abstract class Tools {
|
||||
|
||||
public static final String[] getDBs() {
|
||||
Connection jdbc = null;
|
||||
Statement stmt = null;
|
||||
ResultSet rs = null;
|
||||
try {
|
||||
jdbc = getConnection();
|
||||
stmt = jdbc.createStatement();
|
||||
rs = stmt.executeQuery("SELECT TABLE_SCHEM||' - '||IFNULL(SCHEMA_TEXT, '') FROM SYSIBM.SQLSCHEMAS WHERE TABLE_CAT='GEISAS01'");
|
||||
final ArrayList<String> localDBList = new ArrayList<String>(512);
|
||||
while (rs.next()) {
|
||||
localDBList.add(rs.getString(1));
|
||||
}
|
||||
return localDBList.toArray(new String[0]);
|
||||
} catch (final Exception e) {
|
||||
e.printStackTrace();
|
||||
} finally {
|
||||
if (rs != null) {
|
||||
try {
|
||||
rs.close();
|
||||
} catch (final Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
rs = null;
|
||||
}
|
||||
if (stmt != null) {
|
||||
try {
|
||||
stmt.close();
|
||||
} catch (final Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
stmt = null;
|
||||
}
|
||||
}
|
||||
return new String[0];
|
||||
}
|
||||
|
||||
public final static String[] getTables(final String db) {
|
||||
Connection jdbc = null;
|
||||
Statement stmt = null;
|
||||
ResultSet rs = null;
|
||||
try {
|
||||
jdbc = Tools.getConnection();
|
||||
stmt = jdbc.createStatement(ResultSet.TYPE_FORWARD_ONLY, ResultSet.CONCUR_READ_ONLY);
|
||||
rs = stmt.executeQuery("SELECT DISTINCT RTRIM(a.table_name)||' - '||b.TABLE_TEXT as a FROM sysibm.SQLColumns a INNER JOIN qsys2.systables b ON a.table_name = b.table_name AND a.table_schem = b.table_schema WHERE b.type != 'A' AND a.table_schem='" + db + "' AND b.table_schema='" + db + "' ORDER BY a");
|
||||
final ArrayList<String> localTableList = new ArrayList<String>(512);
|
||||
while (rs.next()) {
|
||||
localTableList.add(rs.getString(1));
|
||||
}
|
||||
return localTableList.toArray(new String[0]);
|
||||
} catch (final Exception e) {
|
||||
e.printStackTrace();
|
||||
} finally {
|
||||
if (rs != null) {
|
||||
try {
|
||||
rs.close();
|
||||
} catch (final Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
rs = null;
|
||||
}
|
||||
if (stmt != null) {
|
||||
try {
|
||||
stmt.close();
|
||||
} catch (final Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
stmt = null;
|
||||
}
|
||||
}
|
||||
return new String[0];
|
||||
}
|
||||
|
||||
private static class DriverShim implements Driver {
|
||||
private Driver driver;
|
||||
private DriverShim(final Driver d) {
|
||||
this.driver = d;
|
||||
}
|
||||
@Override
|
||||
public boolean acceptsURL(final String u) throws SQLException {
|
||||
return this.driver.acceptsURL(u);
|
||||
}
|
||||
@Override
|
||||
public Connection connect(final String u, final Properties p) throws SQLException {
|
||||
return this.driver.connect(u, p);
|
||||
}
|
||||
@Override
|
||||
public int getMajorVersion() {
|
||||
return this.driver.getMajorVersion();
|
||||
}
|
||||
@Override
|
||||
public int getMinorVersion() {
|
||||
return this.driver.getMinorVersion();
|
||||
}
|
||||
@Override
|
||||
public DriverPropertyInfo[] getPropertyInfo(final String u, final Properties p) throws SQLException {
|
||||
return this.driver.getPropertyInfo(u, p);
|
||||
}
|
||||
@Override
|
||||
public boolean jdbcCompliant() {
|
||||
return this.driver.jdbcCompliant();
|
||||
}
|
||||
@Override
|
||||
public Logger getParentLogger() throws SQLFeatureNotSupportedException {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
private static String getjt400Url() throws Exception {
|
||||
final List<String> pathList = new ArrayList<String>(17);
|
||||
pathList.add("C:/EnterpriseClient/tools/embeddedserver/webapps/editor/WEB-INF/lib/jt400.jar");
|
||||
pathList.add("C:/EnterpriseClient/server/tomcattools/webapps/editor/WEB-INF/lib/jt400.jar");
|
||||
pathList.add("C:/Program Files (x86)/Eclipse/jt400.jar");
|
||||
pathList.add("C:/Program Files/Eclipse/jt400.jar");
|
||||
pathList.add("C:/Program Files (x86)/Eclipse/plugins/jt400.jar");
|
||||
pathList.add("C:/Program Files/Eclipse/plugins/jt400.jar");
|
||||
pathList.add("C:/Users/"+ System.getProperty("user.name") + "/.razorsql/jtopen/jt400.jar");
|
||||
pathList.add("C:/Program Files (x86)/Argus/embeddedserver/webapps/argus_page/WEB-INF/lib/jt400.jar");
|
||||
pathList.add("C:/Program Files (x86)/ArgusTest/embeddedserver/webapps/argus_page/WEB-INF/lib/jt400.jar");
|
||||
pathList.add("C:/Program Files/Argus/embeddedserver/webapps/argus_page/WEB-INF/lib/jt400.jar");
|
||||
pathList.add("C:/Program Files/ArgusTest/embeddedserver/webapps/argus_page/WEB-INF/lib/jt400.jar");
|
||||
pathList.add("C:/Program Files/Argus/embeddedserver/webapps/argus_page/WEB-INF/lib/jt400.jar");
|
||||
|
||||
if (Platform.isRunning()) {
|
||||
pathList.add((Platform.getInstallLocation().getURL().toString()+"jt400.jar").substring(6));
|
||||
pathList.add((Platform.getInstallLocation().getURL().toString()+"plugins/jt400.jar").substring(6));
|
||||
}
|
||||
|
||||
pathList.add("C:/projects/argus_page_entw/webcontent/WEB-INF/lib/jt400.jar");
|
||||
pathList.add("C:/Program Files (x86)/IBM/Client Access/jt400/lib/jt400.jar");
|
||||
pathList.add("C:/Program Files/IBM/Client Access/jt400/lib/jt400.jar");
|
||||
|
||||
int i = 0;
|
||||
for(; i != pathList.size(); ++i) {
|
||||
if(new File(pathList.get(i)).exists()) {
|
||||
return "file:/" + pathList.get(i);
|
||||
}
|
||||
}
|
||||
|
||||
throw new Exception("Can't find the jt400.jar driver");
|
||||
}
|
||||
|
||||
static private final String user = "SVCJOBI";//argus GCC2TST
|
||||
static private final String password = "pw_8e0#164";//argus369 GCC2369
|
||||
|
||||
static private boolean driverLoaded = false;
|
||||
|
||||
public static Connection con = null;
|
||||
|
||||
public static Connection getConnection() throws Exception {
|
||||
if(!driverLoaded) {
|
||||
DriverManager.registerDriver((new DriverShim( ((Driver)Class.forName("com.ibm.as400.access.AS400JDBCDriver", true, new URLClassLoader(new URL[] { new URL(getjt400Url()) })).newInstance()))));
|
||||
driverLoaded = true;
|
||||
}
|
||||
if (con == null || con.isClosed()) {
|
||||
con = DriverManager.getConnection("jdbc:as400://as400/GEISDB01;metadata source=0;translate binary=true;naming=system", user, password);
|
||||
con.setReadOnly(true);
|
||||
con.setAutoCommit(false);
|
||||
}
|
||||
return con;
|
||||
}
|
||||
|
||||
public static String read(final String filename) throws IOException {
|
||||
final StringBuilder text = new StringBuilder();
|
||||
final char[] buffer = new char[0xFFFF];
|
||||
|
||||
InputStreamReader reader = new InputStreamReader(new FileInputStream(new File(filename)), "Cp1252");
|
||||
try {
|
||||
int len = 0;
|
||||
while ((len = reader.read(buffer)) != -1) {
|
||||
text.append(buffer, 0, len);
|
||||
}
|
||||
} finally {
|
||||
reader.close();
|
||||
}
|
||||
return text.toString();
|
||||
}
|
||||
|
||||
public static void write(final String filename, final String text) throws IOException {
|
||||
if(filename==null || filename.equals("nullnull"))
|
||||
return;
|
||||
|
||||
String folderName = filename;
|
||||
|
||||
if(folderName.endsWith(".xml") || folderName.endsWith(".java")) {
|
||||
folderName = folderName.substring(0, filename.lastIndexOf('\\'));
|
||||
}
|
||||
File f = new File(filename);
|
||||
try {
|
||||
new File(folderName).mkdirs();
|
||||
}
|
||||
catch(Exception e) {}
|
||||
f.createNewFile();
|
||||
OutputStreamWriter writer = new OutputStreamWriter(new FileOutputStream(f), "Cp1252");
|
||||
try {
|
||||
writer.write(text);
|
||||
writer.flush();
|
||||
} finally {
|
||||
writer.close();
|
||||
}
|
||||
}
|
||||
|
||||
public static String readUTF8(final String filename) throws IOException {
|
||||
final StringBuilder text = new StringBuilder();
|
||||
final char[] buffer = new char[0xFFFF];
|
||||
|
||||
InputStreamReader reader = new InputStreamReader(new FileInputStream(new File(filename)), "UTF-8");
|
||||
try {
|
||||
int len = 0;
|
||||
while ((len = reader.read(buffer)) != -1) {
|
||||
text.append(buffer, 0, len);
|
||||
}
|
||||
} finally {
|
||||
reader.close();
|
||||
}
|
||||
return text.toString();
|
||||
}
|
||||
|
||||
public static void writeUTF8withFolderCreation(final String filename, final String text) throws IOException {
|
||||
if(filename==null || filename.equals("nullnull"))
|
||||
return;
|
||||
|
||||
String folderName = filename;
|
||||
|
||||
if(folderName.endsWith(".xml") || folderName.endsWith(".java")) {
|
||||
folderName = folderName.substring(0, filename.lastIndexOf('\\'));
|
||||
}
|
||||
File f = new File(filename);
|
||||
try {
|
||||
new File(folderName).mkdirs();
|
||||
}
|
||||
catch(Exception e) {}
|
||||
f.createNewFile();
|
||||
OutputStreamWriter writer = new OutputStreamWriter(new FileOutputStream(f), "UTF-8");
|
||||
try {
|
||||
writer.write(text);
|
||||
writer.flush();
|
||||
} finally {
|
||||
writer.close();
|
||||
}
|
||||
}
|
||||
|
||||
public static void writeUTF8(final String filename, final String text) throws IOException {
|
||||
if(filename==null || filename.equals("nullnull"))
|
||||
return;
|
||||
File f = new File(filename);
|
||||
f.createNewFile();
|
||||
OutputStreamWriter writer = new OutputStreamWriter(new FileOutputStream(f), "UTF-8");
|
||||
try {
|
||||
writer.write(text);
|
||||
writer.flush();
|
||||
} finally {
|
||||
writer.close();
|
||||
}
|
||||
}
|
||||
|
||||
public static void writeNoPathCreation(final String filename, final String text) throws IOException {
|
||||
File f = new File(filename);
|
||||
f.createNewFile();
|
||||
OutputStreamWriter writer = new OutputStreamWriter(new FileOutputStream(f), "Cp1252");
|
||||
try {
|
||||
writer.write(text);
|
||||
writer.flush();
|
||||
} finally {
|
||||
writer.close();
|
||||
}
|
||||
}
|
||||
|
||||
public static IProject getCurrentSelectedProject() throws Exception {
|
||||
|
||||
IProject project = null;
|
||||
|
||||
if (Platform.isRunning()) {
|
||||
ISelection selection = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getSelectionService().getSelection();
|
||||
|
||||
if(selection instanceof IStructuredSelection) {
|
||||
Object element = ((IStructuredSelection)selection).getFirstElement();
|
||||
|
||||
if (element instanceof IResource) {
|
||||
project= ((IResource)element).getProject();
|
||||
} else if (element instanceof PackageFragmentRoot) {
|
||||
IJavaProject jProject = ((PackageFragmentRoot)element).getJavaProject();
|
||||
project = jProject.getProject();
|
||||
} else if (element instanceof IJavaElement) {
|
||||
IJavaProject jProject= ((IJavaElement)element).getJavaProject();
|
||||
project = jProject.getProject();
|
||||
}
|
||||
}
|
||||
}
|
||||
return project;
|
||||
}
|
||||
|
||||
public static String trimEnd(final String source) {
|
||||
int pos = source.length() - 1;
|
||||
while ((pos >= 0) && Character.isWhitespace((int) source.charAt(pos))) {
|
||||
pos--;
|
||||
}
|
||||
pos++;
|
||||
return (pos < source.length()) ? source.substring(0, pos) : source;
|
||||
}
|
||||
|
||||
|
||||
//UPDATE GEISDTA.GXPADAT SET PAKEY1 = '2.9', PATXT = '\\nesfs001\install$\Java\Eclipse Plugin\GeisPlugin_2.9.0.jar', PALAED = 09082017, PALAET = 1052 WHERE PAID = 25834;
|
||||
public static boolean isNotUpToDate() {
|
||||
boolean result = false;
|
||||
Connection con = null;
|
||||
try {
|
||||
con = getConnection();
|
||||
} catch (Exception e1) {
|
||||
e1.printStackTrace();
|
||||
return true;
|
||||
}
|
||||
try (
|
||||
Statement ps = con.createStatement();
|
||||
ResultSet rs = ps.executeQuery("SELECT PAKEY1 from GEISDTA.GXPADAT WHERE PAID=25834 AND PAWERT='GEISPLUGIN'")
|
||||
) {
|
||||
if (rs.next()) {
|
||||
//System.out.println(new Double(rs.getString(1)));
|
||||
result = (new Double(rs.getString(1)) > 5.0);
|
||||
}
|
||||
|
||||
} catch (final Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
if (result) {
|
||||
if (JOptionPane.showConfirmDialog(Activator.frame, "A Plugin-Update is available, do you want to continue [Yes] or to update [No] ?", "Update", JOptionPane.YES_NO_OPTION) == JOptionPane.YES_OPTION) {
|
||||
result = false;
|
||||
} else {
|
||||
try {
|
||||
Desktop.getDesktop().open(new File("\\\\nesfs001\\install$\\Java\\Eclipse Plugin"));
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
public static void transform(File source, String srcEncoding, File target, String tgtEncoding) throws IOException {
|
||||
try (
|
||||
BufferedReader br = new BufferedReader(new InputStreamReader(new FileInputStream(source), srcEncoding));
|
||||
BufferedWriter bw = new BufferedWriter(new OutputStreamWriter(new FileOutputStream(target), tgtEncoding)); ) {
|
||||
char[] buffer = new char[16384];
|
||||
int read;
|
||||
while ((read = br.read(buffer)) != -1)
|
||||
bw.write(buffer, 0, read);
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,233 @@
|
||||
package geisplugin.popup.actions;
|
||||
|
||||
|
||||
import geisplugin.Tools;
|
||||
|
||||
import java.sql.SQLException;
|
||||
|
||||
import org.eclipse.core.commands.AbstractHandler;
|
||||
import org.eclipse.core.commands.ExecutionEvent;
|
||||
import org.eclipse.core.commands.ExecutionException;
|
||||
import org.eclipse.core.resources.IResource;
|
||||
import org.eclipse.jdt.core.ICompilationUnit;
|
||||
import org.eclipse.jface.dialogs.MessageDialog;
|
||||
import org.eclipse.jface.viewers.IStructuredSelection;
|
||||
import org.eclipse.swt.widgets.Shell;
|
||||
import org.eclipse.ui.handlers.HandlerUtil;
|
||||
|
||||
/**
|
||||
* DE:
|
||||
*
|
||||
* EN:
|
||||
*
|
||||
*
|
||||
* Program changes
|
||||
* **************************************************************************************
|
||||
* Date * Ticket * KonzFirm * Responsible * programmer *
|
||||
* Change *
|
||||
* **************************************************************************************
|
||||
*
|
||||
* @author huellmante
|
||||
* @version 1.0
|
||||
*
|
||||
*/
|
||||
|
||||
|
||||
public class AddHeaderAction extends AbstractHandler {
|
||||
|
||||
@Override
|
||||
public Object execute(final ExecutionEvent event) throws ExecutionException {
|
||||
try {
|
||||
if (Tools.isNotUpToDate()) {
|
||||
return null;
|
||||
}
|
||||
} finally {
|
||||
try {
|
||||
if (Tools.con != null && !Tools.con.isClosed()) {
|
||||
try {
|
||||
Tools.con.rollback();
|
||||
Tools.con.close();
|
||||
} catch (final SQLException e) {
|
||||
}
|
||||
Tools.con = null;
|
||||
}
|
||||
} catch (SQLException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
Shell shell = HandlerUtil.getActiveShell(event);
|
||||
for (final Object firstElement : ((IStructuredSelection) HandlerUtil.getActiveMenuSelection(event)).toList()) {
|
||||
try {
|
||||
if (firstElement instanceof ICompilationUnit) {
|
||||
createOutput(shell, firstElement);
|
||||
} else {
|
||||
MessageDialog.openInformation(shell, "Info", "Please select Java source file");
|
||||
}
|
||||
} catch (Exception e) {
|
||||
MessageDialog.openError(shell, "Fehler", "Fehler " + e.getMessage());
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
private void createOutput(final Shell shell, final Object firstElement) {
|
||||
ICompilationUnit cu = (ICompilationUnit) firstElement;
|
||||
String file = cu.getResource().getRawLocation().toString();
|
||||
|
||||
try {
|
||||
|
||||
String fileAsString = Tools.read(file);
|
||||
|
||||
if (fileAsString.contains("* Program changes\n")) {
|
||||
MessageDialog.openError(shell, "Error", "Already existing!");
|
||||
return;
|
||||
}
|
||||
|
||||
int index = 0;
|
||||
|
||||
int b = fileAsString.indexOf("public class");
|
||||
if (b != -1) {
|
||||
index = b;
|
||||
}
|
||||
|
||||
b = fileAsString.indexOf("public final class");
|
||||
if (b != -1 && b < index) {
|
||||
index = b;
|
||||
}
|
||||
|
||||
b = fileAsString.indexOf("public final static class");
|
||||
if (b != -1 && b < index) {
|
||||
index = b;
|
||||
}
|
||||
|
||||
b = fileAsString.indexOf("public static final class");
|
||||
if (b != -1 && b < index) {
|
||||
index = b;
|
||||
}
|
||||
|
||||
b = fileAsString.indexOf("private class");
|
||||
if (b != -1 && b < index) {
|
||||
index = b;
|
||||
}
|
||||
|
||||
b = fileAsString.indexOf("private final class");
|
||||
if (b != -1 && b < index) {
|
||||
index = b;
|
||||
}
|
||||
|
||||
b = fileAsString.indexOf("private final static class");
|
||||
if (b != -1 && b < index) {
|
||||
index = b;
|
||||
}
|
||||
|
||||
b = fileAsString.indexOf("private static final class");
|
||||
if (b != -1 && b < index) {
|
||||
index = b;
|
||||
}
|
||||
|
||||
|
||||
b = fileAsString.indexOf("public abstract class");
|
||||
if (b != -1 && b < index) {
|
||||
index = b;
|
||||
}
|
||||
|
||||
b = fileAsString.indexOf("private abstract class");
|
||||
if (b != -1 && b < index) {
|
||||
index = b;
|
||||
}
|
||||
|
||||
b = fileAsString.indexOf("public interface");
|
||||
if (b != -1) {
|
||||
index = b;
|
||||
}
|
||||
|
||||
b = fileAsString.indexOf("public final interface");
|
||||
if (b != -1 && b < index) {
|
||||
index = b;
|
||||
}
|
||||
|
||||
b = fileAsString.indexOf("public final static interface");
|
||||
if (b != -1 && b < index) {
|
||||
index = b;
|
||||
}
|
||||
|
||||
b = fileAsString.indexOf("public static final interface");
|
||||
if (b != -1 && b < index) {
|
||||
index = b;
|
||||
}
|
||||
|
||||
b = fileAsString.indexOf("private interface");
|
||||
if (b != -1 && b < index) {
|
||||
index = b;
|
||||
}
|
||||
|
||||
b = fileAsString.indexOf("private final interface");
|
||||
if (b != -1 && b < index) {
|
||||
index = b;
|
||||
}
|
||||
|
||||
b = fileAsString.indexOf("private final static interface");
|
||||
if (b != -1 && b < index) {
|
||||
index = b;
|
||||
}
|
||||
|
||||
b = fileAsString.indexOf("private static final interface");
|
||||
if (b != -1 && b < index) {
|
||||
index = b;
|
||||
}
|
||||
|
||||
|
||||
b = fileAsString.indexOf("public abstract interface");
|
||||
if (b != -1 && b < index) {
|
||||
index = b;
|
||||
}
|
||||
|
||||
b = fileAsString.indexOf("private abstract interface");
|
||||
if (b != -1 && b < index) {
|
||||
index = b;
|
||||
}
|
||||
|
||||
b = fileAsString.indexOf("public enum");
|
||||
if (b != -1 && b < index) {
|
||||
index = b;
|
||||
}
|
||||
|
||||
b = fileAsString.indexOf("private enum");
|
||||
if (b != -1 && b < index) {
|
||||
index = b;
|
||||
}
|
||||
|
||||
b = fileAsString.indexOf("public final enum");
|
||||
if (b != -1 && b < index) {
|
||||
index = b;
|
||||
}
|
||||
|
||||
b = fileAsString.indexOf("private final enum");
|
||||
if (b != -1 && b < index) {
|
||||
index = b;
|
||||
}
|
||||
|
||||
String a = fileAsString.substring(0, index).trim();
|
||||
String header = "\n\n/**\n * DE: \n *\n * EN: \n * \n * \n * Program changes\n * **************************************************************************************\n * Date\t\t\t* Ticket\t* KonzFirm\t* Responsible\t* programmer *\n * Change\t\t\t\t\t\t\t\t\t\t*\n * **************************************************************************************\n *\n * @author "+System.getProperty("user.name")+"\n * @version 1.0\n *\n */";
|
||||
|
||||
if (!a.isEmpty()) {
|
||||
int y = a.lastIndexOf("import");
|
||||
if(y > -1) {
|
||||
a = a.substring(y).trim();
|
||||
}
|
||||
y = a.indexOf('\n');
|
||||
if(y > -1) {
|
||||
a = a.substring(0, a.indexOf('\n')).trim();
|
||||
}
|
||||
fileAsString = fileAsString.replace(a,a + header);
|
||||
} else {
|
||||
//MessageDialog.openInformation(shell, "Info","Imports/Package are missing.");
|
||||
fileAsString = header.trim() + "\n\n" + fileAsString;
|
||||
}
|
||||
Tools.writeNoPathCreation(file, fileAsString);
|
||||
Tools.getCurrentSelectedProject().refreshLocal(IResource.DEPTH_INFINITE, null);
|
||||
} catch (final Exception e) {
|
||||
MessageDialog.openError(shell, "Fehler", "Fehler!\n"+e.getMessage());
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,110 @@
|
||||
package geisplugin.popup.actions;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.sql.SQLException;
|
||||
|
||||
import org.eclipse.core.commands.AbstractHandler;
|
||||
import org.eclipse.core.commands.ExecutionEvent;
|
||||
import org.eclipse.core.commands.ExecutionException;
|
||||
import org.eclipse.core.resources.IResource;
|
||||
import org.eclipse.core.resources.ResourcesPlugin;
|
||||
import org.eclipse.jface.dialogs.InputDialog;
|
||||
import org.eclipse.jface.dialogs.MessageDialog;
|
||||
import org.eclipse.swt.widgets.Shell;
|
||||
import org.eclipse.ui.handlers.HandlerUtil;
|
||||
|
||||
import geisplugin.Tools;
|
||||
|
||||
/**
|
||||
* DE:
|
||||
*
|
||||
* EN:
|
||||
*
|
||||
*
|
||||
* Program changes
|
||||
* **************************************************************************************
|
||||
* Date * Ticket * KonzFirm * Responsible * programmer *
|
||||
* Change *
|
||||
* **************************************************************************************
|
||||
*
|
||||
* @author huellmante
|
||||
* @version 1.0
|
||||
*
|
||||
*/
|
||||
|
||||
public class CCJspGenerator extends AbstractHandler {
|
||||
|
||||
@Override
|
||||
public Object execute(final ExecutionEvent event) throws ExecutionException {
|
||||
try {
|
||||
if (Tools.isNotUpToDate()) {
|
||||
return null;
|
||||
}
|
||||
} finally {
|
||||
try {
|
||||
if (Tools.con != null && !Tools.con.isClosed()) {
|
||||
try {
|
||||
Tools.con.rollback();
|
||||
Tools.con.close();
|
||||
} catch (final SQLException e) {
|
||||
}
|
||||
Tools.con = null;
|
||||
}
|
||||
} catch (SQLException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
Shell shell = HandlerUtil.getActiveShell(event);
|
||||
|
||||
String path = "";
|
||||
try {
|
||||
path = ResourcesPlugin.getWorkspace().getRoot().getLocation().toFile().getCanonicalPath()+Tools.getCurrentSelectedProject().getFullPath().toString().replace('/', '\\')+"\\";
|
||||
} catch (Exception e) {}
|
||||
|
||||
//MessageDialog.openInformation(shell, "path", path);
|
||||
|
||||
File webcontent = new File(path+"webcontent/");
|
||||
|
||||
if (path == null || path.isEmpty() || !webcontent.exists() || !webcontent.isDirectory()) {
|
||||
MessageDialog.openError(shell, "Info", "Error, can't find a valid webcontent path.");
|
||||
return null;
|
||||
}
|
||||
|
||||
path += "webcontent\\";
|
||||
|
||||
InputDialog dia = new InputDialog(shell, "Set your .jsp path", "Set your .jsp path after "+path, "", null);
|
||||
dia.open();
|
||||
|
||||
String jsp = dia.getValue();
|
||||
|
||||
if (jsp.isEmpty()) {
|
||||
MessageDialog.openError(shell, "Error", "Empty path.");
|
||||
return null;
|
||||
}
|
||||
|
||||
if (!jsp.toLowerCase().endsWith(".jsp")) {
|
||||
jsp += ".jsp";
|
||||
}
|
||||
|
||||
File newJspFile = new File(path+jsp);
|
||||
newJspFile.getParentFile().mkdirs();
|
||||
|
||||
try {
|
||||
Tools.writeNoPathCreation(newJspFile.getAbsolutePath(), "<%@page contentType=\"text/html\"%>\r\n<%@page pageEncoding=\"UTF-8\"%>\r\n\r\n<%@taglib prefix=\"f\" uri=\"http://java.sun.com/jsf/core\"%>\r\n<%@taglib prefix=\"h\" uri=\"http://java.sun.com/jsf/html\"%>\r\n\r\n@@taglibraries@@\r\n\r\n<!-- ========== CONTENT BEGIN ========== -->\r\n<f:view>\r\n<h:form>\r\n<f:subview id=\"template\">\r\n\r\n <t:rowtitlebar id=\"g_2\" />\r\n <t:rowheader id=\"g_3\" />\r\n <t:rowbodypane id=\"g_4\" />\r\n <t:rowstatusbar id=\"g_5\" />\r\n \r\n<t:pageaddons/>\r\n</f:subview>\r\n</h:form>\r\n</f:view>\r\n<!-- ========== CONTENT END ========== -->\r\n");
|
||||
} catch (final IOException e) {
|
||||
MessageDialog.openError(shell, "Error", e.getMessage());
|
||||
e.printStackTrace();
|
||||
return null;
|
||||
}
|
||||
|
||||
try {
|
||||
Tools.getCurrentSelectedProject().refreshLocal(IResource.DEPTH_INFINITE, null);
|
||||
} catch (final Exception e) {
|
||||
MessageDialog.openError(shell, "Info", "Error, can't refresh your workplace automatically");
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
}
|
||||
@ -0,0 +1,105 @@
|
||||
package geisplugin.popup.actions;
|
||||
|
||||
|
||||
import geisplugin.Activator;
|
||||
import geisplugin.Tools;
|
||||
|
||||
import java.sql.SQLException;
|
||||
|
||||
import javax.swing.JOptionPane;
|
||||
|
||||
import org.eclipse.core.commands.AbstractHandler;
|
||||
import org.eclipse.core.commands.ExecutionEvent;
|
||||
import org.eclipse.core.commands.ExecutionException;
|
||||
|
||||
/**
|
||||
* DE:
|
||||
*
|
||||
* EN:
|
||||
*
|
||||
*
|
||||
* Program changes
|
||||
* **************************************************************************************
|
||||
* Date * Ticket * KonzFirm * Responsible * programmer *
|
||||
* Change *
|
||||
* **************************************************************************************
|
||||
*
|
||||
* @author huellmante
|
||||
* @version 1.0
|
||||
*
|
||||
*/
|
||||
|
||||
|
||||
public class ChecksumLFS extends AbstractHandler {
|
||||
|
||||
@Override
|
||||
public Object execute(final ExecutionEvent event) throws ExecutionException {
|
||||
|
||||
try {
|
||||
if (Tools.isNotUpToDate()) {
|
||||
return null;
|
||||
}
|
||||
} finally {
|
||||
try {
|
||||
if (Tools.con != null && !Tools.con.isClosed()) {
|
||||
try {
|
||||
Tools.con.rollback();
|
||||
Tools.con.close();
|
||||
} catch (final SQLException e) {
|
||||
}
|
||||
Tools.con = null;
|
||||
}
|
||||
} catch (SQLException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
String originalLFSNumber = JOptionPane.showInputDialog(Activator.frame, "Calculate LFS checksum of:");
|
||||
if (originalLFSNumber != null && originalLFSNumber.trim().length() == 9) {
|
||||
originalLFSNumber = originalLFSNumber.trim();
|
||||
JOptionPane.showMessageDialog(Activator.frame, Integer.toString(getCreateLFSPruefziffer(originalLFSNumber)));
|
||||
} else {
|
||||
JOptionPane.showMessageDialog(Activator.frame, "The number has to be 9 digits long!");
|
||||
}
|
||||
return null;
|
||||
|
||||
}
|
||||
|
||||
private static int getCreateLFSPruefziffer(final String originalLFSNumber) {
|
||||
/*
|
||||
* Berechnung der 1-stelligen Prüfziffer für
|
||||
*
|
||||
* 1=Behälteretiketten
|
||||
* 2=LE-Etiketten
|
||||
* 3=Packstücketiketten
|
||||
* 4=Lagerplatz
|
||||
*
|
||||
*/
|
||||
|
||||
int zahlInt = 0;
|
||||
String zahlString = null;
|
||||
int summeInt = 0;
|
||||
int tmpSummeInt = 0;
|
||||
int gewichtung = 1;
|
||||
|
||||
try {
|
||||
if (originalLFSNumber.length() == 9) {
|
||||
for (int i = 0; i < originalLFSNumber.length(); ++i) {
|
||||
if (gewichtung == 3) {
|
||||
gewichtung = 1;
|
||||
} else if (gewichtung == 1) {
|
||||
gewichtung = 3;
|
||||
}
|
||||
zahlString = originalLFSNumber.substring(i, i + 1);
|
||||
zahlInt = Integer.parseInt(zahlString);
|
||||
tmpSummeInt = gewichtung * zahlInt;
|
||||
summeInt = summeInt + tmpSummeInt;
|
||||
}
|
||||
summeInt = 10 - (summeInt % 10);
|
||||
}
|
||||
} catch (final Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
return (summeInt == 10) ? 0 : summeInt;
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,79 @@
|
||||
package geisplugin.popup.actions;
|
||||
|
||||
|
||||
import geisplugin.Activator;
|
||||
import geisplugin.Tools;
|
||||
|
||||
import java.math.BigInteger;
|
||||
import java.sql.SQLException;
|
||||
|
||||
import javax.swing.JOptionPane;
|
||||
|
||||
import org.eclipse.core.commands.AbstractHandler;
|
||||
import org.eclipse.core.commands.ExecutionEvent;
|
||||
import org.eclipse.core.commands.ExecutionException;
|
||||
|
||||
/**
|
||||
* DE:
|
||||
*
|
||||
* EN:
|
||||
*
|
||||
*
|
||||
* Program changes
|
||||
* **************************************************************************************
|
||||
* Date * Ticket * KonzFirm * Responsible * programmer *
|
||||
* Change *
|
||||
* **************************************************************************************
|
||||
*
|
||||
* @author huellmante
|
||||
* @version 1.0
|
||||
*
|
||||
*/
|
||||
|
||||
|
||||
public class ChecksumSingleFigure extends AbstractHandler {
|
||||
|
||||
@Override
|
||||
public Object execute(final ExecutionEvent event) throws ExecutionException {
|
||||
try {
|
||||
if (Tools.isNotUpToDate()) {
|
||||
return null;
|
||||
}
|
||||
} finally {
|
||||
try {
|
||||
if (Tools.con != null && !Tools.con.isClosed()) {
|
||||
try {
|
||||
Tools.con.rollback();
|
||||
Tools.con.close();
|
||||
} catch (final SQLException e) {
|
||||
}
|
||||
Tools.con = null;
|
||||
}
|
||||
} catch (SQLException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
String originalValue = JOptionPane.showInputDialog(Activator.frame, "Calculate single figure checksum of:");
|
||||
if (originalValue != null && !originalValue.trim().isEmpty()) {
|
||||
originalValue = originalValue.trim();
|
||||
JOptionPane.showMessageDialog(Activator.frame, Integer.toString(berechnePZ1(originalValue)));
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
private static int berechnePZ1(final String wert) {
|
||||
int mp = 3;
|
||||
int pz = 0;
|
||||
BigInteger bi = null;
|
||||
for (int pos = wert.length() - 1; pos >= 0; pos--) {
|
||||
bi = new BigInteger(wert.substring(pos, pos + 1));
|
||||
pz = pz + (bi.intValue() * mp);
|
||||
mp = (mp == 3) ? 1 : 3;
|
||||
}
|
||||
pz = 10 - (pz % 10);
|
||||
if (pz == 10) {
|
||||
pz = 0;
|
||||
}
|
||||
return pz;
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,86 @@
|
||||
package geisplugin.popup.actions;
|
||||
|
||||
import geisplugin.Tools;
|
||||
|
||||
import java.sql.SQLException;
|
||||
|
||||
import org.eclipse.core.commands.AbstractHandler;
|
||||
import org.eclipse.core.commands.ExecutionEvent;
|
||||
import org.eclipse.core.commands.ExecutionException;
|
||||
import org.eclipse.core.resources.IResource;
|
||||
import org.eclipse.jdt.core.ICompilationUnit;
|
||||
import org.eclipse.jface.dialogs.MessageDialog;
|
||||
import org.eclipse.jface.viewers.IStructuredSelection;
|
||||
import org.eclipse.swt.widgets.Shell;
|
||||
import org.eclipse.ui.handlers.HandlerUtil;
|
||||
|
||||
/**
|
||||
* DE:
|
||||
*
|
||||
* EN:
|
||||
*
|
||||
*
|
||||
* Program changes
|
||||
* **************************************************************************************
|
||||
* Date * Ticket * KonzFirm * Responsible * programmer *
|
||||
* Change *
|
||||
* **************************************************************************************
|
||||
*
|
||||
* @author huellmante
|
||||
* @version 1.0
|
||||
*
|
||||
*/
|
||||
|
||||
public class ConvertToUTF8 extends AbstractHandler {
|
||||
|
||||
@Override
|
||||
public Object execute(final ExecutionEvent event) throws ExecutionException {
|
||||
try {
|
||||
if (Tools.isNotUpToDate()) {
|
||||
return null;
|
||||
}
|
||||
} finally {
|
||||
try {
|
||||
if (Tools.con != null && !Tools.con.isClosed()) {
|
||||
try {
|
||||
Tools.con.rollback();
|
||||
Tools.con.close();
|
||||
} catch (final SQLException e) {
|
||||
}
|
||||
Tools.con = null;
|
||||
}
|
||||
} catch (SQLException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
Shell shell = HandlerUtil.getActiveShell(event);
|
||||
for (Object firstElement : ((IStructuredSelection) HandlerUtil.getActiveMenuSelection(event)).toList()) {
|
||||
try {
|
||||
if (firstElement instanceof ICompilationUnit) {
|
||||
createOutput(shell, firstElement);
|
||||
} else {
|
||||
MessageDialog.openInformation(shell, "Info", "Please select Java file, not a " + firstElement.getClass().getCanonicalName());
|
||||
}
|
||||
} catch (Exception e) {
|
||||
MessageDialog.openError(shell, "Fehler", "Fehler " + e.getMessage());
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
private void createOutput(final Shell shell, final Object firstElement) {
|
||||
ICompilationUnit cu = (ICompilationUnit) firstElement;
|
||||
String file = cu.getResource().getRawLocation().toString();
|
||||
try {
|
||||
|
||||
String fileAsString = Tools.read(file);
|
||||
|
||||
Tools.writeUTF8(file, fileAsString);
|
||||
|
||||
Tools.getCurrentSelectedProject().refreshLocal(IResource.DEPTH_INFINITE, null);
|
||||
} catch (final Exception e) {
|
||||
MessageDialog.openError(shell, "Error", "Error!\n " + e.getMessage());
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,65 @@
|
||||
package geisplugin.popup.actions;
|
||||
|
||||
/**
|
||||
* DE:
|
||||
*
|
||||
* EN:
|
||||
*
|
||||
*
|
||||
* Program changes
|
||||
* **************************************************************************************
|
||||
* Date * Ticket * KonzFirm * Responsible * programmer *
|
||||
* Change *
|
||||
* **************************************************************************************
|
||||
*
|
||||
* @author huellmante
|
||||
* @version 1.0
|
||||
*
|
||||
*/
|
||||
|
||||
public class DatabaseTableObjekt {
|
||||
|
||||
private final boolean id;
|
||||
private final String columnTypeString;
|
||||
private final String columnLabelString;
|
||||
private final int columnTypeInt, precision, scale;
|
||||
private final boolean notnullable;
|
||||
|
||||
public boolean isID() {
|
||||
return id;
|
||||
}
|
||||
|
||||
public String getColumnTypeString() {
|
||||
return columnTypeString;
|
||||
}
|
||||
|
||||
public String getColumnLabelString() {
|
||||
return columnLabelString;
|
||||
}
|
||||
|
||||
public int getColumnTypeInt() {
|
||||
return columnTypeInt;
|
||||
}
|
||||
|
||||
public int getPrecision() {
|
||||
return precision;
|
||||
}
|
||||
|
||||
public int getScale() {
|
||||
return scale;
|
||||
}
|
||||
|
||||
public boolean isNotnullable() {
|
||||
return notnullable;
|
||||
}
|
||||
|
||||
public DatabaseTableObjekt(final String columnTypeString, final String columnLabelString, final int columnTypeInt, final int scale, final int precision, final boolean id, final boolean notnullable, final int columnDisplaySize) {
|
||||
this.columnTypeString = columnTypeString;
|
||||
this.columnLabelString = columnLabelString;
|
||||
this.columnTypeInt = columnTypeInt;
|
||||
this.scale = scale;
|
||||
this.precision = columnTypeString.equals("NCHAR") ? columnDisplaySize : precision;
|
||||
this.id = id;
|
||||
this.notnullable = notnullable;
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,102 @@
|
||||
package geisplugin.popup.actions;
|
||||
|
||||
|
||||
import java.awt.Desktop;
|
||||
import java.io.File;
|
||||
import java.sql.SQLException;
|
||||
|
||||
import javax.swing.JFileChooser;
|
||||
import javax.swing.JOptionPane;
|
||||
import javax.swing.filechooser.FileNameExtensionFilter;
|
||||
|
||||
import org.eclipse.core.commands.AbstractHandler;
|
||||
import org.eclipse.core.commands.ExecutionEvent;
|
||||
|
||||
import geisplugin.Activator;
|
||||
import geisplugin.Tools;
|
||||
|
||||
/**
|
||||
* DE:
|
||||
*
|
||||
* EN:
|
||||
*
|
||||
*
|
||||
* Program changes
|
||||
* **************************************************************************************
|
||||
* Date * Ticket * KonzFirm * Responsible * programmer *
|
||||
* Change *
|
||||
* **************************************************************************************
|
||||
*
|
||||
* @author huellmante
|
||||
* @version 1.0
|
||||
*
|
||||
*/
|
||||
|
||||
public class Decompile extends AbstractHandler {
|
||||
|
||||
public static void main(final String[] args) {
|
||||
new Decompile().execute(null);
|
||||
System.exit(0);
|
||||
}
|
||||
|
||||
public static String createStringStackTrace(final Throwable e) {
|
||||
final StringBuilder stackTrace = new StringBuilder();
|
||||
stackTrace.append(e.getClass().getName());
|
||||
if (e.getMessage() != null && !e.getMessage().trim().isEmpty()) {
|
||||
stackTrace.append(": ");
|
||||
stackTrace.append(e.getMessage());
|
||||
}
|
||||
for (final StackTraceElement element : e.getStackTrace()) {
|
||||
stackTrace.append("\tat ");
|
||||
stackTrace.append(element.toString());
|
||||
stackTrace.append('\n');
|
||||
}
|
||||
return stackTrace.toString();
|
||||
}
|
||||
|
||||
@Override
|
||||
public Object execute(final ExecutionEvent event) {
|
||||
try {
|
||||
if (Tools.isNotUpToDate()) {
|
||||
return null;
|
||||
}
|
||||
} finally {
|
||||
try {
|
||||
if (Tools.con != null && !Tools.con.isClosed()) {
|
||||
try {
|
||||
Tools.con.rollback();
|
||||
Tools.con.close();
|
||||
} catch (final SQLException e) {
|
||||
}
|
||||
Tools.con = null;
|
||||
}
|
||||
} catch (SQLException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
try {
|
||||
JFileChooser chooser = new JFileChooser();
|
||||
FileNameExtensionFilter filter = new FileNameExtensionFilter("Java Files (*.jar, *.class)", "jar", "class");
|
||||
chooser.setFileFilter(filter);
|
||||
chooser.setAcceptAllFileFilterUsed(false);
|
||||
if (chooser.showOpenDialog(Activator.frame) == JFileChooser.APPROVE_OPTION) {
|
||||
File inputFile = chooser.getSelectedFile();
|
||||
if (!inputFile.exists()) {
|
||||
JOptionPane.showMessageDialog(Activator.frame, inputFile.getCanonicalPath() + " does not exist!");
|
||||
return null;
|
||||
}
|
||||
File outputFolder = new File(inputFile.getCanonicalPath() + "_sources\\");
|
||||
if (!outputFolder.isDirectory() && !outputFolder.mkdir()) {
|
||||
JOptionPane.showMessageDialog(Activator.frame, outputFolder.getCanonicalPath() + " can't get created!");
|
||||
return null;
|
||||
}
|
||||
org.benf.cfr.reader.Main.main(new String[] { inputFile.getCanonicalPath(), "--outputdir", outputFolder.getCanonicalPath() + "\\" });
|
||||
Desktop.getDesktop().open(outputFolder);
|
||||
}
|
||||
} catch (final Throwable e) {
|
||||
e.printStackTrace();
|
||||
JOptionPane.showMessageDialog(Activator.frame, createStringStackTrace(e));
|
||||
}
|
||||
return null;
|
||||
}
|
||||
}
|
||||
File diff suppressed because it is too large
Load Diff
@ -0,0 +1,73 @@
|
||||
package geisplugin.popup.actions;
|
||||
|
||||
import geisplugin.Tools;
|
||||
|
||||
import java.io.File;
|
||||
|
||||
import org.eclipse.core.commands.AbstractHandler;
|
||||
import org.eclipse.core.commands.ExecutionEvent;
|
||||
import org.eclipse.core.commands.ExecutionException;
|
||||
import org.eclipse.core.resources.IResource;
|
||||
import org.eclipse.jface.dialogs.MessageDialog;
|
||||
import org.eclipse.swt.widgets.Shell;
|
||||
import org.eclipse.ui.handlers.HandlerUtil;
|
||||
|
||||
/**
|
||||
* DE:
|
||||
*
|
||||
* EN:
|
||||
*
|
||||
*
|
||||
* Program changes
|
||||
* **************************************************************************************
|
||||
* Date * Ticket * KonzFirm * Responsible * programmer *
|
||||
* Change *
|
||||
* **************************************************************************************
|
||||
*
|
||||
* @author huellmante
|
||||
* @version 1.0
|
||||
*
|
||||
*/
|
||||
|
||||
public class GenerateMapping extends AbstractHandler {
|
||||
|
||||
@Override
|
||||
public Object execute(final ExecutionEvent event) throws ExecutionException {
|
||||
if (Tools.isNotUpToDate()) {
|
||||
return null;
|
||||
}
|
||||
Shell shell = HandlerUtil.getActiveShell(event);
|
||||
|
||||
String path = "";
|
||||
try {
|
||||
path = Tools.getCurrentSelectedProject().getLocation().toFile().toString().replace('/', '\\') + "\\";
|
||||
} catch (Exception e) {
|
||||
}
|
||||
|
||||
if (path.isEmpty()) {
|
||||
MessageDialog.openInformation(shell, "Info", "Error, can't find a valid DB path, using desktop");
|
||||
path = "C:\\Users" + System.getProperty("user.name") + "\\Desktop";
|
||||
} else {
|
||||
if (new File(path + "\\src\\main\\java\\de\\geis\\datenbanken").isDirectory()) {
|
||||
path += "\\src\\main\\java\\de\\geis\\datenbanken";
|
||||
} else if (new File(path + "src\\all\\geis\\db").isDirectory()) {
|
||||
path += "src\\all\\geis\\db";
|
||||
} else
|
||||
if (new File(path + "src\\de\\geis\\db").isDirectory()) {
|
||||
path += "src\\de\\geis\\db";
|
||||
} else {
|
||||
path += "src\\de\\geis\\datenbanken";
|
||||
}
|
||||
}
|
||||
|
||||
new GenerateHibernateMapping(shell, path);
|
||||
|
||||
try {
|
||||
Tools.getCurrentSelectedProject().refreshLocal(IResource.DEPTH_INFINITE, null);
|
||||
} catch (final Exception e) {
|
||||
MessageDialog.openError(shell, "Info", "Error, can't refresh your workplace automatically");
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,98 @@
|
||||
package geisplugin.popup.actions;
|
||||
|
||||
import geisplugin.Tools;
|
||||
|
||||
import java.sql.SQLException;
|
||||
|
||||
import org.eclipse.core.commands.AbstractHandler;
|
||||
import org.eclipse.core.commands.ExecutionEvent;
|
||||
import org.eclipse.core.commands.ExecutionException;
|
||||
import org.eclipse.core.resources.IResource;
|
||||
import org.eclipse.jdt.core.ICompilationUnit;
|
||||
import org.eclipse.jface.dialogs.MessageDialog;
|
||||
import org.eclipse.jface.viewers.IStructuredSelection;
|
||||
import org.eclipse.swt.widgets.Shell;
|
||||
import org.eclipse.ui.handlers.HandlerUtil;
|
||||
|
||||
/**
|
||||
* DE:
|
||||
*
|
||||
* EN:
|
||||
*
|
||||
*
|
||||
* Program changes
|
||||
* **************************************************************************************
|
||||
* Date * Ticket * KonzFirm * Responsible * programmer *
|
||||
* Change *
|
||||
* **************************************************************************************
|
||||
*
|
||||
* @author huellmante
|
||||
* @version 1.0
|
||||
*
|
||||
*/
|
||||
|
||||
public class GenerateReflectionGetSet extends AbstractHandler {
|
||||
|
||||
@Override
|
||||
public Object execute(final ExecutionEvent event) throws ExecutionException {
|
||||
try {
|
||||
if (Tools.isNotUpToDate()) {
|
||||
return null;
|
||||
}
|
||||
} finally {
|
||||
try {
|
||||
if (Tools.con != null && !Tools.con.isClosed()) {
|
||||
try {
|
||||
Tools.con.rollback();
|
||||
Tools.con.close();
|
||||
} catch (final SQLException e) {
|
||||
}
|
||||
Tools.con = null;
|
||||
}
|
||||
} catch (SQLException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
Shell shell = HandlerUtil.getActiveShell(event);
|
||||
for (Object firstElement : ((IStructuredSelection) HandlerUtil.getActiveMenuSelection(event)).toList()) {
|
||||
try {
|
||||
if (firstElement instanceof ICompilationUnit) {
|
||||
createOutput(shell, firstElement);
|
||||
} else {
|
||||
MessageDialog.openInformation(shell, "Info", "Please select Java file");
|
||||
}
|
||||
} catch (Exception e) {
|
||||
MessageDialog.openError(shell, "Fehler", "Fehler " + e.getMessage());
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
private void createOutput(final Shell shell, final Object firstElement) {
|
||||
ICompilationUnit cu = (ICompilationUnit) firstElement;
|
||||
String file = cu.getResource().getRawLocation().toString();
|
||||
try {
|
||||
|
||||
String fileAsString = Tools.read(file);
|
||||
|
||||
int where = fileAsString.lastIndexOf('}');
|
||||
|
||||
String afterEnd = "";
|
||||
|
||||
if (where < fileAsString.length()) {
|
||||
afterEnd = fileAsString.substring(where + 1);
|
||||
}
|
||||
|
||||
fileAsString = fileAsString.substring(0, where) + "\n\tpublic void set(String fieldname, Object value) {\t\t\n\t\t\ttry {\n\t\t\t\tif (value != null) {\n\t\t\t\t\t\n\t\t\t\t\tif (this.getClass().getField(fieldname.toLowerCase()).getType().getName().equals(\"java.lang.String\") ) {\n\t\t\t\t\t\tthis.getClass().getField(fieldname.toLowerCase()).set(this, value);\t\n\t\t\t\t\t\t\n\t\t\t\t\t} else if (this.getClass().getField(fieldname.toLowerCase()).getType().getName().equals(\"java.lang.Long\") ) {\n\t\t\t\t\t\t\n\t\t\t\t\t\tif (value == null)\n\t\t\t\t\t\t\tvalue = 0;\n\t\t\t\t\t\t\n\t\t\t\t\t\tthis.getClass().getField(fieldname.toLowerCase()).set(this, Long.parseLong(value.toString()));\t\n\t\t\t\t\t} else if (this.getClass().getField(fieldname.toLowerCase()).getType().getName().equals(\"java.lang.Integer\") ) {\n\t\t\t\t\t\tif (value.toString().trim().length() == 0)\n\t\t\t\t\t\t\tvalue = 0;\n\t\t\t\t\t\t\n\t\t\t\t\t\tthis.getClass().getField(fieldname.toLowerCase()).set(this, Integer.parseInt(value.toString()));\t\n\t\t\t\t\t} else if (this.getClass().getField(fieldname.toLowerCase()).getType().getName().equals(\"java.lang.Double\") ) {\n\t\t\t\t\t\tif (value.toString().trim().length() == 0)\n\t\t\t\t\t\t\tvalue = 0.0;\n\t\t\t\t\t\t\n\t\t\t\t\t\tthis.getClass().getField(fieldname.toLowerCase()).set(this, Double.parseDouble(value.toString()));\t\n\t\t\t\t\t} else if (this.getClass().getField(fieldname.toLowerCase()).getType().getName().equals(\"java.util.Date\") ) {\n\t\n\t\t\t\t\t} else {\n\t\t\t\t\t\tthis.getClass().getField(fieldname.toLowerCase()).set(this, value);\n\t\t\t\t\t}\n\t\t\t\t\t\n\t\t\t\t\t\n\t\t\t\t\t\n\t\t\t\t}\n\t\t\t} catch (Exception e) {\n\t\t\t\te.printStackTrace();\n\t\t\t}\n\t}\n\t\n\tpublic Object get(String fieldname) {\n\t\tObject result = null;\n\t\t\n\t\ttry {\n\t\t\t\n\t\t\tif (fieldname == null || fieldname.trim().length() == 0)\n\t\t\t\treturn \"\";\n\t\t\t\n\t\t\tresult = CCTools.getValueOf(this, fieldname.toLowerCase());\t\n\t\t\t\n\t\t\tif (result == null)\n\t\t\t\tresult = \"\";\n\t\t\t\n\t\t\t\n\t\t} catch (Exception e) {\n\t\t\te.printStackTrace();\n\t\t}\n\t\treturn result;\n\t}\n\t\n\tpublic String getType(String fieldname) {\n\t\tString result = null;\n\t\ttry {\n\t\t\t\n\t\t\tif (fieldname == null || fieldname.trim().length() == 0)\n\t\t\t\treturn \"\";\n\t\t\t\n\t\t\tresult = this.getClass().getField(fieldname.trim().toLowerCase()).getType().getName();\t\n\t\t} catch (Exception e) {\n\t\t\te.printStackTrace();\n\t\t}\n\t\treturn result;\n\t}" + "\n\n}" + afterEnd;
|
||||
|
||||
fileAsString = fileAsString.replace("public", "public").replaceFirst("private static final long serialVersionUID", "public static final long serialVersionUID");
|
||||
|
||||
Tools.writeNoPathCreation(file, fileAsString);
|
||||
|
||||
Tools.getCurrentSelectedProject().refreshLocal(IResource.DEPTH_INFINITE, null);
|
||||
} catch (final Exception e) {
|
||||
MessageDialog.openError(shell, "Error", "Error!\n " + e.getMessage());
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,236 @@
|
||||
package geisplugin.popup.actions;
|
||||
|
||||
import geisplugin.Activator;
|
||||
import geisplugin.Tools;
|
||||
|
||||
import java.awt.Desktop;
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.sql.Connection;
|
||||
import java.sql.DatabaseMetaData;
|
||||
import java.sql.ResultSet;
|
||||
import java.sql.SQLException;
|
||||
import java.sql.Statement;
|
||||
|
||||
import javax.swing.JOptionPane;
|
||||
import javax.swing.filechooser.FileSystemView;
|
||||
|
||||
import jxl.Workbook;
|
||||
import jxl.write.Label;
|
||||
import jxl.write.Number;
|
||||
import jxl.write.WritableSheet;
|
||||
import jxl.write.WritableWorkbook;
|
||||
|
||||
import org.eclipse.core.commands.AbstractHandler;
|
||||
import org.eclipse.core.commands.ExecutionEvent;
|
||||
import org.eclipse.core.commands.ExecutionException;
|
||||
import org.eclipse.jface.dialogs.MessageDialog;
|
||||
import org.eclipse.swt.widgets.Shell;
|
||||
import org.eclipse.ui.handlers.HandlerUtil;
|
||||
|
||||
/**
|
||||
* DE:
|
||||
*
|
||||
* EN:
|
||||
*
|
||||
*
|
||||
* Program changes
|
||||
* **************************************************************************************
|
||||
* Date * Ticket * KonzFirm * Responsible * programmer *
|
||||
* Change *
|
||||
* **************************************************************************************
|
||||
*
|
||||
* @author huellmante
|
||||
* @version 1.0
|
||||
*/
|
||||
|
||||
public class GetMetaData extends AbstractHandler {
|
||||
|
||||
public static void main(String[] args) {
|
||||
try {
|
||||
new GetMetaData().getMetaData();
|
||||
System.exit(0);
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
System.exit(-1);
|
||||
} finally {
|
||||
try {
|
||||
if (Tools.con != null && !Tools.con.isClosed()) {
|
||||
try {
|
||||
Tools.con.rollback();
|
||||
Tools.con.close();
|
||||
} catch (final SQLException e) {
|
||||
}
|
||||
Tools.con = null;
|
||||
}
|
||||
} catch (SQLException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public Object execute(ExecutionEvent event) throws ExecutionException {
|
||||
if (Tools.isNotUpToDate()) {
|
||||
return null;
|
||||
}
|
||||
shell = HandlerUtil.getActiveShell(event);
|
||||
try {
|
||||
getMetaData();
|
||||
} finally {
|
||||
try {
|
||||
if (Tools.con != null && !Tools.con.isClosed()) {
|
||||
try {
|
||||
Tools.con.rollback();
|
||||
Tools.con.close();
|
||||
} catch (final SQLException e) {
|
||||
}
|
||||
Tools.con = null;
|
||||
}
|
||||
} catch (SQLException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
private static Shell shell = null;
|
||||
|
||||
private void getMetaData() {
|
||||
|
||||
String[] dbs = null;
|
||||
|
||||
try {
|
||||
dbs = Tools.getDBs();
|
||||
} catch (Exception e) {
|
||||
}
|
||||
|
||||
if (dbs == null || dbs.length == 0) {
|
||||
|
||||
if (shell != null) {
|
||||
MessageDialog.openInformation(shell, "Info", "Couldn't find any databases, go sure your AS400 driver does exist and read the plugin documentation!");
|
||||
} else {
|
||||
JOptionPane.showMessageDialog(Activator.frame, "Couldn't find any databases, go sure your AS400 driver does exist and read the plugin documentation!");
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
String db = (String) JOptionPane.showInputDialog(Activator.frame, "Which Database?", "Select a Database", JOptionPane.PLAIN_MESSAGE, null, dbs, "GEISDTT");
|
||||
|
||||
dbs = null;
|
||||
|
||||
if (db == null) {
|
||||
return;
|
||||
}
|
||||
|
||||
db = db.substring(0, db.indexOf(" - "));
|
||||
System.out.println(db);
|
||||
|
||||
//url = "jdbc:as400://as400;libraries=" + db + ";metadata source=0";
|
||||
|
||||
getMetaDataWholeDBExcel(db, Tools.getTables(db));
|
||||
}
|
||||
|
||||
@SuppressWarnings("null")
|
||||
private void getMetaDataWholeDBExcel(final String db, final String[] tables) {
|
||||
|
||||
if (tables == null || tables.length == 0) {
|
||||
if (shell != null) {
|
||||
MessageDialog.openError(shell, "Info", db + " is empty.");
|
||||
} else {
|
||||
JOptionPane.showMessageDialog(Activator.frame, db + " is empty.");
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
Connection jdbc = null;
|
||||
ResultSet rs = null;
|
||||
Statement stmt = null;
|
||||
WritableWorkbook workbook = null;
|
||||
|
||||
int currentSheet = 0;
|
||||
String outputFilePath = FileSystemView.getFileSystemView().getHomeDirectory() + "\\" + db + "_metadata.xls";
|
||||
|
||||
//System.out.println(url);
|
||||
|
||||
DatabaseMetaData dbMetaData = null;
|
||||
try {
|
||||
workbook = Workbook.createWorkbook(new File(outputFilePath));
|
||||
jdbc = Tools.getConnection();
|
||||
//System.out.println(url);
|
||||
stmt = jdbc.createStatement();
|
||||
|
||||
|
||||
for (String currentTabelle : tables) {
|
||||
currentTabelle = currentTabelle.substring(0, currentTabelle.indexOf(" - "));
|
||||
dbMetaData = jdbc.getMetaData();
|
||||
rs = dbMetaData.getColumns("GEISDB01", db, currentTabelle, null);
|
||||
|
||||
WritableSheet sheet = workbook.createSheet(currentTabelle, currentSheet);
|
||||
currentSheet++;
|
||||
|
||||
sheet.setColumnView(0, 13);
|
||||
sheet.addCell(new Label(0, 0, "Column Name"));
|
||||
|
||||
sheet.setColumnView(1, 18);
|
||||
sheet.addCell(new Label(1, 0, "Column Type Name"));
|
||||
|
||||
sheet.setColumnView(2, 12);
|
||||
sheet.addCell(new Label(2, 0, "Column Type"));
|
||||
|
||||
sheet.setColumnView(3, 8);
|
||||
sheet.addCell(new Label(3, 0, "Precision"));
|
||||
|
||||
sheet.setColumnView(4, 5);
|
||||
sheet.addCell(new Label(4, 0, "Scale"));
|
||||
|
||||
sheet.setColumnView(5, 50);
|
||||
sheet.addCell(new Label(5, 0, "Remark"));
|
||||
|
||||
int i = 1;
|
||||
|
||||
while (rs.next()) {
|
||||
sheet.addCell(new Label(0, i, rs.getString(4)));//"COLUMN_NAME"
|
||||
sheet.addCell(new Label(1, i, rs.getString(6)));//"TYPE_NAME"
|
||||
sheet.addCell(new Number(2, i, rs.getInt(5)));//"DATA_TYPE"
|
||||
sheet.addCell(new Number(3, i, rs.getInt(7)));//"COLUMN_SIZE"
|
||||
sheet.addCell(new Number(4, i, rs.getInt(9)));//"DECIMAL_DIGITS"
|
||||
sheet.addCell(new Label(5, i, rs.getString(12)));//"REMARKS"
|
||||
i++;
|
||||
}
|
||||
|
||||
if (rs != null) {
|
||||
rs.close();
|
||||
rs = null;
|
||||
}
|
||||
}
|
||||
|
||||
if (stmt != null) {
|
||||
stmt.close();
|
||||
stmt = null;
|
||||
}
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
finally {
|
||||
dbMetaData = null;
|
||||
}
|
||||
try {
|
||||
workbook.write();
|
||||
workbook.close();
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
try {
|
||||
Desktop.getDesktop().open(new File(outputFilePath));
|
||||
} catch (IOException e) {
|
||||
if (shell != null) {
|
||||
MessageDialog.openInformation(shell, "Info", "Done, exported " + outputFilePath);
|
||||
} else {
|
||||
JOptionPane.showMessageDialog(Activator.frame, "Done, exported " + outputFilePath);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,217 @@
|
||||
package geisplugin.popup.actions;
|
||||
|
||||
import geisplugin.Activator;
|
||||
import geisplugin.Tools;
|
||||
|
||||
import java.awt.Desktop;
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.sql.Connection;
|
||||
import java.sql.ResultSet;
|
||||
import java.sql.SQLException;
|
||||
import java.sql.Statement;
|
||||
|
||||
import javax.swing.JOptionPane;
|
||||
import javax.swing.filechooser.FileSystemView;
|
||||
|
||||
import jxl.Workbook;
|
||||
import jxl.write.Label;
|
||||
import jxl.write.Number;
|
||||
import jxl.write.WritableSheet;
|
||||
import jxl.write.WritableWorkbook;
|
||||
|
||||
import org.eclipse.core.commands.AbstractHandler;
|
||||
import org.eclipse.core.commands.ExecutionEvent;
|
||||
import org.eclipse.core.commands.ExecutionException;
|
||||
import org.eclipse.jface.dialogs.MessageDialog;
|
||||
import org.eclipse.swt.widgets.Shell;
|
||||
import org.eclipse.ui.handlers.HandlerUtil;
|
||||
|
||||
/**
|
||||
* DE:
|
||||
*
|
||||
* EN:
|
||||
*
|
||||
*
|
||||
* Program changes
|
||||
* **************************************************************************************
|
||||
* Date * Ticket * KonzFirm * Responsible * programmer *
|
||||
* Change *
|
||||
* **************************************************************************************
|
||||
*
|
||||
* @author huellmante
|
||||
* @version 1.0
|
||||
*/
|
||||
|
||||
public class GetMetaDataTable extends AbstractHandler {
|
||||
|
||||
public static void main(final String[] args) {
|
||||
try {
|
||||
new GetMetaDataTable().getMetaData();
|
||||
System.exit(0);
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
System.exit(-1);
|
||||
} finally {
|
||||
try {
|
||||
if (Tools.con != null && !Tools.con.isClosed()) {
|
||||
try {
|
||||
Tools.con.rollback();
|
||||
Tools.con.close();
|
||||
} catch (final SQLException e) {
|
||||
}
|
||||
Tools.con = null;
|
||||
}
|
||||
} catch (SQLException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public Object execute(final ExecutionEvent event) throws ExecutionException {
|
||||
if (Tools.isNotUpToDate()) {
|
||||
return null;
|
||||
}
|
||||
shell = HandlerUtil.getActiveShell(event);
|
||||
try {
|
||||
getMetaData();
|
||||
} finally {
|
||||
try {
|
||||
if (Tools.con != null && !Tools.con.isClosed()) {
|
||||
try {
|
||||
Tools.con.rollback();
|
||||
Tools.con.close();
|
||||
} catch (final SQLException e) {
|
||||
}
|
||||
Tools.con = null;
|
||||
}
|
||||
} catch (SQLException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
private static Shell shell = null;
|
||||
|
||||
private void getMetaData() {
|
||||
String[] dbs = null;
|
||||
|
||||
try {
|
||||
dbs = Tools.getDBs();
|
||||
} catch (Exception e) {
|
||||
}
|
||||
|
||||
if (dbs == null || dbs.length == 0) {
|
||||
|
||||
if (shell != null) {
|
||||
MessageDialog.openInformation(shell, "Info", "Couldn't find any databases, go sure your AS400 driver does exist and read the plugin documentation!");
|
||||
} else {
|
||||
JOptionPane.showMessageDialog(Activator.frame, "Couldn't find any databases, go sure your AS400 driver does exist and read the plugin documentation!");
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
String db = (String) JOptionPane.showInputDialog(Activator.frame, "Which Database?", "Select a Database", JOptionPane.PLAIN_MESSAGE, null, dbs, "GEISDTT");
|
||||
|
||||
dbs = null;
|
||||
|
||||
if (db == null) {
|
||||
return;
|
||||
}
|
||||
|
||||
db = db.substring(0, db.indexOf(" - "));
|
||||
|
||||
String[] tables = Tools.getTables(db);
|
||||
|
||||
if (tables == null || tables.length == 0) {
|
||||
if (shell != null) {
|
||||
MessageDialog.openError(shell, "Info", "No tables found for " + db + '.');
|
||||
} else {
|
||||
JOptionPane.showMessageDialog(Activator.frame, "No tables found for " + db + '.');
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
String table = (String) JOptionPane.showInputDialog(Activator.frame, "Which Table?", "Select a Table", JOptionPane.PLAIN_MESSAGE, null, tables, tables[0]);
|
||||
|
||||
tables = null;
|
||||
|
||||
if (table != null && !table.trim().isEmpty()) {
|
||||
table = table.substring(0, table.indexOf(" - "));
|
||||
getMetaDataExcel(table, db);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public void getMetaDataExcel(final String table, final String db) {
|
||||
Connection jdbc = null;
|
||||
|
||||
String outputFilePath = FileSystemView.getFileSystemView().getHomeDirectory() + "\\" + db + '_' + table + "_metadata.xls";
|
||||
|
||||
try {
|
||||
jdbc = Tools.getConnection();
|
||||
Statement stmt = jdbc.createStatement();
|
||||
ResultSet rs = jdbc.getMetaData().getColumns("GEISDB01", db, table, "%");
|
||||
|
||||
WritableWorkbook workbook = Workbook.createWorkbook(new File(outputFilePath));
|
||||
|
||||
WritableSheet sheet = workbook.createSheet(table, 0);
|
||||
|
||||
sheet.setColumnView(0, 13);
|
||||
sheet.addCell(new Label(0, 0, "Column Name"));
|
||||
|
||||
sheet.setColumnView(1, 18);
|
||||
sheet.addCell(new Label(1, 0, "Column Type Name"));
|
||||
|
||||
sheet.setColumnView(2, 12);
|
||||
sheet.addCell(new Label(2, 0, "Column Type"));
|
||||
|
||||
sheet.setColumnView(3, 8);
|
||||
sheet.addCell(new Label(3, 0, "Precision"));
|
||||
|
||||
sheet.setColumnView(4, 5);
|
||||
sheet.addCell(new Label(4, 0, "Scale"));
|
||||
|
||||
sheet.setColumnView(5, 50);
|
||||
sheet.addCell(new Label(5, 0, "Remark"));
|
||||
|
||||
int i = 1;
|
||||
|
||||
while (rs.next()) {
|
||||
sheet.addCell(new Label(0, i, rs.getString(4)));//"COLUMN_NAME"
|
||||
sheet.addCell(new Label(1, i, rs.getString(6)));//"TYPE_NAME"
|
||||
sheet.addCell(new Number(2, i, rs.getInt(5)));//"DATA_TYPE"
|
||||
sheet.addCell(new Number(3, i, rs.getInt(7)));//"COLUMN_SIZE"
|
||||
sheet.addCell(new Number(4, i, rs.getInt(9)));//"DECIMAL_DIGITS"
|
||||
sheet.addCell(new Label(5, i, rs.getString(12)));//"REMARKS"
|
||||
i++;
|
||||
}
|
||||
|
||||
workbook.write();
|
||||
workbook.close();
|
||||
|
||||
if (rs != null) {
|
||||
rs.close();
|
||||
rs = null;
|
||||
}
|
||||
if (stmt != null) {
|
||||
stmt.close();
|
||||
stmt = null;
|
||||
}
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
try {
|
||||
Desktop.getDesktop().open(new File(outputFilePath));
|
||||
} catch (IOException e) {
|
||||
if (shell != null) {
|
||||
MessageDialog.openInformation(shell, "Info", "Done, exported " + outputFilePath);
|
||||
} else {
|
||||
JOptionPane.showMessageDialog(Activator.frame, "Done, exported " + outputFilePath);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,183 @@
|
||||
package geisplugin.popup.actions;
|
||||
|
||||
import geisplugin.Activator;
|
||||
import geisplugin.Tools;
|
||||
|
||||
import java.awt.Desktop;
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.sql.Connection;
|
||||
import java.sql.ResultSet;
|
||||
import java.sql.SQLException;
|
||||
|
||||
import javax.swing.JOptionPane;
|
||||
import javax.swing.filechooser.FileSystemView;
|
||||
|
||||
import jxl.Workbook;
|
||||
import jxl.write.Label;
|
||||
import jxl.write.WritableSheet;
|
||||
import jxl.write.WritableWorkbook;
|
||||
|
||||
import org.eclipse.core.commands.AbstractHandler;
|
||||
import org.eclipse.core.commands.ExecutionEvent;
|
||||
import org.eclipse.core.commands.ExecutionException;
|
||||
import org.eclipse.jface.dialogs.MessageDialog;
|
||||
import org.eclipse.swt.widgets.Shell;
|
||||
import org.eclipse.ui.handlers.HandlerUtil;
|
||||
|
||||
/**
|
||||
* DE:
|
||||
*
|
||||
* EN:
|
||||
*
|
||||
*
|
||||
* Program changes
|
||||
* **************************************************************************************
|
||||
* Date * Ticket * KonzFirm * Responsible * programmer *
|
||||
* Change *
|
||||
* **************************************************************************************
|
||||
*
|
||||
* @author huellmante
|
||||
* @version 1.0
|
||||
*/
|
||||
|
||||
public class GetTableMetaData extends AbstractHandler {
|
||||
|
||||
public static void main(final String[] args) {
|
||||
try {
|
||||
new GetTableMetaData().getTableMetaData();
|
||||
System.exit(0);
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
System.exit(-1);
|
||||
} finally {
|
||||
try {
|
||||
if (Tools.con != null && !Tools.con.isClosed()) {
|
||||
try {
|
||||
Tools.con.rollback();
|
||||
Tools.con.close();
|
||||
} catch (final SQLException e) {
|
||||
}
|
||||
Tools.con = null;
|
||||
}
|
||||
} catch (SQLException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public Object execute(final ExecutionEvent event) throws ExecutionException {
|
||||
if (Tools.isNotUpToDate()) {
|
||||
return null;
|
||||
}
|
||||
shell = HandlerUtil.getActiveShell(event);
|
||||
try {
|
||||
getTableMetaData();
|
||||
} finally {
|
||||
try {
|
||||
if (Tools.con != null && !Tools.con.isClosed()) {
|
||||
try {
|
||||
Tools.con.rollback();
|
||||
Tools.con.close();
|
||||
} catch (final SQLException e) {
|
||||
}
|
||||
Tools.con = null;
|
||||
}
|
||||
} catch (SQLException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
private static Shell shell = null;
|
||||
|
||||
private void getTableMetaData() {
|
||||
String[] dbs = null;
|
||||
|
||||
try {
|
||||
dbs = Tools.getDBs();
|
||||
} catch (Exception e) {
|
||||
}
|
||||
|
||||
if (dbs == null || dbs.length == 0) {
|
||||
|
||||
if (shell != null) {
|
||||
MessageDialog.openInformation(shell, "Info", "Couldn't find any databases, go sure your AS400 driver does exist and read the plugin documentation!");
|
||||
} else {
|
||||
JOptionPane.showMessageDialog(Activator.frame, "Couldn't find any databases, go sure your AS400 driver does exist and read the plugin documentation!");
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
String db = (String) JOptionPane.showInputDialog(Activator.frame, "Which Database?", "Select a Database", JOptionPane.PLAIN_MESSAGE, null, dbs, "GEISDTT");
|
||||
|
||||
dbs = null;
|
||||
|
||||
if (db == null) {
|
||||
return;
|
||||
}
|
||||
|
||||
//url = "jdbc:as400://as400;libraries=" + db + ";metadata source=0";
|
||||
|
||||
db = db.substring(0, db.indexOf(" - "));
|
||||
|
||||
getTables(db);
|
||||
}
|
||||
|
||||
private void getTables(final String db) {
|
||||
|
||||
String outputFilePath = FileSystemView.getFileSystemView().getHomeDirectory() + "\\" + db + "_tables_metadata.xls";
|
||||
//System.out.println(outputFilePath);
|
||||
Connection jdbc = null;
|
||||
WritableWorkbook workbook = null;
|
||||
|
||||
try {
|
||||
workbook = Workbook.createWorkbook(new File(outputFilePath));
|
||||
jdbc = Tools.getConnection();
|
||||
|
||||
WritableSheet sheet = workbook.createSheet(db, 0);
|
||||
|
||||
sheet.setColumnView(0, 15);
|
||||
sheet.addCell(new Label(0, 0, "Table Name"));
|
||||
sheet.setColumnView(1, 60);
|
||||
sheet.addCell(new Label(1, 0, "Remarks"));
|
||||
|
||||
ResultSet rs = jdbc.getMetaData().getTables("GEISDB01", db, null, new String[] { "TABLE" });
|
||||
int i = 1;
|
||||
while (rs.next()) {
|
||||
sheet.addCell(new Label(0, i, rs.getString(3)));
|
||||
sheet.addCell(new Label(1, i, rs.getString(5)));
|
||||
i++;
|
||||
}
|
||||
|
||||
try {
|
||||
workbook.write();
|
||||
workbook.close();
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
rs.close();
|
||||
if (rs != null) {
|
||||
rs.close();
|
||||
rs = null;
|
||||
}
|
||||
|
||||
try {
|
||||
Desktop.getDesktop().open(new File(outputFilePath));
|
||||
} catch (IOException e) {
|
||||
if (shell != null) {
|
||||
MessageDialog.openInformation(shell, "Info", "Done, exported " + outputFilePath);
|
||||
} else {
|
||||
JOptionPane.showMessageDialog(Activator.frame, "Done, exported " + outputFilePath);
|
||||
}
|
||||
}
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,142 @@
|
||||
package geisplugin.popup.actions;
|
||||
|
||||
import java.sql.SQLException;
|
||||
|
||||
import org.eclipse.core.commands.AbstractHandler;
|
||||
import org.eclipse.core.commands.ExecutionEvent;
|
||||
import org.eclipse.core.commands.ExecutionException;
|
||||
import org.eclipse.core.resources.IResource;
|
||||
import org.eclipse.jdt.core.ICompilationUnit;
|
||||
import org.eclipse.jface.dialogs.MessageDialog;
|
||||
import org.eclipse.jface.viewers.IStructuredSelection;
|
||||
import org.eclipse.swt.widgets.Shell;
|
||||
import org.eclipse.ui.handlers.HandlerUtil;
|
||||
|
||||
import geisplugin.Tools;
|
||||
|
||||
/**
|
||||
* DE:
|
||||
*
|
||||
* EN:
|
||||
*
|
||||
*
|
||||
* Program changes
|
||||
* **************************************************************************************
|
||||
* Date * Ticket * KonzFirm * Responsible * programmer *
|
||||
* Change *
|
||||
* **************************************************************************************
|
||||
*
|
||||
* @author huellmante
|
||||
* @version 1.0
|
||||
*
|
||||
*/
|
||||
|
||||
public class LinkClassWithManagedbeans extends AbstractHandler {
|
||||
|
||||
@Override
|
||||
public Object execute(final ExecutionEvent event) throws ExecutionException {
|
||||
try {
|
||||
if (Tools.isNotUpToDate()) {
|
||||
return null;
|
||||
}
|
||||
} finally {
|
||||
try {
|
||||
if (Tools.con != null && !Tools.con.isClosed()) {
|
||||
try {
|
||||
Tools.con.rollback();
|
||||
Tools.con.close();
|
||||
} catch (final SQLException e) {
|
||||
}
|
||||
Tools.con = null;
|
||||
}
|
||||
} catch (SQLException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
Shell shell = HandlerUtil.getActiveShell(event);
|
||||
for (final Object firstElement : ((IStructuredSelection) HandlerUtil.getActiveMenuSelection(event)).toList()) {
|
||||
try {
|
||||
if (firstElement instanceof ICompilationUnit) {
|
||||
createOutput(shell, (ICompilationUnit) firstElement);
|
||||
} else {
|
||||
MessageDialog.openInformation(shell, "Info", "Please select a Java source file");
|
||||
}
|
||||
} catch (Exception e) {
|
||||
MessageDialog.openError(shell, "Error", "Error " + e.getMessage());
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
private void createOutput(final Shell shell, final ICompilationUnit element) {
|
||||
final String file = element.getResource().getRawLocation().toString();
|
||||
|
||||
//MessageDialog.openInformation(shell, "file", file);
|
||||
|
||||
int i = 0;
|
||||
|
||||
try {
|
||||
|
||||
String fileAsString = Tools.read(file);
|
||||
|
||||
i = 1;
|
||||
|
||||
if (!fileAsString.contains("@CCGenClass (expressionBase=\"")) {
|
||||
i = 2;
|
||||
MessageDialog.openError(shell, "Error", "This is no CCGenClass");
|
||||
return;
|
||||
}
|
||||
|
||||
i = 3;
|
||||
int index = fileAsString.indexOf("@CCGenClass (expressionBase=\"") + 29;
|
||||
i = 4;
|
||||
String expression = fileAsString.substring(index);
|
||||
i = 5;
|
||||
index = expression.indexOf('"');
|
||||
i = 6;
|
||||
expression = expression.substring(0, index);
|
||||
expression = expression.substring(expression.indexOf('.') + 1, expression.length() - 1);
|
||||
i = 7;
|
||||
|
||||
//Path vom Projekt
|
||||
// -> nicht direkt möglich, aber im CC eigentlich immer in /src/managedbeans/dispatcherinfo.xml
|
||||
|
||||
String dispatcherInfo = file.substring(0, file.indexOf("/src") + 4) + "/managedbeans/dispatcherinfo.xml";
|
||||
|
||||
i = 8;
|
||||
|
||||
//verlinkte .xmls finden -> rekursiv
|
||||
// manuelle Suche vs. XML-DOM API
|
||||
|
||||
//alle .xmls anzeigen und auswählbar machen -> ähnlich der Tabellen-/DB-Auswahl
|
||||
|
||||
String packageStr = fileAsString.substring(fileAsString.indexOf("package") + 8);
|
||||
packageStr = packageStr.substring(0, packageStr.indexOf(';'));
|
||||
//MessageDialog.openInformation(shell, "packageStr", packageStr);
|
||||
|
||||
i = 9;
|
||||
|
||||
String classStr = file.substring(file.lastIndexOf("/") + 1);
|
||||
classStr = classStr.substring(0, classStr.lastIndexOf('.'));
|
||||
//MessageDialog.openInformation(shell, "classStr", classStr);
|
||||
|
||||
i = 10;
|
||||
|
||||
String content = Tools.read(dispatcherInfo);
|
||||
|
||||
i = 11;
|
||||
|
||||
content = content.substring(0, content.lastIndexOf("</dispatcherinfo>")).trim() + "\r\n\t<managedbean name=\"" + expression + "\" class=\"" + packageStr + '.' + classStr + "\"/>\r\n\r\n</dispatcherinfo>";
|
||||
|
||||
i = 12;
|
||||
|
||||
Tools.writeNoPathCreation(dispatcherInfo, content);
|
||||
|
||||
i = 13;
|
||||
|
||||
Tools.getCurrentSelectedProject().refreshLocal(IResource.DEPTH_INFINITE, null);
|
||||
} catch (final Exception e) {
|
||||
MessageDialog.openError(shell, "Error", "Error Code: " + i + ", Line: " + e.getStackTrace()[0].getLineNumber() + ", Message: " + e.getMessage());
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,71 @@
|
||||
package geisplugin.popup.actions;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.nio.charset.Charset;
|
||||
import java.nio.file.Files;
|
||||
import java.nio.file.Paths;
|
||||
import java.text.SimpleDateFormat;
|
||||
import java.util.Date;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map.Entry;
|
||||
import java.util.regex.Matcher;
|
||||
import java.util.regex.Pattern;
|
||||
|
||||
import org.eclipse.core.commands.AbstractHandler;
|
||||
import org.eclipse.core.commands.ExecutionEvent;
|
||||
import org.eclipse.core.commands.ExecutionException;
|
||||
import org.eclipse.jface.dialogs.MessageDialog;
|
||||
import org.eclipse.swt.widgets.Shell;
|
||||
import org.eclipse.ui.handlers.HandlerUtil;
|
||||
|
||||
public class NESAS107 extends AbstractHandler {
|
||||
|
||||
@Override
|
||||
public Object execute(ExecutionEvent event) throws ExecutionException {
|
||||
Shell shell = HandlerUtil.getActiveShell(event);
|
||||
final String today = new SimpleDateFormat("d/M/yyyy").format(new Date());
|
||||
try {
|
||||
// String log = Files.readAllLines(Paths.get("\\\\nesas008\\C$\\Program Files\\UltraVNC\\mslogon.log"), Charset.forName("UTF-8")).stream()
|
||||
// .filter(s -> s.startsWith(today) && s.contains("Connection received from ") && s.contains("using"))
|
||||
// .collect(Collectors.joining("\n"));
|
||||
// MessageDialog.openInformation(shell, "Log", log);
|
||||
|
||||
StringBuilder log = new StringBuilder();
|
||||
Pattern pattern = Pattern.compile("^\\d+\\/\\d+\\/\\d+\\s((?:[0-9]|0[0-9]|1[0-9]|2[0-3]):[0-5][0-9])\\s+(?:.*)\\s+((?:25[0-5]\\.|2[0-4][0-9]\\.|[01]?[0-9][0-9]?\\.){3}(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?))(?:\\s\\w+$|\\s\\w+\\\\n|\\s\\w+\\s(\\w+))");
|
||||
|
||||
HashMap<String, String> map = new HashMap<String, String>();
|
||||
for (String string : Files.readAllLines(Paths.get("\\\\nesas107\\C$\\Program Files\\UltraVNC\\mslogon.log"), Charset.forName("UTF-8"))) {
|
||||
if (string.startsWith(today) && string.contains("Connection received") && string.contains("using") || string.startsWith(today) && string.contains("disconnected") && string.contains("Client ")) {
|
||||
Matcher matcher = pattern.matcher(string);
|
||||
while (matcher.find()) {
|
||||
if ((map.get(matcher.group(2)) == null || map.get(matcher.group(2)).trim().isEmpty()) && matcher.group(3) != null) {
|
||||
map.put(matcher.group(2), matcher.group(1)+";"+matcher.group(2)+";"+matcher.group(3));
|
||||
continue;
|
||||
}
|
||||
if (string.startsWith(today) && string.contains("disconnected") && string.contains("Client ") && map.get(matcher.group(2)) != null) {
|
||||
String[] t1 = map.get(matcher.group(2)).split(";");
|
||||
if (t1.length > 2) {
|
||||
log.append("Connection received from " + t1[0] + " till " + matcher.group(1) + " with user " + t1[2] + " and IP " + t1[1] + "\n");
|
||||
map.put(t1[1], "");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
if (!map.isEmpty()) {
|
||||
for (Entry<String, String> entry : map.entrySet()) {
|
||||
if (entry.getValue().equals("")) {
|
||||
continue;
|
||||
}
|
||||
String[] t1 = entry.getValue().split(";");
|
||||
log.append("Currently online is user "+ t1[2] + " since " + t1[0] + " with IP "+ t1[1] + "\n");
|
||||
}
|
||||
}
|
||||
MessageDialog.openInformation(shell, "Log", log.toString());
|
||||
} catch (final IOException e) {
|
||||
MessageDialog.openError(shell, "Fehler", "Fehler " + e.getMessage());
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
}
|
||||
@ -0,0 +1,93 @@
|
||||
package geisplugin.popup.actions;
|
||||
|
||||
import geisplugin.Tools;
|
||||
|
||||
import java.sql.SQLException;
|
||||
|
||||
import org.eclipse.core.commands.AbstractHandler;
|
||||
import org.eclipse.core.commands.ExecutionEvent;
|
||||
import org.eclipse.core.commands.ExecutionException;
|
||||
import org.eclipse.core.resources.IResource;
|
||||
import org.eclipse.jdt.core.ICompilationUnit;
|
||||
import org.eclipse.jface.dialogs.MessageDialog;
|
||||
import org.eclipse.jface.viewers.IStructuredSelection;
|
||||
import org.eclipse.swt.widgets.Shell;
|
||||
import org.eclipse.ui.handlers.HandlerUtil;
|
||||
|
||||
/**
|
||||
* DE:
|
||||
*
|
||||
* EN:
|
||||
*
|
||||
*
|
||||
* Program changes
|
||||
* **************************************************************************************
|
||||
* Date * Ticket * KonzFirm * Responsible * programmer *
|
||||
* Change *
|
||||
* **************************************************************************************
|
||||
*
|
||||
* @author huellmante
|
||||
* @version 1.0
|
||||
*
|
||||
*/
|
||||
|
||||
public class RemoveGenerateReflectionGetSet extends AbstractHandler {
|
||||
|
||||
@Override
|
||||
public Object execute(final ExecutionEvent event) throws ExecutionException {
|
||||
try {
|
||||
if (Tools.isNotUpToDate()) {
|
||||
return null;
|
||||
}
|
||||
} finally {
|
||||
try {
|
||||
if (Tools.con != null && !Tools.con.isClosed()) {
|
||||
try {
|
||||
Tools.con.rollback();
|
||||
Tools.con.close();
|
||||
} catch (final SQLException e) {
|
||||
}
|
||||
Tools.con = null;
|
||||
}
|
||||
} catch (SQLException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
Shell shell = HandlerUtil.getActiveShell(event);
|
||||
for (Object firstElement : ((IStructuredSelection) HandlerUtil.getActiveMenuSelection(event)).toList()) {
|
||||
try {
|
||||
if (firstElement instanceof ICompilationUnit) {
|
||||
createOutput(shell, firstElement);
|
||||
} else {
|
||||
MessageDialog.openInformation(shell, "Info", "Please select Java source file");
|
||||
}
|
||||
} catch (Exception e) {
|
||||
MessageDialog.openError(shell, "Error", "Error " + e.getMessage());
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
private void createOutput(final Shell shell, final Object firstElement) {
|
||||
try {
|
||||
|
||||
String file = ((ICompilationUnit) firstElement).getResource().getRawLocation().toString();
|
||||
|
||||
String fileAsString = Tools.read(file);
|
||||
|
||||
fileAsString = fileAsString.replace("\n\tpublic void set(String fieldname, Object value) {\t\t\n\t\t\ttry {\n\t\t\t\tif (value != null) {\n\t\t\t\t\t\n\t\t\t\t\tif (this.getClass().getField(fieldname.toLowerCase()).getType().getName().equals(\"java.lang.String\") ) {\n\t\t\t\t\t\tthis.getClass().getField(fieldname.toLowerCase()).set(this, value);\t\n\t\t\t\t\t\t\n\t\t\t\t\t} else if (this.getClass().getField(fieldname.toLowerCase()).getType().getName().equals(\"java.lang.Long\") ) {\n\t\t\t\t\t\t\n\t\t\t\t\t\tif (value == null)\n\t\t\t\t\t\t\tvalue = 0;\n\t\t\t\t\t\t\n\t\t\t\t\t\tthis.getClass().getField(fieldname.toLowerCase()).set(this, Long.parseLong(value.toString()));\t\n\t\t\t\t\t} else if (this.getClass().getField(fieldname.toLowerCase()).getType().getName().equals(\"java.lang.Integer\") ) {\n\t\t\t\t\t\tif (value.toString().trim().length() == 0)\n\t\t\t\t\t\t\tvalue = 0;\n\t\t\t\t\t\t\n\t\t\t\t\t\tthis.getClass().getField(fieldname.toLowerCase()).set(this, Integer.parseInt(value.toString()));\t\n\t\t\t\t\t} else if (this.getClass().getField(fieldname.toLowerCase()).getType().getName().equals(\"java.lang.Double\") ) {\n\t\t\t\t\t\tif (value.toString().trim().length() == 0)\n\t\t\t\t\t\t\tvalue = 0.0;\n\t\t\t\t\t\t\n\t\t\t\t\t\tthis.getClass().getField(fieldname.toLowerCase()).set(this, Double.parseDouble(value.toString()));\t\n\t\t\t\t\t} else if (this.getClass().getField(fieldname.toLowerCase()).getType().getName().equals(\"java.util.Date\") ) {\n\t\n\t\t\t\t\t} else {\n\t\t\t\t\t\tthis.getClass().getField(fieldname.toLowerCase()).set(this, value);\n\t\t\t\t\t}\n\t\t\t\t\t\n\t\t\t\t\t\n\t\t\t\t\t\n\t\t\t\t}\n\t\t\t} catch (Exception e) {\n\t\t\t\te.printStackTrace();\n\t\t\t}\n\t}\n\t\n\tpublic Object get(String fieldname) {\n\t\tObject result = null;\n\t\t\n\t\ttry {\n\t\t\t\n\t\t\tif (fieldname == null || fieldname.trim().length() == 0)\n\t\t\t\treturn \"\";\n\t\t\t\n\t\t\tresult = CCTools.getValueOf(this, fieldname.toLowerCase());\t\n\t\t\t\n\t\t\tif (result == null)\n\t\t\t\tresult = \"\";\n\t\t\t\n\t\t\t\n\t\t} catch (Exception e) {\n\t\t\te.printStackTrace();\n\t\t}\n\t\treturn result;\n\t}\n\t\n\tpublic String getType(String fieldname) {\n\t\tString result = null;\n\t\ttry {\n\t\t\t\n\t\t\tif (fieldname == null || fieldname.trim().length() == 0)\n\t\t\t\treturn \"\";\n\t\t\t\n\t\t\tresult = this.getClass().getField(fieldname.trim().toLowerCase()).getType().getName();\t\n\t\t} catch (Exception e) {\n\t\t\te.printStackTrace();\n\t\t}\n\t\treturn result;\n\t}", "");
|
||||
|
||||
//TODO
|
||||
//RegEx welches auch gemoddete Versionenen erkennt, z.B.;
|
||||
//von
|
||||
//public void set(String fieldname, Object value)[...]
|
||||
//bis
|
||||
//return result;[...]}
|
||||
|
||||
Tools.writeNoPathCreation(file, fileAsString);
|
||||
Tools.getCurrentSelectedProject().refreshLocal(IResource.DEPTH_INFINITE, null);
|
||||
} catch (Exception e) {
|
||||
MessageDialog.openError(shell, "Error", "Error!\n " + e.getMessage());
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,97 @@
|
||||
package geisplugin.popup.actions;
|
||||
|
||||
import geisplugin.Tools;
|
||||
|
||||
import java.sql.SQLException;
|
||||
|
||||
import org.eclipse.core.commands.AbstractHandler;
|
||||
import org.eclipse.core.commands.ExecutionEvent;
|
||||
import org.eclipse.core.commands.ExecutionException;
|
||||
import org.eclipse.core.resources.IResource;
|
||||
import org.eclipse.jdt.core.ICompilationUnit;
|
||||
import org.eclipse.jface.dialogs.MessageDialog;
|
||||
import org.eclipse.jface.viewers.IStructuredSelection;
|
||||
import org.eclipse.swt.widgets.Shell;
|
||||
import org.eclipse.ui.handlers.HandlerUtil;
|
||||
|
||||
/**
|
||||
* DE:
|
||||
*
|
||||
* EN:
|
||||
*
|
||||
*
|
||||
* Program changes
|
||||
* **************************************************************************************
|
||||
* Date * Ticket * KonzFirm * Responsible * programmer *
|
||||
* Change *
|
||||
* **************************************************************************************
|
||||
*
|
||||
* @author huellmante
|
||||
* @version 1.0
|
||||
*
|
||||
*/
|
||||
|
||||
public class WhiteSpaceAction extends AbstractHandler {
|
||||
|
||||
@SuppressWarnings("restriction")
|
||||
@Override
|
||||
public Object execute(final ExecutionEvent event) throws ExecutionException {
|
||||
try {
|
||||
if (Tools.isNotUpToDate()) {
|
||||
return null;
|
||||
}
|
||||
} finally {
|
||||
try {
|
||||
if (Tools.con != null && !Tools.con.isClosed()) {
|
||||
try {
|
||||
Tools.con.rollback();
|
||||
Tools.con.close();
|
||||
} catch (final SQLException e) {
|
||||
}
|
||||
Tools.con = null;
|
||||
}
|
||||
} catch (SQLException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
Shell shell = HandlerUtil.getActiveShell(event);
|
||||
boolean ok = false;
|
||||
|
||||
for (final Object selection : ((IStructuredSelection) HandlerUtil.getActiveMenuSelection(event)).toList()) {
|
||||
|
||||
String path;
|
||||
|
||||
if (selection instanceof ICompilationUnit) {
|
||||
path = ((ICompilationUnit) selection).getResource().getRawLocation().toString().trim();
|
||||
} else
|
||||
if (selection instanceof org.eclipse.core.internal.resources.File) {
|
||||
path = ((org.eclipse.core.internal.resources.File) selection).getRawLocation().toString().trim();
|
||||
} else {
|
||||
return null;
|
||||
}
|
||||
|
||||
try {
|
||||
|
||||
final String input = Tools.read(path);
|
||||
final StringBuilder fileAsString = new StringBuilder(input.length());
|
||||
|
||||
for (final String myString : input.split("\n", 0)) {
|
||||
fileAsString.append(Tools.trimEnd(myString));
|
||||
fileAsString.append('\n');
|
||||
}
|
||||
fileAsString.setLength(fileAsString.length() - 1);
|
||||
Tools.writeNoPathCreation(path, fileAsString.toString());
|
||||
Tools.getCurrentSelectedProject().refreshLocal(IResource.DEPTH_INFINITE, null);
|
||||
ok = true;
|
||||
} catch (final Exception e) {
|
||||
MessageDialog.openError(shell, "Exception", "Exception!\n " + e.getMessage());
|
||||
}
|
||||
}
|
||||
if (ok) {
|
||||
MessageDialog.openInformation(shell, "Success", "Done!");
|
||||
} else {
|
||||
MessageDialog.openWarning(shell, "Error", "Couldn't trim selected files");
|
||||
}
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
After Width: | Height: | Size: 1.1 KiB |
|
After Width: | Height: | Size: 1.1 KiB |
|
After Width: | Height: | Size: 601 B |
Loading…
Reference in new issue