Exemplo n.º 1
0
 /**
  * (non-Javadoc)
  *
  * @see
  *     com.odcgroup.page.ui.properties.table.controls.IPropertyTableItem#getTableInput(java.lang.Object)
  */
 @Override
 public List<Parameter> getTableInput(Event input) {
   List<Parameter> userParam = new ArrayList<Parameter>();
   if (input != null) {
     List<Parameter> existingParameters = new ArrayList<Parameter>();
     existingParameters.addAll(input.getParameters());
     for (Parameter parameter : input.getParameters()) {
       if (parameter.isUserDefined()) {
         userParam.add(parameter);
       }
     }
   }
   return userParam;
 }
Exemplo n.º 2
0
 private void update(Event event) {
   String eventName = event.getEventName();
   updateProperties(MetaModelRegistry.findEventPropertyTypes(eventName), event.getProperties());
   updateEventParameters(
       MetaModelRegistry.findFunctionParameterTypes(event.getFunctionName()),
       event.getParameters());
   for (Snippet snippet : event.getSnippets()) {
     update(snippet);
   }
 }
Exemplo n.º 3
0
 /**
  * Creates the event parameters.
  *
  * @param e The Event
  * @param et The EventTemplate
  */
 private void createParameters(Event e, EventTemplate et) {
   for (ParameterTemplate pt : et.getParameterTemplates()) {
     Parameter p = getModelFactory().createParameter();
     String name = pt.getType() == null ? pt.getName() : pt.getType().getName();
     p.setName(name);
     p.setValue(pt.getValue());
     p.setUserDefined(pt.isUserDefined());
     e.getParameters().add(p);
   }
 }
Exemplo n.º 4
0
  /**
   * Creates the parameters for the Event. Existing parameters are reused so that their values are
   * conserved.
   */
  private void createParameters() {
    Map<String, Parameter> existingParameters = new HashMap<String, Parameter>();
    for (Parameter p : event.getParameters()) {
      existingParameters.put(p.getName(), p);
    }

    // Clear the old parameters
    event.getParameters().clear();

    for (ParameterType pt : event.getFunctionType().getParameters()) {
      Parameter p = existingParameters.get(pt.getName());
      if (p == null) {
        // Create a new parameter
        p = ModelFactory.eINSTANCE.createParameter();
        p.setName(pt.getName());
      }
      event.getParameters().add(p);
    }
  }
Exemplo n.º 5
0
  /** Fills the parameters list. */
  private void fillParametersList() {
    paramsTbl.removeAll();

    SortedSet<Parameter> ps =
        new TreeSet<Parameter>(
            new Comparator<Parameter>() {

              public int compare(Parameter p1, Parameter p2) {
                return p1.getName().compareTo(p2.getName());
              }
            });

    ps.addAll(event.getParameters());

    for (Parameter p : ps) {
      if (!p.isUserDefined())
        new TableItem(paramsTbl, SWT.NONE).setText(new String[] {p.getName(), p.getValue()});
    }
  }
Exemplo n.º 6
0
 /**
  * Creates the events for the Widget.
  *
  * @param widget The Widget to create the events for
  * @param wt The WidgetTemplate
  */
 private void createEvents(Widget widget, WidgetTemplate wt) {
   for (EventTemplate et : wt.getEventTemplates()) {
     String eventName = et.getEventType();
     Event event = getModelFactory().createEvent();
     FunctionType ft = et.getFunctionType();
     event.setEventName(eventName);
     event.setFunctionName(ft.getName());
     event.setNature(EventNature.get(et.getNature()));
     if (!hasEvent(widget, eventName)) {
       widget.getEvents().add(event);
       createParameters(event, et); // from the template
       // add missing parameters defined in the model.
       for (ParameterType pt : et.getFunctionType().getParameters()) {
         String name = pt.getName();
         if (event.findParameter(name) == null) {
           Parameter p = getModelFactory().createParameter();
           p.setName(name);
           p.setValue(pt.getDefaultValue());
           event.getParameters().add(p);
         }
       }
     }
   }
 }