WOComponent Editor

From: Greg (ghuland..ramedphotographics.com)
Date: Wed Aug 31 2005 - 22:50:48 EDT


I have tracked down why I was not able to use the new component
editor. If you have a /bin directory in the project path with the
incremental builder, it causes the creation of the editor to fail. I
worked around this by filtering out any entries returned when
searching for a particular file. I don't know whether this is the
best way to do it, but it does work. Would it be better to filter it
at the WorkbenchUtilities plugin level? Does any wolips component
require the knowledge of anything in the bin directory?

Greg

/* filter out /bin entries */
     public static List removeBinEntries(List l) {
         List ret = new ArrayList();
         for (int i = 0; i < l.size(); i++) {
             IFile f = (IFile)l.get(i);
             String path = f.getFullPath().toOSString();
             if (path.indexOf("/bin/") == -1)
                 ret.add(f);
         }
         return ret;
     }
     /*
      * may return null
      */
     public static ComponentEditorInput createWithDotJava(IFile file) {
         IProject project = file.getProject();
         String ids[] = null;
         IEditorInput allInput[] = null;
         String fileName = file.getName().substring(0,
                 file.getName().length() - 5);
         List htmlResources = ComponentEditorInput.removeBinEntries
(WorkbenchUtilitiesPlugin
                 .findResourcesInProjectByNameAndExtensions(project,
fileName,
                         new String[] { "html" }, false));
         if (htmlResources == null || htmlResources.size() != 1) {
             return null;
         }
         List wodResources = ComponentEditorInput.removeBinEntries
(WorkbenchUtilitiesPlugin
                 .findResourcesInProjectByNameAndExtensions(project,
fileName,
                         new String[] { "wod" }, false));

         if (wodResources == null || wodResources.size() != 1) {
             return null;
         }
         List apiResources = ComponentEditorInput.removeBinEntries
(WorkbenchUtilitiesPlugin
                 .findResourcesInProjectByNameAndExtensions(project,
fileName,
                         new String[] { "api" }, false));

         if (apiResources == null || apiResources.size() != 1) {
             ids = new String[3];
             allInput = new IEditorInput[3];
         } else {
             ids = new String[4];
             allInput = new IEditorInput[4];
         }
         ids[0] = JavaUI.ID_CU_EDITOR;
         allInput[0] = new FileEditorInput(file);
         ids[1] = WodclipsePlugin.HTMLEditorID;
         allInput[1] = new FileEditorInput(((IFile) htmlResources.get
(0)));
         ids[2] = WodclipsePlugin.WODEditorID;
         allInput[2] = new FileEditorInput(((IFile) wodResources.get
(0)));
         if (apiResources != null && apiResources.size() == 1) {
             ids[3] = WodclipsePlugin.ApiEditorID;
             allInput[3] = new ApiEditorInput(((IFile)
apiResources.get(0)));
         }
         ComponentEditorInput input = new ComponentEditorInput(ids,
allInput);

         return input;
     }



This archive was generated by hypermail 2.0.0 : Wed Aug 31 2005 - 22:51:32 EDT