carbidecpp22devenv/plugins/org.eclipse.gmf.templates.legacy_1.0.0.v20090614-0839/codegen.lite.templates/xpt/providers/MetricsAction.xpt
/*
* 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:
* bblajer (Borland) - initial API and implementation
*/
«IMPORT "http://www.eclipse.org/gmf/2008/GenModel"»
«IMPORT "http://www.eclipse.org/emf/2002/Ecore"»
«IMPORT "http://www.eclipse.org/emf/2002/GenModel"»
«EXTENSION xpt::providers::i18n»
«DEFINE className FOR gmfgen::GenDiagram»MetricsAction«ENDDEFINE»
«DEFINE qualifiedClassName FOR gmfgen::GenDiagram»«providersPackageName».«EXPAND className»«ENDDEFINE»
«DEFINE actionKey FOR gmfgen::GenDiagram»«EXPAND qualifiedClassName».«EXPAND keyConstant»«ENDDEFINE»
«DEFINE MetricsAction FOR gmfgen::GenDiagram-»
«EXPAND xpt::Common::copyright FOR editorGen»
package «providersPackageName»;
«EXPAND xpt::Common::generatedClassComment»
public class «EXPAND className» «EXPAND supertypes» {
«EXPAND KEY-»
«EXPAND part-»
«EXPAND ctor-»
«EXPAND run-»
«EXPAND additions-»
}
«ENDDEFINE»
«DEFINE supertypes FOR gmfgen::GenDiagram»extends org.eclipse.jface.action.Action«ENDDEFINE»
«DEFINE KEY FOR gmfgen::GenDiagram-»
«EXPAND xpt::Common::generatedMemberComment»
public static final String «EXPAND keyConstant» = "metricsAction"; «EXPAND xpt::Common::nonNLS»
«ENDDEFINE»
«DEFINE keyConstant FOR gmfgen::GenDiagram»ACTION_KEY«ENDDEFINE»
«DEFINE part FOR gmfgen::GenDiagram-»
«EXPAND xpt::Common::generatedMemberComment»
private org.eclipse.ui.IWorkbenchPart myWorkbenchPart;
«ENDDEFINE»
«DEFINE ctor FOR gmfgen::GenDiagram-»
«EXPAND xpt::Common::generatedMemberComment»
public MetricsAction(org.eclipse.ui.IWorkbenchPart workbenchPart) {
setId(«EXPAND keyConstant»);
setText(«EXPAND xpt::Externalizer::accessorCall(i18nKeyForMetricsActionActionName()) FOR editorGen»);
myWorkbenchPart = workbenchPart;
setEnabled(myWorkbenchPart instanceof «editorGen.editor.getQualifiedClassName()»);
}
«ENDDEFINE»
«DEFINE run FOR gmfgen::GenDiagram-»
«EXPAND xpt::Common::generatedMemberComment»
public void run() {
org.eclipse.ui.IViewPart metricsView = null;
try {
metricsView = org.eclipse.ui.PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage().findView(«EXPAND xpt::providers::MetricProvider::resultViewID»);
if(metricsView == null) {
metricsView = org.eclipse.ui.PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage().showView(«EXPAND xpt::providers::MetricProvider::resultViewID»);
«IF editorGen.editor.eclipseEditor-»
} else {
«ELSE-»
}
if (metricsView != null) {
«ENDIF-»
final «editorGen.editor.getQualifiedClassName()» part = («editorGen.editor.getQualifiedClassName()») myWorkbenchPart;
((«EXPAND xpt::providers::MetricProvider::resultViewQualifiedClassName»)metricsView).setInput(part);
}
myWorkbenchPart.getSite().getPage().activate(metricsView);
} catch (org.eclipse.ui.PartInitException e) {
«editorGen.plugin.getActivatorQualifiedClassName()».getInstance().logError("Diagram metric view failure", e); «EXPAND xpt::Common::nonNLS»
}
}
«ENDDEFINE»
«DEFINE additions FOR gmfgen::GenDiagram»«ENDDEFINE»
«DEFINE i18nAccessors FOR gmfgen::GenDiagram-»
«EXPAND xpt::Externalizer::accessorField(i18nKeyForMetricsActionActionName())-»
«ENDDEFINE»
«DEFINE i18nValues FOR gmfgen::GenDiagram-»
«EXPAND xpt::Externalizer::messageEntry(i18nKeyForMetricsActionActionName(), "&Metrics")-»
«ENDDEFINE»