001: /*
002: * Copyright 2006 Pentaho Corporation. All rights reserved.
003: * This software was developed by Pentaho Corporation and is provided under the terms
004: * of the Mozilla Public License, Version 1.1, or any later version. You may not use
005: * this file except in compliance with the license. If you need a copy of the license,
006: * please go to http://www.mozilla.org/MPL/MPL-1.1.txt. The Original Code is the Pentaho
007: * BI Platform. The Initial Developer is Pentaho Corporation.
008: *
009: * Software distributed under the Mozilla Public License is distributed on an "AS IS"
010: * basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. Please refer to
011: * the license for the specific language governing your rights and limitations.
012: */
013: package org.pentaho.designstudio.controls;
014:
015: import java.util.ArrayList;
016: import java.util.List;
017:
018: import org.eclipse.jface.viewers.ILabelProviderListener;
019: import org.eclipse.jface.viewers.ITableLabelProvider;
020: import org.eclipse.swt.graphics.Image;
021: import org.pentaho.actionsequence.dom.AbstractIOElement;
022: import org.pentaho.actionsequence.dom.actions.ActionDefinition;
023:
024: /**
025: * Label provider for ActionOutputsViewer.
026: *
027: * @author Angelo Rodriguez
028: * @see ActionOutputsTable
029: */
030: public class ActionOutputsLabelProvider implements ITableLabelProvider {
031:
032: List listeners = new ArrayList();
033: ActionDefinition actionDefinition;
034:
035: private static final int OUTPUT_NAME_IDX = 0;
036: private static final int OUTPUT_TYPE_IDX = 1;
037:
038: /**
039: * Creates a label provider
040: * @param ioDescriptions a description of the outputs allowed within the action definition.
041: */
042: public ActionOutputsLabelProvider() {
043: super ();
044: }
045:
046: /* (non-Javadoc)
047: * @see org.eclipse.jface.viewers.ITableLabelProvider#getColumnImage(java.lang.Object, int)
048: */
049: public Image getColumnImage(Object element, int columnIndex) {
050: return null;
051: }
052:
053: /**
054: * Sets the action-definition for which output labels are being provided.
055: * @param actionDefinition the action definition.
056: */
057: public void setActionDefinition(ActionDefinition actionDefinition) {
058: this .actionDefinition = actionDefinition;
059: }
060:
061: /* (non-Javadoc)
062: * @see org.eclipse.jface.viewers.ITableLabelProvider#getColumnText(java.lang.Object, int)
063: */
064: public String getColumnText(Object element, int columnIndex) {
065: String columnText = ""; //$NON-NLS-1$
066: if (element instanceof AbstractIOElement) {
067: AbstractIOElement ioElement = (AbstractIOElement) element;
068: switch (columnIndex) {
069: case OUTPUT_NAME_IDX:
070: columnText = ioElement.getName();
071: break;
072: case OUTPUT_TYPE_IDX:
073: columnText = ioElement.getType();
074: break;
075: }
076: }
077: return columnText;
078: }
079:
080: /* (non-Javadoc)
081: * @see org.eclipse.jface.viewers.IBaseLabelProvider#addListener(org.eclipse.jface.viewers.ILabelProviderListener)
082: */
083: public void addListener(ILabelProviderListener listener) {
084: listeners.add(listener);
085: }
086:
087: /* (non-Javadoc)
088: * @see org.eclipse.jface.viewers.IBaseLabelProvider#dispose()
089: */
090: public void dispose() {
091: }
092:
093: /* (non-Javadoc)
094: * @see org.eclipse.jface.viewers.IBaseLabelProvider#isLabelProperty(java.lang.Object, java.lang.String)
095: */
096: public boolean isLabelProperty(Object element, String property) {
097: return true;
098: }
099:
100: /* (non-Javadoc)
101: * @see org.eclipse.jface.viewers.IBaseLabelProvider#removeListener(org.eclipse.jface.viewers.ILabelProviderListener)
102: */
103: public void removeListener(ILabelProviderListener listener) {
104: listeners.add(listener);
105: }
106:
107: }
|