|
Lines 1-138
Link Here
|
| 1 |
/******************************************************************************* |
|
|
| 2 |
* Copyright (c) 2007, 2012 EclipseSource and others |
| 3 |
* All rights reserved. This program and the accompanying materials |
| 4 |
* are made available under the terms of the Eclipse Public License v1.0 |
| 5 |
* which accompanies this distribution, and is available at |
| 6 |
* http://www.eclipse.org/legal/epl-v10.html |
| 7 |
* |
| 8 |
* Contributors: |
| 9 |
* Innoopract Informationssysteme GmbH - initial API and implementation |
| 10 |
* EclipseSource - ongoing development |
| 11 |
******************************************************************************/ |
| 12 |
package org.eclipse.rap.internal.ui.templates.rap; |
| 13 |
|
| 14 |
import org.eclipse.core.runtime.CoreException; |
| 15 |
import org.eclipse.core.runtime.IProgressMonitor; |
| 16 |
import org.eclipse.jface.wizard.Wizard; |
| 17 |
import org.eclipse.jface.wizard.WizardPage; |
| 18 |
import org.eclipse.pde.core.plugin.IPluginElement; |
| 19 |
import org.eclipse.pde.core.plugin.IPluginExtension; |
| 20 |
import org.eclipse.rap.internal.ui.templates.TemplateUtil; |
| 21 |
import org.eclipse.rap.internal.ui.templates.XmlNames; |
| 22 |
|
| 23 |
class ViewRAPTemplate extends AbstractRAPTemplate { |
| 24 |
|
| 25 |
ViewRAPTemplate() { |
| 26 |
setPageCount( 1 ); |
| 27 |
createTemplateOptions(); |
| 28 |
} |
| 29 |
|
| 30 |
public void addPages( Wizard wizard ) { |
| 31 |
WizardPage page = createPage( 0 ); |
| 32 |
page.setTitle( Messages.viewRAPTemplate_pageTitle ); |
| 33 |
page.setDescription( Messages.viewRAPTemplate_pageDescr ); |
| 34 |
wizard.addPage( page ); |
| 35 |
markPagesAdded(); |
| 36 |
} |
| 37 |
|
| 38 |
public String getSectionId() { |
| 39 |
return "viewRAP"; //$NON-NLS-1$ |
| 40 |
} |
| 41 |
|
| 42 |
public String getApplicationId() { |
| 43 |
return "viewapp"; |
| 44 |
} |
| 45 |
|
| 46 |
public String getServletPath() { |
| 47 |
return "/view"; |
| 48 |
} |
| 49 |
|
| 50 |
protected void updateModel( IProgressMonitor monitor ) throws CoreException { |
| 51 |
createEntryPointExtension(); |
| 52 |
createApplicationExtension(); |
| 53 |
createPerspectivesExtension(); |
| 54 |
createViewsExtension(); |
| 55 |
createBrandingExtension(); |
| 56 |
} |
| 57 |
|
| 58 |
////////////////// |
| 59 |
// helping methods |
| 60 |
|
| 61 |
private void createEntryPointExtension() throws CoreException { |
| 62 |
IPluginExtension extension = createExtension( XmlNames.XID_ENTRYPOINT, true ); |
| 63 |
extension.setId( getApplicationId() + ".entrypoints" ); |
| 64 |
IPluginElement entryPointElement = createElement( extension ); |
| 65 |
entryPointElement.setName( XmlNames.ELEM_ENTRYPOINT ); |
| 66 |
entryPointElement.setAttribute( XmlNames.ATT_ID, getApplicationId() + ".entrypoint" ); |
| 67 |
entryPointElement.setAttribute( XmlNames.ATT_SERVLET_PATH, getServletPath() ); |
| 68 |
entryPointElement.setAttribute( XmlNames.ATT_APPLICATION_ID, getFullApplicationId() ); |
| 69 |
entryPointElement.setAttribute( XmlNames.ATT_BRANDING_ID, getPackageName() + ".branding" ); |
| 70 |
extension.add( entryPointElement ); |
| 71 |
addExtensionToPlugin( extension ); |
| 72 |
} |
| 73 |
|
| 74 |
private void createApplicationExtension() throws CoreException { |
| 75 |
IPluginExtension extension = createExtension( XmlNames.XID_APPLICATION, true ); |
| 76 |
extension.setId( getFullApplicationId() ); |
| 77 |
IPluginElement applicationElement = createElement( extension ); |
| 78 |
applicationElement.setName( XmlNames.ELEM_APPLICATION ); |
| 79 |
applicationElement.setAttribute( XmlNames.ATT_VISIBLE, "true" ); //$NON-NLS-1$ |
| 80 |
applicationElement.setAttribute( XmlNames.ATT_CARDINALITY, "singleton-global" ); //$NON-NLS-1$ |
| 81 |
applicationElement.setAttribute( XmlNames.ATT_THREAD, "main" ); //$NON-NLS-1$ |
| 82 |
extension.add( applicationElement ); |
| 83 |
IPluginElement runElement = createElement( extension ); |
| 84 |
runElement.setName( XmlNames.ELEM_RUN ); |
| 85 |
runElement.setAttribute( XmlNames.ATT_CLASS, getApplicationClass() ); |
| 86 |
applicationElement.add( runElement ); |
| 87 |
addExtensionToPlugin( extension ); |
| 88 |
} |
| 89 |
|
| 90 |
private void createPerspectivesExtension() throws CoreException { |
| 91 |
IPluginExtension extension = createExtension( XmlNames.XID_PERSPECTIVES, true ); |
| 92 |
IPluginElement element = createElement( extension ); |
| 93 |
element.setName( XmlNames.ELEM_PERSPECTIVE ); |
| 94 |
element.setAttribute( XmlNames.ATT_CLASS, getPackageName() + ".Perspective" ); //$NON-NLS-1$ |
| 95 |
element.setAttribute( XmlNames.ATT_NAME, Messages.viewRAPTemplate_perspectiveName ); |
| 96 |
element.setAttribute( XmlNames.ATT_ID, getPluginId() + ".perspective" ); //$NON-NLS-1$ |
| 97 |
extension.add( element ); |
| 98 |
addExtensionToPlugin( extension ); |
| 99 |
} |
| 100 |
|
| 101 |
private void createViewsExtension() throws CoreException { |
| 102 |
IPluginExtension extension = createExtension( XmlNames.XID_VIEWS, true ); |
| 103 |
IPluginElement element = createElement( extension ); |
| 104 |
element.setName( XmlNames.ELEM_VIEW ); |
| 105 |
element.setAttribute( XmlNames.ATT_CLASS, getPackageName() + ".View" ); //$NON-NLS-1$ |
| 106 |
element.setAttribute( XmlNames.ATT_NAME, Messages.viewRAPTemplate_viewName ); |
| 107 |
element.setAttribute( XmlNames.ATT_ID, getPluginId() + ".view" ); //$NON-NLS-1$ |
| 108 |
extension.add( element ); |
| 109 |
addExtensionToPlugin( extension ); |
| 110 |
} |
| 111 |
|
| 112 |
private void createBrandingExtension() throws CoreException { |
| 113 |
IPluginExtension extension = createExtension( XmlNames.XID_BRANDING, true ); |
| 114 |
IPluginElement brandingElement = createElement( extension ); |
| 115 |
// create branding |
| 116 |
brandingElement.setName( XmlNames.ELEM_BRANDING ); |
| 117 |
String brandingId = getPackageName() + ".branding"; //$NON-NLS-1$ |
| 118 |
brandingElement.setAttribute( XmlNames.ATT_ID, brandingId ); |
| 119 |
brandingElement.setAttribute( XmlNames.ATT_THEME_ID, TemplateUtil.FANCY_THEME_ID ); |
| 120 |
brandingElement.setAttribute( XmlNames.ATT_TITLE, "RAP Single View" ); |
| 121 |
// write extension |
| 122 |
extension.add( brandingElement ); |
| 123 |
addExtensionToPlugin( extension ); |
| 124 |
} |
| 125 |
|
| 126 |
private void createTemplateOptions() { |
| 127 |
addOption( KEY_WINDOW_TITLE, |
| 128 |
Messages.viewRAPTemplate_windowTitle, |
| 129 |
Messages.viewRAPTemplate_appWindowTitle, |
| 130 |
0 ); |
| 131 |
addOption( KEY_PACKAGE_NAME, Messages.viewRAPTemplate_packageName, null, 0 ); |
| 132 |
addOption( KEY_APPLICATION_CLASS, |
| 133 |
Messages.viewRAPTemplate_appClass, |
| 134 |
"Application", //$NON-NLS-1$ |
| 135 |
0 ); |
| 136 |
} |
| 137 |
|
| 138 |
} |