private void refreshPointers(@NotNull final Module module) {
    // todo[nik] refresh only pointers related to renamed module/facet?
    List<Pair<FacetPointerImpl, String>> changed = new ArrayList<Pair<FacetPointerImpl, String>>();

    for (FacetPointerImpl pointer : myPointers.values()) {
      final String oldId = pointer.getId();
      pointer.refresh();
      if (!oldId.equals(pointer.getId())) {
        changed.add(Pair.create(pointer, oldId));
      }
    }

    for (Pair<FacetPointerImpl, String> pair : changed) {
      FacetPointerImpl pointer = pair.getFirst();
      final Facet facet = pointer.getFacet();
      Class facetClass = facet != null ? facet.getClass() : Facet.class;
      while (facetClass != Object.class) {
        final EventDispatcher<FacetPointerListener> dispatcher = myDispatchers.get(facetClass);
        if (dispatcher != null) {
          //noinspection unchecked
          dispatcher.getMulticaster().pointerIdChanged(pointer, pair.getSecond());
        }
        facetClass = facetClass.getSuperclass();
      }
    }
  }
 private static boolean shouldBeBuiltByExternalSystem(@NotNull Module module) {
   for (Facet facet : FacetManager.getInstance(module).getAllFacets()) {
     if (ArrayUtil.contains(facet.getName(), "Android", "Android-Gradle", "Java-Gradle"))
       return true;
   }
   return false;
 }
 private void addFacetNode(Facet facet) {
   MasterDetailsComponent.MyNode moduleNode =
       myStructureConfigurable.findModuleNode(facet.getModule());
   if (moduleNode == null) return;
   addFacetNode(facet, moduleNode);
   final FacetStructureConfigurable facetStructureConfigurable =
       FacetStructureConfigurable.getInstance(myStructureConfigurable.getProject());
   final MasterDetailsComponent.MyNode facetTypeNode =
       facetStructureConfigurable.getOrCreateFacetTypeNode(facet.getType());
   LOG.assertTrue(facetTypeNode != null, "Cannot found node for " + facet.getType());
   facetStructureConfigurable.addFacetNodes(facetTypeNode, Collections.singletonList(facet), this);
 }
示例#4
0
 private boolean skipFacetNotification(Facet facet) {
   if (!myModule.getProject().equals(facet.getModule().getProject())) {
     return true;
   }
   Module[] dependencies = ModuleRootManager.getInstance(myModule).getDependencies();
   Module facetModule = facet.getModule();
   for (Module dependency : dependencies) {
     if (dependency.equals(facetModule)) {
       return false;
     }
   }
   return true;
 }
 public static boolean showFacetSettingsDialog(
     @NotNull final Facet facet, @Nullable final String tabNameToSelect) {
   final Project project = facet.getModule().getProject();
   final ProjectStructureConfigurable config = ProjectStructureConfigurable.getInstance(project);
   return ShowSettingsUtil.getInstance()
       .editConfigurable(
           project,
           config,
           new Runnable() {
             @Override
             public void run() {
               final ModuleStructureConfigurable modulesConfig = config.getModulesConfig();
               config
                   .select(facet, true)
                   .doWhenDone(
                       new Runnable() {
                         @Override
                         public void run() {
                           if (tabNameToSelect != null) {
                             FacetEditorImpl facetEditor =
                                 modulesConfig.getFacetConfigurator().getOrCreateEditor(facet);
                             facetEditor.setSelectedTabName(tabNameToSelect);
                           }
                         }
                       });
             }
           });
 }
  @Nullable
  private static MasterDetailsComponent.MyNode findFacetNode(
      final Facet facet, final MasterDetailsComponent.MyNode moduleNode) {
    for (int i = 0; i < moduleNode.getChildCount(); i++) {
      final TreeNode node = moduleNode.getChildAt(i);
      if (node instanceof MasterDetailsComponent.MyNode) {
        final MasterDetailsComponent.MyNode configNode = (MasterDetailsComponent.MyNode) node;
        final NamedConfigurable config = configNode.getConfigurable();
        if (config instanceof FacetConfigurable) {
          final Facet existingFacet = ((FacetConfigurable) config).getEditableObject();
          if (existingFacet != null && existingFacet.equals(facet)) {
            return configNode;
          }
        }
      }
    }

    return null;
  }
  private MasterDetailsComponent.MyNode addFacetNode(
      final Facet facet, final MasterDetailsComponent.MyNode moduleNode) {
    final MasterDetailsComponent.MyNode existing = findFacetNode(facet, moduleNode);
    if (existing != null) return existing;

    final FacetConfigurable facetConfigurable = getOrCreateConfigurable(facet);
    final MasterDetailsComponent.MyNode facetNode =
        new MasterDetailsComponent.MyNode(facetConfigurable);
    myNodes.put(facet, facetNode);
    MasterDetailsComponent.MyNode parent = moduleNode;
    final Facet underlyingFacet = facet.getUnderlyingFacet();
    if (underlyingFacet != null) {
      parent = myNodes.get(underlyingFacet);
      LOG.assertTrue(parent != null);
    }
    myStructureConfigurable.addNode(facetNode, parent);
    return facetNode;
  }