/**
  * Determines if file is jsp fragment or not (does a deep, indepth check, looking into contents of
  * file)
  *
  * @param file assumes file is not null and exists
  * @return true if file is jsp fragment, false otherwise
  */
 private boolean isFragment(IFile file) {
   // copied from JSPValidator
   boolean isFragment = false;
   InputStream is = null;
   try {
     IContentDescription contentDescription = file.getContentDescription();
     // it can be null
     if (contentDescription == null) {
       is = file.getContents();
       contentDescription =
           Platform.getContentTypeManager()
               .getDescriptionFor(
                   is, file.getName(), new QualifiedName[] {IContentDescription.CHARSET});
     }
     if (contentDescription != null) {
       String fileCtId = contentDescription.getContentType().getId();
       isFragment =
           (fileCtId != null && ContentTypeIdForJSP.ContentTypeID_JSPFRAGMENT.equals(fileCtId));
     }
   } catch (IOException e) {
     // ignore, assume it's invalid JSP
   } catch (CoreException e) {
     // ignore, assume it's invalid JSP
   } finally {
     // must close input stream in case others need it
     if (is != null)
       try {
         is.close();
       } catch (Exception e) {
         // not sure how to recover at this point
       }
   }
   return isFragment;
 }
  private void open(IFile file) {
    IWorkbenchWindow dw = FMUIPlugin.getDefault().getWorkbench().getActiveWorkbenchWindow();
    IWorkbenchPage page = dw.getActivePage();
    if (page != null) {
      IContentType contentType = null;
      try {
        IContentDescription description = file.getContentDescription();
        if (description != null) {
          contentType = description.getContentType();
        }
        IEditorDescriptor desc = null;
        if (contentType != null) {
          desc =
              PlatformUI.getWorkbench()
                  .getEditorRegistry()
                  .getDefaultEditor(file.getName(), contentType);
        } else {
          desc = PlatformUI.getWorkbench().getEditorRegistry().getDefaultEditor(file.getName());
        }

        if (desc != null) {
          page.openEditor(new FileEditorInput(file), desc.getId());
        }
      } catch (CoreException e) {
        FMUIPlugin.getDefault().logError(e);
      }
    }
  }
 protected boolean isValid(IResource resource) throws CoreException {
   if (resource instanceof IFile) {
     IFile file = (IFile) resource;
     if (!file.isSynchronized(0)) {
       // In case the resource has been updated, refresh it
       file.refreshLocal(0, null);
     }
     if (file.getContentDescription() != null
         && file.getContentDescription().getContentType() != null
         && KickstartFormMemoryModel.KICKSTART_FORM_CONTENT_TYPE.equals(
             file.getContentDescription().getContentType().getId())) {
       return true;
     }
   } else if (resource instanceof IFolder) {
     return !resource.isDerived() && !resource.isHidden();
   }
   return false;
 }
 private void findFiles(File folder) throws CoreException {
   // ignore the target folder
   if (folder.getName().equalsIgnoreCase("target")
       && folder.getParentFile().getName().equalsIgnoreCase(project.getName())) return;
   File[] files = folder.listFiles();
   if (files != null) {
     for (File f : files) {
       if (f.isDirectory()) {
         findFiles(f);
       } else {
         IFile ifile =
             ResourcesPlugin.getWorkspace().getRoot().findFilesForLocationURI(f.toURI())[0];
         if (ifile.getContentDescription() != null
             && ifile
                 .getContentDescription()
                 .getContentType()
                 .getId()
                 .equals("org.fusesource.ide.camel.editor.camelContentType")) {
           addCamelFile(new CamelVirtualFile((org.eclipse.core.internal.resources.File) ifile));
         }
       }
     }
   }
 }