commons-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From gu...@apache.org
Subject svn commit: r945185 [32/42] - in /commons/sandbox/gsoc/2010/scxml-eclipse/trunk/src/main/java/org.apache.commons.scxml.diagram: ./ META-INF/ bin/ icons/ icons/obj16/ icons/wizban/ src/ src/org/ src/org/apache/ src/org/apache/commons/ src/org/apache/com...
Date Mon, 17 May 2010 14:38:59 GMT
Added: commons/sandbox/gsoc/2010/scxml-eclipse/trunk/src/main/java/org.apache.commons.scxml.diagram/src/org/apache/commons/scxml/diagram/part/DeleteElementAction.java
URL: http://svn.apache.org/viewvc/commons/sandbox/gsoc/2010/scxml-eclipse/trunk/src/main/java/org.apache.commons.scxml.diagram/src/org/apache/commons/scxml/diagram/part/DeleteElementAction.java?rev=945185&view=auto
==============================================================================
--- commons/sandbox/gsoc/2010/scxml-eclipse/trunk/src/main/java/org.apache.commons.scxml.diagram/src/org/apache/commons/scxml/diagram/part/DeleteElementAction.java (added)
+++ commons/sandbox/gsoc/2010/scxml-eclipse/trunk/src/main/java/org.apache.commons.scxml.diagram/src/org/apache/commons/scxml/diagram/part/DeleteElementAction.java Mon May 17 14:38:45 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.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.diagram/src/org/apache/commons/scxml/diagram/part/DeleteElementAction.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: commons/sandbox/gsoc/2010/scxml-eclipse/trunk/src/main/java/org.apache.commons.scxml.diagram/src/org/apache/commons/scxml/diagram/part/DiagramEditorContextMenuProvider.java
URL: http://svn.apache.org/viewvc/commons/sandbox/gsoc/2010/scxml-eclipse/trunk/src/main/java/org.apache.commons.scxml.diagram/src/org/apache/commons/scxml/diagram/part/DiagramEditorContextMenuProvider.java?rev=945185&view=auto
==============================================================================
--- commons/sandbox/gsoc/2010/scxml-eclipse/trunk/src/main/java/org.apache.commons.scxml.diagram/src/org/apache/commons/scxml/diagram/part/DiagramEditorContextMenuProvider.java (added)
+++ commons/sandbox/gsoc/2010/scxml-eclipse/trunk/src/main/java/org.apache.commons.scxml.diagram/src/org/apache/commons/scxml/diagram/part/DiagramEditorContextMenuProvider.java Mon May 17 14:38:45 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.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) {
+			ScxmlDiagramEditorPlugin.getInstance().logError(
+					"Error building context menu", e);
+		}
+	}
+}

Propchange: commons/sandbox/gsoc/2010/scxml-eclipse/trunk/src/main/java/org.apache.commons.scxml.diagram/src/org/apache/commons/scxml/diagram/part/DiagramEditorContextMenuProvider.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: commons/sandbox/gsoc/2010/scxml-eclipse/trunk/src/main/java/org.apache.commons.scxml.diagram/src/org/apache/commons/scxml/diagram/part/Messages.java
URL: http://svn.apache.org/viewvc/commons/sandbox/gsoc/2010/scxml-eclipse/trunk/src/main/java/org.apache.commons.scxml.diagram/src/org/apache/commons/scxml/diagram/part/Messages.java?rev=945185&view=auto
==============================================================================
--- commons/sandbox/gsoc/2010/scxml-eclipse/trunk/src/main/java/org.apache.commons.scxml.diagram/src/org/apache/commons/scxml/diagram/part/Messages.java (added)
+++ commons/sandbox/gsoc/2010/scxml-eclipse/trunk/src/main/java/org.apache.commons.scxml.diagram/src/org/apache/commons/scxml/diagram/part/Messages.java Mon May 17 14:38:45 2010
@@ -0,0 +1,845 @@
+/*
+ * 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.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 ScxmlCreationWizardTitle;
+
+	/**
+	 * @generated
+	 */
+	public static String ScxmlCreationWizard_DiagramModelFilePageTitle;
+
+	/**
+	 * @generated
+	 */
+	public static String ScxmlCreationWizard_DiagramModelFilePageDescription;
+
+	/**
+	 * @generated
+	 */
+	public static String ScxmlCreationWizard_DomainModelFilePageTitle;
+
+	/**
+	 * @generated
+	 */
+	public static String ScxmlCreationWizard_DomainModelFilePageDescription;
+
+	/**
+	 * @generated
+	 */
+	public static String ScxmlCreationWizardOpenEditorError;
+
+	/**
+	 * @generated
+	 */
+	public static String ScxmlCreationWizardCreationError;
+
+	/**
+	 * @generated
+	 */
+	public static String ScxmlCreationWizardPageExtensionError;
+
+	/**
+	 * @generated
+	 */
+	public static String ScxmlDiagramEditorUtil_OpenModelResourceErrorDialogTitle;
+
+	/**
+	 * @generated
+	 */
+	public static String ScxmlDiagramEditorUtil_OpenModelResourceErrorDialogMessage;
+
+	/**
+	 * @generated
+	 */
+	public static String ScxmlDiagramEditorUtil_CreateDiagramProgressTask;
+
+	/**
+	 * @generated
+	 */
+	public static String ScxmlDiagramEditorUtil_CreateDiagramCommandLabel;
+
+	/**
+	 * @generated
+	 */
+	public static String ScxmlDocumentProvider_isModifiable;
+
+	/**
+	 * @generated
+	 */
+	public static String ScxmlDocumentProvider_handleElementContentChanged;
+
+	/**
+	 * @generated
+	 */
+	public static String ScxmlDocumentProvider_IncorrectInputError;
+
+	/**
+	 * @generated
+	 */
+	public static String ScxmlDocumentProvider_NoDiagramInResourceError;
+
+	/**
+	 * @generated
+	 */
+	public static String ScxmlDocumentProvider_DiagramLoadingError;
+
+	/**
+	 * @generated
+	 */
+	public static String ScxmlDocumentProvider_UnsynchronizedFileSaveError;
+
+	/**
+	 * @generated
+	 */
+	public static String ScxmlDocumentProvider_SaveDiagramTask;
+
+	/**
+	 * @generated
+	 */
+	public static String ScxmlDocumentProvider_SaveNextResourceTask;
+
+	/**
+	 * @generated
+	 */
+	public static String ScxmlDocumentProvider_SaveAsOperation;
+
+	/**
+	 * @generated
+	 */
+	public static String ScxmlInitDiagramFileAction_InitDiagramFileResourceErrorDialogTitle;
+
+	/**
+	 * @generated
+	 */
+	public static String ScxmlInitDiagramFileAction_InitDiagramFileResourceErrorDialogMessage;
+
+	/**
+	 * @generated
+	 */
+	public static String ScxmlInitDiagramFileAction_InitDiagramFileWizardTitle;
+
+	/**
+	 * @generated
+	 */
+	public static String ScxmlInitDiagramFileAction_OpenModelFileDialogTitle;
+
+	/**
+	 * @generated
+	 */
+	public static String ScxmlNewDiagramFileWizard_CreationPageName;
+
+	/**
+	 * @generated
+	 */
+	public static String ScxmlNewDiagramFileWizard_CreationPageTitle;
+
+	/**
+	 * @generated
+	 */
+	public static String ScxmlNewDiagramFileWizard_CreationPageDescription;
+
+	/**
+	 * @generated
+	 */
+	public static String ScxmlNewDiagramFileWizard_RootSelectionPageName;
+
+	/**
+	 * @generated
+	 */
+	public static String ScxmlNewDiagramFileWizard_RootSelectionPageTitle;
+
+	/**
+	 * @generated
+	 */
+	public static String ScxmlNewDiagramFileWizard_RootSelectionPageDescription;
+
+	/**
+	 * @generated
+	 */
+	public static String ScxmlNewDiagramFileWizard_RootSelectionPageSelectionTitle;
+
+	/**
+	 * @generated
+	 */
+	public static String ScxmlNewDiagramFileWizard_RootSelectionPageNoSelectionMessage;
+
+	/**
+	 * @generated
+	 */
+	public static String ScxmlNewDiagramFileWizard_RootSelectionPageInvalidSelectionMessage;
+
+	/**
+	 * @generated
+	 */
+	public static String ScxmlNewDiagramFileWizard_InitDiagramCommand;
+
+	/**
+	 * @generated
+	 */
+	public static String ScxmlNewDiagramFileWizard_IncorrectRootError;
+
+	/**
+	 * @generated
+	 */
+	public static String ScxmlDiagramEditor_SavingDeletedFile;
+
+	/**
+	 * @generated
+	 */
+	public static String ScxmlDiagramEditor_SaveAsErrorTitle;
+
+	/**
+	 * @generated
+	 */
+	public static String ScxmlDiagramEditor_SaveAsErrorMessage;
+
+	/**
+	 * @generated
+	 */
+	public static String ScxmlDiagramEditor_SaveErrorTitle;
+
+	/**
+	 * @generated
+	 */
+	public static String ScxmlDiagramEditor_SaveErrorMessage;
+
+	/**
+	 * @generated
+	 */
+	public static String ScxmlElementChooserDialog_SelectModelElementTitle;
+
+	/**
+	 * @generated
+	 */
+	public static String ModelElementSelectionPageMessage;
+
+	/**
+	 * @generated
+	 */
+	public static String ValidateActionMessage;
+
+	/**
+	 * @generated
+	 */
+	public static String Scxml1Group_title;
+
+	/**
+	 * @generated
+	 */
+	public static String State1CreationTool_title;
+
+	/**
+	 * @generated
+	 */
+	public static String State1CreationTool_desc;
+
+	/**
+	 * @generated
+	 */
+	public static String Translation2CreationTool_title;
+
+	/**
+	 * @generated
+	 */
+	public static String Translation2CreationTool_desc;
+
+	/**
+	 * @generated
+	 */
+	public static String Assign3CreationTool_title;
+
+	/**
+	 * @generated
+	 */
+	public static String Assign3CreationTool_desc;
+
+	/**
+	 * @generated
+	 */
+	public static String OnEntry4CreationTool_title;
+
+	/**
+	 * @generated
+	 */
+	public static String OnEntry4CreationTool_desc;
+
+	/**
+	 * @generated
+	 */
+	public static String OnExit5CreationTool_title;
+
+	/**
+	 * @generated
+	 */
+	public static String OnExit5CreationTool_desc;
+
+	/**
+	 * @generated
+	 */
+	public static String InitialState6CreationTool_title;
+
+	/**
+	 * @generated
+	 */
+	public static String InitialState6CreationTool_desc;
+
+	/**
+	 * @generated
+	 */
+	public static String FinalState7CreationTool_title;
+
+	/**
+	 * @generated
+	 */
+	public static String FinalState7CreationTool_desc;
+
+	/**
+	 * @generated
+	 */
+	public static String Parallel8CreationTool_title;
+
+	/**
+	 * @generated
+	 */
+	public static String Parallel8CreationTool_desc;
+
+	/**
+	 * @generated
+	 */
+	public static String HistoryState9CreationTool_title;
+
+	/**
+	 * @generated
+	 */
+	public static String HistoryState9CreationTool_desc;
+
+	/**
+	 * @generated
+	 */
+	public static String Raise10CreationTool_title;
+
+	/**
+	 * @generated
+	 */
+	public static String Raise10CreationTool_desc;
+
+	/**
+	 * @generated
+	 */
+	public static String If11CreationTool_title;
+
+	/**
+	 * @generated
+	 */
+	public static String If11CreationTool_desc;
+
+	/**
+	 * @generated
+	 */
+	public static String ElseIf12CreationTool_title;
+
+	/**
+	 * @generated
+	 */
+	public static String ElseIf12CreationTool_desc;
+
+	/**
+	 * @generated
+	 */
+	public static String Else13CreationTool_title;
+
+	/**
+	 * @generated
+	 */
+	public static String Else13CreationTool_desc;
+
+	/**
+	 * @generated
+	 */
+	public static String Log14CreationTool_title;
+
+	/**
+	 * @generated
+	 */
+	public static String Log14CreationTool_desc;
+
+	/**
+	 * @generated
+	 */
+	public static String ExtenExecContent15CreationTool_title;
+
+	/**
+	 * @generated
+	 */
+	public static String ExtenExecContent15CreationTool_desc;
+
+	/**
+	 * @generated
+	 */
+	public static String DataModel16CreationTool_title;
+
+	/**
+	 * @generated
+	 */
+	public static String DataModel16CreationTool_desc;
+
+	/**
+	 * @generated
+	 */
+	public static String Data17CreationTool_title;
+
+	/**
+	 * @generated
+	 */
+	public static String Data17CreationTool_desc;
+
+	/**
+	 * @generated
+	 */
+	public static String Validate18CreationTool_title;
+
+	/**
+	 * @generated
+	 */
+	public static String Validate18CreationTool_desc;
+
+	/**
+	 * @generated
+	 */
+	public static String Param19CreationTool_title;
+
+	/**
+	 * @generated
+	 */
+	public static String Param19CreationTool_desc;
+
+	/**
+	 * @generated
+	 */
+	public static String Script20CreationTool_title;
+
+	/**
+	 * @generated
+	 */
+	public static String Script20CreationTool_desc;
+
+	/**
+	 * @generated
+	 */
+	public static String Anchor21CreationTool_title;
+
+	/**
+	 * @generated
+	 */
+	public static String Anchor21CreationTool_desc;
+
+	/**
+	 * @generated
+	 */
+	public static String Send22CreationTool_title;
+
+	/**
+	 * @generated
+	 */
+	public static String Send22CreationTool_desc;
+
+	/**
+	 * @generated
+	 */
+	public static String Cancel23CreationTool_title;
+
+	/**
+	 * @generated
+	 */
+	public static String Cancel23CreationTool_desc;
+
+	/**
+	 * @generated
+	 */
+	public static String Content24CreationTool_title;
+
+	/**
+	 * @generated
+	 */
+	public static String Content24CreationTool_desc;
+
+	/**
+	 * @generated
+	 */
+	public static String Donedata25CreationTool_title;
+
+	/**
+	 * @generated
+	 */
+	public static String Donedata25CreationTool_desc;
+
+	/**
+	 * @generated
+	 */
+	public static String Invoke26CreationTool_title;
+
+	/**
+	 * @generated
+	 */
+	public static String Invoke26CreationTool_desc;
+
+	/**
+	 * @generated
+	 */
+	public static String Finalize27CreationTool_title;
+
+	/**
+	 * @generated
+	 */
+	public static String Finalize27CreationTool_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_79_links;
+
+	/**
+	 * @generated
+	 */
+	public static String NavigatorGroupName_State_1001_incominglinks;
+
+	/**
+	 * @generated
+	 */
+	public static String NavigatorGroupName_State_1001_outgoinglinks;
+
+	/**
+	 * @generated
+	 */
+	public static String NavigatorGroupName_InitialState_1002_incominglinks;
+
+	/**
+	 * @generated
+	 */
+	public static String NavigatorGroupName_InitialState_1002_outgoinglinks;
+
+	/**
+	 * @generated
+	 */
+	public static String NavigatorGroupName_Parallel_1004_incominglinks;
+
+	/**
+	 * @generated
+	 */
+	public static String NavigatorGroupName_Parallel_1004_outgoinglinks;
+
+	/**
+	 * @generated
+	 */
+	public static String NavigatorGroupName_FinalState_1006_incominglinks;
+
+	/**
+	 * @generated
+	 */
+	public static String NavigatorGroupName_FinalState_1006_outgoinglinks;
+
+	/**
+	 * @generated
+	 */
+	public static String NavigatorGroupName_InitialState_2030_incominglinks;
+
+	/**
+	 * @generated
+	 */
+	public static String NavigatorGroupName_InitialState_2030_outgoinglinks;
+
+	/**
+	 * @generated
+	 */
+	public static String NavigatorGroupName_HistoryState_2031_incominglinks;
+
+	/**
+	 * @generated
+	 */
+	public static String NavigatorGroupName_HistoryState_2031_outgoinglinks;
+
+	/**
+	 * @generated
+	 */
+	public static String NavigatorGroupName_Parallel_2032_incominglinks;
+
+	/**
+	 * @generated
+	 */
+	public static String NavigatorGroupName_Parallel_2032_outgoinglinks;
+
+	/**
+	 * @generated
+	 */
+	public static String NavigatorGroupName_HistoryState_2033_incominglinks;
+
+	/**
+	 * @generated
+	 */
+	public static String NavigatorGroupName_HistoryState_2033_outgoinglinks;
+
+	/**
+	 * @generated
+	 */
+	public static String NavigatorGroupName_Parallel_2035_incominglinks;
+
+	/**
+	 * @generated
+	 */
+	public static String NavigatorGroupName_Parallel_2035_outgoinglinks;
+
+	/**
+	 * @generated
+	 */
+	public static String NavigatorGroupName_State_2038_incominglinks;
+
+	/**
+	 * @generated
+	 */
+	public static String NavigatorGroupName_State_2038_outgoinglinks;
+
+	/**
+	 * @generated
+	 */
+	public static String NavigatorGroupName_FinalState_2040_incominglinks;
+
+	/**
+	 * @generated
+	 */
+	public static String NavigatorGroupName_FinalState_2040_outgoinglinks;
+
+	/**
+	 * @generated
+	 */
+	public static String NavigatorGroupName_State_2046_incominglinks;
+
+	/**
+	 * @generated
+	 */
+	public static String NavigatorGroupName_State_2046_outgoinglinks;
+
+	/**
+	 * @generated
+	 */
+	public static String NavigatorGroupName_Translation_3001_target;
+
+	/**
+	 * @generated
+	 */
+	public static String NavigatorGroupName_Translation_3001_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 ScxmlModelingAssistantProviderTitle;
+
+	/**
+	 * @generated
+	 */
+	public static String ScxmlModelingAssistantProviderMessage;
+
+	//TODO: put accessor fields manually	
+}

Propchange: commons/sandbox/gsoc/2010/scxml-eclipse/trunk/src/main/java/org.apache.commons.scxml.diagram/src/org/apache/commons/scxml/diagram/part/Messages.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: commons/sandbox/gsoc/2010/scxml-eclipse/trunk/src/main/java/org.apache.commons.scxml.diagram/src/org/apache/commons/scxml/diagram/part/ModelElementSelectionPage.java
URL: http://svn.apache.org/viewvc/commons/sandbox/gsoc/2010/scxml-eclipse/trunk/src/main/java/org.apache.commons.scxml.diagram/src/org/apache/commons/scxml/diagram/part/ModelElementSelectionPage.java?rev=945185&view=auto
==============================================================================
--- commons/sandbox/gsoc/2010/scxml-eclipse/trunk/src/main/java/org.apache.commons.scxml.diagram/src/org/apache/commons/scxml/diagram/part/ModelElementSelectionPage.java (added)
+++ commons/sandbox/gsoc/2010/scxml-eclipse/trunk/src/main/java/org.apache.commons.scxml.diagram/src/org/apache/commons/scxml/diagram/part/ModelElementSelectionPage.java Mon May 17 14:38:45 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.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(
+				ScxmlDiagramEditorPlugin.getInstance()
+						.getItemProvidersAdapterFactory()));
+		modelViewer.setLabelProvider(new AdapterFactoryLabelProvider(
+				ScxmlDiagramEditorPlugin.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.diagram/src/org/apache/commons/scxml/diagram/part/ModelElementSelectionPage.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: commons/sandbox/gsoc/2010/scxml-eclipse/trunk/src/main/java/org.apache.commons.scxml.diagram/src/org/apache/commons/scxml/diagram/part/ScxmlCreationWizard.java
URL: http://svn.apache.org/viewvc/commons/sandbox/gsoc/2010/scxml-eclipse/trunk/src/main/java/org.apache.commons.scxml.diagram/src/org/apache/commons/scxml/diagram/part/ScxmlCreationWizard.java?rev=945185&view=auto
==============================================================================
--- commons/sandbox/gsoc/2010/scxml-eclipse/trunk/src/main/java/org.apache.commons.scxml.diagram/src/org/apache/commons/scxml/diagram/part/ScxmlCreationWizard.java (added)
+++ commons/sandbox/gsoc/2010/scxml-eclipse/trunk/src/main/java/org.apache.commons.scxml.diagram/src/org/apache/commons/scxml/diagram/part/ScxmlCreationWizard.java Mon May 17 14:38:45 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.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 ScxmlCreationWizard extends Wizard implements INewWizard {
+
+	/**
+	 * @generated
+	 */
+	private IWorkbench workbench;
+
+	/**
+	 * @generated
+	 */
+	protected IStructuredSelection selection;
+
+	/**
+	 * @generated
+	 */
+	protected ScxmlCreationWizardPage diagramModelFilePage;
+
+	/**
+	 * @generated
+	 */
+	protected ScxmlCreationWizardPage 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.ScxmlCreationWizardTitle);
+		setDefaultPageImageDescriptor(ScxmlDiagramEditorPlugin
+				.getBundledImageDescriptor("icons/wizban/NewScxmlWizard.gif")); //$NON-NLS-1$
+		setNeedsProgressMonitor(true);
+	}
+
+	/**
+	 * @generated
+	 */
+	public void addPages() {
+		diagramModelFilePage = new ScxmlCreationWizardPage(
+				"DiagramModelFile", getSelection(), "scxml_diagram"); //$NON-NLS-1$ //$NON-NLS-2$
+		diagramModelFilePage
+				.setTitle(Messages.ScxmlCreationWizard_DiagramModelFilePageTitle);
+		diagramModelFilePage
+				.setDescription(Messages.ScxmlCreationWizard_DiagramModelFilePageDescription);
+		addPage(diagramModelFilePage);
+
+		domainModelFilePage = new ScxmlCreationWizardPage(
+				"DomainModelFile", getSelection(), "scxml") { //$NON-NLS-1$ //$NON-NLS-2$
+
+			public void setVisible(boolean visible) {
+				if (visible) {
+					String fileName = diagramModelFilePage.getFileName();
+					fileName = fileName.substring(0, fileName.length()
+							- ".scxml_diagram".length()); //$NON-NLS-1$
+					setFileName(ScxmlDiagramEditorUtil.getUniqueFileName(
+							getContainerFullPath(), fileName, "scxml")); //$NON-NLS-1$
+				}
+				super.setVisible(visible);
+			}
+		};
+		domainModelFilePage
+				.setTitle(Messages.ScxmlCreationWizard_DomainModelFilePageTitle);
+		domainModelFilePage
+				.setDescription(Messages.ScxmlCreationWizard_DomainModelFilePageDescription);
+		addPage(domainModelFilePage);
+	}
+
+	/**
+	 * @generated
+	 */
+	public boolean performFinish() {
+		IRunnableWithProgress op = new WorkspaceModifyOperation(null) {
+
+			protected void execute(IProgressMonitor monitor)
+					throws CoreException, InterruptedException {
+				diagram = ScxmlDiagramEditorUtil.createDiagram(
+						diagramModelFilePage.getURI(), domainModelFilePage
+								.getURI(), monitor);
+				if (isOpenNewlyCreatedDiagramEditor() && diagram != null) {
+					try {
+						ScxmlDiagramEditorUtil.openDiagram(diagram);
+					} catch (PartInitException e) {
+						ErrorDialog.openError(getContainer().getShell(),
+								Messages.ScxmlCreationWizardOpenEditorError,
+								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.ScxmlCreationWizardCreationError, null,
+						((CoreException) e.getTargetException()).getStatus());
+			} else {
+				ScxmlDiagramEditorPlugin.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.diagram/src/org/apache/commons/scxml/diagram/part/ScxmlCreationWizard.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: commons/sandbox/gsoc/2010/scxml-eclipse/trunk/src/main/java/org.apache.commons.scxml.diagram/src/org/apache/commons/scxml/diagram/part/ScxmlCreationWizardPage.java
URL: http://svn.apache.org/viewvc/commons/sandbox/gsoc/2010/scxml-eclipse/trunk/src/main/java/org.apache.commons.scxml.diagram/src/org/apache/commons/scxml/diagram/part/ScxmlCreationWizardPage.java?rev=945185&view=auto
==============================================================================
--- commons/sandbox/gsoc/2010/scxml-eclipse/trunk/src/main/java/org.apache.commons.scxml.diagram/src/org/apache/commons/scxml/diagram/part/ScxmlCreationWizardPage.java (added)
+++ commons/sandbox/gsoc/2010/scxml-eclipse/trunk/src/main/java/org.apache.commons.scxml.diagram/src/org/apache/commons/scxml/diagram/part/ScxmlCreationWizardPage.java Mon May 17 14:38:45 2010
@@ -0,0 +1,103 @@
+/*
+ * 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.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 ScxmlCreationWizardPage extends WizardNewFileCreationPage {
+
+	/**
+	 * @generated
+	 */
+	private final String fileExtension;
+
+	/**
+	 * @generated
+	 */
+	public ScxmlCreationWizardPage(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(ScxmlDiagramEditorUtil.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.ScxmlCreationWizardPageExtensionError, extension));
+			return false;
+		}
+		return true;
+	}
+}

Propchange: commons/sandbox/gsoc/2010/scxml-eclipse/trunk/src/main/java/org.apache.commons.scxml.diagram/src/org/apache/commons/scxml/diagram/part/ScxmlCreationWizardPage.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: commons/sandbox/gsoc/2010/scxml-eclipse/trunk/src/main/java/org.apache.commons.scxml.diagram/src/org/apache/commons/scxml/diagram/part/ScxmlDiagramActionBarContributor.java
URL: http://svn.apache.org/viewvc/commons/sandbox/gsoc/2010/scxml-eclipse/trunk/src/main/java/org.apache.commons.scxml.diagram/src/org/apache/commons/scxml/diagram/part/ScxmlDiagramActionBarContributor.java?rev=945185&view=auto
==============================================================================
--- commons/sandbox/gsoc/2010/scxml-eclipse/trunk/src/main/java/org.apache.commons.scxml.diagram/src/org/apache/commons/scxml/diagram/part/ScxmlDiagramActionBarContributor.java (added)
+++ commons/sandbox/gsoc/2010/scxml-eclipse/trunk/src/main/java/org.apache.commons.scxml.diagram/src/org/apache/commons/scxml/diagram/part/ScxmlDiagramActionBarContributor.java Mon May 17 14:38:45 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.diagram.part;
+
+import org.eclipse.gmf.runtime.diagram.ui.parts.DiagramActionBarContributor;
+
+/**
+ * @generated
+ */
+public class ScxmlDiagramActionBarContributor extends
+		DiagramActionBarContributor {
+
+	/**
+	 * @generated
+	 */
+	protected Class getEditorClass() {
+		return ScxmlDiagramEditor.class;
+	}
+
+	/**
+	 * @generated
+	 */
+	protected String getEditorId() {
+		return ScxmlDiagramEditor.ID;
+	}
+}

Propchange: commons/sandbox/gsoc/2010/scxml-eclipse/trunk/src/main/java/org.apache.commons.scxml.diagram/src/org/apache/commons/scxml/diagram/part/ScxmlDiagramActionBarContributor.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: commons/sandbox/gsoc/2010/scxml-eclipse/trunk/src/main/java/org.apache.commons.scxml.diagram/src/org/apache/commons/scxml/diagram/part/ScxmlDiagramEditor.java
URL: http://svn.apache.org/viewvc/commons/sandbox/gsoc/2010/scxml-eclipse/trunk/src/main/java/org.apache.commons.scxml.diagram/src/org/apache/commons/scxml/diagram/part/ScxmlDiagramEditor.java?rev=945185&view=auto
==============================================================================
--- commons/sandbox/gsoc/2010/scxml-eclipse/trunk/src/main/java/org.apache.commons.scxml.diagram/src/org/apache/commons/scxml/diagram/part/ScxmlDiagramEditor.java (added)
+++ commons/sandbox/gsoc/2010/scxml-eclipse/trunk/src/main/java/org.apache.commons.scxml.diagram/src/org/apache/commons/scxml/diagram/part/ScxmlDiagramEditor.java Mon May 17 14:38:45 2010
@@ -0,0 +1,304 @@
+/*
+ * 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.diagram.part;
+
+import org.apache.commons.scxml.diagram.navigator.ScxmlNavigatorItem;
+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 ScxmlDiagramEditor extends DiagramDocumentEditor implements
+		IGotoMarker {
+
+	/**
+	 * @generated
+	 */
+	public static final String ID = "org.apache.commons.scxml.diagram.part.ScxmlDiagramEditorID"; //$NON-NLS-1$
+
+	/**
+	 * @generated
+	 */
+	public static final String CONTEXT_ID = "org.apache.commons.scxml.diagram.ui.diagramContext"; //$NON-NLS-1$
+
+	/**
+	 * @generated
+	 */
+	public ScxmlDiagramEditor() {
+		super(true);
+	}
+
+	/**
+	 * @generated
+	 */
+	protected String getContextID() {
+		return CONTEXT_ID;
+	}
+
+	/**
+	 * @generated
+	 */
+	protected PaletteRoot createPaletteRoot(PaletteRoot existingPaletteRoot) {
+		PaletteRoot root = super.createPaletteRoot(existingPaletteRoot);
+		new ScxmlPaletteFactory().fillPalette(root);
+		return root;
+	}
+
+	/**
+	 * @generated
+	 */
+	protected PreferencesHint getPreferencesHint() {
+		return ScxmlDiagramEditorPlugin.DIAGRAM_PREFERENCES_HINT;
+	}
+
+	/**
+	 * @generated
+	 */
+	public String getContributorId() {
+		return ScxmlDiagramEditorPlugin.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 ScxmlDiagramEditorPlugin.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(ScxmlDiagramEditorPlugin.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.ScxmlDiagramEditor_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.ScxmlDiagramEditor_SaveAsErrorTitle,
+						Messages.ScxmlDiagramEditor_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.ScxmlDiagramEditor_SaveErrorTitle,
+						Messages.ScxmlDiagramEditor_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) {
+			ScxmlNavigatorItem item = new ScxmlNavigatorItem(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.diagram/src/org/apache/commons/scxml/diagram/part/ScxmlDiagramEditor.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: commons/sandbox/gsoc/2010/scxml-eclipse/trunk/src/main/java/org.apache.commons.scxml.diagram/src/org/apache/commons/scxml/diagram/part/ScxmlDiagramEditorPlugin.java
URL: http://svn.apache.org/viewvc/commons/sandbox/gsoc/2010/scxml-eclipse/trunk/src/main/java/org.apache.commons.scxml.diagram/src/org/apache/commons/scxml/diagram/part/ScxmlDiagramEditorPlugin.java?rev=945185&view=auto
==============================================================================
--- commons/sandbox/gsoc/2010/scxml-eclipse/trunk/src/main/java/org.apache.commons.scxml.diagram/src/org/apache/commons/scxml/diagram/part/ScxmlDiagramEditorPlugin.java (added)
+++ commons/sandbox/gsoc/2010/scxml-eclipse/trunk/src/main/java/org.apache.commons.scxml.diagram/src/org/apache/commons/scxml/diagram/part/ScxmlDiagramEditorPlugin.java Mon May 17 14:38:45 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.diagram.part;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import org.apache.commons.scxml.provider.ScxmlItemProviderAdapterFactory;
+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 ScxmlDiagramEditorPlugin extends AbstractUIPlugin {
+
+	/**
+	 * @generated
+	 */
+	public static final String ID = "org.apache.commons.scxml.diagram"; //$NON-NLS-1$
+
+	/**
+	 * @generated
+	 */
+	public static final PreferencesHint DIAGRAM_PREFERENCES_HINT = new PreferencesHint(
+			ID);
+
+	/**
+	 * @generated
+	 */
+	private static ScxmlDiagramEditorPlugin instance;
+
+	/**
+	 * @generated
+	 */
+	private ComposedAdapterFactory adapterFactory;
+
+	/**
+	 * @generated
+	 */
+	private ScxmlDocumentProvider documentProvider;
+
+	/**
+	 * @generated
+	 */
+	public ScxmlDiagramEditorPlugin() {
+	}
+
+	/**
+	 * @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 ScxmlDiagramEditorPlugin 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 ScxmlItemProviderAdapterFactory());
+		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 ScxmlDocumentProvider getDocumentProvider() {
+		if (documentProvider == null) {
+			documentProvider = new ScxmlDocumentProvider();
+		}
+		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, ScxmlDiagramEditorPlugin.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, ScxmlDiagramEditorPlugin.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.diagram/src/org/apache/commons/scxml/diagram/part/ScxmlDiagramEditorPlugin.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: commons/sandbox/gsoc/2010/scxml-eclipse/trunk/src/main/java/org.apache.commons.scxml.diagram/src/org/apache/commons/scxml/diagram/part/ScxmlDiagramEditorUtil.java
URL: http://svn.apache.org/viewvc/commons/sandbox/gsoc/2010/scxml-eclipse/trunk/src/main/java/org.apache.commons.scxml.diagram/src/org/apache/commons/scxml/diagram/part/ScxmlDiagramEditorUtil.java?rev=945185&view=auto
==============================================================================
--- commons/sandbox/gsoc/2010/scxml-eclipse/trunk/src/main/java/org.apache.commons.scxml.diagram/src/org/apache/commons/scxml/diagram/part/ScxmlDiagramEditorUtil.java (added)
+++ commons/sandbox/gsoc/2010/scxml-eclipse/trunk/src/main/java/org.apache.commons.scxml.diagram/src/org/apache/commons/scxml/diagram/part/ScxmlDiagramEditorUtil.java Mon May 17 14:38:45 2010
@@ -0,0 +1,444 @@
+/*
+ * 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.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.ScxmlFactory;
+import org.apache.commons.scxml.ServiceTemplate;
+import org.apache.commons.scxml.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 ScxmlDiagramEditorUtil {
+
+	/**
+	 * @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), ScxmlDiagramEditor.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) {
+			ScxmlDiagramEditorPlugin.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 = ScxmlDiagramEditorPlugin
+				.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.ScxmlDiagramEditorUtil_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.ScxmlDiagramEditorUtil_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,
+						ScxmlDiagramEditorPlugin.DIAGRAM_PREFERENCES_HINT);
+				if (diagram != null) {
+					diagramResource.getContents().add(diagram);
+					diagram.setName(diagramName);
+					diagram.setElement(model);
+				}
+
+				try {
+					modelResource
+							.save(org.apache.commons.scxml.diagram.part.ScxmlDiagramEditorUtil
+									.getSaveOptions());
+					diagramResource
+							.save(org.apache.commons.scxml.diagram.part.ScxmlDiagramEditorUtil
+									.getSaveOptions());
+				} catch (IOException e) {
+
+					ScxmlDiagramEditorPlugin.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) {
+			ScxmlDiagramEditorPlugin.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.
+	 * <!-- begin-user-doc -->
+	 * <!-- end-user-doc -->
+	 * @generated
+	 */
+	private static ServiceTemplate createInitialModel() {
+		return ScxmlFactory.eINSTANCE.createServiceTemplate();
+	}
+
+	/**
+	 * Store model element in the resource.
+	 * <!-- begin-user-doc -->
+	 * <!-- end-user-doc -->
+	 * @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.diagram/src/org/apache/commons/scxml/diagram/part/ScxmlDiagramEditorUtil.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: commons/sandbox/gsoc/2010/scxml-eclipse/trunk/src/main/java/org.apache.commons.scxml.diagram/src/org/apache/commons/scxml/diagram/part/ScxmlDiagramUpdateCommand.java
URL: http://svn.apache.org/viewvc/commons/sandbox/gsoc/2010/scxml-eclipse/trunk/src/main/java/org.apache.commons.scxml.diagram/src/org/apache/commons/scxml/diagram/part/ScxmlDiagramUpdateCommand.java?rev=945185&view=auto
==============================================================================
--- commons/sandbox/gsoc/2010/scxml-eclipse/trunk/src/main/java/org.apache.commons.scxml.diagram/src/org/apache/commons/scxml/diagram/part/ScxmlDiagramUpdateCommand.java (added)
+++ commons/sandbox/gsoc/2010/scxml-eclipse/trunk/src/main/java/org.apache.commons.scxml.diagram/src/org/apache/commons/scxml/diagram/part/ScxmlDiagramUpdateCommand.java Mon May 17 14:38:45 2010
@@ -0,0 +1,101 @@
+/*
+ * 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.diagram.part;
+
+import java.util.Iterator;
+import java.util.List;
+
+import org.eclipse.core.commands.ExecutionEvent;
+import org.eclipse.core.commands.ExecutionException;
+import org.eclipse.core.commands.IHandler;
+import org.eclipse.core.commands.IHandlerListener;
+import org.eclipse.emf.ecore.EObject;
+import org.eclipse.gef.EditPart;
+import org.eclipse.gmf.runtime.diagram.ui.editpolicies.CanonicalEditPolicy;
+import org.eclipse.gmf.runtime.notation.View;
+import org.eclipse.jface.viewers.ISelection;
+import org.eclipse.jface.viewers.IStructuredSelection;
+import org.eclipse.ui.PlatformUI;
+
+/**
+ * @generated
+ */
+public class ScxmlDiagramUpdateCommand implements IHandler {
+
+	/**
+	 * @generated
+	 */
+	public void addHandlerListener(IHandlerListener handlerListener) {
+	}
+
+	/**
+	 * @generated
+	 */
+	public void dispose() {
+	}
+
+	/**
+	 * @generated
+	 */
+	public Object execute(ExecutionEvent event) throws ExecutionException {
+		ISelection selection = PlatformUI.getWorkbench()
+				.getActiveWorkbenchWindow().getSelectionService()
+				.getSelection();
+		if (selection instanceof IStructuredSelection) {
+			IStructuredSelection structuredSelection = (IStructuredSelection) selection;
+			if (structuredSelection.size() != 1) {
+				return null;
+			}
+			if (structuredSelection.getFirstElement() instanceof EditPart
+					&& ((EditPart) structuredSelection.getFirstElement())
+							.getModel() instanceof View) {
+				EObject modelElement = ((View) ((EditPart) structuredSelection
+						.getFirstElement()).getModel()).getElement();
+				List editPolicies = CanonicalEditPolicy
+						.getRegisteredEditPolicies(modelElement);
+				for (Iterator it = editPolicies.iterator(); it.hasNext();) {
+					CanonicalEditPolicy nextEditPolicy = (CanonicalEditPolicy) it
+							.next();
+					nextEditPolicy.refresh();
+				}
+
+			}
+		}
+		return null;
+	}
+
+	/**
+	 * @generated
+	 */
+	public boolean isEnabled() {
+		return true;
+	}
+
+	/**
+	 * @generated
+	 */
+	public boolean isHandled() {
+		return true;
+	}
+
+	/**
+	 * @generated
+	 */
+	public void removeHandlerListener(IHandlerListener handlerListener) {
+	}
+
+}

Propchange: commons/sandbox/gsoc/2010/scxml-eclipse/trunk/src/main/java/org.apache.commons.scxml.diagram/src/org/apache/commons/scxml/diagram/part/ScxmlDiagramUpdateCommand.java
------------------------------------------------------------------------------
    svn:eol-style = native



Mime
View raw message