예제 #1
0
 public NodeFileStatusMapping(
     MPSProject project,
     CurrentDifferenceRegistry registry,
     NodeVirtualFileSystem nodeFileSystem) {
   super(project.getProject());
   myRegistry = registry;
   myMPSProject = project;
   myNodeFileSystem = nodeFileSystem;
 }
 public void doInit(MPSProject project) {
   TransientModels_CustomProjectPlugin.this.myNotifier =
       new TransientModelsNotification(project.getProject());
   ThreadUtils.runInUIThreadNoWait(
       new Runnable() {
         public void run() {
           TransientModels_CustomProjectPlugin.this.myNotifier.projectOpened();
         }
       });
 }
 public void doInit(MPSProject project) {
   ExtensionPoint<BeforeRunTaskProvider<BeforeRunTask>> beforeTasksExtensionPoint =
       Extensions.getArea(project.getProject())
           .getExtensionPoint(BeforeRunTaskProvider.EXTENSION_POINT_NAME);
   {
     BeforeRunTaskProvider beforeTask = (BeforeRunTaskProvider) new GenerateBuild_BeforeTask();
     ListSequence.fromList(BeforeTasksInitializer_CustomProjectPlugin.this.myRegisteredBeforeTasks)
         .addElement(beforeTask);
     beforeTasksExtensionPoint.registerExtension(beforeTask);
   }
 }
 public void doDispose(MPSProject project) {
   ExtensionPoint<BeforeRunTaskProvider<BeforeRunTask>> beforeTasksExtensionPoint =
       Extensions.getArea(project.getProject())
           .getExtensionPoint(BeforeRunTaskProvider.EXTENSION_POINT_NAME);
   for (BeforeRunTaskProvider beforeTask :
       ListSequence.fromList(
           BeforeTasksInitializer_CustomProjectPlugin.this.myRegisteredBeforeTasks)) {
     beforeTasksExtensionPoint.unregisterExtension(beforeTask);
   }
   ListSequence.fromList(BeforeTasksInitializer_CustomProjectPlugin.this.myRegisteredBeforeTasks)
       .clear();
 }
예제 #5
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();
  }
예제 #6
0
  public void apply(final MPSProject project, final List<SNode> nodesToMove) {

    final Wrappers._T<SModel> currentModel = new Wrappers._T<SModel>();
    project
        .getRepository()
        .getModelAccess()
        .runReadAction(
            new Runnable() {
              public void run() {
                currentModel.value =
                    SNodeOperations.getModel(ListSequence.fromList(nodesToMove).first());
              }
            });
    final NodeLocation newLocation =
        MoveNodesDialog.getSelectedObject(
            project.getProject(),
            currentModel.value,
            new MoveNodesDialog.ModelFilter("Choose Node or Model") {
              @Override
              public boolean check(NodeLocation selectedObject, SModel model) {
                return true;
              }
            });
    if (newLocation == null) {
      return;
    }

    project
        .getRepository()
        .getModelAccess()
        .runReadAction(
            new Runnable() {
              public void run() {
                for (SNode node : ListSequence.fromList(nodesToMove)) {
                  if (!(SNodeUtil.isAccessible(node, project.getRepository()))) {
                    return;
                  }
                }
                if (!(newLocation.isValid(project, nodesToMove))) {
                  return;
                }

                final Set<SReference> refUsages = findUsages(project, nodesToMove);
                SearchResults<SNode> searchResults =
                    nodesToRefactoringResult(
                        nodesToMove,
                        SetSequence.fromSet(refUsages)
                            .select(
                                new ISelector<SReference, SNode>() {
                                  public SNode select(SReference it) {
                                    return it.getSourceNode();
                                  }
                                }),
                        "reference");
                RefactoringViewUtil.refactor(
                    project,
                    searchResults,
                    new _FunctionTypes._void_P1_E0<Set<SNode>>() {
                      public void invoke(final Set<SNode> included) {
                        Map<SReference, SNode> usagesMap =
                            classifyUsages(
                                SetSequence.fromSet(refUsages)
                                    .where(
                                        new IWhereFilter<SReference>() {
                                          public boolean accept(SReference it) {
                                            return SetSequence.fromSet(included)
                                                .contains(it.getSourceNode());
                                          }
                                        }));
                        newLocation.insertNodes(nodesToMove);
                        for (IMapping<SReference, SNode> mapping : MapSequence.fromMap(usagesMap)) {
                          updateUsage(mapping.key(), mapping.value());
                        }
                      }
                    },
                    "Move nodes");
              }
            });
  }