carbidecpp22devenv/plugins/org.eclipse.gmf.templates.legacy_1.0.0.v20090614-0839/codegen.lite.templates/aspects/xpt/application/ActionBarAdvisor.xpt
changeset 422 033392511bf7
equal deleted inserted replaced
421:631a44165bcf 422:033392511bf7
       
     1 /*
       
     2  * Copyright (c) 2006 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  *    Boris Blajer (Borland) - initial API and implementation
       
    11  */
       
    12 
       
    13 «IMPORT "http://www.eclipse.org/gmf/2008/GenModel"»
       
    14 «IMPORT "http://www.eclipse.org/emf/2002/Ecore"»
       
    15 
       
    16 «EXTENSION xpt::Util»
       
    17 
       
    18 «AROUND openEditor FOR gmfgen::GenEditorView-»
       
    19 «ENDAROUND»
       
    20 
       
    21 «AROUND AboutAction FOR gmfgen::GenApplication-»
       
    22 	«EXPAND xpt::Common::generatedMemberComment("About action for the RCP application.")»
       
    23 	public static class AboutAction extends org.eclipse.emf.common.ui.action.WorkbenchWindowActionDelegate {
       
    24 		«EXPAND xpt::Common::generatedMemberComment("@see org.eclipse.ui.IActionDelegate#run(org.eclipse.jface.action.IAction)")»
       
    25 		public void run(org.eclipse.jface.action.IAction action) {
       
    26 			org.eclipse.jface.dialogs.MessageDialog.openInformation(getWindow().getShell(), getString("_UI_About_title"),	«EXPAND xpt::Common::nonNLS»
       
    27 			getString("_UI_About_text"));	«EXPAND xpt::Common::nonNLS»
       
    28 		}
       
    29 	}
       
    30 «ENDAROUND»
       
    31 
       
    32 «AROUND OpenAction FOR gmfgen::GenApplication-»
       
    33 	«EXPAND xpt::Common::generatedClassComment("Open action for the " + editorGen.domainGenModel.modelName + " diagram.")»
       
    34 	public static class OpenAction extends org.eclipse.emf.common.ui.action.WorkbenchWindowActionDelegate {
       
    35 		«EXPAND xpt::Common::generatedMemberComment("Opens the editors for the files selected using the file dialog.")»
       
    36 		public void run(org.eclipse.jface.action.IAction action) {
       
    37 			String filePath = «editorGen.diagram.getDiagramEditorUtilQualifiedClassName()».openFilePathDialog(getWindow().getShell(), "*.«editorGen.diagramFileExtension»", org.eclipse.swt.SWT.OPEN);	«EXPAND xpt::Common::nonNLS»
       
    38 			if (filePath != null) {
       
    39 «IF editorGen.editor.eclipseEditor-»
       
    40 				«editorGen.diagram.getDiagramEditorUtilQualifiedClassName()».openEditor(org.eclipse.emf.common.util.URI.createFileURI(filePath));
       
    41 «ELSE-»
       
    42 				«editorGen.diagram.getDiagramEditorUtilQualifiedClassName()».showView(org.eclipse.emf.common.util.URI.createFileURI(filePath));
       
    43 «ENDIF-»
       
    44 			}
       
    45 		}
       
    46  	}
       
    47 «ENDAROUND»
       
    48 
       
    49 «AROUND OpenUriAction FOR gmfgen::GenApplication-»
       
    50 	«EXPAND xpt::Common::generatedMemberComment("Open URI action for the " + editorGen.domainGenModel.modelName + " diagram.")»
       
    51 	public static class OpenURIAction extends org.eclipse.emf.common.ui.action.WorkbenchWindowActionDelegate {
       
    52 		«EXPAND xpt::Common::generatedMemberComment("Opens the editors for the files selected using the LoadResourceDialog.")»
       
    53 		public void run(org.eclipse.jface.action.IAction action) {
       
    54 			org.eclipse.emf.edit.ui.action.LoadResourceAction.LoadResourceDialog loadResourceDialog = new org.eclipse.emf.edit.ui.action.LoadResourceAction.LoadResourceDialog(getWindow().getShell());
       
    55 			if (org.eclipse.jface.dialogs.Dialog.OK == loadResourceDialog.open()) {
       
    56 				for (java.util.Iterator it = loadResourceDialog.getURIs().iterator(); it.hasNext(); ) {
       
    57 «IF editorGen.editor.eclipseEditor»
       
    58 					«editorGen.diagram.getDiagramEditorUtilQualifiedClassName()».openEditor((org.eclipse.emf.common.util.URI) it.next());
       
    59 «ELSE»
       
    60 					«editorGen.diagram.getDiagramEditorUtilQualifiedClassName()».showView((org.eclipse.emf.common.util.URI) it.next());
       
    61 «ENDIF»
       
    62 				}
       
    63 			}
       
    64 		}
       
    65 	}
       
    66 «ENDAROUND»
       
    67 
       
    68 «AROUND additions FOR gmfgen::GenApplication-»
       
    69 	«EXPAND xpt::Common::generatedMemberComment("Looks up a string in the plugin.properties file for the plugin.")»
       
    70 	private static String getString(String key) {
       
    71 		return «editorGen.plugin.getActivatorQualifiedClassName()».getInstance().getBundleString(key);
       
    72 	}
       
    73 «ENDAROUND»