carbidecpp22devenv/plugins/org.eclipse.gmf.templates.legacy_1.0.0.v20090614-0839/codegen.templates/xpt/providers/ModelingAssistantProvider.xpt
author cawthron
Fri, 04 Dec 2009 11:06:59 -0600
changeset 422 033392511bf7
permissions -rw-r--r--
add files for RCL_2_2
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
422
033392511bf7 add files for RCL_2_2
cawthron
parents:
diff changeset
     1
/*
033392511bf7 add files for RCL_2_2
cawthron
parents:
diff changeset
     2
 * Copyright (c) 2007 Borland Software Corporation
033392511bf7 add files for RCL_2_2
cawthron
parents:
diff changeset
     3
 * 
033392511bf7 add files for RCL_2_2
cawthron
parents:
diff changeset
     4
 * All rights reserved. This program and the accompanying materials
033392511bf7 add files for RCL_2_2
cawthron
parents:
diff changeset
     5
 * are made available under the terms of the Eclipse Public License v1.0
033392511bf7 add files for RCL_2_2
cawthron
parents:
diff changeset
     6
 * which accompanies this distribution, and is available at
033392511bf7 add files for RCL_2_2
cawthron
parents:
diff changeset
     7
 * http://www.eclipse.org/legal/epl-v10.html
033392511bf7 add files for RCL_2_2
cawthron
parents:
diff changeset
     8
 *
033392511bf7 add files for RCL_2_2
cawthron
parents:
diff changeset
     9
 * Contributors:
033392511bf7 add files for RCL_2_2
cawthron
parents:
diff changeset
    10
 *    Dmitry Stadnik (Borland) - initial API and implementation
033392511bf7 add files for RCL_2_2
cawthron
parents:
diff changeset
    11
 */
033392511bf7 add files for RCL_2_2
cawthron
parents:
diff changeset
    12
033392511bf7 add files for RCL_2_2
cawthron
parents:
diff changeset
    13
«IMPORT "http://www.eclipse.org/gmf/2008/GenModel"»
033392511bf7 add files for RCL_2_2
cawthron
parents:
diff changeset
    14
033392511bf7 add files for RCL_2_2
cawthron
parents:
diff changeset
    15
«EXTENSION xpt::diagram::Utils»
033392511bf7 add files for RCL_2_2
cawthron
parents:
diff changeset
    16
«EXTENSION xpt::providers::i18n»
033392511bf7 add files for RCL_2_2
cawthron
parents:
diff changeset
    17
033392511bf7 add files for RCL_2_2
cawthron
parents:
diff changeset
    18
«DEFINE ModelingAssistantProvider FOR gmfgen::GenDiagram-»
033392511bf7 add files for RCL_2_2
cawthron
parents:
diff changeset
    19
«EXPAND xpt::Common::copyright FOR editorGen-»
033392511bf7 add files for RCL_2_2
cawthron
parents:
diff changeset
    20
package «providersPackageName»;
033392511bf7 add files for RCL_2_2
cawthron
parents:
diff changeset
    21
033392511bf7 add files for RCL_2_2
cawthron
parents:
diff changeset
    22
«EXPAND xpt::Common::generatedClassComment»
033392511bf7 add files for RCL_2_2
cawthron
parents:
diff changeset
    23
public class «modelingAssistantProviderClassName»
033392511bf7 add files for RCL_2_2
cawthron
parents:
diff changeset
    24
		extends org.eclipse.gmf.runtime.emf.ui.services.modelingassistant.ModelingAssistantProvider {
033392511bf7 add files for RCL_2_2
cawthron
parents:
diff changeset
    25
033392511bf7 add files for RCL_2_2
cawthron
parents:
diff changeset
    26
	«EXPAND xpt::Common::generatedMemberComment»
033392511bf7 add files for RCL_2_2
cawthron
parents:
diff changeset
    27
	public java.util.List getTypesForPopupBar(org.eclipse.core.runtime.IAdaptable host) {
033392511bf7 add files for RCL_2_2
cawthron
parents:
diff changeset
    28
		org.eclipse.gmf.runtime.diagram.ui.editparts.IGraphicalEditPart editPart =
033392511bf7 add files for RCL_2_2
cawthron
parents:
diff changeset
    29
				(org.eclipse.gmf.runtime.diagram.ui.editparts.IGraphicalEditPart) host.getAdapter(
033392511bf7 add files for RCL_2_2
cawthron
parents:
diff changeset
    30
						org.eclipse.gmf.runtime.diagram.ui.editparts.IGraphicalEditPart.class);
033392511bf7 add files for RCL_2_2
cawthron
parents:
diff changeset
    31
		«FOREACH getAllContainers() AS container-»
033392511bf7 add files for RCL_2_2
cawthron
parents:
diff changeset
    32
			«IF container.getAssistantNodes().size() > 0-»
033392511bf7 add files for RCL_2_2
cawthron
parents:
diff changeset
    33
		if (editPart instanceof «container.getEditPartQualifiedClassName()») {
033392511bf7 add files for RCL_2_2
cawthron
parents:
diff changeset
    34
			java.util.List types = new java.util.ArrayList();
033392511bf7 add files for RCL_2_2
cawthron
parents:
diff changeset
    35
				«FOREACH container.getAssistantNodes() AS node-»
033392511bf7 add files for RCL_2_2
cawthron
parents:
diff changeset
    36
			types.add(«getElementTypesQualifiedClassName()».«node.getUniqueIdentifier()»);
033392511bf7 add files for RCL_2_2
cawthron
parents:
diff changeset
    37
				«ENDFOREACH-»
033392511bf7 add files for RCL_2_2
cawthron
parents:
diff changeset
    38
			return types;
033392511bf7 add files for RCL_2_2
cawthron
parents:
diff changeset
    39
		}
033392511bf7 add files for RCL_2_2
cawthron
parents:
diff changeset
    40
			«ENDIF-»
033392511bf7 add files for RCL_2_2
cawthron
parents:
diff changeset
    41
		«ENDFOREACH-»
033392511bf7 add files for RCL_2_2
cawthron
parents:
diff changeset
    42
		return java.util.Collections.EMPTY_LIST;
033392511bf7 add files for RCL_2_2
cawthron
parents:
diff changeset
    43
	}
033392511bf7 add files for RCL_2_2
cawthron
parents:
diff changeset
    44
033392511bf7 add files for RCL_2_2
cawthron
parents:
diff changeset
    45
	«EXPAND xpt::Common::generatedMemberComment»
033392511bf7 add files for RCL_2_2
cawthron
parents:
diff changeset
    46
	public java.util.List getRelTypesOnSource(org.eclipse.core.runtime.IAdaptable source) {
033392511bf7 add files for RCL_2_2
cawthron
parents:
diff changeset
    47
		org.eclipse.gmf.runtime.diagram.ui.editparts.IGraphicalEditPart sourceEditPart =
033392511bf7 add files for RCL_2_2
cawthron
parents:
diff changeset
    48
				(org.eclipse.gmf.runtime.diagram.ui.editparts.IGraphicalEditPart) source.getAdapter(
033392511bf7 add files for RCL_2_2
cawthron
parents:
diff changeset
    49
						org.eclipse.gmf.runtime.diagram.ui.editparts.IGraphicalEditPart.class);
033392511bf7 add files for RCL_2_2
cawthron
parents:
diff changeset
    50
		«FOREACH getNodes() AS source-»
033392511bf7 add files for RCL_2_2
cawthron
parents:
diff changeset
    51
			«IF getOutgoingLinks(source).size() > 0-»
033392511bf7 add files for RCL_2_2
cawthron
parents:
diff changeset
    52
		if (sourceEditPart instanceof «source.getEditPartQualifiedClassName()») {
033392511bf7 add files for RCL_2_2
cawthron
parents:
diff changeset
    53
			java.util.List types = new java.util.ArrayList();
033392511bf7 add files for RCL_2_2
cawthron
parents:
diff changeset
    54
				«FOREACH getOutgoingLinks(source) AS link-»
033392511bf7 add files for RCL_2_2
cawthron
parents:
diff changeset
    55
			types.add(«getElementTypesQualifiedClassName()».«link.getUniqueIdentifier()»);
033392511bf7 add files for RCL_2_2
cawthron
parents:
diff changeset
    56
				«ENDFOREACH-»
033392511bf7 add files for RCL_2_2
cawthron
parents:
diff changeset
    57
			return types;
033392511bf7 add files for RCL_2_2
cawthron
parents:
diff changeset
    58
		}
033392511bf7 add files for RCL_2_2
cawthron
parents:
diff changeset
    59
			«ENDIF-»
033392511bf7 add files for RCL_2_2
cawthron
parents:
diff changeset
    60
		«ENDFOREACH-»
033392511bf7 add files for RCL_2_2
cawthron
parents:
diff changeset
    61
		return java.util.Collections.EMPTY_LIST;
033392511bf7 add files for RCL_2_2
cawthron
parents:
diff changeset
    62
	}
033392511bf7 add files for RCL_2_2
cawthron
parents:
diff changeset
    63
033392511bf7 add files for RCL_2_2
cawthron
parents:
diff changeset
    64
	«EXPAND xpt::Common::generatedMemberComment»
033392511bf7 add files for RCL_2_2
cawthron
parents:
diff changeset
    65
	public java.util.List getRelTypesOnTarget(org.eclipse.core.runtime.IAdaptable target) {
033392511bf7 add files for RCL_2_2
cawthron
parents:
diff changeset
    66
		org.eclipse.gmf.runtime.diagram.ui.editparts.IGraphicalEditPart targetEditPart =
033392511bf7 add files for RCL_2_2
cawthron
parents:
diff changeset
    67
				(org.eclipse.gmf.runtime.diagram.ui.editparts.IGraphicalEditPart) target.getAdapter(
033392511bf7 add files for RCL_2_2
cawthron
parents:
diff changeset
    68
						org.eclipse.gmf.runtime.diagram.ui.editparts.IGraphicalEditPart.class);
033392511bf7 add files for RCL_2_2
cawthron
parents:
diff changeset
    69
		«FOREACH getNodes() AS target-»
033392511bf7 add files for RCL_2_2
cawthron
parents:
diff changeset
    70
			«IF getIncomingLinks(target).size() > 0-»
033392511bf7 add files for RCL_2_2
cawthron
parents:
diff changeset
    71
		if (targetEditPart instanceof «target.getEditPartQualifiedClassName()») {
033392511bf7 add files for RCL_2_2
cawthron
parents:
diff changeset
    72
			java.util.List types = new java.util.ArrayList();
033392511bf7 add files for RCL_2_2
cawthron
parents:
diff changeset
    73
				«FOREACH getIncomingLinks(target) AS link-»
033392511bf7 add files for RCL_2_2
cawthron
parents:
diff changeset
    74
			types.add(«getElementTypesQualifiedClassName()».«link.getUniqueIdentifier()»);
033392511bf7 add files for RCL_2_2
cawthron
parents:
diff changeset
    75
				«ENDFOREACH-»
033392511bf7 add files for RCL_2_2
cawthron
parents:
diff changeset
    76
			return types;
033392511bf7 add files for RCL_2_2
cawthron
parents:
diff changeset
    77
		}
033392511bf7 add files for RCL_2_2
cawthron
parents:
diff changeset
    78
			«ENDIF-»
033392511bf7 add files for RCL_2_2
cawthron
parents:
diff changeset
    79
		«ENDFOREACH-»
033392511bf7 add files for RCL_2_2
cawthron
parents:
diff changeset
    80
		return java.util.Collections.EMPTY_LIST;
033392511bf7 add files for RCL_2_2
cawthron
parents:
diff changeset
    81
	}
033392511bf7 add files for RCL_2_2
cawthron
parents:
diff changeset
    82
033392511bf7 add files for RCL_2_2
cawthron
parents:
diff changeset
    83
	«EXPAND xpt::Common::generatedMemberComment»
033392511bf7 add files for RCL_2_2
cawthron
parents:
diff changeset
    84
	public java.util.List getRelTypesOnSourceAndTarget(
033392511bf7 add files for RCL_2_2
cawthron
parents:
diff changeset
    85
			org.eclipse.core.runtime.IAdaptable source, org.eclipse.core.runtime.IAdaptable target) {
033392511bf7 add files for RCL_2_2
cawthron
parents:
diff changeset
    86
		org.eclipse.gmf.runtime.diagram.ui.editparts.IGraphicalEditPart sourceEditPart =
033392511bf7 add files for RCL_2_2
cawthron
parents:
diff changeset
    87
				(org.eclipse.gmf.runtime.diagram.ui.editparts.IGraphicalEditPart) source.getAdapter(
033392511bf7 add files for RCL_2_2
cawthron
parents:
diff changeset
    88
						org.eclipse.gmf.runtime.diagram.ui.editparts.IGraphicalEditPart.class);
033392511bf7 add files for RCL_2_2
cawthron
parents:
diff changeset
    89
		org.eclipse.gmf.runtime.diagram.ui.editparts.IGraphicalEditPart targetEditPart =
033392511bf7 add files for RCL_2_2
cawthron
parents:
diff changeset
    90
				(org.eclipse.gmf.runtime.diagram.ui.editparts.IGraphicalEditPart) target.getAdapter(
033392511bf7 add files for RCL_2_2
cawthron
parents:
diff changeset
    91
						org.eclipse.gmf.runtime.diagram.ui.editparts.IGraphicalEditPart.class);
033392511bf7 add files for RCL_2_2
cawthron
parents:
diff changeset
    92
		«FOREACH getNodes() AS source-»
033392511bf7 add files for RCL_2_2
cawthron
parents:
diff changeset
    93
			«IF getOutgoingLinks(source).size() > 0-»
033392511bf7 add files for RCL_2_2
cawthron
parents:
diff changeset
    94
		if (sourceEditPart instanceof «source.getEditPartQualifiedClassName()») {
033392511bf7 add files for RCL_2_2
cawthron
parents:
diff changeset
    95
			java.util.List types = new java.util.ArrayList();
033392511bf7 add files for RCL_2_2
cawthron
parents:
diff changeset
    96
				«FOREACH getOutgoingLinks(source) AS link-»
033392511bf7 add files for RCL_2_2
cawthron
parents:
diff changeset
    97
					«FOREACH link.getAssistantTargets() AS target-»
033392511bf7 add files for RCL_2_2
cawthron
parents:
diff changeset
    98
			if (targetEditPart instanceof «target.getEditPartQualifiedClassName()») {
033392511bf7 add files for RCL_2_2
cawthron
parents:
diff changeset
    99
				types.add(«getElementTypesQualifiedClassName()».«link.getUniqueIdentifier()»);
033392511bf7 add files for RCL_2_2
cawthron
parents:
diff changeset
   100
			}
033392511bf7 add files for RCL_2_2
cawthron
parents:
diff changeset
   101
					«ENDFOREACH-»
033392511bf7 add files for RCL_2_2
cawthron
parents:
diff changeset
   102
				«ENDFOREACH-»
033392511bf7 add files for RCL_2_2
cawthron
parents:
diff changeset
   103
			return types;
033392511bf7 add files for RCL_2_2
cawthron
parents:
diff changeset
   104
		}
033392511bf7 add files for RCL_2_2
cawthron
parents:
diff changeset
   105
			«ENDIF-»
033392511bf7 add files for RCL_2_2
cawthron
parents:
diff changeset
   106
		«ENDFOREACH-»
033392511bf7 add files for RCL_2_2
cawthron
parents:
diff changeset
   107
		return java.util.Collections.EMPTY_LIST;
033392511bf7 add files for RCL_2_2
cawthron
parents:
diff changeset
   108
	}
033392511bf7 add files for RCL_2_2
cawthron
parents:
diff changeset
   109
033392511bf7 add files for RCL_2_2
cawthron
parents:
diff changeset
   110
	«EXPAND xpt::Common::generatedMemberComment»
033392511bf7 add files for RCL_2_2
cawthron
parents:
diff changeset
   111
	public java.util.List getTypesForSource(org.eclipse.core.runtime.IAdaptable target,
033392511bf7 add files for RCL_2_2
cawthron
parents:
diff changeset
   112
			org.eclipse.gmf.runtime.emf.type.core.IElementType relationshipType) {
033392511bf7 add files for RCL_2_2
cawthron
parents:
diff changeset
   113
		org.eclipse.gmf.runtime.diagram.ui.editparts.IGraphicalEditPart targetEditPart =
033392511bf7 add files for RCL_2_2
cawthron
parents:
diff changeset
   114
				(org.eclipse.gmf.runtime.diagram.ui.editparts.IGraphicalEditPart) target.getAdapter(
033392511bf7 add files for RCL_2_2
cawthron
parents:
diff changeset
   115
						org.eclipse.gmf.runtime.diagram.ui.editparts.IGraphicalEditPart.class);
033392511bf7 add files for RCL_2_2
cawthron
parents:
diff changeset
   116
		«FOREACH getNodes() AS target-»
033392511bf7 add files for RCL_2_2
cawthron
parents:
diff changeset
   117
			«IF getIncomingLinks(target).size() > 0-»
033392511bf7 add files for RCL_2_2
cawthron
parents:
diff changeset
   118
		if (targetEditPart instanceof «target.getEditPartQualifiedClassName()») {
033392511bf7 add files for RCL_2_2
cawthron
parents:
diff changeset
   119
			java.util.List types = new java.util.ArrayList();
033392511bf7 add files for RCL_2_2
cawthron
parents:
diff changeset
   120
				«FOREACH getIncomingLinks(target) AS link-»
033392511bf7 add files for RCL_2_2
cawthron
parents:
diff changeset
   121
					«FOREACH link.getAssistantSources() AS source-»
033392511bf7 add files for RCL_2_2
cawthron
parents:
diff changeset
   122
			if (relationshipType == «getElementTypesQualifiedClassName()».«link.getUniqueIdentifier()») {
033392511bf7 add files for RCL_2_2
cawthron
parents:
diff changeset
   123
				types.add(«getElementTypesQualifiedClassName()».«source.getUniqueIdentifier()»);
033392511bf7 add files for RCL_2_2
cawthron
parents:
diff changeset
   124
			}
033392511bf7 add files for RCL_2_2
cawthron
parents:
diff changeset
   125
					«ENDFOREACH-»
033392511bf7 add files for RCL_2_2
cawthron
parents:
diff changeset
   126
				«ENDFOREACH-»
033392511bf7 add files for RCL_2_2
cawthron
parents:
diff changeset
   127
			return types;
033392511bf7 add files for RCL_2_2
cawthron
parents:
diff changeset
   128
		}
033392511bf7 add files for RCL_2_2
cawthron
parents:
diff changeset
   129
			«ENDIF-»
033392511bf7 add files for RCL_2_2
cawthron
parents:
diff changeset
   130
		«ENDFOREACH-»
033392511bf7 add files for RCL_2_2
cawthron
parents:
diff changeset
   131
		return java.util.Collections.EMPTY_LIST;
033392511bf7 add files for RCL_2_2
cawthron
parents:
diff changeset
   132
	}
033392511bf7 add files for RCL_2_2
cawthron
parents:
diff changeset
   133
033392511bf7 add files for RCL_2_2
cawthron
parents:
diff changeset
   134
	«EXPAND xpt::Common::generatedMemberComment»
033392511bf7 add files for RCL_2_2
cawthron
parents:
diff changeset
   135
	public java.util.List getTypesForTarget(org.eclipse.core.runtime.IAdaptable source,
033392511bf7 add files for RCL_2_2
cawthron
parents:
diff changeset
   136
			org.eclipse.gmf.runtime.emf.type.core.IElementType relationshipType) {
033392511bf7 add files for RCL_2_2
cawthron
parents:
diff changeset
   137
		org.eclipse.gmf.runtime.diagram.ui.editparts.IGraphicalEditPart sourceEditPart =
033392511bf7 add files for RCL_2_2
cawthron
parents:
diff changeset
   138
				(org.eclipse.gmf.runtime.diagram.ui.editparts.IGraphicalEditPart) source.getAdapter(
033392511bf7 add files for RCL_2_2
cawthron
parents:
diff changeset
   139
						org.eclipse.gmf.runtime.diagram.ui.editparts.IGraphicalEditPart.class);
033392511bf7 add files for RCL_2_2
cawthron
parents:
diff changeset
   140
		«FOREACH getNodes() AS source-»
033392511bf7 add files for RCL_2_2
cawthron
parents:
diff changeset
   141
			«IF getOutgoingLinks(source).size() > 0-»
033392511bf7 add files for RCL_2_2
cawthron
parents:
diff changeset
   142
		if (sourceEditPart instanceof «source.getEditPartQualifiedClassName()») {
033392511bf7 add files for RCL_2_2
cawthron
parents:
diff changeset
   143
			java.util.List types = new java.util.ArrayList();
033392511bf7 add files for RCL_2_2
cawthron
parents:
diff changeset
   144
				«FOREACH getOutgoingLinks(source) AS link-»
033392511bf7 add files for RCL_2_2
cawthron
parents:
diff changeset
   145
					«FOREACH link.getAssistantTargets() AS target-»
033392511bf7 add files for RCL_2_2
cawthron
parents:
diff changeset
   146
			if (relationshipType == «getElementTypesQualifiedClassName()».«link.getUniqueIdentifier()») {
033392511bf7 add files for RCL_2_2
cawthron
parents:
diff changeset
   147
				types.add(«getElementTypesQualifiedClassName()».«target.getUniqueIdentifier()»);
033392511bf7 add files for RCL_2_2
cawthron
parents:
diff changeset
   148
			}
033392511bf7 add files for RCL_2_2
cawthron
parents:
diff changeset
   149
					«ENDFOREACH-»
033392511bf7 add files for RCL_2_2
cawthron
parents:
diff changeset
   150
				«ENDFOREACH-»
033392511bf7 add files for RCL_2_2
cawthron
parents:
diff changeset
   151
			return types;
033392511bf7 add files for RCL_2_2
cawthron
parents:
diff changeset
   152
		}
033392511bf7 add files for RCL_2_2
cawthron
parents:
diff changeset
   153
			«ENDIF-»
033392511bf7 add files for RCL_2_2
cawthron
parents:
diff changeset
   154
		«ENDFOREACH-»
033392511bf7 add files for RCL_2_2
cawthron
parents:
diff changeset
   155
		return java.util.Collections.EMPTY_LIST;
033392511bf7 add files for RCL_2_2
cawthron
parents:
diff changeset
   156
	}
033392511bf7 add files for RCL_2_2
cawthron
parents:
diff changeset
   157
033392511bf7 add files for RCL_2_2
cawthron
parents:
diff changeset
   158
	«EXPAND xpt::Common::generatedMemberComment»
033392511bf7 add files for RCL_2_2
cawthron
parents:
diff changeset
   159
	public org.eclipse.emf.ecore.EObject selectExistingElementForSource(
033392511bf7 add files for RCL_2_2
cawthron
parents:
diff changeset
   160
			org.eclipse.core.runtime.IAdaptable target,
033392511bf7 add files for RCL_2_2
cawthron
parents:
diff changeset
   161
			org.eclipse.gmf.runtime.emf.type.core.IElementType relationshipType) {
033392511bf7 add files for RCL_2_2
cawthron
parents:
diff changeset
   162
		return selectExistingElement(target, getTypesForSource(target, relationshipType));
033392511bf7 add files for RCL_2_2
cawthron
parents:
diff changeset
   163
	}
033392511bf7 add files for RCL_2_2
cawthron
parents:
diff changeset
   164
033392511bf7 add files for RCL_2_2
cawthron
parents:
diff changeset
   165
	«EXPAND xpt::Common::generatedMemberComment»
033392511bf7 add files for RCL_2_2
cawthron
parents:
diff changeset
   166
	public org.eclipse.emf.ecore.EObject selectExistingElementForTarget(
033392511bf7 add files for RCL_2_2
cawthron
parents:
diff changeset
   167
			org.eclipse.core.runtime.IAdaptable source,
033392511bf7 add files for RCL_2_2
cawthron
parents:
diff changeset
   168
			org.eclipse.gmf.runtime.emf.type.core.IElementType relationshipType) {
033392511bf7 add files for RCL_2_2
cawthron
parents:
diff changeset
   169
		return selectExistingElement(source, getTypesForTarget(source, relationshipType));
033392511bf7 add files for RCL_2_2
cawthron
parents:
diff changeset
   170
	}
033392511bf7 add files for RCL_2_2
cawthron
parents:
diff changeset
   171
033392511bf7 add files for RCL_2_2
cawthron
parents:
diff changeset
   172
	«EXPAND xpt::Common::generatedMemberComment»
033392511bf7 add files for RCL_2_2
cawthron
parents:
diff changeset
   173
	protected org.eclipse.emf.ecore.EObject selectExistingElement(
033392511bf7 add files for RCL_2_2
cawthron
parents:
diff changeset
   174
			org.eclipse.core.runtime.IAdaptable host, java.util.Collection types) {
033392511bf7 add files for RCL_2_2
cawthron
parents:
diff changeset
   175
		if (types.isEmpty()) {
033392511bf7 add files for RCL_2_2
cawthron
parents:
diff changeset
   176
			return null;
033392511bf7 add files for RCL_2_2
cawthron
parents:
diff changeset
   177
		}
033392511bf7 add files for RCL_2_2
cawthron
parents:
diff changeset
   178
		org.eclipse.gmf.runtime.diagram.ui.editparts.IGraphicalEditPart editPart =
033392511bf7 add files for RCL_2_2
cawthron
parents:
diff changeset
   179
				(org.eclipse.gmf.runtime.diagram.ui.editparts.IGraphicalEditPart) host.getAdapter(
033392511bf7 add files for RCL_2_2
cawthron
parents:
diff changeset
   180
						org.eclipse.gmf.runtime.diagram.ui.editparts.IGraphicalEditPart.class);
033392511bf7 add files for RCL_2_2
cawthron
parents:
diff changeset
   181
		if (editPart == null) {
033392511bf7 add files for RCL_2_2
cawthron
parents:
diff changeset
   182
			return null;
033392511bf7 add files for RCL_2_2
cawthron
parents:
diff changeset
   183
		}
033392511bf7 add files for RCL_2_2
cawthron
parents:
diff changeset
   184
		org.eclipse.gmf.runtime.notation.Diagram diagram =
033392511bf7 add files for RCL_2_2
cawthron
parents:
diff changeset
   185
				(org.eclipse.gmf.runtime.notation.Diagram) editPart.getRoot().getContents().getModel();
033392511bf7 add files for RCL_2_2
cawthron
parents:
diff changeset
   186
		java.util.Collection elements = new java.util.HashSet();
033392511bf7 add files for RCL_2_2
cawthron
parents:
diff changeset
   187
		for (java.util.Iterator it = diagram.getElement().eAllContents(); it.hasNext();) {
033392511bf7 add files for RCL_2_2
cawthron
parents:
diff changeset
   188
			org.eclipse.emf.ecore.EObject element = (org.eclipse.emf.ecore.EObject) it.next();
033392511bf7 add files for RCL_2_2
cawthron
parents:
diff changeset
   189
			if (isApplicableElement(element, types)) {
033392511bf7 add files for RCL_2_2
cawthron
parents:
diff changeset
   190
				elements.add(element);
033392511bf7 add files for RCL_2_2
cawthron
parents:
diff changeset
   191
			}
033392511bf7 add files for RCL_2_2
cawthron
parents:
diff changeset
   192
		}
033392511bf7 add files for RCL_2_2
cawthron
parents:
diff changeset
   193
		if (elements.isEmpty()) {
033392511bf7 add files for RCL_2_2
cawthron
parents:
diff changeset
   194
			return null;
033392511bf7 add files for RCL_2_2
cawthron
parents:
diff changeset
   195
		}
033392511bf7 add files for RCL_2_2
cawthron
parents:
diff changeset
   196
		return selectElement((org.eclipse.emf.ecore.EObject[]) elements.toArray(
033392511bf7 add files for RCL_2_2
cawthron
parents:
diff changeset
   197
				new org.eclipse.emf.ecore.EObject[elements.size()]));
033392511bf7 add files for RCL_2_2
cawthron
parents:
diff changeset
   198
	}
033392511bf7 add files for RCL_2_2
cawthron
parents:
diff changeset
   199
033392511bf7 add files for RCL_2_2
cawthron
parents:
diff changeset
   200
	«EXPAND xpt::Common::generatedMemberComment»
033392511bf7 add files for RCL_2_2
cawthron
parents:
diff changeset
   201
	protected boolean isApplicableElement(org.eclipse.emf.ecore.EObject element, java.util.Collection types) {
033392511bf7 add files for RCL_2_2
cawthron
parents:
diff changeset
   202
		org.eclipse.gmf.runtime.emf.type.core.IElementType type =
033392511bf7 add files for RCL_2_2
cawthron
parents:
diff changeset
   203
				org.eclipse.gmf.runtime.emf.type.core.ElementTypeRegistry.getInstance().getElementType(element);
033392511bf7 add files for RCL_2_2
cawthron
parents:
diff changeset
   204
		return types.contains(type);
033392511bf7 add files for RCL_2_2
cawthron
parents:
diff changeset
   205
	}
033392511bf7 add files for RCL_2_2
cawthron
parents:
diff changeset
   206
033392511bf7 add files for RCL_2_2
cawthron
parents:
diff changeset
   207
	«EXPAND xpt::Common::generatedMemberComment»
033392511bf7 add files for RCL_2_2
cawthron
parents:
diff changeset
   208
	protected org.eclipse.emf.ecore.EObject selectElement(org.eclipse.emf.ecore.EObject[] elements) {
033392511bf7 add files for RCL_2_2
cawthron
parents:
diff changeset
   209
		org.eclipse.swt.widgets.Shell shell = org.eclipse.swt.widgets.Display.getCurrent().getActiveShell();
033392511bf7 add files for RCL_2_2
cawthron
parents:
diff changeset
   210
		org.eclipse.jface.viewers.ILabelProvider labelProvider =
033392511bf7 add files for RCL_2_2
cawthron
parents:
diff changeset
   211
			new org.eclipse.emf.edit.ui.provider.AdapterFactoryLabelProvider(
033392511bf7 add files for RCL_2_2
cawthron
parents:
diff changeset
   212
				«editorGen.plugin.getActivatorQualifiedClassName()».getInstance().getItemProvidersAdapterFactory());
033392511bf7 add files for RCL_2_2
cawthron
parents:
diff changeset
   213
		org.eclipse.ui.dialogs.ElementListSelectionDialog dialog =
033392511bf7 add files for RCL_2_2
cawthron
parents:
diff changeset
   214
				new org.eclipse.ui.dialogs.ElementListSelectionDialog(shell, labelProvider);
033392511bf7 add files for RCL_2_2
cawthron
parents:
diff changeset
   215
		dialog.setMessage(«EXPAND xpt::Externalizer::accessorCall(i18nKeyForModelingAssistantProvider().messageKey()) FOR editorGen»);
033392511bf7 add files for RCL_2_2
cawthron
parents:
diff changeset
   216
		dialog.setTitle(«EXPAND xpt::Externalizer::accessorCall(i18nKeyForModelingAssistantProvider().titleKey()) FOR editorGen»);
033392511bf7 add files for RCL_2_2
cawthron
parents:
diff changeset
   217
		dialog.setMultipleSelection(false);
033392511bf7 add files for RCL_2_2
cawthron
parents:
diff changeset
   218
		dialog.setElements(elements);
033392511bf7 add files for RCL_2_2
cawthron
parents:
diff changeset
   219
		org.eclipse.emf.ecore.EObject selected = null;
033392511bf7 add files for RCL_2_2
cawthron
parents:
diff changeset
   220
		if (dialog.open() == org.eclipse.jface.window.Window.OK) {
033392511bf7 add files for RCL_2_2
cawthron
parents:
diff changeset
   221
			selected = (org.eclipse.emf.ecore.EObject) dialog.getFirstResult();
033392511bf7 add files for RCL_2_2
cawthron
parents:
diff changeset
   222
		}
033392511bf7 add files for RCL_2_2
cawthron
parents:
diff changeset
   223
		return selected;
033392511bf7 add files for RCL_2_2
cawthron
parents:
diff changeset
   224
	}
033392511bf7 add files for RCL_2_2
cawthron
parents:
diff changeset
   225
	«EXPAND additions-»
033392511bf7 add files for RCL_2_2
cawthron
parents:
diff changeset
   226
}
033392511bf7 add files for RCL_2_2
cawthron
parents:
diff changeset
   227
«ENDDEFINE»
033392511bf7 add files for RCL_2_2
cawthron
parents:
diff changeset
   228
033392511bf7 add files for RCL_2_2
cawthron
parents:
diff changeset
   229
«DEFINE additions FOR gmfgen::GenDiagram-»«ENDDEFINE»
033392511bf7 add files for RCL_2_2
cawthron
parents:
diff changeset
   230
033392511bf7 add files for RCL_2_2
cawthron
parents:
diff changeset
   231
«DEFINE i18nValues FOR gmfgen::GenDiagram-»
033392511bf7 add files for RCL_2_2
cawthron
parents:
diff changeset
   232
«EXPAND xpt::Externalizer::messageEntry(i18nKeyForModelingAssistantProvider().titleKey(), "Select domain model element")-»
033392511bf7 add files for RCL_2_2
cawthron
parents:
diff changeset
   233
«EXPAND xpt::Externalizer::messageEntry(i18nKeyForModelingAssistantProvider().messageKey(), "Available domain model elements:")-»
033392511bf7 add files for RCL_2_2
cawthron
parents:
diff changeset
   234
«ENDDEFINE»
033392511bf7 add files for RCL_2_2
cawthron
parents:
diff changeset
   235
033392511bf7 add files for RCL_2_2
cawthron
parents:
diff changeset
   236
«DEFINE i18nAccessors FOR gmfgen::GenDiagram-»
033392511bf7 add files for RCL_2_2
cawthron
parents:
diff changeset
   237
	«EXPAND xpt::Externalizer::accessorField(i18nKeyForModelingAssistantProvider().titleKey())-»
033392511bf7 add files for RCL_2_2
cawthron
parents:
diff changeset
   238
	«EXPAND xpt::Externalizer::accessorField(i18nKeyForModelingAssistantProvider().messageKey())-»
033392511bf7 add files for RCL_2_2
cawthron
parents:
diff changeset
   239
«ENDDEFINE»