本文整理汇总了Java中com.intellij.openapi.roots.libraries.LibraryTable.ModifiableModel方法的典型用法代码示例。如果您正苦于以下问题:Java LibraryTable.ModifiableModel方法的具体用法?Java LibraryTable.ModifiableModel怎么用?Java LibraryTable.ModifiableModel使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类com.intellij.openapi.roots.libraries.LibraryTable
的用法示例。
在下文中一共展示了LibraryTable.ModifiableModel方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: createGlobalLibrary
import com.intellij.openapi.roots.libraries.LibraryTable; //导入方法依赖的package包/类
public void createGlobalLibrary(
@NotNull final IdeModifiableModelsProvider modifiableModelsProvider,
@NotNull final File libraryDirRoot,
@NotNull final String libraryName
) {
final LibraryTable.ModifiableModel libraryTableModifiableModel = modifiableModelsProvider
.getModifiableProjectLibrariesModel();
Library library = libraryTableModifiableModel.getLibraryByName(libraryName);
if (null == library) {
library = libraryTableModifiableModel.createLibrary(libraryName);
}
if (libraryTableModifiableModel instanceof LibrariesModifiableModel) {
final ExistingLibraryEditor existingLibraryEditor = ((LibrariesModifiableModel) libraryTableModifiableModel)
.getLibraryEditor(library);
existingLibraryEditor.addJarDirectory(
VfsUtil.getUrlForLibraryRoot(libraryDirRoot), true, OrderRootType.CLASSES
);
} else {
final Library.ModifiableModel libraryModifiableModel = modifiableModelsProvider
.getModifiableLibraryModel(library);
libraryModifiableModel.addJarDirectory(VfsUtil.getUrlForLibraryRoot(libraryDirRoot), true);
}
}
开发者ID:AlexanderBartash,项目名称:hybris-integration-intellij-idea-plugin,代码行数:26,代码来源:OotbHybrisModuleDescriptor.java
示例2: addLibsToModule
import com.intellij.openapi.roots.libraries.LibraryTable; //导入方法依赖的package包/类
private void addLibsToModule(
@NotNull final ModifiableRootModel modifiableRootModel,
@NotNull IdeModifiableModelsProvider modifiableModelsProvider,
@NotNull final String libraryName,
final boolean export
) {
Validate.notNull(modifiableRootModel);
final LibraryTable.ModifiableModel libraryTableModifiableModel = modifiableModelsProvider
.getModifiableProjectLibrariesModel();
Library library = libraryTableModifiableModel.getLibraryByName(libraryName);
if (null == library) {
library = libraryTableModifiableModel.createLibrary(libraryName);
}
modifiableRootModel.addLibraryEntry(library);
if (export) {
setLibraryEntryExported(modifiableRootModel, library);
}
}
开发者ID:AlexanderBartash,项目名称:hybris-integration-intellij-idea-plugin,代码行数:23,代码来源:DefaultLibRootsConfigurator.java
示例3: removeOldProjectData
import com.intellij.openapi.roots.libraries.LibraryTable; //导入方法依赖的package包/类
private static void removeOldProjectData(@NotNull final Project project) {
final ModifiableModuleModel moduleModel = ModuleManager.getInstance(project).getModifiableModel();
for (Module module : moduleModel.getModules()) {
moduleModel.disposeModule(module);
}
final LibraryTable.ModifiableModel libraryModel = ProjectLibraryTable.getInstance(project).getModifiableModel();
for (Library library : libraryModel.getLibraries()) {
libraryModel.removeLibrary(library);
}
ApplicationManager.getApplication().runWriteAction(() -> {
moduleModel.commit();
libraryModel.commit();
});
final GradleSupport gradleSupport = GradleSupport.getInstance();
if (gradleSupport != null) {
gradleSupport.clearLinkedProjectSettings(project);
}
final AntConfigurationBase antConfiguration = AntConfigurationBase.getInstance(project);
for (AntBuildFile antBuildFile : antConfiguration.getBuildFiles()) {
antConfiguration.removeBuildFile(antBuildFile);
}
}
开发者ID:AlexanderBartash,项目名称:hybris-integration-intellij-idea-plugin,代码行数:27,代码来源:ProjectRefreshAction.java
示例4: removeData
import com.intellij.openapi.roots.libraries.LibraryTable; //导入方法依赖的package包/类
@Override
public void removeData(@NotNull final Computable<Collection<Library>> toRemoveComputable,
@NotNull Collection<DataNode<LibraryData>> toIgnore,
@NotNull ProjectData projectData,
@NotNull final Project project,
@NotNull final IdeModifiableModelsProvider modelsProvider) {
final Collection<Library> toRemove = toRemoveComputable.compute();
if (toRemove.isEmpty()) {
return;
}
final LibraryTable.ModifiableModel librariesModel = modelsProvider.getModifiableProjectLibrariesModel();
for (Library library : toRemove) {
String libraryName = library.getName();
if (libraryName != null) {
Library libraryToRemove = librariesModel.getLibraryByName(libraryName);
if (libraryToRemove != null) {
librariesModel.removeLibrary(libraryToRemove);
}
}
}
}
示例5: createNewLibrary
import com.intellij.openapi.roots.libraries.LibraryTable; //导入方法依赖的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;
}
示例6: createDialog
import com.intellij.openapi.roots.libraries.LibraryTable; //导入方法依赖的package包/类
public static EditExistingLibraryDialog createDialog(Component parent,
LibraryTableModifiableModelProvider modelProvider,
Library library,
@Nullable Project project,
LibraryTablePresentation presentation,
StructureConfigurableContext context) {
LibraryTable.ModifiableModel modifiableModel = modelProvider.getModifiableModel();
boolean commitChanges = false;
ExistingLibraryEditor libraryEditor;
if (modifiableModel instanceof LibrariesModifiableModel) {
libraryEditor = ((LibrariesModifiableModel)modifiableModel).getLibraryEditor(library);
}
else {
libraryEditor = new ExistingLibraryEditor(library, context);
commitChanges = true;
}
return new EditExistingLibraryDialog(parent, modifiableModel, project, libraryEditor, commitChanges, presentation, context);
}
示例7: EditExistingLibraryDialog
import com.intellij.openapi.roots.libraries.LibraryTable; //导入方法依赖的package包/类
private EditExistingLibraryDialog(Component parent,
LibraryTable.ModifiableModel tableModifiableModel,
@Nullable Project project,
ExistingLibraryEditor libraryEditor,
boolean commitChanges,
LibraryTablePresentation presentation, StructureConfigurableContext context) {
super(parent, new LibraryRootsComponent(project, libraryEditor));
setTitle("Configure " + presentation.getDisplayName(false));
myTableModifiableModel = tableModifiableModel;
myLibraryEditor = libraryEditor;
myCommitChanges = commitChanges;
if (commitChanges) {
Disposer.register(getDisposable(), libraryEditor);
}
context.addLibraryEditorListener(new LibraryEditorListener() {
@Override
public void libraryRenamed(@NotNull Library library, String oldName, String newName) {
if (library.equals(myLibraryEditor.getLibrary())) {
myNameField.setText(newName);
}
}
}, getDisposable());
init();
}
示例8: getLibraryTableModifiableModel
import com.intellij.openapi.roots.libraries.LibraryTable; //导入方法依赖的package包/类
@Override
public LibraryTable.ModifiableModel getLibraryTableModifiableModel() {
final Project[] projects = ProjectManager.getInstance().getOpenProjects();
for (Project project : projects) {
if (!project.isInitialized()) {
continue;
}
StructureConfigurableContext context = getProjectStructureContext(project);
LibraryTableModifiableModelProvider provider = context != null ? context.createModifiableModelProvider(LibraryTablesRegistrar.APPLICATION_LEVEL) : null;
final LibraryTable.ModifiableModel modifiableModel = provider != null ? provider.getModifiableModel() : null;
if (modifiableModel != null) {
return modifiableModel;
}
}
return LibraryTablesRegistrar.getInstance().getLibraryTable().getModifiableModel();
}
示例9: validateAndApply
import com.intellij.openapi.roots.libraries.LibraryTable; //导入方法依赖的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;
}
示例10: run
import com.intellij.openapi.roots.libraries.LibraryTable; //导入方法依赖的package包/类
@Override
public void run() {
if (module.isDisposed() || module.getProject().isDisposed()) {
logger.warn("Either the module '" + module.getName() + "' or project '" + module.getProject().getName() + " has been disposed." +
" Cannot add root '" + jarDirectory.getPath() + " as a project and module dependency.");
return;
}
LibraryTable projectLibraryTable = LibraryTablesRegistrar.getInstance().getLibraryTable(module.getProject());
LibraryTable.ModifiableModel projectLibraryModel = projectLibraryTable.getModifiableModel();
logger.debug("Adding '" + jarDirectory + "' as a dependency of the project '" + module.getProject().getName() + "'.");
// Create library and add it as a project level dependency.
Library processingLibrary = createProcessingCoreDependencyLibrary(projectLibraryModel);
projectLibraryModel.commit();
logger.debug("Change committed to the project library table.");
logger.debug("Adding '" + jarDirectory + "' as a dependency of the module '" + module.getProject().getName() + "'.");
// Add library as the module level dependency.
ModifiableRootModel rootModel = ModuleRootManager.getInstance(module).getModifiableModel();
rootModel.addLibraryEntry(processingLibrary);
rootModel.commit();
logger.debug("Change committed to the module library table.");
}
示例11: createProcessingCoreDependencyLibrary
import com.intellij.openapi.roots.libraries.LibraryTable; //导入方法依赖的package包/类
private Library createProcessingCoreDependencyLibrary(@NotNull LibraryTable.ModifiableModel libraryModel) {
Library processingCoreLibrary = libraryModel.createLibrary("processing-core");
Library.ModifiableModel modifiableModel = processingCoreLibrary.getModifiableModel();
modifiableModel.addJarDirectory(jarDirectory, true, OrderRootType.CLASSES);
modifiableModel.commit();
return processingCoreLibrary;
}
示例12: disposeLibraryTableModifiableModel
import com.intellij.openapi.roots.libraries.LibraryTable; //导入方法依赖的package包/类
@Override
public void disposeLibraryTableModifiableModel(LibraryTable.ModifiableModel model) {
//IDEA should dispose this model instead of us, because it is was given from StructureConfigurableContext
if (!(model instanceof LibrariesModifiableModel)) {
Disposer.dispose(model);
}
}
示例13: getLibrariesModifiableModel
import com.intellij.openapi.roots.libraries.LibraryTable; //导入方法依赖的package包/类
private LibraryTable.ModifiableModel getLibrariesModifiableModel() {
if (myLibrariesModifiableModel == null) {
myLibrariesModifiableModel = myTable.getModifiableModel();
}
return myLibrariesModifiableModel;
}
示例14: createLibraryInTable
import com.intellij.openapi.roots.libraries.LibraryTable; //导入方法依赖的package包/类
@NotNull
private static Library createLibraryInTable(final @NotNull NewLibraryEditor editor, final LibraryTable table) {
LibraryTable.ModifiableModel modifiableModel = table.getModifiableModel();
final String name = StringUtil.isEmpty(editor.getName()) ? null : getUniqueLibraryName(editor.getName(), modifiableModel);
final LibraryType<?> type = editor.getType();
Library library = modifiableModel.createLibrary(name, type == null ? null : type.getKind());
final LibraryEx.ModifiableModelEx model = (LibraryEx.ModifiableModelEx)library.getModifiableModel();
editor.applyTo(model);
model.commit();
modifiableModel.commit();
return library;
}
示例15: getLibraryEditor
import com.intellij.openapi.roots.libraries.LibraryTable; //导入方法依赖的package包/类
@Override
public ExistingLibraryEditor getLibraryEditor(@NotNull Library library) {
final LibraryTable table = library.getTable();
if (table == null) return null;
final LibraryTable.ModifiableModel model = myContext.getModifiableLibraryTable(table);
if (model instanceof LibrariesModifiableModel) {
return ((LibrariesModifiableModel)model).getLibraryEditor(library);
}
return null;
}