KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > eclipse > pde > internal > ui > wizards > cheatsheet > SimpleCSCreationOperation


1 /*******************************************************************************
2  * Copyright (c) 2006, 2007 IBM Corporation 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  * IBM Corporation - initial API and implementation
10  *******************************************************************************/

11
12 package org.eclipse.pde.internal.ui.wizards.cheatsheet;
13
14 import org.eclipse.core.resources.IFile;
15 import org.eclipse.core.runtime.jobs.ISchedulingRule;
16 import org.eclipse.pde.internal.core.cheatsheet.simple.SimpleCSWorkspaceModel;
17 import org.eclipse.pde.internal.core.icheatsheet.simple.ISimpleCS;
18 import org.eclipse.pde.internal.core.icheatsheet.simple.ISimpleCSDescription;
19 import org.eclipse.pde.internal.core.icheatsheet.simple.ISimpleCSIntro;
20 import org.eclipse.pde.internal.core.icheatsheet.simple.ISimpleCSItem;
21 import org.eclipse.pde.internal.core.icheatsheet.simple.ISimpleCSModelFactory;
22 import org.eclipse.pde.internal.ui.PDEUIMessages;
23
24 /**
25  * SimpleCheatSheetCreationOperation
26  *
27  */

28 public class SimpleCSCreationOperation extends
29         BaseCSCreationOperation {
30
31     /**
32      * @param file
33      */

34     public SimpleCSCreationOperation(IFile file) {
35         super(file);
36     }
37
38     /**
39      * @param rule
40      */

41     public SimpleCSCreationOperation(ISchedulingRule rule) {
42         super(rule);
43     }
44
45     /**
46      *
47      */

48     protected void createContent() {
49         SimpleCSWorkspaceModel model = new SimpleCSWorkspaceModel(fFile, false);
50         initializeCS(model.getSimpleCS());
51         model.save();
52         model.dispose();
53     }
54
55     /**
56      * @param simpleCS
57      */

58     protected void initializeCS(ISimpleCS simpleCS) {
59         ISimpleCSModelFactory factory = simpleCS.getModel().getFactory();
60
61         // Element: intro
62
ISimpleCSIntro intro = factory.createSimpleCSIntro(simpleCS);
63         // Element: description
64
ISimpleCSDescription description = factory.createSimpleCSDescription(intro);
65         description.setContent(
66                 formatTextBold(PDEUIMessages.SimpleCheatSheetCreationOperation_0));
67         intro.setDescription(description);
68
69         // Element: item
70
ISimpleCSItem item = factory.createSimpleCSItem(simpleCS);
71         item.setTitle(PDEUIMessages.SimpleCheatSheetCreationOperation_1);
72         // Element: description
73
ISimpleCSDescription description2 = factory.createSimpleCSDescription(item);
74         description2.setContent(
75                 formatTextBold(PDEUIMessages.SimpleCheatSheetCreationOperation_2));
76         item.setDescription(description2);
77
78         // Attribute: title
79
simpleCS.setTitle(PDEUIMessages.SimpleCheatSheetCreationOperation_3);
80         simpleCS.setIntro(intro);
81         simpleCS.addItem(item);
82         
83     }
84 }
85
Popular Tags