initialize
This commit is contained in:
27
interface/guiconsole/.classpath
Normal file
27
interface/guiconsole/.classpath
Normal file
@@ -0,0 +1,27 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<classpath>
|
||||
<classpathentry kind="src" output="target/classes" path="src/main/java">
|
||||
<attributes>
|
||||
<attribute name="optional" value="true"/>
|
||||
<attribute name="maven.pomderived" value="true"/>
|
||||
</attributes>
|
||||
</classpathentry>
|
||||
<classpathentry kind="src" output="target/test-classes" path="src/test/java">
|
||||
<attributes>
|
||||
<attribute name="optional" value="true"/>
|
||||
<attribute name="maven.pomderived" value="true"/>
|
||||
</attributes>
|
||||
</classpathentry>
|
||||
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.8">
|
||||
<attributes>
|
||||
<attribute name="maven.pomderived" value="true"/>
|
||||
</attributes>
|
||||
</classpathentry>
|
||||
<classpathentry kind="con" path="org.eclipse.m2e.MAVEN2_CLASSPATH_CONTAINER">
|
||||
<attributes>
|
||||
<attribute name="maven.pomderived" value="true"/>
|
||||
<attribute name="org.eclipse.jst.component.nondependency" value=""/>
|
||||
</attributes>
|
||||
</classpathentry>
|
||||
<classpathentry kind="output" path="target/classes"/>
|
||||
</classpath>
|
||||
36
interface/guiconsole/.project
Normal file
36
interface/guiconsole/.project
Normal file
@@ -0,0 +1,36 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<projectDescription>
|
||||
<name>data-interface-gui-console</name>
|
||||
<comment></comment>
|
||||
<projects>
|
||||
</projects>
|
||||
<buildSpec>
|
||||
<buildCommand>
|
||||
<name>org.eclipse.wst.common.project.facet.core.builder</name>
|
||||
<arguments>
|
||||
</arguments>
|
||||
</buildCommand>
|
||||
<buildCommand>
|
||||
<name>org.eclipse.jdt.core.javabuilder</name>
|
||||
<arguments>
|
||||
</arguments>
|
||||
</buildCommand>
|
||||
<buildCommand>
|
||||
<name>org.eclipse.wst.validation.validationbuilder</name>
|
||||
<arguments>
|
||||
</arguments>
|
||||
</buildCommand>
|
||||
<buildCommand>
|
||||
<name>org.eclipse.m2e.core.maven2Builder</name>
|
||||
<arguments>
|
||||
</arguments>
|
||||
</buildCommand>
|
||||
</buildSpec>
|
||||
<natures>
|
||||
<nature>org.eclipse.jem.workbench.JavaEMFNature</nature>
|
||||
<nature>org.eclipse.wst.common.modulecore.ModuleCoreNature</nature>
|
||||
<nature>org.eclipse.jdt.core.javanature</nature>
|
||||
<nature>org.eclipse.m2e.core.maven2Nature</nature>
|
||||
<nature>org.eclipse.wst.common.project.facet.core.nature</nature>
|
||||
</natures>
|
||||
</projectDescription>
|
||||
@@ -0,0 +1,3 @@
|
||||
eclipse.preferences.version=1
|
||||
encoding//src/main/java=UTF-8
|
||||
encoding/<project>=UTF-8
|
||||
@@ -0,0 +1,8 @@
|
||||
eclipse.preferences.version=1
|
||||
org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled
|
||||
org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8
|
||||
org.eclipse.jdt.core.compiler.compliance=1.8
|
||||
org.eclipse.jdt.core.compiler.problem.assertIdentifier=error
|
||||
org.eclipse.jdt.core.compiler.problem.enumIdentifier=error
|
||||
org.eclipse.jdt.core.compiler.problem.forbiddenReference=warning
|
||||
org.eclipse.jdt.core.compiler.source=1.8
|
||||
@@ -0,0 +1,4 @@
|
||||
activeProfiles=
|
||||
eclipse.preferences.version=1
|
||||
resolveWorkspaceProjects=true
|
||||
version=1
|
||||
@@ -0,0 +1,5 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?><project-modules id="moduleCoreId" project-version="1.5.0">
|
||||
<wb-module deploy-name="data-interface-gui-console">
|
||||
<wb-resource deploy-path="/" source-path="/src/main/java"/>
|
||||
</wb-module>
|
||||
</project-modules>
|
||||
@@ -0,0 +1,5 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<faceted-project>
|
||||
<installed facet="java" version="1.8"/>
|
||||
<installed facet="jst.utility" version="1.0"/>
|
||||
</faceted-project>
|
||||
@@ -0,0 +1,2 @@
|
||||
disabled=06target
|
||||
eclipse.preferences.version=1
|
||||
66
interface/guiconsole/pom.xml
Normal file
66
interface/guiconsole/pom.xml
Normal file
@@ -0,0 +1,66 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
<groupId>com.itac.interface.interfaces</groupId>
|
||||
<artifactId>data-interface-gui-console</artifactId>
|
||||
<packaging>jar</packaging>
|
||||
<name>data-interface-gui-console</name>
|
||||
<version>${mes.interface.version}</version>
|
||||
<parent>
|
||||
<groupId>com.itac.interface</groupId>
|
||||
<artifactId>data-interface</artifactId>
|
||||
<version>${mes.interface.version}</version>
|
||||
</parent>
|
||||
<dependencies>
|
||||
<dependency>
|
||||
<groupId>com.itac.product</groupId>
|
||||
<artifactId>artes-client</artifactId>
|
||||
</dependency>
|
||||
<!-- interner -->
|
||||
<dependency>
|
||||
<groupId>com.itac.interface.interfaces</groupId>
|
||||
<artifactId>data-interface-gui</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.swinglabs</groupId>
|
||||
<artifactId>swingx</artifactId>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
<build>
|
||||
<plugins>
|
||||
<plugin>
|
||||
<groupId>com.itac.tools</groupId>
|
||||
<artifactId>webstart-plugin</artifactId>
|
||||
<executions>
|
||||
<execution>
|
||||
<phase>generate-sources</phase>
|
||||
<goals>
|
||||
<goal>itacWebstartClient</goal>
|
||||
</goals>
|
||||
</execution>
|
||||
</executions>
|
||||
<configuration>
|
||||
<applicationName>DataInterfaceAdminConsole.jnlp</applicationName>
|
||||
<title>iTAC.MES.DataInterface Administration Console</title>
|
||||
<description>iTAC.MES.DataInterface Administration Console</description>
|
||||
<category>standard</category>
|
||||
<mainClass>com.itac.mes.datainterface.DataInterfaceAdminConsole</mainClass>
|
||||
<offlineAllowed>false</offlineAllowed>
|
||||
<!-- optional params -->
|
||||
<shortdescription>iTAC.MES.Suite administration console</shortdescription>
|
||||
<tooltip>iTAC.MES.DataInterface Administration Console</tooltip>
|
||||
<icon>com/itac/resource/binaries/companyIcon.png</icon>
|
||||
<jvmArgs>-showversion</jvmArgs>
|
||||
<properties>
|
||||
<property>
|
||||
<name>itac.appid</name>
|
||||
<value>adminConsole</value>
|
||||
</property>
|
||||
</properties>
|
||||
</configuration>
|
||||
</plugin>
|
||||
</plugins>
|
||||
</build>
|
||||
|
||||
</project>
|
||||
@@ -0,0 +1,71 @@
|
||||
/*
|
||||
* Copyright (c) 2013 iTAC Software AG, Germany. All Rights Reserved.
|
||||
*
|
||||
* This software is protected by copyright. Under no circumstances may any part of this file in any form be copied,
|
||||
* printed, edited or otherwise distributed, be stored in a retrieval system, or be translated into another language
|
||||
* without the written permission of iTAC Software AG.
|
||||
*/
|
||||
package com.itac.mes.datainterface;
|
||||
|
||||
import static com.itac.util.logging.LogLevel.ERROR;
|
||||
|
||||
import java.net.InetAddress;
|
||||
import java.util.Date;
|
||||
|
||||
import com.itac.mes.datainterface.data.InterfaceStartType;
|
||||
import com.itac.mes.datainterface.ihap.IRemoteInterface;
|
||||
import com.itac.util.logging.LogHandler;
|
||||
|
||||
public class CheckClientConnectionThread extends Thread {
|
||||
|
||||
private static String LOGGER = CheckClientConnectionThread.class.getSimpleName();
|
||||
// fuer diese properties soll die Verbindung geprueft werden
|
||||
private RemoteInterfaceInfo remoteIntfInfo;
|
||||
private int controlPort;
|
||||
private DataInterfaceAdminConsole adminConsole;
|
||||
|
||||
public CheckClientConnectionThread(String name, DataInterfaceAdminConsole adminConsole, RemoteInterfaceInfo remoteInterfaceInfo,
|
||||
int controlPort) {
|
||||
super(name);
|
||||
this.adminConsole = adminConsole;
|
||||
this.remoteIntfInfo = remoteInterfaceInfo;
|
||||
this.controlPort = controlPort;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void run() {
|
||||
IRemoteInterface remoteInterfaceConnection = null;
|
||||
try {
|
||||
remoteInterfaceConnection = remoteIntfInfo.getConnection();
|
||||
InetAddress addr = InetAddress.getLocalHost();
|
||||
if (remoteInterfaceConnection == null) {
|
||||
// update der Instanz, nicht erreichbar, nicht richtig konfiguriert.
|
||||
adminConsole.updateView(remoteIntfInfo);
|
||||
return;
|
||||
}
|
||||
String hostname = addr.getHostName();
|
||||
remoteInterfaceConnection.setGuiConsoleProperties(hostname, controlPort);
|
||||
remoteIntfInfo.lastUpdated = new Date();
|
||||
remoteIntfInfo.title = remoteInterfaceConnection.getTitle(null);
|
||||
remoteIntfInfo.instanceInfos = remoteInterfaceConnection.getInstanceInfos();
|
||||
remoteIntfInfo.type = remoteInterfaceConnection.getStartType();
|
||||
adminConsole.updateView(remoteIntfInfo);
|
||||
} catch (Throwable e1) {
|
||||
LogHandler.log(LOGGER, ERROR, "client " + remoteIntfInfo.appid + " not reachable, connection refused");
|
||||
// Connection problem
|
||||
remoteIntfInfo.lastUpdated = new Date();
|
||||
remoteIntfInfo.instanceInfos = null;
|
||||
remoteIntfInfo.title = "";
|
||||
remoteIntfInfo.type = InterfaceStartType.UNKNOWN;
|
||||
// wenn diese Instanz bisher geoeffnet war dann View schliessen
|
||||
adminConsole.closeView(remoteIntfInfo.appid);
|
||||
} finally {
|
||||
if (remoteInterfaceConnection != null) {
|
||||
remoteInterfaceConnection.shutdown();
|
||||
}
|
||||
}
|
||||
LogHandler.log(LOGGER, ERROR, "finishing thread" + this.getName());
|
||||
this.interrupt();
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,960 @@
|
||||
/*
|
||||
* Copyright (c) 2013 iTAC Software AG, Germany. All Rights Reserved.
|
||||
*
|
||||
* This software is protected by copyright. Under no circumstances may any part of this file in any form be copied, printed, edited
|
||||
* or otherwise distributed, be stored in a retrieval system, or be translated into another language without the written permission
|
||||
* of iTAC Software AG.
|
||||
*/
|
||||
package com.itac.mes.datainterface;
|
||||
|
||||
import static com.itac.artes.ArtesPropertyNames.PROP_ARTES_CLUSTERNODES;
|
||||
import static com.itac.util.constants.imsapi.ImsApiKey.CONFIG_ADMIN;
|
||||
import static com.itac.util.constants.imsapi.ImsApiKey.CONFIG_APPID;
|
||||
import static com.itac.util.constants.imsapi.ImsApiKey.CONFIG_APPTYPE;
|
||||
import static com.itac.util.constants.imsapi.ImsApiKey.CONFIG_CLUSTER;
|
||||
import static com.itac.util.constants.imsapi.ImsApiKey.CONFIG_VALUE;
|
||||
import static com.itac.util.constants.imsapi.ImsApiKey.PARAMETER_NAME;
|
||||
import static com.itac.util.constants.imsapi.ImsApiKey.PARAMETER_SCOPE;
|
||||
import static com.itac.util.logging.LogLevel.DEBUG;
|
||||
import static com.itac.util.logging.LogLevel.ERROR;
|
||||
import static com.itac.util.logging.LogLevel.INFO;
|
||||
import static com.itac.util.logging.LogLevel.WARN;
|
||||
|
||||
import java.awt.event.ActionEvent;
|
||||
import java.awt.event.ComponentAdapter;
|
||||
import java.awt.event.ComponentEvent;
|
||||
import java.awt.event.WindowAdapter;
|
||||
import java.awt.event.WindowEvent;
|
||||
import java.io.IOException;
|
||||
import java.net.InetAddress;
|
||||
import java.net.URL;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Date;
|
||||
import java.util.HashMap;
|
||||
import java.util.HashSet;
|
||||
import java.util.Hashtable;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import javax.jnlp.BasicService;
|
||||
import javax.jnlp.ServiceManager;
|
||||
import javax.swing.AbstractAction;
|
||||
import javax.swing.JFrame;
|
||||
import javax.swing.JOptionPane;
|
||||
import javax.swing.SwingUtilities;
|
||||
import javax.swing.UIManager;
|
||||
|
||||
import com.itac.artes.ArtesSettings;
|
||||
import com.itac.artes.ihap.LocatorFactory;
|
||||
import com.itac.artes.ihas.LookupException;
|
||||
import com.itac.mes.client.ImsApiTools;
|
||||
import com.itac.mes.config.domain.ItacConfigException;
|
||||
import com.itac.mes.config.domain.Parameter;
|
||||
import com.itac.mes.datainterface.config.AdminConsoleConfig;
|
||||
import com.itac.mes.datainterface.control.LoginJob;
|
||||
import com.itac.mes.datainterface.control.LoginListener;
|
||||
import com.itac.mes.datainterface.data.AdminConsoleWindowSettings;
|
||||
import com.itac.mes.datainterface.data.InterfaceStartType;
|
||||
import com.itac.mes.datainterface.data.Rectangle;
|
||||
import com.itac.mes.datainterface.data.Settings;
|
||||
import com.itac.mes.datainterface.gui.DataInterfaceAdminConsoleDlg;
|
||||
import com.itac.mes.datainterface.gui.DataInterfaceConsoleDlg;
|
||||
import com.itac.mes.datainterface.gui.DataInterfaceMenuAction;
|
||||
import com.itac.mes.datainterface.gui.ISimulationMessageReceiver;
|
||||
import com.itac.mes.datainterface.gui.IWorkerPane;
|
||||
import com.itac.mes.datainterface.gui.InstanceMessage;
|
||||
import com.itac.mes.datainterface.gui.OpenViewListener;
|
||||
import com.itac.mes.datainterface.gui.SettingsDlg;
|
||||
import com.itac.mes.datainterface.ihap.IRemoteGui;
|
||||
import com.itac.mes.datainterface.ihap.IRemoteInterface;
|
||||
import com.itac.mes.datainterface.ihap.InstanceInfo;
|
||||
import com.itac.mes.datainterface.ihap.RemoteGuiSocketAdapter;
|
||||
import com.itac.mes.datainterface.service.LoginService;
|
||||
import com.itac.mes.imsapi.domain.IMSApiService;
|
||||
import com.itac.mes.imsapi.domain.container.KeyValue;
|
||||
import com.itac.mes.imsapi.domain.container.Result_configGetDimensionValues;
|
||||
import com.itac.mes.imsapi.domain.container.Result_configGetValues;
|
||||
import com.itac.resource.ResourcePool;
|
||||
import com.itac.resource.ResourcesIMSInterfaces;
|
||||
import com.itac.util.constants.imsapi.ImsApiKey;
|
||||
import com.itac.util.logging.LogHandler;
|
||||
import com.itac.util.logging.LogLevel;
|
||||
|
||||
public class DataInterfaceAdminConsole implements IRemoteGui, ISimulationMessageReceiver, OpenViewListener, LoginListener {
|
||||
|
||||
public static final String APPTYPE = DataInterfaceAdminConsole.class.getSimpleName();
|
||||
private static final String LOGGER = DataInterfaceAdminConsole.class.getSimpleName();
|
||||
/**
|
||||
* das ist der Port, der von der AdminCosole aufgemacht wird, und auf dem die Interface Daten an die console schicken können
|
||||
*/
|
||||
private static final String CONTROL_PORT = APPTYPE + ".controlPort";
|
||||
/** hier werden die eigenen GUI-eigenschaften gespeichert */
|
||||
private static final String WINDOW_SETTINGS = APPTYPE + ".windowSettings";
|
||||
/**
|
||||
* eine Liste mit allen app-ids, feur die z.Zt. eine View offen ist. Diese Liste wird beim beenden des Clients geschrieben und
|
||||
* beim erneuten starten werden alle diese Views versucht erneut zu offnen
|
||||
*/
|
||||
private static final String OPEN_VIEW_LIST = APPTYPE + ".openViewList";
|
||||
private static final String SETTINGS = APPTYPE + ".settings";
|
||||
private static final String VALID_CONFIGURATIONS_ONLY = SETTINGS + ".validConfigurationsOnly";
|
||||
|
||||
// statische Instanz
|
||||
private static DataInterfaceAdminConsole dataInterfaceAdminConsole;
|
||||
private RemoteGuiSocketAdapter remoteGuiSock;
|
||||
private AdminConsoleConfig adminConsoleConfig;
|
||||
private DataInterfaceAdminConsoleDlg adminConsoleDlg;
|
||||
private SettingsDlg settingsDlg;
|
||||
private int iControlPort;
|
||||
|
||||
private Settings settings = new Settings();
|
||||
|
||||
private LoginJob loginJob;
|
||||
|
||||
// alle geöffneten Dialog sind hier gehalten
|
||||
private Map<String, DataInterfaceConsoleDlg> dataInterfaceDlgMap = new HashMap<String, DataInterfaceConsoleDlg>();
|
||||
|
||||
/** Liste mit allen konfigurierten APP-IDS */
|
||||
private List<RemoteInterfaceInfo> remoteInterfaceInfos;
|
||||
|
||||
private Object syncObject = new Object();
|
||||
private Parameter windowPositionParameter;
|
||||
|
||||
private Map<String, Thread> checkThreadMap = new HashMap<String, Thread>();
|
||||
|
||||
private Thread connectionCheckThread = new Thread("CheckInterfacesThread") {
|
||||
|
||||
@Override
|
||||
public void run() {
|
||||
// über alle
|
||||
while (true) {
|
||||
|
||||
synchronized (syncObject) {
|
||||
LogHandler.log(APPTYPE, DEBUG, "start updating all interfaces connections ");
|
||||
for (RemoteInterfaceInfo remoteInterfaceInfo : remoteInterfaceInfos) {
|
||||
if (!remoteInterfaceInfo.hasValidConnectionProperties()) {
|
||||
LogHandler.log(APPTYPE, INFO,
|
||||
"connection properties for appid " + remoteInterfaceInfo.appid + " are invalid, do not connect");
|
||||
adminConsoleDlg.setStatus(ResourcePool.getInstance()
|
||||
.getMesExceptionMessage(ResourcesIMSInterfaces.INVALID_CONNECTION_PROPERTIES, remoteInterfaceInfo.appid));
|
||||
continue;
|
||||
}
|
||||
|
||||
// es wurden theoretisch gueltige Connection Properties gefunden
|
||||
// versuchen, diesen Client zu erreichen
|
||||
try {
|
||||
Thread chkConnthread = getConnectionThread(dataInterfaceAdminConsole, remoteInterfaceInfo, iControlPort);
|
||||
try {
|
||||
chkConnthread.start();
|
||||
} catch (IllegalThreadStateException e) {
|
||||
// remove Thread from map if not working any longer
|
||||
checkThreadMap.remove(chkConnthread.getName());
|
||||
}
|
||||
} catch (Exception e) {
|
||||
LogHandler.log(APPTYPE, ERROR, "failed to connect to client " + remoteInterfaceInfo.appid, e);
|
||||
adminConsoleDlg.setStatus(ResourcePool.getInstance()
|
||||
.getMesExceptionMessage(ResourcesIMSInterfaces.CONNECTION_TO_CLIENT_FAILED, remoteInterfaceInfo.appid));
|
||||
closeView(remoteInterfaceInfo.appid);
|
||||
}
|
||||
remoteInterfaceInfo.lastUpdated = new Date();
|
||||
}
|
||||
adminConsoleDlg.setRemoteInterfaceInfo(remoteInterfaceInfos);
|
||||
}
|
||||
|
||||
try {
|
||||
Thread.sleep(10000);
|
||||
} catch (InterruptedException e) {
|
||||
// Egal, wenn diese Exception auftritt
|
||||
}
|
||||
}
|
||||
}
|
||||
};
|
||||
private ComponentAdapter componentListener;
|
||||
private AbstractAction settingsAction;
|
||||
private AbstractAction reScanAction;
|
||||
|
||||
private Thread getConnectionThread(DataInterfaceAdminConsole adminConsole, RemoteInterfaceInfo remoteInterfaceInfo,
|
||||
int controlPort) {
|
||||
|
||||
String threadName = "ConnectionThread-" + remoteInterfaceInfo.appid + "@" + remoteInterfaceInfo.port;
|
||||
if (checkThreadMap.containsKey(threadName)) {
|
||||
return checkThreadMap.get(threadName);
|
||||
}
|
||||
|
||||
Thread thread = new CheckClientConnectionThread(threadName, dataInterfaceAdminConsole, remoteInterfaceInfo, iControlPort);
|
||||
checkThreadMap.put(threadName, thread);
|
||||
return thread;
|
||||
}
|
||||
|
||||
public static void main(String[] args) {
|
||||
installShutDownHook();
|
||||
|
||||
// versuchen die clusternodes automatisch zu ermitteln
|
||||
if (System.getProperty(PROP_ARTES_CLUSTERNODES) == null) {
|
||||
try {
|
||||
BasicService bs = (BasicService) ServiceManager.lookup("javax.jnlp.BasicService");
|
||||
URL url = bs.getCodeBase();
|
||||
// url parsing unterschiedlich
|
||||
URL newUrl = new URL(url.getProtocol(), url.getHost(), url.getPort(), "/mes");
|
||||
String value = newUrl.toString();
|
||||
System.out.println("autodetect: set property " + PROP_ARTES_CLUSTERNODES + " to " + value);
|
||||
System.setProperty(PROP_ARTES_CLUSTERNODES, value);
|
||||
} catch (Exception ex) {
|
||||
// es gibt zu diesem Zeitpunkt noch kein initialisiertes Logging
|
||||
// keep System err and printStackTrace, because at the moment of calling logging is not initialized
|
||||
System.err.println("automatic detection of MES failed");
|
||||
ex.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
ArtesSettings.getAppId();
|
||||
|
||||
// Set default look and feel
|
||||
try {
|
||||
UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName());
|
||||
} catch (Exception cnfe) {
|
||||
// keep System err and printStackTrace, because at the moment of calling logging is not initialized
|
||||
System.err.println("Failed to set LookAndFeel");
|
||||
cnfe.printStackTrace();
|
||||
}
|
||||
|
||||
try {
|
||||
// versuchen einen Dienst aufzuloesen
|
||||
LocatorFactory.getLocator().lookup(IMSApiService.class);
|
||||
} catch (LookupException e) {
|
||||
// Im Fehlerfalle ein sinnvolle Fehlermeldung zeigen und nicht nur die Exception loggen
|
||||
JOptionPane.showConfirmDialog(null,
|
||||
"Unable to resolve ImsApi service at " + System.getProperty(PROP_ARTES_CLUSTERNODES) + "\n" + "Please check: \n"
|
||||
+ " 1. the server is reachable at this address \n" + " 2. you provided a valid value for property '"
|
||||
+ PROP_ARTES_CLUSTERNODES + "'" + " to the webstart application",
|
||||
"Server not reachable", JOptionPane.ERROR_MESSAGE);
|
||||
System.exit(-1);
|
||||
}
|
||||
|
||||
// startup GUI Application
|
||||
try {
|
||||
dataInterfaceAdminConsole = new DataInterfaceAdminConsole();
|
||||
dataInterfaceAdminConsole.start();
|
||||
} catch (Exception ex) {
|
||||
LogHandler.log(APPTYPE, ERROR, "gui failed", ex);
|
||||
DataInterface.dataInterface.finish();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* safely shutdown Artes Client; release open or pending connections.
|
||||
*/
|
||||
public static void installShutDownHook() {
|
||||
Runtime.getRuntime().addShutdownHook(new Thread("shutdownhook") {
|
||||
@Override
|
||||
public void run() {
|
||||
try {
|
||||
LocatorFactory.getLocator().shutdown();
|
||||
LogHandler.log(LOGGER, INFO, "artes client shut down");
|
||||
} catch (Exception e) {
|
||||
// ignore exception, print Only if possible
|
||||
LogHandler.log(LOGGER, INFO, "problem safely shutdown artes client");
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
protected void settingsChanged() {
|
||||
adminConsoleConfig.updateParameterValue(VALID_CONFIGURATIONS_ONLY, settings.validConfigurationsOnly);
|
||||
}
|
||||
|
||||
public DataInterfaceAdminConsole() {
|
||||
super();
|
||||
// erzeugen der eigenen Konfiguration
|
||||
try {
|
||||
adminConsoleConfig = new AdminConsoleConfig(APPTYPE);
|
||||
declareParameter();
|
||||
adminConsoleConfig.readAndUpdateConfiguration();
|
||||
// jetzt stehen alle Parameter und alle Werte bereit !!!
|
||||
} catch (Exception e) {
|
||||
LogHandler.log(APPTYPE, ERROR, "creation failed", e);
|
||||
}
|
||||
|
||||
loginJob = new LoginJob(this, new LoginService(adminConsoleConfig));
|
||||
componentListener = new ComponentAdapter() {
|
||||
|
||||
@Override
|
||||
public void componentHidden(ComponentEvent e) {
|
||||
try {
|
||||
DataInterfaceConsoleDlg dataInterfaceDlg = (DataInterfaceConsoleDlg) e.getSource();
|
||||
LogHandler.log(APPTYPE, INFO, "closing dialog " + dataInterfaceDlg.getRemoteInterfaceInfo().appid);
|
||||
closeView(dataInterfaceDlg.getRemoteInterfaceInfo().appid);
|
||||
} catch (Exception exception) {
|
||||
LogHandler.log(APPTYPE, ERROR, "creation failed", exception);
|
||||
}
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
private void declareParameter() {
|
||||
Parameter root = new Parameter(APPTYPE, APPTYPE, Void.class, "010", AdminConsoleConfig.defaultDimPath);
|
||||
adminConsoleConfig.declareParameter(root, null, null);
|
||||
adminConsoleConfig.declareParameter(
|
||||
new Parameter(CONTROL_PORT, "control port", Integer.class, "020", AdminConsoleConfig.defaultDimPath), root,
|
||||
new Integer(33050));
|
||||
adminConsoleConfig.declareParameter(new Parameter(WINDOW_SETTINGS, "window settings", AdminConsoleWindowSettings.class, "030",
|
||||
AdminConsoleConfig.defaultDimPath), root, new AdminConsoleWindowSettings(100, 100, 500, 500));
|
||||
Parameter openViewListParam = new Parameter(OPEN_VIEW_LIST, "open views ", List.class, "040",
|
||||
AdminConsoleConfig.defaultDimPath);
|
||||
openViewListParam.setMetaType(String.class);
|
||||
adminConsoleConfig.declareParameter(openViewListParam, root, new ArrayList<String>());
|
||||
|
||||
Parameter settings = new Parameter(SETTINGS, SETTINGS, Void.class, "100", AdminConsoleConfig.defaultDimPath);
|
||||
adminConsoleConfig.declareParameter(settings, root, null);
|
||||
|
||||
Parameter validConfigsOnly = new Parameter(VALID_CONFIGURATIONS_ONLY, "valid configurations only", Boolean.class, "110",
|
||||
AdminConsoleConfig.defaultDimPath);
|
||||
adminConsoleConfig.declareParameter(validConfigsOnly, settings, true);
|
||||
}
|
||||
|
||||
public void start() throws ItacConfigException {
|
||||
// Grundvoraussetzung: vorhandener API-Service
|
||||
if (adminConsoleConfig.getImsApiService() == null) {
|
||||
LogHandler.log(APPTYPE, ERROR, "no ImsAPI Service available");
|
||||
JOptionPane.showConfirmDialog(null, "ImsApi Service is missing; application start is not possible", "Application Failure",
|
||||
JOptionPane.ERROR_MESSAGE);
|
||||
exit();
|
||||
}
|
||||
|
||||
// zuerst eine Anmeldung, ohne die kann der User nichts machen! Unabhaengig davon werden z.B. schon Einstellungen
|
||||
// geladen, der login startet in einem Thread.
|
||||
loginJob.show();
|
||||
|
||||
// last size and position from window
|
||||
AdminConsoleWindowSettings wds = adminConsoleConfig.getValue(WINDOW_SETTINGS, AdminConsoleWindowSettings.class);
|
||||
if (wds == null) {
|
||||
wds = new AdminConsoleWindowSettings();// enthaelt bereits default-Werte
|
||||
}
|
||||
|
||||
settings.validConfigurationsOnly = adminConsoleConfig.getValue(VALID_CONFIGURATIONS_ONLY, Boolean.class);
|
||||
settings.changed = false;
|
||||
|
||||
settingsDlg = new SettingsDlg();
|
||||
|
||||
// Dialog anzeigen
|
||||
adminConsoleDlg = new DataInterfaceAdminConsoleDlg();
|
||||
adminConsoleDlg.setBounds(wds.left, wds.top, wds.width, wds.height);
|
||||
adminConsoleDlg.setOnOpenViewListener(this);
|
||||
adminConsoleDlg.setSettings(settings);
|
||||
|
||||
settingsAction = new AbstractAction(ResourcePool.getInstance().getString(ResourcesIMSInterfaces.MNU_SETTINGS)) {
|
||||
|
||||
@Override
|
||||
public void actionPerformed(ActionEvent e) {
|
||||
settingsDlg.setSettings(settings);
|
||||
settingsDlg.setModal(true);
|
||||
settingsDlg.setVisible(true);
|
||||
if (settings.changed) {
|
||||
LogHandler.log(LOGGER, INFO, "changed settings");
|
||||
adminConsoleConfig.updateParameterValue(VALID_CONFIGURATIONS_ONLY, settings.validConfigurationsOnly);
|
||||
adminConsoleDlg.setSettings(settings);
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
reScanAction = new AbstractAction(ResourcePool.getInstance().getString(ResourcesIMSInterfaces.MNU_RESCAN)) {
|
||||
|
||||
@Override
|
||||
public void actionPerformed(ActionEvent ae) {
|
||||
|
||||
synchronized (syncObject) {
|
||||
adminConsoleDlg.setStatus(ResourcePool.getInstance().getString(ResourcesIMSInterfaces.RESCAN_APPIDS));
|
||||
remoteInterfaceInfos = getConfiguredAppIds();
|
||||
// zu diesen die Konfigurationen ermitteln (Host, Port ect).
|
||||
for (RemoteInterfaceInfo remoteIntfInfo : remoteInterfaceInfos) {
|
||||
getRemoteInterfaceConnectionSettings(remoteIntfInfo);
|
||||
if (remoteIntfInfo.hasValidConnectionProperties()) {
|
||||
// es wurden theoretisch gueltige Connection Properties gefunden
|
||||
// versuchen, diesen Client zu erreichen
|
||||
|
||||
Thread chkConnthread = getConnectionThread(dataInterfaceAdminConsole, remoteIntfInfo, iControlPort);
|
||||
try {
|
||||
chkConnthread.start();
|
||||
} catch (IllegalThreadStateException e) {
|
||||
// remove Thread from map if not working any longer
|
||||
checkThreadMap.remove(chkConnthread.getName());
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
adminConsoleDlg.setSettingsAction(settingsAction);
|
||||
adminConsoleDlg.setRescanAction(reScanAction);
|
||||
adminConsoleDlg.addWindowListener(new WindowAdapter() {
|
||||
|
||||
@Override
|
||||
public void windowClosed(WindowEvent e) {
|
||||
// main window closed
|
||||
finish();
|
||||
exit();
|
||||
}
|
||||
});
|
||||
adminConsoleDlg.setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE);
|
||||
|
||||
try {
|
||||
checkOrCreateDataInterfaceGuiParameters();
|
||||
} catch (Exception e1) {
|
||||
LogHandler.log(APPTYPE, ERROR, "gui parameters not created", e1);
|
||||
JOptionPane.showConfirmDialog(null,
|
||||
"Application did not create or update all parameters properly.\n" + "Request manufacturer support on this issue",
|
||||
"Application Failure", JOptionPane.ERROR_MESSAGE);
|
||||
System.exit(-3);
|
||||
}
|
||||
|
||||
// den eigenen Endpunkt checken und öffnen
|
||||
try {
|
||||
iControlPort = adminConsoleConfig.getValue(CONTROL_PORT, Integer.class);
|
||||
remoteGuiSock = new RemoteGuiSocketAdapter(iControlPort, dataInterfaceAdminConsole);
|
||||
remoteGuiSock.start();
|
||||
} catch (Exception e) {
|
||||
SwingUtilities.invokeLater(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
loginJob.cancel();
|
||||
}
|
||||
});
|
||||
JOptionPane.showConfirmDialog(null,
|
||||
"Initial start of this Application\n" + "The application automatically created a number of configuration parameters\n"
|
||||
+ "Please configure them properly before restarting the client. You will find them in the Workplace, Application, type...",
|
||||
"Application Hint", JOptionPane.INFORMATION_MESSAGE);
|
||||
System.exit(-2);
|
||||
}
|
||||
// im Hintergrund bereits die Infos zu den Views laden...
|
||||
Thread initThread = new Thread("Init Thread") {
|
||||
public void run() {
|
||||
// alle konfigurierten APP-Ids zum Scope ermitteln
|
||||
synchronized (syncObject) {
|
||||
remoteInterfaceInfos = getConfiguredAppIds();
|
||||
|
||||
// zu diesen die Konfigurationen ermitteln (Host, Port ect).
|
||||
for (RemoteInterfaceInfo remoteIntfInfo : remoteInterfaceInfos) {
|
||||
getRemoteInterfaceConnectionSettings(remoteIntfInfo);
|
||||
if (remoteIntfInfo.hasValidConnectionProperties()) {
|
||||
// es wurden theoretisch gueltige Connection Properties gefunden
|
||||
// versuchen, diesen Client zu erreichen
|
||||
Thread chkConnthread = getConnectionThread(dataInterfaceAdminConsole, remoteIntfInfo, iControlPort);
|
||||
try {
|
||||
chkConnthread.start();
|
||||
} catch (IllegalThreadStateException e) {
|
||||
// remove Thread from map if not working any longer
|
||||
checkThreadMap.remove(chkConnthread.getName());
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
};
|
||||
initThread.start();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onLoginCancelled() {
|
||||
System.exit(-1);
|
||||
}
|
||||
|
||||
public void onLoginSuccess() {
|
||||
adminConsoleDlg.setVisible(true);
|
||||
adminConsoleDlg.invalidate();
|
||||
adminConsoleDlg.repaint();
|
||||
|
||||
SwingUtilities.invokeLater(new Runnable() {
|
||||
public void run() {
|
||||
@SuppressWarnings("unchecked")
|
||||
List<String> appIdList = adminConsoleConfig.getValue(OPEN_VIEW_LIST, List.class);
|
||||
HashSet<String> openViewSet = new HashSet<String>();
|
||||
if (appIdList != null) {
|
||||
openViewSet.addAll(appIdList);
|
||||
}
|
||||
|
||||
synchronized (syncObject) {
|
||||
// diese Daten so weit schon mal im Tablemodel setzen
|
||||
adminConsoleDlg.setRemoteInterfaceInfo(remoteInterfaceInfos);
|
||||
|
||||
// zu diesen die Konfigurationen ermitteln (Host, Port ect).
|
||||
for (RemoteInterfaceInfo remoteIntfInfo : remoteInterfaceInfos) {
|
||||
// Tabellendaten updaten
|
||||
adminConsoleDlg.setRemoteInterfaceInfo(remoteInterfaceInfos);
|
||||
if (openViewSet.contains(remoteIntfInfo.appid)) {
|
||||
openView(remoteIntfInfo);
|
||||
}
|
||||
}
|
||||
|
||||
// Tabellendaten updaten
|
||||
adminConsoleDlg.setRemoteInterfaceInfo(remoteInterfaceInfos);
|
||||
}
|
||||
// Thread starten, der zyklisch nachschaut, ob alle instanzen verfügbar sind
|
||||
if (!connectionCheckThread.isAlive()) {
|
||||
connectionCheckThread.start();
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
private boolean checkClientConnection(RemoteInterfaceInfo remoteIntfInfo) {
|
||||
IRemoteInterface remoteDataInterface = null;
|
||||
boolean instanceAvailable = false;
|
||||
try {
|
||||
remoteDataInterface = remoteIntfInfo.getConnection();
|
||||
InetAddress addr = InetAddress.getLocalHost();
|
||||
if (remoteDataInterface == null) {
|
||||
return false;
|
||||
}
|
||||
String hostname = addr.getHostName();
|
||||
remoteDataInterface.setGuiConsoleProperties(hostname, iControlPort);
|
||||
remoteIntfInfo.lastUpdated = new Date();
|
||||
remoteIntfInfo.title = remoteDataInterface.getTitle(null);
|
||||
remoteIntfInfo.instanceInfos = remoteDataInterface.getInstanceInfos();
|
||||
remoteIntfInfo.type = remoteDataInterface.getStartType();
|
||||
instanceAvailable = true;
|
||||
} catch (IOException e1) {
|
||||
LogHandler.log(APPTYPE, ERROR, "client " + remoteIntfInfo.appid + " not reachable, connection refused");
|
||||
// Connection problem
|
||||
remoteIntfInfo.lastUpdated = new Date();
|
||||
remoteIntfInfo.instanceInfos = null;
|
||||
remoteIntfInfo.title = "";
|
||||
remoteIntfInfo.type = InterfaceStartType.UNKNOWN;
|
||||
if (dataInterfaceDlgMap.containsKey(remoteIntfInfo.appid)) {
|
||||
closeView(remoteIntfInfo.appid);
|
||||
}
|
||||
} finally {
|
||||
if (remoteDataInterface != null) {
|
||||
remoteDataInterface.shutdown();
|
||||
}
|
||||
}
|
||||
return instanceAvailable;
|
||||
}
|
||||
|
||||
// aus der Konfigurationn zu den einzelnen Interfacen die Connection-Properties laden
|
||||
private void getRemoteInterfaceConnectionSettings(RemoteInterfaceInfo remoteIntfInfo) {
|
||||
LogHandler.log(LOGGER, INFO, "get connection settings for remote interface with appid: " + remoteIntfInfo.appid);
|
||||
KeyValue[] options = new KeyValue[] { new KeyValue(CONFIG_ADMIN.name(), "JLPMHRGGEDKO") };
|
||||
KeyValue[] configContext = new KeyValue[] { new KeyValue(CONFIG_APPTYPE.name(), DataInterface.APPTYPE),
|
||||
new KeyValue(CONFIG_CLUSTER.name(), LocatorFactory.getLocator().getClusterName()),
|
||||
new KeyValue(CONFIG_APPID.name(), remoteIntfInfo.appid) };
|
||||
|
||||
KeyValue[] parameterFilterPort = new KeyValue[] { new KeyValue(PARAMETER_NAME.name(), RemoteLocation.PORT) };
|
||||
KeyValue[] parameterFilterHost = new KeyValue[] { new KeyValue(PARAMETER_NAME.name(), RemoteLocation.HOSTNAME) };
|
||||
|
||||
String[] paramResultKeys = new String[0];
|
||||
String[] resultKeys = ImsApiTools.getKeys(CONFIG_VALUE);
|
||||
Result_configGetValues configDimValues = adminConsoleConfig.getImsApiService().configGetValues(
|
||||
adminConsoleConfig.getImsSessionContext(), options, configContext, parameterFilterPort, paramResultKeys, resultKeys);
|
||||
if (configDimValues != null && configDimValues.resultValues != null && configDimValues.resultValues.length > 0) {
|
||||
remoteIntfInfo.port = Integer.parseInt(configDimValues.resultValues[0]);
|
||||
} else {
|
||||
remoteIntfInfo.port = -1;
|
||||
}
|
||||
Result_configGetValues configDimValuesHost = adminConsoleConfig.getImsApiService().configGetValues(
|
||||
adminConsoleConfig.getImsSessionContext(), options, configContext, parameterFilterHost, paramResultKeys, resultKeys);
|
||||
if (configDimValuesHost != null && configDimValuesHost.resultValues != null && configDimValuesHost.resultValues.length > 0) {
|
||||
remoteIntfInfo.host = configDimValuesHost.resultValues[0];
|
||||
} else {
|
||||
remoteIntfInfo.host = null;
|
||||
}
|
||||
}
|
||||
|
||||
protected void exit() {
|
||||
System.exit(0);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return all available DimValues for AppType Data Interface
|
||||
*/
|
||||
private List<RemoteInterfaceInfo> getConfiguredAppIds() {
|
||||
List<RemoteInterfaceInfo> retList = new ArrayList<RemoteInterfaceInfo>();
|
||||
|
||||
KeyValue[] options = new KeyValue[] { new KeyValue(PARAMETER_SCOPE.name(), DataInterface.APPTYPE) };
|
||||
KeyValue[] dimensionFilter = new KeyValue[] { new KeyValue(CONFIG_APPID.name(), "*") };
|
||||
Result_configGetDimensionValues configDimValues = adminConsoleConfig.getImsApiService()
|
||||
.configGetDimensionValues(adminConsoleConfig.getImsSessionContext(), options, dimensionFilter);
|
||||
if (configDimValues != null && configDimValues.resultValues != null && configDimValues.resultValues.length > 0) {
|
||||
for (String value : configDimValues.resultValues) {
|
||||
RemoteInterfaceInfo ris = new RemoteInterfaceInfo();
|
||||
ris.appid = value;
|
||||
retList.add(ris);
|
||||
}
|
||||
}
|
||||
return retList;
|
||||
}
|
||||
|
||||
public void finish() {
|
||||
saveOpenViews();
|
||||
try {
|
||||
// close all open connections
|
||||
// save window position
|
||||
saveWindowPositions();
|
||||
} catch (Exception e) {
|
||||
LogHandler.log(APPTYPE, ERROR, "unable to update window position in configuration", 1);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* save all appids for all currently open views to configuration; if any exception occures logs and ignore them
|
||||
*/
|
||||
private void saveOpenViews() {
|
||||
try {
|
||||
// save list with all open appids
|
||||
List<String> openAppIds = new ArrayList<String>();
|
||||
openAppIds.addAll(dataInterfaceDlgMap.keySet());
|
||||
adminConsoleConfig.updateParameterValue(OPEN_VIEW_LIST, openAppIds);
|
||||
} catch (Exception e) {
|
||||
LogHandler.log(APPTYPE, ERROR, "unable to store all currently open views", e);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* zentraqler Eingang von Benachrichtigungen über Zustandsänderungen der MenuItems. diese müssen von hier aus an die
|
||||
* Dialoge/Menues weiter verteilt werden.
|
||||
*/
|
||||
@Override
|
||||
public synchronized void notifyActionPropertiesChanged(String appId, String instanceName, DataInterfaceMenuAction action) {
|
||||
// incoming calls from gui-less interface, delegate them to the corresponding view
|
||||
LogHandler.log(APPTYPE, DEBUG, "properties changed by gui-less interface '" + appId + "' : " + action);
|
||||
DataInterfaceConsoleDlg dataInterfaceDlg = getDataInterfaceDlg(appId);
|
||||
if (dataInterfaceDlg != null) {
|
||||
dataInterfaceDlg.setActionProperties(action, instanceName);
|
||||
}
|
||||
}
|
||||
|
||||
// den entsprechenden Dialog zu dieser AppId finden
|
||||
private DataInterfaceConsoleDlg getDataInterfaceDlg(String appId) {
|
||||
if (dataInterfaceDlgMap == null) {
|
||||
LogHandler.log(APPTYPE, INFO, "no data interface available in map");
|
||||
return null;
|
||||
}
|
||||
DataInterfaceConsoleDlg dlg = dataInterfaceDlgMap.get(appId);
|
||||
if (dlg == null) {
|
||||
LogHandler.log(APPTYPE, INFO, "data interface with appid " + appId + " not found in map");
|
||||
}
|
||||
return dlg;
|
||||
}
|
||||
|
||||
@Override
|
||||
public synchronized void addMessage(String appId, String instanceName, LogLevel level, boolean append, String text) {
|
||||
// incoming calls from gui-less interface, delegate them to the corresponding view
|
||||
LogHandler.log(APPTYPE, DEBUG, "addMessage received from gui-less interface '" + appId + "', instance '" + instanceName + "'");
|
||||
// die entsprechende view finden
|
||||
IWorkerPane pane = getWorkerPane(appId, instanceName);
|
||||
if (pane != null) {
|
||||
pane.addMessage(instanceName, level, append, text);
|
||||
}
|
||||
}
|
||||
|
||||
private IWorkerPane getWorkerPane(String appId, String instanceName) {
|
||||
DataInterfaceConsoleDlg dataInterfaceDlg = getDataInterfaceDlg(appId);
|
||||
if (dataInterfaceDlg == null) {
|
||||
LogHandler.log(APPTYPE, WARN, "view for appid " + appId + " not found");
|
||||
return null;
|
||||
}
|
||||
IWorkerPane pane = dataInterfaceDlg.getOrCreateWorkerPane(instanceName);
|
||||
if (pane == null) {
|
||||
LogHandler.log(APPTYPE, WARN, "pane " + instanceName + " for appid " + appId + " not found");
|
||||
return null;
|
||||
}
|
||||
return pane;
|
||||
}
|
||||
|
||||
@Override
|
||||
public synchronized void addMessage(String appId, String instanceName, LogLevel level, String text) {
|
||||
// incoming calls from gui-less interface, delegate them to the corresponding view
|
||||
addMessage(appId, instanceName, level, false, text);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void clear(String appId, String instanceName) {
|
||||
// incoming calls from gui-less interface, delegate them to the corresponding view
|
||||
LogHandler.log(APPTYPE, DEBUG, "clear received from gui-less interface '" + appId + "', instance '" + instanceName + "'");
|
||||
IWorkerPane pane = getWorkerPane(appId, instanceName);
|
||||
if (pane != null) {
|
||||
pane.clear();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void fireMenuItem(final DataInterfaceMenuAction menuItem) {
|
||||
// dieses Ereignis per IHAp an das Interface delegieren
|
||||
|
||||
IRemoteInterface connection = null;
|
||||
try {
|
||||
RemoteInterfaceInfo remoteInterfaceInfo = getRemoteInterface(menuItem.getAppid());
|
||||
if (remoteInterfaceInfo == null) {
|
||||
LogHandler.log(APPTYPE, ERROR, "remote interface not available");
|
||||
return;
|
||||
}
|
||||
//
|
||||
connection = remoteInterfaceInfo.getConnection();
|
||||
if (connection == null) {
|
||||
LogHandler.log(APPTYPE, ERROR, "remote interface available but not connected");
|
||||
return;
|
||||
}
|
||||
connection.fireMenuItem(menuItem);
|
||||
} catch (Exception e) {
|
||||
LogHandler.log(APPTYPE, ERROR, "menu item not fired because remote interface not available", e);
|
||||
} finally {
|
||||
if (connection != null) {
|
||||
connection.shutdown();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private RemoteInterfaceInfo getRemoteInterface(String appid) {
|
||||
for (RemoteInterfaceInfo remoteIntf : remoteInterfaceInfos) {
|
||||
if (remoteIntf.appid.equals(appid)) {
|
||||
return remoteIntf;
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
protected void saveWindowPositions() {
|
||||
LogHandler.log(LOGGER, INFO, "get and store main window position/size");
|
||||
AdminConsoleWindowSettings wds = adminConsoleConfig.getValue(WINDOW_SETTINGS, AdminConsoleWindowSettings.class);
|
||||
if (wds == null) {
|
||||
wds = new AdminConsoleWindowSettings();// enthaelt bereits default-Werte
|
||||
}
|
||||
wds.left = adminConsoleDlg.getX();
|
||||
wds.top = adminConsoleDlg.getY();
|
||||
wds.width = adminConsoleDlg.getWidth();
|
||||
wds.height = adminConsoleDlg.getHeight();
|
||||
adminConsoleConfig.updateParameterValue(WINDOW_SETTINGS, wds);
|
||||
}
|
||||
|
||||
/**
|
||||
* Diese Methode wird am Remote-caller aufgerufen, steuert aber nur die IHap-Kommunikation und kommt nie bis zum Call-Empfaenger
|
||||
* durch.
|
||||
*/
|
||||
@Override
|
||||
public void setChannelName(String name) {
|
||||
// Methode bleibt leer
|
||||
}
|
||||
|
||||
/**
|
||||
* Diese Methode wird am Remote-caller aufgerufen, steuert aber nur die IHap-Kommunikation und kommt nie bis zum Call-Empfaenger
|
||||
* durch.
|
||||
*/
|
||||
@Override
|
||||
public void shutdown() {
|
||||
// Methode bleibt leer
|
||||
}
|
||||
|
||||
public void openInterfaceConsoleDialog(RemoteInterfaceInfo remoteIntfInfo) {
|
||||
if (!checkClientConnection(remoteIntfInfo)) {
|
||||
return;
|
||||
}
|
||||
|
||||
adminConsoleDlg.setStatus(ResourcePool.getInstance().getMessage(ResourcesIMSInterfaces.OPENING_INSTANCE, remoteIntfInfo.appid));
|
||||
|
||||
final DataInterfaceConsoleDlg dataInterfaceDlg = new DataInterfaceConsoleDlg();
|
||||
// dataInterfaceDlg.setGuiConsole(dataInterfaceAdminConsole);
|
||||
|
||||
// dataInterfaceDlg.addWindowListener(closeViewListener);
|
||||
dataInterfaceDlg.addComponentListener(componentListener);
|
||||
try {
|
||||
IRemoteInterface remoteDataInterface = remoteIntfInfo.getConnection();
|
||||
|
||||
// Initialierung des Remote-Interface ist nun vollstaendig !!
|
||||
readDialogSettings(dataInterfaceDlg, remoteIntfInfo.appid);
|
||||
|
||||
dataInterfaceDlg.setVisible(true);
|
||||
dataInterfaceDlg.setTitle(remoteDataInterface.getTitle(null));
|
||||
// Infos von der Remote-Schnittstelle laden...
|
||||
|
||||
String mainTab = remoteDataInterface.getMainTab();
|
||||
LogHandler.log(APPTYPE, INFO, "found main Tab " + mainTab);
|
||||
IWorkerPane mainPane = dataInterfaceDlg.getOrCreateWorkerPane(mainTab);
|
||||
|
||||
List<DataInterfaceMenuAction> mnuMainActions = remoteDataInterface.getActions(mainTab);
|
||||
// wenn eine dieser Actions ausgeloest wird muss diese Info an diese Instanz (remoteDataInterface)
|
||||
// weitergeleitet werden
|
||||
if (mnuMainActions != null) {
|
||||
// Aktionen, die Worker-uebergreifend sind (startAll, stopAll);
|
||||
for (DataInterfaceMenuAction dataInterfaceMenuAction : mnuMainActions) {
|
||||
dataInterfaceMenuAction.setInstanceName(mainTab);
|
||||
dataInterfaceMenuAction.setAppid(remoteIntfInfo.appid);
|
||||
dataInterfaceMenuAction.addSimulationMessageReceiver(this);
|
||||
dataInterfaceMenuAction.setEnabled(true);
|
||||
}
|
||||
mainPane.setMenuItems(mnuMainActions);
|
||||
}
|
||||
mainPane.setDescription(remoteDataInterface.getDescription(mainTab));
|
||||
mainPane.setTitle(remoteDataInterface.getTitle(mainTab));
|
||||
dataInterfaceDlg.createWorkerView(mainPane, mnuMainActions);
|
||||
|
||||
List<InstanceMessage> mainMessages = remoteDataInterface.getInstanceMessages(mainTab);
|
||||
// diese Messages in der View darstellen;
|
||||
if (mainMessages != null && mainMessages.size() > 0) {
|
||||
for (InstanceMessage instanceMessage : mainMessages) {
|
||||
mainPane.addMessage(mainTab, instanceMessage.getLevel(), instanceMessage.getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
List<InstanceInfo> instances = remoteIntfInfo.instanceInfos;
|
||||
// alle Fenster der Reihe nach erstellen
|
||||
for (InstanceInfo instanceInfo : instances) {
|
||||
String instName = instanceInfo.getInstanceName();
|
||||
try {
|
||||
LogHandler.log(APPTYPE, INFO, "found instance " + instName);
|
||||
IWorkerPane workerPane = dataInterfaceDlg.getOrCreateWorkerPane(instName);
|
||||
|
||||
List<DataInterfaceMenuAction> mnuActions = remoteDataInterface.getActions(instName);
|
||||
// wenn eine dieser Actions ausgeloest wird muss diese Info an diese Instanz (remoteDataInterface)
|
||||
// weitergeleitet werden
|
||||
for (DataInterfaceMenuAction dataInterfaceMenuAction : mnuActions) {
|
||||
dataInterfaceMenuAction.setInstanceName(instName);
|
||||
dataInterfaceMenuAction.setAppid(remoteIntfInfo.appid);
|
||||
dataInterfaceMenuAction.addSimulationMessageReceiver(this);
|
||||
}
|
||||
workerPane.setMenuItems(mnuActions);
|
||||
workerPane.setDescription(remoteDataInterface.getDescription(instName));
|
||||
dataInterfaceDlg.createWorkerView(workerPane, mnuActions);
|
||||
|
||||
List<InstanceMessage> messages = remoteDataInterface.getInstanceMessages(instName);
|
||||
// diese Messages in der View darstellen;
|
||||
if (messages != null && messages.size() > 0) {
|
||||
for (InstanceMessage instanceMessage : messages) {
|
||||
workerPane.addMessage(mainTab, instanceMessage.getLevel(), instanceMessage.getMessage());
|
||||
}
|
||||
}
|
||||
} catch (Exception e) {
|
||||
LogHandler.log(APPTYPE, ERROR, "instance " + instName + " not created properly");
|
||||
}
|
||||
}
|
||||
|
||||
dataInterfaceDlg.setRemoteInterface(remoteDataInterface);
|
||||
dataInterfaceDlg.setRemoteInterfaceInfo(remoteIntfInfo);
|
||||
} catch (IOException e1) {
|
||||
// Connection problem
|
||||
remoteIntfInfo.lastUpdated = new Date();
|
||||
remoteIntfInfo.instanceInfos = null;
|
||||
remoteIntfInfo.title = "";
|
||||
|
||||
// evtl. aus der Liste der offenen Instanzen loeschen.
|
||||
dataInterfaceDlgMap.remove(remoteIntfInfo.appid);
|
||||
return;
|
||||
}
|
||||
dataInterfaceDlgMap.put(remoteIntfInfo.appid, dataInterfaceDlg);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void finish(String appid) {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void openView(RemoteInterfaceInfo rmio) {
|
||||
// gibt es bereits einen Dialog zu diesem rmio
|
||||
DataInterfaceConsoleDlg dlg = dataInterfaceDlgMap.get(rmio.appid);
|
||||
if (dlg != null) {
|
||||
if (!dlg.isVisible()) {
|
||||
// anzeigen wenn verborgen
|
||||
dlg.setVisible(true);
|
||||
}
|
||||
return;
|
||||
}
|
||||
openInterfaceConsoleDialog(rmio);
|
||||
}
|
||||
|
||||
public void updateView(RemoteInterfaceInfo remoteIntfInfo) {
|
||||
// die connection Parameter fuer diese View Updaten
|
||||
adminConsoleDlg.updateRemoteInterfaceInfo(remoteIntfInfo);
|
||||
}
|
||||
|
||||
public void closeView(String appid) {
|
||||
// Remote Interface informieren dass die GUI beendet wird
|
||||
DataInterfaceConsoleDlg dlg = dataInterfaceDlgMap.get(appid);
|
||||
if (dlg == null) {
|
||||
return;
|
||||
}
|
||||
|
||||
// Wert zum Interface mit der entsprechenden APP-Id speichern
|
||||
saveDialogSettings(dlg, appid);
|
||||
dlg.setVisible(false);
|
||||
try {
|
||||
dlg.getRemoteDataInterface().setGuiConsoleProperties("", 0);
|
||||
} catch (Exception e) {
|
||||
adminConsoleDlg.setStatus(ResourcePool.getInstance().getMessage(ResourcesIMSInterfaces.INSTANCE_CLOSED, appid));
|
||||
}
|
||||
dataInterfaceDlgMap.remove(appid);
|
||||
}
|
||||
|
||||
public void checkOrCreateDataInterfaceGuiParameters() throws Exception {
|
||||
// gibt es den Interface - Root-Parameter?
|
||||
KeyValue scope = new KeyValue(ImsApiKey.PARAMETER_SCOPE.name(), DataInterface.APPTYPE);
|
||||
List<Parameter> interfaceRootParamList = adminConsoleConfig.getScopeParameters(scope);
|
||||
// nein, dann ENDE
|
||||
if (interfaceRootParamList == null) {
|
||||
throw new Exception("No DataInterface Parameter found at all");
|
||||
}
|
||||
|
||||
Hashtable<String, Parameter> declaredParameters = new Hashtable<String, Parameter>();
|
||||
// check for parameter window.position
|
||||
boolean found = false;
|
||||
Parameter rootParam = null;
|
||||
for (Parameter p : interfaceRootParamList) {
|
||||
if (p.getName().equals(WindowSettings.WINDOW_POSITION)) {
|
||||
found = true;
|
||||
}
|
||||
if (p.getName().equals(".version")) {
|
||||
rootParam = p;
|
||||
}
|
||||
}
|
||||
Parameter windowParam = declaredParameters.get(WindowSettings.WINDOW_POSITION);
|
||||
if (!found) {
|
||||
windowParam.setScope(scope);
|
||||
windowParam.setParentId(rootParam.getId());
|
||||
windowParam = adminConsoleConfig.insertParameter(windowParam);
|
||||
} else {
|
||||
for (Parameter p : interfaceRootParamList) {
|
||||
if (p.getName().equals(WindowSettings.WINDOW_POSITION)) {
|
||||
windowParam = p;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// gibt es den window.position parameter
|
||||
found = false;
|
||||
for (Parameter p : interfaceRootParamList) {
|
||||
if (p.getName().equals(WindowSettings.WINDOW_POSITION)) {
|
||||
windowPositionParameter = p;
|
||||
found = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (!found) {
|
||||
windowPositionParameter = declaredParameters.get(WindowSettings.WINDOW_POSITION);
|
||||
windowPositionParameter.setScope(scope);
|
||||
windowPositionParameter.setParentId(windowParam.getId());
|
||||
windowPositionParameter = adminConsoleConfig.insertParameter(windowPositionParameter);
|
||||
}
|
||||
}
|
||||
|
||||
private void saveDialogSettings(DataInterfaceConsoleDlg dlg, String appid) {
|
||||
try {
|
||||
Rectangle r = dlg.getRectangle();
|
||||
LogHandler.log(APPTYPE, INFO, "updating position to " + dlg.getRemoteInterfaceInfo().appid);
|
||||
adminConsoleConfig.updateParameterValue(windowPositionParameter, DataInterface.APPTYPE, appid, r);
|
||||
} catch (Exception e) {
|
||||
// update der Position konnte nicht ausgeführt werden.
|
||||
LogHandler.log(APPTYPE, ERROR, "updating position for dialog " + dlg.getRemoteInterfaceInfo().appid + " failed", e);
|
||||
}
|
||||
}
|
||||
|
||||
private void readDialogSettings(DataInterfaceConsoleDlg dlg, String appid) {
|
||||
try {
|
||||
KeyValue scope = new KeyValue(ImsApiKey.PARAMETER_SCOPE.name(), DataInterface.APPTYPE);
|
||||
Parameter windowParam = adminConsoleConfig.getDataInterfaceParameter(scope, WindowSettings.WINDOW_POSITION);
|
||||
Rectangle r = adminConsoleConfig.getParameterValue(windowParam, scope, DataInterface.APPTYPE, appid);
|
||||
dlg.setBounds(r.left, r.top, r.width, r.height);
|
||||
} catch (Exception e) {
|
||||
// lesen der Position konnte nicht ausgeführt werden.
|
||||
LogHandler.log(APPTYPE, ERROR, "reading position for dialog " + appid + " failed", e);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,95 @@
|
||||
/*
|
||||
* Copyright (c) 2014 iTAC Software AG, Germany. All Rights Reserved.
|
||||
*
|
||||
* This software is protected by copyright. Under no circumstances may any part of this file in any form be copied,
|
||||
* printed, edited or otherwise distributed, be stored in a retrieval system, or be translated into another language
|
||||
* without the written permission of iTAC Software AG.
|
||||
*/
|
||||
package com.itac.mes.datainterface.control;
|
||||
|
||||
import static com.itac.util.logging.LogLevel.DEBUG;
|
||||
import static com.itac.util.logging.LogLevel.ERROR;
|
||||
|
||||
import java.awt.event.ActionEvent;
|
||||
import java.awt.event.ActionListener;
|
||||
|
||||
import javax.swing.SwingUtilities;
|
||||
|
||||
import com.itac.mes.datainterface.gui.DataInterfaceLoginDlg;
|
||||
import com.itac.mes.datainterface.service.LoginService;
|
||||
import com.itac.util.logging.LogHandler;
|
||||
|
||||
public class LoginJob implements Runnable {
|
||||
|
||||
private static final String LOGGER = LoginJob.class.getSimpleName();
|
||||
private DataInterfaceLoginDlg loginDialog;
|
||||
private LoginListener loginListener;
|
||||
private LoginService loginService;
|
||||
|
||||
public LoginJob(final LoginListener loginListener, LoginService loginService) {
|
||||
this.loginListener = loginListener;
|
||||
this.loginService = loginService;
|
||||
|
||||
loginDialog = new DataInterfaceLoginDlg();
|
||||
loginDialog.pack();
|
||||
|
||||
loginDialog.getOkBtn().addActionListener(new ActionListener() {
|
||||
|
||||
@Override
|
||||
public void actionPerformed(ActionEvent e) {
|
||||
run();
|
||||
}
|
||||
});
|
||||
|
||||
loginDialog.getCancelBtn().addActionListener(new ActionListener() {
|
||||
|
||||
@Override
|
||||
public void actionPerformed(ActionEvent e) {
|
||||
if (loginListener != null) {
|
||||
loginListener.onLoginCancelled();
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
public void cancel() {
|
||||
if (loginDialog != null) {
|
||||
loginDialog.setVisible(false);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void run() {
|
||||
try {
|
||||
loginDialog.getLoginStatusLabel().setText("wait for login");
|
||||
|
||||
String client = loginDialog.getClientField().getText();
|
||||
String user = loginDialog.getUserField().getText();
|
||||
String password = String.valueOf(loginDialog.getPasswordField().getPassword());
|
||||
|
||||
String loginResult = loginService.login(user, password, client);
|
||||
if (loginResult != null && loginResult.length() > 0) {
|
||||
loginDialog.getLoginStatusLabel().setText(loginResult);
|
||||
return;
|
||||
}
|
||||
loginDialog.dispose();
|
||||
if (loginListener != null) {
|
||||
loginListener.onLoginSuccess();
|
||||
}
|
||||
} catch (Throwable th) {
|
||||
LogHandler.log(LOGGER, ERROR, "login failed!", th);
|
||||
}
|
||||
}
|
||||
|
||||
public void show() {
|
||||
LogHandler.log(LOGGER, DEBUG, "startLogin");
|
||||
|
||||
SwingUtilities.invokeLater(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
loginDialog.setVisible(true);
|
||||
}
|
||||
});
|
||||
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,14 @@
|
||||
/*
|
||||
* Copyright (c) 2014 iTAC Software AG, Germany. All Rights Reserved.
|
||||
*
|
||||
* This software is protected by copyright. Under no circumstances may any part of this file in any form be copied,
|
||||
* printed, edited or otherwise distributed, be stored in a retrieval system, or be translated into another language
|
||||
* without the written permission of iTAC Software AG.
|
||||
*/
|
||||
package com.itac.mes.datainterface.control;
|
||||
|
||||
public interface LoginListener {
|
||||
public void onLoginSuccess();
|
||||
|
||||
public void onLoginCancelled();
|
||||
}
|
||||
@@ -0,0 +1,8 @@
|
||||
package com.itac.mes.datainterface.data;
|
||||
|
||||
public class Settings {
|
||||
|
||||
public boolean validConfigurationsOnly = false;
|
||||
public boolean changed;
|
||||
|
||||
}
|
||||
@@ -0,0 +1,56 @@
|
||||
/*
|
||||
* Copyright (c) 2013 iTAC Software AG, Germany. All Rights Reserved.
|
||||
*
|
||||
* This software is protected by copyright. Under no circumstances may any part of this file in any form be copied,
|
||||
* printed, edited or otherwise distributed, be stored in a retrieval system, or be translated into another language
|
||||
* without the written permission of iTAC Software AG.
|
||||
*/
|
||||
package com.itac.mes.datainterface.gui;
|
||||
|
||||
import java.awt.Graphics;
|
||||
import java.awt.Image;
|
||||
import java.awt.event.ComponentAdapter;
|
||||
import java.awt.event.ComponentEvent;
|
||||
|
||||
import javax.swing.JPanel;
|
||||
|
||||
import com.itac.resource.ResourcePool;
|
||||
import com.itac.resource.ResourcesIMSInterfacesImages;
|
||||
|
||||
/**
|
||||
* @author frankp
|
||||
*
|
||||
*/
|
||||
public class BackgroundPanel extends JPanel {
|
||||
|
||||
private transient Image imageOrg = null;
|
||||
private transient Image image = null;
|
||||
{
|
||||
addComponentListener(new ComponentAdapter() {
|
||||
@Override
|
||||
public void componentResized(ComponentEvent e) {
|
||||
final int w = BackgroundPanel.this.getWidth();
|
||||
final int h = BackgroundPanel.this.getHeight();
|
||||
image = w > 0 && h > 0 ? imageOrg.getScaledInstance(w, h, Image.SCALE_SMOOTH) : imageOrg;
|
||||
BackgroundPanel.this.repaint();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates new form Header
|
||||
*/
|
||||
public BackgroundPanel() {
|
||||
imageOrg = ResourcePool.getInstance().getImage(ResourcesIMSInterfacesImages.BLUE_GRADIENT_BACKGROUND);
|
||||
image = ResourcePool.getInstance().getImage(ResourcesIMSInterfacesImages.BLUE_GRADIENT_BACKGROUND);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void paintComponent(Graphics g) {
|
||||
|
||||
super.paintComponent(g);
|
||||
if (image != null) {
|
||||
g.drawImage(image, 0, 0, null);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,201 @@
|
||||
/*
|
||||
* Copyright (c) 2013 iTAC Software AG, Germany. All Rights Reserved.
|
||||
*
|
||||
* This software is protected by copyright. Under no circumstances may any part of this file in any form be copied,
|
||||
* printed, edited or otherwise distributed, be stored in a retrieval system, or be translated into another language
|
||||
* without the written permission of iTAC Software AG.
|
||||
*/
|
||||
package com.itac.mes.datainterface.gui;
|
||||
|
||||
import java.awt.Point;
|
||||
import java.awt.Toolkit;
|
||||
import java.awt.datatransfer.Clipboard;
|
||||
import java.awt.datatransfer.StringSelection;
|
||||
import java.awt.event.ActionEvent;
|
||||
import java.awt.event.ActionListener;
|
||||
import java.awt.event.KeyEvent;
|
||||
import java.awt.event.MouseAdapter;
|
||||
import java.awt.event.MouseEvent;
|
||||
import java.util.List;
|
||||
|
||||
import javax.swing.AbstractAction;
|
||||
import javax.swing.JComponent;
|
||||
import javax.swing.JFrame;
|
||||
import javax.swing.JLabel;
|
||||
import javax.swing.JMenu;
|
||||
import javax.swing.JMenuBar;
|
||||
import javax.swing.JMenuItem;
|
||||
import javax.swing.JScrollPane;
|
||||
import javax.swing.JTable;
|
||||
import javax.swing.KeyStroke;
|
||||
import javax.swing.ListSelectionModel;
|
||||
import javax.swing.SwingUtilities;
|
||||
|
||||
import com.itac.mes.datainterface.ColorCellRenderer;
|
||||
import com.itac.mes.datainterface.RemoteInterfaceInfo;
|
||||
import com.itac.mes.datainterface.RemoteInterfaceTableModel;
|
||||
import com.itac.mes.datainterface.data.Settings;
|
||||
import com.itac.resource.ResourcePool;
|
||||
import com.itac.resource.ResourcesIMSInterfaces;
|
||||
import com.itac.resource.ResourcesImages;
|
||||
import com.itac.resource.ResourcesInterfaceFramework;
|
||||
import com.jgoodies.layout.layout.ColumnSpec;
|
||||
import com.jgoodies.layout.layout.FormLayout;
|
||||
import com.jgoodies.layout.layout.FormSpecs;
|
||||
import com.jgoodies.layout.layout.RowSpec;
|
||||
|
||||
public class DataInterfaceAdminConsoleDlg extends JFrame {
|
||||
|
||||
private RemoteInterfaceTableModel tableModel = new RemoteInterfaceTableModel();
|
||||
private JTable table;
|
||||
private OpenViewListener onOpenViewListener;
|
||||
private JLabel lblStatus;
|
||||
private JMenuItem mntmSettings;
|
||||
private JMenuItem mntmRescan;
|
||||
private Settings settings;
|
||||
|
||||
public DataInterfaceAdminConsoleDlg() {
|
||||
try {
|
||||
setIconImage(ResourcePool.getInstance().getImage(ResourcesImages.ICON_MES));
|
||||
} catch (Exception npe) {
|
||||
// ignore problems when setting Icon
|
||||
}
|
||||
setTitle("DataInterface Admin Console");
|
||||
getContentPane().setLayout(
|
||||
new FormLayout(new ColumnSpec[] { FormSpecs.RELATED_GAP_COLSPEC, ColumnSpec.decode("default:grow"),
|
||||
FormSpecs.LABEL_COMPONENT_GAP_COLSPEC, }, new RowSpec[] { FormSpecs.RELATED_GAP_ROWSPEC,
|
||||
FormSpecs.DEFAULT_ROWSPEC, FormSpecs.RELATED_GAP_ROWSPEC, RowSpec.decode("default:grow"),
|
||||
FormSpecs.RELATED_GAP_ROWSPEC, FormSpecs.DEFAULT_ROWSPEC, FormSpecs.LINE_GAP_ROWSPEC, }));
|
||||
|
||||
table = new JTable();
|
||||
table.setBorder(null);
|
||||
table.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
|
||||
table.setRowSelectionAllowed(true);
|
||||
table.setColumnSelectionAllowed(false);
|
||||
|
||||
table.setModel(tableModel);
|
||||
table.getTableHeader().setResizingAllowed(true);
|
||||
table.getTableHeader().setReorderingAllowed(false);
|
||||
table.getColumnModel().getColumn(0).setPreferredWidth(119);
|
||||
table.getColumnModel().getColumn(1).setPreferredWidth(92);
|
||||
table.getColumnModel().getColumn(4).setPreferredWidth(113);
|
||||
|
||||
table.setDefaultRenderer(JLabel.class, new ColorCellRenderer());
|
||||
|
||||
ActionListener listener = new ActionListener() {
|
||||
public void actionPerformed(ActionEvent event) {
|
||||
doCopy();
|
||||
}// end actionPerformed(ActionEvent)
|
||||
};
|
||||
|
||||
final KeyStroke stroke = KeyStroke.getKeyStroke(KeyEvent.VK_C, ActionEvent.CTRL_MASK, false);
|
||||
|
||||
table.registerKeyboardAction(listener, "Copy", stroke, JComponent.WHEN_FOCUSED);
|
||||
|
||||
table.addMouseListener(new MouseAdapter() {
|
||||
@Override
|
||||
public void mouseClicked(MouseEvent e) {
|
||||
if (e.getClickCount() == 2) {
|
||||
Point p = e.getPoint();
|
||||
int row = table.rowAtPoint(p);
|
||||
|
||||
RemoteInterfaceInfo rmio = tableModel.getData(row);
|
||||
if (onOpenViewListener != null) {
|
||||
onOpenViewListener.openView(rmio);
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
JLabel lblNewLabel = ComponentFactory.createLabel("Interface Overview", ResourcesIMSInterfaces.INTERFACE_OVERVIEW);
|
||||
getContentPane().add(lblNewLabel, "2, 2");
|
||||
|
||||
JScrollPane scrollPane = new JScrollPane(table);
|
||||
scrollPane.setBorder(null);
|
||||
getContentPane().add(scrollPane, "2, 4, fill, fill");
|
||||
|
||||
lblStatus = new JLabel("");
|
||||
getContentPane().add(lblStatus, "2, 6, fill, top");
|
||||
|
||||
JMenuBar menuBar = new JMenuBar();
|
||||
setJMenuBar(menuBar);
|
||||
|
||||
JMenu mnNewMenu = ComponentFactory.createMenu(ResourcePool.getInstance().getString(ResourcesInterfaceFramework.INTERFACEFRAMEWORK_MENU_FILE), -1, KeyEvent.VK_F);
|
||||
menuBar.add(mnNewMenu);
|
||||
|
||||
mntmSettings = new JMenuItem("NLS Settings");
|
||||
mntmSettings.setMnemonic(KeyEvent.VK_S);
|
||||
|
||||
mntmRescan = new JMenuItem("NLS RESCAN");
|
||||
mntmRescan.setMnemonic(KeyEvent.VK_R);
|
||||
|
||||
mnNewMenu.add(mntmSettings);
|
||||
mnNewMenu.add(mntmRescan);
|
||||
|
||||
JMenuItem mntmExit = ComponentFactory.createMenuItem("Exit", -1, 0);
|
||||
mntmExit.setAction(new AbstractAction(ResourcePool.getInstance().getString(ResourcesIMSInterfaces.MNU_EXIT)) {
|
||||
|
||||
@Override
|
||||
public void actionPerformed(ActionEvent e) {
|
||||
dispose();
|
||||
}
|
||||
});
|
||||
mntmExit.setMnemonic(KeyEvent.VK_X);
|
||||
mnNewMenu.add(mntmExit);
|
||||
|
||||
}
|
||||
|
||||
private void doCopy() {
|
||||
int row = table.getSelectedRow();
|
||||
if (row != -1) {
|
||||
RemoteInterfaceInfo value = tableModel.getData(row);
|
||||
String data = value.appid;
|
||||
|
||||
final StringSelection selection = new StringSelection(data);
|
||||
|
||||
final Clipboard clipboard = Toolkit.getDefaultToolkit().getSystemClipboard();
|
||||
clipboard.setContents(selection, selection);
|
||||
}// end if
|
||||
}// end doCopy()
|
||||
|
||||
public void setRemoteInterfaceInfo(List<RemoteInterfaceInfo> remoteInterfaceInfos) {
|
||||
int selectedIndex = table.getSelectedRow();
|
||||
tableModel.setShowValidConfigurationsOnly(settings.validConfigurationsOnly);
|
||||
tableModel.setData(remoteInterfaceInfos);
|
||||
if (selectedIndex >= 0) {
|
||||
table.getSelectionModel().setSelectionInterval(selectedIndex, selectedIndex);
|
||||
}
|
||||
}
|
||||
|
||||
public void setOnOpenViewListener(OpenViewListener openViewListener) {
|
||||
this.onOpenViewListener = openViewListener;
|
||||
}
|
||||
|
||||
public void setStatus(final String status) {
|
||||
SwingUtilities.invokeLater(new Runnable() {
|
||||
|
||||
@Override
|
||||
public void run() {
|
||||
lblStatus.setText(status);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
public void setSettingsAction(AbstractAction settingsAction) {
|
||||
mntmSettings.setAction(settingsAction);
|
||||
}
|
||||
|
||||
public void setRescanAction(AbstractAction rescanAction) {
|
||||
mntmRescan.setAction(rescanAction);
|
||||
}
|
||||
|
||||
public void setSettings(Settings settings) {
|
||||
this.settings = settings;
|
||||
tableModel.setShowValidConfigurationsOnly(settings.validConfigurationsOnly);
|
||||
}
|
||||
|
||||
public void updateRemoteInterfaceInfo(RemoteInterfaceInfo remoteIntfInfo) {
|
||||
tableModel.updateRemoteInterfaceInfo(remoteIntfInfo);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,566 @@
|
||||
/*
|
||||
* Copyright (c) 2013 iTAC Software AG, Germany. All Rights Reserved.
|
||||
*
|
||||
* This software is protected by copyright. Under no circumstances may any part of this file in any form be copied,
|
||||
* printed, edited or otherwise distributed, be stored in a retrieval system, or be translated into another language
|
||||
* without the written permission of iTAC Software AG.
|
||||
*/
|
||||
package com.itac.mes.datainterface.gui;
|
||||
|
||||
import static com.itac.mes.datainterface.gui.ComponentFactory.createMenuItem;
|
||||
import static com.itac.resource.ResourcesIMSInterfaces.CLOSE_VIEW;
|
||||
import static com.itac.resource.ResourcesIMSInterfaces.REALLY_SHUTDOWN;
|
||||
import static com.itac.resource.ResourcesIMSInterfaces.SHUTDOWN_TITLE;
|
||||
import static com.itac.resource.ResourcesInterfaceFramework.INTERFACEFRAMEWORK_MENU_EXIT;
|
||||
import static com.itac.resource.ResourcesInterfaceFramework.INTERFACEFRAMEWORK_MENU_FILE;
|
||||
import static com.itac.resource.ResourcesInterfaceFramework.SIMULATIONS;
|
||||
import static com.itac.resource.ResourcesInterfaceFramework.WINDOW;
|
||||
|
||||
import java.awt.BorderLayout;
|
||||
import java.awt.Color;
|
||||
import java.awt.Component;
|
||||
import java.awt.SystemColor;
|
||||
import java.awt.event.ActionEvent;
|
||||
import java.awt.event.ActionListener;
|
||||
import java.util.Collection;
|
||||
import java.util.Hashtable;
|
||||
import java.util.List;
|
||||
|
||||
import javax.swing.AbstractAction;
|
||||
import javax.swing.Action;
|
||||
import javax.swing.JComponent;
|
||||
import javax.swing.JFrame;
|
||||
import javax.swing.JMenu;
|
||||
import javax.swing.JMenuBar;
|
||||
import javax.swing.JMenuItem;
|
||||
import javax.swing.JOptionPane;
|
||||
import javax.swing.JPanel;
|
||||
import javax.swing.JTabbedPane;
|
||||
import javax.swing.border.EmptyBorder;
|
||||
|
||||
import com.itac.mes.clientframe.presentation.JTopPanel;
|
||||
import com.itac.mes.datainterface.DataInterface;
|
||||
import com.itac.mes.datainterface.DataInterfaceAdminConsole;
|
||||
import com.itac.mes.datainterface.RemoteInterfaceInfo;
|
||||
import com.itac.mes.datainterface.VersionInfo;
|
||||
import com.itac.mes.datainterface.data.InterfaceStartType;
|
||||
import com.itac.mes.datainterface.data.Rectangle;
|
||||
import com.itac.mes.datainterface.ihap.IRemoteGui;
|
||||
import com.itac.mes.datainterface.ihap.IRemoteInterface;
|
||||
import com.itac.resource.ResourcePool;
|
||||
import com.itac.resource.ResourcesImages;
|
||||
import com.itac.util.logging.LogHandler;
|
||||
import com.itac.util.logging.LogLevel;
|
||||
|
||||
/**
|
||||
* Diese Klasse ist die visuelle Darstellung zum RemoteDialog
|
||||
*
|
||||
* @author frankp
|
||||
*
|
||||
*/
|
||||
public class DataInterfaceConsoleDlg extends JFrame implements IMainDlg {
|
||||
|
||||
public static final String INTERFACE_TAB_NAME = "Interface";
|
||||
private static final long serialVersionUID = -7081052036265722600L;
|
||||
private static final String LOGGER = DataInterfaceConsoleDlg.class.getSimpleName();
|
||||
|
||||
private AbstractAction exitGuiConsole = new AbstractAction("exitGuiConsole") {
|
||||
|
||||
@Override
|
||||
public void actionPerformed(ActionEvent e) {
|
||||
exitApplication();
|
||||
}
|
||||
};
|
||||
private AbstractAction closeViewGuiConsole = new AbstractAction("closeViewGuiConsole") {
|
||||
|
||||
@Override
|
||||
public void actionPerformed(ActionEvent e) {
|
||||
closeViewRequest();
|
||||
}
|
||||
};
|
||||
private Hashtable<String, IWorkerPane> availableViews = new Hashtable<String, IWorkerPane>();
|
||||
private JPanel jContentPane;
|
||||
private JTopPanel pnlTop;
|
||||
private JMenuBar menubar;
|
||||
private JMenu mnuFile;
|
||||
private JMenuItem mniExit;
|
||||
private JMenu mniWindow;
|
||||
private JMenu mnuSimulations;
|
||||
private JMenuItem mnicloseView;
|
||||
private String mainPaneName;
|
||||
private transient IWorker worker = new RemoteWorker();
|
||||
private IWorker simulation;
|
||||
private IRemoteInterface remoteDataInterface;
|
||||
private RemoteInterfaceInfo remoteInterfaceInfo;
|
||||
private JTabbedPane mainTabPane;
|
||||
private JTabbedPane simulationTabPane;
|
||||
|
||||
/**
|
||||
* This is the default constructor
|
||||
*/
|
||||
public DataInterfaceConsoleDlg() {
|
||||
initialize();
|
||||
}
|
||||
|
||||
/**
|
||||
* This method initializes this
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
private void initialize() {
|
||||
setJMenuBar(getMenubar());
|
||||
setDefaultCloseOperation(javax.swing.WindowConstants.HIDE_ON_CLOSE);
|
||||
try {
|
||||
setIconImage(ResourcePool.getInstance().getImage(ResourcesImages.ICON_ITAC_LOGO));
|
||||
} catch (NullPointerException npe) {
|
||||
}
|
||||
setTitle("Data Interface Gui Console");
|
||||
setContentPane(getJContentPane());
|
||||
this.setSize(600, 300);
|
||||
}
|
||||
|
||||
/**
|
||||
* This method initializes jContentPane
|
||||
*
|
||||
* @return javax.swing.JPanel
|
||||
*/
|
||||
private JPanel getJContentPane() {
|
||||
if (jContentPane == null) {
|
||||
jContentPane = new JPanel(new BorderLayout());
|
||||
jContentPane.add(getPnlTop(), BorderLayout.NORTH);
|
||||
jContentPane.setBackground(SystemColor.window);
|
||||
jContentPane.setForeground(SystemColor.window);
|
||||
jContentPane.setOpaque(true);
|
||||
jContentPane.setBorder(new EmptyBorder(0, 0, 0, 0));
|
||||
|
||||
mainTabPane = new JTabbedPane(JTabbedPane.TOP);
|
||||
mainTabPane.setBackground(SystemColor.window);
|
||||
mainTabPane.setOpaque(true);
|
||||
mainTabPane.setBorder(new EmptyBorder(0, 0, 0, 0));
|
||||
jContentPane.add(mainTabPane, BorderLayout.CENTER);
|
||||
|
||||
}
|
||||
return jContentPane;
|
||||
}
|
||||
|
||||
/**
|
||||
* (non-Javadoc) if the level is less than 0 text is appended to the last line!
|
||||
*
|
||||
* @param level
|
||||
* @param message
|
||||
* @see com.itac.mes.datainterface.data.MessageListener#addMessage(int, java.lang.String)
|
||||
*/
|
||||
@Override
|
||||
public void addMessage(String instance, LogLevel level, String message) {
|
||||
|
||||
for (int i = 0; i < mainTabPane.getTabCount(); i++) {
|
||||
|
||||
Component component = mainTabPane.getTabComponentAt(i);
|
||||
|
||||
if (component instanceof WorkerPane) {
|
||||
((WorkerPane) component).addMessage(instance, level, false, message);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* This method initializes jTopPanel
|
||||
*
|
||||
* @return com.itac.oem.client.gui.JTopPanel
|
||||
*/
|
||||
private JTopPanel getPnlTop() {
|
||||
if (pnlTop == null) {
|
||||
pnlTop = new JTopPanel();
|
||||
// fester Title, zumindest so,lange bis das Interface gestartet ist und ein neuer Titel gesetzt wird...
|
||||
pnlTop.setTitle("Data Interface");
|
||||
try {
|
||||
pnlTop.setIcon(ResourcePool.getInstance().getImageIcon(ResourcesImages.ITAC_RGB_NOINTERLACED));
|
||||
} catch (NullPointerException npe) {
|
||||
}
|
||||
pnlTop.setSubTitle(VersionInfo.getVersion());
|
||||
LogHandler.log(LOGGER, LogLevel.INFO, VersionInfo.getCompleteVersion());
|
||||
}
|
||||
return pnlTop;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setTitle(String title) {
|
||||
super.setTitle(title);
|
||||
getPnlTop().setTitle(title);
|
||||
}
|
||||
|
||||
/**
|
||||
* This method initializes menubar
|
||||
*
|
||||
* @return javax.swing.JMenuBar
|
||||
*/
|
||||
private JMenuBar getMenubar() {
|
||||
if (menubar == null) {
|
||||
menubar = new JMenuBar();
|
||||
menubar.add(getMnuFile());
|
||||
menubar.add(getMniWindow());
|
||||
menubar.add(getMnuSimulations());
|
||||
}
|
||||
return menubar;
|
||||
}
|
||||
|
||||
/**
|
||||
* This method initializes mnuFile
|
||||
*
|
||||
* @return javax.swing.JMenu
|
||||
*/
|
||||
private JMenu getMnuFile() {
|
||||
if (mnuFile == null) {
|
||||
mnuFile = new JMenu();
|
||||
mnuFile.setText(ResourcePool.getInstance().getString(INTERFACEFRAMEWORK_MENU_FILE));
|
||||
mnuFile.add(getMniCloseView()); // eingefuegt mit index 2
|
||||
mnuFile.add(getMniExit()); // eingefuegt mit index 3
|
||||
}
|
||||
return mnuFile;
|
||||
}
|
||||
|
||||
/**
|
||||
* This method initializes mniExit
|
||||
*
|
||||
* @return javax.swing.JMenuItem
|
||||
*/
|
||||
public JMenuItem getMniExit() {
|
||||
if (mniExit == null) {
|
||||
mniExit = createMenuItem("mniExit", INTERFACEFRAMEWORK_MENU_EXIT, -1);
|
||||
exitGuiConsole.putValue(Action.NAME, ResourcePool.getInstance().getString(INTERFACEFRAMEWORK_MENU_EXIT));
|
||||
mniExit.setAction(exitGuiConsole);
|
||||
}
|
||||
return mniExit;
|
||||
}
|
||||
|
||||
/**
|
||||
* This method initializes mniExit
|
||||
*
|
||||
* @return javax.swing.JMenuItem
|
||||
*/
|
||||
public JMenuItem getMniCloseView() {
|
||||
if (mnicloseView == null) {
|
||||
mnicloseView = createMenuItem("mniCloseView", -1, -1);
|
||||
closeViewGuiConsole.putValue(Action.NAME, ResourcePool.getInstance().getString(CLOSE_VIEW));
|
||||
mnicloseView.setAction(closeViewGuiConsole);
|
||||
}
|
||||
return mnicloseView;
|
||||
}
|
||||
|
||||
/**
|
||||
* Fehler beim Initialisieren der Worker, also Tab mit den Initialisierungsmeldungen anzeigen
|
||||
*/
|
||||
@Override
|
||||
public void initFailure() {
|
||||
IDataInterfaceView view = getViewForTitle(INTERFACE_TAB_NAME);
|
||||
if (view != null) {
|
||||
((JComponent) view).setVisible(true);
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @param title
|
||||
* @return
|
||||
*/
|
||||
protected IDataInterfaceView getViewForTitle(String title) {
|
||||
for (int i = 0; i < mainTabPane.getTabCount(); i++) {
|
||||
|
||||
Component component = mainTabPane.getTabComponentAt(i);
|
||||
|
||||
if (component instanceof WorkerPane) {
|
||||
WorkerPane wp = ((WorkerPane) component);
|
||||
if (wp.getTitle().equals(INTERFACE_TAB_NAME)) {
|
||||
|
||||
return (IDataInterfaceView) wp;
|
||||
}
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void addMessage(String instance, LogLevel level, boolean append, String text) {
|
||||
addMessage(instance, level, text);
|
||||
}
|
||||
|
||||
/**
|
||||
* This method initializes mniWindow
|
||||
*
|
||||
* @return javax.swing.JMenu
|
||||
*/
|
||||
private JMenu getMniWindow() {
|
||||
if (mniWindow == null) {
|
||||
mniWindow = new JMenu();
|
||||
mniWindow.setText(ResourcePool.getInstance().getString(WINDOW));
|
||||
mniWindow.setVisible(false);
|
||||
}
|
||||
return mniWindow;
|
||||
}
|
||||
|
||||
/**
|
||||
* This method initializes mnuSimulations
|
||||
*
|
||||
* @return javax.swing.JMenu
|
||||
*/
|
||||
private JMenu getMnuSimulations() {
|
||||
if (mnuSimulations == null) {
|
||||
mnuSimulations = new JMenu();
|
||||
mnuSimulations.setText(ResourcePool.getInstance().getString(SIMULATIONS));
|
||||
mnuSimulations.setVisible(false);
|
||||
}
|
||||
return mnuSimulations;
|
||||
}
|
||||
|
||||
@Override
|
||||
/**
|
||||
* Es wird eine Seite erzeugt, die den entsprechenden Title hat. Die graph. Repräsentation ist mit der Annotation
|
||||
* definiert. Es werden auch die entsprechenden Menues definiert !!!!
|
||||
*/
|
||||
public IWorkerPane createMachineView(IMachineSimulation machineSimulation, String simulationClass,
|
||||
Collection<DataInterfaceMenuAction> mnuItemString) {
|
||||
if (simulationTabPane ==null){
|
||||
// create on demand
|
||||
simulationTabPane = new JTabbedPane(JTabbedPane.TOP);
|
||||
simulationTabPane.setBackground(Color.RED);
|
||||
simulationTabPane.setOpaque(true);
|
||||
simulationTabPane.setBorder(new EmptyBorder(0, 0, 0, 0));
|
||||
jContentPane.add(simulationTabPane, BorderLayout.EAST);
|
||||
}
|
||||
|
||||
IWorkerPane machineSimPane = machineSimulation.getWorkerPane();
|
||||
try {
|
||||
if (machineSimulation.getWorkerPane() == null) {
|
||||
machineSimPane = GuiFactory.getMachineSimulationPane(Class.forName(simulationClass), machineSimulation.getInstanceName());
|
||||
}
|
||||
if (machineSimPane != null) {
|
||||
if (machineSimPane instanceof IDataInterfaceView) {
|
||||
simulationTabPane.addTab(machineSimPane.getTitle(), (JComponent) machineSimPane);
|
||||
}
|
||||
availableViews.put(machineSimPane.getTitle(), machineSimPane);
|
||||
}
|
||||
} catch (ClassNotFoundException e1) {
|
||||
LogHandler.log(LOGGER, LogLevel.ERROR, "class not found for name " + simulationClass, e1);
|
||||
}
|
||||
|
||||
JMenuItem mi = new JMenuItem(machineSimulation.getInstanceName());
|
||||
mi.addActionListener(new ActionListener() {
|
||||
|
||||
@Override
|
||||
public void actionPerformed(ActionEvent e) {
|
||||
String title = ((JMenuItem) e.getSource()).getText();
|
||||
|
||||
IDataInterfaceView view = getViewForTitle(title);
|
||||
if (view != null) {
|
||||
((JComponent) view).setVisible(true);
|
||||
return;
|
||||
}
|
||||
|
||||
// neue Worker View erzeugen
|
||||
IWorkerPane component = availableViews.get(title);
|
||||
if (component instanceof IDataInterfaceView) {
|
||||
// dataInterfaceDoggy.createDockedView((IDataInterfaceView) component);
|
||||
}
|
||||
}
|
||||
});
|
||||
mniWindow.add(mi);
|
||||
mniWindow.setVisible(true);
|
||||
|
||||
if (machineSimPane != null) {
|
||||
machineSimPane.setMenuItems(machineSimulation.getMenuItems());
|
||||
machineSimPane.setMachineSimulation(machineSimulation);
|
||||
}
|
||||
|
||||
JMenu mnuSim = new JMenu(machineSimulation.getInstanceName());
|
||||
mnuSimulations.add(mnuSim);
|
||||
mnuSimulations.setVisible(true);
|
||||
if (mnuItemString != null && mnuItemString.size() > 0) {
|
||||
for (DataInterfaceMenuAction string : mnuItemString) {
|
||||
mnuSim.add(new JMenuItem(new WorkerAction(string, simulation, machineSimPane)));
|
||||
}
|
||||
}
|
||||
return machineSimPane;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void createWorkerView(IWorkerPane workerPane, List<DataInterfaceMenuAction> menuItems) {
|
||||
if (workerPane instanceof IDataInterfaceView) {
|
||||
mainTabPane.addTab(workerPane.getTitle(), (JComponent) workerPane);
|
||||
}
|
||||
|
||||
// für jeden Worker wird ein Submenu erzeugt, und unterhalb dessen jeweils ein Menu für jedes MenuItem
|
||||
if (menuItems != null) {
|
||||
if (workerPane.getTitle().startsWith(DataInterface.MAIN_PANE_NAME)) {
|
||||
int i = 0;
|
||||
for (DataInterfaceMenuAction simMenuItem : menuItems) {
|
||||
JMenuItem mnItem = new JMenuItem();
|
||||
mnItem.setAction(new WorkerAction(simMenuItem, worker, workerPane));
|
||||
mnuFile.insert(mnItem, i++);
|
||||
mnItem.setEnabled(simMenuItem.isEnabled());
|
||||
}
|
||||
|
||||
} else {
|
||||
JMenu mniWorker = new JMenu(workerPane.getTitle());
|
||||
for (DataInterfaceMenuAction simMenuItem : menuItems) {
|
||||
JMenuItem mnItem = new JMenuItem();
|
||||
mnItem.setAction(new WorkerAction(simMenuItem, worker, workerPane));
|
||||
mniWorker.add(mnItem);
|
||||
mnItem.setEnabled(simMenuItem.isEnabled());
|
||||
}
|
||||
mnuFile.insert(mniWorker, 2);
|
||||
}
|
||||
}
|
||||
availableViews.put(workerPane.getTitle(), workerPane);
|
||||
}
|
||||
|
||||
@Override
|
||||
public IWorkerPane getOrCreateWorkerPane(String instance) {
|
||||
if (availableViews != null) {
|
||||
IWorkerPane view = availableViews.get(instance);
|
||||
if (view != null) {
|
||||
return view;
|
||||
}
|
||||
}
|
||||
return GuiFactory.getWorkerPane(instance);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setMainPaneName(String mainPaneName) {
|
||||
this.mainPaneName = mainPaneName;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getMainPaneName() {
|
||||
return mainPaneName;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setWorker(IWorker worker) {
|
||||
this.worker = worker;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setSimulation(IWorker simulation) {
|
||||
this.simulation = simulation;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setActionProperties(DataInterfaceMenuAction action, String instance) {
|
||||
// dieses Event an die entsprechende View weiter leiten
|
||||
IWorkerPane view = availableViews.get(instance);
|
||||
try {
|
||||
view.notifyActionPropertiesChanged(action);
|
||||
} catch (Exception e) {
|
||||
}
|
||||
|
||||
// alle MenuItems durchforsten
|
||||
// das menu-item suchen das so heisst wie die instance, darunter liegende actions mit exakt diesem Namen finden
|
||||
// File Menu durchsuchen
|
||||
for (int i = 0; i < getMnuFile().getItemCount(); i++) {
|
||||
JMenuItem menuItem = getMnuFile().getItem(i);
|
||||
if (menuItem.getText().equals(instance)) {
|
||||
// Übergeordnetes Menu gefunden
|
||||
if (menuItem instanceof JMenu) {
|
||||
JMenu parent = (JMenu) menuItem;
|
||||
for (int j = 0; j < parent.getItemCount(); j++) {
|
||||
if (parent.getItem(j).getText().equals(action.getMenuText())) {
|
||||
LogHandler.log(LOGGER, LogLevel.INFO,
|
||||
"updating menu item enabled flag for " + action.getMenuText() + " to " + action.isEnabled());
|
||||
parent.getItem(j).setEnabled(action.isEnabled());
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// auch noch in den Simulationen suchen...
|
||||
for (int i = 0; i < getMnuSimulations().getItemCount(); i++) {
|
||||
JMenuItem menuItem = getMnuSimulations().getItem(i);
|
||||
if (menuItem.getText().equals(instance)) {
|
||||
// Übergeordnetes Menu gefunden
|
||||
if (menuItem instanceof JMenu) {
|
||||
JMenu parent = (JMenu) menuItem;
|
||||
for (int j = 0; j < parent.getItemCount(); j++) {
|
||||
if (parent.getItem(j).getText().equals(action.getMenuText())) {
|
||||
LogHandler.log(LOGGER, LogLevel.INFO,
|
||||
"updating menu item enabled flag for " + action.getMenuText() + " to " + action.isEnabled());
|
||||
parent.getItem(j).setEnabled(action.isEnabled());
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void fireMenuItem(DataInterfaceMenuAction menuItem) {
|
||||
// Der Hauptdialog reagiert nicht wie eine Simulation
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setInstanceCount(int size) {
|
||||
// startAll nur dann sichtbar, wenn es mehr als einen Worker gibt!!
|
||||
}
|
||||
|
||||
@Override
|
||||
public void clear() {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setRemoteGui(IRemoteGui remoteGui) {
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<InstanceMessage> getInstanceMessages(String instanceName) {
|
||||
return null;
|
||||
}
|
||||
|
||||
public void setGuiConsole(DataInterfaceAdminConsole dataInterfaceGui) {
|
||||
// this.dataInterfaceGui = dataInterfaceGui;
|
||||
}
|
||||
|
||||
public void closeViewRequest() {
|
||||
setVisible(false);
|
||||
}
|
||||
|
||||
public void exitApplication() {
|
||||
// beenden nach Sicherheitsabfrage
|
||||
if (JOptionPane.showConfirmDialog(this, ResourcePool.getInstance().getString(REALLY_SHUTDOWN),
|
||||
ResourcePool.getInstance().getString(SHUTDOWN_TITLE), JOptionPane.YES_NO_OPTION) == JOptionPane.YES_OPTION) {
|
||||
try {
|
||||
remoteDataInterface.exitApplication();
|
||||
} catch (Throwable th) {
|
||||
}
|
||||
setVisible(false);
|
||||
}
|
||||
}
|
||||
|
||||
public void setRemoteInterface(IRemoteInterface remoteDataInterface) {
|
||||
if (remoteDataInterface.getStartType() == InterfaceStartType.SERVICE) {
|
||||
exitGuiConsole.setEnabled(false);
|
||||
}
|
||||
this.remoteDataInterface = remoteDataInterface;
|
||||
}
|
||||
|
||||
public IRemoteInterface getRemoteDataInterface() {
|
||||
return remoteDataInterface;
|
||||
}
|
||||
|
||||
public void setRemoteInterfaceInfo(RemoteInterfaceInfo remoteIntfInfo) {
|
||||
this.remoteInterfaceInfo = remoteIntfInfo;
|
||||
}
|
||||
|
||||
public RemoteInterfaceInfo getRemoteInterfaceInfo() {
|
||||
return remoteInterfaceInfo;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the position of the Dialog window, but not as a java-awt.Rectangle, because this class is not allowed in a WAR
|
||||
* application
|
||||
*/
|
||||
public Rectangle getRectangle() {
|
||||
Rectangle r = new Rectangle(getX(), getY(), getWidth(), getHeight());
|
||||
return r;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,297 @@
|
||||
/*
|
||||
* Copyright (c) 2013 iTAC Software AG, Germany. All Rights Reserved.
|
||||
*
|
||||
* This software is protected by copyright. Under no circumstances may any part of this file in any form be copied,
|
||||
* printed, edited or otherwise distributed, be stored in a retrieval system, or be translated into another language
|
||||
* without the written permission of iTAC Software AG.
|
||||
*/
|
||||
package com.itac.mes.datainterface.gui;
|
||||
|
||||
import java.awt.Color;
|
||||
import java.awt.Font;
|
||||
import java.awt.Image;
|
||||
import java.awt.event.KeyAdapter;
|
||||
import java.awt.event.KeyEvent;
|
||||
import java.awt.image.BufferedImage;
|
||||
|
||||
import javax.swing.Icon;
|
||||
import javax.swing.ImageIcon;
|
||||
import javax.swing.JButton;
|
||||
import javax.swing.JLabel;
|
||||
import javax.swing.JPanel;
|
||||
import javax.swing.JPasswordField;
|
||||
import javax.swing.JTextField;
|
||||
import javax.swing.SwingConstants;
|
||||
import javax.swing.WindowConstants;
|
||||
import javax.swing.event.DocumentEvent;
|
||||
import javax.swing.event.DocumentListener;
|
||||
|
||||
import org.jdesktop.swingx.JXFrame;
|
||||
import org.jdesktop.swingx.JXLabel;
|
||||
|
||||
import com.itac.resource.ResourcePool;
|
||||
import com.itac.resource.Resources;
|
||||
import com.itac.resource.ResourcesIMSInterfacesImages;
|
||||
import com.jgoodies.layout.layout.ColumnSpec;
|
||||
import com.jgoodies.layout.layout.FormLayout;
|
||||
import com.jgoodies.layout.layout.FormSpecs;
|
||||
import com.jgoodies.layout.layout.RowSpec;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author frankp
|
||||
*/
|
||||
public class DataInterfaceLoginDlg extends JXFrame {
|
||||
|
||||
private JLabel itacLogo;
|
||||
private JButton jButtonCancel;
|
||||
private JButton jButtonLogin;
|
||||
private JLabel jXLabelTitle;
|
||||
private JPanel jPanel1;
|
||||
private JPasswordField jPasswordField;
|
||||
private JTextField jTextFieldUser;
|
||||
private JTextField jTextFieldClient;
|
||||
private JXLabel jXLabelInfo;
|
||||
private JXLabel jXLabelPassword;
|
||||
private JXLabel jXLabelClient;
|
||||
private JXLabel jXLabelUser;
|
||||
|
||||
/**
|
||||
* Creates new form AuthenticationLoginDialog
|
||||
*
|
||||
* @param aController
|
||||
*/
|
||||
public DataInterfaceLoginDlg() {
|
||||
setStartPosition(StartPosition.CenterInScreen);
|
||||
initComponents();
|
||||
|
||||
BufferedImage imgOld2 = ResourcePool.getInstance().getImage(ResourcesIMSInterfacesImages.ITAC_LOGO_WHITE);
|
||||
int widthOld2 = imgOld2.getWidth();
|
||||
int heightOld2 = imgOld2.getHeight();
|
||||
Image imgNew2 = imgOld2.getScaledInstance((widthOld2 * 100) / heightOld2, 100, Image.SCALE_SMOOTH);
|
||||
|
||||
Icon icon2 = new ImageIcon(imgNew2);
|
||||
|
||||
getContentPane().setLayout(
|
||||
new FormLayout(new ColumnSpec[] { ColumnSpec.decode("680px"), }, new RowSpec[] { RowSpec.decode("fill:350px"), }));
|
||||
|
||||
itacLogo.setIcon(icon2);
|
||||
getContentPane().add(jPanel1, "1, 1, fill, top");
|
||||
jPanel1.setLayout(new FormLayout(new ColumnSpec[] { ColumnSpec.decode("62px"), ColumnSpec.decode("341px"),
|
||||
ColumnSpec.decode("57px"), ColumnSpec.decode("94px"), FormSpecs.RELATED_GAP_COLSPEC, ColumnSpec.decode("90px"), },
|
||||
new RowSpec[] { RowSpec.decode("38px"), RowSpec.decode("79px"), FormSpecs.RELATED_GAP_ROWSPEC, RowSpec.decode("20px"),
|
||||
FormSpecs.UNRELATED_GAP_ROWSPEC, RowSpec.decode("17px"), FormSpecs.RELATED_GAP_ROWSPEC,
|
||||
FormSpecs.DEFAULT_ROWSPEC, FormSpecs.UNRELATED_GAP_ROWSPEC, FormSpecs.DEFAULT_ROWSPEC,
|
||||
FormSpecs.RELATED_GAP_ROWSPEC, FormSpecs.DEFAULT_ROWSPEC, FormSpecs.UNRELATED_GAP_ROWSPEC,
|
||||
RowSpec.decode("max(30dlu;default)"), FormSpecs.UNRELATED_GAP_ROWSPEC, RowSpec.decode("23px"),
|
||||
RowSpec.decode("40dlu:grow"), }));
|
||||
jPanel1.add(itacLogo, "2, 2, 1, 3, fill, bottom");
|
||||
jPanel1.add(jXLabelTitle, "2, 6, 1, 3, left, bottom");
|
||||
jPanel1.add(jXLabelUser, "4, 2, 3, 1, left, bottom");
|
||||
jPanel1.add(jXLabelPassword, "4, 6, 3, 1, left, bottom");
|
||||
|
||||
jPanel1.add(jXLabelClient, "4, 10, 3, 1, left, bottom");
|
||||
jPanel1.add(jXLabelInfo, "4, 14, 3, 1, fill, top");
|
||||
|
||||
jPanel1.add(jTextFieldClient, "4, 12, 3, 1, fill, bottom");
|
||||
jPanel1.add(jButtonLogin, "4, 16, fill, top");
|
||||
jPanel1.add(jButtonCancel, "6, 16, left, top");
|
||||
jPanel1.add(jTextFieldUser, "4, 4, 3, 1, fill, bottom");
|
||||
jPanel1.add(jPasswordField, "4, 8, 3, 1, fill, bottom");
|
||||
|
||||
// initHeader();
|
||||
jTextFieldUser.getDocument().addDocumentListener(new DocumentListener() {
|
||||
@Override
|
||||
public void insertUpdate(DocumentEvent e) {
|
||||
checkInput(e);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void removeUpdate(DocumentEvent e) {
|
||||
checkInput(e);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void changedUpdate(DocumentEvent e) {
|
||||
checkInput(e);
|
||||
}
|
||||
|
||||
private void checkInput(DocumentEvent e) {
|
||||
int length = e.getDocument().getLength();
|
||||
if (jPasswordField.getPassword() != null && jPasswordField.getPassword().length > 0) {
|
||||
if (length > 0) {
|
||||
jButtonLogin.setEnabled(true);
|
||||
} else {
|
||||
jButtonLogin.setEnabled(false);
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
jPasswordField.getDocument().addDocumentListener(new DocumentListener() {
|
||||
@Override
|
||||
public void insertUpdate(DocumentEvent e) {
|
||||
checkInput(e);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void removeUpdate(DocumentEvent e) {
|
||||
checkInput(e);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void changedUpdate(DocumentEvent e) {
|
||||
checkInput(e);
|
||||
}
|
||||
|
||||
private void checkInput(DocumentEvent e) {
|
||||
int length = e.getDocument().getLength();
|
||||
if (jTextFieldUser.getText().length() > 0) {
|
||||
if (length > 0) {
|
||||
jButtonLogin.setEnabled(true);
|
||||
} else {
|
||||
jButtonLogin.setEnabled(false);
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
setIconImage(ResourcePool.getInstance().getImage(Resources.Images.ICON_MES));
|
||||
setLocationRelativeTo(null);
|
||||
}
|
||||
|
||||
/**
|
||||
* This method is called from within the constructor to initialize the form. WARNING: Do NOT modify this code. The
|
||||
* content of this method is always regenerated by the Form Editor.
|
||||
*/
|
||||
private void initComponents() {
|
||||
|
||||
jPanel1 = new BackgroundPanel();
|
||||
jXLabelUser = new JXLabel();
|
||||
jTextFieldUser = new JTextField();
|
||||
jXLabelPassword = new JXLabel();
|
||||
jPasswordField = new JPasswordField();
|
||||
jXLabelInfo = new JXLabel();
|
||||
jXLabelInfo.setFont(new Font("Tahoma", Font.BOLD, 11));
|
||||
jXLabelClient = new JXLabel();
|
||||
jTextFieldClient = new JTextField();
|
||||
itacLogo = ComponentFactory.createLabel();
|
||||
jXLabelTitle = new JLabel();
|
||||
|
||||
setDefaultCloseOperation(WindowConstants.EXIT_ON_CLOSE);
|
||||
setTitle(ResourcePool.getInstance().getString(Resources.Logon.TITLEDBORDER_BORDERTEXT));
|
||||
setResizable(false);
|
||||
setUndecorated(true);
|
||||
|
||||
jPanel1.setName("jPanel1");
|
||||
|
||||
jXLabelUser.setForeground(new Color(255, 255, 255));
|
||||
jXLabelUser.setText(ResourcePool.getInstance().getString(Resources.Logon.JLABEL_USERNAME));
|
||||
jXLabelUser.setFont(new Font("Tahoma", 1, 14));
|
||||
jXLabelUser.setName("jXLabelUser");
|
||||
|
||||
jTextFieldUser.setName("jTextFieldUser");
|
||||
jTextFieldUser.addKeyListener(new KeyAdapter() {
|
||||
public void keyPressed(KeyEvent evt) {
|
||||
jTextFieldUserKeyPressed(evt);
|
||||
}
|
||||
});
|
||||
|
||||
jXLabelPassword.setForeground(new Color(255, 255, 255));
|
||||
jXLabelPassword.setText(ResourcePool.getInstance().getString(Resources.Logon.JLABEL_PASSWORD));
|
||||
jXLabelPassword.setFont(new Font("Tahoma", 1, 14));
|
||||
jXLabelPassword.setName("jXLabelPassword");
|
||||
|
||||
jPasswordField.setName("jPasswordField");
|
||||
jPasswordField.addKeyListener(new KeyAdapter() {
|
||||
public void keyPressed(KeyEvent evt) {
|
||||
jPasswordFieldKeyPressed(evt);
|
||||
}
|
||||
});
|
||||
|
||||
jXLabelClient.setForeground(new Color(255, 255, 255));
|
||||
jXLabelClient.setText(ResourcePool.getInstance().getString(Resources.AdmRes.ADMARTIKELSTAMMPANEL$TXT_CLIENT));
|
||||
jXLabelClient.setFont(new Font("Tahoma", 1, 14));
|
||||
jXLabelClient.setName("jXLabelClient");
|
||||
|
||||
jTextFieldClient.setName("jtfClient");
|
||||
jTextFieldClient.setText("01");
|
||||
|
||||
jButtonLogin = ComponentFactory.createButton("loginBtn", Resources.Logon.JBUTTON_OK);
|
||||
jButtonLogin.setDefaultCapable(true);
|
||||
jButtonLogin.setEnabled(false);
|
||||
jButtonLogin.setOpaque(false);
|
||||
// jButtonLogin.addActionListener(new ActionListener() {
|
||||
// public void actionPerformed(ActionEvent evt) {
|
||||
// jButtonLoginActionPerformed(evt);
|
||||
// }
|
||||
// });
|
||||
|
||||
jXLabelInfo.setForeground(new Color(234, 153, 130));
|
||||
jXLabelInfo.setText("");
|
||||
jXLabelInfo.setLineWrap(true);
|
||||
jXLabelInfo.setName("jXLabelInfo");
|
||||
|
||||
jButtonCancel = ComponentFactory.createButton("cancelBtn", Resources.Logon.JBUTTON_CANCEL);
|
||||
jButtonCancel.setOpaque(false);
|
||||
// jButtonCancel.addActionListener(new ActionListener() {
|
||||
// public void actionPerformed(ActionEvent evt) {
|
||||
// jButtonCancelActionPerformed(evt);
|
||||
// }
|
||||
// });
|
||||
|
||||
itacLogo.setName("itacLogo");
|
||||
|
||||
jXLabelTitle.setFont(ComponentFactory.fontLoginTitle);
|
||||
jXLabelTitle.setForeground(new Color(234, 153, 130));
|
||||
jXLabelTitle.setHorizontalAlignment(SwingConstants.CENTER);
|
||||
jXLabelTitle.setText("imsInterfaces.adminConsole");
|
||||
jXLabelTitle.setName("imsInterfaces.adminConsole");
|
||||
|
||||
pack();
|
||||
}
|
||||
|
||||
// private void jButtonCancelActionPerformed(ActionEvent evt) {
|
||||
// System.exit(0);
|
||||
// }
|
||||
//
|
||||
// private void jButtonLoginActionPerformed(ActionEvent evt) {
|
||||
// adminConsole.login();
|
||||
// }
|
||||
|
||||
private void jPasswordFieldKeyPressed(KeyEvent evt) {
|
||||
if (evt.getKeyCode() == KeyEvent.VK_ENTER) {
|
||||
jButtonLogin.doClick();
|
||||
}
|
||||
}
|
||||
|
||||
private void jTextFieldUserKeyPressed(KeyEvent evt) {
|
||||
if (evt.getKeyCode() == KeyEvent.VK_ENTER) {
|
||||
jButtonLogin.doClick();
|
||||
}
|
||||
}
|
||||
|
||||
public JPasswordField getPasswordField() {
|
||||
return jPasswordField;
|
||||
}
|
||||
|
||||
public JTextField getUserField() {
|
||||
return jTextFieldUser;
|
||||
}
|
||||
|
||||
public JXLabel getLoginStatusLabel() {
|
||||
return jXLabelInfo;
|
||||
}
|
||||
|
||||
public JTextField getClientField() {
|
||||
return jTextFieldClient;
|
||||
}
|
||||
|
||||
public JButton getOkBtn() {
|
||||
return jButtonLogin;
|
||||
}
|
||||
|
||||
public JButton getCancelBtn() {
|
||||
return jButtonCancel;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,79 @@
|
||||
package com.itac.mes.datainterface.gui;
|
||||
|
||||
import static com.itac.mes.datainterface.gui.ComponentFactory.createButton;
|
||||
import static com.itac.mes.datainterface.gui.ComponentFactory.createCheckBox;
|
||||
import static com.itac.mes.datainterface.gui.ComponentFactory.createLabel;
|
||||
import static com.itac.mes.datainterface.gui.ComponentFactory.fontLabelBold;
|
||||
|
||||
import java.awt.Dimension;
|
||||
import java.awt.event.ActionEvent;
|
||||
import java.awt.event.ActionListener;
|
||||
|
||||
import javax.swing.JButton;
|
||||
import javax.swing.JCheckBox;
|
||||
import javax.swing.JDialog;
|
||||
import javax.swing.JLabel;
|
||||
|
||||
import com.itac.mes.datainterface.data.Settings;
|
||||
import com.itac.resource.ResourcePool;
|
||||
import com.itac.resource.Resources;
|
||||
import com.itac.resource.ResourcesIMSInterfaces;
|
||||
import com.jgoodies.layout.layout.ColumnSpec;
|
||||
import com.jgoodies.layout.layout.FormLayout;
|
||||
import com.jgoodies.layout.layout.FormSpecs;
|
||||
import com.jgoodies.layout.layout.RowSpec;
|
||||
|
||||
public class SettingsDlg extends JDialog {
|
||||
private JCheckBox chckbxValidConfigurationsOnly;
|
||||
private Settings settings;
|
||||
|
||||
public SettingsDlg() {
|
||||
setPreferredSize(new Dimension(400, 135));
|
||||
setMinimumSize(new Dimension(400, 135));
|
||||
setTitle(ResourcePool.getInstance().getString(Resources.IMSInterfaces.SETTINGS));
|
||||
getContentPane().setLayout(
|
||||
new FormLayout(new ColumnSpec[] { FormSpecs.RELATED_GAP_COLSPEC, ColumnSpec.decode("default:grow"),
|
||||
FormSpecs.RELATED_GAP_COLSPEC, FormSpecs.DEFAULT_COLSPEC, FormSpecs.RELATED_GAP_COLSPEC,
|
||||
FormSpecs.DEFAULT_COLSPEC, FormSpecs.RELATED_GAP_COLSPEC, }, new RowSpec[] { FormSpecs.RELATED_GAP_ROWSPEC,
|
||||
FormSpecs.DEFAULT_ROWSPEC, FormSpecs.RELATED_GAP_ROWSPEC, RowSpec.decode("default:grow"),
|
||||
FormSpecs.RELATED_GAP_ROWSPEC, FormSpecs.DEFAULT_ROWSPEC, FormSpecs.RELATED_GAP_ROWSPEC, }));
|
||||
|
||||
JLabel lblSettings = createLabel("Settings", ResourcesIMSInterfaces.SETTINGS, fontLabelBold);
|
||||
|
||||
getContentPane().add(lblSettings, "2, 2");
|
||||
|
||||
chckbxValidConfigurationsOnly = createCheckBox("valid configurations only", Resources.IMSInterfaces.VALID_CONFIGURATIONS_ONLY);
|
||||
getContentPane().add(chckbxValidConfigurationsOnly, "2, 4, 5, 1, fill, top");
|
||||
|
||||
JButton btnOk = createButton("OK", Resources.Basic.TXT_OK);
|
||||
btnOk.setDefaultCapable(true);
|
||||
btnOk.setOpaque(false);
|
||||
btnOk.addActionListener(new ActionListener() {
|
||||
public void actionPerformed(ActionEvent evt) {
|
||||
setVisible(false);
|
||||
settings.changed = true;
|
||||
settings.validConfigurationsOnly = chckbxValidConfigurationsOnly.isSelected();
|
||||
}
|
||||
});
|
||||
getContentPane().add(btnOk, "4, 6");
|
||||
|
||||
JButton jButtonCancel = ComponentFactory.createButton("cancelBtn", Resources.Basic.TXT_CANCEL);
|
||||
// jButtonCancel.setText(ResourcePool.getInstance().getString(Resources.Logon.JBUTTON_CANCEL));
|
||||
// jButtonCancel.setName("jButtonCancel");
|
||||
jButtonCancel.setOpaque(false);
|
||||
jButtonCancel.addActionListener(new ActionListener() {
|
||||
public void actionPerformed(ActionEvent evt) {
|
||||
setVisible(false);
|
||||
}
|
||||
});
|
||||
getContentPane().add(jButtonCancel, "6, 6");
|
||||
|
||||
}
|
||||
|
||||
public void setSettings(Settings settings) {
|
||||
this.settings = settings;
|
||||
settings.changed = false;
|
||||
chckbxValidConfigurationsOnly.setSelected(settings.validConfigurationsOnly);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,64 @@
|
||||
/*
|
||||
* Copyright (c) 2013 iTAC Software AG, Germany. All Rights Reserved.
|
||||
*
|
||||
* This software is protected by copyright. Under no circumstances may any part of this file in any form be copied,
|
||||
* printed, edited or otherwise distributed, be stored in a retrieval system, or be translated into another language
|
||||
* without the written permission of iTAC Software AG.
|
||||
*/
|
||||
package com.itac.mes.datainterface.service;
|
||||
|
||||
import com.itac.mes.datainterface.config.AdminConsoleConfig;
|
||||
import com.itac.mes.imsapi.domain.container.IMSApiSessionValidationStruct;
|
||||
import com.itac.mes.imsapi.domain.container.Result_regLogin;
|
||||
import com.itac.util.logging.LogHandler;
|
||||
import com.itac.util.logging.LogLevel;
|
||||
|
||||
public class LoginService {
|
||||
|
||||
private AdminConsoleConfig adminConsoleConfig;
|
||||
|
||||
public LoginService(AdminConsoleConfig adminConsoleConfig) {
|
||||
this.adminConsoleConfig = adminConsoleConfig;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param user
|
||||
* der Name des Users
|
||||
* @param password
|
||||
* Password des Users
|
||||
* @param client
|
||||
* Client/Mandant, default sollte "01" sein
|
||||
* @return Leerstring, wenn die Anmeldung erfolgreich war, sonst einen Fehlertext
|
||||
*/
|
||||
public String login(String user, String password, String client) {
|
||||
LogHandler.log("Login", LogLevel.INFO, "login()");
|
||||
IMSApiSessionValidationStruct svs = new IMSApiSessionValidationStruct();
|
||||
svs.registrationType = "U"; // User
|
||||
svs.user = user;
|
||||
svs.password = password;
|
||||
svs.client = client;
|
||||
svs.systemIdentifier = "imsInterfacesAdminConsole";
|
||||
|
||||
try {
|
||||
Result_regLogin result = adminConsoleConfig.getImsApiService().regLogin(svs);
|
||||
if (result != null) {
|
||||
if (result.return_value == 0) {
|
||||
// sessionContext = result.sessionContext;
|
||||
// if (sessionContext == null) {
|
||||
// sessionContext = new IMSApiSessionContextStruct();
|
||||
// }
|
||||
return null;
|
||||
} else {
|
||||
String errorText = adminConsoleConfig.getResultText(result.return_value);
|
||||
LogHandler.log("Login", LogLevel.INFO, errorText);
|
||||
return errorText;
|
||||
}
|
||||
} else {
|
||||
LogHandler.log("Login", LogLevel.INFO, "login() failed! Return value is null!");
|
||||
return "login() failed! Return value is null!";
|
||||
}
|
||||
} catch (Throwable th) {
|
||||
return th.getLocalizedMessage();
|
||||
}
|
||||
}
|
||||
}
|
||||
5
interface/guiconsole/target/classes/META-INF/MANIFEST.MF
Normal file
5
interface/guiconsole/target/classes/META-INF/MANIFEST.MF
Normal file
@@ -0,0 +1,5 @@
|
||||
Manifest-Version: 1.0
|
||||
Built-By: frankp
|
||||
Build-Jdk: 1.8.0_111
|
||||
Created-By: Maven Integration for Eclipse
|
||||
|
||||
@@ -0,0 +1,7 @@
|
||||
#Generated by Maven Integration for Eclipse
|
||||
#Tue Oct 13 14:05:26 CEST 2020
|
||||
version=9.10.00beta-DEVELOPER
|
||||
groupId=com.itac.interface.interfaces
|
||||
m2e.projectName=data-interface-gui-console
|
||||
m2e.projectLocation=C\:\\projects_jee\\imsinterface\\mainline\\interface\\guiconsole
|
||||
artifactId=data-interface-gui-console
|
||||
@@ -0,0 +1,66 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
<groupId>com.itac.interface.interfaces</groupId>
|
||||
<artifactId>data-interface-gui-console</artifactId>
|
||||
<packaging>jar</packaging>
|
||||
<name>data-interface-gui-console</name>
|
||||
<version>${mes.interface.version}</version>
|
||||
<parent>
|
||||
<groupId>com.itac.interface</groupId>
|
||||
<artifactId>data-interface</artifactId>
|
||||
<version>${mes.interface.version}</version>
|
||||
</parent>
|
||||
<dependencies>
|
||||
<dependency>
|
||||
<groupId>com.itac.product</groupId>
|
||||
<artifactId>artes-client</artifactId>
|
||||
</dependency>
|
||||
<!-- interner -->
|
||||
<dependency>
|
||||
<groupId>com.itac.interface.interfaces</groupId>
|
||||
<artifactId>data-interface-gui</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.swinglabs</groupId>
|
||||
<artifactId>swingx</artifactId>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
<build>
|
||||
<plugins>
|
||||
<plugin>
|
||||
<groupId>com.itac.tools</groupId>
|
||||
<artifactId>webstart-plugin</artifactId>
|
||||
<executions>
|
||||
<execution>
|
||||
<phase>generate-sources</phase>
|
||||
<goals>
|
||||
<goal>itacWebstartClient</goal>
|
||||
</goals>
|
||||
</execution>
|
||||
</executions>
|
||||
<configuration>
|
||||
<applicationName>DataInterfaceAdminConsole.jnlp</applicationName>
|
||||
<title>iTAC.MES.DataInterface Administration Console</title>
|
||||
<description>iTAC.MES.DataInterface Administration Console</description>
|
||||
<category>standard</category>
|
||||
<mainClass>com.itac.mes.datainterface.DataInterfaceAdminConsole</mainClass>
|
||||
<offlineAllowed>false</offlineAllowed>
|
||||
<!-- optional params -->
|
||||
<shortdescription>iTAC.MES.Suite administration console</shortdescription>
|
||||
<tooltip>iTAC.MES.DataInterface Administration Console</tooltip>
|
||||
<icon>com/itac/resource/binaries/companyIcon.png</icon>
|
||||
<jvmArgs>-showversion</jvmArgs>
|
||||
<properties>
|
||||
<property>
|
||||
<name>itac.appid</name>
|
||||
<value>adminConsole</value>
|
||||
</property>
|
||||
</properties>
|
||||
</configuration>
|
||||
</plugin>
|
||||
</plugins>
|
||||
</build>
|
||||
|
||||
</project>
|
||||
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.
Binary file not shown.
Binary file not shown.
Binary file not shown.
@@ -0,0 +1,61 @@
|
||||
package com.itac.mes.datainterface;
|
||||
|
||||
public class DataInterfaceAdminConsoleWebstartLauncher {
|
||||
|
||||
public static void main(String[] args) {
|
||||
try {
|
||||
System.setProperty("itac.mainclass", "com.itac.mes.datainterface.DataInterfaceAdminConsole");
|
||||
setSystemProperties(args[0]);
|
||||
com.itac.mes.datainterface.DataInterfaceAdminConsole.main(new String[]{});
|
||||
} catch(Exception e) {
|
||||
throw new RuntimeException("Unable to execute com.itac.mes.datainterface.DataInterfaceAdminConsole.main()", e);
|
||||
}
|
||||
}
|
||||
|
||||
private static void setSystemProperties(String complete) {
|
||||
boolean isEscape = false;
|
||||
boolean isValue = false;
|
||||
StringBuilder key = new StringBuilder();
|
||||
StringBuilder value = new StringBuilder();
|
||||
for (int i=0; i<complete.length(); i++) {
|
||||
char c = complete.charAt(i);
|
||||
if (c == ',') {
|
||||
if (isEscape) {
|
||||
if (isValue) {
|
||||
value.append(c);
|
||||
} else {
|
||||
key.append(c);
|
||||
}
|
||||
isEscape = false;
|
||||
} else {
|
||||
System.setProperty(key.toString(), value.toString());
|
||||
key = new StringBuilder();
|
||||
value = new StringBuilder();
|
||||
isEscape = false;
|
||||
isValue = false;
|
||||
}
|
||||
} else if (c == '\\') {
|
||||
if (isEscape) {
|
||||
if (isValue) {
|
||||
value.append(c);
|
||||
} else {
|
||||
key.append(c);
|
||||
}
|
||||
isEscape = false;
|
||||
} else {
|
||||
isEscape = true;
|
||||
}
|
||||
} else if (c == '=') {
|
||||
isValue = true;
|
||||
} else {
|
||||
if (isValue) {
|
||||
value.append(c);
|
||||
} else {
|
||||
key.append(c);
|
||||
}
|
||||
}
|
||||
}
|
||||
System.setProperty(key.toString(), value.toString());
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,5 @@
|
||||
#Generated by Maven
|
||||
#Tue Jun 12 15:26:06 CEST 2018
|
||||
version=9.00.01alpha-DEVELOPER
|
||||
groupId=com.itac.interface.interfaces
|
||||
artifactId=data-interface-gui-console
|
||||
Reference in New Issue
Block a user