use of org.eclipse.che.ide.api.editor.EditorPartPresenter in project che by eclipse.
the class EditorPartStackPresenter method onCloseNonPinnedEditors.
/** {@inheritDoc} */
@Override
public void onCloseNonPinnedEditors(CloseNonPinnedEditorsEvent event) {
EditorPartPresenter editorPart = event.getEditorTab().getRelativeEditorPart();
if (!containsPart(editorPart)) {
return;
}
Iterable<TabItem> nonPinned = filter(parts.keySet(), new Predicate<TabItem>() {
@Override
public boolean apply(@Nullable TabItem input) {
return input instanceof EditorTab && !((EditorTab) input).isPinned();
}
});
for (final TabItem tabItem : nonPinned) {
Scheduler.get().scheduleDeferred(new Scheduler.ScheduledCommand() {
@Override
public void execute() {
eventBus.fireEvent(FileEvent.createCloseFileEvent((EditorTab) tabItem));
}
});
}
}
use of org.eclipse.che.ide.api.editor.EditorPartPresenter in project che by eclipse.
the class SwitchNextEditorAction method actionPerformed.
/** {@inheritDoc} */
@Override
public void actionPerformed(ActionEvent event) {
final EditorPartPresenter activeEditor = editorAgent.getActiveEditor();
checkNotNull(activeEditor, "Null editor occurred");
final EditorPartPresenter previousEditor = getNextEditorBaseOn(activeEditor);
editorAgent.activateEditor(previousEditor);
}
use of org.eclipse.che.ide.api.editor.EditorPartPresenter in project che by eclipse.
the class RunClassTestAction method actionPerformed.
@Override
public void actionPerformed(ActionEvent e) {
final StatusNotification notification = new StatusNotification("Running Tests...", PROGRESS, FLOAT_MODE);
notificationManager.notify(notification);
final Project project = appContext.getRootProject();
EditorPartPresenter editorPart = editorAgent.getActiveEditor();
final VirtualFile file = editorPart.getEditorInput().getFile();
String fqn = JavaUtil.resolveFQN(file);
Map<String, String> parameters = new HashMap<>();
parameters.put("fqn", fqn);
parameters.put("runClass", "true");
parameters.put("updateClasspath", "true");
Promise<TestResult> testResultPromise = service.getTestResult(project.getPath(), "testng", parameters);
testResultPromise.then(new Operation<TestResult>() {
@Override
public void apply(TestResult result) throws OperationException {
notification.setStatus(SUCCESS);
if (result.isSuccess()) {
notification.setTitle("Test runner executed successfully");
notification.setContent("All tests are passed");
} else {
notification.setTitle("Test runner executed successfully with test failures.");
notification.setContent(result.getFailureCount() + " test(s) failed.\n");
}
presenter.handleResponse(result);
}
}).catchError(new Operation<PromiseError>() {
@Override
public void apply(PromiseError exception) throws OperationException {
final String errorMessage = (exception.getMessage() != null) ? exception.getMessage() : "Failed to run test cases";
notification.setContent(errorMessage);
notification.setStatus(FAIL);
}
});
}
use of org.eclipse.che.ide.api.editor.EditorPartPresenter in project che by eclipse.
the class FormatterAction method updateInPerspective.
@Override
public void updateInPerspective(@NotNull ActionEvent event) {
final EditorPartPresenter editor = editorAgent.getActiveEditor();
boolean isCanDoOperation = false;
HandlesTextOperations handlesOperations;
if (editor instanceof HandlesTextOperations) {
handlesOperations = (HandlesTextOperations) editor;
isCanDoOperation = handlesOperations.canDoOperation(TextEditorOperations.FORMAT);
}
event.getPresentation().setEnabled(isCanDoOperation);
}
use of org.eclipse.che.ide.api.editor.EditorPartPresenter in project che by eclipse.
the class OpenFileAction method promise.
@Override
public Promise<Void> promise(final ActionEvent actionEvent) {
if (actionEvent.getParameters() == null) {
return Promises.reject(JsPromiseError.create(localization.canNotOpenFileWithoutParams()));
}
final String pathToOpen = actionEvent.getParameters().get(FILE_PARAM_ID);
if (pathToOpen == null) {
return Promises.reject(JsPromiseError.create(localization.fileToOpenIsNotSpecified()));
}
final Call<Void, Throwable> call = new Call<Void, Throwable>() {
HandlerRegistration handlerRegistration;
@Override
public void makeCall(final Callback<Void, Throwable> callback) {
actionCompletedCallback = callback;
handlerRegistration = eventBus.addHandler(ActivePartChangedEvent.TYPE, new ActivePartChangedHandler() {
@Override
public void onActivePartChanged(ActivePartChangedEvent event) {
if (event.getActivePart() instanceof EditorPartPresenter) {
EditorPartPresenter editor = (EditorPartPresenter) event.getActivePart();
handlerRegistration.removeHandler();
if (Path.valueOf(pathToOpen).equals(editor.getEditorInput().getFile().getLocation())) {
callback.onSuccess(null);
}
}
}
});
actionPerformed(actionEvent);
}
};
return createFromCallback(call);
}
Aggregations