1 11 12 package org.eclipse.pde.internal.ui.editor.cheatsheet.simple; 13 14 import java.util.List ; 15 16 import org.eclipse.jface.viewers.ILabelProvider; 17 import org.eclipse.pde.internal.core.icheatsheet.simple.ISimpleCSConstants; 18 import org.eclipse.pde.internal.core.icheatsheet.simple.ISimpleCSModel; 19 import org.eclipse.pde.internal.core.icheatsheet.simple.ISimpleCSObject; 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 SimpleCSFormOutlinePage extends FormOutlinePage { 29 30 33 public SimpleCSFormOutlinePage(PDEFormEditor editor) { 34 super(editor); 35 } 36 37 41 public class SimpleCSLabelProvider extends BasicLabelProvider { 42 public String getText(Object obj) { 43 if (obj instanceof ISimpleCSObject) { 44 return getObjectText((ISimpleCSObject)obj); 45 } 46 return super.getText(obj); 47 } 48 } 49 50 54 protected String getObjectText(ISimpleCSObject obj) { 55 int limit = 50; 56 57 if (obj.getType() == ISimpleCSConstants.TYPE_CHEAT_SHEET) { 58 limit = 30; 59 } else if (obj.getType() == ISimpleCSConstants.TYPE_ITEM) { 60 limit = 26; 61 } else if (obj.getType() == ISimpleCSConstants.TYPE_INTRO) { 62 limit = 26; 63 } else if (obj.getType() == ISimpleCSConstants.TYPE_SUBITEM) { 64 limit = 22; 65 } 66 67 return PDETextHelper.truncateAndTrailOffText( 68 PDETextHelper.translateReadText(obj.getName()), limit); 69 } 70 71 74 protected Object [] getChildren(Object parent) { 75 if (parent instanceof SimpleCSPage) { 76 ISimpleCSModel cheatsheet = (ISimpleCSModel)fEditor.getAggregateModel(); 77 if ((cheatsheet != null) 78 && cheatsheet.isLoaded()) { 79 Object [] list = new Object [1]; 80 list[0] = cheatsheet.getSimpleCS(); 81 return list; 82 } 83 } else if (parent instanceof ISimpleCSObject) { 84 List list = ((ISimpleCSObject)parent).getChildren(); 85 if (list.size() > 0) { 87 return list.toArray(); 88 } 89 } 90 return super.getChildren(parent); 91 } 92 93 96 public ILabelProvider createLabelProvider() { 97 return new SimpleCSLabelProvider(); 98 } 99 100 103 protected String getParentPageId(Object item) { 104 return SimpleCSPage.PAGE_ID; 105 } 106 107 } 108 | Popular Tags |