Search in sources :

Example 1 with OverviewModelDef

use of org.obeonetwork.dsl.overview.OverviewModelDef in project InformationSystem by ObeoNetwork.

the class OverviewEditor 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.
    // Load the overviewModelDef with this ID
    OverviewModelDef overviewModelDef = null;
    for (OverviewModelDef ovvMDef : OverviewModelDefRegistry.getOverviewModelDefs()) {
        if (getOverviewModelDefID().equals(ovvMDef.getID())) {
            overviewModelDef = ovvMDef;
            break;
        }
    }
    adapterFactory = overviewModelDef.getAdapterFactory();
    // 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) CommandStackListener(org.eclipse.emf.common.command.CommandStackListener) Command(org.eclipse.emf.common.command.Command) LinkedHashMap(java.util.LinkedHashMap) HashMap(java.util.HashMap) OverviewModelDef(org.obeonetwork.dsl.overview.OverviewModelDef) BasicCommandStack(org.eclipse.emf.common.command.BasicCommandStack) EventObject(java.util.EventObject)

Example 2 with OverviewModelDef

use of org.obeonetwork.dsl.overview.OverviewModelDef in project InformationSystem by ObeoNetwork.

the class RootItemProvider method collectNewChildDescriptors.

/**
 * This adds {@link org.eclipse.emf.edit.command.CommandParameter}s
 * describing the children that can be created under this object. <!--
 * begin-user-doc --> <!-- end-user-doc -->
 *
 * @generated NOT
 */
@Override
protected void collectNewChildDescriptors(Collection<Object> newChildDescriptors, Object object) {
    if (object instanceof Root) {
        Root root = (Root) object;
        Collection<OverviewModelDef> overviewModelDefs = OverviewModelDefRegistry.getOverviewModelDefs();
        if (overviewModelDefs != null) {
            for (OverviewModelDef overviewModelDef : overviewModelDefs) {
                if (overviewModelDef.isApplicable(root)) {
                    Collection<?> childDescriptors = overviewModelDef.getNewChildDescriptors(root);
                    if (childDescriptors != null) {
                        newChildDescriptors.addAll(childDescriptors);
                    }
                }
            }
        }
    }
}
Also used : Root(org.obeonetwork.dsl.overview.Root) OverviewModelDef(org.obeonetwork.dsl.overview.OverviewModelDef)

Example 3 with OverviewModelDef

use of org.obeonetwork.dsl.overview.OverviewModelDef in project InformationSystem by ObeoNetwork.

the class OverviewModelWizard method init.

/**
 * This just records the information.
 * <!-- begin-user-doc -->
 * <!-- end-user-doc -->
 * @generated
 */
public void init(IWorkbench workbench, IStructuredSelection selection) {
    this.workbench = workbench;
    this.selection = selection;
    setWindowTitle(OverviewEditorPlugin.INSTANCE.getString("_UI_Wizard_label"));
    setDefaultPageImageDescriptor(ExtendedImageRegistry.INSTANCE.getImageDescriptor(OverviewEditorPlugin.INSTANCE.getImage("full/wizban/NewOverview")));
    // Load the overviewModelDef with this ID
    for (OverviewModelDef ovvMDef : OverviewModelDefRegistry.getOverviewModelDefs()) {
        if (getOverviewModelDefID().equals(ovvMDef.getID())) {
            this.overviewModelDef = ovvMDef;
            break;
        }
    }
    this.filenameExtension = overviewModelDef.getFileNameExtension();
}
Also used : OverviewModelDef(org.obeonetwork.dsl.overview.OverviewModelDef)

Aggregations

OverviewModelDef (org.obeonetwork.dsl.overview.OverviewModelDef)3 EventObject (java.util.EventObject)1 HashMap (java.util.HashMap)1 LinkedHashMap (java.util.LinkedHashMap)1 BasicCommandStack (org.eclipse.emf.common.command.BasicCommandStack)1 Command (org.eclipse.emf.common.command.Command)1 CommandStack (org.eclipse.emf.common.command.CommandStack)1 CommandStackListener (org.eclipse.emf.common.command.CommandStackListener)1 AdapterFactoryEditingDomain (org.eclipse.emf.edit.domain.AdapterFactoryEditingDomain)1 Root (org.obeonetwork.dsl.overview.Root)1