/** Populate tree. */
 protected void populateTree() {
   if (getTreeViewer() == null
       || getTreeViewer().getTree() == null
       || getViewInfo() == null
       || getDiagram() == null) {
     return;
   }
   Diagram diagram = getDiagram();
   Collection<Integer> filters = MDTUtil.getAllViewsToFilterFromDiagram(diagram);
   for (TreeItem item : getTreeViewer().getTree().getItems()) {
     Object data = item.getData();
     if (data instanceof ViewInfo) {
       ViewInfo info = (ViewInfo) data;
       if (filters.contains(info.getVisualID())) {
         item.setChecked(false);
       } else {
         item.setChecked(true);
       }
       if (((ViewInfo) data).isSelectable() == false) {
         item.setForeground(ColorConstants.gray);
       }
     }
     setChecked(item, filters);
   }
 }
 /**
  * Sets the checked.
  *
  * @param root the root
  * @param filters the filters
  */
 protected void setChecked(TreeItem root, Collection<Integer> filters) {
   for (TreeItem item : root.getItems()) {
     Object data = item.getData();
     if (data instanceof ViewInfo) {
       ViewInfo info = (ViewInfo) data;
       if (filters.contains(info.getVisualID())) {
         item.setChecked(false);
       } else {
         item.setChecked(true);
       }
     }
     setChecked(item, filters);
   }
 }
 /**
  * When one element from the tree is selected, all elements with the same VisualID are put into
  * the same state (checked or unchecked).
  *
  * @param items
  * @param visualID
  * @param check
  */
 protected void setAllVisualIDsChecked(TreeItem[] items, int visualID, boolean check) {
   ViewInfo viewInfo = null;
   for (TreeItem item : items) {
     if (item != null) {
       viewInfo =
           (ViewInfo) Platform.getAdapterManager().getAdapter(item.getData(), ViewInfo.class);
       if (viewInfo != null && visualID == viewInfo.getVisualID()) {
         item.setChecked(check);
       }
       if (item.getItems() != null) {
         setAllVisualIDsChecked(item.getItems(), visualID, check);
       }
     }
   }
 }
 protected void treeItemSelected(SelectionEvent e) {
   if (e.detail == SWT.CHECK && isChecking == false) {
     isChecking = true;
     try {
       Object data = e.item.getData();
       ViewInfo viewInfo =
           (ViewInfo) Platform.getAdapterManager().getAdapter(data, ViewInfo.class);
       TreeItem item = (TreeItem) Platform.getAdapterManager().getAdapter(e.item, TreeItem.class);
       if (viewInfo != null && item != null && getTreeViewer().getTree().getItems() != null) {
         if (viewInfo.isSelectable()) {
           setAllVisualIDsChecked(
               getTreeViewer().getTree().getItems(), viewInfo.getVisualID(), item.getChecked());
         } else {
           item.setChecked(!item.getChecked());
         }
       }
     } finally {
       isChecking = false;
     }
   }
 }
예제 #5
0
  /** @generated */
  protected static ViewInfo getPackage_1000ViewInfo() {
    ViewInfo root = new BaseViewInfo(1000, ViewInfo.Head, "", null, null);
    ViewInfo viewInfo = null;
    ViewInfo labelInfo = null;

    viewInfo = new BaseViewInfo(8002, ViewInfo.Node, "Interaction");
    root.addNode(1000, viewInfo);

    viewInfo = new BaseViewInfo(8016, ViewInfo.Node, "Diagram");
    root.addNode(1000, viewInfo);

    viewInfo = new BaseViewInfo(8009, ViewInfo.Edge, "");
    root.addNode(1000, viewInfo);

    labelInfo = new BaseViewInfo(6001, ViewInfo.Label, "", null, viewInfo);
    viewInfo.getChildren().add(labelInfo);

    labelInfo = new BaseViewInfo(6012, ViewInfo.Label, "", null, viewInfo);
    viewInfo.getChildren().add(labelInfo);

    viewInfo = new BaseViewInfo(8010, ViewInfo.Edge, "");
    root.addNode(1000, viewInfo);

    viewInfo = new BaseViewInfo(8011, ViewInfo.Edge, "");
    root.addNode(1000, viewInfo);

    viewInfo = new BaseViewInfo(8012, ViewInfo.Edge, "");
    root.addNode(1000, viewInfo);

    viewInfo = new BaseViewInfo(8013, ViewInfo.Edge, "");
    root.addNode(1000, viewInfo);

    viewInfo = new BaseViewInfo(8001, ViewInfo.Node, "Lifeline");

    root.addNode(7001, viewInfo);

    viewInfo = new BaseViewInfo(8004, ViewInfo.Node, "Constraint");

    root.addNode(7001, viewInfo);

    viewInfo = new BaseViewInfo(8005, ViewInfo.Node, "Comment");

    root.addNode(7001, viewInfo);

    viewInfo = new BaseViewInfo(8006, ViewInfo.Node, "TimeObservation");

    root.addNode(7001, viewInfo);

    viewInfo = new BaseViewInfo(8007, ViewInfo.Node, "DurationObservation");

    root.addNode(7001, viewInfo);

    return root;
  }