X-Git-Url: https://gerrit.simantics.org/r/gitweb?a=blobdiff_plain;f=bundles%2Forg.simantics.modeling.ui%2Fsrc%2Forg%2Fsimantics%2Fmodeling%2Fui%2FdiagramEditor%2Fhandlers%2FDisconnectFlagHandler.java;h=04d1bf2ba4fa3a855f6419491526204e1094167a;hb=6f11a60dee43d620d500c0cf5af34a1d91c80a8b;hp=6d90afa4552e3737611441ef9bc1e4abf38c77b8;hpb=969bd23cab98a79ca9101af33334000879fb60c5;p=simantics%2Fplatform.git diff --git a/bundles/org.simantics.modeling.ui/src/org/simantics/modeling/ui/diagramEditor/handlers/DisconnectFlagHandler.java b/bundles/org.simantics.modeling.ui/src/org/simantics/modeling/ui/diagramEditor/handlers/DisconnectFlagHandler.java index 6d90afa45..04d1bf2ba 100644 --- a/bundles/org.simantics.modeling.ui/src/org/simantics/modeling/ui/diagramEditor/handlers/DisconnectFlagHandler.java +++ b/bundles/org.simantics.modeling.ui/src/org/simantics/modeling/ui/diagramEditor/handlers/DisconnectFlagHandler.java @@ -1,69 +1,69 @@ -/******************************************************************************* - * Copyright (c) 2015 Association for Decentralized Information Management - * in Industry THTH ry. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * Semantum Oy - initial API and implementation - *******************************************************************************/ -package org.simantics.modeling.ui.diagramEditor.handlers; - -import java.util.ArrayList; -import java.util.Set; - -import org.eclipse.core.commands.AbstractHandler; -import org.eclipse.core.commands.ExecutionEvent; -import org.eclipse.core.commands.ExecutionException; -import org.eclipse.core.runtime.IProgressMonitor; -import org.eclipse.core.runtime.IStatus; -import org.eclipse.core.runtime.Status; -import org.eclipse.core.runtime.jobs.Job; -import org.eclipse.jface.viewers.ISelection; -import org.eclipse.ui.handlers.HandlerUtil; -import org.simantics.DatabaseJob; -import org.simantics.db.Resource; -import org.simantics.db.WriteGraph; -import org.simantics.db.common.request.WriteRequest; -import org.simantics.db.exception.DatabaseException; -import org.simantics.modeling.actions.DisconnectFlag; -import org.simantics.modeling.ui.Activator; -import org.simantics.ui.SimanticsUI; -import org.simantics.utils.ui.ISelectionUtils; - -/** - * @author Tuukka Lehtonen - */ -public class DisconnectFlagHandler extends AbstractHandler { - - @Override - public Object execute(ExecutionEvent event) throws ExecutionException { - ISelection sel = HandlerUtil.getCurrentSelection(event); - final Set resources = ISelectionUtils.filterSetSelection(sel, Resource.class); - if (resources.isEmpty()) - return null; - - Job job = new DatabaseJob("Disconnect Flags") { - @Override - protected IStatus run(IProgressMonitor monitor) { - try { - SimanticsUI.getSession().syncRequest(new WriteRequest() { - @Override - public void perform(WriteGraph graph) throws DatabaseException { - graph.markUndoPoint(); - DisconnectFlag.disconnectFlags(graph, new ArrayList<>(resources)); - } - }); - return Status.OK_STATUS; - } catch (DatabaseException e) { - return new Status(IStatus.ERROR, Activator.PLUGIN_ID, "Failed to disconnect flags.", e); - } - } - }; - job.schedule(); - return null; - } - -} +/******************************************************************************* + * Copyright (c) 2015 Association for Decentralized Information Management + * in Industry THTH ry. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * Semantum Oy - initial API and implementation + *******************************************************************************/ +package org.simantics.modeling.ui.diagramEditor.handlers; + +import java.util.ArrayList; +import java.util.Set; + +import org.eclipse.core.commands.AbstractHandler; +import org.eclipse.core.commands.ExecutionEvent; +import org.eclipse.core.commands.ExecutionException; +import org.eclipse.core.runtime.IProgressMonitor; +import org.eclipse.core.runtime.IStatus; +import org.eclipse.core.runtime.Status; +import org.eclipse.core.runtime.jobs.Job; +import org.eclipse.jface.viewers.ISelection; +import org.eclipse.ui.handlers.HandlerUtil; +import org.simantics.DatabaseJob; +import org.simantics.db.Resource; +import org.simantics.db.WriteGraph; +import org.simantics.db.common.request.WriteRequest; +import org.simantics.db.exception.DatabaseException; +import org.simantics.modeling.actions.DisconnectFlag; +import org.simantics.modeling.ui.Activator; +import org.simantics.ui.SimanticsUI; +import org.simantics.utils.ui.ISelectionUtils; + +/** + * @author Tuukka Lehtonen + */ +public class DisconnectFlagHandler extends AbstractHandler { + + @Override + public Object execute(ExecutionEvent event) throws ExecutionException { + ISelection sel = HandlerUtil.getCurrentSelection(event); + final Set resources = ISelectionUtils.filterSetSelection(sel, Resource.class); + if (resources.isEmpty()) + return null; + + Job job = new DatabaseJob("Disconnect Flags") { + @Override + protected IStatus run(IProgressMonitor monitor) { + try { + SimanticsUI.getSession().syncRequest(new WriteRequest() { + @Override + public void perform(WriteGraph graph) throws DatabaseException { + graph.markUndoPoint(); + DisconnectFlag.disconnectFlags(graph, new ArrayList<>(resources)); + } + }); + return Status.OK_STATUS; + } catch (DatabaseException e) { + return new Status(IStatus.ERROR, Activator.PLUGIN_ID, "Failed to disconnect flags.", e); + } + } + }; + job.schedule(); + return null; + } + +}