org.eclipse.emf.edit.domain.AdapterFactoryEditingDomain Java Examples

The following examples show how to use org.eclipse.emf.edit.domain.AdapterFactoryEditingDomain. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: JointCommands.java    From graph-editor with Eclipse Public License 1.0 6 votes vote down vote up
/**
 * Removes any existing joints from the connection and creates a new set of joints at the given positions.
 *
 * <p>
 * This is executed as a single compound command and is therefore a single element in the undo-redo stack.
 * </p>
 *
 * @param positions a list of {@link Point2D} instances speciying the x and y positions of the new joints
 * @param connection the connection in which the joints will be set
 */
public static void setNewJoints(final List<Point2D> positions, final GConnection connection) {

    final EditingDomain editingDomain = AdapterFactoryEditingDomain.getEditingDomainFor(connection);
    final CompoundCommand command = new CompoundCommand();

    command.append(RemoveCommand.create(editingDomain, connection, JOINTS, connection.getJoints()));

    for (final Point2D position : positions) {

        final GJoint newJoint = GraphFactory.eINSTANCE.createGJoint();
        newJoint.setX(position.getX());
        newJoint.setY(position.getY());

        command.append(AddCommand.create(editingDomain, connection, JOINTS, newJoint));
    }

    if (command.canExecute()) {
        editingDomain.getCommandStack().execute(command);
    }
}
 
Example #2
Source File: SearchUtils.java    From slr-toolkit with Eclipse Public License 1.0 6 votes vote down vote up
/**
 * Helper function to get a list of documents from a resource
 * 
 * @param r
 *            The resource
 * @return
 */
public static List<Document> getDocumentList() {
	ArrayList<Document> results = new ArrayList<>();
	ArrayList<Resource> resources = null;
	Optional<AdapterFactoryEditingDomain> oDomain = ModelRegistryPlugin.getModelRegistry().getEditingDomain();
	if (oDomain.isPresent()) {
		resources = new ArrayList<>(oDomain.get().getResourceSet().getResources());
		for(Resource r : resources) {
			for (EObject e : r.getContents()) {
				if (e instanceof Document) {
					results.add((Document) e);
				}
			}
		}
	}
	return results;
}
 
Example #3
Source File: DeleteHandler.java    From bonita-studio with GNU General Public License v2.0 6 votes vote down vote up
public void removeMessage(final MessageFlow flow) {
    final MainProcess diagram = ModelHelper.getMainProcess(flow);
    Assert.isNotNull(diagram);
    final AbstractCatchMessageEvent catchEvent = flow.getTarget();
    final ThrowMessageEvent thowEvent = flow.getSource();
    final EditingDomain domain = AdapterFactoryEditingDomain.getEditingDomainFor(diagram);
    Assert.isNotNull(domain);
    final CompoundCommand cc = new CompoundCommand();
    if (flow.getSource() != null) {
        final List<Message> messages = flow.getSource().getEvents();
        for (final Message message : messages) {
            if (flow.getName().equals(message.getName())) {
                cc.append(DeleteCommand.create(domain, message));
                break;
            }
        }
    }
    cc.append(SetCommand.create(domain, catchEvent, ProcessPackage.Literals.ABSTRACT_CATCH_MESSAGE_EVENT__EVENT, null));
    domain.getCommandStack().execute(cc);
}
 
Example #4
Source File: CustomCutCommand.java    From bonita-studio with GNU General Public License v2.0 6 votes vote down vote up
@Override
protected CommandResult doExecuteWithResult(
		IProgressMonitor progressMonitor, IAdaptable info)
		throws ExecutionException {
	
	Clipboard.setToCopyEditParts(toCopyElement);
	TransactionalEditingDomain domain = (TransactionalEditingDomain) AdapterFactoryEditingDomain.getEditingDomainFor(toCopyElement);
	domain.getCommandStack().execute(new RecordingCommand(domain) {
		protected void doExecute() {
			for (IGraphicalEditPart part : toCopyElement) {
				EcoreUtil.delete(part.resolveSemanticElement());
			}
		}
	});		
	
	return CommandResult.newOKCommandResult();
}
 
Example #5
Source File: GraphEditorPersistence.java    From graph-editor with Eclipse Public License 1.0 6 votes vote down vote up
/**
 * Saves the graph editor's model state in the given file.
 *
 * @param file the {@link File} the model state will be saved in
 * @param model the {@link GModel} to be saved
 */
private void saveModel(final File file, final GModel model) {

    String absolutePath = file.getAbsolutePath();
    if (!absolutePath.endsWith(FILE_EXTENSION)) {
        absolutePath += FILE_EXTENSION;
    }

    final EditingDomain editingDomain = AdapterFactoryEditingDomain.getEditingDomainFor(model);

    final URI fileUri = URI.createFileURI(absolutePath);
    final XMIResourceFactoryImpl resourceFactory = new XMIResourceFactoryImpl();
    final Resource resource = resourceFactory.createResource(fileUri);
    resource.getContents().add(model);

    try {
        resource.save(Collections.EMPTY_MAP);
    } catch (final IOException e) {
        e.printStackTrace();
    }

    editingDomain.getResourceSet().getResources().clear();
    editingDomain.getResourceSet().getResources().add(resource);

    initialDirectory = file.getParentFile();
}
 
Example #6
Source File: TitledSkinController.java    From graph-editor with Eclipse Public License 1.0 6 votes vote down vote up
/**
 * Allocates ID's to recently pasted nodes.
 * 
 * @param nodes the recently pasted nodes
 * @param command the command responsible for adding the nodes
 */
private void allocateIds(final List<GNode> nodes, final CompoundCommand command) {

    final EditingDomain domain = AdapterFactoryEditingDomain.getEditingDomainFor(graphEditor.getModel());
    final EAttribute feature = GraphPackage.Literals.GNODE__ID;

    for (final GNode node : nodes) {

        if (checkNeedsNewId(node, nodes)) {

            final String id = allocateNewId();
            final Command setCommand = SetCommand.create(domain, node, feature, id);

            if (setCommand.canExecute()) {
                command.appendAndExecute(setCommand);
            }

            graphEditor.getSkinLookup().lookupNode(node).initialize();
        }
    }
}
 
Example #7
Source File: ImportWorkspaceApplication.java    From bonita-studio with GNU General Public License v2.0 6 votes vote down vote up
private boolean isSPDiagram(File file) {
    ComposedAdapterFactory adapterFactory = new ComposedAdapterFactory(
            ComposedAdapterFactory.Descriptor.Registry.INSTANCE);
    adapterFactory.addAdapterFactory(new ProcessAdapterFactory());
    adapterFactory.addAdapterFactory(new ParameterAdapterFactory());
    adapterFactory.addAdapterFactory(new ConnectorDefinitionAdapterFactory());
    adapterFactory
            .addAdapterFactory(new ResourceItemProviderAdapterFactory());
    adapterFactory
            .addAdapterFactory(new ReflectiveItemProviderAdapterFactory());
    AdapterFactoryEditingDomain editingDomain = new AdapterFactoryEditingDomain(adapterFactory,
            new BasicCommandStack(), new HashMap<Resource, Boolean>());
    URI fileURI = URI.createFileURI(file.getAbsolutePath());
    editingDomain.getResourceSet().getLoadOptions().put(XMIResource.OPTION_RECORD_UNKNOWN_FEATURE, Boolean.TRUE);
    Resource resource = editingDomain.getResourceSet().getResource(fileURI, true);
    MainProcess process = (MainProcess) resource.getContents().get(0);
    return process.getConfigId().toString().contains("sp");
}
 
Example #8
Source File: FillFieldNumbersHandler.java    From neoscada with Eclipse Public License 1.0 6 votes vote down vote up
@Override
public Object execute ( final ExecutionEvent event ) throws ExecutionException
{

    final IEditorPart editor = getActivePage ().getActiveEditor ();

    byte b = (byte)1;
    for ( final Attribute attribute : SelectionHelper.iterable ( getSelection (), Attribute.class ) )
    {
        EditingDomain domain = AdapterFactoryEditingDomain.getEditingDomainFor ( attribute );

        if ( domain == null && editor instanceof IEditingDomainProvider )
        {
            domain = ( (IEditingDomainProvider)editor ).getEditingDomain ();
        }

        SetCommand.create ( domain, attribute, ProtocolPackage.Literals.ATTRIBUTE__FIELD_NUMBER, b ).execute ();

        b++;
    }

    return null;
}
 
Example #9
Source File: SetExternalNameWizard.java    From neoscada with Eclipse Public License 1.0 6 votes vote down vote up
public void setExternalName ( final CompiledScript script ) throws Exception
{
    final CompoundManager manager = new CompoundManager ();

    for ( final ExternalValue v : SelectionHelper.iterable ( this.selection, ExternalValue.class ) )
    {
        final EditingDomain domain = AdapterFactoryEditingDomain.getEditingDomainFor ( v );
        if ( domain == null )
        {
            continue;
        }
        final String name = evalName ( script, v );
        manager.append ( domain, SetCommand.create ( domain, v, ComponentPackage.Literals.EXTERNAL_VALUE__SOURCE_NAME, name ) );
    }

    manager.executeAll ();
}
 
Example #10
Source File: SetConnectionHandler.java    From neoscada with Eclipse Public License 1.0 6 votes vote down vote up
public void setConnection ( final Driver driver )
{
    final CompoundManager manager = new CompoundManager ();

    for ( final ExternalValue v : SelectionHelper.iterable ( getSelection (), ExternalValue.class ) )
    {
        final EditingDomain domain = AdapterFactoryEditingDomain.getEditingDomainFor ( v );
        if ( domain == null )
        {
            continue;
        }
        manager.append ( domain, SetCommand.create ( domain, v, ComponentPackage.Literals.EXTERNAL_VALUE__CONNECTION, driver ) );
    }

    manager.executeAll ();
}
 
Example #11
Source File: ConnectionCommands.java    From graph-editor with Eclipse Public License 1.0 6 votes vote down vote up
/**
 * Removes a connection from the model.
 *
 * @param model the {@link GModel} from which the connection should be removed
 * @param connection the {@link GConnection} to be removed
 * @return the newly-executed {@link CompoundCommand} that removed the connection
 */
public static CompoundCommand removeConnection(final GModel model, final GConnection connection) {

    final EditingDomain editingDomain = AdapterFactoryEditingDomain.getEditingDomainFor(model);

    if (editingDomain != null) {
        final CompoundCommand command = new CompoundCommand();

        final GConnector source = connection.getSource();
        final GConnector target = connection.getTarget();

        command.append(RemoveCommand.create(editingDomain, model, CONNECTIONS, connection));
        command.append(RemoveCommand.create(editingDomain, source, CONNECTOR_CONNECTIONS, connection));
        command.append(RemoveCommand.create(editingDomain, target, CONNECTOR_CONNECTIONS, connection));

        if (command.canExecute()) {
            editingDomain.getCommandStack().execute(command);
        }
        return command;

    } else {
        return null;
    }
}
 
Example #12
Source File: SelectionCopier.java    From graph-editor with Eclipse Public License 1.0 6 votes vote down vote up
/**
 * Adds the pasted elements to the graph editor via a single EMF command.
 *
 * @param pastedNodes the pasted nodes to be added
 * @param pastedConnections the pasted connections to be added
 * @param consumer a consumer to allow custom commands to be appended to the paste command
 */
private void addPastedElements(final List<GNode> pastedNodes, final List<GConnection> pastedConnections,
        final BiConsumer<List<GNode>, CompoundCommand> consumer) {

    final EditingDomain editingDomain = AdapterFactoryEditingDomain.getEditingDomainFor(model);
    final CompoundCommand command = new CompoundCommand();

    for (final GNode pastedNode : pastedNodes) {
        command.append(AddCommand.create(editingDomain, model, NODES, pastedNode));
    }

    for (final GConnection pastedConnection : pastedConnections) {
        command.append(AddCommand.create(editingDomain, model, CONNECTIONS, pastedConnection));
    }

    if (command.canExecute()) {
        editingDomain.getCommandStack().execute(command);
    }

    if (consumer != null) {
        consumer.accept(pastedNodes, command);
    }

}
 
Example #13
Source File: TestConnectorOperation.java    From bonita-studio with GNU General Public License v2.0 6 votes vote down vote up
private AdapterFactoryEditingDomain createEditingDomain() {
    final ComposedAdapterFactory adapterFactory = new ComposedAdapterFactory(
            ComposedAdapterFactory.Descriptor.Registry.INSTANCE);
    adapterFactory.addAdapterFactory(new ResourceItemProviderAdapterFactory());
    adapterFactory.addAdapterFactory(new ReflectiveItemProviderAdapterFactory());
    adapterFactory.addAdapterFactory(new ConfigurationAdapterFactory());
    adapterFactory.addAdapterFactory(new ProcessAdapterFactory());

    // command stack that will notify this editor as commands are executed
    final BasicCommandStack commandStack = new BasicCommandStack();

    // Create the editing domain with our adapterFactory and command stack.
    final AdapterFactoryEditingDomain editingDomain = new AdapterFactoryEditingDomain(adapterFactory, commandStack,
            new HashMap<Resource, Boolean>());
    editingDomain.getResourceSet().getResourceFactoryRegistry().getExtensionToFactoryMap().put("conf",
            new ConfigurationResourceFactoryImpl());
    return editingDomain;
}
 
Example #14
Source File: PreviewEditorImpl.java    From neoscada with Eclipse Public License 1.0 6 votes vote down vote up
public PreviewEditorImpl ()
{
    this.adapterFactory = new ComposedAdapterFactory ( ComposedAdapterFactory.Descriptor.Registry.INSTANCE );
    this.adapterFactory.addAdapterFactory ( new ResourceItemProviderAdapterFactory () );
    this.adapterFactory.addAdapterFactory ( new ReflectiveItemProviderAdapterFactory () );

    final BasicCommandStack commandStack = new BasicCommandStack ();

    this.editingDomain = new AdapterFactoryEditingDomain ( this.adapterFactory, commandStack, new HashMap<Resource, Boolean> () );

    this.factoryContext = new FactoryContext () {

        @Override
        public void loadedResource ( final URI uri )
        {
            handleLoadedResource ( uri );
        }
    };

    ResourcesPlugin.getWorkspace ().addResourceChangeListener ( this.resourceChangeListener, IResourceChangeEvent.POST_CHANGE );
}
 
Example #15
Source File: ModelRegistry.java    From slr-toolkit with Eclipse Public License 1.0 5 votes vote down vote up
public void setEditingDomain(AdapterFactoryEditingDomain editingDomain) {
	if (sharedEditingDomain != editingDomain) {
		sharedEditingDomain = editingDomain;
		setChanged();
		notifyObservers(sharedEditingDomain);
	}
}
 
Example #16
Source File: GraphEditorTest.java    From graph-editor with Eclipse Public License 1.0 5 votes vote down vote up
@Before
public void setUp() {

    graphEditor = new DefaultGraphEditor();
    model = DummyDataFactory.createModel();
    skinLookup = graphEditor.getSkinLookup();

    graphEditor.setModel(model);

    editingDomain = AdapterFactoryEditingDomain.getEditingDomainFor(model);
    if (editingDomain != null) {
        commandStack = editingDomain.getCommandStack();
    }
}
 
Example #17
Source File: ConnectionCommands.java    From graph-editor with Eclipse Public License 1.0 5 votes vote down vote up
/**
 * Adds a connection to the model.
 *
 * @param model the {@link GModel} to which the connection should be added
 * @param source the source {@link GConnector} of the new connection
 * @param target the target {@link GConnector} of the new connection
 * @param type the type attribute for the new connection
 * @param joints the list of {@link GJoint} instances to be added inside the new connection
 * @return the newly-executed {@link CompoundCommand} that added the connection
 */
public static CompoundCommand addConnection(final GModel model, final GConnector source, final GConnector target,
        final String type, final List<GJoint> joints) {

    final EditingDomain editingDomain = AdapterFactoryEditingDomain.getEditingDomainFor(model);

    if (editingDomain != null) {
        final CompoundCommand command = new CompoundCommand();

        final GConnection connection = GraphFactory.eINSTANCE.createGConnection();

        command.append(AddCommand.create(editingDomain, model, CONNECTIONS, connection));

        if (type != null) {
            command.append(SetCommand.create(editingDomain, connection, CONNECTION_TYPE, type));
        }

        command.append(SetCommand.create(editingDomain, connection, SOURCE, source));
        command.append(SetCommand.create(editingDomain, connection, TARGET, target));
        command.append(AddCommand.create(editingDomain, source, CONNECTOR_CONNECTIONS, connection));
        command.append(AddCommand.create(editingDomain, target, CONNECTOR_CONNECTIONS, connection));

        for (final GJoint joint : joints) {
            command.append(AddCommand.create(editingDomain, connection, JOINTS, joint));
        }

        if (command.canExecute()) {
            editingDomain.getCommandStack().execute(command);
        }
        return command;

    } else {
        return null;
    }
}
 
Example #18
Source File: JointCommands.java    From graph-editor with Eclipse Public License 1.0 5 votes vote down vote up
/**
 * Removes joints from a connection.
 *
 * <p>
 * This method adds the remove operations to the given compound command and does not execute it.
 * </p>
 *
 * @param command a {@link CompoundCommand} to which the remove commands will be added
 * @param indices the indices within the connection's list of joints specifying the joints to be removed
 * @param connection the connection whose joints are to be removed
 */
public static void removeJoints(final CompoundCommand command, final Set<Integer> indices,
        final GConnection connection) {

    final EditingDomain editingDomain = AdapterFactoryEditingDomain.getEditingDomainFor(connection);

    for (int i = 0; i < connection.getJoints().size(); i++) {
        if (indices.contains(i)) {
            final GJoint joint = connection.getJoints().get(i);
            command.append(RemoveCommand.create(editingDomain, connection, JOINTS, joint));
        }
    }
}
 
Example #19
Source File: ConnectorWizard.java    From bonita-studio with GNU General Public License v2.0 5 votes vote down vote up
@Override
public boolean performFinish() {
    final EditingDomain editingDomain = AdapterFactoryEditingDomain
            .getEditingDomainFor(container);
    if (editMode) {
        modelUpdater.update();
    } else {
        editingDomain.getCommandStack().execute(
                createPerformFinishCommandOnCreation(editingDomain));
    }
    return true;
}
 
Example #20
Source File: ConfigurationSynchronizer.java    From bonita-studio with GNU General Public License v2.0 5 votes vote down vote up
public ConfigurationSynchronizer(final AbstractProcess process, final Configuration configuration) {
    this();
    this.process = process;
    this.configuration = configuration;
    synchronizeLocalConfiguraiton = ConfigurationPreferenceConstants.LOCAL_CONFIGURAITON.equals(configuration.getName()) || configuration.getName() == null;
    editingDomain = (AdapterFactoryEditingDomain) TransactionUtil.getEditingDomain(process);
}
 
Example #21
Source File: ConfigurationSynchronizer.java    From bonita-studio with GNU General Public License v2.0 5 votes vote down vote up
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 ReflectiveItemProviderAdapterFactory());
    adapterFactory.addAdapterFactory(new ConfigurationAdapterFactory());
    adapterFactory.addAdapterFactory(new ProcessAdapterFactory());

    // command stack that will notify this editor as commands are executed
    final BasicCommandStack commandStack = new BasicCommandStack();

    // Create the editing domain with our adapterFactory and command stack.
    editingDomain = new AdapterFactoryEditingDomain(adapterFactory, commandStack, new HashMap<Resource, Boolean>());
    editingDomain.getResourceSet().getResourceFactoryRegistry().getExtensionToFactoryMap().put("conf", new ConfigurationResourceFactoryImpl());
}
 
Example #22
Source File: CoreEditor.java    From ifml-editor with MIT License 5 votes vote down vote up
/**
 * Handles what to do with changed resources on activation.
 * <!-- begin-user-doc -->
 * <!-- end-user-doc -->
 * @generated
 */
protected void handleChangedResources() {
	if (!changedResources.isEmpty() && (!isDirty() || handleDirtyConflict())) {
		if (isDirty()) {
			changedResources.addAll(editingDomain.getResourceSet().getResources());
		}
		editingDomain.getCommandStack().flush();

		updateProblemIndication = false;
		for (Resource resource : changedResources) {
			if (resource.isLoaded()) {
				resource.unload();
				try {
					resource.load(Collections.EMPTY_MAP);
				}
				catch (IOException exception) {
					if (!resourceToDiagnosticMap.containsKey(resource)) {
						resourceToDiagnosticMap.put(resource, analyzeResourceProblems(resource, exception));
					}
				}
			}
		}

		if (AdapterFactoryEditingDomain.isStale(editorSelection)) {
			setSelection(StructuredSelection.EMPTY);
		}

		updateProblemIndication = true;
		updateProblemIndication();
	}
}
 
Example #23
Source File: Commands.java    From graph-editor with Eclipse Public License 1.0 5 votes vote down vote up
/**
 * Gets the editing domain associated to the model.
 * 
 * <p>
 * Logs an error if none is found.
 * </p>
 * 
 * @param model a {@link GModel} instance
 * @return the {@link EditingDomain} associated to this model instance
 */
private static EditingDomain getEditingDomain(final GModel model) {

    final EditingDomain editingDomain = AdapterFactoryEditingDomain.getEditingDomainFor(model);

    if (editingDomain == null) {
        LOGGER.error(LogMessages.NO_EDITING_DOMAIN);
    }

    return editingDomain;
}
 
Example #24
Source File: BeansEditor.java    From hybris-commerce-eclipse-plugin with Apache License 2.0 5 votes vote down vote up
/**
 * Handles what to do with changed resources on activation.
 * <!-- begin-user-doc -->
 * <!-- end-user-doc -->
 * @generated
 */
protected void handleChangedResources() {
	if (!changedResources.isEmpty() && (!isDirty() || handleDirtyConflict())) {
		if (isDirty()) {
			changedResources.addAll(editingDomain.getResourceSet().getResources());
		}
		editingDomain.getCommandStack().flush();

		updateProblemIndication = false;
		for (Resource resource : changedResources) {
			if (resource.isLoaded()) {
				resource.unload();
				try {
					resource.load(Collections.EMPTY_MAP);
				}
				catch (IOException exception) {
					if (!resourceToDiagnosticMap.containsKey(resource)) {
						resourceToDiagnosticMap.put(resource, analyzeResourceProblems(resource, exception));
					}
				}
			}
		}

		if (AdapterFactoryEditingDomain.isStale(editorSelection)) {
			setSelection(StructuredSelection.EMPTY);
		}

		updateProblemIndication = true;
		updateProblemIndication();
	}
}
 
Example #25
Source File: GenconfEditor.java    From M2Doc with Eclipse Public License 1.0 5 votes vote down vote up
/**
 * Handles what to do with changed resources on activation.
 * <!-- begin-user-doc -->
 * <!-- end-user-doc -->
 * 
 * @generated
 */
protected void handleChangedResources() {
    if (!changedResources.isEmpty() && (!isDirty() || handleDirtyConflict())) {
        if (isDirty()) {
            changedResources.addAll(editingDomain.getResourceSet().getResources());
        }
        editingDomain.getCommandStack().flush();

        updateProblemIndication = false;
        for (Resource resource : changedResources) {
            if (resource.isLoaded()) {
                resource.unload();
                try {
                    resource.load(Collections.EMPTY_MAP);
                } catch (IOException exception) {
                    if (!resourceToDiagnosticMap.containsKey(resource)) {
                        resourceToDiagnosticMap.put(resource, analyzeResourceProblems(resource, exception));
                    }
                }
            }
        }

        if (AdapterFactoryEditingDomain.isStale(editorSelection)) {
            setSelection(StructuredSelection.EMPTY);
        }

        updateProblemIndication = true;
        updateProblemIndication();
    }
}
 
Example #26
Source File: CrossflowEditor.java    From scava with Eclipse Public License 2.0 5 votes vote down vote up
/**
 * Handles what to do with changed resources on activation.
 * <!-- begin-user-doc -->
 * <!-- end-user-doc -->
 * @generated
 */
protected void handleChangedResources() {
	if (!changedResources.isEmpty() && (!isDirty() || handleDirtyConflict())) {
		ResourceSet resourceSet = editingDomain.getResourceSet();
		if (isDirty()) {
			changedResources.addAll(resourceSet.getResources());
		}
		editingDomain.getCommandStack().flush();

		updateProblemIndication = false;
		for (Resource resource : changedResources) {
			if (resource.isLoaded()) {
				resource.unload();
				try {
					resource.load(resourceSet.getLoadOptions());
				}
				catch (IOException exception) {
					if (!resourceToDiagnosticMap.containsKey(resource)) {
						resourceToDiagnosticMap.put(resource, analyzeResourceProblems(resource, exception));
					}
				}
			}
		}

		if (AdapterFactoryEditingDomain.isStale(editorSelection)) {
			setSelection(StructuredSelection.EMPTY);
		}

		updateProblemIndication = true;
		updateProblemIndication();
	}
}
 
Example #27
Source File: ConfigurationEditor.java    From neoscada with Eclipse Public License 1.0 5 votes vote down vote up
/**
 * Handles what to do with changed resources on activation.
 * <!-- begin-user-doc -->
 * <!-- end-user-doc -->
 * @generated
 */
protected void handleChangedResources ()
{
    if ( !changedResources.isEmpty () && ( !isDirty () || handleDirtyConflict () ) )
    {
        if ( isDirty () )
        {
            changedResources.addAll ( editingDomain.getResourceSet ().getResources () );
        }
        editingDomain.getCommandStack ().flush ();

        updateProblemIndication = false;
        for ( Resource resource : changedResources )
        {
            if ( resource.isLoaded () )
            {
                resource.unload ();
                try
                {
                    resource.load ( Collections.EMPTY_MAP );
                }
                catch ( IOException exception )
                {
                    if ( !resourceToDiagnosticMap.containsKey ( resource ) )
                    {
                        resourceToDiagnosticMap.put ( resource, analyzeResourceProblems ( resource, exception ) );
                    }
                }
            }
        }

        if ( AdapterFactoryEditingDomain.isStale ( editorSelection ) )
        {
            setSelection ( StructuredSelection.EMPTY );
        }

        updateProblemIndication = true;
        updateProblemIndication ();
    }
}
 
Example #28
Source File: WorkflowModelServerAccess.java    From graphical-lsp with Eclipse Public License 2.0 5 votes vote down vote up
public WorkflowModelServerAccess(String sourceURI, ModelServerClient modelServerClient,
		AdapterFactory adapterFactory, CommandCodec commandCodec) {
	Preconditions.checkNotNull(modelServerClient);
	this.sourceURI = sourceURI;
	this.modelServerClient = modelServerClient;
	this.resourceSet = setupResourceSet();
	this.editingDomain = new AdapterFactoryEditingDomain(adapterFactory, new BasicCommandStack(), resourceSet);
	this.commandCodec = commandCodec;
}
 
Example #29
Source File: ConvertToExternalHandler.java    From neoscada with Eclipse Public License 1.0 5 votes vote down vote up
private void replace ( final CompoundManager manager, final SingleValue v )
{
    if ( v instanceof ExternalValue )
    {
        return;
    }

    final EditingDomain domain = AdapterFactoryEditingDomain.getEditingDomainFor ( v );

    final Command command = ReplaceCommand.create ( domain, v.eContainer (), v.eContainmentFeature (), v, Collections.singletonList ( convert ( v ) ) );
    manager.append ( domain, command );
}
 
Example #30
Source File: ItemEditor.java    From neoscada with Eclipse Public License 1.0 5 votes vote down vote up
/**
 * Handles what to do with changed resources on activation.
 * <!-- begin-user-doc -->
 * <!-- end-user-doc -->
 * @generated
 */
protected void handleChangedResources ()
{
    if ( !changedResources.isEmpty () && ( !isDirty () || handleDirtyConflict () ) )
    {
        if ( isDirty () )
        {
            changedResources.addAll ( editingDomain.getResourceSet ().getResources () );
        }
        editingDomain.getCommandStack ().flush ();

        updateProblemIndication = false;
        for ( Resource resource : changedResources )
        {
            if ( resource.isLoaded () )
            {
                resource.unload ();
                try
                {
                    resource.load ( Collections.EMPTY_MAP );
                }
                catch ( IOException exception )
                {
                    if ( !resourceToDiagnosticMap.containsKey ( resource ) )
                    {
                        resourceToDiagnosticMap.put ( resource, analyzeResourceProblems ( resource, exception ) );
                    }
                }
            }
        }

        if ( AdapterFactoryEditingDomain.isStale ( editorSelection ) )
        {
            setSelection ( StructuredSelection.EMPTY );
        }

        updateProblemIndication = true;
        updateProblemIndication ();
    }
}