示例#1
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);
   }
 }
示例#2
0
  /** Create the dialog area and place correctly the user interfaces widgets */
  @Override
  protected Control createDialogArea(Composite parent) {
    Composite comp = (Composite) super.createDialogArea(parent);
    GridLayout gridLayout = new GridLayout(1, false);
    comp.setLayout(gridLayout);
    GridData gridData = new GridData(GridData.FILL_BOTH);
    comp.setLayoutData(gridData);

    Group body = new Group(comp, SWT.SHADOW_ETCHED_IN);
    gridLayout = new GridLayout(1, false);
    body.setLayout(gridLayout);
    gridData = new GridData(GridData.FILL_BOTH);
    body.setLayoutData(gridData);

    Composite eventBody = new Composite(body, SWT.FILL);
    gridLayout = new GridLayout(2, false);
    eventBody.setLayout(gridLayout);
    gridData = new GridData(GridData.FILL_BOTH);
    eventBody.setLayoutData(gridData);

    Composite eBody = new Composite(eventBody, SWT.FILL);
    gridLayout = new GridLayout(2, false);
    eBody.setLayout(gridLayout);
    gridData = new GridData(GridData.FILL_VERTICAL);
    gridData.verticalAlignment = SWT.TOP;
    eBody.setLayoutData(gridData);

    // Events
    Label eventLbl = new Label(eBody, SWT.LEFT);
    eventLbl.setText("Event:");

    eventCbx = new Combo(eBody, SWT.NONE);
    fillEventTypesList();

    // Create a new Event
    if (event == null) {
      event = createEvent(eventCbx.getItem(0));
    } else {
      // We need to copy the original event in case the user cancels his changes
      event = WidgetCopier.copy(event);
    }
    eventCbx.setText(event.getEventName());

    eventCbx.addSelectionListener(
        new SelectionAdapter() {

          public void widgetSelected(SelectionEvent e) {
            String eventName = ((Combo) e.getSource()).getText();
            event.setEventName(eventName);
            createProperties();
            // DS-3322 - Page Designer - Refactoring - begin
            //                event.eAdapters().remove(localizable);
            //                localizable = (Localizable)
            // EventLocalizableAdapterFactory.INSTANCE.adapt(event, Localizable.class);
            //                editor.setLocalizable(localizable);
            //                editor.setReadOnly(isReadOnly(widget));
            // DS-3322 - Page Designer - Refactoring - end
            fillFunctionsList();
            String selection = null;
            if (fctList.getSelection().length > 0) selection = fctList.getSelection()[0];
            refreshParamControl(selection);
          }
        });

    // Functions
    Label functionsLbl = new Label(eBody, SWT.LEFT);
    functionsLbl.setText("Functions:");
    gridData = new GridData();
    gridData.verticalAlignment = GridData.VERTICAL_ALIGN_BEGINNING;
    functionsLbl.setLayoutData(gridData);

    fctList = new List(eBody, SWT.BORDER | SWT.SINGLE | SWT.V_SCROLL);
    gridData = new GridData(GridData.FILL_VERTICAL);
    gridData.heightHint = 120;
    gridData.widthHint = 120;
    fctList.setLayoutData(gridData);

    fillFunctionsList();

    fctList.addSelectionListener(
        new SelectionAdapter() {

          public void widgetSelected(SelectionEvent e) {
            String funcName = fctList.getSelection()[0];
            event.setFunctionName(funcName);
            createParameters();
            fillParametersList();
            refreshParamControl(funcName);
          }
        });

    // parameters group
    Group paramGroup = new Group(eventBody, SWT.SHADOW_ETCHED_IN | SWT.FILL);
    paramGroup.setText(" Parameters ");
    gridLayout = new GridLayout(1, false);
    paramGroup.setLayout(gridLayout);
    gridData = new GridData(GridData.FILL_BOTH);
    paramGroup.setLayoutData(gridData);
    userParamControl = new UserParameterControl(paramGroup, SWT.FILL);
    userParamControl.setInput(event, null);
    userParamControl.setEnabled(false);

    if (!StringUtils.isEmpty(event.getFunctionName())) {
      fctList.setSelection(new String[] {event.getFunctionName()});
      refreshParamControl(event.getFunctionName());
    }

    // attributes group
    Group def = new Group(body, SWT.SHADOW_ETCHED_IN);
    def.setText(" Attributes ");
    gridLayout = new GridLayout(1, false);
    def.setLayout(gridLayout);
    gridData = new GridData(GridData.FILL_BOTH);
    def.setLayoutData(gridData);

    // Parameters table
    paramsTbl = new Table(def, SWT.SINGLE);
    gridData = new GridData(GridData.FILL_BOTH);
    gridData.heightHint = 100;
    paramsTbl.setLayoutData(gridData);
    paramsTbl.setHeaderVisible(true);
    paramsTbl.setLinesVisible(true);
    addColumn(paramsTbl, "Attribute", 100);
    addColumn(paramsTbl, "Value", 300);
    paramsTbl.addListener(
        SWT.MeasureItem,
        new Listener() {

          public void handleEvent(org.eclipse.swt.widgets.Event event) {
            Double dou = new Double(event.gc.getFontMetrics().getHeight() * 1.12);
            event.height = dou.intValue();
          }
        });
    final TableEditor paramsTblEditor = new TableEditor(paramsTbl);
    // The editor must have the same size as the cell and must not be any
    // smaller than 50 pixels.
    paramsTblEditor.horizontalAlignment = SWT.LEFT;
    paramsTblEditor.grabHorizontal = true;
    paramsTblEditor.grabVertical = true;
    paramsTblEditor.minimumWidth = 50;
    paramsTbl.addListener(
        SWT.MouseDown,
        new Listener() {

          public void handleEvent(org.eclipse.swt.widgets.Event event) {
            int nbColumns = paramsTbl.getColumnCount();
            Rectangle clientArea = paramsTbl.getClientArea();
            Point pt = new Point(event.x, event.y);
            int index = paramsTbl.getTopIndex();
            while (index < paramsTbl.getItemCount()) {
              boolean visible = false;
              TableItem item = paramsTbl.getItem(index);
              for (int cx = 0; cx < nbColumns; cx++) {
                Rectangle rect = item.getBounds(cx);
                if (rect.contains(pt)) {
                  installCellEditor(paramsTblEditor, item, index, cx);
                }
                if (!visible && rect.intersects(clientArea)) {
                  visible = true;
                }
              }
              if (!visible) return;
              index++;
            }
          }
        });

    fillParametersList();

    def = new Group(body, SWT.SHADOW_ETCHED_IN);
    def.setText(" Confirmation Translations ");
    gridLayout = new GridLayout(1, false);
    def.setLayout(gridLayout);
    gridData = new GridData(GridData.FILL_BOTH);
    def.setLayoutData(gridData);

    createProperties();

    // DS-3322 - Page Designer - Refactoring - begin
    //        editor = LocalizableEditorSupportFactory.createLocalizableEditor(def, 2, false, true);
    //        localizable = (Localizable) EventLocalizableAdapterFactory.INSTANCE.adapt(event,
    // Localizable.class);
    //        editor.setLocalizable(localizable);
    //        editor.setReadOnly(isReadOnly(widget));
    //        addListeners();
    // DS-3322 - Page Designer - Refactoring - end

    return comp;
  }