Search in sources :

Example 6 with CommandStackListener

use of org.eclipse.emf.common.command.CommandStackListener in project InformationSystem by ObeoNetwork.

the class ViewEditor method createPages.

/**
 * This is the method used by the framework to install your own controls.
 * <!-- begin-user-doc -->
 * <!-- end-user-doc -->
 * @generated NOT
 */
@Override
public void createPages() {
    // Creates the model from the editor input
    // 
    createModel();
    // 
    if (!getEditingDomain().getResourceSet().getResources().isEmpty()) {
        // Create a page for the selection tree view.
        // 
        Tree tree = new Tree(getContainer(), SWT.MULTI);
        selectionViewer = new TreeViewer(tree);
        setCurrentViewer(selectionViewer);
        selectionViewer.setContentProvider(new AdapterFactoryContentProvider(adapterFactory));
        selectionViewer.setLabelProvider(new AdapterFactoryLabelProvider(adapterFactory));
        selectionViewer.setInput(editingDomain.getResourceSet());
        selectionViewer.setSelection(new StructuredSelection(editingDomain.getResourceSet().getResources().get(0)), true);
        new AdapterFactoryTreeEditor(selectionViewer.getTree(), adapterFactory);
        getEditingDomain().getCommandStack().addCommandStackListener(new CommandStackListener() {

            public void commandStackChanged(EventObject event) {
                selectionViewer.refresh();
            }
        });
        createContextMenuFor(selectionViewer);
        int pageIndex = addPage(tree);
        setPageText(pageIndex, getString("_UI_SelectionPage_label"));
        getSite().getShell().getDisplay().asyncExec(new Runnable() {

            public void run() {
                setActivePage(0);
            }
        });
    }
    // Ensures that this editor will only display the page's tab
    // area if there are more than one page
    // 
    getContainer().addControlListener(new ControlAdapter() {

        boolean guard = false;

        @Override
        public void controlResized(ControlEvent event) {
            if (!guard) {
                guard = true;
                hideTabs();
                guard = false;
            }
        }
    });
    getSite().getShell().getDisplay().asyncExec(new Runnable() {

        public void run() {
            updateProblemIndication();
        }
    });
}
Also used : AdapterFactoryTreeEditor(org.eclipse.emf.edit.ui.celleditor.AdapterFactoryTreeEditor) CommandStackListener(org.eclipse.emf.common.command.CommandStackListener) ControlAdapter(org.eclipse.swt.events.ControlAdapter) TreeViewer(org.eclipse.jface.viewers.TreeViewer) StructuredSelection(org.eclipse.jface.viewers.StructuredSelection) IStructuredSelection(org.eclipse.jface.viewers.IStructuredSelection) AdapterFactoryContentProvider(org.eclipse.emf.edit.ui.provider.AdapterFactoryContentProvider) AdapterFactoryLabelProvider(org.eclipse.emf.edit.ui.provider.AdapterFactoryLabelProvider) EventObject(java.util.EventObject) Point(org.eclipse.swt.graphics.Point) Tree(org.eclipse.swt.widgets.Tree) ControlEvent(org.eclipse.swt.events.ControlEvent)

Example 7 with CommandStackListener

use of org.eclipse.emf.common.command.CommandStackListener in project InformationSystem by ObeoNetwork.

the class ViewEditor method initializeEditingDomain.

/**
 * This sets up the editing domain for the model editor.
 * <!-- begin-user-doc -->
 * <!-- end-user-doc -->
 * @generated
 */
protected void initializeEditingDomain() {
    // Create an adapter factory that yields item providers.
    // 
    adapterFactory = new ComposedAdapterFactory(ComposedAdapterFactory.Descriptor.Registry.INSTANCE);
    adapterFactory.addAdapterFactory(new ResourceItemProviderAdapterFactory());
    adapterFactory.addAdapterFactory(new CinematicItemProviderAdapterFactory());
    adapterFactory.addAdapterFactory(new ViewItemProviderAdapterFactory());
    adapterFactory.addAdapterFactory(new FlowItemProviderAdapterFactory());
    adapterFactory.addAdapterFactory(new ToolkitsItemProviderAdapterFactory());
    adapterFactory.addAdapterFactory(new EnvironmentItemProviderAdapterFactory());
    adapterFactory.addAdapterFactory(new TechnicalIDItemProviderAdapterFactory());
    adapterFactory.addAdapterFactory(new ReflectiveItemProviderAdapterFactory());
    // Create the command stack that will notify this editor as commands are executed.
    // 
    BasicCommandStack commandStack = new BasicCommandStack();
    // Add a listener to set the most recent command's affected objects to be the selection of the viewer with focus.
    // 
    commandStack.addCommandStackListener(new CommandStackListener() {

        public void commandStackChanged(final EventObject event) {
            getContainer().getDisplay().asyncExec(new Runnable() {

                public void run() {
                    firePropertyChange(IEditorPart.PROP_DIRTY);
                    // Try to select the affected objects.
                    // 
                    Command mostRecentCommand = ((CommandStack) event.getSource()).getMostRecentCommand();
                    if (mostRecentCommand != null) {
                        setSelectionToViewer(mostRecentCommand.getAffectedObjects());
                    }
                    for (Iterator<PropertySheetPage> i = propertySheetPages.iterator(); i.hasNext(); ) {
                        PropertySheetPage propertySheetPage = i.next();
                        if (propertySheetPage.getControl().isDisposed()) {
                            i.remove();
                        } else {
                            propertySheetPage.refresh();
                        }
                    }
                }
            });
        }
    });
    // Create the editing domain with a special command stack.
    // 
    editingDomain = new AdapterFactoryEditingDomain(adapterFactory, commandStack, new HashMap<Resource, Boolean>());
}
Also used : TechnicalIDItemProviderAdapterFactory(org.obeonetwork.dsl.technicalid.provider.TechnicalIDItemProviderAdapterFactory) AdapterFactoryEditingDomain(org.eclipse.emf.edit.domain.AdapterFactoryEditingDomain) BasicCommandStack(org.eclipse.emf.common.command.BasicCommandStack) CommandStack(org.eclipse.emf.common.command.CommandStack) FlowItemProviderAdapterFactory(org.obeonetwork.dsl.cinematic.flow.provider.FlowItemProviderAdapterFactory) PropertySheetPage(org.eclipse.ui.views.properties.PropertySheetPage) IPropertySheetPage(org.eclipse.ui.views.properties.IPropertySheetPage) ExtendedPropertySheetPage(org.eclipse.emf.edit.ui.view.ExtendedPropertySheetPage) ViewItemProviderAdapterFactory(org.obeonetwork.dsl.cinematic.view.provider.ViewItemProviderAdapterFactory) CommandStackListener(org.eclipse.emf.common.command.CommandStackListener) ResourceItemProviderAdapterFactory(org.eclipse.emf.edit.provider.resource.ResourceItemProviderAdapterFactory) LinkedHashMap(java.util.LinkedHashMap) HashMap(java.util.HashMap) ToolkitsItemProviderAdapterFactory(org.obeonetwork.dsl.cinematic.toolkits.provider.ToolkitsItemProviderAdapterFactory) ComposedAdapterFactory(org.eclipse.emf.edit.provider.ComposedAdapterFactory) BasicCommandStack(org.eclipse.emf.common.command.BasicCommandStack) EventObject(java.util.EventObject) ReflectiveItemProviderAdapterFactory(org.eclipse.emf.edit.provider.ReflectiveItemProviderAdapterFactory) Command(org.eclipse.emf.common.command.Command) EnvironmentItemProviderAdapterFactory(org.obeonetwork.dsl.environment.provider.EnvironmentItemProviderAdapterFactory) CinematicItemProviderAdapterFactory(org.obeonetwork.dsl.cinematic.provider.CinematicItemProviderAdapterFactory)

Example 8 with CommandStackListener

use of org.eclipse.emf.common.command.CommandStackListener in project InformationSystem by ObeoNetwork.

the class CinematicEditor method createPages.

/**
 * This is the method used by the framework to install your own controls.
 * <!-- begin-user-doc -->
 * <!-- end-user-doc -->
 * @generated NOT
 */
@Override
public void createPages() {
    // Creates the model from the editor input
    // 
    createModel();
    // 
    if (!getEditingDomain().getResourceSet().getResources().isEmpty()) {
        // Create a page for the selection tree view.
        // 
        Tree tree = new Tree(getContainer(), SWT.MULTI);
        selectionViewer = new TreeViewer(tree);
        setCurrentViewer(selectionViewer);
        selectionViewer.setContentProvider(new AdapterFactoryContentProvider(adapterFactory));
        selectionViewer.setLabelProvider(new AdapterFactoryLabelProvider(adapterFactory));
        selectionViewer.setInput(editingDomain.getResourceSet());
        selectionViewer.setSelection(new StructuredSelection(editingDomain.getResourceSet().getResources().get(0)), true);
        new AdapterFactoryTreeEditor(selectionViewer.getTree(), adapterFactory);
        getEditingDomain().getCommandStack().addCommandStackListener(new CommandStackListener() {

            public void commandStackChanged(EventObject event) {
                selectionViewer.refresh();
            }
        });
        createContextMenuFor(selectionViewer);
        int pageIndex = addPage(tree);
        setPageText(pageIndex, getString("_UI_SelectionPage_label"));
        getSite().getShell().getDisplay().asyncExec(new Runnable() {

            public void run() {
                setActivePage(0);
            }
        });
    }
    // Ensures that this editor will only display the page's tab
    // area if there are more than one page
    // 
    getContainer().addControlListener(new ControlAdapter() {

        boolean guard = false;

        @Override
        public void controlResized(ControlEvent event) {
            if (!guard) {
                guard = true;
                hideTabs();
                guard = false;
            }
        }
    });
    getSite().getShell().getDisplay().asyncExec(new Runnable() {

        public void run() {
            updateProblemIndication();
        }
    });
}
Also used : AdapterFactoryTreeEditor(org.eclipse.emf.edit.ui.celleditor.AdapterFactoryTreeEditor) CommandStackListener(org.eclipse.emf.common.command.CommandStackListener) ControlAdapter(org.eclipse.swt.events.ControlAdapter) TreeViewer(org.eclipse.jface.viewers.TreeViewer) StructuredSelection(org.eclipse.jface.viewers.StructuredSelection) IStructuredSelection(org.eclipse.jface.viewers.IStructuredSelection) AdapterFactoryContentProvider(org.eclipse.emf.edit.ui.provider.AdapterFactoryContentProvider) AdapterFactoryLabelProvider(org.eclipse.emf.edit.ui.provider.AdapterFactoryLabelProvider) EventObject(java.util.EventObject) Point(org.eclipse.swt.graphics.Point) Tree(org.eclipse.swt.widgets.Tree) ControlEvent(org.eclipse.swt.events.ControlEvent)

Example 9 with CommandStackListener

use of org.eclipse.emf.common.command.CommandStackListener in project InformationSystem by ObeoNetwork.

the class CinematicEditor method initializeEditingDomain.

/**
 * This sets up the editing domain for the model editor.
 * <!-- begin-user-doc -->
 * <!-- end-user-doc -->
 * @generated NOT
 */
protected void initializeEditingDomain() {
    // Create an adapter factory that yields item providers.
    // 
    adapterFactory = new ComposedAdapterFactory(ComposedAdapterFactory.Descriptor.Registry.INSTANCE);
    adapterFactory.addAdapterFactory(new ResourceItemProviderAdapterFactory());
    adapterFactory.addAdapterFactory(new CinematicItemProviderAdapterFactory());
    adapterFactory.addAdapterFactory(new ViewItemProviderAdapterFactory());
    adapterFactory.addAdapterFactory(new FlowItemProviderAdapterFactory());
    adapterFactory.addAdapterFactory(new ToolkitsItemProviderAdapterFactory());
    adapterFactory.addAdapterFactory(new EnvironmentItemProviderAdapterFactory());
    adapterFactory.addAdapterFactory(new ReflectiveItemProviderAdapterFactory());
    // Create the command stack that will notify this editor as commands are executed.
    // 
    BasicCommandStack commandStack = new BasicCommandStack();
    // Add a listener to set the most recent command's affected objects to be the selection of the viewer with focus.
    // 
    commandStack.addCommandStackListener(new CommandStackListener() {

        public void commandStackChanged(final EventObject event) {
            getContainer().getDisplay().asyncExec(new Runnable() {

                public void run() {
                    firePropertyChange(IEditorPart.PROP_DIRTY);
                    // Try to select the affected objects.
                    // 
                    Command mostRecentCommand = ((CommandStack) event.getSource()).getMostRecentCommand();
                    if (mostRecentCommand != null) {
                        setSelectionToViewer(mostRecentCommand.getAffectedObjects());
                    }
                    if (propertySheetPage != null && !propertySheetPage.getControl().isDisposed() && propertySheetPage.getCurrentTab() != null) {
                        propertySheetPage.refresh();
                    }
                }
            });
        }
    });
    // Create the editing domain with a special command stack.
    // 
    editingDomain = new AdapterFactoryEditingDomain(adapterFactory, commandStack, new HashMap<Resource, Boolean>());
}
Also used : AdapterFactoryEditingDomain(org.eclipse.emf.edit.domain.AdapterFactoryEditingDomain) BasicCommandStack(org.eclipse.emf.common.command.BasicCommandStack) CommandStack(org.eclipse.emf.common.command.CommandStack) FlowItemProviderAdapterFactory(org.obeonetwork.dsl.cinematic.flow.provider.FlowItemProviderAdapterFactory) ViewItemProviderAdapterFactory(org.obeonetwork.dsl.cinematic.view.provider.ViewItemProviderAdapterFactory) CommandStackListener(org.eclipse.emf.common.command.CommandStackListener) ResourceItemProviderAdapterFactory(org.eclipse.emf.edit.provider.resource.ResourceItemProviderAdapterFactory) LinkedHashMap(java.util.LinkedHashMap) HashMap(java.util.HashMap) ToolkitsItemProviderAdapterFactory(org.obeonetwork.dsl.cinematic.toolkits.provider.ToolkitsItemProviderAdapterFactory) ComposedAdapterFactory(org.eclipse.emf.edit.provider.ComposedAdapterFactory) BasicCommandStack(org.eclipse.emf.common.command.BasicCommandStack) EventObject(java.util.EventObject) ReflectiveItemProviderAdapterFactory(org.eclipse.emf.edit.provider.ReflectiveItemProviderAdapterFactory) Command(org.eclipse.emf.common.command.Command) EnvironmentItemProviderAdapterFactory(org.obeonetwork.dsl.environment.provider.EnvironmentItemProviderAdapterFactory) CinematicItemProviderAdapterFactory(org.obeonetwork.dsl.cinematic.provider.CinematicItemProviderAdapterFactory)

Example 10 with CommandStackListener

use of org.eclipse.emf.common.command.CommandStackListener in project InformationSystem by ObeoNetwork.

the class EnvironmentEditor method initializeEditingDomain.

/**
 * This sets up the editing domain for the model editor.
 * <!-- begin-user-doc -->
 * <!-- end-user-doc -->
 * @generated
 */
protected void initializeEditingDomain() {
    // Create an adapter factory that yields item providers.
    // 
    adapterFactory = new ComposedAdapterFactory(ComposedAdapterFactory.Descriptor.Registry.INSTANCE);
    adapterFactory.addAdapterFactory(new ResourceItemProviderAdapterFactory());
    adapterFactory.addAdapterFactory(new EnvironmentItemProviderAdapterFactory());
    adapterFactory.addAdapterFactory(new TechnicalIDItemProviderAdapterFactory());
    adapterFactory.addAdapterFactory(new ReflectiveItemProviderAdapterFactory());
    // Create the command stack that will notify this editor as commands are executed.
    // 
    BasicCommandStack commandStack = new BasicCommandStack();
    // Add a listener to set the most recent command's affected objects to be the selection of the viewer with focus.
    // 
    commandStack.addCommandStackListener(new CommandStackListener() {

        public void commandStackChanged(final EventObject event) {
            getContainer().getDisplay().asyncExec(new Runnable() {

                public void run() {
                    firePropertyChange(IEditorPart.PROP_DIRTY);
                    // Try to select the affected objects.
                    // 
                    Command mostRecentCommand = ((CommandStack) event.getSource()).getMostRecentCommand();
                    if (mostRecentCommand != null) {
                        setSelectionToViewer(mostRecentCommand.getAffectedObjects());
                    }
                    for (Iterator<PropertySheetPage> i = propertySheetPages.iterator(); i.hasNext(); ) {
                        PropertySheetPage propertySheetPage = i.next();
                        if (propertySheetPage.getControl().isDisposed()) {
                            i.remove();
                        } else {
                            propertySheetPage.refresh();
                        }
                    }
                }
            });
        }
    });
    // Create the editing domain with a special command stack.
    // 
    editingDomain = new AdapterFactoryEditingDomain(adapterFactory, commandStack, new HashMap<Resource, Boolean>());
}
Also used : TechnicalIDItemProviderAdapterFactory(org.obeonetwork.dsl.technicalid.provider.TechnicalIDItemProviderAdapterFactory) AdapterFactoryEditingDomain(org.eclipse.emf.edit.domain.AdapterFactoryEditingDomain) BasicCommandStack(org.eclipse.emf.common.command.BasicCommandStack) CommandStack(org.eclipse.emf.common.command.CommandStack) PropertySheetPage(org.eclipse.ui.views.properties.PropertySheetPage) IPropertySheetPage(org.eclipse.ui.views.properties.IPropertySheetPage) ExtendedPropertySheetPage(org.eclipse.emf.edit.ui.view.ExtendedPropertySheetPage) CommandStackListener(org.eclipse.emf.common.command.CommandStackListener) ResourceItemProviderAdapterFactory(org.eclipse.emf.edit.provider.resource.ResourceItemProviderAdapterFactory) LinkedHashMap(java.util.LinkedHashMap) HashMap(java.util.HashMap) ComposedAdapterFactory(org.eclipse.emf.edit.provider.ComposedAdapterFactory) BasicCommandStack(org.eclipse.emf.common.command.BasicCommandStack) EventObject(java.util.EventObject) ReflectiveItemProviderAdapterFactory(org.eclipse.emf.edit.provider.ReflectiveItemProviderAdapterFactory) Command(org.eclipse.emf.common.command.Command) EnvironmentItemProviderAdapterFactory(org.obeonetwork.dsl.environment.provider.EnvironmentItemProviderAdapterFactory)

Aggregations

EventObject (java.util.EventObject)35 CommandStackListener (org.eclipse.emf.common.command.CommandStackListener)35 HashMap (java.util.HashMap)30 LinkedHashMap (java.util.LinkedHashMap)30 BasicCommandStack (org.eclipse.emf.common.command.BasicCommandStack)30 Command (org.eclipse.emf.common.command.Command)30 CommandStack (org.eclipse.emf.common.command.CommandStack)30 AdapterFactoryEditingDomain (org.eclipse.emf.edit.domain.AdapterFactoryEditingDomain)30 ComposedAdapterFactory (org.eclipse.emf.edit.provider.ComposedAdapterFactory)29 ReflectiveItemProviderAdapterFactory (org.eclipse.emf.edit.provider.ReflectiveItemProviderAdapterFactory)29 ResourceItemProviderAdapterFactory (org.eclipse.emf.edit.provider.resource.ResourceItemProviderAdapterFactory)29 ExtendedPropertySheetPage (org.eclipse.emf.edit.ui.view.ExtendedPropertySheetPage)15 IPropertySheetPage (org.eclipse.ui.views.properties.IPropertySheetPage)15 PropertySheetPage (org.eclipse.ui.views.properties.PropertySheetPage)15 EnvironmentItemProviderAdapterFactory (org.obeonetwork.dsl.environment.provider.EnvironmentItemProviderAdapterFactory)13 EcoreItemProviderAdapterFactory (org.eclipse.emf.ecore.provider.EcoreItemProviderAdapterFactory)8 TechnicalIDItemProviderAdapterFactory (org.obeonetwork.dsl.technicalid.provider.TechnicalIDItemProviderAdapterFactory)8 AdapterFactoryTreeEditor (org.eclipse.emf.edit.ui.celleditor.AdapterFactoryTreeEditor)5 AdapterFactoryContentProvider (org.eclipse.emf.edit.ui.provider.AdapterFactoryContentProvider)5 AdapterFactoryLabelProvider (org.eclipse.emf.edit.ui.provider.AdapterFactoryLabelProvider)5