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.editors.actionsequence.pages.actions.details;
014:
015: import org.eclipse.swt.layout.GridData;
016: import org.eclipse.swt.layout.GridLayout;
017: import org.eclipse.swt.widgets.Composite;
018: import org.pentaho.actionsequence.dom.AbstractIOElement;
019: import org.pentaho.actionsequence.dom.ActionInput;
020: import org.pentaho.actionsequence.dom.ActionOutput;
021: import org.pentaho.actionsequence.dom.ActionSequenceDocument;
022: import org.pentaho.actionsequence.dom.ActionSequenceInput;
023: import org.pentaho.actionsequence.dom.IActionSequenceElement;
024: import org.pentaho.actionsequence.dom.actions.SharkWorkflowAction;
025: import org.pentaho.designstudio.controls.ActionInputCheckBox;
026: import org.pentaho.designstudio.controls.ActionInputCombo;
027: import org.pentaho.designstudio.controls.ActionInputsList;
028: import org.pentaho.designstudio.controls.ActionInputsListToolbar;
029: import org.pentaho.designstudio.controls.WidgetFactory;
030: import org.pentaho.designstudio.editors.actionsequence.pages.actions.IActionIOFilter;
031: import org.pentaho.designstudio.messages.Messages;
032:
033: /**
034: * The template describing the action definition used to submit shark workflow requests.
035: *
036: * @author Angelo Rodriguez
037: */
038: public class SharkWorkflowDetailsPage extends ActionDetailsPage
039: implements IActionIOFilter {
040:
041: public static final String DISPLAY_NAME = Messages
042: .getString("SharkWorkflowDetailsPage.UI_COMPONENT_NAME_SHARK_WORKFLOW"); //$NON-NLS-1$
043:
044: ActionInputCombo packageName;
045: ActionInputCombo processName;
046: ActionInputsList paramList;
047: ActionInputsListToolbar paramListToolbar;
048: ActionInputCheckBox newInstanceButton;
049:
050: /**
051: * Creates a shark workflow template.
052: */
053: public SharkWorkflowDetailsPage() {
054: super ();
055: }
056:
057: /* (non-Javadoc)
058: * @see org.pentaho.designstudio.editors.actionsequence.pages.actions.templates.ActionDefinitionTemplate#getComponentClassName()
059: */
060: public String getComponentName() {
061: return SharkWorkflowAction.COMPONENT_NAME;
062: }
063:
064: /* (non-Javadoc)
065: * @see org.pentaho.designstudio.editors.actionsequence.pages.actions.templates.ActionDefinitionTemplate#getDisplayName()
066: */
067: public String getName() {
068: return DISPLAY_NAME;
069: }
070:
071: public void createDetailsComposite(Composite parent) {
072: Composite actionConfigComposite = parent;
073:
074: GridLayout gridLayout = new GridLayout(1, true);
075: gridLayout.horizontalSpacing = 20;
076: actionConfigComposite.setLayout(gridLayout);
077:
078: WidgetFactory
079: .createLabel(
080: actionConfigComposite,
081: Messages
082: .getString("SharkWorkflowDetailsPage.UI_PACKAGE_NAME_LABEL")); //$NON-NLS-1$
083:
084: packageName = new ActionInputCombo(actionConfigComposite,
085: new GridData(GridData.FILL_HORIZONTAL));
086:
087: WidgetFactory.createLabel(actionConfigComposite, ""); //$NON-NLS-1$
088:
089: WidgetFactory
090: .createLabel(
091: actionConfigComposite,
092: Messages
093: .getString("SharkWorkflowDetailsPage.UI_PROCESS_NAME_LABEL")); //$NON-NLS-1$
094:
095: processName = new ActionInputCombo(actionConfigComposite,
096: new GridData(GridData.FILL_HORIZONTAL));
097:
098: WidgetFactory.createLabel(actionConfigComposite, ""); //$NON-NLS-1$
099:
100: Composite composite = WidgetFactory
101: .createComposite(actionConfigComposite);
102: gridLayout = new GridLayout(2, false);
103: gridLayout.marginWidth = 0;
104: gridLayout.marginHeight = 0;
105: composite.setLayout(gridLayout);
106: composite.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
107: WidgetFactory
108: .createLabel(
109: composite,
110: Messages
111: .getString("SharkWorkflowDetailsPage.UI_WORKFLOW_INPUTS_LABEL")); //$NON-NLS-1$
112:
113: paramList = new ActionInputsList(actionConfigComposite);
114: GridData gridData = new GridData(GridData.FILL_HORIZONTAL);
115: gridData.heightHint = 150;
116: paramList.getList().setLayoutData(gridData);
117: paramList.setFilter(this );
118:
119: paramListToolbar = new ActionInputsListToolbar(composite,
120: paramList);
121: gridData = new GridData(GridData.FILL_HORIZONTAL);
122: gridData.horizontalAlignment = GridData.END;
123: paramListToolbar.getControl().setLayoutData(gridData);
124:
125: WidgetFactory.createLabel(actionConfigComposite, ""); //$NON-NLS-1$
126:
127: newInstanceButton = new ActionInputCheckBox(
128: Messages
129: .getString("SharkWorkflowDetailsPage.UI_CREATE_NEW_RUNTIME_LABEL"), actionConfigComposite, new GridData(GridData.FILL_HORIZONTAL)); //$NON-NLS-1$
130: }
131:
132: public void refresh() {
133: super .refresh();
134: packageName.setTargetInput(actionDefinition,
135: SharkWorkflowAction.PACKAGE_NAME_ELEMENT,
136: ActionSequenceDocument.STRING_TYPE);
137: processName.setTargetInput(actionDefinition,
138: SharkWorkflowAction.PROCESS_NAME_ELEMENT,
139: ActionSequenceDocument.STRING_TYPE);
140: paramList.setInput(actionDefinition);
141: newInstanceButton.setTargetInput(actionDefinition,
142: SharkWorkflowAction.NEW_INSTANCE_ELEMENT);
143: paramListToolbar.refresh();
144: }
145:
146: public boolean accept(AbstractIOElement ioElement) {
147: String name = null;
148: if ((ioElement instanceof ActionSequenceInput)
149: || (ioElement instanceof ActionInput)) {
150: name = ioElement.getName();
151: } else if (ioElement instanceof ActionOutput) {
152: name = ((ActionOutput) ioElement).getPublicName();
153: }
154: return !SharkWorkflowAction.PROCESS_NAME_ELEMENT.equals(name)
155: && !SharkWorkflowAction.PACKAGE_NAME_ELEMENT
156: .equals(name)
157: && !SharkWorkflowAction.NEW_INSTANCE_ELEMENT
158: .equals(name);
159: }
160:
161: public boolean accepts(IActionSequenceElement actionDef) {
162: return actionDef instanceof SharkWorkflowAction;
163: }
164: }
|