consulo.util.pointers.Named Java Examples

The following examples show how to use consulo.util.pointers.Named. 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: SchemesManagerImpl.java    From consulo with Apache License 2.0 6 votes vote down vote up
@Nonnull
private String checkFileNameIsFree(@Nonnull String subPath, @Nonnull String schemeName) {
  for (Named scheme : mySchemes) {
    if (scheme instanceof ExternalizableScheme) {
      String name = ((ExternalizableScheme)scheme).getExternalInfo().getCurrentFileName();
      if (name != null &&
          !schemeName.equals(scheme.getName()) &&
          subPath.length() == (name.length() + mySchemeExtension.length()) &&
          subPath.startsWith(name) &&
          subPath.endsWith(mySchemeExtension)) {
        return UniqueNameGenerator.generateUniqueName(FileUtil.sanitizeName(schemeName), collectAllFileNames());
      }
    }
  }
  return subPath;
}
 
Example #2
Source File: SchemesToImportPopup.java    From consulo with Apache License 2.0 5 votes vote down vote up
@Override
public Component getListCellRendererComponent(@Nonnull JList list, Object val, int i, boolean isSelected, boolean cellHasFocus) {
  Named c = (Named)val;
  myNameLabel.setText(c.getName());

  updateColors(isSelected);
  return myPanel;
}
 
Example #3
Source File: SchemesManagerFactoryImpl.java    From consulo with Apache License 2.0 5 votes vote down vote up
@Override
public <T extends Named, E extends ExternalizableScheme> SchemesManager<T, E> createSchemesManager(final String fileSpec,
                                                                                                    final SchemeProcessor<E> processor,
                                                                                                    final RoamingType roamingType) {
  final Application application = ApplicationManager.getApplication();
  if (!(application instanceof ApplicationEx2)) return null;
  String baseDirPath = ((ApplicationEx2)application).getStateStore().getStateStorageManager().expandMacros(fileSpec);

  StreamProvider
          provider = ((ApplicationEx2)ApplicationManager.getApplication()).getStateStore().getStateStorageManager().getStreamProvider();
  SchemesManagerImpl<T, E> manager = new SchemesManagerImpl<T, E>(fileSpec, processor, roamingType, provider, new File(baseDirPath));
  myRegisteredManagers.add(manager);
  return manager;
}
 
Example #4
Source File: SchemeImporterEP.java    From consulo with Apache License 2.0 5 votes vote down vote up
/**
 * Finds extensions supporting the given <code>schemeClass</code>
 * @param schemeClass The class of the scheme to search extensions for.
 * @return A collection of importers capable of importing schemes of the given class. An empty collection is returned if there are
 *         no matching importers.
 */
@Nonnull
public static <S extends Named> Collection<SchemeImporterEP<S>> getExtensions(Class<S> schemeClass) {
  List<SchemeImporterEP<S>> importers = new ArrayList<SchemeImporterEP<S>>();
  for (SchemeImporterEP<?> importerEP : EP_NAME.getExtensions()) {
    if (schemeClass.getName().equals(importerEP.schemeClass)) {
      //noinspection unchecked
      importers.add((SchemeImporterEP<S>)importerEP);
    }
  }
  return importers;
}
 
Example #5
Source File: SchemeImporterEP.java    From consulo with Apache License 2.0 5 votes vote down vote up
/**
 * Find an importer for the given name and scheme class. It is allowed for importers to have the same name but different scheme classes.
 * @param name        The importer name as defined in plug-in configuration.
 * @param schemeClass The scheme class the importer has to support.
 * @return The found importer or null if there are no importers for the given name and scheme class.
 */
@Nullable
public static <S extends Named> SchemeImporter<S> getImporter(@Nonnull String name, Class<S> schemeClass) {
  for (SchemeImporterEP<S> importerEP : getExtensions(schemeClass)) {
    if (name.equals(importerEP.name)) {
      return importerEP.getInstance();
    }
  }
  return null;
}
 
Example #6
Source File: SchemesManagerImpl.java    From consulo with Apache License 2.0 5 votes vote down vote up
@Override
protected void schemeDeleted(@Nonnull Named scheme) {
  super.schemeDeleted(scheme);

  if (scheme instanceof ExternalizableScheme) {
    ContainerUtilRt.addIfNotNull(myFilesToDelete, ((ExternalizableScheme)scheme).getExternalInfo().getCurrentFileName());
  }
}
 
Example #7
Source File: EmptyModuleInheritableNamedPointer.java    From consulo-unity3d with Apache License 2.0 4 votes vote down vote up
@Nonnull
@SuppressWarnings("unchecked")
public static <T extends Named> EmptyModuleInheritableNamedPointer<T> empty()
{
	return ourInstance;
}
 
Example #8
Source File: MockSchemesManagerFactory.java    From consulo with Apache License 2.0 4 votes vote down vote up
@Override
public <T extends Named,E extends ExternalizableScheme> SchemesManager<T,E> createSchemesManager(final String fileSpec,
                                                                 final SchemeProcessor<E> processor, final RoamingType roamingType) {
  return new EmptySchemesManager();
}
 
Example #9
Source File: SchemesManagerFactory.java    From consulo with Apache License 2.0 4 votes vote down vote up
public abstract <T extends Named, E extends ExternalizableScheme> SchemesManager<T,E> createSchemesManager(String fileSpec, SchemeProcessor<E> processor,
RoamingType roamingType);
 
Example #10
Source File: ShareSchemeDialog.java    From consulo with Apache License 2.0 4 votes vote down vote up
public void init(Named scheme){
  myShareSchemePanel.setName(scheme.getName());
}
 
Example #11
Source File: EmptySchemesManager.java    From consulo with Apache License 2.0 4 votes vote down vote up
@Override
public void addNewScheme(@Nonnull final Named scheme, final boolean replaceExisting) {
}
 
Example #12
Source File: EmptySchemesManager.java    From consulo with Apache License 2.0 4 votes vote down vote up
@Override
public Named findSchemeByName(@Nonnull String schemeName) {
  return null;
}
 
Example #13
Source File: EmptySchemesManager.java    From consulo with Apache License 2.0 4 votes vote down vote up
@Override
public Named getCurrentScheme() {
  return null;
}
 
Example #14
Source File: EmptySchemesManager.java    From consulo with Apache License 2.0 4 votes vote down vote up
@Override
public void removeScheme(@Nonnull Named scheme) {
}
 
Example #15
Source File: AbstractSchemesManager.java    From consulo with Apache License 2.0 4 votes vote down vote up
protected void checkCurrentScheme(@Nonnull Named scheme) {
  if (myCurrentScheme == null && Objects.equals(scheme.getName(), myCurrentSchemeName)) {
    //noinspection unchecked
    myCurrentScheme = (T)scheme;
  }
}
 
Example #16
Source File: AbstractSchemesManager.java    From consulo with Apache License 2.0 4 votes vote down vote up
protected void schemeDeleted(@Nonnull Named scheme) {
  if (myCurrentScheme == scheme) {
    myCurrentScheme = null;
  }
}