1 package net.sourceforge.phpdt.sql.view;
5 import org.eclipse.jface.resource.ImageDescriptor;
6 import org.eclipse.jface.viewers.ILabelProvider;
7 import org.eclipse.jface.viewers.ILabelProviderListener;
8 import org.eclipse.swt.graphics.Image;
10 import net.sourceforge.phpdt.sql.Messages;
11 import net.sourceforge.phpdt.sql.PHPEclipseSQLPlugin;
12 import net.sourceforge.phpdt.sql.view.bookmark.ColumnMetaData;
13 import net.sourceforge.phpdt.sql.view.bookmark.Root;
14 import net.sourceforge.phpdt.sql.view.bookmark.SequenceNode;
15 import net.sourceforge.phpdt.sql.view.bookmark.SubsetNode;
16 import net.sourceforge.phpdt.sql.view.bookmark.TableNode;
17 import net.sourceforge.phpdt.sql.view.bookmark.ViewNode;
22 * Implements the ILabelProvider for the Bookmarks.
24 public class SubsetLabelProvider implements ILabelProvider {
26 * @see org.eclipse.jface.viewers.ILabelProvider#getImage(Object)
28 public Image getImage(Object element) {
29 ImageDescriptor descriptor = null;
30 if (element instanceof SubsetNode) {
32 URL installURL = PHPEclipseSQLPlugin.getDefault().getDescriptor().getInstallURL();
33 URL url = new URL(installURL, "icons/subset.gif"); //$NON-NLS-1$
34 descriptor = ImageDescriptor.createFromURL(url);
35 } catch (Exception e) {
38 } else if (element instanceof ColumnMetaData){
40 ColumnMetaData columnMetaData = (ColumnMetaData) element;
41 return columnMetaData.getImage();
42 } catch (Exception e) {
48 return descriptor.createImage();
52 * @see org.eclipse.jface.viewers.ILabelProvider#getText(Object)
54 public String getText(Object element) {
55 if (element instanceof SubsetNode) {
56 SubsetNode subset = (SubsetNode) element;
57 return subset.getName();
58 } else if (element.equals(Root.ROOT)) {
59 return "ROOT"; //$NON-NLS-1$
60 } else if (element instanceof TableNode) {
61 TableNode node = (TableNode) element;
62 if (node.isSizeVisible()) {
63 return Messages.getString("BookmarkLabelProvider.TablePrefix") + element.toString() + " (" + node.getSize() + ")"; //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
65 return Messages.getString("BookmarkLabelProvider.TablePrefix") + element.toString(); //$NON-NLS-1$
67 } else if (element instanceof ViewNode) {
68 ViewNode node = (ViewNode) element;
69 if (node.isSizeVisible()) {
70 return Messages.getString("BookmarkLabelProvider.ViewPrefix") + element.toString() + " (" + node.getSize() + ")"; //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
72 return Messages.getString("BookmarkLabelProvider.ViewPrefix") + element.toString(); //$NON-NLS-1$
74 } else if (element instanceof SequenceNode) {
75 return Messages.getString("BookmarkLabelProvider.SequencePrefix") + element.toString(); //$NON-NLS-1$
77 return element.toString();
81 * @see org.eclipse.jface.viewers.IBaseLabelProvider#addListener(ILabelProviderListener)
83 public void addListener(ILabelProviderListener listener) {
87 * @see org.eclipse.jface.viewers.IBaseLabelProvider#dispose()
89 public void dispose() {
93 * @see org.eclipse.jface.viewers.IBaseLabelProvider#isLabelProperty(Object, String)
95 public boolean isLabelProperty(Object element, String property) {
100 * @see org.eclipse.jface.viewers.IBaseLabelProvider#removeListener(ILabelProviderListener)
102 public void removeListener(ILabelProviderListener listener) {