diff options
author | Tom Schindl | 2015-09-02 06:07:15 +0000 |
---|---|---|
committer | Tom Schindl | 2015-09-02 06:07:15 +0000 |
commit | c84faa3e642d2388bd2bae0fcf6259997e2c3661 (patch) | |
tree | 7b0a85f070d381a68a59773ef73f9e6b1de7cded | |
parent | 6071eec89ccc26da4918de4e42e42d6bcbbdc777 (diff) | |
download | org.eclipse.efxclipse-2.1.0.tar.gz org.eclipse.efxclipse-2.1.0.tar.xz org.eclipse.efxclipse-2.1.0.zip |
removed old function2.1.0
-rw-r--r-- | bundles/code/org.eclipse.fx.code.editor.fx.e4/src/org/eclipse/fx/code/editor/fx/e4/internal/TextEditorOpenerContextFunction.java | 85 |
1 files changed, 0 insertions, 85 deletions
diff --git a/bundles/code/org.eclipse.fx.code.editor.fx.e4/src/org/eclipse/fx/code/editor/fx/e4/internal/TextEditorOpenerContextFunction.java b/bundles/code/org.eclipse.fx.code.editor.fx.e4/src/org/eclipse/fx/code/editor/fx/e4/internal/TextEditorOpenerContextFunction.java deleted file mode 100644 index e83320ce0..000000000 --- a/bundles/code/org.eclipse.fx.code.editor.fx.e4/src/org/eclipse/fx/code/editor/fx/e4/internal/TextEditorOpenerContextFunction.java +++ /dev/null @@ -1,85 +0,0 @@ -package org.eclipse.fx.code.editor.fx.e4.internal; - -import java.util.Collections; -import java.util.List; - -import javax.inject.Inject; - -import org.eclipse.e4.core.contexts.ContextFunction; -import org.eclipse.e4.core.contexts.ContextInjectionFactory; -import org.eclipse.e4.core.contexts.IContextFunction; -import org.eclipse.e4.core.contexts.IEclipseContext; -import org.eclipse.e4.ui.model.application.MApplication; -import org.eclipse.e4.ui.model.application.ui.MElementContainer; -import org.eclipse.e4.ui.model.application.ui.basic.MPart; -import org.eclipse.e4.ui.model.application.ui.basic.MWindow; -import org.eclipse.e4.ui.workbench.modeling.EModelService; -import org.eclipse.e4.ui.workbench.modeling.EPartService; -import org.eclipse.fx.code.editor.Constants; -import org.eclipse.fx.code.editor.services.FileIconProvider; -import org.eclipse.fx.code.editor.services.TextEditorOpener; -import org.eclipse.fx.core.URI; -import org.eclipse.fx.core.di.Service; -import org.osgi.service.component.annotations.Component; - -@Component(service=IContextFunction.class,property={"service.context.key=org.eclipse.fx.code.editor.services.TextEditorOpener"}) -public class TextEditorOpenerContextFunction extends ContextFunction { - @Override - public Object compute(IEclipseContext context) { - return ContextInjectionFactory.make(TextEditorOpenHelper.class, context); - } - - public static class TextEditorOpenHelper implements TextEditorOpener { - @Inject - MWindow window; - - @Inject - MApplication application; - - @Inject - EModelService modelService; - - @Inject - @Service - List<FileIconProvider> fileIconProvider; - - @SuppressWarnings({ "unchecked", "rawtypes" }) - @Override - public void openEditor(String uri) { - List<MPart> list = modelService.findElements(application, MPart.class, EModelService.ANYWHERE, (p) -> { - return uri.equals(p.getPersistedState().get(Constants.DOCUMENT_URL)); - }); - - MPart part = null; - if( list.isEmpty() ) { - List<MElementContainer> elements = modelService.findElements(window, null, MElementContainer.class, Collections.singletonList(Constants.EDITOR_CONTAINER_TAG)); - if( ! elements.isEmpty() ) { - MElementContainer<MPart> container = elements.get(0); - - part = modelService.createModelElement(MPart.class); - part.setCloseable(true); - part.setLabel(URI.create(uri).lastSegment()); - part.setContributionURI("bundleclass://org.eclipse.fx.code.editor.fx/org.eclipse.fx.code.editor.fx.TextEditor"); - String iconUri = fileIconProvider - .stream() - .filter( f -> f.test(uri)) - .findFirst() - .map( f -> f.getFileIconUri(uri)) - .orElse("platform:/plugin/org.eclipse.fx.code.editor.fx.e4/icons/file_16.png"); - part.setIconURI(iconUri); - part.getPersistedState().put(Constants.DOCUMENT_URL, uri); - part.getTags().add("removeOnHide"); - container.getChildren().add(part); - } - } else { - part = list.get(0); - } - - IEclipseContext context = modelService.getContainingContext(part); - if( context != null ) { - EPartService partService = context.get(EPartService.class); - partService.activate(part); - } - } - } -} |