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.actions.details;
023:
024: import org.eclipse.jface.viewers.ISelection;
025: import org.eclipse.jface.viewers.IStructuredSelection;
026: import org.eclipse.swt.layout.FillLayout;
027: import org.eclipse.swt.layout.GridData;
028: import org.eclipse.swt.layout.GridLayout;
029: import org.eclipse.swt.widgets.Composite;
030: import org.eclipse.ui.forms.IFormPart;
031: import org.eclipse.ui.forms.IManagedForm;
032: import org.eclipse.ui.forms.widgets.Section;
033: import org.eclipse.ui.forms.widgets.TableWrapData;
034: import org.eclipse.ui.forms.widgets.TableWrapLayout;
035: import org.pentaho.actionsequence.dom.ActionLoop;
036: import org.pentaho.actionsequence.dom.IActionSequenceElement;
037: import org.pentaho.designstudio.controls.ActionLoopCombo;
038: import org.pentaho.designstudio.controls.WidgetFactory;
039: import org.pentaho.designstudio.editors.actionsequence.pages.IActionSequenceDetailsPage;
040: import org.pentaho.designstudio.messages.Messages;
041:
042: /**
043: * Page for viewing the details of an "actions" element in an action sequence.
044: * @author Angelo Rodriguez
045: */
046: public class ActionLoopDetailsPage implements
047: IActionSequenceDetailsPage {
048:
049: private ActionLoopCombo combo;
050: ActionLoop actionLoop;
051: protected IManagedForm mform;
052: private boolean dirty = false;
053:
054: /**
055: * Creates a detail page.
056: */
057: public ActionLoopDetailsPage() {
058: }
059:
060: public void createDetailsComposite(Composite parent) {
061: }
062:
063: /* (non-Javadoc)
064: * @see org.eclipse.ui.forms.IDetailsPage#createContents(org.eclipse.swt.widgets.Composite)
065: */
066: public void createContents(Composite parent) {
067: TableWrapLayout layout = new TableWrapLayout();
068: layout.topMargin = 5;
069: layout.leftMargin = 5;
070: layout.rightMargin = 2;
071: layout.bottomMargin = 5;
072: parent.setLayout(layout);
073: createGeneralSection(parent);
074: }
075:
076: /**
077: * Synchronizes this page with the contents of the actions element being displayed.
078: */
079: public void refresh() {
080: combo.setTargetLoop(actionLoop);
081: }
082:
083: private void createGeneralSection(Composite parent) {
084: Section section = createSection(
085: parent,
086: Messages
087: .getString("ActionLoopDetailsPage.UI_DETAILS_LOOP_SECTION_LABEL")); //$NON-NLS-1$
088: Composite composite = (Composite) section.getClient();
089: composite.setLayout(new GridLayout());
090:
091: WidgetFactory
092: .createLabel(
093: composite,
094: Messages
095: .getString("ActionLoopDetailsPage.UI_DETAILS_LOOP_LOOP-ON_LABEL")); //$NON-NLS-1$
096: combo = new ActionLoopCombo(composite, new GridData(
097: GridData.FILL_HORIZONTAL));
098: }
099:
100: public boolean accepts(IActionSequenceElement detailElement) {
101: return detailElement instanceof ActionLoop;
102: }
103:
104: public String getName() {
105: return Messages
106: .getString("ActionLoopDetailsPage.UI_DETAILS_LOOP_NAME"); //$NON-NLS-1$
107: }
108:
109: public void setActionSequenceElement(IActionSequenceElement element) {
110: actionLoop = (ActionLoop) element;
111: refresh();
112: }
113:
114: /* (non-Javadoc)
115: * @see org.eclipse.ui.forms.IFormPart#initialize(org.eclipse.ui.forms.IManagedForm)
116: */
117: public void initialize(IManagedForm form) {
118: this .mform = form;
119: }
120:
121: /* (non-Javadoc)
122: * @see org.eclipse.ui.forms.IFormPart#isDirty()
123: */
124: public boolean isDirty() {
125: return dirty;
126: }
127:
128: /* (non-Javadoc)
129: * @see org.eclipse.ui.forms.IFormPart#commit(boolean)
130: */
131: public void commit(boolean onSave) {
132: }
133:
134: /* (non-Javadoc)
135: * @see org.eclipse.ui.forms.IFormPart#setFormInput(java.lang.Object)
136: */
137: public boolean setFormInput(Object input) {
138: return false;
139: }
140:
141: /* (non-Javadoc)
142: * @see org.eclipse.ui.forms.IFormPart#setFocus()
143: */
144: public void setFocus() {
145: }
146:
147: /* (non-Javadoc)
148: * @see org.eclipse.ui.forms.IFormPart#isStale()
149: */
150: public boolean isStale() {
151: return false;
152: }
153:
154: /**
155: * Returns the form on which this details page appears.
156: * */
157: protected IManagedForm getManagedForm() {
158: return mform;
159: }
160:
161: /* (non-Javadoc)
162: * @see org.eclipse.ui.forms.IFormPart#dispose()
163: */
164: public void dispose() {
165: }
166:
167: public void selectionChanged(IFormPart part, ISelection selection) {
168: IStructuredSelection ssel = (IStructuredSelection) selection;
169: if (ssel.size() == 1) {
170: setActionSequenceElement((IActionSequenceElement) ssel
171: .getFirstElement());
172: } else {
173: setActionSequenceElement(null);
174: }
175: }
176:
177: public IActionSequenceElement getActionSequenceElement() {
178: return actionLoop;
179: }
180:
181: protected Section createSection(Composite parent,
182: String sectionName, int style) {
183: Section section = WidgetFactory.createSection(parent, style);
184: section.setText(sectionName);
185:
186: section.setLayoutData(new TableWrapData(
187: TableWrapData.FILL_GRAB, TableWrapData.TOP));
188:
189: WidgetFactory.createSeparator(section);
190: Composite composite = WidgetFactory.createComposite(section);
191: composite.setLayout(new FillLayout());
192: composite.setLayoutData(new TableWrapData(
193: TableWrapData.FILL_GRAB));
194: section.setClient(composite);
195:
196: return section;
197: }
198:
199: protected Section createSection(Composite parent, String sectionName) {
200: return createSection(parent, sectionName, Section.EXPANDED);
201: }
202:
203: public void grabFocus() {
204: }
205: }
|