コード例 #1
0
 /**
  * PDE editors should call this during their creation.
  *
  * <p>Currently the pde editor superclass (PDEFormEditor) connects during its createPages method
  * and so this method does not need to be invoked anywhere else.
  *
  * @param editor the editor to connect to
  */
 public static void connect(PDEFormEditor editor) {
   IProject project = editor.getCommonProject();
   if (project == null) return;
   if (fOpenPDEEditors.containsKey(project)) {
     ArrayList list = (ArrayList) fOpenPDEEditors.get(project);
     if (!list.contains(editor)) list.add(editor);
   } else {
     ArrayList list = new ArrayList();
     list.add(editor);
     fOpenPDEEditors.put(project, list);
   }
 }
コード例 #2
0
 /**
  * PDE editors should call this when they are closing down.
  *
  * @param editor the pde editor to disconnect from
  */
 public static void disconnect(PDEFormEditor editor) {
   IProject project = editor.getCommonProject();
   if (project == null) {
     // getCommonProject will return null when project is deleted with editor open - bug 226788
     // Solution is to use editor input if it is a FileEditorInput.
     IEditorInput input = editor.getEditorInput();
     if (input != null && input instanceof FileEditorInput) {
       FileEditorInput fei = (FileEditorInput) input;
       IFile file = fei.getFile();
       project = file.getProject();
     }
   }
   if (project == null) return;
   if (!fOpenPDEEditors.containsKey(project)) return;
   ArrayList list = (ArrayList) fOpenPDEEditors.get(project);
   list.remove(editor);
   if (list.size() == 0) fOpenPDEEditors.remove(project);
 }