1 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.jface.operation.IRunnableWithProgress; 17 import org.eclipse.pde.internal.core.cheatsheet.comp.CompCSWorkspaceModel; 18 import org.eclipse.pde.internal.core.icheatsheet.comp.ICompCS; 19 import org.eclipse.pde.internal.core.icheatsheet.comp.ICompCSConstants; 20 import org.eclipse.pde.internal.core.icheatsheet.comp.ICompCSIntro; 21 import org.eclipse.pde.internal.core.icheatsheet.comp.ICompCSModelFactory; 22 import org.eclipse.pde.internal.core.icheatsheet.comp.ICompCSObject; 23 import org.eclipse.pde.internal.core.icheatsheet.comp.ICompCSOnCompletion; 24 import org.eclipse.pde.internal.core.icheatsheet.comp.ICompCSTask; 25 import org.eclipse.pde.internal.core.icheatsheet.comp.ICompCSTaskGroup; 26 import org.eclipse.pde.internal.ui.PDEUIMessages; 27 28 32 public class CompCSCreationOperation extends BaseCSCreationOperation 33 implements IRunnableWithProgress { 34 35 38 public CompCSCreationOperation(IFile file) { 39 super(file); 40 } 41 42 45 public CompCSCreationOperation(ISchedulingRule rule) { 46 super(rule); 47 } 48 49 52 protected void createContent() { 53 CompCSWorkspaceModel model = new CompCSWorkspaceModel(fFile, false); 54 initializeCS(model.getCompCS()); 55 model.save(); 56 model.dispose(); 57 } 58 59 62 private void initializeCS(ICompCS compCS) { 63 ICompCSTaskGroup taskGroup = createBasicGroup(compCS); 66 ICompCSTask task = createBasicTask(taskGroup); 69 taskGroup.addFieldTaskObject(task); 71 compCS.setFieldName(PDEUIMessages.CompCSCreationOperation_title); 74 compCS.setFieldTaskObject(taskGroup); 75 } 76 77 81 public static ICompCSTask createBasicTask(ICompCSObject parent) { 82 ICompCSModelFactory factory = parent.getModel().getFactory(); 83 ICompCSTask task = factory.createCompCSTask(parent); 86 ICompCSIntro taskIntro = factory.createCompCSIntro(task); 89 taskIntro.setFieldContent( 90 formatTextBold(PDEUIMessages.CompCSCreationOperation_introduction)); 91 ICompCSOnCompletion taskConclusion = 93 factory.createCompCSOnCompletion(task); 94 taskConclusion.setFieldContent( 95 formatTextBold(PDEUIMessages.CompCSCreationOperation_conclusion)); 96 task.setFieldName(PDEUIMessages.CompCSCreationOperation_task); 98 task.setFieldKind(ICompCSConstants.ATTRIBUTE_VALUE_CHEATSHEET); 100 task.setFieldIntro(taskIntro); 101 task.setFieldOnCompletion(taskConclusion); 102 103 return task; 104 } 105 106 110 public static ICompCSTaskGroup createBasicGroup(ICompCSObject parent) { 111 ICompCSModelFactory factory = parent.getModel().getFactory(); 112 ICompCSTaskGroup taskGroup = factory.createCompCSTaskGroup(parent); 115 ICompCSIntro taskGroupIntro = factory.createCompCSIntro(taskGroup); 118 taskGroupIntro.setFieldContent( 119 formatTextBold(PDEUIMessages.CompCSCreationOperation_introduction)); 120 ICompCSOnCompletion taskGroupConclusion = 122 factory.createCompCSOnCompletion(taskGroup); 123 taskGroupConclusion.setFieldContent( 124 formatTextBold(PDEUIMessages.CompCSCreationOperation_conclusion)); 125 taskGroup.setFieldName(PDEUIMessages.CompCSCreationOperation_group); 127 taskGroup.setFieldKind(ICompCSConstants.ATTRIBUTE_VALUE_SET); 129 taskGroup.setFieldIntro(taskGroupIntro); 130 taskGroup.setFieldOnCompletion(taskGroupConclusion); 131 132 return taskGroup; 133 } 134 } 135 | Popular Tags |