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.scheduling;
014:
015: import java.util.Arrays;
016:
017: import org.eclipse.swt.SWT;
018: import org.eclipse.swt.custom.StackLayout;
019: import org.eclipse.swt.events.SelectionEvent;
020: import org.eclipse.swt.events.SelectionListener;
021: import org.eclipse.swt.layout.GridData;
022: import org.eclipse.swt.layout.GridLayout;
023: import org.eclipse.swt.widgets.Button;
024: import org.eclipse.swt.widgets.Composite;
025: import org.pentaho.actionsequence.dom.AbstractIOElement;
026: import org.pentaho.actionsequence.dom.ActionInput;
027: import org.pentaho.actionsequence.dom.ActionOutput;
028: import org.pentaho.actionsequence.dom.ActionSequenceDocument;
029: import org.pentaho.actionsequence.dom.ActionSequenceInput;
030: import org.pentaho.actionsequence.dom.IActionSequenceElement;
031: import org.pentaho.actionsequence.dom.actions.StartScheduledJobAction;
032: import org.pentaho.designstudio.controls.ActionInputCombo;
033: import org.pentaho.designstudio.controls.ActionInputsList;
034: import org.pentaho.designstudio.controls.ActionInputsListToolbar;
035: import org.pentaho.designstudio.controls.NewActionInputCombo;
036: import org.pentaho.designstudio.controls.WidgetFactory;
037: import org.pentaho.designstudio.editors.actionsequence.pages.actions.IActionIOFilter;
038: import org.pentaho.designstudio.messages.Messages;
039:
040: public class StartScheduledJobDetailsPage extends
041: AbstractScheduledJobDetailsPage implements IActionIOFilter,
042: SelectionListener {
043:
044: StackLayout stackLayout;
045: Composite stackedComposite;
046: Button cronTriggerRadioButton;
047: Button simpleTriggerRadioButton;
048: NewActionInputCombo cronValue;
049: NewActionInputCombo intervalValue;
050: NewActionInputCombo countValue;
051: Composite simpleComposite;
052: Composite cronComposite;
053: NewActionInputCombo solutionName;
054: NewActionInputCombo solutionSubdir;
055: NewActionInputCombo xactionName;
056: NewActionInputCombo triggerName;
057: ActionInputsList jobInputsList;
058: ActionInputsListToolbar jobInputsToolbar;
059:
060: public String getName() {
061: return Messages
062: .getString("StartScheduledJobDetailsPage.UI_START_SCHED_JOB_TITLE"); //$NON-NLS-1$
063: }
064:
065: public void createDetailsComposite(Composite parent) {
066: Composite actionConfigComposite = parent;
067:
068: GridLayout gridLayout = new GridLayout(3, true);
069: gridLayout.horizontalSpacing = 10;
070: actionConfigComposite.setLayout(gridLayout);
071:
072: GridData gridData = new GridData();
073: gridData.horizontalSpan = 2;
074: WidgetFactory
075: .createLabel(
076: actionConfigComposite,
077: Messages
078: .getString("AbstractScheduledJobDetailsPage.UI_JOB_NAME_LABEL")).setLayoutData(gridData); //$NON-NLS-1$
079:
080: Composite composite = WidgetFactory
081: .createComposite(actionConfigComposite);
082: gridLayout = new GridLayout(2, false);
083: gridLayout.marginWidth = 0;
084: gridLayout.marginHeight = 0;
085: composite.setLayout(gridLayout);
086: composite.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
087: WidgetFactory.createLabel(composite, Messages
088: .getString("StartScheduledJobDetailsPage.JOB_INPUTS")); //$NON-NLS-1$
089:
090: gridData = new GridData(GridData.FILL_HORIZONTAL);
091: gridData.horizontalSpan = 2;
092: jobNameComboBox = new NewActionInputCombo(
093: actionConfigComposite, gridData);
094:
095: jobInputsList = new ActionInputsList(actionConfigComposite);
096: gridData = new GridData(GridData.FILL_HORIZONTAL);
097: gridData.verticalAlignment = SWT.FILL;
098: gridData.verticalSpan = 4;
099: jobInputsList.getControl().setLayoutData(gridData);
100: jobInputsList.setFilter(this );
101:
102: jobInputsToolbar = new ActionInputsListToolbar(composite,
103: jobInputsList);
104: gridData = new GridData(GridData.FILL_HORIZONTAL);
105: gridData.horizontalAlignment = GridData.END;
106: jobInputsToolbar.getControl().setLayoutData(gridData);
107:
108: gridData = new GridData(GridData.FILL_HORIZONTAL);
109: gridData.horizontalSpan = 2;
110: WidgetFactory
111: .createLabel(actionConfigComposite, "").setLayoutData(gridData); //$NON-NLS-1$
112:
113: gridData = new GridData(GridData.FILL_HORIZONTAL);
114: gridData.horizontalSpan = 2;
115: WidgetFactory
116: .createLabel(
117: actionConfigComposite,
118: Messages
119: .getString("StartScheduledJobDetailsPage.UI_JOB_DESCRIPT_LABEL")).setLayoutData(gridData); //$NON-NLS-1$
120:
121: composite = WidgetFactory.createComposite(
122: actionConfigComposite, SWT.BORDER);
123: composite.setLayout(new GridLayout());
124: gridData = new GridData(GridData.FILL_HORIZONTAL);
125: gridData.horizontalSpan = 2;
126: composite.setLayoutData(gridData);
127:
128: WidgetFactory
129: .createLabel(
130: composite,
131: Messages
132: .getString("StartScheduledJobDetailsPage.UI_SOLUTION_NAME_LABEL")); //$NON-NLS-1$
133: solutionName = new NewActionInputCombo(composite, new GridData(
134: GridData.FILL_HORIZONTAL));
135:
136: WidgetFactory
137: .createLabel(
138: composite,
139: Messages
140: .getString("StartScheduledJobDetailsPage.UI_SOLUTION_DIR_LABEL")); //$NON-NLS-1$
141: solutionSubdir = new NewActionInputCombo(composite,
142: new GridData(GridData.FILL_HORIZONTAL));
143:
144: WidgetFactory
145: .createLabel(
146: composite,
147: Messages
148: .getString("StartScheduledJobDetailsPage.UI_XACTION_FILE_LABEL")); //$NON-NLS-1$
149: xactionName = new NewActionInputCombo(composite, new GridData(
150: GridData.FILL_HORIZONTAL));
151:
152: gridData = new GridData(GridData.FILL_HORIZONTAL);
153: gridData.horizontalSpan = 3;
154: WidgetFactory
155: .createLabel(actionConfigComposite, "").setLayoutData(gridData); //$NON-NLS-1$
156: gridData = new GridData(GridData.FILL_HORIZONTAL);
157: gridData.horizontalSpan = 3;
158: WidgetFactory
159: .createLabel(
160: actionConfigComposite,
161: Messages
162: .getString("StartScheduledJobDetailsPage.UI_TRIGGER_DESCRIPTION_LABEL")).setLayoutData(gridData); //$NON-NLS-1$
163:
164: composite = WidgetFactory.createComposite(
165: actionConfigComposite, SWT.BORDER);
166: GridLayout layout = new GridLayout(2, false);
167: layout.horizontalSpacing = 10;
168: composite.setLayout(layout);
169: gridData = new GridData(GridData.FILL_HORIZONTAL);
170: gridData.horizontalSpan = 3;
171: composite.setLayoutData(gridData);
172:
173: GridData layoutData = new GridData();
174: layoutData.horizontalSpan = 2;
175: WidgetFactory
176: .createLabel(
177: composite,
178: Messages
179: .getString("StartScheduledJobDetailsPage.UI_TRIGGER_NAME_LABEL")).setLayoutData(layoutData); //$NON-NLS-1$
180:
181: layoutData = new GridData(GridData.FILL_HORIZONTAL);
182: layoutData.horizontalSpan = 2;
183: triggerName = new NewActionInputCombo(composite, layoutData);
184:
185: layoutData = new GridData(GridData.FILL_HORIZONTAL);
186: layoutData.horizontalSpan = 2;
187: WidgetFactory
188: .createLabel(composite, "").setLayoutData(layoutData); //$NON-NLS-1$
189:
190: Composite btnComposite = WidgetFactory.createComposite(
191: composite, SWT.NONE);
192: btnComposite.setLayout(new GridLayout());
193:
194: simpleTriggerRadioButton = WidgetFactory
195: .createButton(
196: btnComposite,
197: Messages
198: .getString("StartScheduledJobDetailsPage.UI_SIMPLE_TRIGGER_NAME"), SWT.RADIO); //$NON-NLS-1$
199: cronTriggerRadioButton = WidgetFactory
200: .createButton(
201: btnComposite,
202: Messages
203: .getString("StartScheduledJobDetailsPage.UI_CRON_TRIGGER_NAME"), SWT.RADIO); //$NON-NLS-1$
204:
205: simpleTriggerRadioButton.addSelectionListener(this );
206: cronTriggerRadioButton.addSelectionListener(this );
207:
208: stackLayout = new StackLayout();
209: stackedComposite = WidgetFactory.createComposite(composite,
210: SWT.NULL);
211: stackedComposite.setLayout(stackLayout);
212: layoutData = new GridData(GridData.FILL_HORIZONTAL);
213: stackedComposite.setLayoutData(layoutData);
214:
215: simpleComposite = WidgetFactory.createComposite(
216: stackedComposite, SWT.NONE);
217: layout = new GridLayout(2, true);
218: layout.horizontalSpacing = 10;
219: simpleComposite.setLayout(layout);
220: WidgetFactory
221: .createLabel(
222: simpleComposite,
223: Messages
224: .getString("StartScheduledJobDetailsPage.TRIGGER_COUNT")); //$NON-NLS-1$
225: WidgetFactory
226: .createLabel(
227: simpleComposite,
228: Messages
229: .getString("StartScheduledJobDetailsPage.TRIGGER_INTERVAL")); //$NON-NLS-1$
230: countValue = new NewActionInputCombo(simpleComposite,
231: new GridData(GridData.FILL_HORIZONTAL));
232: intervalValue = new NewActionInputCombo(simpleComposite,
233: new GridData(GridData.FILL_HORIZONTAL));
234:
235: cronComposite = WidgetFactory.createComposite(stackedComposite,
236: SWT.NONE);
237: cronComposite.setLayout(new GridLayout(2, true));
238: layoutData = new GridData();
239: layoutData.horizontalSpan = 2;
240: WidgetFactory
241: .createLabel(
242: cronComposite,
243: Messages
244: .getString("StartScheduledJobDetailsPage.CRON_STRING")).setLayoutData(layoutData); //$NON-NLS-1$
245: cronValue = new NewActionInputCombo(cronComposite,
246: new GridData(GridData.FILL_HORIZONTAL));
247: }
248:
249: public void refresh() {
250: super .refresh();
251: cronValue.setTargetInput(actionDefinition,
252: StartScheduledJobAction.CRON_STRING,
253: ActionSequenceDocument.STRING_TYPE);
254: countValue.setTargetInput(actionDefinition,
255: StartScheduledJobAction.REPEAT_COUNT,
256: ActionSequenceDocument.LONG_TYPE);
257: intervalValue.setTargetInput(actionDefinition,
258: StartScheduledJobAction.REPEAT_INTERVAL,
259: ActionSequenceDocument.LONG_TYPE);
260: jobInputsList.setInput(actionDefinition);
261: jobInputsToolbar.refresh();
262:
263: simpleTriggerRadioButton.removeSelectionListener(this );
264: cronTriggerRadioButton.removeSelectionListener(this );
265: StartScheduledJobAction startScheduledJobAction = (StartScheduledJobAction) actionDefinition;
266: if (StartScheduledJobAction.CRON_TRIGGER
267: .equals(startScheduledJobAction.getTriggerType()
268: .getStringValue())) {
269: cronTriggerRadioButton.setSelection(true);
270: simpleTriggerRadioButton.setSelection(false);
271: stackLayout.topControl = cronComposite;
272: } else {
273: cronTriggerRadioButton.setSelection(false);
274: simpleTriggerRadioButton.setSelection(true);
275: stackLayout.topControl = simpleComposite;
276: }
277: stackedComposite.layout();
278: simpleTriggerRadioButton.addSelectionListener(this );
279: cronTriggerRadioButton.addSelectionListener(this );
280:
281: triggerName.setTargetInput(actionDefinition,
282: StartScheduledJobAction.TRIGGER_NAME,
283: ActionSequenceDocument.STRING_TYPE);
284: solutionName.setTargetInput(actionDefinition,
285: StartScheduledJobAction.SOLUTION_ELEMENT,
286: ActionSequenceDocument.STRING_TYPE);
287: solutionSubdir.setTargetInput(actionDefinition,
288: StartScheduledJobAction.PATH_ELEMENT,
289: ActionSequenceDocument.STRING_TYPE);
290: xactionName.setTargetInput(actionDefinition,
291: StartScheduledJobAction.ACTION_ELEMENT,
292: ActionSequenceDocument.STRING_TYPE);
293: }
294:
295: public boolean accept(AbstractIOElement ioElement) {
296: String name = null;
297: if ((ioElement instanceof ActionSequenceInput)
298: || (ioElement instanceof ActionInput)) {
299: name = ioElement.getName();
300: } else if (ioElement instanceof ActionOutput) {
301: name = ((ActionOutput) ioElement).getPublicName();
302: }
303: return (name != null)
304: && !Arrays.asList(
305: actionDefinition.getReservedInputNames())
306: .contains(name);
307: }
308:
309: public boolean accepts(IActionSequenceElement actionDef) {
310: return actionDef instanceof StartScheduledJobAction;
311: }
312:
313: public void widgetDefaultSelected(SelectionEvent e) {
314: // TODO Auto-generated method stub
315:
316: }
317:
318: public void widgetSelected(SelectionEvent e) {
319: simpleTriggerRadioButton.removeSelectionListener(this );
320: cronTriggerRadioButton.removeSelectionListener(this );
321: StartScheduledJobAction startScheduledJobAction = (StartScheduledJobAction) actionDefinition;
322: if ((e.getSource() == simpleTriggerRadioButton)
323: && simpleTriggerRadioButton.getSelection()) {
324: startScheduledJobAction.setCronString(null);
325: stackLayout.topControl = simpleComposite;
326: } else if ((e.getSource() == cronTriggerRadioButton)
327: && cronTriggerRadioButton.getSelection()) {
328: startScheduledJobAction.setRepeatCount(null);
329: startScheduledJobAction.setRepeatInterval(null);
330: stackLayout.topControl = cronComposite;
331: }
332: stackedComposite.layout();
333: cronValue.refresh();
334: intervalValue.refresh();
335: countValue.refresh();
336: simpleTriggerRadioButton.addSelectionListener(this);
337: cronTriggerRadioButton.addSelectionListener(this);
338: }
339: }
|