X-Git-Url: https://gerrit.simantics.org/r/gitweb?a=blobdiff_plain;f=bundles%2Forg.simantics.modeling.ui%2Fsrc%2Forg%2Fsimantics%2Fmodeling%2Fui%2FmodelBrowser%2Fhandlers%2FCreateIssue.java;h=76ea9607b72857f52493b8a9c1c84b5aab6fcb53;hb=e84008c029ef2336cf55ad371256c9a12a889e98;hp=6f1804121ba1eb32b6832ee6d4796bf85d26db2f;hpb=969bd23cab98a79ca9101af33334000879fb60c5;p=simantics%2Fplatform.git diff --git a/bundles/org.simantics.modeling.ui/src/org/simantics/modeling/ui/modelBrowser/handlers/CreateIssue.java b/bundles/org.simantics.modeling.ui/src/org/simantics/modeling/ui/modelBrowser/handlers/CreateIssue.java index 6f1804121..76ea9607b 100644 --- a/bundles/org.simantics.modeling.ui/src/org/simantics/modeling/ui/modelBrowser/handlers/CreateIssue.java +++ b/bundles/org.simantics.modeling.ui/src/org/simantics/modeling/ui/modelBrowser/handlers/CreateIssue.java @@ -1,63 +1,63 @@ -/******************************************************************************* - * Copyright (c) 2007, 2010 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: - * VTT Technical Research Centre of Finland - initial API and implementation - *******************************************************************************/ -package org.simantics.modeling.ui.modelBrowser.handlers; - -import java.util.Collections; - -import org.eclipse.core.commands.AbstractHandler; -import org.eclipse.core.commands.ExecutionEvent; -import org.eclipse.core.commands.ExecutionException; -import org.eclipse.jface.viewers.ISelection; -import org.eclipse.ui.handlers.HandlerUtil; -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.issues.common.IssueUtils; -import org.simantics.issues.ontology.IssueResource; -import org.simantics.modeling.ModelingResources; -import org.simantics.ui.SimanticsUI; -import org.simantics.utils.ui.AdaptionUtils; -public class CreateIssue extends AbstractHandler { - - private static Resource getResource(ISelection sel) { - Resource r = AdaptionUtils.adaptToSingle(sel, Resource.class); - return r; - } - - @Override - public Object execute(ExecutionEvent event) throws ExecutionException { - - ISelection sel = HandlerUtil.getCurrentSelection(event); - final Resource element = getResource(sel); - if (element == null) - return null; - - SimanticsUI.getSession().asyncRequest(new WriteRequest() { - @Override - public void perform(WriteGraph graph) throws DatabaseException { - - IssueResource ISSUE = IssueResource.getInstance(graph); - - Resource resource = graph.getPossibleObject(element, ModelingResources.getInstance(graph).ElementToComponent); - if(resource == null) return; - - IssueUtils.newUserIssueForModel(graph, resource, "New User Issue", ISSUE.Severity_Note, Collections.singletonList(resource)); - - } - }); - - return null; - } - -} - +/******************************************************************************* + * Copyright (c) 2007, 2010 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: + * VTT Technical Research Centre of Finland - initial API and implementation + *******************************************************************************/ +package org.simantics.modeling.ui.modelBrowser.handlers; + +import java.util.Collections; + +import org.eclipse.core.commands.AbstractHandler; +import org.eclipse.core.commands.ExecutionEvent; +import org.eclipse.core.commands.ExecutionException; +import org.eclipse.jface.viewers.ISelection; +import org.eclipse.ui.handlers.HandlerUtil; +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.issues.common.IssueUtils; +import org.simantics.issues.ontology.IssueResource; +import org.simantics.modeling.ModelingResources; +import org.simantics.ui.SimanticsUI; +import org.simantics.utils.ui.AdaptionUtils; +public class CreateIssue extends AbstractHandler { + + private static Resource getResource(ISelection sel) { + Resource r = AdaptionUtils.adaptToSingle(sel, Resource.class); + return r; + } + + @Override + public Object execute(ExecutionEvent event) throws ExecutionException { + + ISelection sel = HandlerUtil.getCurrentSelection(event); + final Resource element = getResource(sel); + if (element == null) + return null; + + SimanticsUI.getSession().asyncRequest(new WriteRequest() { + @Override + public void perform(WriteGraph graph) throws DatabaseException { + + IssueResource ISSUE = IssueResource.getInstance(graph); + + Resource resource = graph.getPossibleObject(element, ModelingResources.getInstance(graph).ElementToComponent); + if(resource == null) return; + + IssueUtils.newUserIssueForModel(graph, resource, "New User Issue", ISSUE.Severity_Note, Collections.singletonList(resource)); + + } + }); + + return null; + } + +} +