Esempio n. 1
0
  @Override
  protected void setInput(final IEditorInput input) {
    if (input instanceof FileEditorInput) {
      final IFile file = ((FileEditorInput) input).getFile();
      setPartName(file.getProject().getName() + "/" + input.getName());

      editorInput =
          new RedProjectEditorInput(
              Optional.of(file),
              !file.isReadOnly(),
              new RedEclipseProjectConfigReader().readConfigurationWithLines(file));
      installResourceListener();
    } else {
      final IStorage storage = (IStorage) input.getAdapter(IStorage.class);
      if (storage != null) {
        setPartName(storage.getName() + " [" + storage.getFullPath() + "]");

        try (InputStream stream = storage.getContents()) {
          editorInput =
              new RedProjectEditorInput(
                  Optional.<IFile>absent(),
                  !storage.isReadOnly(),
                  new RobotProjectConfigReader().readConfigurationWithLines(stream));
        } catch (final CoreException | IOException e) {
          throw new IllegalProjectConfigurationEditorInputException(
              "Unable to open editor: unrecognized input of class: " + input.getClass().getName(),
              e);
        }
      } else {
        throw new IllegalProjectConfigurationEditorInputException(
            "Unable to open editor: unrecognized input of class: " + input.getClass().getName());
      }
    }
    super.setInput(input);
  }
Esempio n. 2
0
 @Override
 public void setInput(final IEditorInput input) {
   super.setInput(input);
   setPartName(input.getName());
   for (int i = 0; i < getPageCount(); i++) removePage(i);
   createPages();
 }