Search in sources :

Example 1 with EditorOpenedEvent

use of org.eclipse.che.ide.api.editor.EditorOpenedEvent in project che by eclipse.

the class ClassFileSourcesDownloader method onEditorOpened.

@Override
public void onEditorOpened(EditorOpenedEvent event) {
    EditorPartPresenter editor = event.getEditor();
    VirtualFile file = editor.getEditorInput().getFile();
    if (file instanceof JarFileNode) {
        final JarFileNode jarFileNode = (JarFileNode) file;
        if (jarFileNode.isContentGenerated()) {
            if (editor instanceof TextEditor) {
                final TextEditor presenter = (TextEditor) editor;
                TextEditorPartView view = presenter.getView();
                final DivElement divElement = Elements.createDivElement();
                divElement.setClassName(resources.css().editorInfoPanel());
                Text textNode = Elements.createTextNode(constant.mavenClassDecompiled());
                DivElement decompiledElement = Elements.createDivElement();
                decompiledElement.appendChild(textNode);
                decompiledElement.setClassName(resources.css().editorMessage());
                divElement.appendChild(decompiledElement);
                AnchorElement anchorElement = Elements.createAnchorElement();
                anchorElement.appendChild(Elements.createTextNode(constant.mavenDownloadSources()));
                anchorElement.setHref("#");
                anchorElement.setClassName(resources.css().downloadLink());
                divElement.appendChild(anchorElement);
                final HasNotificationPanel.NotificationRemover remover = view.addNotification((Element) divElement);
                anchorElement.setOnclick(new EventListener() {

                    @Override
                    public void handleEvent(Event evt) {
                        downloadSources(jarFileNode, remover);
                    }
                });
            }
        }
    }
}
Also used : VirtualFile(org.eclipse.che.ide.api.resources.VirtualFile) AnchorElement(elemental.html.AnchorElement) Text(elemental.dom.Text) HasNotificationPanel(org.eclipse.che.ide.api.editor.texteditor.HasNotificationPanel) JarFileNode(org.eclipse.che.ide.ext.java.client.tree.library.JarFileNode) TextEditorPartView(org.eclipse.che.ide.api.editor.texteditor.TextEditorPartView) DivElement(elemental.html.DivElement) TextEditor(org.eclipse.che.ide.api.editor.texteditor.TextEditor) EditorOpenedEvent(org.eclipse.che.ide.api.editor.EditorOpenedEvent) Event(elemental.events.Event) FileContentUpdateEvent(org.eclipse.che.ide.api.event.FileContentUpdateEvent) EditorPartPresenter(org.eclipse.che.ide.api.editor.EditorPartPresenter) EventListener(elemental.events.EventListener)

Example 2 with EditorOpenedEvent

use of org.eclipse.che.ide.api.editor.EditorOpenedEvent in project che by eclipse.

the class BreakpointManagerImpl method registerEventHandlers.

/**
     * Registers events handlers.
     */
private void registerEventHandlers(EventBus eventBus) {
    eventBus.addHandler(WorkspaceReadyEvent.getType(), new WorkspaceReadyEvent.WorkspaceReadyHandler() {

        @Override
        public void onWorkspaceReady(WorkspaceReadyEvent event) {
            restoreBreakpoints();
        }
    });
    eventBus.addHandler(EditorOpenedEvent.TYPE, new EditorOpenedEventHandler() {

        @Override
        public void onEditorOpened(EditorOpenedEvent event) {
            onOpenEditor(event.getFile().getLocation().toString(), event.getEditor());
        }
    });
    eventBus.addHandler(DeleteProjectEvent.TYPE, new DeleteProjectHandler() {

        @Override
        public void onProjectDeleted(DeleteProjectEvent event) {
            if (breakpoints.isEmpty()) {
                return;
            }
            ProjectConfigDto config = event.getProjectConfig();
            String path = config.getPath() + "/";
            deleteBreakpoints(getBreakpointPaths(path));
        }
    });
    eventBus.addHandler(ResourceChangedEvent.getType(), new ResourceChangedEvent.ResourceChangedHandler() {

        @Override
        public void onResourceChanged(ResourceChangedEvent event) {
            if (event.getDelta().getKind() == ResourceDelta.REMOVED) {
                if (breakpoints.isEmpty()) {
                    return;
                }
                final Resource resource = event.getDelta().getResource();
                Path path = resource.getLocation();
                if (resource.isFolder()) {
                    path.addTrailingSeparator();
                    deleteBreakpoints(getBreakpointPaths(path.toString()));
                } else if (resource.isFile()) {
                    deleteBreakpoints(Collections.singleton(path.toString()));
                }
            }
        }
    });
}
Also used : Path(org.eclipse.che.ide.resource.Path) DeleteProjectEvent(org.eclipse.che.ide.api.event.project.DeleteProjectEvent) EditorOpenedEvent(org.eclipse.che.ide.api.editor.EditorOpenedEvent) ProjectConfigDto(org.eclipse.che.api.workspace.shared.dto.ProjectConfigDto) Resource(org.eclipse.che.ide.api.resources.Resource) DeleteProjectHandler(org.eclipse.che.ide.api.event.project.DeleteProjectHandler) EditorOpenedEventHandler(org.eclipse.che.ide.api.editor.EditorOpenedEventHandler) WorkspaceReadyEvent(org.eclipse.che.ide.api.workspace.WorkspaceReadyEvent) ResourceChangedEvent(org.eclipse.che.ide.api.resources.ResourceChangedEvent)

Example 3 with EditorOpenedEvent

use of org.eclipse.che.ide.api.editor.EditorOpenedEvent in project che by eclipse.

the class EditorAgentImpl method finalizeInit.

private void finalizeInit(final VirtualFile file, final OpenEditorCallback callback, final EditorPartPresenter editor, EditorProvider editorProvider) {
    openedEditors.add(editor);
    openedEditorsToProviders.put(editor, editorProvider.getId());
    workspaceAgent.setActivePart(editor);
    editor.addPropertyListener(new PropertyListener() {

        @Override
        public void propertyChanged(PartPresenter source, int propId) {
            if (propId == EditorPartPresenter.PROP_INPUT) {
                if (editor instanceof HasReadOnlyProperty) {
                    ((HasReadOnlyProperty) editor).setReadOnly(file.isReadOnly());
                }
                if (editor instanceof TextEditor) {
                    editorContentSynchronizerProvider.get().trackEditor(editor);
                }
                callback.onEditorOpened(editor);
                eventBus.fireEvent(new EditorOpenedEvent(file, editor));
            }
        }
    });
}
Also used : TextEditor(org.eclipse.che.ide.api.editor.texteditor.TextEditor) EditorOpenedEvent(org.eclipse.che.ide.api.editor.EditorOpenedEvent) PropertyListener(org.eclipse.che.ide.api.parts.PropertyListener) HasReadOnlyProperty(org.eclipse.che.ide.api.editor.texteditor.HasReadOnlyProperty) PartPresenter(org.eclipse.che.ide.api.parts.PartPresenter) EditorPartPresenter(org.eclipse.che.ide.api.editor.EditorPartPresenter)

Aggregations

EditorOpenedEvent (org.eclipse.che.ide.api.editor.EditorOpenedEvent)3 EditorPartPresenter (org.eclipse.che.ide.api.editor.EditorPartPresenter)2 TextEditor (org.eclipse.che.ide.api.editor.texteditor.TextEditor)2 Text (elemental.dom.Text)1 Event (elemental.events.Event)1 EventListener (elemental.events.EventListener)1 AnchorElement (elemental.html.AnchorElement)1 DivElement (elemental.html.DivElement)1 ProjectConfigDto (org.eclipse.che.api.workspace.shared.dto.ProjectConfigDto)1 EditorOpenedEventHandler (org.eclipse.che.ide.api.editor.EditorOpenedEventHandler)1 HasNotificationPanel (org.eclipse.che.ide.api.editor.texteditor.HasNotificationPanel)1 HasReadOnlyProperty (org.eclipse.che.ide.api.editor.texteditor.HasReadOnlyProperty)1 TextEditorPartView (org.eclipse.che.ide.api.editor.texteditor.TextEditorPartView)1 FileContentUpdateEvent (org.eclipse.che.ide.api.event.FileContentUpdateEvent)1 DeleteProjectEvent (org.eclipse.che.ide.api.event.project.DeleteProjectEvent)1 DeleteProjectHandler (org.eclipse.che.ide.api.event.project.DeleteProjectHandler)1 PartPresenter (org.eclipse.che.ide.api.parts.PartPresenter)1 PropertyListener (org.eclipse.che.ide.api.parts.PropertyListener)1 Resource (org.eclipse.che.ide.api.resources.Resource)1 ResourceChangedEvent (org.eclipse.che.ide.api.resources.ResourceChangedEvent)1