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: /*******************************************************************************
014: * Copyright (c) 2000, 2004 IBM Corporation and others.
015: * All rights reserved. This program and the accompanying materials
016: * are made available under the terms of the Common Public License v1.0
017: * which accompanies this distribution, and is available at
018: * http://www.eclipse.org/legal/cpl-v10.html
019: *
020: * Contributors:
021: * IBM Corporation - initial API and implementation
022: *******************************************************************************/package org.pentaho.designstudio.editors.actionsequence.pages.parameters;
023:
024: import org.dom4j.Element;
025: import org.eclipse.jface.viewers.ISelection;
026: import org.eclipse.jface.viewers.IStructuredSelection;
027: import org.eclipse.swt.SWT;
028: import org.eclipse.swt.layout.FillLayout;
029: import org.eclipse.swt.layout.GridData;
030: import org.eclipse.swt.layout.GridLayout;
031: import org.eclipse.swt.widgets.Composite;
032: import org.eclipse.swt.widgets.Label;
033: import org.eclipse.ui.forms.IFormPart;
034: import org.eclipse.ui.forms.IManagedForm;
035: import org.eclipse.ui.forms.widgets.Section;
036: import org.eclipse.ui.forms.widgets.TableWrapData;
037: import org.eclipse.ui.forms.widgets.TableWrapLayout;
038: import org.pentaho.actionsequence.dom.ActionSequenceDocument;
039: import org.pentaho.actionsequence.dom.ActionSequenceOutput;
040: import org.pentaho.actionsequence.dom.IActionSequenceElement;
041: import org.pentaho.designstudio.controls.WidgetFactory;
042: import org.pentaho.designstudio.editors.actionsequence.pages.IActionSequenceDetailsPage;
043: import org.pentaho.designstudio.messages.Messages;
044:
045: /**
046: * Page used to view and modify the details of a specific action sequence output parameter.
047: *
048: * @author Angelo Rodriguez
049: *
050: */
051: public class OutputDetailsPage implements IActionSequenceDetailsPage {
052: OutputDestViewer outputDestinationViewer;
053: Label typeLabel;
054: Label nameLabel;
055: ActionSequenceOutput actionSequenceOutput;
056: protected IManagedForm mform;
057: private boolean dirty = false;
058:
059: public final static String[] PARAM_TYPES = new String[] {
060: ActionSequenceDocument.STRING_TYPE,
061: ActionSequenceDocument.LONG_TYPE,
062: ActionSequenceDocument.STRING_LIST_TYPE,
063: ActionSequenceDocument.PROPERTY_MAP_TYPE,
064: ActionSequenceDocument.PROPERTY_MAP_LIST_TYPE,
065: ActionSequenceDocument.CONTENT_TYPE };
066:
067: /**
068: * Creates and output details page.
069: */
070: public OutputDetailsPage() {
071: super ();
072: }
073:
074: /* (non-Javadoc)
075: * @see org.eclipse.ui.forms.IDetailsPage#createContents(org.eclipse.swt.widgets.Composite)
076: */
077: public void createContents(Composite parent) {
078: TableWrapLayout layout = new TableWrapLayout();
079: layout.topMargin = 5;
080: layout.leftMargin = 5;
081: layout.rightMargin = 2;
082: layout.bottomMargin = 5;
083: parent.setLayout(layout);
084:
085: Section section = createSection(
086: parent,
087: Messages
088: .getString("OutputDetailsPage.UI_PROCESS_OUTPUT_SECTION_LABEL"), SWT.NONE); //$NON-NLS-1$
089: Composite mainComposite = (Composite) section.getClient();
090: mainComposite.setLayout(new GridLayout(2, false));
091:
092: Label label = WidgetFactory.createLabel(mainComposite, Messages
093: .getString("OutputDetailsPage.UI_NAME_LABEL")); //$NON-NLS-1$
094:
095: nameLabel = WidgetFactory.createLabel(mainComposite, ""); //$NON-NLS-1$
096:
097: label = WidgetFactory.createLabel(mainComposite, Messages
098: .getString("OutputDetailsPage.UI_OUTPUT_TYPE_LABEL")); //$NON-NLS-1$
099:
100: typeLabel = WidgetFactory.createLabel(mainComposite, ""); //$NON-NLS-1$
101:
102: label = WidgetFactory.createLabel(mainComposite, ""); //$NON-NLS-1$
103: GridData layoutData = new GridData(GridData.FILL_HORIZONTAL);
104: layoutData.horizontalSpan = 2;
105: label.setLayoutData(layoutData);
106:
107: Composite composite = WidgetFactory
108: .createComposite(mainComposite);
109: composite.setLayout(new GridLayout(2, false));
110: layoutData = new GridData(GridData.FILL_HORIZONTAL);
111: layoutData.horizontalSpan = 2;
112: composite.setLayoutData(layoutData);
113: WidgetFactory
114: .createLabel(
115: composite,
116: Messages
117: .getString("OutputDetailsPage.UI_OUTPUT_DESTINATION_LABEL")).setLayoutData(new GridData(GridData.FILL_HORIZONTAL)); //$NON-NLS-1$
118:
119: outputDestinationViewer = new OutputDestViewer(mainComposite,
120: SWT.NONE);
121: layoutData = new GridData(GridData.FILL_HORIZONTAL);
122: layoutData.horizontalSpan = 2;
123: layoutData.heightHint = 100;
124: outputDestinationViewer.setLayoutData(layoutData);
125:
126: new OutputDestToolbar(composite, outputDestinationViewer);
127: }
128:
129: /* (non-Javadoc)
130: * @see org.eclipse.ui.forms.IFormPart#refresh()
131: */
132: public void refresh() {
133: nameLabel.setText(actionSequenceOutput.getName());
134: String typeString = actionSequenceOutput.getType();
135: typeLabel.setText(typeString != null ? typeString : ""); //$NON-NLS-1$
136: outputDestinationViewer.setInput(actionSequenceOutput);
137:
138: }
139:
140: /* (non-Javadoc)
141: * @see org.pentaho.designstudio.editors.actionsequence.pages.ActionSequenceDetailsPage#accepts(org.dom4j.Element)
142: */
143: public boolean accepts(IActionSequenceElement detailElement) {
144: return detailElement instanceof ActionSequenceOutput;
145: }
146:
147: /* (non-Javadoc)
148: * @see org.pentaho.designstudio.editors.actionsequence.pages.ActionSequenceDetailsPage#createDetail()
149: */
150: protected Element createDetail() {
151: return null;
152: }
153:
154: /* (non-Javadoc)
155: * @see org.pentaho.designstudio.editors.actionsequence.pages.ActionSequenceDetailsPage#getDisplayName()
156: */
157: public String getName() {
158: return Messages.getString("OutputDetailsPage.9"); //$NON-NLS-1$
159: }
160:
161: public void dispose() {
162: // TODO Auto-generated method stub
163:
164: }
165:
166: public void selectionChanged(IFormPart part, ISelection selection) {
167: IStructuredSelection ssel = (IStructuredSelection) selection;
168: if ((ssel.size() == 1)
169: && (ssel.getFirstElement() instanceof ActionSequenceOutput)) {
170: setActionSequenceElement((ActionSequenceOutput) ssel
171: .getFirstElement());
172: } else {
173: setActionSequenceElement(null);
174: }
175: }
176:
177: /* (non-Javadoc)
178: * @see org.eclipse.ui.forms.IFormPart#initialize(org.eclipse.ui.forms.IManagedForm)
179: */
180: public void initialize(IManagedForm form) {
181: this .mform = form;
182: }
183:
184: /* (non-Javadoc)
185: * @see org.eclipse.ui.forms.IFormPart#isDirty()
186: */
187: public boolean isDirty() {
188: return dirty;
189: }
190:
191: /* (non-Javadoc)
192: * @see org.eclipse.ui.forms.IFormPart#commit(boolean)
193: */
194: public void commit(boolean onSave) {
195: }
196:
197: /* (non-Javadoc)
198: * @see org.eclipse.ui.forms.IFormPart#setFormInput(java.lang.Object)
199: */
200: public boolean setFormInput(Object input) {
201: return false;
202: }
203:
204: /* (non-Javadoc)
205: * @see org.eclipse.ui.forms.IFormPart#setFocus()
206: */
207: public void setFocus() {
208: }
209:
210: /* (non-Javadoc)
211: * @see org.eclipse.ui.forms.IFormPart#isStale()
212: */
213: public boolean isStale() {
214: return false;
215: }
216:
217: public void setOutput(ActionSequenceOutput output) {
218: actionSequenceOutput = output;
219: refresh();
220: }
221:
222: protected Section createSection(Composite parent,
223: String sectionName, int style) {
224: Section section = WidgetFactory.createSection(parent, style);
225: section.setText(sectionName);
226:
227: section.setLayoutData(new TableWrapData(
228: TableWrapData.FILL_GRAB, TableWrapData.TOP));
229:
230: WidgetFactory.createSeparator(section);
231: Composite composite = new Composite(section, SWT.NULL);
232: composite.setLayout(new FillLayout());
233: composite.setLayoutData(new TableWrapData(
234: TableWrapData.FILL_GRAB));
235: section.setClient(composite);
236:
237: return section;
238: }
239:
240: protected Section createSection(Composite parent, String sectionName) {
241: return createSection(parent, sectionName, Section.TWISTIE
242: | Section.EXPANDED);
243: }
244:
245: protected Section createConfigurationSection(Composite parent) {
246: return (createSection(parent, Messages
247: .getString("ActionDetailsPage.UI_CONFIG_SECTION_LABEL"))); //$NON-NLS-1$
248: }
249:
250: public IActionSequenceElement getActionSequenceElement() {
251: return actionSequenceOutput;
252: }
253:
254: public void setActionSequenceElement(IActionSequenceElement element) {
255: actionSequenceOutput = (ActionSequenceOutput) element;
256: refresh();
257: }
258:
259: public void grabFocus() {
260: }
261: }
|