422
|
1 |
/*
|
|
2 |
* Copyright (c) 2007 Borland Software Corporation
|
|
3 |
*
|
|
4 |
* All rights reserved. This program and the accompanying materials
|
|
5 |
* are made available under the terms of the Eclipse Public License v1.0
|
|
6 |
* which accompanies this distribution, and is available at
|
|
7 |
* http://www.eclipse.org/legal/epl-v10.html
|
|
8 |
*
|
|
9 |
* Contributors:
|
|
10 |
* Dmitry Stadnik (Borland) - initial API and implementation
|
|
11 |
*/
|
|
12 |
|
|
13 |
«IMPORT "http://www.eclipse.org/gmf/2008/GenModel"»
|
|
14 |
«IMPORT "http://www.eclipse.org/emf/2002/GenModel"»
|
|
15 |
«IMPORT "http://www.eclipse.org/emf/2002/Ecore"»
|
|
16 |
|
|
17 |
«DEFINE className FOR gmfgen::GenDiagram»PrintfParser«ENDDEFINE»
|
|
18 |
|
|
19 |
«DEFINE qualifiedClassName FOR gmfgen::GenDiagram»«parsersPackageName».«EXPAND className»«ENDDEFINE»
|
|
20 |
|
|
21 |
«DEFINE PrintfParser FOR gmfgen::GenDiagram-»
|
|
22 |
«EXPAND xpt::Common::copyright FOR editorGen-»
|
|
23 |
package «parsersPackageName»;
|
|
24 |
|
|
25 |
«EXPAND xpt::Common::generatedClassComment»
|
|
26 |
public class «EXPAND className» extends «EXPAND xpt::parsers::AbstractParser::qualifiedClassName» {
|
|
27 |
|
|
28 |
«EXPAND xpt::Common::generatedMemberComment»
|
|
29 |
private String defaultPattern;
|
|
30 |
|
|
31 |
«EXPAND xpt::Common::generatedMemberComment»
|
|
32 |
public «EXPAND className»(org.eclipse.emf.ecore.EAttribute[] features) {
|
|
33 |
super(features);
|
|
34 |
}
|
|
35 |
|
|
36 |
«EXPAND xpt::Common::generatedMemberComment»
|
|
37 |
protected String getDefaultPattern() {
|
|
38 |
if (defaultPattern == null) {
|
|
39 |
StringBuffer sb = new StringBuffer();
|
|
40 |
for (int i = 0; i < features.length; i++) {
|
|
41 |
if (i > 0) {
|
|
42 |
sb.append(' ');
|
|
43 |
}
|
|
44 |
sb.append('%');
|
|
45 |
sb.append(i + 1);
|
|
46 |
sb.append('$');
|
|
47 |
sb.append('s');
|
|
48 |
}
|
|
49 |
defaultPattern = sb.toString();
|
|
50 |
}
|
|
51 |
return defaultPattern;
|
|
52 |
}
|
|
53 |
|
|
54 |
«EXPAND xpt::Common::generatedMemberComment»
|
|
55 |
public String getViewPattern() {
|
|
56 |
String pattern = super.getViewPattern();
|
|
57 |
return pattern != null ? pattern : getDefaultPattern();
|
|
58 |
}
|
|
59 |
|
|
60 |
«EXPAND xpt::Common::generatedMemberComment»
|
|
61 |
public String getEditorPattern() {
|
|
62 |
String pattern = super.getEditorPattern();
|
|
63 |
return pattern != null ? pattern : getDefaultPattern();
|
|
64 |
}
|
|
65 |
|
|
66 |
«EXPAND xpt::Common::generatedMemberComment»
|
|
67 |
public String getPrintString(org.eclipse.core.runtime.IAdaptable adapter, int flags) {
|
|
68 |
org.eclipse.emf.ecore.EObject element =
|
|
69 |
(org.eclipse.emf.ecore.EObject) adapter.getAdapter(org.eclipse.emf.ecore.EObject.class);
|
|
70 |
return String.format(getViewPattern(), getValues(element));
|
|
71 |
}
|
|
72 |
|
|
73 |
«EXPAND xpt::Common::generatedMemberComment»
|
|
74 |
public String getEditString(org.eclipse.core.runtime.IAdaptable adapter, int flags) {
|
|
75 |
org.eclipse.emf.ecore.EObject element =
|
|
76 |
(org.eclipse.emf.ecore.EObject) adapter.getAdapter(org.eclipse.emf.ecore.EObject.class);
|
|
77 |
return String.format(getEditorPattern(), getValues(element));
|
|
78 |
}
|
|
79 |
|
|
80 |
«EXPAND xpt::Common::generatedMemberComment»
|
|
81 |
public org.eclipse.gmf.runtime.common.ui.services.parser.IParserEditStatus isValidEditString(
|
|
82 |
org.eclipse.core.runtime.IAdaptable adapter, String editString) {
|
|
83 |
return org.eclipse.gmf.runtime.common.ui.services.parser.ParserEditStatus.UNEDITABLE_STATUS;
|
|
84 |
}
|
|
85 |
|
|
86 |
«EXPAND xpt::Common::generatedMemberComment»
|
|
87 |
public org.eclipse.gmf.runtime.common.core.command.ICommand getParseCommand(
|
|
88 |
org.eclipse.core.runtime.IAdaptable adapter, String newString, int flags) {
|
|
89 |
return org.eclipse.gmf.runtime.common.core.command.UnexecutableCommand.INSTANCE;
|
|
90 |
}
|
|
91 |
«EXPAND additions-»
|
|
92 |
}
|
|
93 |
«ENDDEFINE»
|
|
94 |
|
|
95 |
«DEFINE additions FOR gmfgen::GenDiagram»«ENDDEFINE»
|