01: /*
02: * Copyright 2006 Pentaho Corporation. All rights reserved.
03: * This software was developed by Pentaho Corporation and is provided under the terms
04: * of the Mozilla Public License, Version 1.1, or any later version. You may not use
05: * this file except in compliance with the license. If you need a copy of the license,
06: * please go to http://www.mozilla.org/MPL/MPL-1.1.txt. The Original Code is the Pentaho
07: * BI Platform. The Initial Developer is Pentaho Corporation.
08: *
09: * Software distributed under the Mozilla Public License is distributed on an "AS IS"
10: * basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. Please refer to
11: * the license for the specific language governing your rights and limitations.
12: */
13: package org.pentaho.designstudio.widgets.flowtable;
14:
15: import org.eclipse.swt.graphics.Image;
16: import org.pentaho.actionsequence.dom.AbstractIOElement;
17: import org.pentaho.actionsequence.dom.ActionOutput;
18: import org.pentaho.actionsequence.dom.actions.ActionDefinition;
19: import org.pentaho.designstudio.editors.actionsequence.pages.ActionSequenceLabelProvider;
20: import org.pentaho.designstudio.messages.Messages;
21:
22: public class ActionContent extends FlowContent {
23:
24: ActionDefinition actionDef;
25:
26: public ActionContent(ActionDefinition actionDefinition,
27: int indentLevel) {
28: super (indentLevel);
29: actionDef = actionDefinition;
30: // TODO Auto-generated constructor stub
31: }
32:
33: public Image getImage() {
34: return null;
35: }
36:
37: public String getName() {
38: String text = actionDef.getDescription();
39: if ((text == null) || (text.trim().length() == 0)) {
40: String name = actionDef.getComponentName();
41: if (name.length() > 0) {
42: text = name;
43: int index = name.lastIndexOf("."); //$NON-NLS-1$
44: if ((index >= 0) && ((index + 1) < name.length())) {
45: String subStr = text.substring(index + 1).trim();
46: if (subStr.length() > 0) {
47: text = subStr;
48: }
49: }
50: }
51: }
52: if ((text == null) || (text.trim().length() == 0)) {
53: text = Messages
54: .getString("ActionContent.UNKNOWN_ACTION_DEFINITION"); //$NON-NLS-1$
55: }
56: return text;
57: }
58:
59: public AbstractIOElement[] getParameters() {
60: return actionDef.getAllOutputParams();
61: }
62:
63: public String getDescription() {
64: String description = getName();
65: ActionOutput[] actionOutputs = actionDef.getAllOutputParams();
66: for (int j = 0; j < actionOutputs.length; ++j) {
67: description += '\n' + ActionSequenceLabelProvider
68: .getText(actionOutputs[j]);
69: }
70: return description;
71: }
72:
73: public boolean equals(Object arg0) {
74: return (arg0 != null) && (arg0.getClass() == getClass())
75: && ((ActionContent) arg0).actionDef.equals(actionDef);
76: }
77:
78: public Object getData() {
79: return actionDef;
80: }
81:
82: }
|