本文整理汇总了Java中com.intellij.openapi.roots.ui.configuration.libraries.LibraryEditingUtil类的典型用法代码示例。如果您正苦于以下问题:Java LibraryEditingUtil类的具体用法?Java LibraryEditingUtil怎么用?Java LibraryEditingUtil使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
LibraryEditingUtil类属于com.intellij.openapi.roots.ui.configuration.libraries包,在下文中一共展示了LibraryEditingUtil类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: showDialogAndAddLibraryToDependencies
import com.intellij.openapi.roots.ui.configuration.libraries.LibraryEditingUtil; //导入依赖的package包/类
public static void showDialogAndAddLibraryToDependencies(final Library library, final Project project, boolean allowEmptySelection) {
for (ProjectStructureValidator validator : EP_NAME.getExtensions()) {
if (validator.addLibraryToDependencies(library, project, allowEmptySelection)) {
return;
}
}
final ModuleStructureConfigurable moduleStructureConfigurable = ModuleStructureConfigurable.getInstance(project);
final List<Module> modules =
LibraryEditingUtil.getSuitableModules(moduleStructureConfigurable, ((LibraryEx)library).getKind(), library);
if (modules.isEmpty()) return;
final ChooseModulesDialog
dlg = new ChooseModulesDialog(moduleStructureConfigurable.getProject(), modules, ProjectBundle.message("choose.modules.dialog.title"),
ProjectBundle
.message("choose.modules.dialog.description", library.getName()));
if (dlg.showAndGet()) {
final List<Module> chosenModules = dlg.getChosenElements();
for (Module module : chosenModules) {
moduleStructureConfigurable.addLibraryOrderEntry(module, library);
}
}
}
示例2: actionPerformed
import com.intellij.openapi.roots.ui.configuration.libraries.LibraryEditingUtil; //导入依赖的package包/类
@Override
public void actionPerformed(final AnActionEvent e) {
final Object o = getSelectedObject();
if (o instanceof LibraryEx) {
final LibraryEx selected = (LibraryEx)o;
final String newName = Messages.showInputDialog("Enter library name:", "Copy Library", null, selected.getName() + "2", new NonEmptyInputValidator());
if (newName == null) return;
BaseLibrariesConfigurable configurable = BaseLibrariesConfigurable.this;
final LibraryEx library = (LibraryEx)myContext.getLibrary(selected.getName(), myLevel);
LOG.assertTrue(library != null);
final LibrariesModifiableModel libsModel = configurable.getModelProvider().getModifiableModel();
final Library lib = libsModel.createLibrary(newName, library.getKind());
final LibraryEx.ModifiableModelEx model = (LibraryEx.ModifiableModelEx)libsModel.getLibraryEditor(lib).getModel();
LibraryEditingUtil.copyLibrary(library, Collections.<String, String>emptyMap(), model);
}
}
示例3: validateAndApply
import com.intellij.openapi.roots.ui.configuration.libraries.LibraryEditingUtil; //导入依赖的package包/类
protected boolean validateAndApply() {
String newName = myNameField.getText().trim();
if (newName.length() == 0) {
newName = null;
}
if (shouldCheckName(newName)) {
final LibraryTable.ModifiableModel tableModifiableModel = getTableModifiableModel();
if (tableModifiableModel != null && !(tableModifiableModel instanceof ModuleLibraryTable)) {
if (newName == null) {
Messages.showErrorDialog(ProjectBundle.message("library.name.not.specified.error", newName), ProjectBundle.message("library.name.not.specified.title"));
return false;
}
if (LibraryEditingUtil.libraryAlreadyExists(tableModifiableModel, newName)) {
Messages.showErrorDialog(ProjectBundle.message("library.name.already.exists.error", newName), ProjectBundle.message("library.name.already.exists.title"));
return false;
}
}
myLibraryRootsComponent.renameLibrary(newName);
}
myLibraryRootsComponent.applyProperties();
return true;
}
示例4: createLibrary
import com.intellij.openapi.roots.ui.configuration.libraries.LibraryEditingUtil; //导入依赖的package包/类
@Nullable
public static Library createLibrary(@Nullable final LibraryType type, @NotNull final JComponent parentComponent,
@NotNull final Project project, @NotNull final LibrariesModifiableModel modifiableModel) {
final NewLibraryConfiguration configuration = createNewLibraryConfiguration(type, parentComponent, project);
if (configuration == null) return null;
final LibraryType<?> libraryType = configuration.getLibraryType();
final Library library = modifiableModel.createLibrary(
LibraryEditingUtil.suggestNewLibraryName(modifiableModel, configuration.getDefaultLibraryName()),
libraryType != null ? libraryType.getKind() : null);
final NewLibraryEditor editor = new NewLibraryEditor(libraryType, configuration.getProperties());
configuration.addRoots(editor);
final Library.ModifiableModel model = library.getModifiableModel();
editor.applyTo((LibraryEx.ModifiableModelEx)model);
AccessToken token = WriteAction.start();
try {
model.commit();
}
finally {
token.finish();
}
return library;
}
示例5: doEdit
import com.intellij.openapi.roots.ui.configuration.libraries.LibraryEditingUtil; //导入依赖的package包/类
private void doEdit() {
final OrderEntry entry = getSelectedEntry();
if (!(entry instanceof LibraryOrderEntry)) return;
final Library library = ((LibraryOrderEntry)entry).getLibrary();
if (library == null) {
return;
}
final LibraryTable table = library.getTable();
final String tableLevel = table != null ? table.getTableLevel() : LibraryTableImplUtil.MODULE_LEVEL;
final LibraryTablePresentation presentation = LibraryEditingUtil.getLibraryTablePresentation(getProject(), tableLevel);
final LibraryTableModifiableModelProvider provider = getModifiableModelProvider(tableLevel);
EditExistingLibraryDialog dialog = EditExistingLibraryDialog.createDialog(this, provider, library, myState.getProject(),
presentation, getStructureConfigurableContext());
dialog.setContextModule(getRootModel().getModule());
dialog.show();
myEntryTable.repaint();
ModuleStructureConfigurable.getInstance(myState.getProject()).getTree().repaint();
}
示例6: chooseTypeAndCreate
import com.intellij.openapi.roots.ui.configuration.libraries.LibraryEditingUtil; //导入依赖的package包/类
public static void chooseTypeAndCreate(final ClasspathPanel classpathPanel,
final StructureConfigurableContext context,
final JButton contextButton, @NotNull final LibraryCreatedCallback callback) {
if (LibraryEditingUtil.hasSuitableTypes(classpathPanel)) {
final ListPopup popup = JBPopupFactory.getInstance().createListPopup(LibraryEditingUtil.createChooseTypeStep(classpathPanel, new ParameterizedRunnable<LibraryType>() {
@Override
public void run(LibraryType libraryType) {
doCreateLibrary(classpathPanel, context, callback, contextButton, libraryType);
}
}));
popup.showUnderneathOf(contextButton);
}
else {
doCreateLibrary(classpathPanel, context, callback, contextButton, null);
}
}
示例7: createNewLibrary
import com.intellij.openapi.roots.ui.configuration.libraries.LibraryEditingUtil; //导入依赖的package包/类
private LibraryEx createNewLibrary(@NotNull final Module module, final LibraryTable.ModifiableModel modifiableModel) {
RepositoryLibraryProperties libraryProperties = new RepositoryLibraryProperties(
libraryDescription.getGroupId(),
libraryDescription.getArtifactId(),
model.getVersion());
final LibraryEx library = (LibraryEx)modifiableModel.createLibrary(
LibraryEditingUtil.suggestNewLibraryName(modifiableModel, RepositoryLibraryType.getInstance().getDescription(libraryProperties)),
RepositoryLibraryType.REPOSITORY_LIBRARY_KIND);
RepositoryLibraryProperties realLibraryProperties = (RepositoryLibraryProperties)library.getProperties();
realLibraryProperties.setMavenId(libraryProperties.getMavenId());
ApplicationManager.getApplication().runWriteAction(new Runnable() {
@Override
public void run() {
modifiableModel.commit();
}
});
RepositoryUtils.loadDependencies(
module.getProject(),
library,
model.isDownloadSources(),
model.isDownloadJavaDocs(),
null);
return library;
}
示例8: showDialogAndAddLibraryToDependencies
import com.intellij.openapi.roots.ui.configuration.libraries.LibraryEditingUtil; //导入依赖的package包/类
public static void showDialogAndAddLibraryToDependencies(final Library library, final Project project, boolean allowEmptySelection) {
for (ProjectStructureValidator validator : EP_NAME.getExtensions()) {
if (validator.addLibraryToDependencies(library, project, allowEmptySelection)) {
return;
}
}
final ModuleStructureConfigurable moduleStructureConfigurable = ModuleStructureConfigurable.getInstance(project);
final List<Module> modules = LibraryEditingUtil.getSuitableModules(moduleStructureConfigurable, ((LibraryEx)library).getKind(), library);
if (modules.isEmpty()) return;
final ChooseModulesDialog
dlg = new ChooseModulesDialog(moduleStructureConfigurable.getProject(), modules, ProjectBundle.message("choose.modules.dialog.title"),
ProjectBundle
.message("choose.modules.dialog.description", library.getName()));
dlg.show();
if (dlg.isOK()) {
final List<Module> chosenModules = dlg.getChosenElements();
for (Module module : chosenModules) {
moduleStructureConfigurable.addLibraryOrderEntry(module, library);
}
}
}
示例9: createLibrary
import com.intellij.openapi.roots.ui.configuration.libraries.LibraryEditingUtil; //导入依赖的package包/类
@Nullable
public static Library createLibrary(@Nullable final LibraryType type, @NotNull final JComponent parentComponent,
@NotNull final Project project, @NotNull final LibrariesModifiableModel modifiableModel) {
final NewLibraryConfiguration configuration = createNewLibraryConfiguration(type, parentComponent, project);
if (configuration == null) return null;
final LibraryType<?> libraryType = configuration.getLibraryType();
final Library library = modifiableModel.createLibrary(
LibraryEditingUtil.suggestNewLibraryName(modifiableModel, configuration.getDefaultLibraryName()), libraryType != null ? libraryType.getKind() : null);
final NewLibraryEditor editor = new NewLibraryEditor(libraryType, configuration.getProperties());
configuration.addRoots(editor);
final Library.ModifiableModel model = library.getModifiableModel();
editor.applyTo((LibraryEx.ModifiableModelEx)model);
AccessToken token = WriteAction.start();
try {
model.commit();
}
finally {
token.finish();
}
return library;
}
示例10: ProjectLibraryTabContext
import com.intellij.openapi.roots.ui.configuration.libraries.LibraryEditingUtil; //导入依赖的package包/类
public ProjectLibraryTabContext(final ClasspathPanel classpathPanel, StructureConfigurableContext context) {
super(classpathPanel, context);
StructureLibraryTableModifiableModelProvider projectLibrariesProvider = context.getProjectLibrariesProvider();
Library[] libraries = projectLibrariesProvider.getModifiableModel().getLibraries();
final Condition<Library> condition = LibraryEditingUtil.getNotAddedLibrariesCondition(myClasspathPanel.getRootModel());
myItems = ContainerUtil.filter(libraries, condition);
ContainerUtil.sort(myItems, new Comparator<Library>() {
@Override
public int compare(Library o1, Library o2) {
return StringUtil.compare(o1.getName(), o2.getName(), false);
}
});
myLibraryList = new JBList(myItems);
myLibraryList.setCellRenderer(new ColoredListCellRendererWrapper<Library>() {
@Override
protected void doCustomize(JList list, Library value, int index, boolean selected, boolean hasFocus) {
final CellAppearanceEx appearance = OrderEntryAppearanceService.getInstance().forLibrary(classpathPanel.getProject(), value, false);
appearance.customize(this);
}
});
new ListSpeedSearch(myLibraryList);
}
示例11: createLibrary
import com.intellij.openapi.roots.ui.configuration.libraries.LibraryEditingUtil; //导入依赖的package包/类
@Nullable
public static Library createLibrary(@Nullable final LibraryType type,
@Nonnull final JComponent parentComponent,
@Nonnull final Project project,
@Nonnull final LibrariesModifiableModel modifiableModel) {
final NewLibraryConfiguration configuration = createNewLibraryConfiguration(type, parentComponent, project);
if (configuration == null) return null;
final LibraryType<?> libraryType = configuration.getLibraryType();
final Library library = modifiableModel
.createLibrary(LibraryEditingUtil.suggestNewLibraryName(modifiableModel, configuration.getDefaultLibraryName()),
libraryType != null ? libraryType.getKind() : null);
final NewLibraryEditor editor = new NewLibraryEditor(libraryType, configuration.getProperties());
configuration.addRoots(editor);
final Library.ModifiableModel model = library.getModifiableModel();
editor.applyTo((LibraryEx.ModifiableModelEx)model);
AccessToken token = WriteAction.start();
try {
model.commit();
}
finally {
token.finish();
}
return library;
}
示例12: update
import com.intellij.openapi.roots.ui.configuration.libraries.LibraryEditingUtil; //导入依赖的package包/类
@Override
public void update(AnActionEvent e) {
final ProjectStructureElement element = myConfigurable.getSelectedElement();
boolean visible = false;
if (element instanceof LibraryProjectStructureElement) {
final LibraryEx library = (LibraryEx)((LibraryProjectStructureElement)element).getLibrary();
visible = !LibraryEditingUtil.getSuitableModules(ModuleStructureConfigurable.getInstance(myProject), library.getKind(), library).isEmpty();
}
e.getPresentation().setVisible(visible);
}
示例13: actionPerformed
import com.intellij.openapi.roots.ui.configuration.libraries.LibraryEditingUtil; //导入依赖的package包/类
@Override
public void actionPerformed(AnActionEvent e) {
final LibraryProjectStructureElement element = (LibraryProjectStructureElement)myConfigurable.getSelectedElement();
if (element == null) return;
final Library library = element.getLibrary();
LibraryEditingUtil.showDialogAndAddLibraryToDependencies(library, myProject, false);
}
示例14: checkName
import com.intellij.openapi.roots.ui.configuration.libraries.LibraryEditingUtil; //导入依赖的package包/类
private void checkName() {
final String name = getLibraryName();
if (name.isEmpty()) {
if (!myAllowEmptyName) {
setErrorText("Library name is not specified");
}
return;
}
if (LibraryEditingUtil.libraryAlreadyExists(myModifiableModel, name)) {
setErrorText("Library '" + name + "' already exists");
return;
}
setErrorText(null);
}
示例15: createActionOrGroup
import com.intellij.openapi.roots.ui.configuration.libraries.LibraryEditingUtil; //导入依赖的package包/类
public static AnAction[] createActionOrGroup(@NotNull String text, @NotNull BaseLibrariesConfigurable librariesConfigurable, final @NotNull Project project) {
final LibraryType<?>[] extensions = LibraryType.EP_NAME.getExtensions();
List<LibraryType<?>> suitableTypes = new ArrayList<LibraryType<?>>();
if (librariesConfigurable instanceof ProjectLibrariesConfigurable || !project.isDefault()) {
final ModuleStructureConfigurable configurable = ModuleStructureConfigurable.getInstance(project);
for (LibraryType<?> extension : extensions) {
if (!LibraryEditingUtil.getSuitableModules(configurable, extension.getKind(), null).isEmpty()) {
suitableTypes.add(extension);
}
}
}
else {
Collections.addAll(suitableTypes, extensions);
}
if (suitableTypes.isEmpty()) {
return new AnAction[]{new CreateNewLibraryAction(text, PlatformIcons.LIBRARY_ICON, null, librariesConfigurable, project)};
}
List<AnAction> actions = new ArrayList<AnAction>();
actions.add(new CreateNewLibraryAction(IdeBundle.message("create.default.library.type.action.name"), PlatformIcons.LIBRARY_ICON, null, librariesConfigurable, project));
for (LibraryType<?> type : suitableTypes) {
final String actionName = type.getCreateActionName();
if (actionName != null) {
actions.add(new CreateNewLibraryAction(actionName, type.getIcon(null), type, librariesConfigurable, project));
}
}
return actions.toArray(new AnAction[actions.size()]);
}