KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > eclipse > pde > internal > ui > editor > cheatsheet > comp > actions > CompCSAbstractAddAction


1 /*******************************************************************************
2  * Copyright (c) 2006 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.editor.cheatsheet.comp.actions;
13
14 import java.util.HashSet JavaDoc;
15
16 import org.eclipse.pde.internal.core.icheatsheet.comp.ICompCSObject;
17 import org.eclipse.pde.internal.core.icheatsheet.comp.ICompCSTaskGroup;
18 import org.eclipse.pde.internal.core.icheatsheet.comp.ICompCSTaskObject;
19 import org.eclipse.pde.internal.ui.editor.cheatsheet.CSAbstractAddAction;
20
21 /**
22  * SimpleCSAddStepAction
23  *
24  */

25 public abstract class CompCSAbstractAddAction extends CSAbstractAddAction {
26
27     protected ICompCSObject fParentObject;
28     
29     /**
30      *
31      */

32     public CompCSAbstractAddAction() {
33         // NO-OP
34
}
35
36     /**
37      * @param cheatsheet
38      */

39     public void setParentObject(ICompCSObject object) {
40         fParentObject = object;
41     }
42     
43     /**
44      * @return
45      */

46     protected String JavaDoc generateTaskObjectName(ICompCSTaskGroup parent, String JavaDoc base) {
47         StringBuffer JavaDoc result = new StringBuffer JavaDoc(base);
48         ICompCSTaskObject[] taskObjects = parent.getFieldTaskObjects();
49         // Used to track auto-generated numbers used
50
HashSet JavaDoc set = new HashSet JavaDoc();
51
52         // Linear search O(n).
53
// Performance hit unnoticeable because number of items per cheatsheet
54
// should be minimal.
55
for (int i = 0; i < taskObjects.length; i++) {
56             compareTitleWithBase(base, set, taskObjects[i].getFieldName());
57         }
58         // Add an auto-generated number
59
addNumberToBase(result, set);
60         
61         return result.toString();
62     }
63 }
64
Popular Tags