GComponentList : Différence entre versions

De Wiki
Aller à : navigation, rechercher
(Page créée avec « TBW ... Return to the introduction ↑ Go to the next page → »)
 
Ligne 1 : Ligne 1 :
TBW ...
+
[{{PathCurrentJavaDoc}}/fr/cnes/genius/highLevel/GComponentList.html GComponentList] allows to display list of widgets :
 +
* These widgets must have a constructor without arguments
 +
* There is the possibility to duplicate an element only if the <font color=#FF8C00>Cloneable</font> interface (and a <font color=#FF8C00>clone()</font> method) is implemented.
 +
 
 +
Two modes are also available:
 +
* a « single » mode, displaying only one widget each time (case of complex widgets)
 +
* a « multiple » mode displaying all the widgets placed behind each other
 +
 
 +
The [{{PathCurrentJavaDoc}}/fr/cnes/genius/highLevel/GComponentList.html GComponentList] may be instantiated by giving the kind of class to display or an object that will serve to initialized new ones.
 +
 
 +
<syntaxhighlight lang="java">
 +
  GComponentList test;
 +
  test = new GComponentList(name, className.class, mode[true/false]); // First way to instantiate
 +
  test = new GComponentList(name, defaultObj, mode[true/false]); // Second way to instantiate
 +
</syntaxhighlight>
 +
 
 +
The list may also be initialized by a predefined list:
 +
 
 +
<syntaxhighlight lang="java">
 +
  ArrayList<GComponent> list = new ArrayList<GComponent>();
 +
  list.add(new XXX(...));
 +
  list.add(new XXX(...));
 +
 
 +
  GComponentList test = null;
 +
  test.setList (list);
 +
</syntaxhighlight>
 +
 
 +
== Example ==
 +
 
 +
First, let us create a class, corresponding to a widget including several basic other widgets (here a [{{PathCurrentJavaDoc}}/fr/cnes/genius/highLevel/GEntryString.html GEntryString], a [{{PathCurrentJavaDoc}}/fr/cnes/genius/highLevel/GEntryInt.html GEntryInt] and a [{{PathCurrentJavaDoc}}/fr/cnes/genius/highLevel/GEntryReal.html GEntryReal]):
 +
 
 +
<syntaxhighlight lang="java">
 +
public class TestForGComponentListWidget extends GPanel implements GReadWrite {
 +
 +
  GEntryString widget1;
 +
  GEntryInt widget2;
 +
  GEntryReal widget3;
 +
 +
  public TestForGComponentListWidget () {
 +
 +
    widget1 = new GEntryString("Text", "try");
 +
    widget2 = new GEntryInt("Integer", 0);
 +
    widget3 = new GEntryReal("Double", 0.);
 +
 
 +
  }
 +
 +
  public void generic() throws GException {
 +
    beginOfElement("widForGC", "test");
 +
      put(widget1);
 +
      put(widget2);
 +
      put(widget3);
 +
    endOfElement();
 +
  }
 +
 
 +
  public void read() throws GException { generic(); }
 +
  public void write() throws GException { generic(); }
 +
  public void display() throws GException { generic(); }
 +
 
 +
}
 +
</syntaxhighlight>
 +
 
 +
Note that it is recommended to encapsulate data with <font color=#4169E1>beginOfElement()</font> and <font color=#4169E1>endOfElement()</font> (see [[GReadWrite_interface#Data file management|Data file management]] section) not to have conflicts when reading or writing between to data with the same name.
 +
 
 +
At last, we will have just to create a [{{PathCurrentJavaDoc}}/fr/cnes/genius/highLevel/GComponentList.html GComponentList] for this kind of ''TestForGComponentListWidget''
 +
 
 +
<syntaxhighlight lang="java">
 +
  GComponentList test = new GComponentList("TestGC", TestForGComponentListWidget.class, [true/false]);
 +
</syntaxhighlight>
 +
 
 +
{[[File:GComponentList1.jpg|330 px "single" mode]]
 +
[[File:GComponentList2.jpg|330 px "multiple" mode]]
 +
 
 +
It is also possible to custom some labels ("''Amount of Items''", "''Item number''" and "''Item n''") by using the <font color=#4169E1>setLabels()</font> method.
 +
 
 +
At last, it is also possible to use the <font color=#4169E1>setEditable()</font> method if we just want to disply the list without modifying it.
 +
 
  
 
[[WELCOME_TO_THE_GENIUS_WIKI|Return to the introduction ↑]]  
 
[[WELCOME_TO_THE_GENIUS_WIKI|Return to the introduction ↑]]  
 
[[GDialog_and_GDetachedPanel|Go to the next page →]]
 
[[GDialog_and_GDetachedPanel|Go to the next page →]]

Version du 5 mai 2017 à 13:50

GComponentList allows to display list of widgets :

  • These widgets must have a constructor without arguments
  • There is the possibility to duplicate an element only if the Cloneable interface (and a clone() method) is implemented.

Two modes are also available:

  • a « single » mode, displaying only one widget each time (case of complex widgets)
  • a « multiple » mode displaying all the widgets placed behind each other

The GComponentList may be instantiated by giving the kind of class to display or an object that will serve to initialized new ones.

  GComponentList test;
  test = new GComponentList(name, className.class, mode[true/false]); // First way to instantiate
  test = new GComponentList(name, defaultObj, mode[true/false]); // Second way to instantiate

The list may also be initialized by a predefined list:

  ArrayList<GComponent> list = new ArrayList<GComponent>();
  list.add(new XXX(...));
  list.add(new XXX(...));
 
  GComponentList test = null;
  test.setList (list);

Example

First, let us create a class, corresponding to a widget including several basic other widgets (here a GEntryString, a GEntryInt and a GEntryReal):

public class TestForGComponentListWidget extends GPanel implements GReadWrite {
 
  GEntryString widget1;
  GEntryInt widget2;
  GEntryReal widget3;
 
  public TestForGComponentListWidget () {
 
    widget1 = new GEntryString("Text", "try");
    widget2 = new GEntryInt("Integer", 0);
    widget3 = new GEntryReal("Double", 0.);
 
  }
 
  public void generic() throws GException {
    beginOfElement("widForGC", "test");
      put(widget1);
      put(widget2);
      put(widget3);
    endOfElement();
  }
 
  public void read() throws GException { generic(); }
  public void write() throws GException { generic(); }
  public void display() throws GException { generic(); }
 
}

Note that it is recommended to encapsulate data with beginOfElement() and endOfElement() (see Data file management section) not to have conflicts when reading or writing between to data with the same name.

At last, we will have just to create a GComponentList for this kind of TestForGComponentListWidget

  GComponentList test = new GComponentList("TestGC", TestForGComponentListWidget.class, [true/false]);

{330 px "single" mode 330 px "multiple" mode

It is also possible to custom some labels ("Amount of Items", "Item number" and "Item n") by using the setLabels() method.

At last, it is also possible to use the setEditable() method if we just want to disply the list without modifying it.


Return to the introduction ↑ Go to the next page →