1 /* 2 * Created on Jan 19, 2004 3 * 4 * Copyright (C) 2004 Sean Ruff 5 * 6 * This program is free software; you can redistribute it and/or 7 * modify it under the terms of the GNU General Public License 8 * as published by the Free Software Foundation; either version 2 9 * of the License, or (at your option) any later version. 10 * 11 * This program is distributed in the hope that it will be useful, 12 * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 * GNU General Public License for more details. 15 * 16 * You should have received a copy of the GNU General Public License 17 * along with this program; if not, write to the Free Software 18 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. 19 */ 20 package org.un4gvn.editorviewer.internal.element; 21 22 import org.eclipse.core.runtime.IAdaptable; 23 import org.eclipse.core.runtime.Platform; 24 import org.eclipse.swt.graphics.Image; 25 import org.eclipse.ui.IEditorPart; 26 import org.un4gvn.editorviewer.internal.Messages; 27 28 /*** 29 * Subclass of AbstractViewerElement to wrap IEditorReference objects 30 * <p> 31 * @author Sean Ruff 32 */ 33 34 public class EditorElement extends AbstractViewerElement implements IAdaptable { 35 36 private String _label = null; 37 private Image _image = null; 38 39 /*** 40 * IEditorReference to wrap 41 */ 42 private IEditorPart _part = null; 43 44 /*** 45 * Constructor 46 * @param parent 47 * @param ref 48 */ 49 public EditorElement(IViewerElement parent, Object id, IEditorPart part){ 50 super(parent,id); 51 _part = part; 52 _label = part.getTitle(); 53 } 54 55 /*** 56 * @see org.un4gvn.editorviewer.internal.element.IViewerElement#getLabel() 57 */ 58 public String getLabel(){ 59 if ( _part.isDirty() ) 60 return Messages.getString("EditorElement.0") + _label; //$NON-NLS-1$ 61 return _label; 62 } 63 64 /*** 65 * @see org.un4gvn.editorviewer.internal.element.IViewerElement#getImage() 66 */ 67 public Image getImage(){ 68 return _part.getTitleImage(); 69 } 70 71 /*** 72 * Retreive the underlying IEditorReference object 73 * @return IEditorReference 74 */ 75 public IEditorPart getEditorPart(){ 76 return _part; 77 } 78 79 /*** 80 * @see org.un4gvn.editorviewer.internal.element.IViewerElement#isLeaf() 81 */ 82 public boolean isLeaf(){ return true; } 83 84 /*** 85 * @see org.un4gvn.editorviewer.internal.element.IViewerElement#getAdapter(java.lang.Class) 86 */ 87 public Object getAdapter(Class objClass){ 88 Object res = _part.getEditorInput().getAdapter(objClass); 89 if ( res != null ) 90 return res; 91 return Platform.getAdapterManager().getAdapter(_part,objClass); 92 } 93 94 95 }

This page was automatically generated by Maven