com.intellij.openapi.roots.ui.configuration.ProjectStructureConfigurable Java Examples

The following examples show how to use com.intellij.openapi.roots.ui.configuration.ProjectStructureConfigurable. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: OrderEntryAppearanceServiceImpl.java    From consulo with Apache License 2.0 6 votes vote down vote up
@Nonnull
@Override
public CellAppearanceEx forLibrary(Project project, @Nonnull final Library library, final boolean hasInvalidRoots) {
  final StructureConfigurableContext context = ProjectStructureConfigurable.getInstance(project).getContext();
  final Image icon = LibraryPresentationManager.getInstance().getCustomIcon(library, context);

  final String name = library.getName();
  if (name != null) {
    return normalOrRedWaved(name, (icon != null ? icon :  AllIcons.Nodes.PpLib), hasInvalidRoots);
  }

  final String[] files = library.getUrls(BinariesOrderRootType.getInstance());
  if (files.length == 0) {
    return SimpleTextCellAppearance.invalid(ProjectBundle.message("library.empty.library.item"),  AllIcons.Nodes.PpLib);
  }
  else if (files.length == 1) {
    return forVirtualFilePointer(new LightFilePointer(files[0]));
  }

  final String url = StringUtil.trimEnd(files[0], URLUtil.ARCHIVE_SEPARATOR);
  return SimpleTextCellAppearance.regular(PathUtil.getFileName(url),  AllIcons.Nodes.PpLib);
}
 
Example #2
Source File: SdkComboBox.java    From consulo with Apache License 2.0 6 votes vote down vote up
public void reloadModel(SdkComboBoxItem firstItem, @Nullable Project project) {
  final DefaultComboBoxModel model = ((DefaultComboBoxModel)getModel());
  if (project == null) {
    model.addElement(firstItem);
    return;
  }
  model.removeAllElements();
  model.addElement(firstItem);
  final DefaultSdksModel projectSdksModel = ProjectStructureConfigurable.getInstance(project).getProjectSdksModel();
  List<Sdk> sdks = new ArrayList<Sdk>(projectSdksModel.getProjectSdks().values());
  if (myFilter != null) {
    sdks = ContainerUtil.filter(sdks, getSdkFilter(myFilter));
  }
  Collections.sort(sdks, new Comparator<Sdk>() {
    @Override
    public int compare(final Sdk o1, final Sdk o2) {
      return o1.getName().compareToIgnoreCase(o2.getName());
    }
  });
  for (Sdk sdk : sdks) {
    model.addElement(new SdkComboBoxItem(sdk));
  }
}
 
Example #3
Source File: ModuleStructureConfigurable.java    From consulo with Apache License 2.0 6 votes vote down vote up
public AsyncResult<Void> selectOrderEntry(@Nonnull final Module module, @Nullable final OrderEntry orderEntry) {
  Place p = new Place();
  p.putPath(ProjectStructureConfigurable.CATEGORY, this);
  Runnable r = null;

  final MasterDetailsComponent.MyNode node = findModuleNode(module);
  if (node != null) {
    p.putPath(TREE_OBJECT, module);
    p.putPath(ModuleEditor.SELECTED_EDITOR_NAME, ClasspathEditor.NAME);
    r = new Runnable() {
      @Override
      public void run() {
        if (orderEntry != null) {
          ModuleEditor moduleEditor = ((ModuleConfigurable)node.getConfigurable()).getModuleEditor();
          ModuleConfigurationEditor editor = moduleEditor.getEditor(ClasspathEditor.NAME);
          if (editor instanceof ClasspathEditor) {
            ((ClasspathEditor)editor).selectOrderEntry(orderEntry);
          }
        }
      }
    };
  }
  final AsyncResult<Void> result = ProjectStructureConfigurable.getInstance(myProject).navigateTo(p, true);
  return r != null ? result.doWhenDone(r) : result;
}
 
Example #4
Source File: DesktopProjectStructureDialog.java    From consulo with Apache License 2.0 6 votes vote down vote up
public DesktopProjectStructureDialog(@Nonnull Project project, Configurable configurable, @NonNls String dimensionKey, ProjectStructureConfigurable structureConfigurable) {
  super(project, configurable, dimensionKey, true, IdeModalityType.PROJECT, true);
  myStructureConfigurable = structureConfigurable;

  boolean isDefaultProject = project.isDefault();

  if (!isDefaultProject) {
    addConfigurable(structureConfigurable.getProjectConfigurable());
    addConfigurable(structureConfigurable.getModulesConfigurable());
  }
  addConfigurable(structureConfigurable.getProjectLibrariesConfigurable());

  if (!isDefaultProject) {
    addConfigurable(structureConfigurable.getArtifactsStructureConfigurable());
  }

  addConfigurable(structureConfigurable.getSdkConfigurable());

  structureConfigurable.setConfigurablesForDispose(myName2Config);

  structureConfigurable.setProjectStructureDialog(this::select);

  init();

  getConfigurable().reset();
}
 
Example #5
Source File: ClasspathPanelImpl.java    From consulo with Apache License 2.0 6 votes vote down vote up
@Override
public void navigate(boolean openLibraryEditor) {
  final OrderEntry entry = getSelectedEntry();
  final ProjectStructureConfigurable rootConfigurable = ProjectStructureConfigurable.getInstance(myState.getProject());
  if (entry instanceof ModuleOrderEntry) {
    Module module = ((ModuleOrderEntry)entry).getModule();
    if (module != null) {
      rootConfigurable.select(module.getName(), null, true);
    }
  }
  else if (entry instanceof LibraryOrderEntry) {
    if (!openLibraryEditor) {
      rootConfigurable.select((LibraryOrderEntry)entry, true);
    }
    else {
      myEditButton.actionPerformed(ActionUtil.createEmptyEvent());
    }
  }
  else if (entry instanceof ModuleExtensionWithSdkOrderEntry) {
    Sdk jdk = ((ModuleExtensionWithSdkOrderEntry)entry).getSdk();
    if (jdk != null) {
      rootConfigurable.select(jdk, true);
    }
  }
}
 
Example #6
Source File: ArtifactEditorContextImpl.java    From consulo with Apache License 2.0 6 votes vote down vote up
@Override
public void selectLibrary(@Nonnull Library library) {
  final LibraryTable table = library.getTable();
  if (table != null) {
    ProjectStructureConfigurable.getInstance(getProject()).selectProjectOrGlobalLibrary(library, true);
  }
  else {
    final Module module = ((LibraryImpl)library).getModule();
    if (module != null) {
      final ModuleRootModel rootModel = myParent.getModulesProvider().getRootModel(module);
      final String libraryName = library.getName();
      for (OrderEntry entry : rootModel.getOrderEntries()) {
        if (entry instanceof ModuleLibraryOrderEntryImpl) {
          final ModuleLibraryOrderEntryImpl libraryEntry = (ModuleLibraryOrderEntryImpl)entry;
          if (libraryName != null && libraryName.equals(libraryEntry.getLibraryName())
             || libraryName == null && library.equals(libraryEntry.getLibrary())) {
            ProjectStructureConfigurable.getInstance(getProject()).selectOrderEntry(module, libraryEntry);
            return;
          }
        }
      }
    }
  }
}
 
Example #7
Source File: LibraryProjectStructureElement.java    From consulo with Apache License 2.0 6 votes vote down vote up
@Override
public void performFix() {
  final LibraryTable.ModifiableModel libraryTable = myContext.getModifiableLibraryTable(myLibrary.getTable());
  if (libraryTable instanceof LibrariesModifiableModel) {
    for (String invalidRoot : myInvalidUrls) {
      final ExistingLibraryEditor libraryEditor = ((LibrariesModifiableModel)libraryTable).getLibraryEditor(myLibrary);
      libraryEditor.removeRoot(invalidRoot, myType);
    }
    myContext.getDaemonAnalyzer().queueUpdate(LibraryProjectStructureElement.this);
    final ProjectStructureConfigurable structureConfigurable = ProjectStructureConfigurable.getInstance(myContext.getProject());
    navigate().doWhenDone(new Runnable() {
      @Override
      public void run() {
        final NamedConfigurable configurable = structureConfigurable.getConfigurableFor(myLibrary).getSelectedConfigurable();
        if (configurable instanceof LibraryConfigurable) {
          ((LibraryConfigurable)configurable).updateComponent();
        }
      }
    });
  }
}
 
Example #8
Source File: DesktopShowSettingsUtilImpl.java    From consulo with Apache License 2.0 5 votes vote down vote up
@RequiredUIAccess
@Override
public void showProjectStructureDialog(@Nonnull Project project, @Nonnull Consumer<ProjectStructureSelector> consumer) {
  new Task.Backgroundable(project, "Opening Project Structure...") {
    private ProjectStructureConfigurable myConfigurable;

    @Override
    public void run(@Nonnull ProgressIndicator indicator) {
      myConfigurable = ProjectStructureConfigurable.getInstance(project);
    }

    @RequiredUIAccess
    @Override
    public void onFinished() {
      UIAccess uiAccess = UIAccess.current();
      uiAccess.give(() -> {
        DesktopProjectStructureDialog dialog = new DesktopProjectStructureDialog(project, myConfigurable, ShowSettingsUtil.DIMENSION_KEY, myConfigurable);
        new UiNotifyConnector.Once(dialog.getContentPane(), new Activatable() {
          @Override
          public void showNotify() {
            consumer.accept(myConfigurable);
          }
        });
        dialog.showAsync();
      });
    }
  }.queue();
}
 
Example #9
Source File: PlaceInArtifact.java    From consulo with Apache License 2.0 5 votes vote down vote up
@Nonnull
@Override
public AsyncResult<Void> navigate() {
  final Artifact artifact = myContext.getArtifactModel().getArtifactByOriginal(myArtifact);
  return ProjectStructureConfigurable.getInstance(myContext.getProject()).select(myArtifact, true).doWhenDone(new Runnable() {
    @Override
    public void run() {
      final ArtifactEditorEx artifactEditor = (ArtifactEditorEx)myContext.getOrCreateEditor(artifact);
      if (myParentPath != null && myPackagingElement != null) {
        artifactEditor.getLayoutTreeComponent().selectNode(myParentPath, myPackagingElement);
      }
    }
  });
}
 
Example #10
Source File: CreateNewLibraryAction.java    From consulo with Apache License 2.0 5 votes vote down vote up
@Override
public void actionPerformed(AnActionEvent e) {
  Library library =
    createLibrary(myType, myLibrariesConfigurable.getTree(), myProject, myLibrariesConfigurable.getModelProvider().getModifiableModel());
  if (library == null) return;

  final BaseLibrariesConfigurable rootConfigurable = ProjectStructureConfigurable.getInstance(myProject).getConfigurableFor(library);
  final DefaultMutableTreeNode libraryNode =
    MasterDetailsComponent.findNodeByObject((TreeNode)rootConfigurable.getTree().getModel().getRoot(), library);
  rootConfigurable.selectNodeInTree(libraryNode);
  LibraryEditingUtil.showDialogAndAddLibraryToDependencies(library, myProject, true);
}
 
Example #11
Source File: LibrariesModifiableModel.java    From consulo with Apache License 2.0 5 votes vote down vote up
@Override
public Library createLibrary(String name, @Nullable PersistentLibraryKind type) {
  final Library library = ((LibraryTableBase.ModifiableModelEx)getLibrariesModifiableModel()).createLibrary(name, type);
  //createLibraryEditor(library);                     \
  final BaseLibrariesConfigurable configurable = ProjectStructureConfigurable.getInstance(myProject).getConfigurableFor(library);
  configurable.createLibraryNode(library);
  return library;
}
 
Example #12
Source File: AnalyzeDependenciesComponent.java    From consulo with Apache License 2.0 5 votes vote down vote up
/**
 * {@inheritDoc}
 */
@Override
public void actionPerformed(AnActionEvent e) {
  final Module module = e.getData(LangDataKeys.MODULE);
  if (module == null) {
    return;
  }
  final ModuleDependenciesAnalyzer.OrderPathElement element = e.getData(ORDER_PATH_ELEMENT_KEY);
  if (element != null && element instanceof ModuleDependenciesAnalyzer.OrderEntryPathElement) {
    final ModuleDependenciesAnalyzer.OrderEntryPathElement o = (ModuleDependenciesAnalyzer.OrderEntryPathElement)element;
    final OrderEntry entry = o.entry();
    final Module m = entry.getOwnerModule();
    ProjectStructureConfigurable.getInstance(module.getProject()).selectOrderEntry(m, entry);
  }
}
 
Example #13
Source File: PlaceInModuleClasspath.java    From consulo with Apache License 2.0 4 votes vote down vote up
@Nonnull
@Override
public AsyncResult<Void> navigate() {
  return ProjectStructureConfigurable.getInstance(myContext.getProject()).selectOrderEntry(myModule, myOrderEntry);
}
 
Example #14
Source File: ArtifactEditorContextImpl.java    From consulo with Apache License 2.0 4 votes vote down vote up
@Override
public void selectArtifact(@Nonnull Artifact artifact) {
  ProjectStructureConfigurable.getInstance(getProject()).select(artifact, true);
}
 
Example #15
Source File: ArtifactEditorContextImpl.java    From consulo with Apache License 2.0 4 votes vote down vote up
@Override
public void selectModule(@Nonnull Module module) {
  ProjectStructureConfigurable.getInstance(getProject()).select(module.getName(), null, true);
}
 
Example #16
Source File: LibraryProjectStructureElement.java    From consulo with Apache License 2.0 4 votes vote down vote up
@Nonnull
private PlaceInProjectStructure createPlace() {
  final Project project = myContext.getProject();
  return new PlaceInProjectStructureBase(project, ProjectStructureConfigurable.getInstance(project).createProjectOrGlobalLibraryPlace(myLibrary), this);
}
 
Example #17
Source File: PlaceInProjectStructureBase.java    From consulo with Apache License 2.0 4 votes vote down vote up
@Nonnull
@Override
public AsyncResult<Void> navigate() {
  return ProjectStructureConfigurable.getInstance(myProject).navigateTo(myPlace, true);
}
 
Example #18
Source File: ModuleProjectStructureElement.java    From consulo with Apache License 2.0 4 votes vote down vote up
private PlaceInProjectStructure createPlace() {
  final Project project = myContext.getProject();
  return new PlaceInProjectStructureBase(project, ProjectStructureConfigurable.getInstance(project).createModulePlace(myModule), this);
}
 
Example #19
Source File: ClasspathPanelImpl.java    From consulo with Apache License 2.0 4 votes vote down vote up
private StructureConfigurableContext getStructureConfigurableContext() {
  return ProjectStructureConfigurable.getInstance(myState.getProject()).getContext();
}
 
Example #20
Source File: IdeaModifiableModelsProvider.java    From consulo with Apache License 2.0 4 votes vote down vote up
@Nullable
private static StructureConfigurableContext getProjectStructureContext(Project project) {
  final ProjectStructureConfigurable structureConfigurable = ProjectStructureConfigurable.getInstance(project);
  return structureConfigurable.getContext() ;
}