Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.
View | Details | Raw Unified | Return to bug 398073
Collapse All | Expand All

(-)a/bundles/org.eclipse.rap.tools.templates/plugin.properties (-10 lines)
Lines 22-37 helloRAP.description = \ Link Here
22
<li>org.eclipse.ui.perspectives</li>\
22
<li>org.eclipse.ui.perspectives</li>\
23
<p>This code will need the <b>RAP target</b> to compile.</p>
23
<p>This code will need the <b>RAP target</b> to compile.</p>
24
24
25
viewRAP.name = RAP Application with a view
26
viewRAP.description = \
27
<p>This wizard creates a RAP application that consists of an application window with a single view.</p>\
28
<p><b>Extensions Used</b></p>\
29
<li>org.eclipse.core.runtime.applications</li>\
30
<li>org.eclipse.ui.perspectives</li>\
31
<li>org.eclipse.ui.views</li>\
32
<li>org.eclipse.rap.ui.branding</li>\
33
<p>This code will need the <b>RAP target</b> to compile.</p>
34
35
mailRAP.name = RAP Mail Template
25
mailRAP.name = RAP Mail Template
36
mailRAP.description = \
26
mailRAP.description = \
37
<p>This wizard creates a RAP application that shows how to:</p>\
27
<p>This wizard creates a RAP application that shows how to:</p>\
(-)a/bundles/org.eclipse.rap.tools.templates/plugin.xml (-12 lines)
Lines 17-34 Link Here
17
         </description>
17
         </description>
18
      </wizard>
18
      </wizard>
19
      <wizard
19
      <wizard
20
            class="org.eclipse.rap.internal.ui.templates.rap.ViewRAPWizard"
21
            icon="$nl$/icons/etool16/newexprj_wiz.gif"
22
            id="org.eclipse.rap.internal.ui.templates.rap.ViewRAPWizard"
23
            java="true"
24
            rcp="false"
25
            name="%viewRAP.name"
26
            ui-content="true">
27
         <description>
28
            %viewRAP.description
29
         </description>
30
      </wizard>
31
      <wizard
32
            class="org.eclipse.rap.internal.ui.templates.rap.MailRAPWizard"
20
            class="org.eclipse.rap.internal.ui.templates.rap.MailRAPWizard"
33
            icon="$nl$/icons/etool16/newexprj_wiz.gif"
21
            icon="$nl$/icons/etool16/newexprj_wiz.gif"
34
            id="org.eclipse.rap.internal.ui.templates.rap.MailRAPWizard"
22
            id="org.eclipse.rap.internal.ui.templates.rap.MailRAPWizard"
(-)a/bundles/org.eclipse.rap.tools.templates/src/org/eclipse/rap/internal/ui/templates/rap/Messages.java (-10 lines)
Lines 43-58 public class Messages extends NLS { Link Here
43
  public static String mailRAPTemplate_windowTitle;
43
  public static String mailRAPTemplate_windowTitle;
44
  public static String mailRAPWizard_windowTitle;
44
  public static String mailRAPWizard_windowTitle;
45
45
46
  public static String viewRAPTemplate_appClass;
47
  public static String viewRAPTemplate_appWindowTitle;
48
  public static String viewRAPTemplate_packageName;
49
  public static String viewRAPTemplate_pageDescr;
50
  public static String viewRAPTemplate_pageTitle;
51
  public static String viewRAPTemplate_perspectiveName;
52
  public static String viewRAPTemplate_viewName;
53
  public static String viewRAPTemplate_windowTitle;
54
  public static String viewRAPWizard_windowTitle;
55
56
  private static final String BUNDLE_NAME 
46
  private static final String BUNDLE_NAME 
57
    = "org.eclipse.rap.internal.ui.templates.rap.messages"; //$NON-NLS-1$
47
    = "org.eclipse.rap.internal.ui.templates.rap.messages"; //$NON-NLS-1$
58
48
(-)a/bundles/org.eclipse.rap.tools.templates/src/org/eclipse/rap/internal/ui/templates/rap/ViewRAPTemplate.java (-138 lines)
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
}
(-)a/bundles/org.eclipse.rap.tools.templates/src/org/eclipse/rap/internal/ui/templates/rap/ViewRAPWizard.java (-41 lines)
Lines 1-41 Link Here
1
/*******************************************************************************
2
 * Copyright (c) 2007, 2011 EclipseSource
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.pde.ui.IFieldData;
15
import org.eclipse.pde.ui.templates.ITemplateSection;
16
17
public class ViewRAPWizard extends AbstractRAPWizard {
18
19
  private AbstractRAPTemplate template;
20
21
  public void init( final IFieldData data ) {
22
    super.init( data );
23
    setWindowTitle( Messages.viewRAPWizard_windowTitle );
24
  }
25
26
  public ITemplateSection[] createTemplateSections() {
27
    template = new ViewRAPTemplate();
28
    return new ITemplateSection[] {
29
      template
30
    };
31
  }
32
33
  protected String getEntryPointName() {
34
    return template.getFullApplicationId();
35
  }
36
37
  protected String getServletPath() {
38
    return template.getServletPath();
39
  }
40
41
}
(-)a/bundles/org.eclipse.rap.tools.templates/src/org/eclipse/rap/internal/ui/templates/rap/messages.properties (-11 / +1 lines)
Lines 11-27 Link Here
11
11
12
AbstractRAPWizard_targetQuestionDialogTitle=Install RAP Target Platform
12
AbstractRAPWizard_targetQuestionDialogTitle=Install RAP Target Platform
13
AbstractRAPWizard_targetQuestionDialogMessage=RAP projects need to be compiled against a RAP target platform. Do you want to install a RAP target platform now?
13
AbstractRAPWizard_targetQuestionDialogMessage=RAP projects need to be compiled against a RAP target platform. Do you want to install a RAP target platform now?
14
AbstractRAPWizard_Modifying=Modifing {0}
14
AbstractRAPWizard_Modifying=Modifying {0}
15
16
viewRAPTemplate_pageTitle=Single View RAP Application
17
viewRAPTemplate_pageDescr=This wizard creates a RAP application that consists of an application window with a single view.
18
viewRAPWizard_windowTitle=New RAP Project with a view
19
viewRAPTemplate_perspectiveName=RAP Perspective
20
viewRAPTemplate_viewName=View
21
viewRAPTemplate_windowTitle=Application window &title\:
22
viewRAPTemplate_appWindowTitle=RAP with a View
23
viewRAPTemplate_packageName=Pa&ckage name\:
24
viewRAPTemplate_appClass=App&lication class\:
25
15
26
mailRAPWizard_windowTitle=New Project with a RAP Mail Template
16
mailRAPWizard_windowTitle=New Project with a RAP Mail Template
27
17
(-)a/bundles/org.eclipse.rap.tools.templates/templates/viewRAP/java/$applicationClass$.java (-24 lines)
Lines 1-24 Link Here
1
package $packageName$;
2
3
import org.eclipse.equinox.app.IApplication;
4
import org.eclipse.equinox.app.IApplicationContext;
5
import org.eclipse.swt.widgets.Display;
6
import org.eclipse.ui.PlatformUI;
7
import org.eclipse.ui.application.WorkbenchAdvisor;
8
9
/**
10
 * This class controls all aspects of the application's execution
11
 * and is contributed through the plugin.xml.
12
 */
13
public class $applicationClass$ implements IApplication {
14
15
	public Object start(IApplicationContext context) throws Exception {
16
		Display display = PlatformUI.createDisplay();
17
		WorkbenchAdvisor advisor = new ApplicationWorkbenchAdvisor();
18
		return PlatformUI.createAndRunWorkbench(display, advisor);
19
	}
20
21
	public void stop() {
22
		// Do nothing
23
	}
24
}
(-)a/bundles/org.eclipse.rap.tools.templates/templates/viewRAP/java/ApplicationActionBarAdvisor.java (-41 lines)
Lines 1-41 Link Here
1
package $packageName$;
2
3
import org.eclipse.jface.action.IMenuManager;
4
import org.eclipse.jface.action.MenuManager;
5
import org.eclipse.ui.IWorkbenchActionConstants;
6
import org.eclipse.ui.IWorkbenchWindow;
7
import org.eclipse.ui.actions.ActionFactory;
8
import org.eclipse.ui.actions.ActionFactory.IWorkbenchAction;
9
import org.eclipse.ui.application.ActionBarAdvisor;
10
import org.eclipse.ui.application.IActionBarConfigurer;
11
12
/**
13
 * Creates, adds and disposes actions for the menus and action bars of
14
 * each workbench window.
15
 */
16
public class ApplicationActionBarAdvisor extends ActionBarAdvisor {
17
18
	public ApplicationActionBarAdvisor(IActionBarConfigurer configurer) {
19
		super(configurer);
20
	}
21
22
	// Actions - important to allocate these only in makeActions, and then use
23
	// them in the fill methods. This ensures that the actions aren't recreated
24
	// in the fill methods. 
25
	private IWorkbenchAction exitAction;
26
27
	protected void makeActions(IWorkbenchWindow window) {
28
		// Creates the actions and registers them. Registering also 
29
		// provides automatic disposal of the actions when the window is closed.
30
		exitAction = ActionFactory.QUIT.create(window);
31
		register(exitAction);
32
	}
33
34
	protected void fillMenuBar(IMenuManager menuBar) {
35
		MenuManager fileMenu 
36
		= new MenuManager("&File",IWorkbenchActionConstants.M_FILE);
37
		menuBar.add(fileMenu);
38
		fileMenu.add(exitAction);
39
	}
40
41
}
(-)a/bundles/org.eclipse.rap.tools.templates/templates/viewRAP/java/ApplicationWorkbenchAdvisor.java (-22 lines)
Lines 1-22 Link Here
1
package $packageName$;
2
3
import org.eclipse.ui.application.IWorkbenchWindowConfigurer;
4
import org.eclipse.ui.application.WorkbenchAdvisor;
5
import org.eclipse.ui.application.WorkbenchWindowAdvisor;
6
7
/**
8
 * This workbench advisor creates the window advisor, and specifies
9
 * the perspective id for the initial window.
10
 */
11
public class ApplicationWorkbenchAdvisor extends WorkbenchAdvisor {
12
13
	private static final String PERSPECTIVE_ID = "$pluginId$.perspective";
14
15
	public WorkbenchWindowAdvisor createWorkbenchWindowAdvisor(IWorkbenchWindowConfigurer configurer) {
16
		return new ApplicationWorkbenchWindowAdvisor(configurer);
17
	}
18
19
	public String getInitialWindowPerspectiveId() {
20
		return PERSPECTIVE_ID;
21
	}
22
}
(-)a/bundles/org.eclipse.rap.tools.templates/templates/viewRAP/java/ApplicationWorkbenchWindowAdvisor.java (-31 lines)
Lines 1-31 Link Here
1
package $packageName$;
2
3
import org.eclipse.swt.SWT;
4
import org.eclipse.swt.graphics.Point;
5
import org.eclipse.ui.application.ActionBarAdvisor;
6
import org.eclipse.ui.application.IActionBarConfigurer;
7
import org.eclipse.ui.application.IWorkbenchWindowConfigurer;
8
import org.eclipse.ui.application.WorkbenchWindowAdvisor;
9
10
/**
11
 * Configures the initial size and appearance of a workbench window.
12
 */
13
public class ApplicationWorkbenchWindowAdvisor extends WorkbenchWindowAdvisor {
14
15
	public ApplicationWorkbenchWindowAdvisor(IWorkbenchWindowConfigurer configurer) {
16
		super(configurer);
17
	}
18
19
	public ActionBarAdvisor createActionBarAdvisor(IActionBarConfigurer configurer) {
20
		return new ApplicationActionBarAdvisor(configurer);
21
	}
22
23
	public void preWindowOpen() {
24
		IWorkbenchWindowConfigurer configurer = getWindowConfigurer();
25
		configurer.setInitialSize(new Point(400, 300));
26
		configurer.setShowCoolBar(false);
27
		configurer.setShowStatusLine(false);
28
		configurer.setTitle("$windowTitle$");
29
		configurer.setShellStyle(SWT.TITLE | SWT.RESIZE);
30
	}
31
}
(-)a/bundles/org.eclipse.rap.tools.templates/templates/viewRAP/java/Perspective.java (-20 lines)
Lines 1-20 Link Here
1
package $packageName$;
2
3
import org.eclipse.ui.IPageLayout;
4
import org.eclipse.ui.IPerspectiveFactory;
5
6
/**
7
 * Configures the perspective layout. This class is contributed through the
8
 * plugin.xml.
9
 */
10
public class Perspective implements IPerspectiveFactory {
11
12
	public void createInitialLayout(IPageLayout layout) {
13
		String editorArea = layout.getEditorArea();
14
		layout.setEditorAreaVisible(false);
15
		layout.setFixed(true);
16
17
		layout.addStandaloneView(View.ID, false, IPageLayout.LEFT, 1.0f,
18
				editorArea);
19
	}
20
}
(-)a/bundles/org.eclipse.rap.tools.templates/templates/viewRAP/java/View.java (-74 lines)
Lines 1-73 Link Here
1
package $packageName$;
2
3
import org.eclipse.jface.viewers.IStructuredContentProvider;
4
import org.eclipse.jface.viewers.ITableLabelProvider;
5
import org.eclipse.jface.viewers.LabelProvider;
6
import org.eclipse.jface.viewers.TableViewer;
7
import org.eclipse.jface.viewers.Viewer;
8
import org.eclipse.swt.SWT;
9
import org.eclipse.swt.graphics.Image;
10
import org.eclipse.swt.widgets.Composite;
11
import org.eclipse.ui.ISharedImages;
12
import org.eclipse.ui.PlatformUI;
13
import org.eclipse.ui.part.ViewPart;
14
15
public class View extends ViewPart {
16
	public static final String ID = "$pluginId$.view";
17
18
	private TableViewer viewer;
19
20
	/**
21
	 * The content provider class is responsible for providing objects to the
22
	 * view. It can wrap existing objects in adapters or simply return objects
23
	 * as-is. These objects may be sensitive to the current input of the view,
24
	 * or ignore it and always show the same content (like Task List, for
25
	 * example).
26
	 */
27
	class ViewContentProvider implements IStructuredContentProvider {
28
		public void inputChanged(Viewer v, Object oldInput, Object newInput) {
29
		}
30
31
		public void dispose() {
32
		}
33
34
		public Object[] getElements(Object parent) {
35
			return new String[] { "One", "Two", "Three" };
36
		}
37
	}
38
39
	class ViewLabelProvider extends LabelProvider implements
40
			ITableLabelProvider {
41
		public String getColumnText(Object obj, int index) {
42
			return getText(obj);
43
		}
44
45
		public Image getColumnImage(Object obj, int index) {
46
			return getImage(obj);
47
		}
48
49
		public Image getImage(Object obj) {
50
			return PlatformUI.getWorkbench().getSharedImages().getImage(
51
					ISharedImages.IMG_OBJ_ELEMENT);
52
		}
53
	}
54
55
	/**
56
	 * This is a callback that will allow us to create the viewer and initialize
57
	 * it.
58
	 */
59
	public void createPartControl(Composite parent) {
60
		int style = SWT.MULTI | SWT.H_SCROLL | SWT.V_SCROLL;
61
		viewer = new TableViewer(parent, style);
62
		viewer.setContentProvider(new ViewContentProvider());
63
		viewer.setLabelProvider(new ViewLabelProvider());
64
		viewer.setInput(getViewSite());
65
	}
66
67
	/**
68
	 * Passing the focus request to the viewer's control.
69
	 */
70
	public void setFocus() {
71
		viewer.getControl().setFocus();
72
	}
73
}
74
- 

Return to bug 398073