Example #1
0
 @Override
 public void update(final ModelEvent event) {
   if (event.part == ModelPart.SELECTED_ATTRIBUTE) {
     for (final CTabItem item : folder.getItems()) {
       if (item.getText().equals(event.data)) {
         folder.setSelection(item);
         break;
       }
     }
   } else if (event.part == ModelPart.MODEL) {
     model = (Model) event.data;
   } else if (event.part == ModelPart.INPUT) {
     reset();
     folder.setRedraw(false);
     for (int i = 0; i < model.getInputConfig().getInput().getHandle().getNumColumns(); i++) {
       final String col = model.getInputConfig().getInput().getHandle().getAttributeName(i);
       final IView l = new ViewAttributeDefinition(folder, col, controller);
       l.update(new ModelEvent(this, ModelPart.MODEL, model));
       l.update(new ModelEvent(this, ModelPart.INPUT, event.data));
       names.put(i, col);
       views.add(l);
     }
     folder.setRedraw(true);
     folder.redraw();
   }
 }
Example #2
0
  @Override
  public void update(final ModelEvent event) {

    // Enable/Disable sort button
    if (event.part == ModelPart.OUTPUT
        || event.part == ModelPart.INPUT
        || event.part == ModelPart.SELECTED_VIEW_CONFIG) {

      if (model != null && model.getOutput() != null) {
        groupsButton.setEnabled(true);
        subsetButton.setEnabled(true);
      } else {
        groupsButton.setEnabled(false);
        subsetButton.setEnabled(false);
      }
    }

    // Update model
    if (event.part == ModelPart.MODEL) {
      model = (Model) event.data;
      reset();
    }

    if (event.part == ModelPart.SELECTED_VIEW_CONFIG) {
      subsetButton.setSelection(model.getViewConfig().isSubset());
    }

    if (event.part == ModelPart.SELECTED_ATTRIBUTE) {
      table.setSelectedAttribute((String) event.data);
    }
  }
Example #3
0
 /**
  * Selects the given column.
  *
  * @param index
  */
 private void actionColumnSelected(int index) {
   DataHandle handle = getHandle();
   if (handle != null && index < handle.getNumColumns()) {
     final String attr = handle.getAttributeName(index);
     model.setSelectedAttribute(attr);
     table.setSelectedAttribute(attr);
     controller.update(new ModelEvent(this, ModelPart.SELECTED_ATTRIBUTE, attr));
   }
 }
Example #4
0
 /** Handle a selection event. */
 private void selectionEvent() {
   int index = folder.getSelectionIndex();
   if (index >= 0) {
     final String name = names.get(index);
     if (model != null) {
       model.setSelectedAttribute(name);
       controller.update(new ModelEvent(this, ModelPart.SELECTED_ATTRIBUTE, name));
     }
   }
 }
Example #5
0
  @Override
  public void update(final ModelEvent event) {

    super.update(event);

    if (event.part == ModelPart.SELECTED_NODE) {
      if (model.getSelectedNode() != null) {
        toolbar.setRedraw(false);
        labelSelected.setText(
            Resources.getMessage("MainToolBar.3")
                + //$NON-NLS-1$
                Arrays.toString(model.getSelectedNode().getTransformation()));
        labelSelected.pack();
        layout();
        toolbar.setRedraw(true);
      }
    } else if (event.part == ModelPart.OUTPUT) {
      if (model.getOutputNode() != null) {

        // Update tool tip
        SearchSpaceStatistics stats = new SearchSpaceStatistics(model.getResult());
        setToolTip(stats);

        // Update labels
        toolbar.setRedraw(false);
        labelTransformations.setText(
            Resources.getMessage("MainToolBar.6")
                + //$NON-NLS-1$
                SWTUtil.getPrettyString(stats.numTransformationsInSearchSpace));
        labelTransformations.pack();

        labelApplied.setText(
            Resources.getMessage("MainToolBar.4")
                + //$NON-NLS-1$
                Arrays.toString(model.getOutputNode().getTransformation()));
        labelApplied.pack();

        layout();

        toolbar.setRedraw(true);
      } else {
        reset();
      }
    } else if (event.part == ModelPart.RESULT) {
      if (model.getResult() != null) {

        // Update tool tip
        SearchSpaceStatistics stats = new SearchSpaceStatistics(model.getResult());
        setToolTip(stats);

        // Update labels
        toolbar.setRedraw(false);
        labelTransformations.setText(
            Resources.getMessage("MainToolBar.6")
                + //$NON-NLS-1$
                SWTUtil.getPrettyString(stats.numTransformationsInSearchSpace));
        labelTransformations.pack();

        labelSelected.setText(Resources.getMessage("MainToolBar.7")); // $NON-NLS-1$
        labelSelected.pack();

        labelApplied.setText(Resources.getMessage("MainToolBar.8")); // $NON-NLS-1$
        labelApplied.pack();

        layout();

        toolbar.setRedraw(true);
      }
    } else if (event.part == ModelPart.SELECTED_ATTRIBUTE) {
      String attribute = (String) event.data;

      // Update label
      toolbar.setRedraw(false);
      labelAttribute.setText(
          Resources.getMessage("MainToolBar.50") + trim(attribute)); // $NON-NLS-1$
      labelAttribute.pack();
      layout();
      toolbar.setRedraw(true);
    } else if (event.part == ModelPart.MODEL) {
      model = (Model) event.data;
    }
  }