Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
Diffstat (limited to 'plugins/org.eclipse.gmf.codegen/templates.migrated/xpt/propsheet/PropertySection.xpt')
-rw-r--r--plugins/org.eclipse.gmf.codegen/templates.migrated/xpt/propsheet/PropertySection.xpt145
1 files changed, 145 insertions, 0 deletions
diff --git a/plugins/org.eclipse.gmf.codegen/templates.migrated/xpt/propsheet/PropertySection.xpt b/plugins/org.eclipse.gmf.codegen/templates.migrated/xpt/propsheet/PropertySection.xpt
new file mode 100644
index 000000000..29c0729dd
--- /dev/null
+++ b/plugins/org.eclipse.gmf.codegen/templates.migrated/xpt/propsheet/PropertySection.xpt
@@ -0,0 +1,145 @@
+/*
+ * Copyright (c) 2007 Borland Software Corporation
+ *
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Artem Tikhomirov (Borland) - initial API and implementation
+ */
+«IMPORT 'http://www.eclipse.org/gmf/2008/GenModel'»
+«IMPORT 'http://www.eclipse.org/emf/2002/Ecore'»
+
+«DEFINE Class FOR gmfgen::GenCustomPropertyTab»
+ «EXPAND xpt::Common::copyright FOR sheet.editorGen-»
+package «sheet.packageName»;
+
+«EXPAND xpt::Common::generatedClassComment»
+public class «className» extends «EXPAND extendsList» «EXPAND implementsClause»{
+
+«EXPAND getPropertySourceMethod»
+«IF sheet.readOnly»
+«EXPAND createReadonlyControlsMethod»
+«ENDIF»
+«EXPAND getPropertySourceProviderMethod»
+«EXPAND transfromSelectionMethod»
+«EXPAND setInputMethod»
+«EXPAND getAdapterFactoryMethod»
+
+«EXPAND additions»
+}
+«ENDDEFINE»
+
+«DEFINE extendsList FOR gmfgen::GenCustomPropertyTab»org.eclipse.gmf.runtime.diagram.ui.properties.sections.AdvancedPropertySection«ENDDEFINE»
+«DEFINE implementsClause FOR gmfgen::GenCustomPropertyTab»implements org.eclipse.ui.views.properties.IPropertySourceProvider«ENDDEFINE»
+
+«DEFINE getPropertySourceMethod FOR gmfgen::GenCustomPropertyTab-»
+ «EXPAND xpt::Common::generatedMemberComment»
+ public org.eclipse.ui.views.properties.IPropertySource getPropertySource(Object object) {
+ if (object instanceof org.eclipse.ui.views.properties.IPropertySource) {
+ return (org.eclipse.ui.views.properties.IPropertySource) object;
+ }
+ org.eclipse.emf.common.notify.AdapterFactory af = getAdapterFactory(object);
+ if (af != null) {
+ org.eclipse.emf.edit.provider.IItemPropertySource ips = (org.eclipse.emf.edit.provider.IItemPropertySource) af.adapt(object, org.eclipse.emf.edit.provider.IItemPropertySource.class);
+ if (ips != null) {
+ return new org.eclipse.emf.edit.ui.provider.PropertySource(object, ips);
+ }
+ }
+ if (object instanceof org.eclipse.core.runtime.IAdaptable) {
+ return (org.eclipse.ui.views.properties.IPropertySource) ((org.eclipse.core.runtime.IAdaptable) object).getAdapter(org.eclipse.ui.views.properties.IPropertySource.class);
+ }
+ return null;
+ }
+«ENDDEFINE»
+
+«DEFINE createReadonlyControlsMethod FOR gmfgen::GenCustomPropertyTab»
+ «EXPAND xpt::Common::generatedMemberComment»
+ public void createControls(org.eclipse.swt.widgets.Composite parent, org.eclipse.ui.views.properties.tabbed.TabbedPropertySheetPage aTabbedPropertySheetPage) {
+ super.createControls(parent, aTabbedPropertySheetPage);
+ class ROEntry extends org.eclipse.gmf.runtime.emf.ui.properties.sections.UndoableModelPropertySheetEntry {
+ ROEntry(org.eclipse.core.commands.operations.IOperationHistory operationHistory) {
+ super(operationHistory);
+ }
+ public org.eclipse.jface.viewers.CellEditor getEditor(org.eclipse.swt.widgets.Composite parentComposite) {
+ return null; // do not allow editing
+ }
+ protected org.eclipse.gmf.runtime.emf.ui.properties.sections.PropertySheetEntry createChildEntry() {
+ return new ROEntry(getOperationHistory());
+ }
+ };
+ ROEntry root = new ROEntry(org.eclipse.core.commands.operations.OperationHistoryFactory.getOperationHistory());
+ root.setPropertySourceProvider(getPropertySourceProvider());
+ page.setRootEntry(root);
+ }
+«ENDDEFINE»
+
+«DEFINE getPropertySourceProviderMethod FOR gmfgen::GenCustomPropertyTab»
+ «EXPAND xpt::Common::generatedMemberComment»
+ protected org.eclipse.ui.views.properties.IPropertySourceProvider getPropertySourceProvider() {
+ return this;
+ }
+«ENDDEFINE»
+
+«DEFINE transfromSelectionMethod FOR gmfgen::GenCustomPropertyTab»
+ «EXPAND xpt::Common::generatedMemberComment('Modify/unwrap selection.')»
+ protected Object transformSelection(Object selected) {
+«IF 'domain' = iD /*perhaps, override setInput should obey same condition?*/-»
+ «EXPAND transfromSelectionMethodBodyDefault-»
+«ENDIF-»
+ return selected;
+ }
+«ENDDEFINE»
+
+«DEFINE transfromSelectionMethodBodyDefault FOR gmfgen::GenCustomPropertyTab»
+ if (selected instanceof org.eclipse.gef.EditPart) {
+ Object model = ((org.eclipse.gef.EditPart) selected).getModel();
+ return model instanceof org.eclipse.gmf.runtime.notation.View ? ((org.eclipse.gmf.runtime.notation.View) model).getElement() : null;
+ }
+ if (selected instanceof org.eclipse.gmf.runtime.notation.View) {
+ return ((org.eclipse.gmf.runtime.notation.View) selected).getElement();
+ }
+ if (selected instanceof org.eclipse.core.runtime.IAdaptable) {
+ org.eclipse.gmf.runtime.notation.View view = (org.eclipse.gmf.runtime.notation.View) ((org.eclipse.core.runtime.IAdaptable) selected).getAdapter(org.eclipse.gmf.runtime.notation.View.class);
+ if (view != null) {
+ return view.getElement();
+ }
+ }
+«ENDDEFINE»
+
+«DEFINE setInputMethod FOR gmfgen::GenCustomPropertyTab»
+ «EXPAND xpt::Common::generatedMemberComment»
+ public void setInput(org.eclipse.ui.IWorkbenchPart part, org.eclipse.jface.viewers.ISelection selection) {
+ if (selection.isEmpty() || false == selection instanceof org.eclipse.jface.viewers.StructuredSelection) {
+ super.setInput(part, selection);
+ return;
+ }
+ final org.eclipse.jface.viewers.StructuredSelection structuredSelection = ((org.eclipse.jface.viewers.StructuredSelection) selection);
+ java.util.ArrayList transformedSelection = new java.util.ArrayList(structuredSelection.size());
+ for (java.util.Iterator it = structuredSelection.iterator(); it.hasNext();) {
+ Object r = transformSelection(it.next());
+ if (r != null) {
+ transformedSelection.add(r);
+ }
+ }
+ super.setInput(part, new org.eclipse.jface.viewers.StructuredSelection(transformedSelection));
+ }
+«ENDDEFINE»
+
+«DEFINE getAdapterFactoryMethod FOR gmfgen::GenCustomPropertyTab»
+ «EXPAND xpt::Common::generatedMemberComment»
+ protected org.eclipse.emf.common.notify.AdapterFactory getAdapterFactory(Object object) {
+ if (getEditingDomain() instanceof org.eclipse.emf.edit.domain.AdapterFactoryEditingDomain) {
+ return ((org.eclipse.emf.edit.domain.AdapterFactoryEditingDomain) getEditingDomain()).getAdapterFactory();
+ }
+ org.eclipse.emf.transaction.TransactionalEditingDomain editingDomain = org.eclipse.emf.transaction.util.TransactionUtil.getEditingDomain(object);
+ if (editingDomain != null) {
+ return ((org.eclipse.emf.edit.domain.AdapterFactoryEditingDomain) editingDomain).getAdapterFactory();
+ }
+ return null;
+ }
+«ENDDEFINE»
+
+«DEFINE additions FOR gmfgen::GenCustomPropertyTab»«ENDDEFINE» \ No newline at end of file

Back to the top