X-Git-Url: https://gerrit.simantics.org/r/gitweb?a=blobdiff_plain;f=bundles%2Forg.simantics.modeling.ui%2Fsrc%2Forg%2Fsimantics%2Fmodeling%2Fui%2Factions%2FNewComponentTypeAction.java;h=a07fe933a4976d3631e95b36919f6a7f432d888f;hb=HEAD;hp=a51139a49ebf6fc216ad40c3bda4d872718fbac8;hpb=969bd23cab98a79ca9101af33334000879fb60c5;p=simantics%2Fplatform.git diff --git a/bundles/org.simantics.modeling.ui/src/org/simantics/modeling/ui/actions/NewComponentTypeAction.java b/bundles/org.simantics.modeling.ui/src/org/simantics/modeling/ui/actions/NewComponentTypeAction.java index a51139a49..a07fe933a 100644 --- a/bundles/org.simantics.modeling.ui/src/org/simantics/modeling/ui/actions/NewComponentTypeAction.java +++ b/bundles/org.simantics.modeling.ui/src/org/simantics/modeling/ui/actions/NewComponentTypeAction.java @@ -1,60 +1,60 @@ -/******************************************************************************* - * Copyright (c) 2012 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.actions; - -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.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.db.layer0.adapter.ActionFactory; -import org.simantics.modeling.NewComponentType; -import org.simantics.modeling.ui.Activator; -import org.simantics.ui.SimanticsUI; - -public class NewComponentTypeAction implements ActionFactory { - - @Override - public Runnable create(Object target) { - if(!(target instanceof Resource)) - return null; - final Resource library = (Resource) target; - return new Runnable() { - @Override - public void run() { - Job job = new DatabaseJob("New User Component") { - @Override - protected IStatus run(IProgressMonitor monitor) { - try { - SimanticsUI.getSession().syncRequest(new WriteRequest() { - @Override - public void perform(WriteGraph graph) throws DatabaseException { - graph.markUndoPoint(); - NewComponentType.createComponentType(graph, library); - } - }); - return Status.OK_STATUS; - } catch (DatabaseException e) { - return new Status(IStatus.ERROR, Activator.PLUGIN_ID, "Failed to create new user component.", e); - } - } - }; - job.schedule(); - } - }; - } - -} +/******************************************************************************* + * Copyright (c) 2012 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.actions; + +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.simantics.DatabaseJob; +import org.simantics.Simantics; +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.db.layer0.adapter.ActionFactory; +import org.simantics.modeling.NewComponentType; +import org.simantics.modeling.ui.Activator; + +public class NewComponentTypeAction implements ActionFactory { + + @Override + public Runnable create(Object target) { + if(!(target instanceof Resource)) + return null; + final Resource library = (Resource) target; + return new Runnable() { + @Override + public void run() { + Job job = new DatabaseJob(Messages.NewComponentTypeAction_NewUserComponent) { + @Override + protected IStatus run(IProgressMonitor monitor) { + try { + Simantics.getSession().syncRequest(new WriteRequest() { + @Override + public void perform(WriteGraph graph) throws DatabaseException { + graph.markUndoPoint(); + NewComponentType.createComponentType(graph, library); + } + }); + return Status.OK_STATUS; + } catch (DatabaseException e) { + return new Status(IStatus.ERROR, Activator.PLUGIN_ID, Messages.NewComponentTypeAction_ActivatorFailedToCreateNewUserComponent, e); + } + } + }; + job.schedule(); + } + }; + } + +}