Ejemplo n.º 1
0
 public List<SModelReference> getResult() {
   List<SModelReference> result = new ArrayList<SModelReference>();
   if (myIsCancelled) return result;
   List<Object> choosen = Collections.unmodifiableList(myChooser.getChosenElements());
   for (Object item : choosen) {
     if (item instanceof BaseModelItem) {
       BaseModelItem modelItem = (BaseModelItem) item;
       result.add(modelItem.getModelReference());
     }
   }
   return result;
 }
Ejemplo n.º 2
0
  private void doInit(
      final List<SModelReference> options, @Nullable List<SModelReference> nonProjectModels) {
    setModal(true);
    myModels.addAll(options);
    if (nonProjectModels != null) {
      myNonProjectModels.addAll(nonProjectModels);
    }

    DataContext dataContext = DataManager.getInstance().getDataContext();
    final Project project = MPSDataKeys.PROJECT.getData(dataContext);

    BaseModelModel goToModelModel =
        new BaseModelModel(project) {
          public NavigationItem doGetNavigationItem(final SModelReference modelReference) {
            return new BaseModelItem(modelReference) {
              public void navigate(boolean requestFocus) {}
            };
          }

          @Override
          public SModelReference[] find(boolean checkboxState) {
            if (checkboxState) {
              return myNonProjectModels.toArray(new SModelReference[myNonProjectModels.size()]);
            } else {
              return myModels.toArray(new SModelReference[myModels.size()]);
            }
          }

          public SModelReference[] find(IScope scope) {
            throw new UnsupportedOperationException("must not be used");
          }

          @Override
          public boolean loadInitialCheckBoxState() {
            return false;
          }
        };

    myChooser =
        MpsPopupFactory.createPanelForPackage(goToModelModel, !myNonProjectModels.isEmpty());
    myChooser.invoke(
        new Callback() {
          public void elementChosen(Object element) {
            if (!myOkDone) {
              myOkDone = true;
              onOk();
            }
          }
        },
        ModalityState.current(),
        myIsMultipleSelection);
  }
Ejemplo n.º 3
0
  private void doInit(final List<SNode> options) {
    setModal(true);
    myNodes.addAll(options);

    DataContext dataContext = DataManager.getInstance().getDataContext();
    final Project project = MPSDataKeys.PROJECT.getData(dataContext);

    BaseNodeModel goToNodeModel =
        new BaseNodeModel(project) {
          public NavigationItem doGetNavigationItem(final SNode node) {
            return new BaseNodeItem(node) {
              public void navigate(boolean requestFocus) {}
            };
          }

          @Override
          public SNode[] find(boolean checkboxState) {
            return myNodes.toArray(new SNode[myNodes.size()]);
          }

          public SNode[] find(IScope scope) {
            throw new UnsupportedOperationException("must not be used");
          }

          @Override
          public boolean loadInitialCheckBoxState() {
            return false;
          }
        };

    myChooser = MpsPopupFactory.createPanelForNode(goToNodeModel, false);
    myChooser.invoke(
        new Callback() {
          public void elementChosen(Object element) {
            if (!myOkDone) {
              myOkDone = true;
              onOk();
            }
          }
        },
        ModalityState.current(),
        false);
  }
Ejemplo n.º 4
0
 protected JComponent getMainComponent() {
   return myChooser.getPanel();
 }
Ejemplo n.º 5
0
 public SNode getResult() {
   if (myIsCancelled) return null;
   BaseNodeItem nodeItem = (BaseNodeItem) myChooser.getChosenElement();
   if (nodeItem == null) return null;
   return nodeItem.getNode();
 }