01: /*******************************************************************************
02: * Copyright (c) 2006, 2007 IBM Corporation and others.
03: * All rights reserved. This program and the accompanying materials
04: * are made available under the terms of the Eclipse Public License v1.0
05: * which accompanies this distribution, and is available at
06: * http://www.eclipse.org/legal/epl-v10.html
07: *
08: * Contributors:
09: * IBM Corporation - initial API and implementation
10: *******************************************************************************/package org.eclipse.pde.internal.ui.wizards.cheatsheet;
11:
12: import org.eclipse.core.resources.IFile;
13: import org.eclipse.core.runtime.CoreException;
14: import org.eclipse.core.runtime.jobs.ISchedulingRule;
15: import org.eclipse.pde.internal.core.icheatsheet.simple.ISimpleCS;
16: import org.eclipse.pde.internal.core.icheatsheet.simple.ISimpleCSDescription;
17: import org.eclipse.pde.internal.core.icheatsheet.simple.ISimpleCSIntro;
18: import org.eclipse.pde.internal.core.icheatsheet.simple.ISimpleCSItem;
19: import org.eclipse.pde.internal.core.icheatsheet.simple.ISimpleCSModelFactory;
20: import org.eclipse.pde.internal.core.text.cheatsheet.simple.SimpleCSModel;
21: import org.eclipse.pde.internal.core.util.CoreUtility;
22: import org.eclipse.pde.internal.ui.PDEUIMessages;
23:
24: /**
25: * SimpleCheatSheetCreationOperation
26: *
27: */
28: public class SimpleCSCreationOperation extends BaseCSCreationOperation {
29:
30: /**
31: * @param file
32: */
33: public SimpleCSCreationOperation(IFile file) {
34: super (file);
35: }
36:
37: /**
38: * @param rule
39: */
40: public SimpleCSCreationOperation(ISchedulingRule rule) {
41: super (rule);
42: }
43:
44: /**
45: *
46: */
47: protected void createContent() throws CoreException {
48: SimpleCSModel model = new SimpleCSModel(CoreUtility
49: .getTextDocument(fFile.getContents()), false);
50: model.setUnderlyingResource(fFile);
51: initializeCS(model.getSimpleCS());
52: model.save();
53: model.dispose();
54: }
55:
56: /**
57: * @param simpleCS
58: */
59: protected void initializeCS(ISimpleCS simpleCS) {
60: ISimpleCSModelFactory factory = simpleCS.getModel()
61: .getFactory();
62:
63: // Element: intro
64: ISimpleCSIntro intro = factory.createSimpleCSIntro(simpleCS);
65: // Element: description
66: ISimpleCSDescription description = factory
67: .createSimpleCSDescription(intro);
68: description
69: .setContent(formatTextBold(PDEUIMessages.SimpleCheatSheetCreationOperation_0));
70: intro.setDescription(description);
71:
72: // Element: item
73: ISimpleCSItem item = factory.createSimpleCSItem(simpleCS);
74: item
75: .setTitle(PDEUIMessages.SimpleCheatSheetCreationOperation_1);
76: // Element: description
77: ISimpleCSDescription description2 = factory
78: .createSimpleCSDescription(item);
79: description2
80: .setContent(formatTextBold(PDEUIMessages.SimpleCheatSheetCreationOperation_2));
81: item.setDescription(description2);
82:
83: // Attribute: title
84: simpleCS
85: .setTitle(PDEUIMessages.SimpleCheatSheetCreationOperation_3);
86: simpleCS.setIntro(intro);
87: simpleCS.addItem(item);
88:
89: }
90: }
|