diff options
author | Thomas Schindl | 2010-06-03 17:24:43 +0000 |
---|---|---|
committer | Thomas Schindl | 2010-06-03 17:24:43 +0000 |
commit | a8522b13887dc568ae485ce87b8e33e0e1c71203 (patch) | |
tree | 9a239654cae873422ee4887ec2ef9cdbd0d2c336 | |
parent | 708974f00311d38a84403f7a7c66f9c7338e1477 (diff) | |
download | org.eclipse.e4.tools-a8522b13887dc568ae485ce87b8e33e0e1c71203.tar.gz org.eclipse.e4.tools-a8522b13887dc568ae485ce87b8e33e0e1c71203.tar.xz org.eclipse.e4.tools-a8522b13887dc568ae485ce87b8e33e0e1c71203.zip |
Bug 304584 - [Tooling] Implement Workbench-Model-Tooling
* using new compat implementation
10 files changed, 39 insertions, 349 deletions
diff --git a/bundles/org.eclipse.e4.tools.compat/src/org/eclipse/e4/tools/compat/parts/DIEditorPart.java b/bundles/org.eclipse.e4.tools.compat/src/org/eclipse/e4/tools/compat/parts/DIEditorPart.java index 2549071c..3f2580cb 100644 --- a/bundles/org.eclipse.e4.tools.compat/src/org/eclipse/e4/tools/compat/parts/DIEditorPart.java +++ b/bundles/org.eclipse.e4.tools.compat/src/org/eclipse/e4/tools/compat/parts/DIEditorPart.java @@ -108,7 +108,7 @@ public abstract class DIEditorPart<C> extends EditorPart { context.set(Composite.class.getName(), comp); component = ContextInjectionFactory.make(clazz, context); - styleEngine.setClassname(comp, getSite().getId()); + styleEngine.setClassname(comp, getClass().getSimpleName()); } public C getComponent() { diff --git a/bundles/org.eclipse.e4.tools.emf.editor3x/META-INF/MANIFEST.MF b/bundles/org.eclipse.e4.tools.emf.editor3x/META-INF/MANIFEST.MF index e419afd5..db0beef8 100644 --- a/bundles/org.eclipse.e4.tools.emf.editor3x/META-INF/MANIFEST.MF +++ b/bundles/org.eclipse.e4.tools.emf.editor3x/META-INF/MANIFEST.MF @@ -22,7 +22,9 @@ Require-Bundle: org.eclipse.ui;bundle-version="3.6.0", org.eclipse.e4.core.di;bundle-version="0.9.0", org.eclipse.e4.core.services;bundle-version="0.9.1", org.eclipse.emf.edit;bundle-version="2.6.0", - org.eclipse.e4.ui.services;bundle-version="0.9.1" -Service-Component: OSGI-INF/pdecontributionprovider.xml, OSGI-INF/xmiresourcecontextfunction.xml, OSGI-INF/selectionproviderfunction.xml + org.eclipse.e4.ui.services;bundle-version="0.9.1", + org.eclipse.e4.tools.compat;bundle-version="1.0.0", + org.eclipse.e4.tools.services;bundle-version="1.0.0" +Service-Component: OSGI-INF/pdecontributionprovider.xml, OSGI-INF/xmiresourcecontextfunction.xml Bundle-ActivationPolicy: lazy Export-Package: org.eclipse.e4.tools.emf.editor3x.wizard;x-internal:=true diff --git a/bundles/org.eclipse.e4.tools.emf.editor3x/OSGI-INF/selectionproviderfunction.xml b/bundles/org.eclipse.e4.tools.emf.editor3x/OSGI-INF/selectionproviderfunction.xml deleted file mode 100644 index 73d6e010..00000000 --- a/bundles/org.eclipse.e4.tools.emf.editor3x/OSGI-INF/selectionproviderfunction.xml +++ /dev/null @@ -1,8 +0,0 @@ -<?xml version="1.0" encoding="UTF-8"?> -<scr:component xmlns:scr="http://www.osgi.org/xmlns/scr/v1.1.0" name="org.eclipse.e4.tools.emf.editor3x.selectionprovider"> - <implementation class="org.eclipse.e4.tools.emf.editor3x.compat.SelectionProviderContextFunction"/> - <service> - <provide interface="org.eclipse.e4.core.contexts.IContextFunction"/> - </service> - <property name="service.context.key" type="String" value="org.eclipse.e4.tools.emf.ui.common.ISelectionProviderService"/> -</scr:component> diff --git a/bundles/org.eclipse.e4.tools.emf.editor3x/plugin.xml b/bundles/org.eclipse.e4.tools.emf.editor3x/plugin.xml index 3859e566..8a4c94ce 100644 --- a/bundles/org.eclipse.e4.tools.emf.editor3x/plugin.xml +++ b/bundles/org.eclipse.e4.tools.emf.editor3x/plugin.xml @@ -38,14 +38,5 @@ name="e4"> </category> </extension> - <extension - point="org.eclipse.ui.services"> - <serviceFactory - factoryClass="org.eclipse.e4.tools.emf.editor3x.compat.IEclipseContextServiceFactory"> - <service - serviceClass="org.eclipse.e4.core.contexts.IEclipseContext"> - </service> - </serviceFactory> - </extension> </plugin> diff --git a/bundles/org.eclipse.e4.tools.emf.editor3x/src/org/eclipse/e4/tools/emf/editor3x/E4WorkbenchModelEditor.java b/bundles/org.eclipse.e4.tools.emf.editor3x/src/org/eclipse/e4/tools/emf/editor3x/E4WorkbenchModelEditor.java index e3a506d6..ec9134ae 100644 --- a/bundles/org.eclipse.e4.tools.emf.editor3x/src/org/eclipse/e4/tools/emf/editor3x/E4WorkbenchModelEditor.java +++ b/bundles/org.eclipse.e4.tools.emf.editor3x/src/org/eclipse/e4/tools/emf/editor3x/E4WorkbenchModelEditor.java @@ -10,11 +10,34 @@ ******************************************************************************/ package org.eclipse.e4.tools.emf.editor3x; -import org.eclipse.e4.tools.emf.editor3x.compat.E4CompatEditorPart; +import org.eclipse.core.runtime.IProgressMonitor; +import org.eclipse.e4.tools.compat.parts.DIEditorPart; +import org.eclipse.e4.tools.emf.ui.internal.wbm.ApplicationModelEditor; -public class E4WorkbenchModelEditor extends E4CompatEditorPart { +@SuppressWarnings("restriction") +public class E4WorkbenchModelEditor extends DIEditorPart<ApplicationModelEditor> { public E4WorkbenchModelEditor() { - super("platform:/plugin/org.eclipse.e4.tools.emf.ui/org.eclipse.e4.tools.emf.ui.internal.wbm.ApplicationModelEditor"); + super(ApplicationModelEditor.class); + } + + @Override + public void doSave(IProgressMonitor monitor) { + getComponent().doSave(monitor); + } + + @Override + public void doSaveAs() { + + } + + @Override + public boolean isSaveAsAllowed() { + return false; + } + + @Override + public void setFocus() { + getComponent().setFocus(); } } diff --git a/bundles/org.eclipse.e4.tools.emf.editor3x/src/org/eclipse/e4/tools/emf/editor3x/XMIResourceFunction.java b/bundles/org.eclipse.e4.tools.emf.editor3x/src/org/eclipse/e4/tools/emf/editor3x/XMIResourceFunction.java index 8ea8779a..b8e737b8 100644 --- a/bundles/org.eclipse.e4.tools.emf.editor3x/src/org/eclipse/e4/tools/emf/editor3x/XMIResourceFunction.java +++ b/bundles/org.eclipse.e4.tools.emf.editor3x/src/org/eclipse/e4/tools/emf/editor3x/XMIResourceFunction.java @@ -2,20 +2,19 @@ package org.eclipse.e4.tools.emf.editor3x; import org.eclipse.e4.core.contexts.ContextFunction; import org.eclipse.e4.core.contexts.IEclipseContext; -import org.eclipse.e4.tools.emf.editor3x.compat.E4CompatEditorPart; import org.eclipse.e4.tools.emf.editor3x.emf.EditUIUtil; import org.eclipse.e4.tools.emf.ui.common.XMIModelResource; import org.eclipse.e4.tools.emf.ui.common.IModelResource.ModelListener; +import org.eclipse.e4.tools.services.IDirtyProviderService; import org.eclipse.emf.common.util.URI; import org.eclipse.ui.IEditorInput; -import org.eclipse.ui.part.EditorPart; public class XMIResourceFunction extends ContextFunction { @Override public Object compute(final IEclipseContext context) { final IEditorInput input = context.get(IEditorInput.class); - final E4CompatEditorPart part = (E4CompatEditorPart) context.get(EditorPart.class); + final IDirtyProviderService dirtyProvider = context.get(IDirtyProviderService.class); if( input != null ) { URI resourceURI = EditUIUtil.getURI(input); @@ -23,8 +22,7 @@ public class XMIResourceFunction extends ContextFunction { resource.addModelListener(new ModelListener() { public void dirtyChanged() { - context.set(EditorPart.class.getName()+".dirty", resource.isDirty()); - part.firePropertyChange(EditorPart.PROP_DIRTY); + dirtyProvider.setDirtyState(resource.isDirty()); } public void commandStackChanged() { diff --git a/bundles/org.eclipse.e4.tools.emf.editor3x/src/org/eclipse/e4/tools/emf/editor3x/compat/E4CompatEditorPart.java b/bundles/org.eclipse.e4.tools.emf.editor3x/src/org/eclipse/e4/tools/emf/editor3x/compat/E4CompatEditorPart.java deleted file mode 100644 index ba0d7381..00000000 --- a/bundles/org.eclipse.e4.tools.emf.editor3x/src/org/eclipse/e4/tools/emf/editor3x/compat/E4CompatEditorPart.java +++ /dev/null @@ -1,186 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2010 BestSolution.at and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * Tom Schindl <tom.schindl@bestsolution.at> - initial API and implementation - ******************************************************************************/ -package org.eclipse.e4.tools.emf.editor3x.compat; - -import org.eclipse.core.resources.IProject; -import org.eclipse.core.runtime.IExecutableExtension; -import org.eclipse.core.runtime.IProgressMonitor; -import org.eclipse.core.runtime.ListenerList; -import org.eclipse.e4.core.contexts.IEclipseContext; -import org.eclipse.e4.core.services.contributions.IContributionFactory; -import org.eclipse.e4.tools.emf.editor3x.E4WorkbenchModelEditor; -import org.eclipse.e4.ui.css.swt.theme.IThemeEngine; -import org.eclipse.e4.ui.css.swt.theme.IThemeManager; -import org.eclipse.e4.ui.model.application.ui.basic.MPart; -import org.eclipse.jface.viewers.ISelection; -import org.eclipse.jface.viewers.ISelectionChangedListener; -import org.eclipse.jface.viewers.ISelectionProvider; -import org.eclipse.jface.viewers.SelectionChangedEvent; -import org.eclipse.jface.viewers.StructuredSelection; -import org.eclipse.swt.SWT; -import org.eclipse.swt.layout.FillLayout; -import org.eclipse.swt.widgets.Composite; -import org.eclipse.ui.IEditorInput; -import org.eclipse.ui.IEditorSite; -import org.eclipse.ui.IFileEditorInput; -import org.eclipse.ui.ISelectionListener; -import org.eclipse.ui.ISelectionService; -import org.eclipse.ui.IWorkbenchPart; -import org.eclipse.ui.PartInitException; -import org.eclipse.ui.part.EditorPart; -import org.osgi.framework.Bundle; -import org.osgi.framework.FrameworkUtil; -import org.osgi.framework.ServiceReference; - -public class E4CompatEditorPart extends EditorPart implements IExecutableExtension { - private Object instance; - private String classUri; - - //TODO can we create a context as a top-level service? - private IEclipseContext context; - - public E4CompatEditorPart(String classUri) { - this.classUri = classUri; - } - - @Override - public void doSave(IProgressMonitor monitor) { - IContributionFactory factory = (IContributionFactory) context.get(IContributionFactory.class); - factory.call(instance, null, "doSave", context, null); - } - - @Override - public void doSaveAs() { - // TODO Auto-generated method stub - - } - - @Override - public void init(IEditorSite site, IEditorInput input) - throws PartInitException { - setSite(site); - setInput(input); - - IEclipseContext parentContext = (IEclipseContext) getSite().getService(IEclipseContext.class); - -// System.err.println("The context" + parentContext); - - // We are in e4 Compat-Mode - if( parentContext.get("org.eclipse.e4.workbench.ui.IPresentationEngine") != null ) { - MPart p = (MPart) getSite().getService(MPart.class); - context = p.getContext(); - } else { - context = parentContext.createChild("EditPart('"+getPartName()+"')"); //$NON-NLS-1$ - } - - context.declareModifiable(IEditorInput.class); - context.declareModifiable(EditorPart.class); - - context.set(EditorPart.class,this); - context.set(IEditorInput.class, input); - - if( input instanceof IFileEditorInput ) { - IFileEditorInput fInput = (IFileEditorInput)getEditorInput(); - context.set(IProject.class, fInput.getFile().getProject()); - } - - } - - @Override - public void firePropertyChange(int propertyId) { - super.firePropertyChange(propertyId); - } - - @Override - public boolean isDirty() { - Boolean b = (Boolean) context.get(EditorPart.class.getName()+".dirty"); - return b != null && b; - } - - @Override - public boolean isSaveAsAllowed() { - // TODO Auto-generated method stub - return false; - } - - @Override - public void createPartControl(Composite parent) { - ISelectionProvider s = new SelectionProviderImpl(); - context.set(ISelectionProvider.class, s); - getSite().setSelectionProvider(s); - - - Composite comp = new Composite(parent, SWT.NONE); - comp.setBackgroundMode(SWT.INHERIT_DEFAULT); - - FillLayout layout = new FillLayout(); - layout.marginWidth = 10; - layout.marginHeight = 10; - comp.setLayout(layout); - - context.set(Composite.class.getName(), comp); - IContributionFactory factory = (IContributionFactory) context.get(IContributionFactory.class); - instance = factory.create(classUri, context); - - Bundle b = FrameworkUtil.getBundle(E4WorkbenchModelEditor.class); - if( b != null ) { - ServiceReference ref = b.getBundleContext().getServiceReference(IThemeManager.class.getName()); - if( ref != null ) { - IThemeManager mgr = (IThemeManager) b.getBundleContext().getService(ref); - IThemeEngine engine = mgr.getEngineForDisplay(parent.getDisplay()); - engine.applyStyles(parent, true); - } - } - } - - @Override - public void setFocus() { - // TODO Auto-generated method stub - - } - - @Override - public void dispose() { - context.dispose(); - context = null; - super.dispose(); - } - - private class SelectionProviderImpl implements ISelectionProvider { - private ISelection currentSelection = StructuredSelection.EMPTY; - - private ListenerList listeners = new ListenerList(); - - public void setSelection(ISelection selection) { - currentSelection = selection; - SelectionChangedEvent evt = new SelectionChangedEvent(this, selection); - - for( Object l : listeners.getListeners() ) { - ((ISelectionChangedListener)l).selectionChanged(evt); - } - } - - public void removeSelectionChangedListener( - ISelectionChangedListener listener) { - listeners.remove(listener); - } - - public ISelection getSelection() { - System.err.println("Selection: " + currentSelection); - return currentSelection; - } - - public void addSelectionChangedListener(ISelectionChangedListener listener) { - System.err.println("Adding listener: " + listener); - listeners.add(listener); - } - } -} diff --git a/bundles/org.eclipse.e4.tools.emf.editor3x/src/org/eclipse/e4/tools/emf/editor3x/compat/IEclipseContextServiceFactory.java b/bundles/org.eclipse.e4.tools.emf.editor3x/src/org/eclipse/e4/tools/emf/editor3x/compat/IEclipseContextServiceFactory.java deleted file mode 100644 index 93f095a2..00000000 --- a/bundles/org.eclipse.e4.tools.emf.editor3x/src/org/eclipse/e4/tools/emf/editor3x/compat/IEclipseContextServiceFactory.java +++ /dev/null @@ -1,96 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2010 BestSolution.at and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * Tom Schindl <tom.schindl@bestsolution.at> - initial API and implementation - * ARTAL Technologies <simon.chemouil@artal.fr> - bugfix 315362 - ******************************************************************************/ -package org.eclipse.e4.tools.emf.editor3x.compat; - -import org.eclipse.core.runtime.IExtensionRegistry; -import org.eclipse.core.runtime.RegistryFactory; -import org.eclipse.e4.core.contexts.EclipseContextFactory; -import org.eclipse.e4.core.contexts.IEclipseContext; -import org.eclipse.e4.core.services.contributions.IContributionFactory; -import org.eclipse.e4.ui.services.IServiceConstants; -import org.eclipse.e4.workbench.ui.internal.ReflectionContributionFactory; -import org.eclipse.jface.viewers.ISelection; -import org.eclipse.jface.viewers.IStructuredSelection; -import org.eclipse.ui.ISelectionListener; -import org.eclipse.ui.ISelectionService; -import org.eclipse.ui.IWorkbenchPart; -import org.eclipse.ui.IWorkbenchPartSite; -import org.eclipse.ui.IWorkbenchWindow; -import org.eclipse.ui.internal.services.IWorkbenchLocationService; -import org.eclipse.ui.services.AbstractServiceFactory; -import org.eclipse.ui.services.IServiceLocator; -import org.osgi.framework.Bundle; -import org.osgi.framework.BundleContext; -import org.osgi.framework.FrameworkUtil; - -public class IEclipseContextServiceFactory extends AbstractServiceFactory { - - public IEclipseContextServiceFactory() { - } - - @SuppressWarnings("restriction") - @Override - public Object create(Class serviceInterface, IServiceLocator parentLocator, - IServiceLocator locator) { - if( ! IEclipseContext.class.equals(serviceInterface) ) { - return null; - } - - IWorkbenchLocationService wls = (IWorkbenchLocationService) locator.getService(IWorkbenchLocationService.class); - final IWorkbenchWindow window = wls.getWorkbenchWindow(); - final IWorkbenchPartSite site = wls.getPartSite(); - -// System.err.println("The locator: " + locator); -// System.err.println(" Window: " + window); -// System.err.println(" Site: " + site); - - Object o = parentLocator.getService(serviceInterface); - - // This happens when we run in plain 3.x - // We need to create a parent service context - if( window == null && site == null ) { - Bundle bundle = FrameworkUtil.getBundle(IEclipseContextServiceFactory.class); - BundleContext bundleContext = bundle.getBundleContext(); - IEclipseContext serviceContext = EclipseContextFactory.getServiceContext(bundleContext); - - final IEclipseContext appContext = serviceContext.createChild("WorkbenchContext"); //$NON-NLS-1$ - IExtensionRegistry registry = RegistryFactory.getRegistry(); - ReflectionContributionFactory contributionFactory = new ReflectionContributionFactory(registry); - appContext.set(IContributionFactory.class.getName(),contributionFactory); - - return appContext; - } else if( o != null && site == null ) { - final IEclipseContext windowContext = ((IEclipseContext)o).createChild("WindowContext("+window+")"); - windowContext.set(ISelectionService.class, window.getSelectionService()); - window.getSelectionService().addSelectionListener(new ISelectionListener() { - - public void selectionChanged(IWorkbenchPart part, ISelection selection) { - if( ! selection.isEmpty() ) { - if( ! (selection instanceof IStructuredSelection) ) { - windowContext.set(ISelection.class, selection); - } else { - IStructuredSelection s = (IStructuredSelection) selection; - if( s.size() == 1 ) { - windowContext.set(IServiceConstants.SELECTION, s.getFirstElement()); - } else { - windowContext.set(IServiceConstants.SELECTION, s.toList()); - } - } - } - } - }); - return windowContext; - } - - return o; - } -}
\ No newline at end of file diff --git a/bundles/org.eclipse.e4.tools.emf.editor3x/src/org/eclipse/e4/tools/emf/editor3x/compat/SelectionProviderContextFunction.java b/bundles/org.eclipse.e4.tools.emf.editor3x/src/org/eclipse/e4/tools/emf/editor3x/compat/SelectionProviderContextFunction.java deleted file mode 100644 index e908509e..00000000 --- a/bundles/org.eclipse.e4.tools.emf.editor3x/src/org/eclipse/e4/tools/emf/editor3x/compat/SelectionProviderContextFunction.java +++ /dev/null @@ -1,39 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2010 BestSolution.at and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * Tom Schindl <tom.schindl@bestsolution.at> - initial API and implementation - ******************************************************************************/ -package org.eclipse.e4.tools.emf.editor3x.compat; - -import java.util.List; - -import org.eclipse.e4.core.contexts.ContextFunction; -import org.eclipse.e4.core.contexts.IEclipseContext; -import org.eclipse.e4.tools.emf.ui.common.ISelectionProviderService; -import org.eclipse.jface.viewers.ISelectionProvider; -import org.eclipse.jface.viewers.StructuredSelection; - -public class SelectionProviderContextFunction extends ContextFunction { - - @Override - public Object compute(final IEclipseContext context) { - return new ISelectionProviderService() { - - public void setSelection(Object selection) { - ISelectionProvider pv = context.get(ISelectionProvider.class); - - if( selection instanceof List<?> ) { - pv.setSelection(new StructuredSelection((List<?>)selection)); - } else { - pv.setSelection(new StructuredSelection(selection)); - } - - } - }; - } -}
\ No newline at end of file diff --git a/bundles/org.eclipse.e4.tools.emf.ui/css/default.css b/bundles/org.eclipse.e4.tools.emf.ui/css/default.css index 751eb8fc..2117aec7 100644 --- a/bundles/org.eclipse.e4.tools.emf.ui/css/default.css +++ b/bundles/org.eclipse.e4.tools.emf.ui/css/default.css @@ -19,4 +19,9 @@ .formContainer { background-color: #fff; +} + +/* SingleSourcing Container */ +.E4WorkbenchModelEditor { + background-color: #fff; }
\ No newline at end of file |