Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
NomadGUI
Manage
Activity
Members
Code
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Deploy
Releases
Container Registry
Model registry
Analyze
Contributor analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Instrument Control
NomadGUI
Commits
0b9ac222
Commit
0b9ac222
authored
3 years ago
by
Cristina Cocho
Browse files
Options
Downloads
Patches
Plain Diff
after merge with V4.0
parent
d45625bc
No related branches found
Branches containing commit
No related tags found
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
src/main/java/fr/ill/ics/client/control/MainWindow.java
+210
-176
210 additions, 176 deletions
src/main/java/fr/ill/ics/client/control/MainWindow.java
src/main/java/fr/ill/ics/client/view/MainWindowPeer.java
+1
-1
1 addition, 1 deletion
src/main/java/fr/ill/ics/client/view/MainWindowPeer.java
with
211 additions
and
177 deletions
src/main/java/fr/ill/ics/client/control/MainWindow.java
+
210
−
176
View file @
0b9ac222
...
...
@@ -17,6 +17,12 @@
*/
package
fr.ill.ics.client.control
;
import
java.io.BufferedWriter
;
import
java.io.File
;
import
java.io.FileWriter
;
import
java.io.IOException
;
import
java.io.PrintWriter
;
import
java.io.StringWriter
;
import
java.util.ArrayList
;
import
java.util.Iterator
;
import
java.util.List
;
...
...
@@ -36,6 +42,7 @@ import fr.ill.ics.bridge.listeners.ServerEndedListener;
import
fr.ill.ics.cameo.Application
;
import
fr.ill.ics.cameo.Application.Instance
;
import
fr.ill.ics.cameo.Server
;
import
fr.ill.ics.client.control.admin.AdministratorLogin
;
import
fr.ill.ics.client.control.command.CommandWindow
;
import
fr.ill.ics.client.control.command.ServerCommandZone
;
import
fr.ill.ics.client.control.command.commandline.CommandLine
;
...
...
@@ -47,16 +54,21 @@ import fr.ill.ics.client.control.configuration.setup.ControllerConfigurationSetu
import
fr.ill.ics.client.control.configuration.setup.DriverConfigurationSetup
;
import
fr.ill.ics.client.control.experiment.ExperimentData
;
import
fr.ill.ics.client.control.login.Authentication
;
import
fr.ill.ics.client.control.login.UserConnection
;
import
fr.ill.ics.client.control.plot.PlotyManager
;
import
fr.ill.ics.client.control.plugin.selection.CommandsSelectionPlugin
;
import
fr.ill.ics.client.control.plugin.selection.HardwareSelectionPlugin
;
import
fr.ill.ics.client.control.plugin.selection.SelectionPlugin
;
import
fr.ill.ics.client.control.plugin.selection.SettingsSelectionPlugin
;
import
fr.ill.ics.client.control.plugin.selection.ToolBarSelectionPlugin
;
import
fr.ill.ics.client.control.spy.SpyManager
;
import
fr.ill.ics.client.control.startup.Startup
;
import
fr.ill.ics.client.control.state.MainWindowConfigurationState
;
import
fr.ill.ics.client.control.state.MainWindowExecutionState
;
import
fr.ill.ics.client.control.state.MainWindowState
;
import
fr.ill.ics.client.test.TestClientConfiguration
;
import
fr.ill.ics.client.view.MainWindowPeer
;
import
fr.ill.ics.client.view.magnifier.Magnifier
;
import
fr.ill.ics.client.view.util.dialog.DialogManager
;
import
fr.ill.ics.client.view.util.listener.INewCountRepeaterFileListener
;
import
fr.ill.ics.common.Nomad
;
...
...
@@ -66,6 +78,7 @@ import fr.ill.ics.nscclient.notification.commandzone.ClientDisconnectedPublisher
import
fr.ill.ics.nscclient.serverconnection.ServerConnection
;
import
fr.ill.ics.nscclient.sessionmanagement.SessionManager
;
import
fr.ill.ics.util.ConfigManager
;
import
fr.ill.ics.util.ServerException
;
import
fr.ill.ics.util.exception.CommandNotFoundException
;
import
fr.ill.ics.util.exception.ControllerNotFoundException
;
import
fr.ill.ics.util.exception.ExitException
;
...
...
@@ -77,8 +90,10 @@ public class MainWindow implements ServerConfigurationChangeListener, ServerEnde
private
final
static
String
NOMADLOGS_APP_NAME
=
"nlogs"
;
private
final
static
String
NOMADSURVEY_APP_NAME
=
"nsurvey"
;
private
final
static
String
NOMAD_ADMINISTRATOR
=
"nomadAdministrator"
;
private
final
static
String
serverExceptionsDirectory
=
ConfigManager
.
NOMAD_CLIENT_FILES
+
ConfigManager
.
FILE_SEPARATOR
+
"log"
+
ConfigManager
.
FILE_SEPARATOR
+
".server"
;
private
final
static
String
serverExceptionsFileName
=
serverExceptionsDirectory
+
ConfigManager
.
FILE_SEPARATOR
+
"serverExceptions.txt"
;
private
final
static
String
serverExceptionsDirectory
=
ConfigManager
.
NOMAD_CLIENT_FILES
+
ConfigManager
.
FILE_SEPARATOR
+
"log"
+
ConfigManager
.
FILE_SEPARATOR
+
".server"
;
private
final
static
String
serverExceptionsFileName
=
serverExceptionsDirectory
+
ConfigManager
.
FILE_SEPARATOR
+
"serverExceptions.txt"
;
private
static
MainWindow
instance
=
null
;
...
...
@@ -89,10 +104,9 @@ public class MainWindow implements ServerConfigurationChangeListener, ServerEnde
private
boolean
standalone
=
false
;
// temporaire pour debug FIGARO
protected
final
static
Logger
LOGGER
=
Logger
.
getLogger
(
MainWindow
.
class
.
getName
());
protected
final
static
Logger
LOGGER
=
Logger
.
getLogger
(
MainWindow
.
class
.
getName
());
public
final
static
boolean
DEBUG
=
false
;
private
static
boolean
useNomadLogs
=
true
;
public
MainWindowState
mainWindowState
;
...
...
@@ -100,11 +114,9 @@ public class MainWindow implements ServerConfigurationChangeListener, ServerEnde
private
MainWindowExecutionState
mainWindowExecutionState
;
private
MainWindowConfigurationState
mainWindowConfigurationState
;
private
Authentication
authentication
;
private
SelectionPlugin
selectionPluginBeforeAdminLogin
;
private
Server
cameoServer
;
private
Instance
nomadLogsInstance
;
private
Instance
nomadSurveyInstance
;
...
...
@@ -113,9 +125,15 @@ public class MainWindow implements ServerConfigurationChangeListener, ServerEnde
private
static
final
String
VISA
=
"visa"
;
private
static
String
virtualHomeValue
;
private
static
String
visaValue
;
private
String
credentials
=
null
;
//remove this variables
private
static
boolean
initOk
=
false
;
private
static
boolean
testEvents
=
false
;
public
static
boolean
testConfig
=
false
;
/**
* @param args
...
...
@@ -127,7 +145,7 @@ public class MainWindow implements ServerConfigurationChangeListener, ServerEnde
System
.
out
.
println
(
VISA
+
" = "
+
System
.
getProperty
(
VISA
));
visaValue
=
System
.
getProperty
(
VISA
);
int
exitCode
=
0
;
try
{
...
...
@@ -145,30 +163,27 @@ public class MainWindow implements ServerConfigurationChangeListener, ServerEnde
}
/*
int mb = 1024*1024;
//Getting the runtime reference from system
Runtime runtime = Runtime.getRuntime();
System.out.println("##### Heap utilisation statistics [MB] #####");
//Print used memory
System.out.println("Used Memory:"
+ (runtime.totalMemory() - runtime.freeMemory()) / mb);
//Print free memory
System.out.println("Free Memory:"
+ runtime.freeMemory() / mb);
//Print total available memory
System.out.println("Total Memory:" + runtime.totalMemory() / mb);
//Print Maximum available memory
System.out.println("Max Memory:" + runtime.maxMemory() / mb);
* int mb = 1024*1024;
*
* //Getting the runtime reference from system Runtime runtime =
* Runtime.getRuntime();
*
* System.out.println("##### Heap utilisation statistics [MB] #####");
*
* //Print used memory System.out.println("Used Memory:" +
* (runtime.totalMemory() - runtime.freeMemory()) / mb);
*
* //Print free memory System.out.println("Free Memory:" + runtime.freeMemory()
* / mb);
*
* //Print total available memory System.out.println("Total Memory:" +
* runtime.totalMemory() / mb);
*
* //Print Maximum available memory System.out.println("Max Memory:" +
* runtime.maxMemory() / mb);
*/
// MainWindow.getInstance().getMainWindowState().init(virtualHomeValue);
// MainWindow.getInstance().getMainWindowState().run();
// MainWindow.getInstance().getMainWindowState().init(virtualHomeValue);
// MainWindow.getInstance().getMainWindowState().run();
MainWindow
.
getInstance
().
init
();
...
...
@@ -268,14 +283,13 @@ public class MainWindow implements ServerConfigurationChangeListener, ServerEnde
public
void
init
()
{
ConfigManager
.
initInstance
(
virtualHomeValue
);
// Create logs directory if it doesn't exist
File
logsDirectory
=
new
File
(
ConfigManager
.
getInstance
().
getString
(
"logsDirectory"
));
if
(!
logsDirectory
.
exists
())
{
// Directory does not exist: create it
(
new
File
(
ConfigManager
.
getInstance
().
getString
(
"logsDirectory"
))).
mkdir
();
(
new
File
(
ConfigManager
.
getInstance
().
getString
(
"logsDirectory"
))).
mkdir
();
}
// Initialise the display
...
...
@@ -297,7 +311,8 @@ public class MainWindow implements ServerConfigurationChangeListener, ServerEnde
try
{
if
(
ConfigManager
.
getInstance
().
getPreferenceValue
(
ConfigManager
.
USE_NOMADLOGS
)
!=
null
)
{
useNomadLogs
=
Boolean
.
valueOf
(
ConfigManager
.
getInstance
().
getPreferenceValue
(
ConfigManager
.
USE_NOMADLOGS
));
useNomadLogs
=
Boolean
.
valueOf
(
ConfigManager
.
getInstance
().
getPreferenceValue
(
ConfigManager
.
USE_NOMADLOGS
));
}
else
{
useNomadLogs
=
true
;
}
...
...
@@ -329,7 +344,8 @@ public class MainWindow implements ServerConfigurationChangeListener, ServerEnde
}
catch
(
ExitException
e
)
{
}
catch
(
Exception
e
)
{
try
{
String
fileName
=
ConfigManager
.
getInstance
().
getString
(
"logsDirectory"
)
+
ConfigManager
.
FILE_SEPARATOR
+
"crash_"
+
Nomad
.
getDateAndTime
()
+
".txt"
;
String
fileName
=
ConfigManager
.
getInstance
().
getString
(
"logsDirectory"
)
+
ConfigManager
.
FILE_SEPARATOR
+
"crash_"
+
Nomad
.
getDateAndTime
()
+
".txt"
;
BufferedWriter
writer
=
new
BufferedWriter
(
new
FileWriter
(
fileName
));
writer
.
write
(
convertStackTrace
(
e
));
e
.
printStackTrace
();
...
...
@@ -345,15 +361,13 @@ public class MainWindow implements ServerConfigurationChangeListener, ServerEnde
}
}
private
String
convertStackTrace
(
Throwable
t
)
{
StringWriter
sw
=
new
StringWriter
();
PrintWriter
pw
=
new
PrintWriter
(
sw
);
t
.
printStackTrace
(
pw
);
return
sw
.
toString
();
t
.
printStackTrace
(
pw
);
return
sw
.
toString
();
}
private
void
logServerException
(
ServerException
se
)
{
BufferedWriter
writer
=
null
;
try
{
...
...
@@ -363,7 +377,8 @@ public class MainWindow implements ServerConfigurationChangeListener, ServerEnde
file
.
createNewFile
();
}
writer
=
new
BufferedWriter
(
new
FileWriter
(
serverExceptionsFileName
,
true
));
writer
.
write
(
Nomad
.
getDateAndTime
()
+
"\t"
+
se
.
getClassName
()
+
"::"
+
se
.
getMethodName
()
+
".\t"
+
se
.
getException
().
getMessage
()
+
"\n"
);
writer
.
write
(
Nomad
.
getDateAndTime
()
+
"\t"
+
se
.
getClassName
()
+
"::"
+
se
.
getMethodName
()
+
".\t"
+
se
.
getException
().
getMessage
()
+
"\n"
);
writer
.
flush
();
writer
.
close
();
...
...
@@ -373,7 +388,6 @@ public class MainWindow implements ServerConfigurationChangeListener, ServerEnde
}
}
public
void
readAndDispatchServerEvents
()
{
if
(
MainWindowState
.
testEvents
)
{
ChangeManager
.
getInstance
().
readAndDispatchALotOfEvents
();
...
...
@@ -446,25 +460,25 @@ public class MainWindow implements ServerConfigurationChangeListener, ServerEnde
}
return
false
;
}
// public boolean nomadLogsOpen() {
// if (MainWindow.getInstance().isInExecutionState()) {
// ((MainWindowExecutionState)mainWindowState).nomadLogsOpen();
// }
// return false;
// }
// public void startNomadLogs() {
// if (MainWindow.getInstance().isInExecutionState()) {
// ((MainWindowExecutionState)mainWindowState).startNomadLogs();
// }
// }
// public boolean nomadLogsOpen() {
// if (MainWindow.getInstance().isInExecutionState()) {
// ((MainWindowExecutionState)mainWindowState).nomadLogsOpen();
// }
// return false;
// }
// public void onProposalChange(String selectedProposalId) {
// if (MainWindow.getInstance().isInExecutionState()) {
// ((MainWindowExecutionState)mainWindowState).onProposalChange(selectedProposalId);
// }
// }
// public void startNomadLogs() {
// if (MainWindow.getInstance().isInExecutionState()) {
// ((MainWindowExecutionState)mainWindowState).startNomadLogs();
// }
// }
// public void onProposalChange(String selectedProposalId) {
// if (MainWindow.getInstance().isInExecutionState()) {
// ((MainWindowExecutionState)mainWindowState).onProposalChange(selectedProposalId);
// }
// }
public
final
boolean
onClose
(
int
err
)
{
boolean
goOn
=
true
;
...
...
@@ -474,8 +488,10 @@ public class MainWindow implements ServerConfigurationChangeListener, ServerEnde
}
if
(
goOn
)
{
if
(
Nomad
.
getComputerFullName
()
==
null
||
!(
Nomad
.
getComputerFullName
().
equals
(
"gamma34"
)
||
Nomad
.
getComputerFullName
().
equals
(
"gamma23"
)))
{
goOn
=
(
DialogManager
.
getInstance
().
nomadYesNoMessageDialog
(
"quitNomadMessage"
,
"quitNomadMessageTitle"
));
if
(
Nomad
.
getComputerFullName
()
==
null
||
!(
Nomad
.
getComputerFullName
().
equals
(
"gamma34"
)
||
Nomad
.
getComputerFullName
().
equals
(
"gamma23"
)))
{
goOn
=
(
DialogManager
.
getInstance
().
nomadYesNoMessageDialog
(
"quitNomadMessage"
,
"quitNomadMessageTitle"
));
}
if
(
goOn
)
{
if
(
getCurrentSelectionPlugin
().
getCurrentControllerPlugin
()
!=
null
)
{
...
...
@@ -492,8 +508,9 @@ public class MainWindow implements ServerConfigurationChangeListener, ServerEnde
}
public
void
close
()
{
mainWindowState
.
close
();
MainWindowPeer
.
getInstance
().
onClose
();
//TODO
// mainWindowState.close();
// MainWindowPeer.getInstance().onClose();
}
// This method does not exist in master branch
...
...
@@ -503,11 +520,11 @@ public class MainWindow implements ServerConfigurationChangeListener, ServerEnde
}
// This method does not exist in master branch
//
public void onUserChange() {
//
if (mainWindowState.isInExecutionState()) {
//
((MainWindowExecutionState)mainWindowState).onUserChange();
//
}
//
}
//
public void onUserChange() {
//
if (mainWindowState.isInExecutionState()) {
//
((MainWindowExecutionState)mainWindowState).onUserChange();
//
}
//
}
public
void
close
(
int
err
)
{
...
...
@@ -522,8 +539,10 @@ public class MainWindow implements ServerConfigurationChangeListener, ServerEnde
ConfigManager
.
getInstance
().
savePreference
(
ConfigManager
.
MAGNIFY_FACTOR_INDEX
,
Magnifier
.
getScaleIndex
()
+
""
);
ConfigManager
.
getInstance
().
savePreference
(
ConfigManager
.
X_MAIN_WINDOW
,
String
.
valueOf
(
MainWindowPeer
.
getInstance
().
getX
()));
ConfigManager
.
getInstance
().
savePreference
(
ConfigManager
.
Y_MAIN_WINDOW
,
String
.
valueOf
(
MainWindowPeer
.
getInstance
().
getY
()));
ConfigManager
.
getInstance
().
savePreference
(
ConfigManager
.
X_MAIN_WINDOW
,
String
.
valueOf
(
MainWindowPeer
.
getInstance
().
getX
()));
ConfigManager
.
getInstance
().
savePreference
(
ConfigManager
.
Y_MAIN_WINDOW
,
String
.
valueOf
(
MainWindowPeer
.
getInstance
().
getY
()));
ConfigManager
.
getInstance
().
savePreferences
();
MainWindowPeer
.
getInstance
().
onClose
(
err
);
...
...
@@ -532,9 +551,11 @@ public class MainWindow implements ServerConfigurationChangeListener, ServerEnde
private
void
reset
()
{
System
.
out
.
println
(
"Trying to reset tabs"
);
// Do not kill the simulation servers directly but calling onReset that resets the Cameo objects.
// Do not kill the simulation servers directly but calling onReset that resets
// the Cameo objects.
if
(
CommandWindow
.
getInstance
().
getNavigationBar
()
!=
null
)
{
ArrayList
<
TabButton
>
copy
=
new
ArrayList
<
TabButton
>(
CommandWindow
.
getInstance
().
getNavigationBar
().
getTabs
());
ArrayList
<
TabButton
>
copy
=
new
ArrayList
<
TabButton
>(
CommandWindow
.
getInstance
().
getNavigationBar
().
getTabs
());
for
(
TabButton
b
:
copy
)
{
b
.
onReset
();
}
...
...
@@ -543,44 +564,49 @@ public class MainWindow implements ServerConfigurationChangeListener, ServerEnde
System
.
out
.
println
(
"Reset tabs"
);
CommandZoneWrapper
.
getInstance
(
CommandZoneWrapper
.
SERVER_ID
).
release
();
boolean
serverRunning
=
fr
.
ill
.
ics
.
nscclient
.
serverconnection
.
ServerConnection
.
getInstance
(
CommandZoneWrapper
.
SERVER_ID
).
serverExists
();
boolean
serverRunning
=
fr
.
ill
.
ics
.
nscclient
.
serverconnection
.
ServerConnection
.
getInstance
(
CommandZoneWrapper
.
SERVER_ID
).
serverExists
();
if
(
serverRunning
)
{
LoginManager
.
getInstance
().
logout
(
CommandZoneWrapper
.
SERVER_ID
);
}
}
public
void
goToNode
(
String
selectionPluginId
,
String
nodeName
)
{
// This method is called from the main menu... should not be available when being in ConfigurationState
// if (mainWindowState.isInExecutionState()) {
// ((MainWindowExecutionState)mainWindowState).goToNode(selectionPluginId, nodeName);
// This method is called from the main menu... should not be available when
// being in ConfigurationState
if
(
mainWindowState
.
isInExecutionState
())
{
((
MainWindowExecutionState
)
mainWindowState
).
goToNode
(
selectionPluginId
,
nodeName
);
}
// SelectionPlugin selectionPlugin = null;
//
// if (selectionPluginId.equals(SelectionPlugin.HARDWARE_ID)) {
// selectionPlugin = hardwareSelectionPlugin;
// } else if (selectionPluginId.equals(SelectionPlugin.SETTINGS_ID)) {
// selectionPlugin = settingsSelectionPlugin;
// }
// if (selectionPlugin != null) {
// // Select settings tab
// selectionPlugin.selectButton();
// if (nodeName != null) {
// // Select controller node in selection tree
// selectionPlugin.selectNode(nodeName);
// }
// }
SelectionPlugin
selectionPlugin
=
null
;
if
(
selectionPluginId
.
equals
(
SelectionPlugin
.
HARDWARE_ID
))
{
selectionPlugin
=
hardwareSelectionPlugin
;
}
else
if
(
selectionPluginId
.
equals
(
SelectionPlugin
.
SETTINGS_ID
))
{
selectionPlugin
=
settingsSelectionPlugin
;
}
if
(
selectionPlugin
!=
null
)
{
// Select settings tab
selectionPlugin
.
selectButton
();
if
(
nodeName
!=
null
)
{
// Select controller node in selection tree
selectionPlugin
.
selectNode
(
nodeName
);
}
}
}
// public void setCommandsSelectionPlugin(CommandsSelectionPlugin commandsSelectionPlugin) {
// this.commandsSelectionPlugin = commandsSelectionPlugin;
// }
// public void setCommandsSelectionPlugin(CommandsSelectionPlugin
// commandsSelectionPlugin) {
// this.commandsSelectionPlugin = commandsSelectionPlugin;
// }
/**
* <p>Adds a new INewCountRepeaterFileListener to the list of listeners to this particular plugin.
* If the listener already exists then ignor.
* @param INewCountRepeaterFileListener a new listener
* <p>
* Adds a new INewCountRepeaterFileListener to the list of listeners to this
* particular plugin. If the listener already exists then ignor.
*
* @param INewCountRepeaterFileListener
* a new listener
*/
public
void
addNewCountRepeaterFileListener
(
INewCountRepeaterFileListener
newCountRepeaterFileListener
)
{
if
(
newCountRepeaterFileListeners
==
null
)
{
...
...
@@ -594,8 +620,9 @@ public class MainWindow implements ServerConfigurationChangeListener, ServerEnde
}
/**
* <p>Removes a INewCountRepeaterFileListener.
* <br>If the listener does not exist in the list of listeners then ignor it.
* <p>
* Removes a INewCountRepeaterFileListener. <br>
* If the listener does not exist in the list of listeners then ignor it.
*/
public
void
removeNewCountRepeaterFileListener
(
INewCountRepeaterFileListener
newCountRepeaterFileListener
)
{
if
(
newCountRepeaterFileListeners
!=
null
)
{
...
...
@@ -641,7 +668,7 @@ public class MainWindow implements ServerConfigurationChangeListener, ServerEnde
public
boolean
simulationModeIsReady
(
String
serverId
)
{
// The Configuration state should not have a simulation mode
if
(
mainWindowState
.
isInExecutionState
())
{
return
((
MainWindowExecutionState
)
mainWindowState
).
simulationModeIsReady
(
serverId
);
return
((
MainWindowExecutionState
)
mainWindowState
).
simulationModeIsReady
(
serverId
);
}
return
false
;
}
...
...
@@ -664,14 +691,14 @@ public class MainWindow implements ServerConfigurationChangeListener, ServerEnde
public
void
onAdministratorLogin
()
{
// This method should be only accessible when being in Execution State
if
(
mainWindowState
.
isInExecutionState
())
{
((
MainWindowExecutionState
)
mainWindowState
).
onAdministratorLogin
();
((
MainWindowExecutionState
)
mainWindowState
).
onAdministratorLogin
();
}
}
public
void
onAdministratorLogout
()
{
// This method should be only accessible when being in Execution State
if
(
mainWindowState
.
isInExecutionState
())
{
((
MainWindowExecutionState
)
mainWindowState
).
onAdministratorLogout
();
((
MainWindowExecutionState
)
mainWindowState
).
onAdministratorLogout
();
}
}
...
...
@@ -688,57 +715,59 @@ public class MainWindow implements ServerConfigurationChangeListener, ServerEnde
}
public
void
onControllerNotFoundException
(
ControllerNotFoundException
e
)
{
//DialogManager.getInstance().onConfigurationException(e);
//
DialogManager.getInstance().onConfigurationException(e);
}
public
void
onPropertyNotFoundException
(
PropertyNotFoundException
e
)
{
//DialogManager.getInstance().onConfigurationException(e);
//
DialogManager.getInstance().onConfigurationException(e);
}
public
void
onCommandNotFoundException
(
CommandNotFoundException
e
)
{
//DialogManager.getInstance().onConfigurationException(e);
//
DialogManager.getInstance().onConfigurationException(e);
}
public
void
onParticularWidgetNotFoundException
(
ParticularWidgetNotFoundException
e
)
{
//DialogManager.getInstance().onConfigurationException(e);
//
DialogManager.getInstance().onConfigurationException(e);
}
public
void
setCredentials
(
String
credentials
)
{
this
.
credentials
=
credentials
;
}
@Override
@Override
public
void
configurationChanged
(
int
servantID
,
ClientConfigurationState
enable
)
{
// Reload the controllers in case it is a global configuration change.
if
(
servantID
==
0
)
{
ControllerManager
.
getInstance
().
reloadControllers
();
System
.
out
.
println
(
"Reload controllers"
);
}
// Reload the trees if it is not a property configuration change.
if
(
enable
!=
ClientConfigurationState
.
PROPERTY
)
{
hardwareSelectionPlugin
.
reloadTree
();
settingsSelectionPlugin
.
reloadTree
();
commandsSelectionPlugin
.
reloadTree
();
hardwareSelectionPlugin
.
onConfigurationChanged
();
System
.
out
.
println
(
"Reload trees"
);
if
(
mainWindowState
.
isInExecutionState
())
{
((
MainWindowExecutionState
)
mainWindowState
).
configurationChanged
(
servantID
,
enable
);
}
// // Reload the controllers in case it is a global configuration change.
// if (servantID == 0) {
// ControllerManager.getInstance().reloadControllers();
//
// System.out.println("Reload controllers");
// }
//
// // Reload the trees if it is not a property configuration change.
// if (enable != ClientConfigurationState.PROPERTY) {
// hardwareSelectionPlugin.reloadTree();
// settingsSelectionPlugin.reloadTree();
// commandsSelectionPlugin.reloadTree();
// hardwareSelectionPlugin.onConfigurationChanged();
//
// System.out.println("Reload trees");
// }
}
// public static boolean useNomadLogs() {
// return useNomadLogs;
// }
//
//
// public static boolean useNomadLogs() {
// return useNomadLogs;
// }
//
//
public
boolean
nomadLogsOpen
()
{
return
true
;
}
public
void
startNomadLogs
()
{
if
(
credentials
==
null
)
{
...
...
@@ -764,7 +793,8 @@ public class MainWindow implements ServerConfigurationChangeListener, ServerEnde
String
prodArgument
=
""
;
int
mode
=
UserConnection
.
MODE_FULL_TEST
;
try
{
mode
=
Integer
.
valueOf
(
ConfigManager
.
getInstance
().
getStringOrNothingAtAll
(
UserConnection
.
NOMAD_SENDDATA
));
mode
=
Integer
.
valueOf
(
ConfigManager
.
getInstance
().
getStringOrNothingAtAll
(
UserConnection
.
NOMAD_SENDDATA
));
}
catch
(
Exception
e
)
{
mode
=
UserConnection
.
MODE_FULL_TEST
;
}
...
...
@@ -773,31 +803,34 @@ public class MainWindow implements ServerConfigurationChangeListener, ServerEnde
prodArgument
=
"-prod"
;
}
//
String authentication = Nomad.base64Encode("ics" + ":" + "icsics");
//
String authentication = Nomad.base64Encode("ics" + ":" + "icsics");
String
[]
args
=
new
String
[]
{
prodArgument
,
"-auth"
,
credentials
,
"-proposal"
,
instrumentId
+
"/"
+
year
+
"/"
+
proposNo
,
"-width "
+
MainWindowPeer
.
getInstance
().
getWidth
(),
"-height "
+
MainWindowPeer
.
getInstance
().
getHeight
()};
String
[]
args
=
new
String
[]
{
prodArgument
,
"-auth"
,
credentials
,
"-proposal"
,
instrumentId
+
"/"
+
year
+
"/"
+
proposNo
,
"-width "
+
MainWindowPeer
.
getInstance
().
getWidth
(),
"-height "
+
MainWindowPeer
.
getInstance
().
getHeight
()
};
for
(
String
arg:
args
)
{
for
(
String
arg
:
args
)
{
System
.
out
.
println
(
"arg "
+
arg
);
}
nomadLogsInstance
=
cameoServer
.
start
(
NOMADLOGS_APP_NAME
,
args
);
if
(
nomadLogsInstance
.
exists
())
{
System
.
out
.
println
(
"Starting "
+
nomadLogsInstance
);
/* waiting for a real "is running" status (see YLG)
nomadLogsInstance.waitFor(Application.State.RUNNING);
System.out.println(nomadLogsInstance + " started");
/*
* waiting for a real "is running" status (see YLG)
* nomadLogsInstance.waitFor(Application.State.RUNNING);
* System.out.println(nomadLogsInstance + " started");
*/
}
else
if
(
nomadLogsInstance
.
getErrorMessage
()
!=
null
)
{
DialogManager
.
getInstance
().
nomadMessageDialog
(
nomadLogsInstance
.
getErrorMessage
(),
"viewLogsMessage"
);
}
}
else
{
DialogManager
.
getInstance
().
nomadMessageDialog
(
"unableToLocateNomadServerPropertyMessage"
,
"configurationErrorMessage"
);
DialogManager
.
getInstance
().
nomadMessageDialog
(
"unableToLocateNomadServerPropertyMessage"
,
"configurationErrorMessage"
);
}
}
public
void
stopNomadLogs
()
{
if
(
nomadLogsInstance
!=
null
)
{
System
.
out
.
println
(
"Killing nomadLogs instance..."
);
...
...
@@ -808,7 +841,6 @@ public class MainWindow implements ServerConfigurationChangeListener, ServerEnde
}
}
public
void
stopNomadSurvey
()
{
if
(
nomadSurveyInstance
!=
null
)
{
System
.
out
.
println
(
"Killing NomadSurvey instance..."
);
...
...
@@ -819,25 +851,22 @@ public class MainWindow implements ServerConfigurationChangeListener, ServerEnde
}
}
private
boolean
nomadLogsIsOpen
()
{
if
(
cameoServer
!=
null
)
{
nomadLogsInstance
=
cameoServer
.
connect
(
NOMADLOGS_APP_NAME
);
return
(
nomadLogsInstance
.
exists
());
}
}
return
false
;
}
private
boolean
nomadSurveyIsOpen
()
{
if
(
cameoServer
!=
null
)
{
nomadSurveyInstance
=
cameoServer
.
connect
(
NOMADSURVEY_APP_NAME
);
return
(
nomadSurveyInstance
.
exists
());
}
}
return
false
;
}
public
void
onProposalChange
(
String
selectedProposalId
)
{
// Warn NomadLogs (if open) that proposal has changed
if
(
MainWindow
.
useNomadLogs
())
{
...
...
@@ -849,58 +878,57 @@ public class MainWindow implements ServerConfigurationChangeListener, ServerEnde
MainWindow
.
getInstance
().
onProposalChange
(
Long
.
valueOf
(
selectedProposalId
));
}
public
void
onUserChange
()
{
if
(
initOk
&&
nomadLogsIsOpen
())
{
// Prevent initial call when username property is set
stopNomadLogs
();
// do not restart it, when the user changes, the proposal changes just after and will restart logs if necessary
// do not restart it, when the user changes, the proposal changes just after and
// will restart logs if necessary
}
if
(
initOk
&&
nomadSurveyIsOpen
())
{
if
(
initOk
&&
nomadSurveyIsOpen
())
{
stopNomadSurvey
();
// do not restart it, when the user changes, the proposal changes just after and will restart logs if necessary
// do not restart it, when the user changes, the proposal changes just after and
// will restart logs if necessary
}
}
public
void
onTokenStateChange
()
{
MainWindowPeer
.
getInstance
().
onTokenStateChange
();
}
public
void
onProposalChange
(
long
selectedProposalId
)
{
MainWindowPeer
.
getInstance
().
onProposalChange
(
selectedProposalId
);
MainWindowPeer
.
getInstance
().
onProposalChange
(
selectedProposalId
);
}
public
void
closeChat
()
{
MainWindowPeer
.
getInstance
().
closeChat
();
MainWindowPeer
.
getInstance
().
closeChat
();
}
public
void
onProposalChange
()
{
authentication
.
updateProposal
();
// this call will open chat's file for current proposal
onProposalChange
(
ExperimentData
.
getInstance
().
getProposalId
());
}
@Override
public
void
serverEnded
(
ServerEndedEvent
event
)
{
// Stop the logs and charts applications.
stopNomadLogs
();
stopNomadSurvey
();
System
.
out
.
println
(
"Exiting..."
);
// Direct exit to avoid blockings: we used to call close() in an async runnable but it was not robust.
// Exit with -3 so that the exit code can be processed by the script that runs NomadGUI and display an appropriate window.
// Direct exit to avoid blockings: we used to call close() in an async runnable
// but it was not robust.
// Exit with -3 so that the exit code can be processed by the script that runs
// NomadGUI and display an appropriate window.
System
.
exit
(-
3
);
}
public
Object
getCredentials
()
{
return
credentials
;
}
public
void
startParameterSurvey
()
{
if
(
credentials
==
null
)
{
DialogManager
.
getInstance
().
nomadMessageDialog
(
"mustLogInToViewSurveyMessage"
,
"viewSurveyTitle"
);
...
...
@@ -920,7 +948,8 @@ public class MainWindow implements ServerConfigurationChangeListener, ServerEnde
String
prodArgument
=
""
;
int
mode
=
UserConnection
.
MODE_FULL_TEST
;
try
{
mode
=
Integer
.
valueOf
(
ConfigManager
.
getInstance
().
getStringOrNothingAtAll
(
UserConnection
.
NOMAD_SENDDATA
));
mode
=
Integer
.
valueOf
(
ConfigManager
.
getInstance
().
getStringOrNothingAtAll
(
UserConnection
.
NOMAD_SENDDATA
));
}
catch
(
Exception
e
)
{
mode
=
UserConnection
.
MODE_FULL_TEST
;
}
...
...
@@ -929,21 +958,25 @@ public class MainWindow implements ServerConfigurationChangeListener, ServerEnde
prodArgument
=
"-prod"
;
}
String
[]
args
=
new
String
[]
{
prodArgument
,
"-auth"
,
credentials
,
"-proposal"
,
instrumentId
+
"/-1/-1"
,
"-width "
+
MainWindowPeer
.
getInstance
().
getWidth
(),
"-height "
+
MainWindowPeer
.
getInstance
().
getHeight
()};
String
[]
args
=
new
String
[]
{
prodArgument
,
"-auth"
,
credentials
,
"-proposal"
,
instrumentId
+
"/-1/-1"
,
"-width "
+
MainWindowPeer
.
getInstance
().
getWidth
(),
"-height "
+
MainWindowPeer
.
getInstance
().
getHeight
()
};
for
(
String
arg:
args
)
{
for
(
String
arg
:
args
)
{
System
.
out
.
println
(
"arg "
+
arg
);
}
nomadSurveyInstance
=
cameoServer
.
start
(
NOMADSURVEY_APP_NAME
,
args
);
if
(
nomadSurveyInstance
.
exists
())
{
System
.
out
.
println
(
"Starting "
+
nomadSurveyInstance
);
}
else
if
(
nomadSurveyInstance
.
getErrorMessage
()
!=
null
)
{
DialogManager
.
getInstance
().
nomadMessageDialog
(
nomadSurveyInstance
.
getErrorMessage
(),
"viewSurveyTitle"
);
DialogManager
.
getInstance
().
nomadMessageDialog
(
nomadSurveyInstance
.
getErrorMessage
(),
"viewSurveyTitle"
);
}
}
else
{
DialogManager
.
getInstance
().
nomadMessageDialog
(
"unableToLocateNomadServerPropertyMessage"
,
"configurationErrorMessage"
);
}
DialogManager
.
getInstance
().
nomadMessageDialog
(
"unableToLocateNomadServerPropertyMessage"
,
"configurationErrorMessage"
);
}
}
public
boolean
visa
()
{
...
...
@@ -952,14 +985,13 @@ public class MainWindow implements ServerConfigurationChangeListener, ServerEnde
@Override
public
void
onClientDisconnected
()
{
((
ServerCommandZone
)
CommandWindow
.
getInstance
().
getServerTabButton
().
getCommandZone
()).
disconnect
();
((
ServerCommandZone
)
CommandWindow
.
getInstance
().
getServerTabButton
().
getCommandZone
()).
disconnect
();
DialogManager
.
getInstance
().
nomadMessageDialog
(
"clientDisconnectedMessage"
,
"clientDisconnectedTitle"
);
close
(-
4
);
}
// Particular code at start
public
void
breakingNews
()
{
// D11: ask if current beamstop is the right one
...
...
@@ -968,14 +1000,16 @@ public class MainWindow implements ServerConfigurationChangeListener, ServerEnde
if
(
ConfigManager
.
getInstance
().
isMainClient
())
{
try
{
Controller
controller
=
ControllerManager
.
getInstance
().
getController
(
"BeamStop"
);
Property
actualBeamStopProperty
=
PropertyManager
.
getInstance
().
getProperty
(
controller
,
"actual_number"
);
Property
actualBeamStopProperty
=
PropertyManager
.
getInstance
().
getProperty
(
controller
,
"actual_number"
);
if
(
actualBeamStopProperty
!=
null
)
{
MainWindowPeer
.
getInstance
().
breakingNews
(
"Actual beamstop number is "
+
actualBeamStopProperty
.
getValue
()
+
".\nIs that correct ?"
);
MainWindowPeer
.
getInstance
().
breakingNews
(
"Actual beamstop number is "
+
actualBeamStopProperty
.
getValue
()
+
".\nIs that correct ?"
);
}
}
catch
(
ControllerNotFoundException
e
)
{
MainWindow
.
getInstance
().
onControllerNotFoundException
(
e
);
}
}
}
}
}
}
This diff is collapsed.
Click to expand it.
src/main/java/fr/ill/ics/client/view/MainWindowPeer.java
+
1
−
1
View file @
0b9ac222
...
...
@@ -314,7 +314,7 @@ public abstract class MainWindowPeer {
//not in V4
public
void
addTokenInfoInChat
(
String
message
)
{
tokenWidget
.
addTokenInfoInChat
(
message
);
//
tokenWidget.addTokenInfoInChat(message);
}
public
void
onServerRemoteStateChange
()
{
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment