Search in sources :

Example 11 with ActivePartChangedEvent

use of org.eclipse.che.ide.api.event.ActivePartChangedEvent 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());
                }
            }
        }
    });
}
Also used : ActivePartChangedHandler(org.eclipse.che.ide.api.event.ActivePartChangedHandler) TextEditor(org.eclipse.che.ide.api.editor.texteditor.TextEditor) Optional(com.google.common.base.Optional) ActivePartChangedEvent(org.eclipse.che.ide.api.event.ActivePartChangedEvent) Resource(org.eclipse.che.ide.api.resources.Resource) ResourceChangedEvent(org.eclipse.che.ide.api.resources.ResourceChangedEvent) Inject(com.google.inject.Inject)

Aggregations

ActivePartChangedEvent (org.eclipse.che.ide.api.event.ActivePartChangedEvent)11 Test (org.junit.Test)8 SelectionChangedHandler (org.eclipse.che.ide.api.event.SelectionChangedHandler)3 AcceptsOneWidget (com.google.gwt.user.client.ui.AcceptsOneWidget)2 ActivePartChangedHandler (org.eclipse.che.ide.api.event.ActivePartChangedHandler)2 AbstractPartPresenter (org.eclipse.che.ide.api.parts.AbstractPartPresenter)2 Selection (org.eclipse.che.ide.api.selection.Selection)2 Optional (com.google.common.base.Optional)1 Callback (com.google.gwt.core.client.Callback)1 Inject (com.google.inject.Inject)1 HandlerRegistration (com.google.web.bindery.event.shared.HandlerRegistration)1 Call (org.eclipse.che.api.promises.client.callback.CallbackPromiseHelper.Call)1 CallbackPromiseHelper.createFromCallback (org.eclipse.che.api.promises.client.callback.CallbackPromiseHelper.createFromCallback)1 EditorPartPresenter (org.eclipse.che.ide.api.editor.EditorPartPresenter)1 TextEditor (org.eclipse.che.ide.api.editor.texteditor.TextEditor)1 PartStackView (org.eclipse.che.ide.api.parts.PartStackView)1 Resource (org.eclipse.che.ide.api.resources.Resource)1 ResourceChangedEvent (org.eclipse.che.ide.api.resources.ResourceChangedEvent)1 Before (org.junit.Before)1