本文整理汇总了Java中com.intellij.packaging.elements.PackagingElementFactory类的典型用法代码示例。如果您正苦于以下问题:Java PackagingElementFactory类的具体用法?Java PackagingElementFactory怎么用?Java PackagingElementFactory使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
PackagingElementFactory类属于com.intellij.packaging.elements包,在下文中一共展示了PackagingElementFactory类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。
示例1: getOrCreateModifiableParent
import com.intellij.packaging.elements.PackagingElementFactory; //导入依赖的package包/类
private static CompositePackagingElement<?> getOrCreateModifiableParent(CompositePackagingElement<?> parentElement, PackagingElementNode<?> node) {
PackagingElementNode<?> current = node;
List<String> dirNames = new ArrayList<String>();
while (current != null && !(current instanceof ArtifactRootNode)) {
final PackagingElement<?> packagingElement = current.getFirstElement();
if (!(packagingElement instanceof DirectoryPackagingElement)) {
return parentElement;
}
dirNames.add(((DirectoryPackagingElement)packagingElement).getDirectoryName());
current = current.getParentNode();
}
if (current == null) return parentElement;
final PackagingElement<?> rootElement = current.getElementIfSingle();
if (!(rootElement instanceof CompositePackagingElement<?>)) return parentElement;
Collections.reverse(dirNames);
String path = StringUtil.join(dirNames, "/");
return PackagingElementFactory.getInstance().getOrCreateDirectory((CompositePackagingElement<?>)rootElement, path);
}
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:21,代码来源:LayoutTreeComponent.java
示例2: packInto
import com.intellij.packaging.elements.PackagingElementFactory; //导入依赖的package包/类
public void packInto(@NotNull final List<? extends PackagingSourceItem> items, final String pathToJar) {
final List<PackagingElement<?>> toSelect = new ArrayList<PackagingElement<?>>();
final CompositePackagingElement<?> rootElement = getArtifact().getRootElement();
editLayout(new Runnable() {
@Override
public void run() {
final CompositePackagingElement<?> archive = PackagingElementFactory.getInstance().getOrCreateArchive(rootElement, pathToJar);
for (PackagingSourceItem item : items) {
final List<? extends PackagingElement<?>> elements = item.createElements(myContext);
archive.addOrFindChildren(elements);
}
toSelect.add(archive);
}
});
myArtifactsEditor.getSourceItemsTree().rebuildTree();
updateAndSelect(myTree.getRootPackagingNode(), toSelect);
}
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:19,代码来源:LayoutTreeComponent.java
示例3: getFileToArtifactsMap
import com.intellij.packaging.elements.PackagingElementFactory; //导入依赖的package包/类
public CachedValue<MultiValuesMap<VirtualFile, Artifact>> getFileToArtifactsMap() {
if (myFile2Artifacts == null) {
myFile2Artifacts =
CachedValuesManager.getManager(myProject).createCachedValue(new CachedValueProvider<MultiValuesMap<VirtualFile, Artifact>>() {
public Result<MultiValuesMap<VirtualFile, Artifact>> compute() {
MultiValuesMap<VirtualFile, Artifact> result = computeFileToArtifactsMap();
List<ModificationTracker> trackers = new ArrayList<ModificationTracker>();
trackers.add(ArtifactManager.getInstance(myProject).getModificationTracker());
for (ComplexPackagingElementType<?> type : PackagingElementFactory.getInstance().getComplexElementTypes()) {
ContainerUtil.addIfNotNull(type.getAllSubstitutionsModificationTracker(myProject), trackers);
}
return Result.create(result, trackers.toArray(new ModificationTracker[trackers.size()]));
}
}, false);
}
return myFile2Artifacts;
}
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:18,代码来源:ArtifactBySourceFileFinderImpl.java
示例4: findOrCreateWebArtifact
import com.intellij.packaging.elements.PackagingElementFactory; //导入依赖的package包/类
@NotNull
private static Artifact findOrCreateWebArtifact(AppEngineFacet appEngineFacet) {
Module module = appEngineFacet.getModule();
ArtifactType webArtifactType = AppEngineWebIntegration.getInstance().getAppEngineWebArtifactType();
final Collection<Artifact> artifacts = ArtifactUtil.getArtifactsContainingModuleOutput(module);
for (Artifact artifact : artifacts) {
if (webArtifactType.equals(artifact.getArtifactType())) {
return artifact;
}
}
ArtifactManager artifactManager = ArtifactManager.getInstance(module.getProject());
PackagingElementFactory elementFactory = PackagingElementFactory.getInstance();
ArtifactRootElement<?> root = elementFactory.createArtifactRootElement();
elementFactory.getOrCreateDirectory(root, "WEB-INF/classes").addOrFindChild(elementFactory.createModuleOutput(module));
return artifactManager.addArtifact(module.getName(), webArtifactType, root);
}
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:17,代码来源:AppEngineSupportProvider.java
示例5: addArtifactToLayout
import com.intellij.packaging.elements.PackagingElementFactory; //导入依赖的package包/类
public static void addArtifactToLayout(
final Project project, final Artifact parent, final Artifact toAdd) {
new WriteAction() {
@Override
protected void run(@NotNull final Result result) {
final ModifiableArtifactModel model =
ArtifactManager.getInstance(project).createModifiableModel();
final PackagingElement<?> artifactElement =
PackagingElementFactory.getInstance().createArtifactElement(toAdd, project);
model
.getOrCreateModifiableArtifact(parent)
.getRootElement()
.addOrFindChild(artifactElement);
model.commit();
}
}.execute();
}
开发者ID:GoogleCloudPlatform,项目名称:google-cloud-intellij,代码行数:18,代码来源:ArtifactsTestUtil.java
示例6: findOrCreateWebArtifact
import com.intellij.packaging.elements.PackagingElementFactory; //导入依赖的package包/类
@NotNull
static Artifact findOrCreateWebArtifact(AppEngineStandardFacet appEngineStandardFacet) {
Module module = appEngineStandardFacet.getModule();
ArtifactType webArtifactType =
AppEngineStandardWebIntegration.getInstance().getAppEngineWebArtifactType();
final Collection<Artifact> artifacts = ArtifactUtil.getArtifactsContainingModuleOutput(module);
for (Artifact artifact : artifacts) {
if (webArtifactType.equals(artifact.getArtifactType())) {
return artifact;
}
}
ArtifactManager artifactManager = ArtifactManager.getInstance(module.getProject());
PackagingElementFactory elementFactory = PackagingElementFactory.getInstance();
ArtifactRootElement<?> root = elementFactory.createArtifactRootElement();
elementFactory
.getOrCreateDirectory(root, "WEB-INF/classes")
.addOrFindChild(elementFactory.createModuleOutput(module));
return artifactManager.addArtifact(module.getName(), webArtifactType, root);
}
开发者ID:GoogleCloudPlatform,项目名称:google-cloud-intellij,代码行数:20,代码来源:AppEngineStandardSupportProvider.java
示例7: putIntoDefaultLocations
import com.intellij.packaging.elements.PackagingElementFactory; //导入依赖的package包/类
public void putIntoDefaultLocations(@NotNull final List<? extends PackagingSourceItem> items) {
final List<PackagingElement<?>> toSelect = new ArrayList<PackagingElement<?>>();
editLayout(new Runnable() {
@Override
public void run() {
final CompositePackagingElement<?> rootElement = getArtifact().getRootElement();
final ArtifactType artifactType = getArtifact().getArtifactType();
for (PackagingSourceItem item : items) {
final String path = artifactType.getDefaultPathFor(item);
if (path != null) {
final CompositePackagingElement<?> directory = PackagingElementFactory.getInstance().getOrCreateDirectory(rootElement, path);
final List<? extends PackagingElement<?>> elements = item.createElements(myContext);
toSelect.addAll(directory.addOrFindChildren(elements));
}
}
}
});
myArtifactsEditor.getSourceItemsTree().rebuildTree();
updateAndSelect(myTree.getRootPackagingNode(), toSelect);
}
开发者ID:lshain-android-source,项目名称:tools-idea,代码行数:22,代码来源:LayoutTreeComponent.java
示例8: findOrCreateArtifact
import com.intellij.packaging.elements.PackagingElementFactory; //导入依赖的package包/类
@NotNull
private static Artifact findOrCreateArtifact(AppEngineFacet appEngineFacet) {
Module module = appEngineFacet.getModule();
ArtifactType artifactType = AppEngineWebIntegration.getInstance().getAppEngineTargetArtifactType();
final Collection<Artifact> artifacts = ArtifactUtil.getArtifactsContainingModuleOutput(module);
for (Artifact artifact : artifacts) {
if (artifactType.equals(artifact.getArtifactType())) {
return artifact;
}
}
ArtifactManager artifactManager = ArtifactManager.getInstance(module.getProject());
PackagingElementFactory elementFactory = PackagingElementFactory.getInstance();
ArtifactRootElement<?> root = elementFactory.createArtifactRootElement();
elementFactory.getOrCreateDirectory(root, "WEB-INF/classes").addOrFindChild(elementFactory.createModuleOutput(module));
return artifactManager.addArtifact(module.getName(), artifactType, root);
}
开发者ID:lshain-android-source,项目名称:tools-idea,代码行数:17,代码来源:AppEngineSupportProvider.java
示例9: createComposite
import com.intellij.packaging.elements.PackagingElementFactory; //导入依赖的package包/类
@Override
public CompositePackagingElement<?> createComposite(CompositePackagingElement<?> parent,
@Nullable String baseName,
@Nonnull ArtifactEditorContext context) {
final String initialValue = PackagingElementFactoryImpl.suggestFileName(parent, baseName != null ? baseName : "archive", ".zip");
String path =
Messages.showInputDialog(context.getProject(), "Enter archive name: ", "New Archive", null, initialValue, new FilePathValidator());
if (path == null) {
return null;
}
path = FileUtil.toSystemIndependentName(path);
final String parentPath = PathUtil.getParentPath(path);
final String fileName = PathUtil.getFileName(path);
final PackagingElement<?> element = new ZipArchivePackagingElement(fileName);
return (CompositePackagingElement<?>)PackagingElementFactory.getInstance().createParentDirectories(parentPath, element);
}
开发者ID:consulo,项目名称:consulo,代码行数:17,代码来源:ZipArchiveElementType.java
示例10: putIntoDefaultLocations
import com.intellij.packaging.elements.PackagingElementFactory; //导入依赖的package包/类
public void putIntoDefaultLocations(@Nonnull final List<? extends PackagingSourceItem> items) {
final List<PackagingElement<?>> toSelect = new ArrayList<PackagingElement<?>>();
editLayout(new Runnable() {
@Override
public void run() {
final CompositePackagingElement<?> rootElement = getArtifact().getRootElement();
final ArtifactType artifactType = getArtifact().getArtifactType();
for (PackagingSourceItem item : items) {
final String path = artifactType.getDefaultPathFor(item);
if (path != null) {
final CompositePackagingElement<?> directory = PackagingElementFactory.getInstance().getOrCreateDirectory(rootElement, path);
final List<? extends PackagingElement<?>> elements = item.createElements(myContext);
toSelect.addAll(directory.addOrFindChildren(elements));
}
}
}
});
myArtifactsEditor.getSourceItemsTree().rebuildTree();
updateAndSelect(myTree.getRootPackagingNode(), toSelect);
}
开发者ID:consulo,项目名称:consulo,代码行数:22,代码来源:LayoutTreeComponent.java
示例11: packInto
import com.intellij.packaging.elements.PackagingElementFactory; //导入依赖的package包/类
public void packInto(@Nonnull final List<? extends PackagingSourceItem> items, final String pathToJar) {
final List<PackagingElement<?>> toSelect = new ArrayList<PackagingElement<?>>();
final CompositePackagingElement<?> rootElement = getArtifact().getRootElement();
editLayout(new Runnable() {
@Override
public void run() {
final CompositePackagingElement<?> archive = PackagingElementFactory.getInstance().getOrCreateArchive(rootElement, pathToJar);
for (PackagingSourceItem item : items) {
final List<? extends PackagingElement<?>> elements = item.createElements(myContext);
archive.addOrFindChildren(elements);
}
toSelect.add(archive);
}
});
myArtifactsEditor.getSourceItemsTree().rebuildTree();
updateAndSelect(myTree.getRootPackagingNode(), toSelect);
}
开发者ID:consulo,项目名称:consulo,代码行数:19,代码来源:LayoutTreeComponent.java
示例12: createComposite
import com.intellij.packaging.elements.PackagingElementFactory; //导入依赖的package包/类
@Override
public CompositePackagingElement<?> createComposite(CompositePackagingElement<?> parent, @Nullable String baseName,
@NotNull ArtifactEditorContext context)
{
final String initialValue = PackagingElementFactoryImpl.suggestFileName(parent, baseName != null ? baseName : "archive", ".jar");
String path = Messages.showInputDialog(context.getProject(), "Enter archive name: ", "New Archive", null, initialValue,
new FilePathValidator());
if(path == null)
{
return null;
}
path = FileUtil.toSystemIndependentName(path);
final String parentPath = PathUtil.getParentPath(path);
final String fileName = PathUtil.getFileName(path);
final PackagingElement<?> element = new JarArchivePackagingElement(fileName);
return (CompositePackagingElement<?>) PackagingElementFactory.getInstance().createParentDirectories(parentPath, element);
}
开发者ID:consulo,项目名称:consulo-java,代码行数:18,代码来源:JarArchiveElementType.java
示例13: addLibraries
import com.intellij.packaging.elements.PackagingElementFactory; //导入依赖的package包/类
private void addLibraries(Set<Library> libraries, ArtifactRootElement<?> root, CompositePackagingElement<?> archive,
List<String> classpath) {
PackagingElementFactory factory = PackagingElementFactory.getInstance();
for (Library library : libraries) {
if (LibraryPackagingElement.getKindForLibrary(library).containsDirectoriesWithClasses()) {
for (VirtualFile classesRoot : library.getFiles(OrderRootType.CLASSES)) {
if (classesRoot.isInLocalFileSystem()) {
archive.addOrFindChild(factory.createDirectoryCopyWithParentDirectories(classesRoot.getPath(), "/"));
}
else {
final PackagingElement<?> child = factory.createFileCopyWithParentDirectories(PathUtil.getLocalFile(classesRoot).getPath(), "/");
root.addOrFindChild(child);
classpath.addAll(ManifestFileUtil.getClasspathForElements(Collections.singletonList(child), myContext, PlainArtifactType.getInstance()));
}
}
}
else {
final List<? extends PackagingElement<?>> children = factory.createLibraryElements(library);
classpath.addAll(ManifestFileUtil.getClasspathForElements(children, myContext, PlainArtifactType.getInstance()));
root.addOrFindChildren(children);
}
}
}
开发者ID:consulo,项目名称:consulo-java,代码行数:25,代码来源:JarFromModulesTemplate.java
示例14: addExtractedLibrariesToJar
import com.intellij.packaging.elements.PackagingElementFactory; //导入依赖的package包/类
private static void addExtractedLibrariesToJar(CompositePackagingElement<?> archive, PackagingElementFactory factory, Set<Library> libraries) {
for (Library library : libraries) {
if (LibraryPackagingElement.getKindForLibrary(library).containsJarFiles()) {
for (VirtualFile classesRoot : library.getFiles(OrderRootType.CLASSES)) {
if (classesRoot.isInLocalFileSystem()) {
archive.addOrFindChild(factory.createDirectoryCopyWithParentDirectories(classesRoot.getPath(), "/"));
}
else {
archive.addOrFindChild(factory.createExtractedDirectory(classesRoot));
}
}
}
else {
archive.addOrFindChildren(factory.createLibraryElements(library));
}
}
}
开发者ID:consulo,项目名称:consulo-java,代码行数:19,代码来源:JarFromModulesTemplate.java
示例15: actionPerformed
import com.intellij.packaging.elements.PackagingElementFactory; //导入依赖的package包/类
@Override
public void actionPerformed(AnActionEvent event) {
Project project = event.getProject();
if (project == null) {
show("There isn't a project!", NotificationType.ERROR);
return;
}
Module module = findModule(event);
if (module == null) return;
String name = module.getName();
ArtifactManager manager = ArtifactManager.getInstance(project);
Artifact searchArtifact = manager.findArtifact(name);
if (searchArtifact != null) {
show("An artifact with this name already exists!", NotificationType.ERROR);
return;
}
ArtifactType type = ArtifactType.findById("jar");
if (type == null) {
show("Error: Cannot find artifact type!", NotificationType.ERROR);
return;
}
PackagingElementFactory elementFactory = PackagingElementFactory.getInstance();
CompositePackagingElement<?> packagingElement = elementFactory.createArchive(name + ".jar");
packagingElement.addOrFindChild(elementFactory.createModuleOutput(module));
Artifact artifact = manager.addArtifact(name, type, packagingElement);
if (artifact instanceof ModifiableArtifact) {
ModifiableArtifact modArtifact = (ModifiableArtifact) artifact;
modArtifact.setBuildOnMake(true);
}
show("Artifact with name \"" + name + "\" created!");
}
开发者ID:LukWebsForge,项目名称:FastArtifact,代码行数:37,代码来源:CreateArtifact.java
示例16: replaceElement
import com.intellij.packaging.elements.PackagingElementFactory; //导入依赖的package包/类
@Override
public void replaceElement(final ProjectStructureElement newElement) {
Library library = ((LibraryProjectStructureElement)newElement).getLibrary();
PackagingElement<?> newLibraryElement = PackagingElementFactory.getInstance().createLibraryFiles(library.getName(),
library.getTable().getTableLevel(),
null);
replaceElement(newLibraryElement);
}
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:9,代码来源:UsageInArtifact.java
示例17: actionPerformed
import com.intellij.packaging.elements.PackagingElementFactory; //导入依赖的package包/类
@Override
public void actionPerformed(AnActionEvent e) {
final DefaultActionGroup group = new DefaultActionGroup();
for (PackagingElementType type : PackagingElementFactory.getInstance().getAllElementTypes()) {
group.add(new AddNewPackagingElementAction((PackagingElementType<?>)type, myArtifactEditor));
}
final DataContext dataContext = e.getDataContext();
final ListPopup popup = JBPopupFactory.getInstance().createActionGroupPopup("Add", group, dataContext, JBPopupFactory.ActionSelectionAid.SPEEDSEARCH, false);
popup.showInBestPositionFor(dataContext);
}
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:11,代码来源:ShowAddPackagingElementPopupAction.java
示例18: putIntoDefaultLocations
import com.intellij.packaging.elements.PackagingElementFactory; //导入依赖的package包/类
public void putIntoDefaultLocations(@NotNull final List<? extends PackagingSourceItem> items) {
final List<PackagingElement<?>> toSelect = new ArrayList<PackagingElement<?>>();
editLayout(new Runnable() {
@Override
public void run() {
final CompositePackagingElement<?> rootElement = getArtifact().getRootElement();
final ArtifactType artifactType = getArtifact().getArtifactType();
for (PackagingSourceItem item : items) {
final String path = artifactType.getDefaultPathFor(item);
if (path != null) {
final CompositePackagingElement<?> parent;
if (path.endsWith(URLUtil.JAR_SEPARATOR)) {
parent = PackagingElementFactory.getInstance().getOrCreateArchive(rootElement, StringUtil.trimEnd(path, URLUtil.JAR_SEPARATOR));
}
else {
parent = PackagingElementFactory.getInstance().getOrCreateDirectory(rootElement, path);
}
final List<? extends PackagingElement<?>> elements = item.createElements(myContext);
toSelect.addAll(parent.addOrFindChildren(elements));
}
}
}
});
myArtifactsEditor.getSourceItemsTree().rebuildTree();
updateAndSelect(myTree.getRootPackagingNode(), toSelect);
}
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:28,代码来源:LayoutTreeComponent.java
示例19: putElements
import com.intellij.packaging.elements.PackagingElementFactory; //导入依赖的package包/类
public void putElements(@NotNull final String path, @NotNull final List<? extends PackagingElement<?>> elements) {
final List<PackagingElement<?>> toSelect = new ArrayList<PackagingElement<?>>();
editLayout(new Runnable() {
@Override
public void run() {
final CompositePackagingElement<?> directory =
PackagingElementFactory.getInstance().getOrCreateDirectory(getArtifact().getRootElement(), path);
toSelect.addAll(directory.addOrFindChildren(elements));
}
});
myArtifactsEditor.getSourceItemsTree().rebuildTree();
updateAndSelect(myTree.getRootPackagingNode(), toSelect);
}
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:14,代码来源:LayoutTreeComponent.java
示例20: loadState
import com.intellij.packaging.elements.PackagingElementFactory; //导入依赖的package包/类
@Override
public void loadState(ArtifactEditorSettingsState state) {
mySortElements = state.mySortElements;
myTypesToShowContent.clear();
for (String id : state.myTypesToShowContentIds) {
final PackagingElementType<?> type = PackagingElementFactory.getInstance().findElementType(id);
if (type instanceof ComplexPackagingElementType<?>) {
myTypesToShowContent.add((ComplexPackagingElementType<?>)type);
}
}
}
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:12,代码来源:ArtifactEditorSettings.java
注:本文中的com.intellij.packaging.elements.PackagingElementFactory类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论