consulo.roots.ModifiableModuleRootLayer Java Examples

The following examples show how to use consulo.roots.ModifiableModuleRootLayer. 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: RootModelImpl.java    From consulo with Apache License 2.0 6 votes vote down vote up
@Nonnull
@Override
public ModifiableModuleRootLayer addLayer(@Nonnull String name, @Nullable String nameForCopy, boolean activate) {
  ModuleRootLayerImpl moduleRootLayer = myLayers.get(name);
  if (moduleRootLayer != null) {
    return moduleRootLayer;
  }

  ModuleRootLayerImpl layer = new ModuleRootLayerImpl(null, this);

  if (nameForCopy != null) {
    ModuleRootLayerImpl original = myLayers.get(nameForCopy);
    if (original != null) {
      original.copy(layer, false);
    }
  }
  myLayers.put(name, layer);
  if (activate) {
    setCurrentLayerSafe(name);
  }
  return layer;
}
 
Example #2
Source File: FileOrDirectoryDependencyTabContext.java    From consulo with Apache License 2.0 6 votes vote down vote up
private Library createLibraryFromRoots(ModifiableModuleRootLayer layer, List<OrderRoot> roots, @Nullable final LibraryType libraryType) {
  final LibraryTable.ModifiableModel moduleLibraryModel = layer.getModuleLibraryTable().getModifiableModel();

  final PersistentLibraryKind kind = libraryType == null ? null : libraryType.getKind();
  final Library library = ((LibraryTableBase.ModifiableModelEx)moduleLibraryModel).createLibrary(null, kind);
  final LibraryEx.ModifiableModelEx libModel = (LibraryEx.ModifiableModelEx)library.getModifiableModel();

  for (OrderRoot root : roots) {
    if (root.isJarDirectory()) {
      libModel.addJarDirectory(root.getFile(), false, root.getType());
    }
    else {
      libModel.addRoot(root.getFile(), root.getType());
    }
  }
  libModel.commit();
  return library;
}
 
Example #3
Source File: RootModelImpl.java    From consulo with Apache License 2.0 5 votes vote down vote up
@Nullable
@Override
public ModifiableModuleRootLayer setCurrentLayer(@Nonnull String name) {
  assertWritable();
  ModuleRootLayerImpl moduleRootLayer = myLayers.get(name);
  if (moduleRootLayer == null) {
    return null;
  }
  myCurrentLayerName = name;
  myCachedCurrentLayer = moduleRootLayer;
  return moduleRootLayer;
}
 
Example #4
Source File: ModuleDependencyTabContext.java    From consulo with Apache License 2.0 5 votes vote down vote up
@Override
public List<OrderEntry> createOrderEntries(@Nonnull ModifiableModuleRootLayer layer, DialogWrapper dialogWrapper) {
  Object[] selectedValues = myModuleList.getSelectedValues();
  List<OrderEntry> orderEntries = new ArrayList<OrderEntry>(selectedValues.length);
  for (Object selectedValue : selectedValues) {
    orderEntries.add(layer.addModuleOrderEntry((Module)selectedValue));
  }
  return orderEntries;
}
 
Example #5
Source File: AddModuleDependencyTabContext.java    From consulo with Apache License 2.0 5 votes vote down vote up
public final void processAddOrderEntries(DialogWrapper dialogWrapper) {
  ModifiableModuleRootLayer currentLayer = (ModifiableModuleRootLayer)myClasspathPanel.getRootModel().getCurrentLayer();

  List<OrderEntry> orderEntries = createOrderEntries(currentLayer, dialogWrapper);
  if(orderEntries.isEmpty()) {
    return;
  }

  List<ClasspathTableItem<?>> items = new ArrayList<ClasspathTableItem<?>>(orderEntries.size());
  for (OrderEntry orderEntry : orderEntries) {
    ClasspathTableItem<?> item = ClasspathTableItem.createItem(orderEntry, myContext);
    items.add(item);
  }
  myClasspathPanel.addItems(items);
}
 
Example #6
Source File: FileOrDirectoryDependencyTabContext.java    From consulo with Apache License 2.0 5 votes vote down vote up
private List<OrderRoot> filterAlreadyAdded(ModifiableModuleRootLayer layer, final List<OrderRoot> roots) {
  if (roots == null || roots.isEmpty()) {
    return Collections.emptyList();
  }

  final List<OrderRoot> result = new ArrayList<OrderRoot>();
  final Library[] libraries = layer.getModuleLibraryTable().getLibraries();
  for (OrderRoot root : roots) {
    if (!isIncluded(root, libraries)) {
      result.add(root);
    }
  }
  return result;
}
 
Example #7
Source File: ModuleExtensionImpl.java    From consulo with Apache License 2.0 4 votes vote down vote up
@Nonnull
@Override
public ModifiableModuleRootLayer getModuleRootLayer() {
  return (ModifiableModuleRootLayer)myModuleRootLayer;
}
 
Example #8
Source File: MutableModuleExtension.java    From consulo with Apache License 2.0 4 votes vote down vote up
@Override
@Nonnull
ModifiableModuleRootLayer getModuleRootLayer();
 
Example #9
Source File: ModifiableRootModel.java    From consulo with Apache License 2.0 4 votes vote down vote up
@Nonnull
ModifiableModuleRootLayer addLayer(@Nonnull String name, @javax.annotation.Nullable String nameForCopy, boolean activate);
 
Example #10
Source File: ModifiableRootModel.java    From consulo with Apache License 2.0 4 votes vote down vote up
@javax.annotation.Nullable()
ModifiableModuleRootLayer setCurrentLayer(@Nonnull String name);
 
Example #11
Source File: ExtensionEditor.java    From consulo with Apache License 2.0 4 votes vote down vote up
@RequiredUIAccess
public void extensionChanged(MutableModuleExtension extension) {
  final JComponent secondComponent = myConfigurablePanelExtension != extension ? null : mySplitter.getSecondComponent();
  if (secondComponent == null && extension.isEnabled() || secondComponent != null && !extension.isEnabled()) {
    updateSecondComponent(!extension.isEnabled() ? null : extension);
  }

  if (extension instanceof ModuleExtensionWithSdk) {
    // we using module layer, dont use modifiable model - it ill proxy, and methods 'addModuleExtensionSdkEntry' && 'removeOrderEntry'
    // ill call this method again
    ModifiableModuleRootLayer moduleRootLayer = extension.getModuleRootLayer();

    final ModuleExtensionWithSdkOrderEntry sdkOrderEntry = moduleRootLayer.findModuleExtensionSdkEntry(extension);
    if (!extension.isEnabled() && sdkOrderEntry != null) {
      moduleRootLayer.removeOrderEntry(sdkOrderEntry);
    }

    if (extension.isEnabled()) {
      final ModuleExtensionWithSdk sdkExtension = (ModuleExtensionWithSdk)extension;
      if (!sdkExtension.getInheritableSdk().isNull()) {
        if (sdkOrderEntry == null) {
          moduleRootLayer.addModuleExtensionSdkEntry(sdkExtension);
        }
        else {
          final ModuleExtensionWithSdk<?> moduleExtension = sdkOrderEntry.getModuleExtension();
          if (moduleExtension != null && !Comparing.equal(sdkExtension.getInheritableSdk(), moduleExtension.getInheritableSdk())) {
            moduleRootLayer.addModuleExtensionSdkEntry(sdkExtension);
          }
        }
      }
      else if (sdkOrderEntry != null) {
        moduleRootLayer.removeOrderEntry(sdkOrderEntry);
      }
    }
  }

  for (PsiPackageSupportProvider supportProvider : PsiPackageSupportProvider.EP_NAME.getExtensionList()) {
    final Module module = extension.getModule();
    if (supportProvider.isSupported(extension)) {
      PsiPackageManager.getInstance(module.getProject()).dropCache(extension.getClass());
    }
  }

  myClasspathEditor.moduleStateChanged();
  myContentEntriesEditor.moduleStateChanged();
  myOutputEditor.moduleStateChanged();
}
 
Example #12
Source File: AddModuleDependencyTabContext.java    From consulo with Apache License 2.0 4 votes vote down vote up
public List<OrderEntry> createOrderEntries(@Nonnull ModifiableModuleRootLayer layer, DialogWrapper dialogWrapper) {
  return Collections.emptyList();
}