Search in sources :

Example 6 with TransactionalEditingDomain

use of org.eclipse.emf.transaction.TransactionalEditingDomain in project Palladio-Editors-Sirius by PalladioSimulator.

the class SiriusCustomUtil method selectViewpoints.

public static void selectViewpoints(Session session, HashSet<Viewpoint> viewpoints, boolean createRepresentation, IProgressMonitor monitor) {
    final ViewpointSelectionCallback selectionCallback = new ViewpointSelectionCallback();
    final TransactionalEditingDomain domain = session.getTransactionalEditingDomain();
    Collection<Viewpoint> selectedViewpoints = session.getSelectedViewpoints(false);
    for (Viewpoint v : viewpoints) {
        if (selectedViewpoints.contains(v))
            viewpoints.remove(v);
    }
    @SuppressWarnings("restriction") final Command command = new ChangeViewpointSelectionCommand(session, selectionCallback, viewpoints, new HashSet<Viewpoint>(), createRepresentation, SubMonitor.convert(monitor));
    domain.getCommandStack().execute(command);
}
Also used : TransactionalEditingDomain(org.eclipse.emf.transaction.TransactionalEditingDomain) CreateRepresentationCommand(org.eclipse.sirius.business.api.dialect.command.CreateRepresentationCommand) ChangeViewpointSelectionCommand(org.eclipse.sirius.ui.business.internal.commands.ChangeViewpointSelectionCommand) Command(org.eclipse.emf.common.command.Command) Viewpoint(org.eclipse.sirius.viewpoint.description.Viewpoint) ChangeViewpointSelectionCommand(org.eclipse.sirius.ui.business.internal.commands.ChangeViewpointSelectionCommand) ViewpointSelectionCallback(org.eclipse.sirius.ui.business.api.viewpoint.ViewpointSelectionCallback)

Example 7 with TransactionalEditingDomain

use of org.eclipse.emf.transaction.TransactionalEditingDomain in project Palladio-Editors-Sirius by PalladioSimulator.

the class SiriusCustomUtil method createRepresentation.

public static DRepresentation createRepresentation(Session session, String representationName, RepresentationDescription description, EObject semantic, IProgressMonitor monitor) {
    TransactionalEditingDomain domain = session.getTransactionalEditingDomain();
    final CreateRepresentationCommand createRepresentationCommand = new CreateRepresentationCommand(session, description, semantic, representationName, SubMonitor.convert(monitor));
    domain.getCommandStack().execute(createRepresentationCommand);
    return createRepresentationCommand.getCreatedRepresentation();
}
Also used : TransactionalEditingDomain(org.eclipse.emf.transaction.TransactionalEditingDomain) CreateRepresentationCommand(org.eclipse.sirius.business.api.dialect.command.CreateRepresentationCommand)

Example 8 with TransactionalEditingDomain

use of org.eclipse.emf.transaction.TransactionalEditingDomain in project Palladio-Editors-Sirius by PalladioSimulator.

the class EventTypesEditorSection method createViewerCellEditors.

/* (non-Javadoc)
	 * @see org.palladiosimulator.editors.commons.tabs.generic.EditorSection#createViewerCellEditors(org.eclipse.swt.widgets.Table)
	 */
@Override
protected CellEditor[] createViewerCellEditors(Table table) {
    CellEditor[] editors = new CellEditor[columnNames.length];
    editors[EVENTTYPENAME_COLUMN_INDEX] = new TextCellEditor(table);
    // create 'DeleteCellValueListener' and as SelectionListener to the 'TableVewer'
    EventTypeDeleteCellValueListener cellValueListener = new EventTypeDeleteCellValueListener(viewer);
    viewer.addSelectionChangedListener(cellValueListener);
    editors[PARAMETER_NAME_COLUMN_INDEX] = new TextCellEditor(table);
    editors[PARAMETER_TYPE_COLUMN_INDEX] = new TypeDialogCellEditor(table, cellValueListener) {

        /* (non-Javadoc)
			 * @see org.eclipse.jface.viewers.DialogCellEditor#openDialogBox(org.eclipse.swt.widgets.Control)
			 */
        @Override
        protected Object openDialogBox(Control cellEditorWindow) {
            TransactionalEditingDomain editingDomain = TransactionUtil.getEditingDomain(getSelectedEventType());
            ArrayList<Object> filterList = new ArrayList<Object>();
            filterList.add(DataType.class);
            filterList.add(Repository.class);
            ArrayList<EReference> additionalReferences = new ArrayList<EReference>();
            CallDataTypeDialog dialog = new CallDataTypeDialog(cellEditorWindow.getShell(), filterList, additionalReferences, editingDomain.getResourceSet());
            dialog.setProvidedService(DataType.class);
            dialog.open();
            if (!(dialog.getResult() instanceof DataType))
                return null;
            return dialog.getResult();
        }
    };
    return editors;
}
Also used : TextCellEditor(org.eclipse.jface.viewers.TextCellEditor) CellEditor(org.eclipse.jface.viewers.CellEditor) TypeDialogCellEditor(org.palladiosimulator.editors.commons.tabs.operations.TypeDialogCellEditor) ArrayList(java.util.ArrayList) TypeDialogCellEditor(org.palladiosimulator.editors.commons.tabs.operations.TypeDialogCellEditor) CallDataTypeDialog(org.palladiosimulator.editors.commons.dialogs.datatype.CallDataTypeDialog) Control(org.eclipse.swt.widgets.Control) Repository(org.palladiosimulator.pcm.repository.Repository) EventTypeDeleteCellValueListener(org.palladiosimulator.editors.commons.tabs.operations.EventTypeDeleteCellValueListener) TransactionalEditingDomain(org.eclipse.emf.transaction.TransactionalEditingDomain) DataType(org.palladiosimulator.pcm.repository.DataType) EObject(org.eclipse.emf.ecore.EObject) TextCellEditor(org.eclipse.jface.viewers.TextCellEditor) EReference(org.eclipse.emf.ecore.EReference)

Example 9 with TransactionalEditingDomain

use of org.eclipse.emf.transaction.TransactionalEditingDomain in project Palladio-Editors-Sirius by PalladioSimulator.

the class ResourceSelectorPage method getResult.

protected EObject getResult(Session session) {
    EObject result = null;
    URI uri = URI.createURI(path, true);
    TransactionalEditingDomain domain = session.getTransactionalEditingDomain();
    ResourceSet resourceSet = domain.getResourceSet();
    try {
        Resource resource = resourceSet.getResource(uri, true);
        result = (EObject) resource.getContents().get(0);
    } catch (WrappedException ex) {
    // do nothing
    }
    return result;
}
Also used : WrappedException(org.eclipse.emf.common.util.WrappedException) TransactionalEditingDomain(org.eclipse.emf.transaction.TransactionalEditingDomain) EObject(org.eclipse.emf.ecore.EObject) Resource(org.eclipse.emf.ecore.resource.Resource) ResourceSet(org.eclipse.emf.ecore.resource.ResourceSet) URI(org.eclipse.emf.common.util.URI)

Example 10 with TransactionalEditingDomain

use of org.eclipse.emf.transaction.TransactionalEditingDomain in project tdi-studio-se by Talend.

the class BusinessGraphicalNodeEditPolicy method getConnectionWithReorientedViewCompleteCommand.

/**
     * @generated
     */
protected Command getConnectionWithReorientedViewCompleteCommand(CreateConnectionRequest request) {
    ICommandProxy c = (ICommandProxy) super.getConnectionCompleteCommand(request);
    CompositeCommand cc = (CompositeCommand) c.getICommand();
    TransactionalEditingDomain editingDomain = ((IGraphicalEditPart) getHost()).getEditingDomain();
    BusinessReorientConnectionViewCommand rcvCommand = new BusinessReorientConnectionViewCommand(editingDomain, null);
    rcvCommand.setEdgeAdaptor(getViewAdapter());
    cc.compose(rcvCommand);
    return c;
}
Also used : IGraphicalEditPart(org.eclipse.gmf.runtime.diagram.ui.editparts.IGraphicalEditPart) ICommandProxy(org.eclipse.gmf.runtime.diagram.ui.commands.ICommandProxy) TransactionalEditingDomain(org.eclipse.emf.transaction.TransactionalEditingDomain) BusinessReorientConnectionViewCommand(org.talend.designer.business.model.business.diagram.edit.commands.BusinessReorientConnectionViewCommand) CompositeCommand(org.eclipse.gmf.runtime.common.core.command.CompositeCommand)

Aggregations

TransactionalEditingDomain (org.eclipse.emf.transaction.TransactionalEditingDomain)17 EObject (org.eclipse.emf.ecore.EObject)7 ArrayList (java.util.ArrayList)5 Resource (org.eclipse.emf.ecore.resource.Resource)5 ResourceSet (org.eclipse.emf.ecore.resource.ResourceSet)4 WrappedException (org.eclipse.emf.common.util.WrappedException)3 IGraphicalEditPart (org.eclipse.gmf.runtime.diagram.ui.editparts.IGraphicalEditPart)3 CompositeTransactionalCommand (org.eclipse.gmf.runtime.emf.commands.core.command.CompositeTransactionalCommand)3 IOException (java.io.IOException)2 List (java.util.List)2 ExecutionException (org.eclipse.core.commands.ExecutionException)2 IFile (org.eclipse.core.resources.IFile)2 IAdaptable (org.eclipse.core.runtime.IAdaptable)2 IProgressMonitor (org.eclipse.core.runtime.IProgressMonitor)2 SubProgressMonitor (org.eclipse.core.runtime.SubProgressMonitor)2 URI (org.eclipse.emf.common.util.URI)2 EReference (org.eclipse.emf.ecore.EReference)2 Command (org.eclipse.gef.commands.Command)2 UnexecutableCommand (org.eclipse.gef.commands.UnexecutableCommand)2 ICommand (org.eclipse.gmf.runtime.common.core.command.ICommand)2