コード例 #1
0
ファイル: CreateRootNodeGroup.java プロジェクト: sprig/MPS
 @Override
 protected boolean collectActionData(AnActionEvent e, Map<String, Object> _params) {
   if (!super.collectActionData(e, _params)) return false;
   myProject = MPSDataKeys.PROJECT.getData(e.getDataContext());
   myScope = MPSDataKeys.SCOPE.getData(e.getDataContext());
   if (myScope == null) return false;
   myContext = MPSDataKeys.OPERATION_CONTEXT.getData(e.getDataContext());
   if (myContext == null) return false;
   return true;
 }
コード例 #2
0
  @Nullable
  public Object getData(DataProvider dataProvider) {
    IOperationContext context =
        (IOperationContext) dataProvider.getData(MPSDataKeys.OPERATION_CONTEXT.getName());
    if (context == null) return null;
    IScope scope = context.getScope();
    if (scope != null) return scope;

    MPSProject project = (MPSProject) dataProvider.getData(MPSDataKeys.MPS_PROJECT.getName());
    if (project != null) return project.getProject().getComponent(ProjectScope.class);
    return GlobalScope.getInstance();
  }
コード例 #3
0
  public Object getData(String dataId) {
    // MPSDK
    if (dataId.equals(MPSDataKeys.NODE.getName())) return getSelectedSNode();
    if (dataId.equals(MPSDataKeys.NODES.getName())) return getSelectedSNodes();

    if (dataId.equals(MPSDataKeys.MODEL.getName())) return getSelectedModel();
    if (dataId.equals(MPSDataKeys.CONTEXT_MODEL.getName())) return getContextModel();
    if (dataId.equals(MPSDataKeys.MODELS.getName())) return getSelectedModels();

    if (dataId.equals(MPSDataKeys.MODULE.getName())) return getSelectedModule();
    if (dataId.equals(MPSDataKeys.CONTEXT_MODULE.getName())) return getContextModule();
    if (dataId.equals(MPSDataKeys.MODULES.getName())) return getSelectedModules();

    if (dataId.equals(MPSDataKeys.VIRTUAL_PACKAGE.getName())) {
      List<String> selectedPackages = getSelectedPackages();
      if (selectedPackages.size() != 1) return null;
      return selectedPackages.get(0);
    }
    if (dataId.equals(MPSDataKeys.VIRTUAL_PACKAGES.getName())) return getSelectedPackages();

    if (dataId.equals(MPSDataKeys.NAMESPACE.getName())) {
      NamespaceTextNode selectedNamespaceNode = getSelectedTreeNode(NamespaceTextNode.class);
      if (selectedNamespaceNode != null) {
        return selectedNamespaceNode.getNamespace();
      }
      return null;
    }

    if (dataId.equals(MPSDataKeys.OPERATION_CONTEXT.getName())) return getContextForSelection();
    if (dataId.equals(MPSDataKeys.LOGICAL_VIEW_NODE.getName()))
      return getSelectedTreeNode(TreeNode.class);
    if (dataId.equals(MPSDataKeys.LOGICAL_VIEW_NODES.getName()))
      return getSelectedTreeNodes(TreeNode.class);
    if (dataId.equals(MPSDataKeys.LOGICAL_VIEW_SELECTION_SIZE.getName())) return getSelectionSize();
    if (dataId.equals(MPSDataKeys.PLACE.getName())) return getPlace();

    // PDK
    if (dataId.equals(PlatformDataKeys.COPY_PROVIDER.getName())) return new MyCopyProvider();
    if (dataId.equals(PlatformDataKeys.PASTE_PROVIDER.getName())) return new MyPasteProvider();
    if (dataId.equals(PlatformDataKeys.CUT_PROVIDER.getName())) return new MyCutProvider();
    if (dataId.equals(PlatformDataKeys.VIRTUAL_FILE_ARRAY.getName())) return getSelectedFiles();

    // not found
    return null;
  }