X-Git-Url: https://gerrit.simantics.org/r/gitweb?a=blobdiff_plain;f=bundles%2Forg.simantics.modeling.ui%2Fsrc%2Forg%2Fsimantics%2Fmodeling%2Fui%2Ftypicals%2FNewMasterTypicalDiagram.java;h=62c45447689142b71daccf3632a656d39f3ea7d4;hb=0475b9e2a9331ef8f3dcd61567e5d071ae8ef561;hp=86926145ccffed8808c715c65f69ece3e9b6edc8;hpb=8ada31c956ee02aef38627ba4deaaae3eecb623a;p=simantics%2Fplatform.git diff --git a/bundles/org.simantics.modeling.ui/src/org/simantics/modeling/ui/typicals/NewMasterTypicalDiagram.java b/bundles/org.simantics.modeling.ui/src/org/simantics/modeling/ui/typicals/NewMasterTypicalDiagram.java index 86926145c..62c454476 100644 --- a/bundles/org.simantics.modeling.ui/src/org/simantics/modeling/ui/typicals/NewMasterTypicalDiagram.java +++ b/bundles/org.simantics.modeling.ui/src/org/simantics/modeling/ui/typicals/NewMasterTypicalDiagram.java @@ -1,96 +1,96 @@ -/******************************************************************************* - * 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.typicals; - -import java.lang.reflect.InvocationTargetException; -import org.eclipse.core.runtime.IProgressMonitor; -import org.eclipse.jface.operation.IRunnableWithProgress; -import org.eclipse.swt.widgets.Shell; -import org.eclipse.ui.IWorkbenchWindow; -import org.eclipse.ui.PlatformUI; -import org.simantics.Simantics; -import org.simantics.browsing.ui.common.ErrorLogger; -import org.simantics.db.Resource; -import org.simantics.db.Session; -import org.simantics.db.exception.DatabaseException; -import org.simantics.db.layer0.adapter.ActionFactory; -import org.simantics.modeling.ModelingResources; -import org.simantics.modeling.typicals.TypicalUtil; -import org.simantics.ui.workbench.action.ChooseActionRequest; -import org.simantics.utils.ui.SWTUtils; -import org.simantics.utils.ui.workbench.WorkbenchUtils; - -/** - * Creates a new master typical diagram and its corresponding composites. - * - *

- * The created typical composite and diagram type are specified by the model - * using {@link ModelingResources#StructuralModel_HasTypicalCompositeBaseType} - * and {@link ModelingResources#StructuralModel_HasTypicalDiagramBaseType}. - * - *

- * Marks the created master composite with the model-specified master composite - * type to support searching. The master type is specified by the model using - * {@link ModelingResources#StructuralModel_HasMasterTypicalCompositeType}. - * - *

- * Clones symbol contributions from the sources specified by the model through - * {@link ModelingResources#StructuralModel_CloneTypicalDiagramSymbolContributionsFrom} - * . - * - * @author Tuukka Lehtonen - */ -public class NewMasterTypicalDiagram implements ActionFactory { - - @Override - public Runnable create(Object target_) { - final Resource target = (Resource)target_; - return new Runnable() { - @Override - public void run() { - try { - PlatformUI.getWorkbench().getProgressService().busyCursorWhile(new IRunnableWithProgress() { - @Override - public void run(IProgressMonitor monitor) throws InvocationTargetException, InterruptedException { - try { - Resource composite = TypicalUtil.newMasterTypical(target); - - // Perform default action on the newly created diagram - performDefaultAction(Simantics.getSession(), composite); - } catch (DatabaseException e) { - throw new InvocationTargetException(e); - } finally { - monitor.done(); - } - } - }); - } catch (InvocationTargetException e) { - ErrorLogger.defaultLogError(e.getCause()); - } catch (InterruptedException e) { - ErrorLogger.defaultLogError(e); - } - } - }; - }; - - private static void performDefaultAction(final Session session, final Object input) { - SWTUtils.asyncExec(PlatformUI.getWorkbench().getDisplay(), new Runnable() { - @Override - public void run() { - IWorkbenchWindow window = PlatformUI.getWorkbench().getActiveWorkbenchWindow(); - Shell shell = window != null ? window.getShell() : null; - session.asyncRequest(new ChooseActionRequest(shell, null, input, WorkbenchUtils.getCurrentPerspectiveId(), false, false, true)); - } - }); - } - -} +/******************************************************************************* + * 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.typicals; + +import java.lang.reflect.InvocationTargetException; +import org.eclipse.core.runtime.IProgressMonitor; +import org.eclipse.jface.operation.IRunnableWithProgress; +import org.eclipse.swt.widgets.Shell; +import org.eclipse.ui.IWorkbenchWindow; +import org.eclipse.ui.PlatformUI; +import org.simantics.Simantics; +import org.simantics.browsing.ui.common.ErrorLogger; +import org.simantics.db.Resource; +import org.simantics.db.Session; +import org.simantics.db.exception.DatabaseException; +import org.simantics.db.layer0.adapter.ActionFactory; +import org.simantics.modeling.ModelingResources; +import org.simantics.modeling.typicals.TypicalUtil; +import org.simantics.ui.workbench.action.ChooseActionRequest; +import org.simantics.utils.ui.SWTUtils; +import org.simantics.utils.ui.workbench.WorkbenchUtils; + +/** + * Creates a new master typical diagram and its corresponding composites. + * + *

+ * The created typical composite and diagram type are specified by the model + * using {@link ModelingResources#StructuralModel_HasTypicalCompositeBaseType} + * and {@link ModelingResources#StructuralModel_HasTypicalDiagramBaseType}. + * + *

+ * Marks the created master composite with the model-specified master composite + * type to support searching. The master type is specified by the model using + * {@link ModelingResources#StructuralModel_HasMasterTypicalCompositeType}. + * + *

+ * Clones symbol contributions from the sources specified by the model through + * {@link ModelingResources#StructuralModel_CloneTypicalDiagramSymbolContributionsFrom} + * . + * + * @author Tuukka Lehtonen + */ +public class NewMasterTypicalDiagram implements ActionFactory { + + @Override + public Runnable create(Object target_) { + final Resource target = (Resource)target_; + return new Runnable() { + @Override + public void run() { + try { + PlatformUI.getWorkbench().getProgressService().busyCursorWhile(new IRunnableWithProgress() { + @Override + public void run(IProgressMonitor monitor) throws InvocationTargetException, InterruptedException { + try { + Resource composite = TypicalUtil.newMasterTypical(target); + + // Perform default action on the newly created diagram + performDefaultAction(Simantics.getSession(), composite); + } catch (DatabaseException e) { + throw new InvocationTargetException(e); + } finally { + monitor.done(); + } + } + }); + } catch (InvocationTargetException e) { + ErrorLogger.defaultLogError(e.getCause()); + } catch (InterruptedException e) { + ErrorLogger.defaultLogError(e); + } + } + }; + }; + + private static void performDefaultAction(final Session session, final Object input) { + SWTUtils.asyncExec(PlatformUI.getWorkbench().getDisplay(), new Runnable() { + @Override + public void run() { + IWorkbenchWindow window = PlatformUI.getWorkbench().getActiveWorkbenchWindow(); + Shell shell = window != null ? window.getShell() : null; + session.asyncRequest(new ChooseActionRequest(shell, null, input, WorkbenchUtils.getCurrentPerspectiveId(), false, false, true)); + } + }); + } + +}