Commit 0fd0acfc authored by Locatelli's avatar Locatelli
Browse files

Merge V4.0 to master

parent ee1604d1
4.0.32 dd/mm/2020
4.0.51 21/09/2021
------
* Add debug messages again to understand crashes around addCommandBox.
4.0.50 20/09/2021
------
* Add debug messages to understand crashes around addCommandBox.
4.0.49 10/09/2021
------
* SessionManager takes into account disconnections.
4.0.48 04/08/2021
------
* Add rgb option for plot
4.0.47 22/06/2021
------
* No longer log messages "CommandBoxNotFoundException occured for command box ..."
4.0.46 11/06/2021
------
* Maxlength condition no longer prevents to enter a value which length exceeds maxlength, but is only used to give text's griddata an appropriate width.
* Display a message for Common.Error.Type.NO_SUCH_COMMAND.
4.0.45 10/06/2021
------
* Added test on server state in ServerConnection.startConnectedToServerThread() to avoid exiting with an error code when the client is closed.
4.0.44 18/05/2021
------
* New method in PropertyFormat to solve problem in sample sequencer copy button code: when copying value from a double property to following ones,
for example "12345", Nomad adds ".00" to the value so it exceeds maxlength for the property and the copy process doesn't work.
4.0.43 30/04/2021
------
* Forward only the first event informing that Nomad client is disconnected from Nomad server.
* Add a property for ploty2
* Automatically add unitformat for property whose name is "unit".
* Change the way properties whose unit contains special characters (°, µ, ...) is formatted.
4.0.42 09/04/2021
------
* Inform user that its Nomad client is disconnected from Nomad server.
4.0.41 10/02/2021
------
* Add method updateStandardPropertiesDescriptor to solve problems related to enumerated values and labels when enabling a controller
4.0.40 4/02/2021
------
* Add some resets in logoutAll method for clearing requester in cameo
4.0.39 19/01/2021
------
* Delete the command boxes when a CommandBoxDeleted event is received.
4.0.38 15/01/2021
------
* NewFileCreated events received and notified to NewFileCreatedListener.
4.0.37 21/12/2020
------
* Add method isPaused in IServerCommand.
4.0.36 03/12/2020
------
* Update version of nomad-command-system-messages (0.0.21 --> 0.0.22).
4.0.35 26/11/2020
------
* Connected users management.
* Users' roles management.
4.0.34 13/11/2020
------
* Cameo 1.0.0 integrated.
4.0.33 13/10/2020
------
* Modifications for attached files in chat.
4.0.32 01/10/2020
------
* Add 2 preference values to restore main window x and y.
* Add a ploty2 message property
4.0.31 13/08/2020
------
......
......@@ -2,7 +2,7 @@
<modelVersion>4.0.0</modelVersion>
<groupId>fr.ill.ics</groupId>
<artifactId>nomadcommandsystem</artifactId>
<version>4.0.31</version>
<version>4.0.51</version>
<name>NomadCommandSystem</name>
<description>Java bridge for the communication with the Nomad server</description>
<scm>
......@@ -61,12 +61,12 @@
<dependency>
<groupId>fr.ill.ics</groupId>
<artifactId>nomadcommandsystem-messages</artifactId>
<version>0.0.17</version>
<version>0.0.28</version>
</dependency>
<dependency>
<groupId>fr.ill.ics</groupId>
<artifactId>cameo-api</artifactId>
<version>0.1.9</version>
<version>1.0.0</version>
<exclusions>
<exclusion>
<groupId>fr.ill.ics</groupId>
......@@ -77,7 +77,7 @@
<dependency>
<groupId>fr.ill.ics</groupId>
<artifactId>cameo-com-jzmq</artifactId>
<version>0.0.3</version>
<version>0.0.4</version>
</dependency>
</dependencies>
<build>
......@@ -133,4 +133,4 @@
</plugins>
</build>
</project>
\ No newline at end of file
</project>
......@@ -310,6 +310,11 @@ public class ControllerManager implements ServerConfigurationChangeListener {
ControllerServant controller = (ControllerServant)servant;
ServantManagerAccessor.getInstance(serverId).updateDynamicProperties(controller.getId());
}
public void updateStandardPropertiesDescriptor(Controller servant) {
ControllerServant controller = (ControllerServant)servant;
ServantManagerAccessor.getInstance(serverId).updateStandardPropertiesDescriptor(controller.getId());
}
public void configurationChanged(int servantID, ClientConfigurationState enable) {
......
......@@ -21,6 +21,8 @@ package fr.ill.ics.bridge;
import java.util.HashMap;
import com.google.protobuf.ByteString;
import fr.ill.ics.nscclient.command.CommandZoneAccessor;
import fr.ill.ics.nscclient.dataprovider.ServantManagerAccessor;
import fr.ill.ics.nscclient.servant.ResourceNotFoundException;
......@@ -39,6 +41,7 @@ public class ResourceManager {
public final static int SURVEY_FILE = 4;
public final static int CHAT_FILE = 5;
public final static int PROPERTIES_FILE = 6;
public final static int ATTACHED_FILE = 7;
private String serverId;
......@@ -85,11 +88,18 @@ public class ResourceManager {
CommandZoneAccessor.getInstance(serverId).saveFile(fileName, content, fileType, addServerHome);
}
public void saveBinaryFile(String fileName, byte[] bytes, int fileType, boolean addServerHome) {
ByteString byteString = ByteString.copyFrom(bytes);
CommandZoneAccessor.getInstance(serverId).saveBinaryFile(fileName, byteString, fileType, addServerHome);
}
public String getFileContent(String fileName) throws ResourceNotFoundException {
return CommandZoneAccessor.getInstance(serverId).getFileContent(fileName);
}
public byte[] getBinaryFileContent(String fileName) throws ResourceNotFoundException {
return CommandZoneAccessor.getInstance(serverId).getBinaryFileContent(fileName);
}
public String getFileContentAbsolutePath(String fileName) throws ResourceNotFoundException {
return CommandZoneAccessor.getInstance(serverId).getFileContentAbsolutePath(fileName);
......
......@@ -19,11 +19,13 @@
package fr.ill.ics.bridge.command;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import fr.ill.ics.bridge.events.ServerCommandStateChangeEvent;
import fr.ill.ics.bridge.events.ServerCommandStateChangeEvent.CommandState;
import fr.ill.ics.bridge.events.ServerResetCommandEvent;
import fr.ill.ics.bridge.listeners.ServerCommandBoxDeletedListener;
import fr.ill.ics.bridge.listeners.ServerCommandStateChangeListener;
import fr.ill.ics.bridge.listeners.ServerCommandZoneErrorListener;
import fr.ill.ics.bridge.listeners.ServerCommandZoneSyncListener;
......@@ -53,6 +55,7 @@ public class CommandZoneWrapper implements ICommandZoneEventListener, ICommandZo
private ServerResetCommandListener resetCommandListener;
private ServerCommandZoneErrorListener commandZoneErrorListener;
private ServerCommandZoneSyncListener commandZoneSyncListener;
private ServerCommandBoxDeletedListener commandBoxDeletedListener;
public CommandZoneWrapper(String serverId) {
this.serverId = serverId;
......@@ -100,6 +103,10 @@ public class CommandZoneWrapper implements ICommandZoneEventListener, ICommandZo
this.commandZoneSyncListener = listener;
CommandZoneSyncEventClient.getInstance().addCommandZoneListener(this);
}
public void addServerCommandBoxDeletedListener(ServerCommandBoxDeletedListener listener) {
this.commandBoxDeletedListener = listener;
}
public void removeServerProgressChangeListener(ServerProgressChangeListener listener) {
this.commandProgressListener = null;
......@@ -123,6 +130,10 @@ public class CommandZoneWrapper implements ICommandZoneEventListener, ICommandZo
CommandZoneSyncEventClient.getInstance().removeCommandZoneListener(this);
}
public void removeServerCommandBoxDeletedListener(ServerCommandBoxDeletedListener listener) {
this.commandBoxDeletedListener = null;
}
public void commandZoneStarted() {
if (commandStateListener != null) {
ServerCommandStateChangeEvent event = new ServerCommandStateChangeEvent(null, null);
......@@ -158,6 +169,13 @@ public class CommandZoneWrapper implements ICommandZoneEventListener, ICommandZo
resetCommandListener.reset(new ServerResetCommandEvent(true));
}
}
public void onCommandBoxesDeleted(List<Integer> commandBoxIds) {
commandBoxDeletedListener.onCommandBoxDeleted(commandBoxIds);
/* for (Integer id : commandBoxIds) {
System.out.println(" command box " + id);
}*/
}
public void errorOccurred(String message) {
commandZoneErrorListener.errorOccurred(message);
......
......@@ -18,6 +18,8 @@
package fr.ill.ics.bridge.command;
import java.util.List;
public interface ICommandZoneEventListener {
void commandZoneStarted();
......@@ -28,5 +30,6 @@ public interface ICommandZoneEventListener {
int getCommandZoneID();
void onReset();
void onCommandBoxesDeleted(List<Integer> commandBoxIds);
}
\ No newline at end of file
......@@ -27,6 +27,7 @@ public interface IServerCommand {
String getName();
boolean isRunning();
boolean isPaused();
boolean isFinished();
void toggleBackground();
......
/*
* Nomad Instrument Control Software
*
* Copyright 2011 Institut Laue-Langevin
*
* Licensed under the EUPL, Version 1.1 only (the "License");
* You may not use this work except in compliance with the Licence.
* You may obtain a copy of the Licence at:
*
* http://joinup.ec.europa.eu/software/page/eupl
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the Licence is distributed on an "AS IS" basis,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the Licence for the specific language governing permissions and
* limitations under the Licence.
*/
package fr.ill.ics.bridge.events;
import java.time.LocalDateTime;
import fr.ill.ics.util.ConfigManager;
/**
*
* @author ortizh
*
*/
public class AttachedFileChatEvent extends ChatEvent {
private String fileName;
public AttachedFileChatEvent(String sender, String message, String fileName) {
super(sender, message);
this.fileName = fileName;
}
public AttachedFileChatEvent(String sender, String message, String fileName, LocalDateTime timestamp) {
super(sender, message, timestamp);
this.fileName = fileName;
}
@Override
public boolean hasAttachment() {
return true;
}
public String getShortFileName() {
return fileName.substring(fileName.lastIndexOf(ConfigManager.FILE_SEPARATOR)+1);
}
/**
* Returns the file extension (including dot separator), for example ".txt"
* @return
*/
public String getFileExtension() {
return fileName.substring(fileName.lastIndexOf("."));
}
}
......@@ -32,7 +32,6 @@ import fr.ill.ics.util.ConfigManager;
*/
public class ChatEvent {
public final static String NOMAD = "nomad";
private LocalDateTime timestamp;
private String sender;
private String formattedSender;
......@@ -57,6 +56,10 @@ public class ChatEvent {
public String getMessage() {
return message;
}
public void setMessage(String message) {
this.message = message;
}
public String getFormattedDate() {
// Today or not ?
......@@ -83,8 +86,9 @@ public class ChatEvent {
return sender.equals(SessionManager.getInstance(CommandZoneWrapper.SERVER_ID).getUserName());
}
}
public boolean comesFromServer() {
return sender.equals(NOMAD);
public boolean hasAttachment() {
return false;
}
}
\ No newline at end of file
/*
* Nomad Instrument Control Software
*
* Copyright 2011 Institut Laue-Langevin
*
* Licensed under the EUPL, Version 1.1 only (the "License");
* You may not use this work except in compliance with the Licence.
* You may obtain a copy of the Licence at:
*
* http://joinup.ec.europa.eu/software/page/eupl
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the Licence is distributed on an "AS IS" basis,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the Licence for the specific language governing permissions and
* limitations under the Licence.
*/
package fr.ill.ics.bridge.events;
/**
*
*
*/
public class NewFile {
private int fileType;
private String fileName;
public NewFile(String fileName, int fileType) {
super();
this.fileType = fileType;
this.fileName = fileName;
}
public int getFileType() {
return fileType;
}
public String getFileName() {
return fileName;
}
}
\ No newline at end of file
/*
* Nomad Instrument Control Software
*
* Copyright 2011 Institut Laue-Langevin
*
* Licensed under the EUPL, Version 1.1 only (the "License");
* You may not use this work except in compliance with the Licence.
* You may obtain a copy of the Licence at:
*
* http://joinup.ec.europa.eu/software/page/eupl
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the Licence is distributed on an "AS IS" basis,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the Licence for the specific language governing permissions and
* limitations under the Licence.
*/
package fr.ill.ics.bridge.listeners;
/**
*
* @author ortizh
*/
public interface ClientDisconnectedListener {
public void onClientDisconnected();
}
\ No newline at end of file
/*
* Nomad Instrument Control Software
*
* Copyright 2011 Institut Laue-Langevin
*
* Licensed under the EUPL, Version 1.1 only (the "License");
* You may not use this work except in compliance with the Licence.
* You may obtain a copy of the Licence at:
*
* http://joinup.ec.europa.eu/software/page/eupl
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the Licence is distributed on an "AS IS" basis,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the Licence for the specific language governing permissions and
* limitations under the Licence.
*/
package fr.ill.ics.bridge.listeners;
/**
*
*/
public interface ConnectedUsersChangeListener {
public void connectedUsersChanged();
}
\ No newline at end of file
/*
* Nomad Instrument Control Software
*
* Copyright 2011 Institut Laue-Langevin
*
* Licensed under the EUPL, Version 1.1 only (the "License");
* You may not use this work except in compliance with the Licence.
* You may obtain a copy of the Licence at:
*
* http://joinup.ec.europa.eu/software/page/eupl
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the Licence is distributed on an "AS IS" basis,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the Licence for the specific language governing permissions and
* limitations under the Licence.
*/
package fr.ill.ics.bridge.listeners;
import fr.ill.ics.bridge.events.NewFile;
/**
*
*/
public interface NewFileCreatedListener {
public void newFileCreated(NewFile newFile);
}
\ No newline at end of file
/*
* Nomad Instrument Control Software
*
* Copyright 2011 Institut Laue-Langevin
*
* Licensed under the EUPL, Version 1.1 only (the "License");
* You may not use this work except in compliance with the Licence.
* You may obtain a copy of the Licence at:
*
* http://joinup.ec.europa.eu/software/page/eupl
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the Licence is distributed on an "AS IS" basis,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the Licence for the specific language governing permissions and
* limitations under the Licence.
*/
package fr.ill.ics.bridge.listeners;
import java.util.List;
public interface ServerCommandBoxDeletedListener {
public void onCommandBoxDeleted(List<Integer> commandBoxIds);
}
\ No newline at end of file
......@@ -194,7 +194,7 @@ public abstract class Property implements ServerPropertyChangeListener, ICommand
if (conditions != null) {
for (Iterator<IPropertyCondition> iter = this.conditions.iterator(); iter.hasNext();) {
IPropertyCondition condition = iter.next();
if (!condition.isOk(value)) {
if (!condition.isOk(getPropertyFormat().format(value))) {
setErrorMessageAndTitle(condition.getErrorMessage(getName()), "invalidValueTitle");
sendPropertyErrorEvent();
sendPropertyChangedEvent();
......
......@@ -33,6 +33,7 @@ import java.util.logging.Logger;
import fr.ill.ics.core.property.condition.GreaterThanPropertyCondition;
import fr.ill.ics.core.property.condition.LowerThanPropertyCondition;
import fr.ill.ics.core.property.condition.MaxLengthCondition;
import fr.ill.ics.core.property.condition.PositivePropertyCondition;
import fr.ill.ics.core.property.condition.RangePropertyCondition;
import fr.ill.ics.core.property.condition.RangePropertyDependentCondition;
......@@ -127,7 +128,7 @@ public class PropertyFactory {
} else if (propertyDescriptor.getFormat().equals(PropertyParser.TAG_HEXADECIMAL_FORMAT)) {
property.setPropertyFormat(new HexadecimalFormat());
} else if (propertyDescriptor.getFormat().equals(PropertyParser.TAG_UNIT_FORMAT)) {
} else if (propertyDescriptor.getFormat().equals(PropertyParser.TAG_UNIT_FORMAT) || propertyDescriptor.getPropertyName().equals("unit")) {
property.setPropertyFormat(new UnitFormat());
}
......@@ -138,6 +139,7 @@ public class PropertyFactory {
// max length
property.setMaxLength(propertyDescriptor.getMaxLength());
property.addCondition(new MaxLengthCondition(property.getMaxLength()));
// max view length
property.setViewMaxLength(propertyDescriptor.getViewMaxLength());
......@@ -201,7 +203,7 @@ public class PropertyFactory {
* @param propertyDescriptors a map containing controller property names as keys and PropertyDescriptor instances as values
* @return a map containing controller property names as keys and Property instances as values
*/
public Map createPropertiesForController(int databaseId, int servantId, LinkedHashMap<String, XMLPropertyDescriptor> propertyDescriptors) {
public Map<String, Property> createPropertiesForController(int databaseId, int servantId, LinkedHashMap<String, XMLPropertyDescriptor> propertyDescriptors) {
Map<String, Property> properties = new LinkedHashMap<String, Property>();
Iterator<Entry<String, XMLPropertyDescriptor>> it = propertyDescriptors.entrySet().iterator();
while (it.hasNext()) {
......
/*
* Nomad Instrument Control Software
*
* Copyright 2011 Institut Laue-Langevin
*
* Licensed under the EUPL, Version 1.1 only (the "License");
* You may not use this work except in compliance with the Licence.
* You may obtain a copy of the Licence at:
*
* http://joinup.ec.europa.eu/software/page/eupl
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the Licence is distributed on an "AS IS" basis,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the Licence for the specific language governing permissions and
* limitations under the Licence.
*/
package fr.ill.ics.core.property.condition;
import fr.ill.ics.util.ConfigManager;
/**
*
* @author ortizh
*
*/
public class MaxLengthCondition implements IPropertyCondition {
private int maxLength;
public MaxLengthCondition(int maxLength) {
this.maxLength = maxLength;
}
@Override
public boolean isOk(String value) {
// H.ORTIZ 11/06/21: Maxlength is only used to give text's griddata an appropriate width
return true;
//return value.length() <= maxLength;
}
@Override
public String getErrorMessage(String propertyName) {
return propertyName + ": " + ConfigManager.getInstance().getString("cannotSetPropertyValueIsTooLongSuffix") + " " + maxLength;
}
}
......@@ -64,4 +64,9 @@ public class HexadecimalFormat extends PropertyFormat {