1 9 10 package org.eclipse.ui.internal.navigator; 11 12 import org.eclipse.jface.viewers.ViewerLabel; 13 14 20 public class ReusableViewerLabel extends ViewerLabel { 21 22 private ViewerLabel original = null; 23 27 public ReusableViewerLabel() { 28 super(null, null); 29 } 30 31 32 38 public void reset(ViewerLabel theOriginal) { 39 original = theOriginal; 40 setBackground(original.getBackground()); 41 setFont(original.getFont()); 42 setForeground(original.getForeground()); 43 setImage(null); 44 setText(null); 45 } 46 47 51 public void fill(ViewerLabel theOriginal) { 52 53 theOriginal.setBackground(getBackground()); 54 theOriginal.setFont(getFont()); 55 theOriginal.setForeground(getForeground()); 56 theOriginal.setImage(getImage()); 57 theOriginal.setText(getText() != null ? getText() : ""); } 59 60 65 public boolean hasChanged() { 66 67 boolean changed = false; 68 if(original != null) { 69 if(original.getText() == null ^ getText() != null) 70 changed |= getText() != null; 71 if(original.getText() != null && getImage() != null) 72 changed |= !getImage().equals(original.getImage()); 73 } 74 return changed; 75 } 76 77 80 public boolean isValid() { 81 return getText() != null && getText().length() > 0 && getImage() != null; 82 83 } 84 85 } 86 | Popular Tags |