1 11 12 package org.eclipse.pde.internal.ui.editor.cheatsheet.comp; 13 14 import java.util.List ; 15 16 import org.eclipse.jface.viewers.ILabelProvider; 17 import org.eclipse.pde.internal.core.icheatsheet.comp.ICompCSConstants; 18 import org.eclipse.pde.internal.core.icheatsheet.comp.ICompCSModel; 19 import org.eclipse.pde.internal.core.icheatsheet.comp.ICompCSObject; 20 import org.eclipse.pde.internal.core.util.PDETextHelper; 21 import org.eclipse.pde.internal.ui.editor.FormOutlinePage; 22 import org.eclipse.pde.internal.ui.editor.PDEFormEditor; 23 24 28 public class CompCSFormOutlinePage extends FormOutlinePage { 29 30 33 public CompCSFormOutlinePage(PDEFormEditor editor) { 34 super(editor); 35 } 36 37 41 private class CompCSLabelProvider extends BasicLabelProvider { 42 public String getText(Object obj) { 43 if (obj instanceof ICompCSObject) { 44 return getObjectText((ICompCSObject)obj); 45 } 46 return super.getText(obj); 47 } 48 } 49 50 54 protected String getObjectText(ICompCSObject obj) { 55 int limit = 50; 56 57 if (obj.getType() == ICompCSConstants.TYPE_COMPOSITE_CHEATSHEET) { 58 limit = 30; 59 } else if (obj.getType() == ICompCSConstants.TYPE_TASK) { 60 limit = 26; 61 } else if (obj.getType() == ICompCSConstants.TYPE_TASKGROUP) { 62 limit = 22; 63 } 64 65 return PDETextHelper.truncateAndTrailOffText( 66 PDETextHelper.translateReadText(obj.getName()), limit); 67 } 68 69 72 protected Object [] getChildren(Object parent) { 73 if (parent instanceof CompCSPage) { 74 ICompCSModel cheatsheet = (ICompCSModel)fEditor.getAggregateModel(); 75 if ((cheatsheet != null) 76 && cheatsheet.isLoaded()) { 77 Object [] list = new Object [1]; 78 list[0] = cheatsheet.getCompCS(); 79 return list; 80 } 81 } else if (parent instanceof ICompCSObject) { 82 List list = ((ICompCSObject)parent).getChildren(); 83 if (list.size() > 0) { 85 return list.toArray(); 86 } 87 } 88 return super.getChildren(parent); 89 } 90 91 94 public ILabelProvider createLabelProvider() { 95 return new CompCSLabelProvider(); 96 } 97 98 101 protected String getParentPageId(Object item) { 102 return CompCSPage.PAGE_ID; 103 } 104 105 } 106 | Popular Tags |