コード例 #1
0
ファイル: DLTKUIPlugin.java プロジェクト: earlyster/dltk.core
  /** This method is called upon plug-in activation */
  public void start(BundleContext context) throws Exception {
    super.start(context);

    WorkingCopyOwner.setPrimaryBufferProvider(
        new WorkingCopyOwner() {
          public IBuffer createBuffer(ISourceModule workingCopy) {
            ISourceModule original = workingCopy.getPrimary();
            IResource resource = original.getResource();
            if (resource != null) {
              if (resource instanceof IFile) {
                return new DocumentAdapter(workingCopy, (IFile) resource);
              }
            } else if (original instanceof IExternalSourceModule) {
              IProjectFragment fragment =
                  (IProjectFragment) original.getAncestor(IModelElement.PROJECT_FRAGMENT);
              if (!fragment.isArchive()) {
                // IPath path = original.getPath();
                // return new DocumentAdapter(workingCopy, path);
                return BufferManager.createBuffer(original);
              }
              return BufferManager.createBuffer(original);
            }

            if (original instanceof DBGPSourceModule) {
              return BufferManager.createBuffer(original);
            }

            if (original instanceof BuiltinSourceModule) {
              // IPath path = original.getPath();
              // return new DocumentAdapter(workingCopy, path);
              return BufferManager.createBuffer(original);
            }
            return DocumentAdapter.NULL;
          }
        });

    // must add here to guarantee that it is the first in the listener list

    IPreferenceStore store = getPreferenceStore();
    fMembersOrderPreferenceCache = new MembersOrderPreferenceCache();
    fMembersOrderPreferenceCache.install(store);

    // to initialize launching
    DLTKLaunchingPlugin.getDefault();

    // Close all open editors which has remote environment files open
    try {
      PlatformUI.getWorkbench().addWorkbenchListener(new ShutdownCloseRemoteEditorsListener());
      ContextActivator.getInstance().install();
    } catch (IllegalStateException e) {
      // IGNORE: workbench has not been created yet.
    }

    ExecutionContexts.setManager(new UIExecutionContextManager());
    new InitializeJob().schedule();
  }
コード例 #2
0
ファイル: DLTKUIPlugin.java プロジェクト: earlyster/dltk.core
  /** This method is called when the plug-in is stopped */
  @Override
  public void stop(BundleContext context) throws Exception {

    ExecutionContexts.setManager(null);
    if (fMembersOrderPreferenceCache != null) {
      fMembersOrderPreferenceCache.dispose();
      fMembersOrderPreferenceCache = null;
    }
    Object[] listeners = shutdownListeners.getListeners();
    for (int i = 0; i < listeners.length; ++i) {
      ((IShutdownListener) listeners[i]).shutdown();
    }
    shutdownListeners.clear();
    super.stop(context);
    DLTKUIPlugin.plugin = null;
  }