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: /*
14: * Copyright (C) 2004 by Friederich Kupzog Elektronik & Software
15: * All rights reserved. This program and the accompanying materials
16: * are made available under the terms of the Eclipse Public License v1.0
17: * which accompanies this distribution, and is available at
18: * http://www.eclipse.org/legal/epl-v10.html
19:
20: Author: Friederich Kupzog
21: fkmk@kupzog.de
22: www.kupzog.de/fkmk
23: */
24: package org.pentaho.designstudio.widgets.flowtable;
25:
26: import org.eclipse.swt.graphics.Image;
27: import org.eclipse.swt.graphics.Point;
28: import org.eclipse.swt.graphics.Rectangle;
29: import org.pentaho.actionsequence.dom.AbstractIOElement;
30: import org.pentaho.designstudio.messages.Messages;
31:
32: /**
33: * Wrapper for Image with text.
34: * @author Friederich Kupzog
35: */
36: public abstract class FlowContent {
37: static final String FLOW_ICON_DIR = Messages
38: .getString("ActionsContent.ICON_FLOW_ICON_DIR"); //$NON-NLS-1$
39:
40: public int indentLevel;
41: public Rectangle textBox = null;
42:
43: public FlowContent() {
44: this (0);
45: }
46:
47: public FlowContent(int indentLevel) {
48: this .indentLevel = indentLevel;
49: }
50:
51: AbstractIOElement getSelectedParameter(Point pt) {
52: AbstractIOElement[] parameters = getParameters();
53: if ((parameters != null) && (parameters.length > 0)) {
54: if (textBox.contains(pt)) {
55: int yOffset = pt.y - textBox.y;
56: int pixelsPerRow = textBox.height
57: / (parameters.length + 2);
58: int row = yOffset / pixelsPerRow;
59: if (row > 1) {
60: return (parameters[row - 2]);
61: }
62: }
63: }
64: return (null);
65: }
66:
67: public String toString() {
68: return getName();
69: }
70:
71: public abstract Image getImage();
72:
73: public abstract String getName();
74:
75: public abstract AbstractIOElement[] getParameters();
76:
77: public abstract String getDescription();
78:
79: public abstract Object getData();
80: }
|