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);
}
});
}
}
}
}
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()));
}
}
}
});
}
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));
}
}
});
}
Aggregations