Search in sources :

Example 1 with DeleteLinkCommand

use of org.openlca.app.editors.graphical.command.DeleteLinkCommand in project olca-app by GreenDelta.

the class LinkPart method createEditPolicies.

@Override
protected void createEditPolicies() {
    installEditPolicy(EditPolicy.CONNECTION_ENDPOINTS_ROLE, new ConnectionEndpointEditPolicy());
    installEditPolicy(EditPolicy.CONNECTION_ROLE, new ConnectionEditPolicy() {

        @Override
        protected Command getDeleteCommand(GroupRequest _req) {
            return new DeleteLinkCommand(getModel());
        }
    });
}
Also used : ConnectionEndpointEditPolicy(org.eclipse.gef.editpolicies.ConnectionEndpointEditPolicy) ConnectionEditPolicy(org.eclipse.gef.editpolicies.ConnectionEditPolicy) DeleteLinkCommand(org.openlca.app.editors.graphical.command.DeleteLinkCommand) Command(org.eclipse.gef.commands.Command) GroupRequest(org.eclipse.gef.requests.GroupRequest) DeleteLinkCommand(org.openlca.app.editors.graphical.command.DeleteLinkCommand)

Example 2 with DeleteLinkCommand

use of org.openlca.app.editors.graphical.command.DeleteLinkCommand in project olca-app by GreenDelta.

the class RemoveAllConnectionsAction method run.

@Override
public void run() {
    if (processNodes.size() == 0)
        return;
    ProductSystemNode systemNode = editor.getModel();
    List<Link> links = new ArrayList<>();
    // create new link search to avoid problems with missing entries before
    // ConnectionLink.unlink is called
    List<ProcessLink> pLinks = systemNode.getProductSystem().processLinks;
    MutableProcessLinkSearchMap linkSearch = new MutableProcessLinkSearchMap(pLinks);
    for (ProcessNode processNode : processNodes) {
        List<ProcessLink> processLinks = linkSearch.getLinks(processNode.process.id);
        for (ProcessLink link : processLinks) linkSearch.remove(link);
        for (Link link : processNode.links) if (!links.contains(link))
            links.add(link);
    }
    Command command = new DeleteLinkCommand(links);
    editor.getCommandStack().execute(command);
}
Also used : ProcessLink(org.openlca.core.model.ProcessLink) Command(org.eclipse.gef.commands.Command) DeleteLinkCommand(org.openlca.app.editors.graphical.command.DeleteLinkCommand) ProductSystemNode(org.openlca.app.editors.graphical.model.ProductSystemNode) ArrayList(java.util.ArrayList) ProcessNode(org.openlca.app.editors.graphical.model.ProcessNode) MutableProcessLinkSearchMap(org.openlca.app.editors.graphical.search.MutableProcessLinkSearchMap) DeleteLinkCommand(org.openlca.app.editors.graphical.command.DeleteLinkCommand) Link(org.openlca.app.editors.graphical.model.Link) ProcessLink(org.openlca.core.model.ProcessLink)

Aggregations

Command (org.eclipse.gef.commands.Command)2 DeleteLinkCommand (org.openlca.app.editors.graphical.command.DeleteLinkCommand)2 ArrayList (java.util.ArrayList)1 ConnectionEditPolicy (org.eclipse.gef.editpolicies.ConnectionEditPolicy)1 ConnectionEndpointEditPolicy (org.eclipse.gef.editpolicies.ConnectionEndpointEditPolicy)1 GroupRequest (org.eclipse.gef.requests.GroupRequest)1 Link (org.openlca.app.editors.graphical.model.Link)1 ProcessNode (org.openlca.app.editors.graphical.model.ProcessNode)1 ProductSystemNode (org.openlca.app.editors.graphical.model.ProductSystemNode)1 MutableProcessLinkSearchMap (org.openlca.app.editors.graphical.search.MutableProcessLinkSearchMap)1 ProcessLink (org.openlca.core.model.ProcessLink)1