Return-Path: Delivered-To: apmail-commons-commits-archive@minotaur.apache.org Received: (qmail 59572 invoked from network); 9 Jun 2010 16:13:40 -0000 Received: from unknown (HELO mail.apache.org) (140.211.11.3) by 140.211.11.9 with SMTP; 9 Jun 2010 16:13:40 -0000 Received: (qmail 13316 invoked by uid 500); 9 Jun 2010 16:13:39 -0000 Delivered-To: apmail-commons-commits-archive@commons.apache.org Received: (qmail 13258 invoked by uid 500); 9 Jun 2010 16:13:39 -0000 Mailing-List: contact commits-help@commons.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@commons.apache.org Delivered-To: mailing list commits@commons.apache.org Received: (qmail 13251 invoked by uid 99); 9 Jun 2010 16:13:39 -0000 Received: from athena.apache.org (HELO athena.apache.org) (140.211.11.136) by apache.org (qpsmtpd/0.29) with ESMTP; Wed, 09 Jun 2010 16:13:39 +0000 X-ASF-Spam-Status: No, hits=-2000.0 required=10.0 tests=ALL_TRUSTED,AWL X-Spam-Check-By: apache.org Received: from [140.211.11.4] (HELO eris.apache.org) (140.211.11.4) by apache.org (qpsmtpd/0.29) with ESMTP; Wed, 09 Jun 2010 16:13:34 +0000 Received: by eris.apache.org (Postfix, from userid 65534) id 4A01E2388A32; Wed, 9 Jun 2010 16:12:49 +0000 (UTC) Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: svn commit: r953071 [1/5] - /commons/sandbox/gsoc/2010/scxml-eclipse/trunk/src/main/java/org.apache.commons.scxml.modeling.diagram/src/org/apache/commons/scxml/modeling/diagram/part/ Date: Wed, 09 Jun 2010 16:12:48 -0000 To: commits@commons.apache.org From: guixl@apache.org X-Mailer: svnmailer-1.0.8 Message-Id: <20100609161249.4A01E2388A32@eris.apache.org> Author: guixl Date: Wed Jun 9 16:12:48 2010 New Revision: 953071 URL: http://svn.apache.org/viewvc?rev=953071&view=rev Log: change data model - remove initial state in service template, only state has initial state node Added: commons/sandbox/gsoc/2010/scxml-eclipse/trunk/src/main/java/org.apache.commons.scxml.modeling.diagram/src/org/apache/commons/scxml/modeling/diagram/part/DeleteElementAction.java (with props) commons/sandbox/gsoc/2010/scxml-eclipse/trunk/src/main/java/org.apache.commons.scxml.modeling.diagram/src/org/apache/commons/scxml/modeling/diagram/part/DiagramEditorContextMenuProvider.java (with props) commons/sandbox/gsoc/2010/scxml-eclipse/trunk/src/main/java/org.apache.commons.scxml.modeling.diagram/src/org/apache/commons/scxml/modeling/diagram/part/Messages.java (with props) commons/sandbox/gsoc/2010/scxml-eclipse/trunk/src/main/java/org.apache.commons.scxml.modeling.diagram/src/org/apache/commons/scxml/modeling/diagram/part/ModelElementSelectionPage.java (with props) commons/sandbox/gsoc/2010/scxml-eclipse/trunk/src/main/java/org.apache.commons.scxml.modeling.diagram/src/org/apache/commons/scxml/modeling/diagram/part/ModelingCreationWizard.java (with props) commons/sandbox/gsoc/2010/scxml-eclipse/trunk/src/main/java/org.apache.commons.scxml.modeling.diagram/src/org/apache/commons/scxml/modeling/diagram/part/ModelingCreationWizardPage.java (with props) commons/sandbox/gsoc/2010/scxml-eclipse/trunk/src/main/java/org.apache.commons.scxml.modeling.diagram/src/org/apache/commons/scxml/modeling/diagram/part/ModelingDiagramActionBarContributor.java (with props) commons/sandbox/gsoc/2010/scxml-eclipse/trunk/src/main/java/org.apache.commons.scxml.modeling.diagram/src/org/apache/commons/scxml/modeling/diagram/part/ModelingDiagramEditor.java (with props) commons/sandbox/gsoc/2010/scxml-eclipse/trunk/src/main/java/org.apache.commons.scxml.modeling.diagram/src/org/apache/commons/scxml/modeling/diagram/part/ModelingDiagramEditorPlugin.java (with props) commons/sandbox/gsoc/2010/scxml-eclipse/trunk/src/main/java/org.apache.commons.scxml.modeling.diagram/src/org/apache/commons/scxml/modeling/diagram/part/ModelingDiagramEditorUtil.java (with props) commons/sandbox/gsoc/2010/scxml-eclipse/trunk/src/main/java/org.apache.commons.scxml.modeling.diagram/src/org/apache/commons/scxml/modeling/diagram/part/ModelingDiagramUpdateCommand.java (with props) commons/sandbox/gsoc/2010/scxml-eclipse/trunk/src/main/java/org.apache.commons.scxml.modeling.diagram/src/org/apache/commons/scxml/modeling/diagram/part/ModelingDiagramUpdater.java (with props) commons/sandbox/gsoc/2010/scxml-eclipse/trunk/src/main/java/org.apache.commons.scxml.modeling.diagram/src/org/apache/commons/scxml/modeling/diagram/part/ModelingDocumentProvider.java (with props) commons/sandbox/gsoc/2010/scxml-eclipse/trunk/src/main/java/org.apache.commons.scxml.modeling.diagram/src/org/apache/commons/scxml/modeling/diagram/part/ModelingDomainModelElementTester.java (with props) commons/sandbox/gsoc/2010/scxml-eclipse/trunk/src/main/java/org.apache.commons.scxml.modeling.diagram/src/org/apache/commons/scxml/modeling/diagram/part/ModelingInitDiagramFileAction.java (with props) commons/sandbox/gsoc/2010/scxml-eclipse/trunk/src/main/java/org.apache.commons.scxml.modeling.diagram/src/org/apache/commons/scxml/modeling/diagram/part/ModelingLinkDescriptor.java (with props) commons/sandbox/gsoc/2010/scxml-eclipse/trunk/src/main/java/org.apache.commons.scxml.modeling.diagram/src/org/apache/commons/scxml/modeling/diagram/part/ModelingLoadResourceAction.java (with props) commons/sandbox/gsoc/2010/scxml-eclipse/trunk/src/main/java/org.apache.commons.scxml.modeling.diagram/src/org/apache/commons/scxml/modeling/diagram/part/ModelingMatchingStrategy.java (with props) commons/sandbox/gsoc/2010/scxml-eclipse/trunk/src/main/java/org.apache.commons.scxml.modeling.diagram/src/org/apache/commons/scxml/modeling/diagram/part/ModelingNewDiagramFileWizard.java (with props) commons/sandbox/gsoc/2010/scxml-eclipse/trunk/src/main/java/org.apache.commons.scxml.modeling.diagram/src/org/apache/commons/scxml/modeling/diagram/part/ModelingNodeDescriptor.java (with props) commons/sandbox/gsoc/2010/scxml-eclipse/trunk/src/main/java/org.apache.commons.scxml.modeling.diagram/src/org/apache/commons/scxml/modeling/diagram/part/ModelingPaletteFactory.java (with props) commons/sandbox/gsoc/2010/scxml-eclipse/trunk/src/main/java/org.apache.commons.scxml.modeling.diagram/src/org/apache/commons/scxml/modeling/diagram/part/ModelingUriEditorInputTester.java (with props) commons/sandbox/gsoc/2010/scxml-eclipse/trunk/src/main/java/org.apache.commons.scxml.modeling.diagram/src/org/apache/commons/scxml/modeling/diagram/part/ModelingVisualIDRegistry.java (with props) Added: commons/sandbox/gsoc/2010/scxml-eclipse/trunk/src/main/java/org.apache.commons.scxml.modeling.diagram/src/org/apache/commons/scxml/modeling/diagram/part/DeleteElementAction.java URL: http://svn.apache.org/viewvc/commons/sandbox/gsoc/2010/scxml-eclipse/trunk/src/main/java/org.apache.commons.scxml.modeling.diagram/src/org/apache/commons/scxml/modeling/diagram/part/DeleteElementAction.java?rev=953071&view=auto ============================================================================== --- commons/sandbox/gsoc/2010/scxml-eclipse/trunk/src/main/java/org.apache.commons.scxml.modeling.diagram/src/org/apache/commons/scxml/modeling/diagram/part/DeleteElementAction.java (added) +++ commons/sandbox/gsoc/2010/scxml-eclipse/trunk/src/main/java/org.apache.commons.scxml.modeling.diagram/src/org/apache/commons/scxml/modeling/diagram/part/DeleteElementAction.java Wed Jun 9 16:12:48 2010 @@ -0,0 +1,104 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.apache.commons.scxml.modeling.diagram.part; + +import java.util.Iterator; +import java.util.List; + +import org.eclipse.gef.EditPart; +import org.eclipse.gef.Request; +import org.eclipse.gef.commands.Command; +import org.eclipse.gef.commands.UnexecutableCommand; +import org.eclipse.gmf.runtime.diagram.ui.actions.AbstractDeleteFromAction; +import org.eclipse.gmf.runtime.diagram.ui.actions.ActionIds; +import org.eclipse.gmf.runtime.diagram.ui.commands.CommandProxy; +import org.eclipse.gmf.runtime.diagram.ui.commands.ICommandProxy; +import org.eclipse.gmf.runtime.diagram.ui.l10n.DiagramUIMessages; +import org.eclipse.gmf.runtime.emf.commands.core.command.CompositeTransactionalCommand; +import org.eclipse.ui.ISharedImages; +import org.eclipse.ui.IWorkbenchPage; +import org.eclipse.ui.IWorkbenchPart; +import org.eclipse.ui.PlatformUI; + +/** + * @generated + */ +public class DeleteElementAction extends AbstractDeleteFromAction { + + /** + * @generated + */ + public DeleteElementAction(IWorkbenchPart part) { + super(part); + } + + /** + * @generated + */ + public DeleteElementAction(IWorkbenchPage workbenchPage) { + super(workbenchPage); + } + + /** + * @generated + */ + public void init() { + super.init(); + setId(ActionIds.ACTION_DELETE_FROM_MODEL); + setText(DiagramUIMessages.DiagramEditor_Delete_from_Model); + setToolTipText(DiagramUIMessages.DiagramEditor_Delete_from_ModelToolTip); + ISharedImages workbenchImages = PlatformUI.getWorkbench() + .getSharedImages(); + setHoverImageDescriptor(workbenchImages + .getImageDescriptor(ISharedImages.IMG_TOOL_DELETE)); + setImageDescriptor(workbenchImages + .getImageDescriptor(ISharedImages.IMG_TOOL_DELETE)); + setDisabledImageDescriptor(workbenchImages + .getImageDescriptor(ISharedImages.IMG_TOOL_DELETE_DISABLED)); + } + + /** + * @generated + */ + protected String getCommandLabel() { + return DiagramUIMessages.DiagramEditor_Delete_from_Model; + } + + /** + * @generated + */ + protected Command getCommand(Request request) { + List operationSet = getOperationSet(); + if (operationSet.isEmpty()) { + return UnexecutableCommand.INSTANCE; + } + Iterator editParts = operationSet.iterator(); + CompositeTransactionalCommand command = new CompositeTransactionalCommand( + getEditingDomain(), getCommandLabel()); + while (editParts.hasNext()) { + EditPart editPart = (EditPart) editParts.next(); + Command curCommand = editPart.getCommand(request); + if (curCommand != null) { + command.compose(new CommandProxy(curCommand)); + } + } + if (command.isEmpty() || command.size() != operationSet.size()) { + return UnexecutableCommand.INSTANCE; + } + return new ICommandProxy(command); + } +} Propchange: commons/sandbox/gsoc/2010/scxml-eclipse/trunk/src/main/java/org.apache.commons.scxml.modeling.diagram/src/org/apache/commons/scxml/modeling/diagram/part/DeleteElementAction.java ------------------------------------------------------------------------------ svn:eol-style = native Added: commons/sandbox/gsoc/2010/scxml-eclipse/trunk/src/main/java/org.apache.commons.scxml.modeling.diagram/src/org/apache/commons/scxml/modeling/diagram/part/DiagramEditorContextMenuProvider.java URL: http://svn.apache.org/viewvc/commons/sandbox/gsoc/2010/scxml-eclipse/trunk/src/main/java/org.apache.commons.scxml.modeling.diagram/src/org/apache/commons/scxml/modeling/diagram/part/DiagramEditorContextMenuProvider.java?rev=953071&view=auto ============================================================================== --- commons/sandbox/gsoc/2010/scxml-eclipse/trunk/src/main/java/org.apache.commons.scxml.modeling.diagram/src/org/apache/commons/scxml/modeling/diagram/part/DiagramEditorContextMenuProvider.java (added) +++ commons/sandbox/gsoc/2010/scxml-eclipse/trunk/src/main/java/org.apache.commons.scxml.modeling.diagram/src/org/apache/commons/scxml/modeling/diagram/part/DiagramEditorContextMenuProvider.java Wed Jun 9 16:12:48 2010 @@ -0,0 +1,91 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.apache.commons.scxml.modeling.diagram.part; + +import org.eclipse.emf.ecore.EObject; +import org.eclipse.emf.transaction.util.TransactionUtil; +import org.eclipse.gef.EditPartViewer; +import org.eclipse.gmf.runtime.common.ui.services.action.contributionitem.ContributionItemService; +import org.eclipse.gmf.runtime.diagram.ui.actions.ActionIds; +import org.eclipse.gmf.runtime.diagram.ui.providers.DiagramContextMenuProvider; +import org.eclipse.jface.action.IMenuManager; +import org.eclipse.ui.IWorkbenchPart; + +/** + * @generated + */ +public class DiagramEditorContextMenuProvider extends + DiagramContextMenuProvider { + + /** + * @generated + */ + private IWorkbenchPart part; + + /** + * @generated + */ + private DeleteElementAction deleteAction; + + /** + * @generated + */ + public DiagramEditorContextMenuProvider(IWorkbenchPart part, + EditPartViewer viewer) { + super(part, viewer); + this.part = part; + deleteAction = new DeleteElementAction(part); + deleteAction.init(); + } + + /** + * @generated + */ + public void dispose() { + if (deleteAction != null) { + deleteAction.dispose(); + deleteAction = null; + } + super.dispose(); + } + + /** + * @generated + */ + public void buildContextMenu(final IMenuManager menu) { + getViewer().flush(); + try { + TransactionUtil.getEditingDomain( + (EObject) getViewer().getContents().getModel()) + .runExclusive(new Runnable() { + + public void run() { + ContributionItemService + .getInstance() + .contributeToPopupMenu( + DiagramEditorContextMenuProvider.this, + part); + menu.remove(ActionIds.ACTION_DELETE_FROM_MODEL); + menu.appendToGroup("editGroup", deleteAction); + } + }); + } catch (Exception e) { + ModelingDiagramEditorPlugin.getInstance().logError( + "Error building context menu", e); + } + } +} Propchange: commons/sandbox/gsoc/2010/scxml-eclipse/trunk/src/main/java/org.apache.commons.scxml.modeling.diagram/src/org/apache/commons/scxml/modeling/diagram/part/DiagramEditorContextMenuProvider.java ------------------------------------------------------------------------------ svn:eol-style = native Added: commons/sandbox/gsoc/2010/scxml-eclipse/trunk/src/main/java/org.apache.commons.scxml.modeling.diagram/src/org/apache/commons/scxml/modeling/diagram/part/Messages.java URL: http://svn.apache.org/viewvc/commons/sandbox/gsoc/2010/scxml-eclipse/trunk/src/main/java/org.apache.commons.scxml.modeling.diagram/src/org/apache/commons/scxml/modeling/diagram/part/Messages.java?rev=953071&view=auto ============================================================================== --- commons/sandbox/gsoc/2010/scxml-eclipse/trunk/src/main/java/org.apache.commons.scxml.modeling.diagram/src/org/apache/commons/scxml/modeling/diagram/part/Messages.java (added) +++ commons/sandbox/gsoc/2010/scxml-eclipse/trunk/src/main/java/org.apache.commons.scxml.modeling.diagram/src/org/apache/commons/scxml/modeling/diagram/part/Messages.java Wed Jun 9 16:12:48 2010 @@ -0,0 +1,870 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.apache.commons.scxml.modeling.diagram.part; + +import org.eclipse.osgi.util.NLS; + +/** + * @generated + */ +public class Messages extends NLS { + + /** + * @generated + */ + static { + NLS.initializeMessages("messages", Messages.class); //$NON-NLS-1$ + } + + /** + * @generated + */ + private Messages() { + } + + /** + * @generated + */ + public static String ModelingCreationWizardTitle; + + /** + * @generated + */ + public static String ModelingCreationWizard_DiagramModelFilePageTitle; + + /** + * @generated + */ + public static String ModelingCreationWizard_DiagramModelFilePageDescription; + + /** + * @generated + */ + public static String ModelingCreationWizard_DomainModelFilePageTitle; + + /** + * @generated + */ + public static String ModelingCreationWizard_DomainModelFilePageDescription; + + /** + * @generated + */ + public static String ModelingCreationWizardOpenEditorError; + + /** + * @generated + */ + public static String ModelingCreationWizardCreationError; + + /** + * @generated + */ + public static String ModelingCreationWizardPageExtensionError; + + /** + * @generated + */ + public static String ModelingDiagramEditorUtil_OpenModelResourceErrorDialogTitle; + + /** + * @generated + */ + public static String ModelingDiagramEditorUtil_OpenModelResourceErrorDialogMessage; + + /** + * @generated + */ + public static String ModelingDiagramEditorUtil_CreateDiagramProgressTask; + + /** + * @generated + */ + public static String ModelingDiagramEditorUtil_CreateDiagramCommandLabel; + + /** + * @generated + */ + public static String ModelingDocumentProvider_isModifiable; + + /** + * @generated + */ + public static String ModelingDocumentProvider_handleElementContentChanged; + + /** + * @generated + */ + public static String ModelingDocumentProvider_IncorrectInputError; + + /** + * @generated + */ + public static String ModelingDocumentProvider_NoDiagramInResourceError; + + /** + * @generated + */ + public static String ModelingDocumentProvider_DiagramLoadingError; + + /** + * @generated + */ + public static String ModelingDocumentProvider_UnsynchronizedFileSaveError; + + /** + * @generated + */ + public static String ModelingDocumentProvider_SaveDiagramTask; + + /** + * @generated + */ + public static String ModelingDocumentProvider_SaveNextResourceTask; + + /** + * @generated + */ + public static String ModelingDocumentProvider_SaveAsOperation; + + /** + * @generated + */ + public static String ModelingInitDiagramFileAction_InitDiagramFileResourceErrorDialogTitle; + + /** + * @generated + */ + public static String ModelingInitDiagramFileAction_InitDiagramFileResourceErrorDialogMessage; + + /** + * @generated + */ + public static String ModelingInitDiagramFileAction_InitDiagramFileWizardTitle; + + /** + * @generated + */ + public static String ModelingInitDiagramFileAction_OpenModelFileDialogTitle; + + /** + * @generated + */ + public static String ModelingNewDiagramFileWizard_CreationPageName; + + /** + * @generated + */ + public static String ModelingNewDiagramFileWizard_CreationPageTitle; + + /** + * @generated + */ + public static String ModelingNewDiagramFileWizard_CreationPageDescription; + + /** + * @generated + */ + public static String ModelingNewDiagramFileWizard_RootSelectionPageName; + + /** + * @generated + */ + public static String ModelingNewDiagramFileWizard_RootSelectionPageTitle; + + /** + * @generated + */ + public static String ModelingNewDiagramFileWizard_RootSelectionPageDescription; + + /** + * @generated + */ + public static String ModelingNewDiagramFileWizard_RootSelectionPageSelectionTitle; + + /** + * @generated + */ + public static String ModelingNewDiagramFileWizard_RootSelectionPageNoSelectionMessage; + + /** + * @generated + */ + public static String ModelingNewDiagramFileWizard_RootSelectionPageInvalidSelectionMessage; + + /** + * @generated + */ + public static String ModelingNewDiagramFileWizard_InitDiagramCommand; + + /** + * @generated + */ + public static String ModelingNewDiagramFileWizard_IncorrectRootError; + + /** + * @generated + */ + public static String ModelingDiagramEditor_SavingDeletedFile; + + /** + * @generated + */ + public static String ModelingDiagramEditor_SaveAsErrorTitle; + + /** + * @generated + */ + public static String ModelingDiagramEditor_SaveAsErrorMessage; + + /** + * @generated + */ + public static String ModelingDiagramEditor_SaveErrorTitle; + + /** + * @generated + */ + public static String ModelingDiagramEditor_SaveErrorMessage; + + /** + * @generated + */ + public static String ModelingElementChooserDialog_SelectModelElementTitle; + + /** + * @generated + */ + public static String ModelElementSelectionPageMessage; + + /** + * @generated + */ + public static String ValidateActionMessage; + + /** + * @generated + */ + public static String ScxmlStateElement1Group_title; + + /** + * @generated + */ + public static String ExecuteContent2Group_title; + + /** + * @generated + */ + public static String DataModelElement3Group_title; + + /** + * @generated + */ + public static String State1CreationTool_title; + + /** + * @generated + */ + public static String State1CreationTool_desc; + + /** + * @generated + */ + public static String Transition2CreationTool_title; + + /** + * @generated + */ + public static String Transition2CreationTool_desc; + + /** + * @generated + */ + public static String OnEntry3CreationTool_title; + + /** + * @generated + */ + public static String OnEntry3CreationTool_desc; + + /** + * @generated + */ + public static String OnExit4CreationTool_title; + + /** + * @generated + */ + public static String OnExit4CreationTool_desc; + + /** + * @generated + */ + public static String InitialState5CreationTool_title; + + /** + * @generated + */ + public static String InitialState5CreationTool_desc; + + /** + * @generated + */ + public static String FinalState6CreationTool_title; + + /** + * @generated + */ + public static String FinalState6CreationTool_desc; + + /** + * @generated + */ + public static String Parallel7CreationTool_title; + + /** + * @generated + */ + public static String Parallel7CreationTool_desc; + + /** + * @generated + */ + public static String HistoryState8CreationTool_title; + + /** + * @generated + */ + public static String HistoryState8CreationTool_desc; + + /** + * @generated + */ + public static String ExtenExecContent9CreationTool_title; + + /** + * @generated + */ + public static String ExtenExecContent9CreationTool_desc; + + /** + * @generated + */ + public static String Anchor10CreationTool_title; + + /** + * @generated + */ + public static String Anchor10CreationTool_desc; + + /** + * @generated + */ + public static String Donedata11CreationTool_title; + + /** + * @generated + */ + public static String Donedata11CreationTool_desc; + + /** + * @generated + */ + public static String Invoke12CreationTool_title; + + /** + * @generated + */ + public static String Invoke12CreationTool_desc; + + /** + * @generated + */ + public static String Finalize13CreationTool_title; + + /** + * @generated + */ + public static String Finalize13CreationTool_desc; + + /** + * @generated + */ + public static String Assign1CreationTool_title; + + /** + * @generated + */ + public static String Assign1CreationTool_desc; + + /** + * @generated + */ + public static String Raise2CreationTool_title; + + /** + * @generated + */ + public static String Raise2CreationTool_desc; + + /** + * @generated + */ + public static String If3CreationTool_title; + + /** + * @generated + */ + public static String If3CreationTool_desc; + + /** + * @generated + */ + public static String ElseIf4CreationTool_title; + + /** + * @generated + */ + public static String ElseIf4CreationTool_desc; + + /** + * @generated + */ + public static String Else5CreationTool_title; + + /** + * @generated + */ + public static String Else5CreationTool_desc; + + /** + * @generated + */ + public static String Log6CreationTool_title; + + /** + * @generated + */ + public static String Log6CreationTool_desc; + + /** + * @generated + */ + public static String Validate7CreationTool_title; + + /** + * @generated + */ + public static String Validate7CreationTool_desc; + + /** + * @generated + */ + public static String Param8CreationTool_title; + + /** + * @generated + */ + public static String Param8CreationTool_desc; + + /** + * @generated + */ + public static String Send9CreationTool_title; + + /** + * @generated + */ + public static String Send9CreationTool_desc; + + /** + * @generated + */ + public static String Cancel10CreationTool_title; + + /** + * @generated + */ + public static String Cancel10CreationTool_desc; + + /** + * @generated + */ + public static String DataModel1CreationTool_title; + + /** + * @generated + */ + public static String DataModel1CreationTool_desc; + + /** + * @generated + */ + public static String Data2CreationTool_title; + + /** + * @generated + */ + public static String Data2CreationTool_desc; + + /** + * @generated + */ + public static String Script3CreationTool_title; + + /** + * @generated + */ + public static String Script3CreationTool_desc; + + /** + * @generated + */ + public static String Content4CreationTool_title; + + /** + * @generated + */ + public static String Content4CreationTool_desc; + + /** + * @generated + */ + public static String StateStateCompartmentEditPart_title; + + /** + * @generated + */ + public static String OnEntryOnEntryCompartmentEditPart_title; + + /** + * @generated + */ + public static String IfIfCompartmentEditPart_title; + + /** + * @generated + */ + public static String SendSendCompartmentEditPart_title; + + /** + * @generated + */ + public static String ContentContentCompartmentEditPart_title; + + /** + * @generated + */ + public static String ContentContentCompartment2EditPart_title; + + /** + * @generated + */ + public static String OnExitOnExitCompartmentEditPart_title; + + /** + * @generated + */ + public static String IfIfCompartment2EditPart_title; + + /** + * @generated + */ + public static String SendSendCompartment2EditPart_title; + + /** + * @generated + */ + public static String InvokeInvokeCompartmentEditPart_title; + + /** + * @generated + */ + public static String ContentContentCompartment3EditPart_title; + + /** + * @generated + */ + public static String ParallelParallelCompartmentEditPart_title; + + /** + * @generated + */ + public static String ParallelParallelCompartment2EditPart_title; + + /** + * @generated + */ + public static String OnEntryOnEntryCompartment2EditPart_title; + + /** + * @generated + */ + public static String OnExitOnExitCompartment2EditPart_title; + + /** + * @generated + */ + public static String StateStateCompartment2EditPart_title; + + /** + * @generated + */ + public static String FinalStateFinalStateCompartmentEditPart_title; + + /** + * @generated + */ + public static String DonedataDonedataCompartmentEditPart_title; + + /** + * @generated + */ + public static String ContentContentCompartment4EditPart_title; + + /** + * @generated + */ + public static String OnEntryOnEntryCompartment3EditPart_title; + + /** + * @generated + */ + public static String OnExitOnExitCompartment3EditPart_title; + + /** + * @generated + */ + public static String StateStateCompartment3EditPart_title; + + /** + * @generated + */ + public static String ParallelParallelCompartment3EditPart_title; + + /** + * @generated + */ + public static String DataModelDataModelCompartmentEditPart_title; + + /** + * @generated + */ + public static String DataDataCompartmentEditPart_title; + + /** + * @generated + */ + public static String ContentContentCompartment5EditPart_title; + + /** + * @generated + */ + public static String FinalStateFinalStateCompartment2EditPart_title; + + /** + * @generated + */ + public static String CommandName_OpenDiagram; + + /** + * @generated + */ + public static String NavigatorGroupName_ServiceTemplate_1000_links; + + /** + * @generated + */ + public static String NavigatorGroupName_State_2001_incominglinks; + + /** + * @generated + */ + public static String NavigatorGroupName_State_2001_outgoinglinks; + + /** + * @generated + */ + public static String NavigatorGroupName_InitialState_2002_incominglinks; + + /** + * @generated + */ + public static String NavigatorGroupName_InitialState_2002_outgoinglinks; + + /** + * @generated + */ + public static String NavigatorGroupName_Parallel_2004_incominglinks; + + /** + * @generated + */ + public static String NavigatorGroupName_Parallel_2004_outgoinglinks; + + /** + * @generated + */ + public static String NavigatorGroupName_FinalState_2006_incominglinks; + + /** + * @generated + */ + public static String NavigatorGroupName_FinalState_2006_outgoinglinks; + + /** + * @generated + */ + public static String NavigatorGroupName_InitialState_3030_incominglinks; + + /** + * @generated + */ + public static String NavigatorGroupName_InitialState_3030_outgoinglinks; + + /** + * @generated + */ + public static String NavigatorGroupName_HistoryState_3031_incominglinks; + + /** + * @generated + */ + public static String NavigatorGroupName_HistoryState_3031_outgoinglinks; + + /** + * @generated + */ + public static String NavigatorGroupName_Parallel_3032_incominglinks; + + /** + * @generated + */ + public static String NavigatorGroupName_Parallel_3032_outgoinglinks; + + /** + * @generated + */ + public static String NavigatorGroupName_HistoryState_3033_incominglinks; + + /** + * @generated + */ + public static String NavigatorGroupName_HistoryState_3033_outgoinglinks; + + /** + * @generated + */ + public static String NavigatorGroupName_Parallel_3035_incominglinks; + + /** + * @generated + */ + public static String NavigatorGroupName_Parallel_3035_outgoinglinks; + + /** + * @generated + */ + public static String NavigatorGroupName_State_3038_incominglinks; + + /** + * @generated + */ + public static String NavigatorGroupName_State_3038_outgoinglinks; + + /** + * @generated + */ + public static String NavigatorGroupName_FinalState_3040_incominglinks; + + /** + * @generated + */ + public static String NavigatorGroupName_FinalState_3040_outgoinglinks; + + /** + * @generated + */ + public static String NavigatorGroupName_State_3046_incominglinks; + + /** + * @generated + */ + public static String NavigatorGroupName_State_3046_outgoinglinks; + + /** + * @generated + */ + public static String NavigatorGroupName_Transition_4001_target; + + /** + * @generated + */ + public static String NavigatorGroupName_Transition_4001_source; + + /** + * @generated + */ + public static String NavigatorActionProvider_OpenDiagramActionName; + + /** + * @generated + */ + public static String AbstractParser_UnexpectedValueTypeMessage; + + /** + * @generated + */ + public static String AbstractParser_WrongStringConversionMessage; + + /** + * @generated + */ + public static String AbstractParser_UnknownLiteralMessage; + + /** + * @generated + */ + public static String MessageFormatParser_InvalidInputError; + + /** + * @generated + */ + public static String ModelingModelingAssistantProviderTitle; + + /** + * @generated + */ + public static String ModelingModelingAssistantProviderMessage; + + public static String ModelingInitDiagramFileAction_ExportScxmlDocumentWizardTitle; + + public static String ModelingNewScxmlFileWizard_CreationPageName; + + public static String ModelingNewScxmlFileWizard_CreationPageTitle; + public static String ModelingNewScxmlFileWizard_CreationPageDescription; + public static String ModelingNewScxmlFileWizard_RootSelectionPageName; + public static String ModelingNewScxmlFileWizard_RootSelectionPageTitle; + public static String ModelingNewScxmlFileWizard_RootSelectionPageDescription; + public static String ModelingNewScxmlFileWizard_RootSelectionPageSelectionTitle; + public static String ModelingNewScxmlFileWizard_RootSelectionPageNoSelectionMessage; + public static String ModelingNewScxmlFileWizard_RootSelectionPageInvalidSelectionMessage; + public static String ModelingNewScxmlFileWizard_InitDiagramCommand; + public static String ModelingNewScxmlFileWizard_IncorrectRootError; + + //TODO: put accessor fields manually +} Propchange: commons/sandbox/gsoc/2010/scxml-eclipse/trunk/src/main/java/org.apache.commons.scxml.modeling.diagram/src/org/apache/commons/scxml/modeling/diagram/part/Messages.java ------------------------------------------------------------------------------ svn:eol-style = native Added: commons/sandbox/gsoc/2010/scxml-eclipse/trunk/src/main/java/org.apache.commons.scxml.modeling.diagram/src/org/apache/commons/scxml/modeling/diagram/part/ModelElementSelectionPage.java URL: http://svn.apache.org/viewvc/commons/sandbox/gsoc/2010/scxml-eclipse/trunk/src/main/java/org.apache.commons.scxml.modeling.diagram/src/org/apache/commons/scxml/modeling/diagram/part/ModelElementSelectionPage.java?rev=953071&view=auto ============================================================================== --- commons/sandbox/gsoc/2010/scxml-eclipse/trunk/src/main/java/org.apache.commons.scxml.modeling.diagram/src/org/apache/commons/scxml/modeling/diagram/part/ModelElementSelectionPage.java (added) +++ commons/sandbox/gsoc/2010/scxml-eclipse/trunk/src/main/java/org.apache.commons.scxml.modeling.diagram/src/org/apache/commons/scxml/modeling/diagram/part/ModelElementSelectionPage.java Wed Jun 9 16:12:48 2010 @@ -0,0 +1,166 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.apache.commons.scxml.modeling.diagram.part; + +import org.eclipse.emf.ecore.EObject; +import org.eclipse.emf.ecore.util.FeatureMap; +import org.eclipse.emf.edit.provider.IWrapperItemProvider; +import org.eclipse.emf.edit.ui.provider.AdapterFactoryContentProvider; +import org.eclipse.emf.edit.ui.provider.AdapterFactoryLabelProvider; +import org.eclipse.jface.viewers.ISelectionChangedListener; +import org.eclipse.jface.viewers.IStructuredSelection; +import org.eclipse.jface.viewers.SelectionChangedEvent; +import org.eclipse.jface.viewers.StructuredSelection; +import org.eclipse.jface.viewers.TreeViewer; +import org.eclipse.jface.wizard.WizardPage; +import org.eclipse.swt.SWT; +import org.eclipse.swt.layout.GridData; +import org.eclipse.swt.layout.GridLayout; +import org.eclipse.swt.widgets.Composite; +import org.eclipse.swt.widgets.Label; + +/** + * Wizard page that allows to select element from model. + * @generated + */ +public class ModelElementSelectionPage extends WizardPage { + /** + * @generated + */ + protected EObject selectedModelElement; + + /** + * @generated + */ + private TreeViewer modelViewer; + + /** + * @generated + */ + public ModelElementSelectionPage(String pageName) { + super(pageName); + } + + /** + * @generated + */ + public EObject getModelElement() { + return selectedModelElement; + } + + /** + * @generated + */ + public void setModelElement(EObject modelElement) { + selectedModelElement = modelElement; + if (modelViewer != null) { + if (selectedModelElement != null) { + modelViewer.setInput(selectedModelElement.eResource()); + modelViewer.setSelection(new StructuredSelection( + selectedModelElement)); + } else { + modelViewer.setInput(null); + } + setPageComplete(validatePage()); + } + } + + /** + * @generated + */ + public void createControl(Composite parent) { + initializeDialogUnits(parent); + + Composite plate = new Composite(parent, SWT.NONE); + plate.setLayoutData(new GridData(GridData.FILL_BOTH)); + GridLayout layout = new GridLayout(); + layout.marginWidth = 0; + plate.setLayout(layout); + setControl(plate); + + Label label = new Label(plate, SWT.NONE); + label.setText(getSelectionTitle()); + label.setLayoutData(new GridData(GridData.HORIZONTAL_ALIGN_BEGINNING)); + + modelViewer = new TreeViewer(plate, SWT.SINGLE | SWT.H_SCROLL + | SWT.V_SCROLL | SWT.BORDER); + GridData layoutData = new GridData(GridData.FILL_BOTH); + layoutData.heightHint = 300; + layoutData.widthHint = 300; + modelViewer.getTree().setLayoutData(layoutData); + modelViewer.setContentProvider(new AdapterFactoryContentProvider( + ModelingDiagramEditorPlugin.getInstance() + .getItemProvidersAdapterFactory())); + modelViewer.setLabelProvider(new AdapterFactoryLabelProvider( + ModelingDiagramEditorPlugin.getInstance() + .getItemProvidersAdapterFactory())); + if (selectedModelElement != null) { + modelViewer.setInput(selectedModelElement.eResource()); + modelViewer.setSelection(new StructuredSelection( + selectedModelElement)); + } + modelViewer + .addSelectionChangedListener(new ISelectionChangedListener() { + public void selectionChanged(SelectionChangedEvent event) { + ModelElementSelectionPage.this + .updateSelection((IStructuredSelection) event + .getSelection()); + } + }); + + setPageComplete(validatePage()); + } + + /** + * Override to provide custom model element description. + * @generated + */ + protected String getSelectionTitle() { + return Messages.ModelElementSelectionPageMessage; + } + + /** + * @generated + */ + protected void updateSelection(IStructuredSelection selection) { + selectedModelElement = null; + if (selection.size() == 1) { + Object selectedElement = selection.getFirstElement(); + if (selectedElement instanceof IWrapperItemProvider) { + selectedElement = ((IWrapperItemProvider) selectedElement) + .getValue(); + } + if (selectedElement instanceof FeatureMap.Entry) { + selectedElement = ((FeatureMap.Entry) selectedElement) + .getValue(); + } + if (selectedElement instanceof EObject) { + selectedModelElement = (EObject) selectedElement; + } + } + setPageComplete(validatePage()); + } + + /** + * Override to provide specific validation of the selected model element. + * @generated + */ + protected boolean validatePage() { + return true; + } + +} Propchange: commons/sandbox/gsoc/2010/scxml-eclipse/trunk/src/main/java/org.apache.commons.scxml.modeling.diagram/src/org/apache/commons/scxml/modeling/diagram/part/ModelElementSelectionPage.java ------------------------------------------------------------------------------ svn:eol-style = native Added: commons/sandbox/gsoc/2010/scxml-eclipse/trunk/src/main/java/org.apache.commons.scxml.modeling.diagram/src/org/apache/commons/scxml/modeling/diagram/part/ModelingCreationWizard.java URL: http://svn.apache.org/viewvc/commons/sandbox/gsoc/2010/scxml-eclipse/trunk/src/main/java/org.apache.commons.scxml.modeling.diagram/src/org/apache/commons/scxml/modeling/diagram/part/ModelingCreationWizard.java?rev=953071&view=auto ============================================================================== --- commons/sandbox/gsoc/2010/scxml-eclipse/trunk/src/main/java/org.apache.commons.scxml.modeling.diagram/src/org/apache/commons/scxml/modeling/diagram/part/ModelingCreationWizard.java (added) +++ commons/sandbox/gsoc/2010/scxml-eclipse/trunk/src/main/java/org.apache.commons.scxml.modeling.diagram/src/org/apache/commons/scxml/modeling/diagram/part/ModelingCreationWizard.java Wed Jun 9 16:12:48 2010 @@ -0,0 +1,188 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.apache.commons.scxml.modeling.diagram.part; + +import java.lang.reflect.InvocationTargetException; + +import org.eclipse.core.runtime.CoreException; +import org.eclipse.core.runtime.IProgressMonitor; +import org.eclipse.emf.ecore.resource.Resource; +import org.eclipse.jface.dialogs.ErrorDialog; +import org.eclipse.jface.operation.IRunnableWithProgress; +import org.eclipse.jface.viewers.IStructuredSelection; +import org.eclipse.jface.wizard.Wizard; +import org.eclipse.ui.INewWizard; +import org.eclipse.ui.IWorkbench; +import org.eclipse.ui.PartInitException; +import org.eclipse.ui.actions.WorkspaceModifyOperation; + +/** + * @generated + */ +public class ModelingCreationWizard extends Wizard implements INewWizard { + + /** + * @generated + */ + private IWorkbench workbench; + + /** + * @generated + */ + protected IStructuredSelection selection; + + /** + * @generated + */ + protected ModelingCreationWizardPage diagramModelFilePage; + + /** + * @generated + */ + protected ModelingCreationWizardPage domainModelFilePage; + + /** + * @generated + */ + protected Resource diagram; + + /** + * @generated + */ + private boolean openNewlyCreatedDiagramEditor = true; + + /** + * @generated + */ + public IWorkbench getWorkbench() { + return workbench; + } + + /** + * @generated + */ + public IStructuredSelection getSelection() { + return selection; + } + + /** + * @generated + */ + public final Resource getDiagram() { + return diagram; + } + + /** + * @generated + */ + public final boolean isOpenNewlyCreatedDiagramEditor() { + return openNewlyCreatedDiagramEditor; + } + + /** + * @generated + */ + public void setOpenNewlyCreatedDiagramEditor( + boolean openNewlyCreatedDiagramEditor) { + this.openNewlyCreatedDiagramEditor = openNewlyCreatedDiagramEditor; + } + + /** + * @generated + */ + public void init(IWorkbench workbench, IStructuredSelection selection) { + this.workbench = workbench; + this.selection = selection; + setWindowTitle(Messages.ModelingCreationWizardTitle); + setDefaultPageImageDescriptor(ModelingDiagramEditorPlugin + .getBundledImageDescriptor("icons/wizban/NewModelingWizard.gif")); //$NON-NLS-1$ + setNeedsProgressMonitor(true); + } + + /** + * @generated + */ + public void addPages() { + diagramModelFilePage = new ModelingCreationWizardPage( + "DiagramModelFile", getSelection(), "modeling_diagram"); //$NON-NLS-1$ //$NON-NLS-2$ + diagramModelFilePage + .setTitle(Messages.ModelingCreationWizard_DiagramModelFilePageTitle); + diagramModelFilePage + .setDescription(Messages.ModelingCreationWizard_DiagramModelFilePageDescription); + addPage(diagramModelFilePage); + + domainModelFilePage = new ModelingCreationWizardPage( + "DomainModelFile", getSelection(), "modeling") { //$NON-NLS-1$ //$NON-NLS-2$ + + public void setVisible(boolean visible) { + if (visible) { + String fileName = diagramModelFilePage.getFileName(); + fileName = fileName.substring(0, fileName.length() + - ".modeling_diagram".length()); //$NON-NLS-1$ + setFileName(ModelingDiagramEditorUtil.getUniqueFileName( + getContainerFullPath(), fileName, "modeling")); //$NON-NLS-1$ + } + super.setVisible(visible); + } + }; + domainModelFilePage + .setTitle(Messages.ModelingCreationWizard_DomainModelFilePageTitle); + domainModelFilePage + .setDescription(Messages.ModelingCreationWizard_DomainModelFilePageDescription); + addPage(domainModelFilePage); + } + + /** + * @generated + */ + public boolean performFinish() { + IRunnableWithProgress op = new WorkspaceModifyOperation(null) { + + protected void execute(IProgressMonitor monitor) + throws CoreException, InterruptedException { + diagram = ModelingDiagramEditorUtil.createDiagram( + diagramModelFilePage.getURI(), domainModelFilePage + .getURI(), monitor); + if (isOpenNewlyCreatedDiagramEditor() && diagram != null) { + try { + ModelingDiagramEditorUtil.openDiagram(diagram); + } catch (PartInitException e) { + ErrorDialog.openError(getContainer().getShell(), + Messages.ModelingCreationWizardOpenEditorError, + null, e.getStatus()); + } + } + } + }; + try { + getContainer().run(false, true, op); + } catch (InterruptedException e) { + return false; + } catch (InvocationTargetException e) { + if (e.getTargetException() instanceof CoreException) { + ErrorDialog.openError(getContainer().getShell(), + Messages.ModelingCreationWizardCreationError, null, + ((CoreException) e.getTargetException()).getStatus()); + } else { + ModelingDiagramEditorPlugin.getInstance().logError( + "Error creating diagram", e.getTargetException()); //$NON-NLS-1$ + } + return false; + } + return diagram != null; + } +} Propchange: commons/sandbox/gsoc/2010/scxml-eclipse/trunk/src/main/java/org.apache.commons.scxml.modeling.diagram/src/org/apache/commons/scxml/modeling/diagram/part/ModelingCreationWizard.java ------------------------------------------------------------------------------ svn:eol-style = native Added: commons/sandbox/gsoc/2010/scxml-eclipse/trunk/src/main/java/org.apache.commons.scxml.modeling.diagram/src/org/apache/commons/scxml/modeling/diagram/part/ModelingCreationWizardPage.java URL: http://svn.apache.org/viewvc/commons/sandbox/gsoc/2010/scxml-eclipse/trunk/src/main/java/org.apache.commons.scxml.modeling.diagram/src/org/apache/commons/scxml/modeling/diagram/part/ModelingCreationWizardPage.java?rev=953071&view=auto ============================================================================== --- commons/sandbox/gsoc/2010/scxml-eclipse/trunk/src/main/java/org.apache.commons.scxml.modeling.diagram/src/org/apache/commons/scxml/modeling/diagram/part/ModelingCreationWizardPage.java (added) +++ commons/sandbox/gsoc/2010/scxml-eclipse/trunk/src/main/java/org.apache.commons.scxml.modeling.diagram/src/org/apache/commons/scxml/modeling/diagram/part/ModelingCreationWizardPage.java Wed Jun 9 16:12:48 2010 @@ -0,0 +1,104 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.apache.commons.scxml.modeling.diagram.part; + +import org.eclipse.core.runtime.IPath; +import org.eclipse.core.runtime.Path; +import org.eclipse.emf.common.util.URI; +import org.eclipse.jface.viewers.IStructuredSelection; +import org.eclipse.osgi.util.NLS; +import org.eclipse.swt.widgets.Composite; +import org.eclipse.ui.dialogs.WizardNewFileCreationPage; + +/** + * @generated + */ +public class ModelingCreationWizardPage extends WizardNewFileCreationPage { + + /** + * @generated + */ + private final String fileExtension; + + /** + * @generated + */ + public ModelingCreationWizardPage(String pageName, + IStructuredSelection selection, String fileExtension) { + super(pageName, selection); + this.fileExtension = fileExtension; + } + + /** + * Override to create files with this extension. + * + * @generated + */ + protected String getExtension() { + return fileExtension; + } + + /** + * @generated + */ + public URI getURI() { + return URI.createPlatformResourceURI(getFilePath().toString(), false); + } + + /** + * @generated + */ + protected IPath getFilePath() { + IPath path = getContainerFullPath(); + if (path == null) { + path = new Path(""); //$NON-NLS-1$ + } + String fileName = getFileName(); + if (fileName != null) { + path = path.append(fileName); + } + return path; + } + + /** + * @generated + */ + public void createControl(Composite parent) { + super.createControl(parent); + setFileName(ModelingDiagramEditorUtil.getUniqueFileName( + getContainerFullPath(), getFileName(), getExtension())); + setPageComplete(validatePage()); + } + + /** + * @generated + */ + protected boolean validatePage() { + if (!super.validatePage()) { + return false; + } + String extension = getExtension(); + if (extension != null + && !getFilePath().toString().endsWith("." + extension)) { + setErrorMessage(NLS.bind( + Messages.ModelingCreationWizardPageExtensionError, + extension)); + return false; + } + return true; + } +} Propchange: commons/sandbox/gsoc/2010/scxml-eclipse/trunk/src/main/java/org.apache.commons.scxml.modeling.diagram/src/org/apache/commons/scxml/modeling/diagram/part/ModelingCreationWizardPage.java ------------------------------------------------------------------------------ svn:eol-style = native Added: commons/sandbox/gsoc/2010/scxml-eclipse/trunk/src/main/java/org.apache.commons.scxml.modeling.diagram/src/org/apache/commons/scxml/modeling/diagram/part/ModelingDiagramActionBarContributor.java URL: http://svn.apache.org/viewvc/commons/sandbox/gsoc/2010/scxml-eclipse/trunk/src/main/java/org.apache.commons.scxml.modeling.diagram/src/org/apache/commons/scxml/modeling/diagram/part/ModelingDiagramActionBarContributor.java?rev=953071&view=auto ============================================================================== --- commons/sandbox/gsoc/2010/scxml-eclipse/trunk/src/main/java/org.apache.commons.scxml.modeling.diagram/src/org/apache/commons/scxml/modeling/diagram/part/ModelingDiagramActionBarContributor.java (added) +++ commons/sandbox/gsoc/2010/scxml-eclipse/trunk/src/main/java/org.apache.commons.scxml.modeling.diagram/src/org/apache/commons/scxml/modeling/diagram/part/ModelingDiagramActionBarContributor.java Wed Jun 9 16:12:48 2010 @@ -0,0 +1,40 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.apache.commons.scxml.modeling.diagram.part; + +import org.eclipse.gmf.runtime.diagram.ui.parts.DiagramActionBarContributor; + +/** + * @generated + */ +public class ModelingDiagramActionBarContributor extends + DiagramActionBarContributor { + + /** + * @generated + */ + protected Class getEditorClass() { + return ModelingDiagramEditor.class; + } + + /** + * @generated + */ + protected String getEditorId() { + return ModelingDiagramEditor.ID; + } +} Propchange: commons/sandbox/gsoc/2010/scxml-eclipse/trunk/src/main/java/org.apache.commons.scxml.modeling.diagram/src/org/apache/commons/scxml/modeling/diagram/part/ModelingDiagramActionBarContributor.java ------------------------------------------------------------------------------ svn:eol-style = native Added: commons/sandbox/gsoc/2010/scxml-eclipse/trunk/src/main/java/org.apache.commons.scxml.modeling.diagram/src/org/apache/commons/scxml/modeling/diagram/part/ModelingDiagramEditor.java URL: http://svn.apache.org/viewvc/commons/sandbox/gsoc/2010/scxml-eclipse/trunk/src/main/java/org.apache.commons.scxml.modeling.diagram/src/org/apache/commons/scxml/modeling/diagram/part/ModelingDiagramEditor.java?rev=953071&view=auto ============================================================================== --- commons/sandbox/gsoc/2010/scxml-eclipse/trunk/src/main/java/org.apache.commons.scxml.modeling.diagram/src/org/apache/commons/scxml/modeling/diagram/part/ModelingDiagramEditor.java (added) +++ commons/sandbox/gsoc/2010/scxml-eclipse/trunk/src/main/java/org.apache.commons.scxml.modeling.diagram/src/org/apache/commons/scxml/modeling/diagram/part/ModelingDiagramEditor.java Wed Jun 9 16:12:48 2010 @@ -0,0 +1,305 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.apache.commons.scxml.modeling.diagram.part; + +import org.apache.commons.scxml.modeling.diagram.navigator.ModelingNavigatorItem; +import org.eclipse.core.resources.IFile; +import org.eclipse.core.resources.IMarker; +import org.eclipse.core.resources.IWorkspaceRoot; +import org.eclipse.core.resources.ResourcesPlugin; +import org.eclipse.core.runtime.CoreException; +import org.eclipse.core.runtime.IPath; +import org.eclipse.core.runtime.IProgressMonitor; +import org.eclipse.core.runtime.IStatus; +import org.eclipse.core.runtime.NullProgressMonitor; +import org.eclipse.emf.common.ui.URIEditorInput; +import org.eclipse.emf.transaction.TransactionalEditingDomain; +import org.eclipse.emf.workspace.util.WorkspaceSynchronizer; +import org.eclipse.gef.palette.PaletteRoot; +import org.eclipse.gmf.runtime.common.ui.services.marker.MarkerNavigationService; +import org.eclipse.gmf.runtime.diagram.core.preferences.PreferencesHint; +import org.eclipse.gmf.runtime.diagram.ui.actions.ActionIds; +import org.eclipse.gmf.runtime.diagram.ui.resources.editor.document.IDiagramDocument; +import org.eclipse.gmf.runtime.diagram.ui.resources.editor.document.IDocument; +import org.eclipse.gmf.runtime.diagram.ui.resources.editor.document.IDocumentProvider; +import org.eclipse.gmf.runtime.diagram.ui.resources.editor.parts.DiagramDocumentEditor; +import org.eclipse.gmf.runtime.notation.Diagram; +import org.eclipse.jface.dialogs.ErrorDialog; +import org.eclipse.jface.dialogs.IMessageProvider; +import org.eclipse.jface.dialogs.MessageDialog; +import org.eclipse.jface.viewers.ISelection; +import org.eclipse.jface.viewers.StructuredSelection; +import org.eclipse.jface.window.Window; +import org.eclipse.osgi.util.NLS; +import org.eclipse.swt.widgets.Shell; +import org.eclipse.ui.IEditorInput; +import org.eclipse.ui.IEditorMatchingStrategy; +import org.eclipse.ui.IEditorReference; +import org.eclipse.ui.IFileEditorInput; +import org.eclipse.ui.PlatformUI; +import org.eclipse.ui.dialogs.SaveAsDialog; +import org.eclipse.ui.ide.IGotoMarker; +import org.eclipse.ui.navigator.resources.ProjectExplorer; +import org.eclipse.ui.part.FileEditorInput; +import org.eclipse.ui.part.IShowInTargetList; +import org.eclipse.ui.part.ShowInContext; + +/** + * @generated + */ +public class ModelingDiagramEditor extends DiagramDocumentEditor implements + IGotoMarker { + + /** + * @generated + */ + public static final String ID = "org.apache.commons.scxml.modeling.diagram.part.ModelingDiagramEditorID"; //$NON-NLS-1$ + + /** + * @generated + */ + public static final String CONTEXT_ID = "org.apache.commons.scxml.modeling.diagram.ui.diagramContext"; //$NON-NLS-1$ + + /** + * @generated + */ + public ModelingDiagramEditor() { + super(true); + } + + /** + * @generated + */ + protected String getContextID() { + return CONTEXT_ID; + } + + /** + * @generated + */ + protected PaletteRoot createPaletteRoot(PaletteRoot existingPaletteRoot) { + PaletteRoot root = super.createPaletteRoot(existingPaletteRoot); + new ModelingPaletteFactory().fillPalette(root); + return root; + } + + /** + * @generated + */ + protected PreferencesHint getPreferencesHint() { + return ModelingDiagramEditorPlugin.DIAGRAM_PREFERENCES_HINT; + } + + /** + * @generated + */ + public String getContributorId() { + return ModelingDiagramEditorPlugin.ID; + } + + /** + * @generated + */ + public Object getAdapter(Class type) { + if (type == IShowInTargetList.class) { + return new IShowInTargetList() { + public String[] getShowInTargetIds() { + return new String[] { ProjectExplorer.VIEW_ID }; + } + }; + } + return super.getAdapter(type); + } + + /** + * @generated + */ + protected IDocumentProvider getDocumentProvider(IEditorInput input) { + if (input instanceof IFileEditorInput + || input instanceof URIEditorInput) { + return ModelingDiagramEditorPlugin.getInstance() + .getDocumentProvider(); + } + return super.getDocumentProvider(input); + } + + /** + * @generated + */ + public TransactionalEditingDomain getEditingDomain() { + IDocument document = getEditorInput() != null ? getDocumentProvider() + .getDocument(getEditorInput()) : null; + if (document instanceof IDiagramDocument) { + return ((IDiagramDocument) document).getEditingDomain(); + } + return super.getEditingDomain(); + } + + /** + * @generated + */ + protected void setDocumentProvider(IEditorInput input) { + if (input instanceof IFileEditorInput + || input instanceof URIEditorInput) { + setDocumentProvider(ModelingDiagramEditorPlugin.getInstance() + .getDocumentProvider()); + } else { + super.setDocumentProvider(input); + } + } + + /** + * @generated + */ + public void gotoMarker(IMarker marker) { + MarkerNavigationService.getInstance().gotoMarker(this, marker); + } + + /** + * @generated + */ + public boolean isSaveAsAllowed() { + return true; + } + + /** + * @generated + */ + public void doSaveAs() { + performSaveAs(new NullProgressMonitor()); + } + + /** + * @generated + */ + protected void performSaveAs(IProgressMonitor progressMonitor) { + Shell shell = getSite().getShell(); + IEditorInput input = getEditorInput(); + SaveAsDialog dialog = new SaveAsDialog(shell); + IFile original = input instanceof IFileEditorInput ? ((IFileEditorInput) input) + .getFile() + : null; + if (original != null) { + dialog.setOriginalFile(original); + } + dialog.create(); + IDocumentProvider provider = getDocumentProvider(); + if (provider == null) { + // editor has been programmatically closed while the dialog was open + return; + } + if (provider.isDeleted(input) && original != null) { + String message = NLS.bind( + Messages.ModelingDiagramEditor_SavingDeletedFile, original + .getName()); + dialog.setErrorMessage(null); + dialog.setMessage(message, IMessageProvider.WARNING); + } + if (dialog.open() == Window.CANCEL) { + if (progressMonitor != null) { + progressMonitor.setCanceled(true); + } + return; + } + IPath filePath = dialog.getResult(); + if (filePath == null) { + if (progressMonitor != null) { + progressMonitor.setCanceled(true); + } + return; + } + IWorkspaceRoot workspaceRoot = ResourcesPlugin.getWorkspace().getRoot(); + IFile file = workspaceRoot.getFile(filePath); + final IEditorInput newInput = new FileEditorInput(file); + // Check if the editor is already open + IEditorMatchingStrategy matchingStrategy = getEditorDescriptor() + .getEditorMatchingStrategy(); + IEditorReference[] editorRefs = PlatformUI.getWorkbench() + .getActiveWorkbenchWindow().getActivePage() + .getEditorReferences(); + for (int i = 0; i < editorRefs.length; i++) { + if (matchingStrategy.matches(editorRefs[i], newInput)) { + MessageDialog.openWarning(shell, + Messages.ModelingDiagramEditor_SaveAsErrorTitle, + Messages.ModelingDiagramEditor_SaveAsErrorMessage); + return; + } + } + boolean success = false; + try { + provider.aboutToChange(newInput); + getDocumentProvider(newInput).saveDocument(progressMonitor, + newInput, + getDocumentProvider().getDocument(getEditorInput()), true); + success = true; + } catch (CoreException x) { + IStatus status = x.getStatus(); + if (status == null || status.getSeverity() != IStatus.CANCEL) { + ErrorDialog.openError(shell, + Messages.ModelingDiagramEditor_SaveErrorTitle, + Messages.ModelingDiagramEditor_SaveErrorMessage, x + .getStatus()); + } + } finally { + provider.changed(newInput); + if (success) { + setInput(newInput); + } + } + if (progressMonitor != null) { + progressMonitor.setCanceled(!success); + } + } + + /** + * @generated + */ + public ShowInContext getShowInContext() { + return new ShowInContext(getEditorInput(), getNavigatorSelection()); + } + + /** + * @generated + */ + private ISelection getNavigatorSelection() { + IDiagramDocument document = getDiagramDocument(); + if (document == null) { + return StructuredSelection.EMPTY; + } + Diagram diagram = document.getDiagram(); + IFile file = WorkspaceSynchronizer.getFile(diagram.eResource()); + if (file != null) { + ModelingNavigatorItem item = new ModelingNavigatorItem(diagram, + file, false); + return new StructuredSelection(item); + } + return StructuredSelection.EMPTY; + } + + /** + * @generated + */ + protected void configureGraphicalViewer() { + super.configureGraphicalViewer(); + DiagramEditorContextMenuProvider provider = new DiagramEditorContextMenuProvider( + this, getDiagramGraphicalViewer()); + getDiagramGraphicalViewer().setContextMenu(provider); + getSite().registerContextMenu(ActionIds.DIAGRAM_EDITOR_CONTEXT_MENU, + provider, getDiagramGraphicalViewer()); + } + +} Propchange: commons/sandbox/gsoc/2010/scxml-eclipse/trunk/src/main/java/org.apache.commons.scxml.modeling.diagram/src/org/apache/commons/scxml/modeling/diagram/part/ModelingDiagramEditor.java ------------------------------------------------------------------------------ svn:eol-style = native Added: commons/sandbox/gsoc/2010/scxml-eclipse/trunk/src/main/java/org.apache.commons.scxml.modeling.diagram/src/org/apache/commons/scxml/modeling/diagram/part/ModelingDiagramEditorPlugin.java URL: http://svn.apache.org/viewvc/commons/sandbox/gsoc/2010/scxml-eclipse/trunk/src/main/java/org.apache.commons.scxml.modeling.diagram/src/org/apache/commons/scxml/modeling/diagram/part/ModelingDiagramEditorPlugin.java?rev=953071&view=auto ============================================================================== --- commons/sandbox/gsoc/2010/scxml-eclipse/trunk/src/main/java/org.apache.commons.scxml.modeling.diagram/src/org/apache/commons/scxml/modeling/diagram/part/ModelingDiagramEditorPlugin.java (added) +++ commons/sandbox/gsoc/2010/scxml-eclipse/trunk/src/main/java/org.apache.commons.scxml.modeling.diagram/src/org/apache/commons/scxml/modeling/diagram/part/ModelingDiagramEditorPlugin.java Wed Jun 9 16:12:48 2010 @@ -0,0 +1,264 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.apache.commons.scxml.modeling.diagram.part; + +import java.util.ArrayList; +import java.util.List; + +import org.apache.commons.scxml.modeling.provider.ModelingItemProviderAdapterFactory; +import org.eclipse.core.runtime.IPath; +import org.eclipse.core.runtime.IStatus; +import org.eclipse.core.runtime.Path; +import org.eclipse.core.runtime.Platform; +import org.eclipse.core.runtime.Status; +import org.eclipse.emf.common.notify.AdapterFactory; +import org.eclipse.emf.edit.provider.ComposedAdapterFactory; +import org.eclipse.emf.edit.provider.IItemLabelProvider; +import org.eclipse.emf.edit.provider.ReflectiveItemProviderAdapterFactory; +import org.eclipse.emf.edit.provider.resource.ResourceItemProviderAdapterFactory; +import org.eclipse.emf.edit.ui.provider.ExtendedImageRegistry; +import org.eclipse.gmf.runtime.diagram.core.preferences.PreferencesHint; +import org.eclipse.jface.resource.ImageDescriptor; +import org.eclipse.swt.graphics.Image; +import org.eclipse.ui.plugin.AbstractUIPlugin; +import org.osgi.framework.BundleContext; + +/** + * @generated + */ +public class ModelingDiagramEditorPlugin extends AbstractUIPlugin { + + /** + * @generated + */ + public static final String ID = "org.apache.commons.scxml.modeling.diagram"; //$NON-NLS-1$ + + /** + * @generated + */ + public static final PreferencesHint DIAGRAM_PREFERENCES_HINT = new PreferencesHint( + ID); + + /** + * @generated + */ + private static ModelingDiagramEditorPlugin instance; + + /** + * @generated + */ + private ComposedAdapterFactory adapterFactory; + + /** + * @generated + */ + private ModelingDocumentProvider documentProvider; + + /** + * @generated + */ + public ModelingDiagramEditorPlugin() { + } + + /** + * @generated + */ + public void start(BundleContext context) throws Exception { + super.start(context); + instance = this; + PreferencesHint.registerPreferenceStore(DIAGRAM_PREFERENCES_HINT, + getPreferenceStore()); + adapterFactory = createAdapterFactory(); + } + + /** + * @generated + */ + public void stop(BundleContext context) throws Exception { + adapterFactory.dispose(); + adapterFactory = null; + instance = null; + super.stop(context); + } + + /** + * @generated + */ + public static ModelingDiagramEditorPlugin getInstance() { + return instance; + } + + /** + * @generated + */ + protected ComposedAdapterFactory createAdapterFactory() { + List factories = new ArrayList(); + fillItemProviderFactories(factories); + return new ComposedAdapterFactory(factories); + } + + /** + * @generated + */ + protected void fillItemProviderFactories(List factories) { + factories.add(new ModelingItemProviderAdapterFactory()); + factories.add(new ResourceItemProviderAdapterFactory()); + factories.add(new ReflectiveItemProviderAdapterFactory()); + } + + /** + * @generated + */ + public AdapterFactory getItemProvidersAdapterFactory() { + return adapterFactory; + } + + /** + * @generated + */ + public ImageDescriptor getItemImageDescriptor(Object item) { + IItemLabelProvider labelProvider = (IItemLabelProvider) adapterFactory + .adapt(item, IItemLabelProvider.class); + if (labelProvider != null) { + return ExtendedImageRegistry.getInstance().getImageDescriptor( + labelProvider.getImage(item)); + } + return null; + } + + /** + * Returns an image descriptor for the image file at the given + * plug-in relative path. + * + * @generated + * @param path the path + * @return the image descriptor + */ + public static ImageDescriptor getBundledImageDescriptor(String path) { + return AbstractUIPlugin.imageDescriptorFromPlugin(ID, path); + } + + /** + * Respects images residing in any plug-in. If path is relative, + * then this bundle is looked up for the image, otherwise, for absolute + * path, first segment is taken as id of plug-in with image + * + * @generated + * @param path the path to image, either absolute (with plug-in id as first segment), or relative for bundled images + * @return the image descriptor + */ + public static ImageDescriptor findImageDescriptor(String path) { + final IPath p = new Path(path); + if (p.isAbsolute() && p.segmentCount() > 1) { + return AbstractUIPlugin.imageDescriptorFromPlugin(p.segment(0), p + .removeFirstSegments(1).makeAbsolute().toString()); + } else { + return getBundledImageDescriptor(p.makeAbsolute().toString()); + } + } + + /** + * Returns an image for the image file at the given plug-in relative path. + * Client do not need to dispose this image. Images will be disposed automatically. + * + * @generated + * @param path the path + * @return image instance + */ + public Image getBundledImage(String path) { + Image image = getImageRegistry().get(path); + if (image == null) { + getImageRegistry().put(path, getBundledImageDescriptor(path)); + image = getImageRegistry().get(path); + } + return image; + } + + /** + * Returns string from plug-in's resource bundle + * + * @generated + */ + public static String getString(String key) { + return Platform.getResourceString(getInstance().getBundle(), "%" + key); //$NON-NLS-1$ + } + + /** + * @generated + */ + public ModelingDocumentProvider getDocumentProvider() { + if (documentProvider == null) { + documentProvider = new ModelingDocumentProvider(); + } + return documentProvider; + } + + /** + * @generated + */ + public void logError(String error) { + logError(error, null); + } + + /** + * @generated + */ + public void logError(String error, Throwable throwable) { + if (error == null && throwable != null) { + error = throwable.getMessage(); + } + getLog().log( + new Status(IStatus.ERROR, ModelingDiagramEditorPlugin.ID, + IStatus.OK, error, throwable)); + debug(error, throwable); + } + + /** + * @generated + */ + public void logInfo(String message) { + logInfo(message, null); + } + + /** + * @generated + */ + public void logInfo(String message, Throwable throwable) { + if (message == null && throwable != null) { + message = throwable.getMessage(); + } + getLog().log( + new Status(IStatus.INFO, ModelingDiagramEditorPlugin.ID, + IStatus.OK, message, throwable)); + debug(message, throwable); + } + + /** + * @generated + */ + private void debug(String message, Throwable throwable) { + if (!isDebugging()) { + return; + } + if (message != null) { + System.err.println(message); + } + if (throwable != null) { + throwable.printStackTrace(); + } + } +} Propchange: commons/sandbox/gsoc/2010/scxml-eclipse/trunk/src/main/java/org.apache.commons.scxml.modeling.diagram/src/org/apache/commons/scxml/modeling/diagram/part/ModelingDiagramEditorPlugin.java ------------------------------------------------------------------------------ svn:eol-style = native Added: commons/sandbox/gsoc/2010/scxml-eclipse/trunk/src/main/java/org.apache.commons.scxml.modeling.diagram/src/org/apache/commons/scxml/modeling/diagram/part/ModelingDiagramEditorUtil.java URL: http://svn.apache.org/viewvc/commons/sandbox/gsoc/2010/scxml-eclipse/trunk/src/main/java/org.apache.commons.scxml.modeling.diagram/src/org/apache/commons/scxml/modeling/diagram/part/ModelingDiagramEditorUtil.java?rev=953071&view=auto ============================================================================== --- commons/sandbox/gsoc/2010/scxml-eclipse/trunk/src/main/java/org.apache.commons.scxml.modeling.diagram/src/org/apache/commons/scxml/modeling/diagram/part/ModelingDiagramEditorUtil.java (added) +++ commons/sandbox/gsoc/2010/scxml-eclipse/trunk/src/main/java/org.apache.commons.scxml.modeling.diagram/src/org/apache/commons/scxml/modeling/diagram/part/ModelingDiagramEditorUtil.java Wed Jun 9 16:12:48 2010 @@ -0,0 +1,446 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.apache.commons.scxml.modeling.diagram.part; + +import java.io.IOException; +import java.util.ArrayList; +import java.util.Collections; +import java.util.HashMap; +import java.util.Iterator; +import java.util.List; +import java.util.Map; +import java.util.Set; + +import org.apache.commons.scxml.modeling.ModelingFactory; +import org.apache.commons.scxml.modeling.ServiceTemplate; +import org.apache.commons.scxml.modeling.diagram.edit.parts.ServiceTemplateEditPart; +import org.eclipse.core.commands.ExecutionException; +import org.eclipse.core.commands.operations.OperationHistoryFactory; +import org.eclipse.core.resources.IFile; +import org.eclipse.core.resources.IResource; +import org.eclipse.core.resources.ResourcesPlugin; +import org.eclipse.core.runtime.CoreException; +import org.eclipse.core.runtime.IAdaptable; +import org.eclipse.core.runtime.IPath; +import org.eclipse.core.runtime.IProgressMonitor; +import org.eclipse.core.runtime.NullProgressMonitor; +import org.eclipse.core.runtime.Path; +import org.eclipse.core.runtime.SubProgressMonitor; +import org.eclipse.emf.common.util.URI; +import org.eclipse.emf.ecore.EObject; +import org.eclipse.emf.ecore.resource.Resource; +import org.eclipse.emf.ecore.xmi.XMLResource; +import org.eclipse.emf.transaction.TransactionalEditingDomain; +import org.eclipse.emf.workspace.util.WorkspaceSynchronizer; +import org.eclipse.gef.EditPart; +import org.eclipse.gmf.runtime.common.core.command.CommandResult; +import org.eclipse.gmf.runtime.diagram.core.services.ViewService; +import org.eclipse.gmf.runtime.diagram.ui.editparts.DiagramEditPart; +import org.eclipse.gmf.runtime.diagram.ui.editparts.IGraphicalEditPart; +import org.eclipse.gmf.runtime.diagram.ui.editparts.IPrimaryEditPart; +import org.eclipse.gmf.runtime.diagram.ui.parts.IDiagramGraphicalViewer; +import org.eclipse.gmf.runtime.diagram.ui.parts.IDiagramWorkbenchPart; +import org.eclipse.gmf.runtime.emf.commands.core.command.AbstractTransactionalCommand; +import org.eclipse.gmf.runtime.emf.core.GMFEditingDomainFactory; +import org.eclipse.gmf.runtime.emf.core.util.EMFCoreUtil; +import org.eclipse.gmf.runtime.notation.Diagram; +import org.eclipse.gmf.runtime.notation.View; +import org.eclipse.jface.dialogs.IDialogSettings; +import org.eclipse.jface.wizard.Wizard; +import org.eclipse.jface.wizard.WizardDialog; +import org.eclipse.swt.widgets.Shell; +import org.eclipse.ui.IWorkbenchPage; +import org.eclipse.ui.PartInitException; +import org.eclipse.ui.PlatformUI; +import org.eclipse.ui.part.FileEditorInput; + +/** + * @generated + */ +public class ModelingDiagramEditorUtil { + + /** + * @generated + */ + public static Map getSaveOptions() { + Map saveOptions = new HashMap(); + saveOptions.put(XMLResource.OPTION_ENCODING, "UTF-8"); //$NON-NLS-1$ + saveOptions.put(Resource.OPTION_SAVE_ONLY_IF_CHANGED, + Resource.OPTION_SAVE_ONLY_IF_CHANGED_MEMORY_BUFFER); + return saveOptions; + } + + /** + * @generated + */ + public static boolean openDiagram(Resource diagram) + throws PartInitException { + String path = diagram.getURI().toPlatformString(true); + IResource workspaceResource = ResourcesPlugin.getWorkspace().getRoot() + .findMember(new Path(path)); + if (workspaceResource instanceof IFile) { + IWorkbenchPage page = PlatformUI.getWorkbench() + .getActiveWorkbenchWindow().getActivePage(); + return null != page.openEditor(new FileEditorInput( + (IFile) workspaceResource), ModelingDiagramEditor.ID); + } + return false; + } + + /** + * @generated + */ + public static void setCharset(IFile file) { + if (file == null) { + return; + } + try { + file.setCharset("UTF-8", new NullProgressMonitor()); //$NON-NLS-1$ + } catch (CoreException e) { + ModelingDiagramEditorPlugin.getInstance().logError( + "Unable to set charset for file " + file.getFullPath(), e); //$NON-NLS-1$ + } + } + + /** + * @generated + */ + public static String getUniqueFileName(IPath containerFullPath, + String fileName, String extension) { + if (containerFullPath == null) { + containerFullPath = new Path(""); //$NON-NLS-1$ + } + if (fileName == null || fileName.trim().length() == 0) { + fileName = "default"; //$NON-NLS-1$ + } + IPath filePath = containerFullPath.append(fileName); + if (extension != null && !extension.equals(filePath.getFileExtension())) { + filePath = filePath.addFileExtension(extension); + } + extension = filePath.getFileExtension(); + fileName = filePath.removeFileExtension().lastSegment(); + int i = 1; + while (ResourcesPlugin.getWorkspace().getRoot().exists(filePath)) { + i++; + filePath = containerFullPath.append(fileName + i); + if (extension != null) { + filePath = filePath.addFileExtension(extension); + } + } + return filePath.lastSegment(); + } + + /** + * Runs the wizard in a dialog. + * + * @generated + */ + public static void runWizard(Shell shell, Wizard wizard, String settingsKey) { + IDialogSettings pluginDialogSettings = ModelingDiagramEditorPlugin + .getInstance().getDialogSettings(); + IDialogSettings wizardDialogSettings = pluginDialogSettings + .getSection(settingsKey); + if (wizardDialogSettings == null) { + wizardDialogSettings = pluginDialogSettings + .addNewSection(settingsKey); + } + wizard.setDialogSettings(wizardDialogSettings); + WizardDialog dialog = new WizardDialog(shell, wizard); + dialog.create(); + dialog.getShell().setSize(Math.max(500, dialog.getShell().getSize().x), + 500); + dialog.open(); + } + + /** + * This method should be called within a workspace modify operation since it creates resources. + * @generated + */ + public static Resource createDiagram(URI diagramURI, URI modelURI, + IProgressMonitor progressMonitor) { + TransactionalEditingDomain editingDomain = GMFEditingDomainFactory.INSTANCE + .createEditingDomain(); + progressMonitor + .beginTask( + Messages.ModelingDiagramEditorUtil_CreateDiagramProgressTask, + 3); + final Resource diagramResource = editingDomain.getResourceSet() + .createResource(diagramURI); + final Resource modelResource = editingDomain.getResourceSet() + .createResource(modelURI); + final String diagramName = diagramURI.lastSegment(); + AbstractTransactionalCommand command = new AbstractTransactionalCommand( + editingDomain, + Messages.ModelingDiagramEditorUtil_CreateDiagramCommandLabel, + Collections.EMPTY_LIST) { + protected CommandResult doExecuteWithResult( + IProgressMonitor monitor, IAdaptable info) + throws ExecutionException { + ServiceTemplate model = createInitialModel(); + attachModelToResource(model, modelResource); + + Diagram diagram = ViewService.createDiagram(model, + ServiceTemplateEditPart.MODEL_ID, + ModelingDiagramEditorPlugin.DIAGRAM_PREFERENCES_HINT); + if (diagram != null) { + diagramResource.getContents().add(diagram); + diagram.setName(diagramName); + diagram.setElement(model); + } + + try { + modelResource + .save(org.apache.commons.scxml.modeling.diagram.part.ModelingDiagramEditorUtil + .getSaveOptions()); + diagramResource + .save(org.apache.commons.scxml.modeling.diagram.part.ModelingDiagramEditorUtil + .getSaveOptions()); + } catch (IOException e) { + + ModelingDiagramEditorPlugin.getInstance().logError( + "Unable to store model and diagram resources", e); //$NON-NLS-1$ + } + return CommandResult.newOKCommandResult(); + } + }; + try { + OperationHistoryFactory.getOperationHistory().execute(command, + new SubProgressMonitor(progressMonitor, 1), null); + } catch (ExecutionException e) { + ModelingDiagramEditorPlugin.getInstance().logError( + "Unable to create model and diagram", e); //$NON-NLS-1$ + } + setCharset(WorkspaceSynchronizer.getFile(modelResource)); + setCharset(WorkspaceSynchronizer.getFile(diagramResource)); + return diagramResource; + } + + /** + * Create a new instance of domain element associated with canvas. + * + * + * @generated + */ + private static ServiceTemplate createInitialModel() { + return ModelingFactory.eINSTANCE.createServiceTemplate(); + } + + /** + * Store model element in the resource. + * + * + * @generated + */ + private static void attachModelToResource(ServiceTemplate model, + Resource resource) { + resource.getContents().add(model); + } + + /** + * @generated + */ + public static void selectElementsInDiagram( + IDiagramWorkbenchPart diagramPart, List/*EditPart*/editParts) { + diagramPart.getDiagramGraphicalViewer().deselectAll(); + + EditPart firstPrimary = null; + for (Iterator it = editParts.iterator(); it.hasNext();) { + EditPart nextPart = (EditPart) it.next(); + diagramPart.getDiagramGraphicalViewer().appendSelection(nextPart); + if (firstPrimary == null && nextPart instanceof IPrimaryEditPart) { + firstPrimary = nextPart; + } + } + + if (!editParts.isEmpty()) { + diagramPart.getDiagramGraphicalViewer().reveal( + firstPrimary != null ? firstPrimary : (EditPart) editParts + .get(0)); + } + } + + /** + * @generated + */ + private static int findElementsInDiagramByID(DiagramEditPart diagramPart, + EObject element, List editPartCollector) { + IDiagramGraphicalViewer viewer = (IDiagramGraphicalViewer) diagramPart + .getViewer(); + final int intialNumOfEditParts = editPartCollector.size(); + + if (element instanceof View) { // support notation element lookup + EditPart editPart = (EditPart) viewer.getEditPartRegistry().get( + element); + if (editPart != null) { + editPartCollector.add(editPart); + return 1; + } + } + + String elementID = EMFCoreUtil.getProxyID(element); + List associatedParts = viewer.findEditPartsForElement(elementID, + IGraphicalEditPart.class); + // perform the possible hierarchy disjoint -> take the top-most parts only + for (Iterator editPartIt = associatedParts.iterator(); editPartIt + .hasNext();) { + EditPart nextPart = (EditPart) editPartIt.next(); + EditPart parentPart = nextPart.getParent(); + while (parentPart != null && !associatedParts.contains(parentPart)) { + parentPart = parentPart.getParent(); + } + if (parentPart == null) { + editPartCollector.add(nextPart); + } + } + + if (intialNumOfEditParts == editPartCollector.size()) { + if (!associatedParts.isEmpty()) { + editPartCollector.add(associatedParts.iterator().next()); + } else { + if (element.eContainer() != null) { + return findElementsInDiagramByID(diagramPart, element + .eContainer(), editPartCollector); + } + } + } + return editPartCollector.size() - intialNumOfEditParts; + } + + /** + * @generated + */ + public static View findView(DiagramEditPart diagramEditPart, + EObject targetElement, LazyElement2ViewMap lazyElement2ViewMap) { + boolean hasStructuralURI = false; + if (targetElement.eResource() instanceof XMLResource) { + hasStructuralURI = ((XMLResource) targetElement.eResource()) + .getID(targetElement) == null; + } + + View view = null; + if (hasStructuralURI + && !lazyElement2ViewMap.getElement2ViewMap().isEmpty()) { + view = (View) lazyElement2ViewMap.getElement2ViewMap().get( + targetElement); + } else if (findElementsInDiagramByID(diagramEditPart, targetElement, + lazyElement2ViewMap.editPartTmpHolder) > 0) { + EditPart editPart = (EditPart) lazyElement2ViewMap.editPartTmpHolder + .get(0); + lazyElement2ViewMap.editPartTmpHolder.clear(); + view = editPart.getModel() instanceof View ? (View) editPart + .getModel() : null; + } + + return (view == null) ? diagramEditPart.getDiagramView() : view; + } + + /** + * @generated + */ + public static class LazyElement2ViewMap { + /** + * @generated + */ + private Map element2ViewMap; + + /** + * @generated + */ + private View scope; + + /** + * @generated + */ + private Set elementSet; + + /** + * @generated + */ + public final List editPartTmpHolder = new ArrayList(); + + /** + * @generated + */ + public LazyElement2ViewMap(View scope, Set elements) { + this.scope = scope; + this.elementSet = elements; + } + + /** + * @generated + */ + public final Map getElement2ViewMap() { + if (element2ViewMap == null) { + element2ViewMap = new HashMap(); + // map possible notation elements to itself as these can't be found by view.getElement() + for (Iterator it = elementSet.iterator(); it.hasNext();) { + EObject element = (EObject) it.next(); + if (element instanceof View) { + View view = (View) element; + if (view.getDiagram() == scope.getDiagram()) { + element2ViewMap.put(element, element); // take only those that part of our diagram + } + } + } + + buildElement2ViewMap(scope, element2ViewMap, elementSet); + } + return element2ViewMap; + } + + /** + * @generated + */ + static Map buildElement2ViewMap(View parentView, Map element2ViewMap, + Set elements) { + if (elements.size() == element2ViewMap.size()) + return element2ViewMap; + + if (parentView.isSetElement() + && !element2ViewMap.containsKey(parentView.getElement()) + && elements.contains(parentView.getElement())) { + element2ViewMap.put(parentView.getElement(), parentView); + if (elements.size() == element2ViewMap.size()) + return element2ViewMap; + } + + for (Iterator it = parentView.getChildren().iterator(); it + .hasNext();) { + buildElement2ViewMap((View) it.next(), element2ViewMap, + elements); + if (elements.size() == element2ViewMap.size()) + return element2ViewMap; + } + for (Iterator it = parentView.getSourceEdges().iterator(); it + .hasNext();) { + buildElement2ViewMap((View) it.next(), element2ViewMap, + elements); + if (elements.size() == element2ViewMap.size()) + return element2ViewMap; + } + for (Iterator it = parentView.getSourceEdges().iterator(); it + .hasNext();) { + buildElement2ViewMap((View) it.next(), element2ViewMap, + elements); + if (elements.size() == element2ViewMap.size()) + return element2ViewMap; + } + return element2ViewMap; + } + } //LazyElement2ViewMap + +} Propchange: commons/sandbox/gsoc/2010/scxml-eclipse/trunk/src/main/java/org.apache.commons.scxml.modeling.diagram/src/org/apache/commons/scxml/modeling/diagram/part/ModelingDiagramEditorUtil.java ------------------------------------------------------------------------------ svn:eol-style = native