use of org.eclipse.che.ide.api.event.ActivePartChangedHandler 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);
}
use of org.eclipse.che.ide.api.event.ActivePartChangedHandler in project che by eclipse.
the class FileWatcher method handleFileOperations.
@Inject
private void handleFileOperations(EventBus eventBus) {
eventBus.addHandler(ResourceChangedEvent.getType(), new ResourceChangedEvent.ResourceChangedHandler() {
@Override
public void onResourceChanged(ResourceChangedEvent event) {
if (event.getDelta().getKind() != REMOVED) {
return;
}
if ((event.getDelta().getFlags() & DERIVED) == 0) {
return;
}
final Resource resource = event.getDelta().getResource();
final Optional<Resource> srcFolder = resource.getParentWithMarker(SourceFolderMarker.ID);
if (srcFolder.isPresent()) {
reparseAllOpenedFiles();
}
}
});
eventBus.addHandler(ActivePartChangedEvent.TYPE, new ActivePartChangedHandler() {
@Override
public void onActivePartChanged(ActivePartChangedEvent event) {
if (event.getActivePart() instanceof TextEditor) {
if (editor2reconcile.contains(event.getActivePart())) {
reParseEditor((TextEditor) event.getActivePart());
}
}
}
});
}
Aggregations