コード例 #1
0
  @Before
  public void setUp() {
    when(fileTypeRegistry.getFileTypeByFile(file)).thenReturn(fileType);
    when(fileTypeRegistry.getFileTypeByFile(newFileNode)).thenReturn(fileType);
    when(fileTypeRegistry.getFileTypeByFile(fileNode2)).thenReturn(fileType);
    when(editorRegistry.getEditor(fileType)).thenReturn(editorProvider);
    when(editorProvider.getEditor()).thenReturn(editor);
    when(file.getPath()).thenReturn(PATH);
    when(newFileNode.getPath()).thenReturn(NEW_PATH);

    when(editor.getEditorInput()).thenReturn(editorInput);
    when(editorInput.getFile()).thenReturn(file);

    editorAgent =
        new EditorAgentImpl(
            eventBus,
            fileTypeRegistry,
            editorRegistry,
            workspace,
            notificationManager,
            coreLocalizationConstant,
            nodeManager,
            projectServiceClient,
            appContext,
            dtoUnmarshallerFactory);
  }
コード例 #2
0
  @Override
  public List<ActionDescriptor> getActions(String projectPath) {
    EditorAgent editorAgent = editorAgentProvider.get();
    EditorPartPresenter activeEditor = editorAgent.getActiveEditor();

    final List<ActionDescriptor> actions = new ArrayList<>();

    if (activeEditor == null) {
      return Collections.emptyList();
    }

    VirtualFile virtualFile = activeEditor.getEditorInput().getFile();

    String openNodeActionId = actionManager.getId(openFileAction);

    actions.add(
        dtoFactory
            .createDto(ActionDescriptor.class)
            .withId(openNodeActionId)
            .withParameters(Collections.singletonMap(FILE_PARAM_ID, virtualFile.getPath())));
    return actions;
  }
コード例 #3
0
  @Test
  public void presenterShouldGoneContainerWhenEditorNotNull() {
    AcceptsOneWidget container = mock(AcceptsOneWidget.class);
    when(editor.isDirty()).thenReturn(true);

    presenter.initializeEditor(file, editorProvider, fileTypeRegistry);
    presenter.go(container);

    verify(container).setWidget(view);
    verify(editor).activate();
    verify(editor).onOpen();
    verify(view).setEnableSaveButton(true);
    verify(view).setEnableCancelButton(true);
  }
コード例 #4
0
ファイル: BranchPresenter.java プロジェクト: jgallimore/che
  private void updateOpenedFiles() {
    for (EditorPartPresenter editorPartPresenter : editorAgent.getOpenedEditors().values()) {
      final VirtualFile file = editorPartPresenter.getEditorInput().getFile();
      final String filePath = file.getPath();
      Unmarshallable<ItemReference> unmarshaller =
          dtoUnmarshallerFactory.newUnmarshaller(ItemReference.class);

      projectService.getItem(
          workspaceId,
          filePath,
          new AsyncRequestCallback<org.eclipse.che.api.project.shared.dto.ItemReference>(
              unmarshaller) {
            @Override
            protected void onSuccess(ItemReference itemReference) {
              eventBus.fireEvent(new FileContentUpdateEvent(filePath));
            }

            @Override
            protected void onFailure(Throwable throwable) {
              eventBus.fireEvent(new FileEvent(file, FileEvent.FileOperation.CLOSE));
            }
          });
    }
  }
コード例 #5
0
  @Before
  public void setUp() {
    when(appContext.getCurrentProject()).thenReturn(currentProject);

    when(environment.getScope()).thenReturn(SYSTEM);
    when(environment.getPath()).thenReturn(TEXT);
    when(environment.getName()).thenReturn(TEXT);
    when(environment.getType()).thenReturn(TEXT);
    when(environment.getRam()).thenReturn(MB_500.getValue());

    when(currentProject.getCurrentTree()).thenReturn(treeStructure);
    when(currentProject.getProjectDescription()).thenReturn(descriptor);

    when(fileTypeRegistry.getFileTypeByFile(file)).thenReturn(fileType);
    when(editorProvider.getEditor()).thenReturn(editor);

    when(editor.getEditorInput()).thenReturn(editorInput);
    when(editorInput.getFile()).thenReturn(file);

    presenter = new DummyPanelProperties(view, appContext);
  }