示例#1
0
  @Override
  public void init(IEditorSite site, IEditorInput input) throws PartInitException {
    if (!(input instanceof TaskEditorInput)) {
      throw new PartInitException(
          "Invalid editor input \"" + input.getClass() + "\""); // $NON-NLS-1$ //$NON-NLS-2$
    }

    super.init(site, input);

    this.taskEditorInput = (TaskEditorInput) input;
    this.task = taskEditorInput.getTask();

    // initialize selection
    site.getSelectionProvider().setSelection(new StructuredSelection(task));

    setPartName(input.getName());

    // activate context
    IContextService contextSupport = (IContextService) site.getService(IContextService.class);
    if (contextSupport != null) {
      contextSupport.activateContext(ID_EDITOR);
    }
  }