コード例 #1
0
 private static PDEFormEditor getOpenEditor(IProject project, String editorId) {
   ArrayList list = (ArrayList) fOpenPDEEditors.get(project);
   if (list == null) return null;
   for (int i = 0; i < list.size(); i++) {
     PDEFormEditor editor = (PDEFormEditor) list.get(i);
     if (editor.getEditorSite().getId().equals(editorId)) return editor;
   }
   return null;
 }
コード例 #2
0
 private static PDEFormEditor getOpenEditor(String editorID, String inputContextID, IFile file) {
   // Get the file's project
   IProject project = file.getProject();
   // Check for open editors housed in the specified project
   ArrayList list = (ArrayList) fOpenPDEEditors.get(project);
   // No open editors found
   if (list == null) {
     return null;
   }
   // Get the open editor whose
   // (1) Editor ID matches the specified editor ID
   // (2) Underlying file matches the specified file
   // Check all open editors
   for (int i = 0; i < list.size(); i++) {
     // Get the editor
     PDEFormEditor editor = (PDEFormEditor) list.get(i);
     // Check for the specified type
     // Get the editor ID
     String currentEditorID = editor.getEditorSite().getId();
     if (currentEditorID.equals(editorID) == false) {
       continue;
     }
     // Check for the specified file
     // Find the editor's input context
     InputContext context = editor.getContextManager().findContext(inputContextID);
     // Ensure we have an input context
     if (context == null) {
       continue;
     }
     // Get the editor input
     IEditorInput input = context.getInput();
     // Ensure we have a file editor input
     if ((input instanceof IFileEditorInput) == false) {
       continue;
     }
     // Get the editor's underlying file
     IFile currentFile = ((IFileEditorInput) input).getFile();
     // If the file matches the specified file, we have found the
     // specified editor
     if (currentFile.equals(file)) {
       return editor;
     }
   }
   return null;
 }