1 11 package org.eclipse.ui.internal.part.services; 12 13 import org.eclipse.core.runtime.IProgressMonitor; 14 import org.eclipse.core.runtime.NullProgressMonitor; 15 import org.eclipse.jface.action.IStatusLineManager; 16 import org.eclipse.jface.resource.ImageDescriptor; 17 import org.eclipse.swt.graphics.Image; 18 import org.eclipse.ui.internal.part.components.services.IStatusFactory; 19 import org.eclipse.ui.internal.part.components.services.IStatusHandler; 20 21 26 public class StatusLineManagerAdapter extends NullContributionManager implements 27 IStatusLineManager { 28 29 private IStatusHandler handler; 30 private IStatusFactory factory; 31 32 private String currentError; 33 private Image currentErrorImage; 34 private String currentMessage; 35 private Image currentMessageImage; 36 37 public StatusLineManagerAdapter(IStatusHandler handler, IStatusFactory factory) { 38 this.handler = handler; 39 this.factory = factory; 40 } 41 42 public IProgressMonitor getProgressMonitor() { 43 return new NullProgressMonitor(); 44 } 45 46 public boolean isCancelEnabled() { 47 return false; 48 } 49 50 public void setCancelEnabled(boolean enabled) { 51 } 52 53 public void setErrorMessage(String message) { 54 setErrorMessage(null, message); 55 } 56 57 public void setErrorMessage(Image image, String message) { 58 currentErrorImage = image; 59 currentError = message; 60 updateHandler(); 61 } 62 63 public void setMessage(String message) { 64 setMessage(null, message); 65 } 66 67 public void setMessage(Image image, String message) { 68 currentMessageImage = image; 69 currentMessage = message; 70 updateHandler(); 71 } 72 73 private void updateHandler() { 74 if (currentError != null) { 75 handler.set(factory.newError(currentError, null), currentErrorImage == null ? null : 76 ImageDescriptor.createFromImage(currentErrorImage)); 77 return; 78 } 79 80 if (currentMessage != null) { 81 handler.set(factory.newMessage(currentMessage), currentMessageImage == null ? null : 82 ImageDescriptor.createFromImage(currentMessageImage)); 83 return; 84 } 85 86 handler.set(null, null); 87 } 88 89 } 90 | Popular Tags |