| 1 | /******************************************************************************* |
| 2 | * Copyright (c) 2003, 2007 IBM Corporation and others. |
| 3 | * All rights reserved. This program and the accompanying materials |
| 4 | * are made available under the terms of the Eclipse Public License v1.0 |
| 5 | * which accompanies this distribution, and is available at |
| 6 | * http://www.eclipse.org/legal/epl-v10.html |
| 7 | * |
| 8 | * Contributors: |
| 9 | * IBM Corporation - initial API and implementation |
| 10 | *******************************************************************************/ |
| 11 | package org.eclipse.ui.internal.progress; |
| 12 | |
| 13 | import org.eclipse.swt.graphics.Image; |
| 14 | |
| 15 | /** |
| 16 | * The JobTreeElement is the abstract superclass of items displayed in the tree. |
| 17 | */ |
| 18 | abstract class JobTreeElement implements Comparable { |
| 19 | |
| 20 | /** |
| 21 | * Return the parent of this object. |
| 22 | * |
| 23 | * @return Object |
| 24 | */ |
| 25 | abstract Object getParent(); |
| 26 | |
| 27 | /** |
| 28 | * Return whether or not the receiver has children. |
| 29 | * |
| 30 | * @return boolean |
| 31 | */ |
| 32 | abstract boolean hasChildren(); |
| 33 | |
| 34 | /** |
| 35 | * Return the children of the receiver. |
| 36 | * |
| 37 | * @return Object[] |
| 38 | */ |
| 39 | abstract Object[] getChildren(); |
| 40 | |
| 41 | /** |
| 42 | * Return the displayString for the receiver. |
| 43 | * |
| 44 | * @return String |
| 45 | */ |
| 46 | abstract String getDisplayString(); |
| 47 | |
| 48 | /** |
| 49 | * Return the displayString for the receiver. |
| 50 | * |
| 51 | * @param showProgress |
| 52 | * Whether or not progress is being shown (if relevant). |
| 53 | * @return String |
| 54 | */ |
| 55 | String getDisplayString(boolean showProgress) { |
| 56 | return getDisplayString(); |
| 57 | } |
| 58 | |
| 59 | /** |
| 60 | * Get the image for the reciever. By default there is no image. |
| 61 | * |
| 62 | * @return Image or <code>null</code>. |
| 63 | */ |
| 64 | public Image getDisplayImage() { |
| 65 | return null; |
| 66 | } |
| 67 | |
| 68 | /** |
| 69 | * Return the condensed version of the display string |
| 70 | * |
| 71 | * @return String |
| 72 | */ |
| 73 | String getCondensedDisplayString() { |
| 74 | return getDisplayString(); |
| 75 | } |
| 76 | |
| 77 | /** |
| 78 | * Return whether or not the receiver is an info. |
| 79 | * |
| 80 | * @return boolean |
| 81 | */ |
| 82 | abstract boolean isJobInfo(); |
| 83 | |
| 84 | /* |
| 85 | * (non-Javadoc) |
| 86 | * |
| 87 | * @see java.lang.Comparable#compareTo(java.lang.Object) |
| 88 | */ |
| 89 | public int compareTo(Object arg0) { |
| 90 | if (arg0 instanceof JobTreeElement) |
| 91 | return getDisplayString().compareTo( |
| 92 | ((JobTreeElement) arg0).getDisplayString()); |
| 93 | return 0; |
| 94 | } |
| 95 | |
| 96 | /** |
| 97 | * Return whether or not this is currently active. |
| 98 | * |
| 99 | * @return boolean |
| 100 | */ |
| 101 | abstract boolean isActive(); |
| 102 | |
| 103 | /** |
| 104 | * Return whether or not the receiver can be cancelled. |
| 105 | * |
| 106 | * @return boolean |
| 107 | */ |
| 108 | public boolean isCancellable() { |
| 109 | return false; |
| 110 | } |
| 111 | |
| 112 | /** |
| 113 | * Cancel the receiver. |
| 114 | */ |
| 115 | public void cancel() { |
| 116 | // By default do nothing. |
| 117 | } |
| 118 | } |