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); }
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); }