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.parameters;
014:
015: import java.util.ArrayList;
016: import java.util.Iterator;
017: import java.util.List;
018:
019: import org.eclipse.jface.dialogs.Dialog;
020: import org.eclipse.jface.dialogs.IDialogConstants;
021: import org.eclipse.jface.viewers.IStructuredContentProvider;
022: import org.eclipse.jface.viewers.LabelProvider;
023: import org.eclipse.jface.viewers.ListViewer;
024: import org.eclipse.jface.viewers.Viewer;
025: import org.eclipse.swt.SWT;
026: import org.eclipse.swt.layout.GridData;
027: import org.eclipse.swt.widgets.Composite;
028: import org.eclipse.swt.widgets.Control;
029: import org.eclipse.swt.widgets.Shell;
030: import org.pentaho.actionsequence.dom.ActionInput;
031: import org.pentaho.actionsequence.dom.ActionLoop;
032: import org.pentaho.actionsequence.dom.ActionSequenceOutput;
033: import org.pentaho.actionsequence.dom.actions.ActionDefinition;
034: import org.pentaho.designstudio.controls.WidgetFactory;
035: import org.pentaho.designstudio.editors.actionsequence.pages.ActionSequenceLabelProvider;
036: import org.pentaho.designstudio.messages.Messages;
037:
038: public class BrokenParamReferencesDialog extends Dialog implements
039: IStructuredContentProvider {
040:
041: ListViewer listViewer;
042: List parameterReferences;
043:
044: public BrokenParamReferencesDialog(Shell parentShell,
045: List parameterReferences) {
046: super (parentShell);
047: this .parameterReferences = parameterReferences;
048: }
049:
050: protected void configureShell(Shell shell) {
051: super .configureShell(shell);
052: shell
053: .setText(Messages
054: .getString("BrokenParamReferencesDialog.BROKEN_PARAMETERS_TITLE")); //$NON-NLS-1$
055: }
056:
057: protected void createButtonsForButtonBar(Composite parent) {
058: createButton(parent, IDialogConstants.OK_ID,
059: IDialogConstants.OK_LABEL, true);
060: createButton(parent, IDialogConstants.CANCEL_ID,
061: IDialogConstants.CANCEL_LABEL, false);
062: }
063:
064: protected Control createDialogArea(Composite parent) {
065: Composite composite = (Composite) super
066: .createDialogArea(parent);
067: GridData gridData = new GridData(GridData.FILL_HORIZONTAL);
068: gridData.widthHint = 10;
069: gridData.heightHint = 75;
070: WidgetFactory
071: .createLabel(
072: composite,
073: Messages
074: .getString("BrokenParamReferencesDialog.BROKEN_REFERENCES_MSG"), SWT.WRAP).setLayoutData(gridData); //$NON-NLS-1$
075: gridData = new GridData(GridData.FILL_HORIZONTAL);
076: gridData.heightHint = 100;
077: gridData.widthHint = 300;
078: listViewer = new ListViewer(composite, SWT.NONE);
079: listViewer.getControl().setLayoutData(gridData);
080: listViewer.setContentProvider(this );
081: listViewer.setLabelProvider(new LabelProvider() {
082: public String getText(Object element) {
083: String text = element.toString();
084: if (element instanceof ActionDefinition) {
085: text = ActionSequenceLabelProvider
086: .getText((ActionDefinition) element);
087: } else if (element instanceof ActionSequenceOutput) {
088: text = Messages
089: .getString("RenameParameterDialog.ACTION_SEQUENCE_OUTPUT"); //$NON-NLS-1$
090: } else if (element instanceof ActionLoop) {
091: text = ActionSequenceLabelProvider
092: .getText((ActionLoop) element);
093: }
094: return text;
095: }
096: });
097: listViewer.setInput(parameterReferences);
098: return composite;
099: }
100:
101: public Object[] getElements(Object inputElement) {
102: ArrayList elements = new ArrayList();
103: for (Iterator iter = parameterReferences.iterator(); iter
104: .hasNext();) {
105: Object object = iter.next();
106: if (object instanceof ActionInput) {
107: ActionInput actionInput = (ActionInput) object;
108: ActionDefinition actionDefinition = actionInput
109: .getActionDefinition();
110: if (!elements.contains(actionDefinition)) {
111: elements.add(actionInput.getActionDefinition());
112: }
113: } else if ((object instanceof ActionLoop)
114: || (object instanceof ActionSequenceOutput)) {
115: elements.add(object);
116: }
117: }
118: return elements.toArray();
119: }
120:
121: public void dispose() {
122: }
123:
124: public void inputChanged(Viewer viewer, Object oldInput,
125: Object newInput) {
126: }
127: }
|