Skip to content

Commit

Permalink
[sre] Add decoration to the network launch configuration panel in ord…
Browse files Browse the repository at this point in the history
…er to explain the meaning of the parameters.

Signed-off-by: Stéphane Galland <galland@arakhne.org>
  • Loading branch information
gallandarakhneorg committed Nov 10, 2020
1 parent 294cb9e commit 73a3efb
Show file tree
Hide file tree
Showing 5 changed files with 65 additions and 5 deletions.
Expand Up @@ -23,9 +23,14 @@

import org.arakhne.afc.vmutil.OperatingSystem;
import org.eclipse.debug.internal.ui.SWTFactory;
import org.eclipse.jface.fieldassist.ControlDecoration;
import org.eclipse.jface.fieldassist.FieldDecoration;
import org.eclipse.jface.fieldassist.FieldDecorationRegistry;
import org.eclipse.swt.SWT;
import org.eclipse.swt.graphics.Image;
import org.eclipse.swt.layout.GridData;
import org.eclipse.swt.widgets.Composite;
import org.eclipse.swt.widgets.Control;
import org.eclipse.swt.widgets.Spinner;

/**
Expand Down Expand Up @@ -200,4 +205,31 @@ public static Spinner createSpinner(Composite parent, int hspan, int min, int ma
return createSpinner(parent, hspan, min, max, DEFAULT_INCREMENT, DEFAULT_PAGE_INCREMENT);
}

/** Attach an information decorator to the given component.
*
* @param parent the component that receives the info decorator.
* @param text the information message.
* @param location the attachment location. It may be bitwise value from {@link SWT#TOP},
* {@link SWT#DOWN}, {@link SWT#LEFT}, {@link SWT#RIGHT}, {@link SWT#CENTER}.
* @return the decorator.
*/
public static ControlDecoration createInfoDecorator(Control parent, String text, int location) {
final ControlDecoration txtDecorator = new ControlDecoration(parent, location);
final FieldDecoration fieldDecoration = FieldDecorationRegistry.getDefault().getFieldDecoration(FieldDecorationRegistry.DEC_INFORMATION);
final Image img = fieldDecoration.getImage();
txtDecorator.setImage(img);
txtDecorator.setDescriptionText(text);
return txtDecorator;
}

/** Attach an information decorator to the given component at its top left corner.
*
* @param parent the component that receives the info decorator.
* @param text the information message.
* @return the decorator.
*/
public static ControlDecoration createInfoDecorator(Control parent, String text) {
return createInfoDecorator(parent, text, SWT.TOP|SWT.LEFT);
}

}
Expand Up @@ -21,7 +21,7 @@

package io.sarl.sre.eclipse.network;

import static io.sarl.eclipse.launching.dialog.SarlSwtFactory.createSpinner;
import static io.sarl.eclipse.launching.dialog.SarlSwtFactory.*;
import static io.sarl.eclipse.launching.dialog.SarlSwtFactory.getCommandLineDefinition;
import static io.sarl.eclipse.launching.dialog.SarlSwtFactory.getCommandLineOption;
import static org.eclipse.debug.internal.ui.SWTFactory.createComposite;
Expand Down Expand Up @@ -140,21 +140,25 @@ public void createControl(Composite parent) {
createSeparator(parent, 2);
createVerticalSpacer(topComp, 2);

final String defaultClusterName = SreNetworkConfig.createStandardClusterName(Messages.JanusLaunchNetworkTab_6);
this.clusterNameLabel = createLabel(topComp,
MessageFormat.format(Messages.JanusLaunchNetworkTab_2,
getCommandLineDefinition(VariableNames.toPropertyName(SreNetworkConfig.CLUSTER_NAME_NAME), Messages.JanusLaunchNetworkTab_8)),
1);
this.clusterNameText = createSingleText(topComp, 1);
this.clusterNameText.setMessage(MessageFormat.format(Messages.JanusLaunchNetworkTab_7,
SreNetworkConfig.createStandardClusterName(Messages.JanusLaunchNetworkTab_6)));
this.clusterNameText.setMessage(defaultClusterName);
this.clusterNameText.addModifyListener(this.defaultListener);
createInfoDecorator(this.clusterNameText,
MessageFormat.format(Messages.JanusLaunchNetworkTab_7, defaultClusterName, Messages.JanusLaunchNetworkTab_6));

this.minClusterSizeLabel = createLabel(topComp,
MessageFormat.format(Messages.JanusLaunchNetworkTab_3,
getCommandLineDefinition(VariableNames.toPropertyName(SreNetworkConfig.MIN_CLUSTER_SIZE_NAME), Messages.JanusLaunchNetworkTab_9)),
1);
this.minClusterSizeSpinner = createSpinner(topComp, 1, MIN_CLUSTER_SIZE, MAX_CLUSTER_SIZE);
this.minClusterSizeSpinner.addModifyListener(this.defaultListener);
createInfoDecorator(this.minClusterSizeSpinner,
MessageFormat.format(Messages.JanusLaunchNetworkTab_10, MIN_CLUSTER_SIZE, SreNetworkConfig.DEFAULT_MIN_CLUSTER_SIZE_VALUE));

this.portAutoIncrementButton = SWTFactory.createCheckButton(topComp,
MessageFormat.format(Messages.JanusLaunchNetworkTab_4,
Expand Down
Expand Up @@ -36,6 +36,7 @@ public class Messages extends NLS {
private static final String BUNDLE_NAME = Messages.class.getPackage().getName() + ".messages"; //$NON-NLS-1$
public static String JanusLaunchNetworkTab_0;
public static String JanusLaunchNetworkTab_1;
public static String JanusLaunchNetworkTab_10;
public static String JanusLaunchNetworkTab_2;
public static String JanusLaunchNetworkTab_3;
public static String JanusLaunchNetworkTab_4;
Expand Down
@@ -1,11 +1,34 @@
JanusLaunchNetworkTab_0=Networking
JanusLaunchNetworkTab_1=Enable SRE communication over the computer network ({0} or {1})
JanusLaunchNetworkTab_10=Each SRE kernel is an Hazelcast node.\n\
These nodes may interact with the other nodes over a computer\n\
network when they are inside the single Hazelcast group, named\n\
cluster. The minimal number of members in a cluster is a strict\n\
constraint that indicates the Hazelcast infrastructure is waiting\n\
for the given number of cluster members before starting. A consequence\n\
of this constraint is that a SRE is blocked until the Hazelcast framework\n\
has built a cluster with the given amount of members.\n\
The default value for the minimal number of members is {1}.
JanusLaunchNetworkTab_2=Cluster name ({0}):
JanusLaunchNetworkTab_3=Minimal size of the cluster ({0}):
JanusLaunchNetworkTab_4=Auto-incrementation of the socket port numbers ({0})
JanusLaunchNetworkTab_5=This panel enables the configuration of the networking features of the Janus SARL Runtime Environment.\n\
It is based on the Hazelcast library for supporting the communication between the SRE kernels over the network.
JanusLaunchNetworkTab_6=<root context id>
JanusLaunchNetworkTab_7=Default is: {0}
JanusLaunchNetworkTab_7=Each SRE kernel is an Hazelcast node.\n\
These nodes may interact with the other nodes over a computer\n\
network when they are inside the single Hazelcast group, named\n\
cluster. In order to create different clusters in parallel, each\n\
cluster is identified by its name. You could specify explicitly\n\
the cluster''s name with this configuration parameter. If you do\n\
not specify a name, the SRE will use the default value\n\
''{0}'', where\n\
''{1}'' is the identifier of the root\n\
agent context in the SRE.\n\
Caution: even if the SRE nodes are not connected to clusters with\n\
different names, there is no warranty about the privacy of exchanged\n\
messages within a cluster. In other words, it is still technically\n\
possible to connect an Haselcast node to the cluster for obtaining the\n\
exchanged messages.
JanusLaunchNetworkTab_8=<name>
JanusLaunchNetworkTab_9=<nb>
Expand Up @@ -111,7 +111,7 @@ class SreNetworkConfig {
/**
* Default value for the minimal number of hazelcast nodes before starting.
*/
public static val DEFAULT_MIN_CLUSTER_SIZE_VALUE = 2
public static val DEFAULT_MIN_CLUSTER_SIZE_VALUE = 1

@Accessors(PUBLIC_GETTER)
var enable : boolean = DEFAULT_ENABLE_VALUE
Expand Down

0 comments on commit 73a3efb

Please sign in to comment.