Package org.eclipse.core.resources

Examples of org.eclipse.core.resources.IStorage


   */
  protected void updateCache(IStorageEditorInput input) throws CoreException {
    StorageInfo info= (StorageInfo) getElementInfo(input);
    if (info != null) {
      try {
        IStorage storage= input.getStorage();
        if (storage != null) {
          boolean readOnly= storage.isReadOnly();
          info.fIsReadOnly=  readOnly;
          info.fIsModifiable= !readOnly;
        }
      } catch (CoreException x) {
        handleCoreException(x, TextEditorMessages.StorageDocumentProvider_updateCache);
View Full Code Here


   * @see org.eclipse.ui.texteditor.IDocumentProviderExtension4#getContentType(java.lang.Object)
   * @since 3.1
   */
  public IContentType getContentType(Object element) throws CoreException {
    if (element instanceof IStorageEditorInput) {
      IStorage storage= ((IStorageEditorInput) element).getStorage();
      Reader reader= null;
      InputStream stream= null;
      try {
        IContentDescription desc;
        IDocument document= getDocument(element);
        if (document != null) {
          reader= new DocumentReader(document);
          desc= Platform.getContentTypeManager().getDescriptionFor(reader, storage.getName(), NO_PROPERTIES);
        } else {
          stream= storage.getContents();
          desc= Platform.getContentTypeManager().getDescriptionFor(stream, storage.getName(), NO_PROPERTIES);
        }
        if (desc != null && desc.getContentType() != null)
          return desc.getContentType();
      } catch (IOException x) {
        IPath path= storage.getFullPath();
        String name;
        if (path != null)
          name= path.toOSString();
        else
          name= storage.getName();
        String message;
        if (name != null)
          message= NLSUtility.format(TextEditorMessages.StorageDocumentProvider_getContentDescriptionFor, name);
        else
          message= TextEditorMessages.StorageDocumentProvider_getContentDescription;
View Full Code Here

   * @return the persisted encoding
   * @since 2.1
   */
  protected String getPersistedEncoding(Object element) {
    if (element instanceof IStorageEditorInput) {
      IStorage storage;
      try {
        storage= ((IStorageEditorInput)element).getStorage();
        if (storage instanceof IEncodedStorage)
          return ((IEncodedStorage)storage).getCharset();
      } catch (CoreException e) {
View Full Code Here

              if (varName.equals(vars[i].getName())) {
                // ok we found.
                if (vars[i].getMode() == IVariableInfo.RESOURCEBUNDLE) {
                  String resourceName = vars[i]
                      .getTypeInfoString();
                  IStorage s = null;
                  try {
                    s = LoadBundleUtil
                        .getLoadBundleResource(_prj,
                            resourceName);
                  } catch (CoreException ex) {
                    // "Error"
                    _log
                        .info(
                            "PageExpressionContext.Info.0", ex); //$NON-NLS-1$
                  }
                  if (s == null) {
                    throw new ELException();
                  }
                  InputStream input = null;
                  try {
                    input = new BufferedInputStream(s
                        .getContents());
                    Properties p = new Properties();
                    p.load(input);
                    return p;
                  } catch (CoreException e) {
View Full Code Here

    //Bug 306811 - Invalid error "messages not found in classpath for project"
    private ISymbol createSymbolForResourceBundleInJAR(IProject project, final String name, final String basename) {
      IComponentSymbol symbol = null;
      InputStream in = null;
      try {
        final IStorage storage = LoadBundleUtil.getLoadBundleResource(project, basename);
        if (storage != null) {
          in = storage.getContents();
          Properties props = new Properties();
          props.load(in);
          final IMapTypeDescriptor typeDesc = SymbolFactory.eINSTANCE.createIMapTypeDescriptor();
          typeDesc.setMapSource(props);
          symbol = SymbolFactory.eINSTANCE.createIComponentSymbol();
View Full Code Here

        location = path.toString();
      }
    }
    if (location == null) {
      try {
        IStorage storage = input.getStorage();
        if (storage != null) {
          IPath storagePath = storage.getFullPath();
          String name = storage.getName();
          if (storagePath != null) {
            /*
             * If the path's last segment and the name are
             * different, the IStorage contract is not being
             * honored
 
View Full Code Here

        path = ipath.toString();
      }
    }
    if (path == null) {
      try {
        IStorage storage = input.getStorage();
        if (storage != null) {
          IPath storagePath = storage.getFullPath();
          String name = storage.getName();
          if (storagePath != null) {
            // If they are different, the IStorage contract is not
            // being honored
            // (https://bugs.eclipse.org/bugs/show_bug.cgi?id=73098).
            // Favor the name.
View Full Code Here

   * @see org.eclipse.ui.editors.text.StorageDocumentProvider#getPersistedEncoding(java.lang.Object)
   */
  protected String getPersistedEncoding(Object element) {
    String charset = super.getPersistedEncoding(element);
    if (charset == null && element instanceof IStorageEditorInput) {
      IStorage storage;
      try {
        storage = ((IStorageEditorInput) element).getStorage();
        if (storage != null && !(storage instanceof IEncodedStorage)) {
          InputStream contents = null;
          try {
            contents = storage.getContents();
            if (contents != null) {
              QualifiedName[] detectionOptions = new QualifiedName[]{IContentDescription.BYTE_ORDER_MARK, IContentDescription.CHARSET};
              IContentDescription description = Platform.getContentTypeManager().getDescriptionFor(contents, storage.getName(), detectionOptions);
              if (description != null) {
                charset = description.getCharset();
              }
            }

View Full Code Here

  public boolean isValidValue( String value )
  {
    try
    {
      IProject project = getProject();
      IStorage bundle = LoadBundleUtil.getLoadBundleResource( project , value );
      if( bundle != null )
      {
        return true;
      }
    }
View Full Code Here

  public static IStorage getLoadBundleResource(final IProject project,
      final String baseName) throws CoreException {
    if (project == null || baseName == null) {
      return null;
    }
    IStorage loadBundleResource = null;
    if (project.hasNature(JavaCore.NATURE_ID)) {
      IJavaProject javaProject = JavaCore.create(project);
      IFile sourceFile = getSourceFile(javaProject, baseName);
      if (sourceFile == null || !sourceFile.exists()) {
        loadBundleResource = getJarFile(javaProject, baseName);
View Full Code Here

TOP

Related Classes of org.eclipse.core.resources.IStorage

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.