0001: /*
0002: * Copyright 2006 Pentaho Corporation. All rights reserved.
0003: * This software was developed by Pentaho Corporation and is provided under the terms
0004: * of the Mozilla Public License, Version 1.1, or any later version. You may not use
0005: * this file except in compliance with the license. If you need a copy of the license,
0006: * please go to http://www.mozilla.org/MPL/MPL-1.1.txt. The Original Code is the Pentaho
0007: * BI Platform. The Initial Developer is Pentaho Corporation.
0008: *
0009: * Software distributed under the Mozilla Public License is distributed on an "AS IS"
0010: * basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. Please refer to
0011: * the license for the specific language governing your rights and limitations.
0012: */
0013: package org.pentaho.designstudio.editors.actionsequence.pages.actions.details.reports;
0014:
0015: import org.eclipse.core.runtime.IPath;
0016: import org.eclipse.core.runtime.Path;
0017: import org.eclipse.jface.dialogs.MessageDialog;
0018: import org.eclipse.swt.SWT;
0019: import org.eclipse.swt.custom.StackLayout;
0020: import org.eclipse.swt.events.SelectionEvent;
0021: import org.eclipse.swt.events.SelectionListener;
0022: import org.eclipse.swt.layout.GridData;
0023: import org.eclipse.swt.layout.GridLayout;
0024: import org.eclipse.swt.widgets.Button;
0025: import org.eclipse.swt.widgets.Composite;
0026: import org.eclipse.swt.widgets.FileDialog;
0027: import org.eclipse.swt.widgets.Label;
0028: import org.eclipse.swt.widgets.Text;
0029: import org.pentaho.actionsequence.dom.AbstractIOElement;
0030: import org.pentaho.actionsequence.dom.ActionInput;
0031: import org.pentaho.actionsequence.dom.ActionOutput;
0032: import org.pentaho.actionsequence.dom.ActionSequenceDocument;
0033: import org.pentaho.actionsequence.dom.ActionSequenceDocumentAdapter;
0034: import org.pentaho.actionsequence.dom.ActionSequenceInput;
0035: import org.pentaho.actionsequence.dom.ActionSequenceResource;
0036: import org.pentaho.actionsequence.dom.IActionInputValueProvider;
0037: import org.pentaho.actionsequence.dom.IActionSequenceElement;
0038: import org.pentaho.actionsequence.dom.actions.ActionDefinition;
0039: import org.pentaho.actionsequence.dom.actions.JFreeReportAction;
0040: import org.pentaho.designstudio.controls.ActionInputsList;
0041: import org.pentaho.designstudio.controls.ActionInputsListToolbar;
0042: import org.pentaho.designstudio.controls.ActionOutputText;
0043: import org.pentaho.designstudio.controls.ActionResourceText;
0044: import org.pentaho.designstudio.controls.NewActionInputCombo;
0045: import org.pentaho.designstudio.controls.NewActionInputText;
0046: import org.pentaho.designstudio.controls.PageTemplateText;
0047: import org.pentaho.designstudio.controls.WidgetFactory;
0048: import org.pentaho.designstudio.editors.actionsequence.pages.actions.IActionIOFilter;
0049: import org.pentaho.designstudio.editors.actionsequence.pages.actions.details.ActionDetailsPage;
0050: import org.pentaho.designstudio.messages.Messages;
0051: import org.pentaho.designstudio.util.SolutionHelper;
0052:
0053: /**
0054: * The template describing the action definition used to run JFree reports.
0055: *
0056: * @author Angelo Rodriguez
0057: */
0058: public class JFreeReportDetailsPage_Depricated extends
0059: ActionDetailsPage implements SelectionListener {
0060:
0061: public static final String DISPLAY_NAME = Messages
0062: .getString("JFreeReportDetailsPage.UI_COMPONENT_NAME_JFREE_REPORT"); //$NON-NLS-1$
0063: public static final String[] JFREE_REPORT_TYPES = new String[] {
0064: "html", "pdf", "xls", "rtf", "csv", "xml" }; //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$ //$NON-NLS-5$ //$NON-NLS-6$ //TODO get this from JFREE
0065:
0066: class JFreeRadioButton implements SelectionListener {
0067: Button button = null;
0068:
0069: public JFreeRadioButton(Composite parent) {
0070: button = WidgetFactory
0071: .createButton(
0072: parent,
0073: Messages
0074: .getString("JFreeReportDetailsPage.USE_JFREE_SPEC"), SWT.RADIO); //$NON-NLS-1$
0075: button.addSelectionListener(this );
0076: }
0077:
0078: public void widgetDefaultSelected(SelectionEvent e) {
0079: }
0080:
0081: public void widgetSelected(SelectionEvent e) {
0082: if (button.getSelection()
0083: && !actionDefinition.getComponentName().endsWith(
0084: "JFreeReportComponent")) { //$NON-NLS-1$
0085: actionDefinition.clearInputParams();
0086: actionDefinition.clearOutputParams();
0087: actionDefinition.clearResourceParams();
0088: actionDefinition.removeComponentDefinitions();
0089: ActionSequenceInput actionSequenceInput = actionDefinition
0090: .getDocument().getInput(
0091: JFreeReportAction.DATA_ELEMENT);
0092: if (actionSequenceInput != null) {
0093: actionSequenceInput.delete();
0094: }
0095: actionSequenceInput = actionDefinition
0096: .getDocument()
0097: .getInput(
0098: JFreeReportAction.REPORT_DEFINITION_ELEMENT);
0099: if (actionSequenceInput != null) {
0100: actionSequenceInput.delete();
0101: }
0102: actionDefinition
0103: .setComponentName("JFreeReportComponent"); //$NON-NLS-1$
0104: JFreeReportDetailsPage_Depricated.this .refresh();
0105: }
0106: }
0107:
0108: public void refresh() {
0109: button.removeSelectionListener(this );
0110: button.setSelection(actionDefinition.getComponentName()
0111: .endsWith("JFreeReportComponent")); //$NON-NLS-1$
0112: button.addSelectionListener(this );
0113: }
0114:
0115: }
0116:
0117: class WizardRadioButton implements SelectionListener {
0118: Button button = null;
0119:
0120: public WizardRadioButton(Composite parent) {
0121: button = WidgetFactory
0122: .createButton(
0123: parent,
0124: Messages
0125: .getString("JFreeReportDetailsPage.USE_WIZARD_SPEC"), SWT.RADIO); //$NON-NLS-1$
0126: button.addSelectionListener(this );
0127: }
0128:
0129: public void widgetDefaultSelected(SelectionEvent e) {
0130: }
0131:
0132: public void widgetSelected(SelectionEvent e) {
0133: if (button.getSelection()
0134: && !actionDefinition.getComponentName().endsWith(
0135: "ReportWizardSpecComponent")) { //$NON-NLS-1$
0136: actionDefinition.clearInputParams();
0137: actionDefinition.clearOutputParams();
0138: actionDefinition.clearResourceParams();
0139: actionDefinition.removeComponentDefinitions();
0140: actionDefinition
0141: .setComponentName("ReportWizardSpecComponent"); //$NON-NLS-1$
0142: actionDefinition.addInputParam(
0143: JFreeReportAction.REPORT_DEFINITION_ELEMENT,
0144: ActionSequenceDocument.STRING_TYPE);
0145: actionDefinition.addInputParam(
0146: JFreeReportAction.DATA_ELEMENT,
0147: ActionSequenceDocument.RESULTSET_TYPE);
0148: ActionSequenceInput actionSequenceInput = actionDefinition
0149: .getDocument().createInput(
0150: JFreeReportAction.DATA_ELEMENT,
0151: ActionSequenceDocument.STRING_TYPE);
0152: actionSequenceInput.setDefaultValue(""); //$NON-NLS-1$
0153: actionSequenceInput = actionDefinition
0154: .getDocument()
0155: .createInput(
0156: JFreeReportAction.REPORT_DEFINITION_ELEMENT,
0157: ActionSequenceDocument.STRING_TYPE);
0158: actionSequenceInput.setDefaultValue(""); //$NON-NLS-1$
0159: actionDefinition.setComponentDefinition(
0160: JFreeReportAction.OUTPUT_TYPE_ELEMENT, "html"); //$NON-NLS-1$
0161: JFreeReportDetailsPage_Depricated.this .refresh();
0162: }
0163: }
0164:
0165: public void refresh() {
0166: button.removeSelectionListener(this );
0167: button.setSelection(actionDefinition.getComponentName()
0168: .endsWith("ReportWizardSpecComponent")); //$NON-NLS-1$
0169: button.addSelectionListener(this );
0170: }
0171:
0172: }
0173:
0174: class ActionSequenceListener extends ActionSequenceDocumentAdapter {
0175:
0176: public void actionChanged(ActionDefinition action) {
0177: if (action.equals(actionDefinition)) {
0178: String currentQuery = actionDefinition
0179: .getComponentDefinitionValue(JFreeReportAction.QUERY_ELEMENT);
0180: if (currentQuery == null) {
0181: currentQuery = ""; //$NON-NLS-1$
0182: }
0183: if (!currentQuery.equals(lastQueryText)) {
0184: queryParams.refresh();
0185: lastQueryText = currentQuery;
0186: }
0187: }
0188: }
0189:
0190: }
0191:
0192: public class DataSourceRadioBtn implements SelectionListener {
0193:
0194: protected Button button;
0195:
0196: int typeOfDataSource;
0197:
0198: public DataSourceRadioBtn(String label, Composite parent,
0199: Object layoutData, int typeOfDataSource) {
0200: button = WidgetFactory.createButton(parent, label,
0201: SWT.RADIO);
0202: this .typeOfDataSource = typeOfDataSource;
0203:
0204: if (layoutData != null) {
0205: button.setLayoutData(layoutData);
0206: }
0207:
0208: button.addSelectionListener(this );
0209: }
0210:
0211: public void widgetDefaultSelected(SelectionEvent e) {
0212: }
0213:
0214: public void widgetSelected(SelectionEvent e) {
0215: switch (typeOfDataSource) {
0216: case RESULT_SET_DATA_SOURCE:
0217: actionDefinition
0218: .setComponentDefinition(
0219: JFreeReportAction.DRIVER_ELEMENT,
0220: (String) null);
0221: actionDefinition.setComponentDefinition(
0222: JFreeReportAction.CONNECTION_ELEMENT,
0223: (String) null);
0224: actionDefinition.setComponentDefinition(
0225: JFreeReportAction.LIVE_CONNECTION_ELEMENT,
0226: (String) null);
0227: actionDefinition.setComponentDefinition(
0228: JFreeReportAction.USER_ID_ELEMENT,
0229: (String) null);
0230: actionDefinition.setComponentDefinition(
0231: JFreeReportAction.PASSWORD_ELEMENT,
0232: (String) null);
0233: actionDefinition.setComponentDefinition(
0234: JFreeReportAction.JNDI_ELEMENT, (String) null);
0235: actionDefinition.setComponentDefinition(
0236: JFreeReportAction.REPORT_DATA_SOURCE_ELEMENT,
0237: (String) null);
0238: actionDefinition.setComponentDefinition(
0239: JFreeReportAction.QUERY_ELEMENT, (String) null);
0240: actionDefinition
0241: .removeResourceParam(JFreeReportAction.REPORT_JAR_ELEMENT);
0242: actionDefinition
0243: .removeInputParam(JFreeReportAction.DRIVER_ELEMENT);
0244: actionDefinition
0245: .removeInputParam(JFreeReportAction.CONNECTION_ELEMENT);
0246: actionDefinition
0247: .removeInputParam(JFreeReportAction.LIVE_CONNECTION_ELEMENT);
0248: actionDefinition
0249: .removeInputParam(JFreeReportAction.USER_ID_ELEMENT);
0250: actionDefinition
0251: .removeInputParam(JFreeReportAction.PASSWORD_ELEMENT);
0252: actionDefinition
0253: .removeInputParam(JFreeReportAction.JNDI_ELEMENT);
0254: actionDefinition
0255: .removeInputParam(JFreeReportAction.REPORT_DATA_SOURCE_ELEMENT);
0256: actionDefinition
0257: .removeInputParam(JFreeReportAction.QUERY_ELEMENT);
0258: break;
0259: case MDX_QUERY_DATA_SOURCE:
0260: actionDefinition
0261: .removeInputParam(JFreeReportAction.DATA_ELEMENT);
0262: actionDefinition
0263: .removeResourceParam(JFreeReportAction.REPORT_JAR_ELEMENT);
0264: actionDefinition.setComponentDefinition(
0265: JFreeReportAction.REPORT_DATA_SOURCE_ELEMENT,
0266: JFreeReportAction.MDX_DATA_SOURCE);
0267: break;
0268: case SQL_QUERY_DATA_SOURCE:
0269: actionDefinition
0270: .removeInputParam(JFreeReportAction.DATA_ELEMENT);
0271: actionDefinition.removeResourceParam("report-jar"); //$NON-NLS-1$
0272: actionDefinition.setComponentDefinition(
0273: JFreeReportAction.REPORT_DATA_SOURCE_ELEMENT,
0274: JFreeReportAction.SQL_DATA_SOURCE);
0275: break;
0276: }
0277: JFreeReportDetailsPage_Depricated.this .refresh();
0278: }
0279:
0280: public void refresh() {
0281: button.removeSelectionListener(this );
0282: button.setSelection(false);
0283: String sourceVal = actionDefinition
0284: .getComponentDefinitionValue(JFreeReportAction.REPORT_DATA_SOURCE_ELEMENT);
0285: if (typeOfDataSource == RESULT_SET_DATA_SOURCE) {
0286: button.setSelection(!JFreeReportAction.MDX_DATA_SOURCE
0287: .equals(sourceVal)
0288: && !JFreeReportAction.SQL_DATA_SOURCE
0289: .equals(sourceVal));
0290: } else if (typeOfDataSource == MDX_QUERY_DATA_SOURCE) {
0291: button.setSelection(JFreeReportAction.MDX_DATA_SOURCE
0292: .equals(sourceVal));
0293: } else if (typeOfDataSource == SQL_QUERY_DATA_SOURCE) {
0294: button.setSelection(JFreeReportAction.SQL_DATA_SOURCE
0295: .equals(sourceVal));
0296: }
0297: button.addSelectionListener(this );
0298: }
0299:
0300: public Button getControl() {
0301: return button;
0302: }
0303:
0304: }
0305:
0306: public class LiveConnectionCheckBox implements SelectionListener {
0307:
0308: protected Button button;
0309:
0310: public LiveConnectionCheckBox(String label, Composite parent,
0311: Object layoutData) {
0312: button = WidgetFactory.createButton(parent, label,
0313: SWT.CHECK);
0314:
0315: if (layoutData != null) {
0316: button.setLayoutData(layoutData);
0317: }
0318:
0319: button.addSelectionListener(this );
0320: }
0321:
0322: public void widgetDefaultSelected(SelectionEvent e) {
0323: }
0324:
0325: public void widgetSelected(SelectionEvent e) {
0326: updateXml();
0327: }
0328:
0329: public void refresh() {
0330: button.removeSelectionListener(this );
0331: button
0332: .setSelection("true".equals(actionDefinition.getComponentDefinitionValue(JFreeReportAction.LIVE_CONNECTION_ELEMENT))); //$NON-NLS-1$
0333: button.addSelectionListener(this );
0334: }
0335:
0336: protected void updateXml() {
0337: actionDefinition.setComponentDefinition(
0338: JFreeReportAction.LIVE_CONNECTION_ELEMENT, button
0339: .getSelection() ? "true" : "false"); //$NON-NLS-1$ //$NON-NLS-2$
0340: }
0341: }
0342:
0343: class JndiRadioButton implements SelectionListener {
0344:
0345: Button button;
0346:
0347: public JndiRadioButton(Composite parent) {
0348: button = WidgetFactory
0349: .createButton(
0350: parent,
0351: Messages
0352: .getString("JFreeReportDetailsPage.UI_JNDI_LABEL"), SWT.RADIO); //$NON-NLS-1$
0353: button.addSelectionListener(this );
0354: }
0355:
0356: public void widgetDefaultSelected(SelectionEvent e) {
0357: }
0358:
0359: public void widgetSelected(SelectionEvent e) {
0360: if (!button.getSelection()) {
0361: return;
0362: }
0363:
0364: dbConnectionStackedLayout.topControl = jndiComposite;
0365: dbConnectionStackedComposite.layout();
0366:
0367: actionDefinition.setComponentDefinition(
0368: JFreeReportAction.DRIVER_ELEMENT, (String) null);
0369: actionDefinition
0370: .setComponentDefinition(
0371: JFreeReportAction.CONNECTION_ELEMENT,
0372: (String) null);
0373: actionDefinition.setComponentDefinition(
0374: JFreeReportAction.USER_ID_ELEMENT, (String) null);
0375: actionDefinition.setComponentDefinition(
0376: JFreeReportAction.PASSWORD_ELEMENT, (String) null);
0377: }
0378:
0379: public void refresh() {
0380: button.removeSelectionListener(this );
0381: button
0382: .setSelection(((actionDefinition
0383: .getComponentDefinitionValue(JFreeReportAction.JNDI_ELEMENT) != null) || (actionDefinition
0384: .getInputParam(JFreeReportAction.JNDI_ELEMENT) != null))
0385: && (actionDefinition
0386: .getComponentDefinitionValue(JFreeReportAction.DRIVER_ELEMENT) == null)
0387: && (actionDefinition
0388: .getInputParam(JFreeReportAction.DRIVER_ELEMENT) == null));
0389: button.addSelectionListener(this );
0390: }
0391:
0392: }
0393:
0394: class JdbcRadioButton implements SelectionListener {
0395: Button button;
0396:
0397: public JdbcRadioButton(Composite parent) {
0398: button = WidgetFactory
0399: .createButton(
0400: parent,
0401: Messages
0402: .getString("JFreeReportDetailsPage.UI_JDBC_LABEL"), SWT.RADIO); //$NON-NLS-1$
0403: button.addSelectionListener(this );
0404: }
0405:
0406: public void widgetDefaultSelected(SelectionEvent e) {
0407: }
0408:
0409: public void widgetSelected(SelectionEvent e) {
0410: if (!button.getSelection()) {
0411: return;
0412: }
0413: dbConnectionStackedLayout.topControl = jdbcComposite;
0414: dbConnectionStackedComposite.layout();
0415: actionDefinition.setComponentDefinition(
0416: JFreeReportAction.JNDI_ELEMENT, (String) null);
0417: }
0418:
0419: public void refresh() {
0420: button.removeSelectionListener(this );
0421: button
0422: .setSelection(((actionDefinition
0423: .getComponentDefinitionValue(JFreeReportAction.DRIVER_ELEMENT) != null) || (actionDefinition
0424: .getInputParam(JFreeReportAction.DRIVER_ELEMENT) != null))
0425: && (actionDefinition
0426: .getComponentDefinitionValue(JFreeReportAction.JNDI_ELEMENT) == null)
0427: && (actionDefinition
0428: .getInputParam(JFreeReportAction.JNDI_ELEMENT) == null));
0429: button.addSelectionListener(this );
0430: }
0431: }
0432:
0433: static final int RESULT_SET_DATA_SOURCE = 0;
0434: static final int SQL_QUERY_DATA_SOURCE = 1;
0435: static final int MDX_QUERY_DATA_SOURCE = 2;
0436:
0437: Composite jndiComposite;
0438: Composite jdbcComposite;
0439: Composite dbConnectionStackedComposite;
0440: Composite dbConnectionComposite;
0441: Composite queryComp;
0442: Composite resultSetComposite;
0443: Composite topComposite;
0444: Composite jFreeComposite;
0445: Composite wizardComposite;
0446:
0447: StackLayout dbConnectionStackedLayout;
0448: StackLayout topStackLayout;
0449:
0450: DataSourceRadioBtn resultSetRadioBtn;
0451: DataSourceRadioBtn sqlQueryRadioBtn;
0452: DataSourceRadioBtn mdxQueryRadioBtn;
0453:
0454: LiveConnectionCheckBox liveConnectionButton;
0455: JdbcRadioButton jdbcRadioButton;
0456: JndiRadioButton jndiRadioButton;
0457:
0458: JFreeRadioButton jFreeSpecRadioBtn1;
0459: WizardRadioButton wizardSpecRadioBtn1;
0460: JFreeRadioButton jFreeSpecRadioBtn2;
0461: WizardRadioButton wizardSpecRadioBtn2;
0462:
0463: ActionResourceText reportDefText;
0464: Composite xslComposite;
0465: NewActionInputCombo resultSetCombo;
0466: NewActionInputCombo jdbcDriver;
0467: NewActionInputCombo jdbcConnection;
0468: NewActionInputCombo userName;
0469: NewActionInputCombo password;
0470: NewActionInputCombo jndiName;
0471: PageTemplateText xslFile;
0472: NewActionInputCombo reportFormat;
0473: NewActionInputCombo wizardReportFormat;
0474: NewActionInputText queryText;
0475: ActionOutputText outputName;
0476: ActionInputsList queryParams;
0477: ActionInputsListToolbar queryParamsToolbar;
0478: String lastQueryText = ""; //$NON-NLS-1$
0479:
0480: ActionSequenceListener actionSequenceListener = new ActionSequenceListener();
0481:
0482: ActionResourceText wizardSpecText;
0483: ActionInputsList wizardSpecInputsList;
0484: ActionInputsListToolbar wizardSpecInputsToolbar;
0485:
0486: Button browseJFreeSpecBtn;
0487: Button browseWizardSpecBtn;
0488: Button browseXslBtn;
0489:
0490: IPath basePath;
0491:
0492: /**
0493: * Creates a JFree report template.
0494: */
0495: public JFreeReportDetailsPage_Depricated(IPath basePath) {
0496: super ();
0497: this .basePath = basePath;
0498: }
0499:
0500: /* (non-Javadoc)
0501: * @see org.pentaho.designstudio.editors.actionsequence.pages.actions.templates.detailElementTemplate#getComponentClassName()
0502: */
0503: public String getComponentName() {
0504: return JFreeReportAction.COMPONENT_NAME;
0505: }
0506:
0507: /* (non-Javadoc)
0508: * @see org.pentaho.designstudio.editors.actionsequence.pages.actions.templates.detailElementTemplate#getDisplayName()
0509: */
0510: public String getName() {
0511: return DISPLAY_NAME;
0512: }
0513:
0514: private Composite createReportDataComposite(Composite parent) {
0515:
0516: Composite composite = WidgetFactory.createComposite(parent,
0517: SWT.BORDER);
0518:
0519: composite.setLayout(new GridLayout(3, false));
0520:
0521: resultSetRadioBtn = new DataSourceRadioBtn(
0522: Messages
0523: .getString("JFreeReportDetailsPage.UI_RESULT_SET_LABEL"), composite, null, RESULT_SET_DATA_SOURCE); //$NON-NLS-1$
0524: sqlQueryRadioBtn = new DataSourceRadioBtn(
0525: Messages
0526: .getString("JFreeReportDetailsPage.UI_SQL_QUERY_LABEL"), composite, null, SQL_QUERY_DATA_SOURCE); //$NON-NLS-1$
0527: mdxQueryRadioBtn = new DataSourceRadioBtn(
0528: Messages
0529: .getString("JFreeReportDetailsPage.UI_MDX_QUERY_LABEL"), composite, null, MDX_QUERY_DATA_SOURCE); //$NON-NLS-1$
0530: mdxQueryRadioBtn.button.setLayoutData(new GridData(
0531: GridData.FILL_HORIZONTAL));
0532:
0533: Label label = WidgetFactory.createLabel(composite, ""); //$NON-NLS-1$
0534: GridData layoutData = new GridData(GridData.FILL_HORIZONTAL);
0535: layoutData.horizontalSpan = 3;
0536: label.setLayoutData(layoutData);
0537:
0538: resultSetComposite = WidgetFactory.createComposite(composite,
0539: SWT.NONE);
0540: GridLayout layout = new GridLayout();
0541: layout.marginWidth = 1;
0542: layout.marginHeight = 1;
0543: resultSetComposite.setLayout(layout);
0544: layoutData = new GridData(GridData.FILL_HORIZONTAL);
0545: layoutData.horizontalSpan = 3;
0546: resultSetComposite.setLayoutData(layoutData);
0547: label = WidgetFactory
0548: .createLabel(
0549: resultSetComposite,
0550: Messages
0551: .getString("JFreeReportDetailsPage.UI_RESULT_SET_LABEL")); //$NON-NLS-1$
0552:
0553: resultSetCombo = new NewActionInputCombo(resultSetComposite,
0554: new GridData(GridData.FILL_HORIZONTAL));
0555:
0556: return composite;
0557: }
0558:
0559: private Composite createDbConnectionComposite(Composite parent) {
0560:
0561: dbConnectionComposite = WidgetFactory.createComposite(parent,
0562: SWT.NONE);
0563: GridLayout layout = new GridLayout();
0564: layout.marginWidth = 1;
0565: dbConnectionComposite.setLayout(layout);
0566:
0567: WidgetFactory
0568: .createLabel(
0569: dbConnectionComposite,
0570: Messages
0571: .getString("JFreeReportDetailsPage.UI_DB_CONNECTION_LABEL")); //$NON-NLS-1$
0572:
0573: Composite composite = WidgetFactory.createComposite(
0574: dbConnectionComposite, SWT.BORDER);
0575: composite.setLayout(new GridLayout());
0576: composite.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
0577:
0578: Composite buttonComposite = WidgetFactory.createComposite(
0579: composite, SWT.NONE);
0580: buttonComposite.setLayout(new GridLayout(2, false));
0581: GridData layoutData = new GridData(GridData.FILL_HORIZONTAL);
0582: layoutData.horizontalSpan = 2;
0583: buttonComposite.setLayoutData(layoutData);
0584:
0585: jdbcRadioButton = new JdbcRadioButton(buttonComposite);
0586: jndiRadioButton = new JndiRadioButton(buttonComposite);
0587:
0588: dbConnectionStackedLayout = new StackLayout();
0589: dbConnectionStackedComposite = WidgetFactory.createComposite(
0590: composite, SWT.NULL);
0591: dbConnectionStackedComposite
0592: .setLayout(dbConnectionStackedLayout);
0593: layoutData = new GridData(GridData.FILL_HORIZONTAL);
0594: layoutData.horizontalSpan = 2;
0595: dbConnectionStackedComposite.setLayoutData(layoutData);
0596:
0597: jdbcComposite = createJdbcComposite(dbConnectionStackedComposite);
0598: jndiComposite = createJndiComposite(dbConnectionStackedComposite);
0599:
0600: dbConnectionStackedLayout.topControl = null;
0601: dbConnectionStackedComposite.layout();
0602:
0603: liveConnectionButton = new LiveConnectionCheckBox(
0604: Messages
0605: .getString("JFreeReportDetailsPage.UI_KEEP_OPEN_LABEL"), composite, null); //$NON-NLS-1$
0606:
0607: return dbConnectionComposite;
0608: }
0609:
0610: private Composite createJndiComposite(Composite parent) {
0611: Composite composite = WidgetFactory.createComposite(parent,
0612: SWT.NONE);
0613:
0614: GridLayout gridLayout = new GridLayout(2, true);
0615: gridLayout.horizontalSpacing = 20;
0616: composite.setLayout(gridLayout);
0617:
0618: WidgetFactory.createLabel(composite, Messages
0619: .getString("JFreeReportDetailsPage.UI_NAME_LABEL")); //$NON-NLS-1$
0620: WidgetFactory.createLabel(composite, ""); //$NON-NLS-1$
0621: jndiName = new NewActionInputCombo(composite, new GridData(
0622: GridData.FILL_HORIZONTAL));
0623: return composite;
0624: }
0625:
0626: private Composite createJdbcComposite(Composite parent) {
0627: Composite composite = WidgetFactory.createComposite(parent,
0628: SWT.NONE);
0629:
0630: GridLayout gridLayout = new GridLayout(2, true);
0631: gridLayout.horizontalSpacing = 20;
0632: composite.setLayout(gridLayout);
0633:
0634: WidgetFactory.createLabel(composite, Messages
0635: .getString("JFreeReportDetailsPage.UI_DRIVER_LABEL")); //$NON-NLS-1$
0636:
0637: WidgetFactory
0638: .createLabel(
0639: composite,
0640: Messages
0641: .getString("JFreeReportDetailsPage.UI_USER_NAME_LABEL")); //$NON-NLS-1$
0642:
0643: jdbcDriver = new NewActionInputCombo(composite, new GridData(
0644: GridData.FILL_HORIZONTAL));
0645: userName = new NewActionInputCombo(composite, new GridData(
0646: GridData.FILL_HORIZONTAL));
0647:
0648: WidgetFactory
0649: .createLabel(
0650: composite,
0651: Messages
0652: .getString("JFreeReportDetailsPage.UI_CONNECTION_LABEL")); //$NON-NLS-1$
0653:
0654: WidgetFactory.createLabel(composite, Messages
0655: .getString("JFreeReportDetailsPage.UI_PASSWORD_LABEL")); //$NON-NLS-1$
0656:
0657: jdbcConnection = new NewActionInputCombo(composite,
0658: new GridData(GridData.FILL_HORIZONTAL));
0659: password = new NewActionInputCombo(composite, new GridData(
0660: GridData.FILL_HORIZONTAL));
0661:
0662: return composite;
0663: }
0664:
0665: private Composite createReportDefComposite(Composite parent) {
0666: Composite composite = WidgetFactory.createComposite(parent,
0667: SWT.BORDER);
0668: composite.setLayout(new GridLayout(2, false));
0669: jFreeSpecRadioBtn2 = new JFreeRadioButton(composite);
0670: wizardSpecRadioBtn2 = new WizardRadioButton(composite);
0671:
0672: Label label = WidgetFactory.createLabel(composite, ""); //$NON-NLS-1$
0673: GridData layoutData = new GridData(GridData.FILL_HORIZONTAL);
0674: layoutData.horizontalSpan = 2;
0675: label.setLayoutData(layoutData);
0676:
0677: label = WidgetFactory.createLabel(composite, Messages
0678: .getString("JFreeReportDetailsPage.FILE_LOCATION")); //$NON-NLS-1$
0679: layoutData = new GridData(GridData.FILL_HORIZONTAL);
0680: layoutData.horizontalSpan = 2;
0681: label.setLayoutData(layoutData);
0682:
0683: GridData gridData = new GridData(GridData.FILL_HORIZONTAL);
0684: gridData.verticalAlignment = GridData.BEGINNING;
0685: gridData.horizontalSpan = 2;
0686: reportDefText = new ActionResourceText(composite, gridData);
0687: reportDefText.setBasePath(basePath);
0688:
0689: browseJFreeSpecBtn = WidgetFactory
0690: .createButton(
0691: composite,
0692: Messages
0693: .getString("JFreeReportDetailsPage.UI_BROWSE_LABEL"), SWT.FLAT); //$NON-NLS-1$
0694: browseJFreeSpecBtn.addSelectionListener(this );
0695: gridData = new GridData(GridData.FILL_HORIZONTAL);
0696: gridData.horizontalSpan = 2;
0697: gridData.horizontalAlignment = GridData.END;
0698: browseJFreeSpecBtn.setLayoutData(gridData);
0699:
0700: return composite;
0701: }
0702:
0703: private Composite createJFreeComposite(Composite parent) {
0704: Composite actionConfigComposite = WidgetFactory
0705: .createComposite(parent, SWT.NONE);
0706: GridLayout gridLayout = new GridLayout(2, true);
0707: gridLayout.horizontalSpacing = 20;
0708: actionConfigComposite.setLayout(gridLayout);
0709:
0710: WidgetFactory
0711: .createLabel(
0712: actionConfigComposite,
0713: Messages
0714: .getString("JFreeReportDetailsPage.UI_REPORT_DEF_LABEL")); //$NON-NLS-1$
0715:
0716: WidgetFactory
0717: .createLabel(
0718: actionConfigComposite,
0719: Messages
0720: .getString("JFreeReportDetailsPage.UI_REPORT_DATA_LABEL")); //$NON-NLS-1$
0721:
0722: Composite composite = createReportDefComposite(actionConfigComposite);
0723: composite.setLayoutData(new GridData(GridData.FILL_BOTH));
0724:
0725: composite = createReportDataComposite(actionConfigComposite);
0726: composite.setLayoutData(new GridData(GridData.FILL_BOTH));
0727:
0728: GridData gridData = new GridData();
0729: gridData.horizontalSpan = 2;
0730: WidgetFactory
0731: .createLabel(actionConfigComposite, "").setLayoutData(gridData); //$NON-NLS-1$
0732:
0733: composite = WidgetFactory
0734: .createComposite(actionConfigComposite);
0735: WidgetFactory.adapt(composite);
0736: gridLayout = new GridLayout(2, false);
0737: gridLayout.marginWidth = 0;
0738: gridLayout.marginHeight = 0;
0739: composite.setLayout(gridLayout);
0740: composite.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
0741: WidgetFactory
0742: .createLabel(
0743: composite,
0744: Messages
0745: .getString("JFreeReportDetailsPage.UI_REPORT_PARAMETERS_LABEL")); //$NON-NLS-1$
0746:
0747: WidgetFactory
0748: .createLabel(
0749: actionConfigComposite,
0750: Messages
0751: .getString("JFreeReportDetailsPage.UI_REPORT_FORMAT_LABEL")); //$NON-NLS-1$
0752:
0753: queryParams = new ActionInputsList(actionConfigComposite);
0754: gridData = new GridData(GridData.FILL_BOTH);
0755: gridData.verticalSpan = 5;
0756: queryParams.getControl().setLayoutData(gridData);
0757:
0758: queryParamsToolbar = new ActionInputsListToolbar(composite,
0759: queryParams);
0760: gridData = new GridData(GridData.FILL_HORIZONTAL);
0761: gridData.horizontalAlignment = GridData.END;
0762: queryParamsToolbar.getControl().setLayoutData(gridData);
0763:
0764: reportFormat = new NewActionInputCombo(actionConfigComposite,
0765: new GridData(GridData.FILL_HORIZONTAL));
0766:
0767: WidgetFactory
0768: .createLabel(
0769: actionConfigComposite,
0770: Messages
0771: .getString("JFreeReportDetailsPage.UI_REPORT_DESTINATION_LABEL")); //$NON-NLS-1$
0772: outputName = new ActionOutputText(actionConfigComposite,
0773: new GridData(GridData.FILL_HORIZONTAL));
0774:
0775: xslComposite = WidgetFactory
0776: .createComposite(actionConfigComposite);
0777: xslComposite.setLayoutData(new GridData(
0778: GridData.FILL_HORIZONTAL));
0779: gridLayout = new GridLayout();
0780: gridLayout.marginWidth = 1;
0781: gridLayout.marginHeight = 1;
0782: xslComposite.setLayout(gridLayout);
0783:
0784: WidgetFactory
0785: .createLabel(
0786: xslComposite,
0787: Messages
0788: .getString("JFreeReportDetailsPage.UI_STYLESHEET_LABEL")); //$NON-NLS-1$
0789: xslFile = new PageTemplateText(xslComposite, new GridData(
0790: GridData.FILL_HORIZONTAL));
0791: xslFile.setBasePath(basePath);
0792:
0793: browseXslBtn = WidgetFactory
0794: .createButton(
0795: xslComposite,
0796: Messages
0797: .getString("JFreeReportDetailsPage.UI_BROWSE_LABEL"), SWT.FLAT); //$NON-NLS-1$
0798: browseXslBtn.addSelectionListener(this );
0799: gridData = new GridData(GridData.FILL_HORIZONTAL);
0800: gridData.horizontalAlignment = GridData.END;
0801: browseXslBtn.setLayoutData(gridData);
0802:
0803: gridData = new GridData();
0804: gridData.horizontalSpan = 2;
0805: WidgetFactory
0806: .createLabel(actionConfigComposite, "").setLayoutData(gridData); //$NON-NLS-1$
0807:
0808: queryComp = WidgetFactory.createComposite(
0809: actionConfigComposite, SWT.NONE);
0810: gridLayout = new GridLayout();
0811: gridLayout.marginWidth = 1;
0812: queryComp.setLayout(gridLayout);
0813: gridData = new GridData(GridData.FILL_BOTH);
0814: gridData.horizontalSpan = 2;
0815: queryComp.setLayoutData(gridData);
0816: WidgetFactory.createLabel(queryComp, Messages
0817: .getString("JFreeReportDetailsPage.UI_QUERY_LABEL")); //$NON-NLS-1$
0818: gridData = new GridData(GridData.FILL_BOTH);
0819: gridData.horizontalSpan = 2;
0820: gridData.heightHint = 150;
0821: gridData.widthHint = 150;
0822: queryText = new NewActionInputText(queryComp, gridData,
0823: SWT.MULTI | SWT.WRAP | SWT.V_SCROLL | SWT.BORDER);
0824:
0825: gridData = new GridData();
0826: gridData.horizontalSpan = 2;
0827: WidgetFactory
0828: .createLabel(actionConfigComposite, "").setLayoutData(gridData); //$NON-NLS-1$
0829:
0830: composite = createDbConnectionComposite(actionConfigComposite);
0831: gridData = new GridData(GridData.FILL_BOTH);
0832: gridData.horizontalSpan = 2;
0833: composite.setLayoutData(gridData);
0834:
0835: return actionConfigComposite;
0836: }
0837:
0838: public void createDetailsComposite(Composite parent) {
0839:
0840: Composite composite = parent;
0841: composite.setLayout(new GridLayout(2, false));
0842: topComposite = new Composite(composite, SWT.NONE);
0843: GridData gridData = new GridData(GridData.FILL_HORIZONTAL);
0844: gridData.horizontalSpan = 2;
0845: topComposite.setLayoutData(gridData);
0846: topStackLayout = new StackLayout();
0847: topComposite.setLayout(topStackLayout);
0848:
0849: jFreeComposite = createJFreeComposite(topComposite);
0850: wizardComposite = createWizardComposite(topComposite);
0851:
0852: }
0853:
0854: public void refresh() {
0855: super .refresh();
0856:
0857: topStackLayout.topControl = null;
0858: if (actionDefinition.getComponentName().endsWith(
0859: "ReportWizardSpecComponent")) { //$NON-NLS-1$
0860: topStackLayout.topControl = wizardComposite;
0861: } else if (actionDefinition.getComponentName().endsWith(
0862: "JFreeReportComponent")) { //$NON-NLS-1$
0863: topStackLayout.topControl = jFreeComposite;
0864: }
0865: topComposite.layout();
0866:
0867: wizardSpecRadioBtn1.refresh();
0868: jFreeSpecRadioBtn1.refresh();
0869: wizardSpecRadioBtn2.refresh();
0870: jFreeSpecRadioBtn2.refresh();
0871: resultSetRadioBtn.refresh();
0872: sqlQueryRadioBtn.refresh();
0873: mdxQueryRadioBtn.refresh();
0874:
0875: wizardSpecInputsList.setInput(actionDefinition);
0876: wizardSpecInputsToolbar.refresh();
0877: wizardSpecText.setTargetResource(actionDefinition,
0878: JFreeReportAction.REPORT_WIZ_SPEC_ELEMENT);
0879: reportDefText.setTargetResource(actionDefinition,
0880: JFreeReportAction.REPORT_DEFINITION_ELEMENT);
0881: resultSetCombo.setTargetInput(actionDefinition,
0882: JFreeReportAction.DATA_ELEMENT,
0883: ActionSequenceDocument.RESULTSET_TYPE);
0884: jdbcDriver.setTargetInput(actionDefinition,
0885: JFreeReportAction.DRIVER_ELEMENT,
0886: ActionSequenceDocument.STRING_TYPE);
0887: jdbcConnection.setTargetInput(actionDefinition,
0888: JFreeReportAction.CONNECTION_ELEMENT,
0889: ActionSequenceDocument.STRING_TYPE);
0890: userName.setTargetInput(actionDefinition,
0891: JFreeReportAction.USER_ID_ELEMENT,
0892: ActionSequenceDocument.STRING_TYPE);
0893: password.setTargetInput(actionDefinition,
0894: JFreeReportAction.PASSWORD_ELEMENT,
0895: ActionSequenceDocument.STRING_TYPE);
0896: jndiName.setTargetInput(actionDefinition,
0897: JFreeReportAction.JNDI_ELEMENT,
0898: ActionSequenceDocument.STRING_TYPE);
0899: liveConnectionButton.refresh();
0900: queryText.setTargetInput(actionDefinition,
0901: JFreeReportAction.QUERY_ELEMENT);
0902: lastQueryText = actionDefinition
0903: .getComponentDefinitionValue(JFreeReportAction.QUERY_ELEMENT);
0904: xslFile
0905: .setActionDefinition((JFreeReportAction) actionDefinition);
0906: wizardReportFormat.setTargetInput(actionDefinition,
0907: JFreeReportAction.OUTPUT_TYPE_ELEMENT,
0908: ActionSequenceDocument.STRING_TYPE);
0909: wizardReportFormat.setDefaultConstants(JFREE_REPORT_TYPES);
0910: reportFormat.setTargetInput(actionDefinition,
0911: JFreeReportAction.OUTPUT_TYPE_ELEMENT,
0912: ActionSequenceDocument.STRING_TYPE);
0913: reportFormat.setDefaultConstants(JFREE_REPORT_TYPES);
0914: jndiRadioButton.refresh();
0915: jdbcRadioButton.refresh();
0916: queryParams.setInput(actionDefinition);
0917: queryParamsToolbar.refresh();
0918: outputName.setTargetOutput(actionDefinition,
0919: JFreeReportAction.OUTPUT_REPORT);
0920:
0921: if (jndiRadioButton.button.getSelection()
0922: && (dbConnectionStackedLayout.topControl != jndiComposite)) {
0923: dbConnectionStackedLayout.topControl = jndiComposite;
0924: dbConnectionStackedComposite.layout();
0925: } else if (jdbcRadioButton.button.getSelection()
0926: && (dbConnectionStackedLayout.topControl != jdbcComposite)) {
0927: dbConnectionStackedLayout.topControl = jdbcComposite;
0928: dbConnectionStackedComposite.layout();
0929: } else if (!jdbcRadioButton.button.getSelection()
0930: && !jndiRadioButton.button.getSelection()
0931: && (dbConnectionStackedLayout.topControl != null)) {
0932: dbConnectionStackedLayout.topControl = null;
0933: dbConnectionStackedComposite.layout();
0934: }
0935:
0936: resultSetComposite.setVisible(resultSetRadioBtn.button
0937: .getSelection());
0938: queryComp.setVisible(sqlQueryRadioBtn.button.getSelection()
0939: || mdxQueryRadioBtn.button.getSelection());
0940: dbConnectionComposite.setVisible(sqlQueryRadioBtn.button
0941: .getSelection()
0942: || mdxQueryRadioBtn.button.getSelection());
0943: xslComposite.setVisible(((JFreeReportAction) actionDefinition)
0944: .getXsl() != IActionInputValueProvider.NULL_INPUT); //$NON-NLS-1$ //$NON-NLS-2$
0945: }
0946:
0947: public void setActionSequenceElement(IActionSequenceElement element) {
0948: super .setActionSequenceElement(element);
0949: if (actionDefinition != null) {
0950: actionDefinition.getDocument().addListener(
0951: actionSequenceListener);
0952: }
0953: }
0954:
0955: private Composite createWizardSpecComposite(Composite parent) {
0956: Composite composite = WidgetFactory.createComposite(parent,
0957: SWT.BORDER);
0958: composite.setLayout(new GridLayout(2, false));
0959: jFreeSpecRadioBtn1 = new JFreeRadioButton(composite);
0960: wizardSpecRadioBtn1 = new WizardRadioButton(composite);
0961:
0962: GridData layoutData = new GridData(GridData.FILL_HORIZONTAL);
0963: layoutData.horizontalSpan = 2;
0964: WidgetFactory
0965: .createLabel(composite, "").setLayoutData(layoutData); //$NON-NLS-1$
0966:
0967: layoutData = new GridData(GridData.FILL_HORIZONTAL);
0968: layoutData.horizontalSpan = 2;
0969: WidgetFactory
0970: .createLabel(
0971: composite,
0972: Messages
0973: .getString("JFreeReportDetailsPage.FILE_LOCATION")).setLayoutData(layoutData); //$NON-NLS-1$
0974:
0975: GridData gridData = new GridData(GridData.FILL_HORIZONTAL);
0976: gridData.verticalAlignment = GridData.BEGINNING;
0977: gridData.horizontalSpan = 2;
0978: wizardSpecText = new ActionResourceText(composite, gridData);
0979: wizardSpecText.setBasePath(basePath);
0980:
0981: browseWizardSpecBtn = WidgetFactory
0982: .createButton(
0983: composite,
0984: Messages
0985: .getString("JFreeReportDetailsPage.UI_BROWSE_LABEL"), SWT.FLAT); //$NON-NLS-1$
0986: browseWizardSpecBtn.addSelectionListener(this );
0987: gridData = new GridData(GridData.FILL_HORIZONTAL);
0988: gridData.horizontalSpan = 2;
0989: gridData.horizontalAlignment = GridData.END;
0990: browseWizardSpecBtn.setLayoutData(gridData);
0991:
0992: return composite;
0993: }
0994:
0995: public Composite createWizardComposite(Composite parent) {
0996: Composite actionConfigComposite = WidgetFactory
0997: .createComposite(parent, SWT.NONE);
0998: GridLayout gridLayout = new GridLayout(2, true);
0999: gridLayout.horizontalSpacing = 10;
1000: actionConfigComposite.setLayout(gridLayout);
1001:
1002: WidgetFactory
1003: .createLabel(
1004: actionConfigComposite,
1005: Messages
1006: .getString("JFreeReportDetailsPage.REPORT_WIZARD_SPEC")); //$NON-NLS-1$
1007:
1008: Composite composite = WidgetFactory
1009: .createComposite(actionConfigComposite);
1010: WidgetFactory.adapt(composite);
1011: gridLayout = new GridLayout(2, false);
1012: gridLayout.marginWidth = 0;
1013: gridLayout.marginHeight = 0;
1014: composite.setLayout(gridLayout);
1015: composite.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
1016: WidgetFactory.createLabel(composite, Messages
1017: .getString("JFreeReportDetailsPage.REPORT_INPUTS")); //$NON-NLS-1$
1018:
1019: createWizardSpecComposite(actionConfigComposite).setLayoutData(
1020: new GridData(GridData.FILL_HORIZONTAL));
1021:
1022: wizardSpecInputsList = new ActionInputsList(
1023: actionConfigComposite);
1024: GridData gridData = new GridData(GridData.FILL_HORIZONTAL);
1025: gridData.verticalAlignment = GridData.FILL;
1026: wizardSpecInputsList.getList().setLayoutData(gridData);
1027: wizardSpecInputsList.setFilter(new IActionIOFilter() {
1028:
1029: public boolean accept(AbstractIOElement ioElement) {
1030: String name = null;
1031: if (ioElement.getType().equals(
1032: ActionSequenceDocument.STRING_TYPE)) {
1033: if ((ioElement instanceof ActionSequenceInput)
1034: || (ioElement instanceof ActionInput)) {
1035: name = ioElement.getName();
1036: } else if (ioElement instanceof ActionOutput) {
1037: name = ((ActionOutput) ioElement)
1038: .getPublicName();
1039: }
1040: }
1041: return !JFreeReportAction.REPORT_DEFINITION_ELEMENT
1042: .equals(name)
1043: && !JFreeReportAction.OUTPUT_TYPE_ELEMENT
1044: .equals(name);
1045: }
1046:
1047: });
1048:
1049: wizardSpecInputsToolbar = new ActionInputsListToolbar(
1050: composite, wizardSpecInputsList);
1051: gridData = new GridData(GridData.FILL_HORIZONTAL);
1052: gridData.horizontalAlignment = GridData.END;
1053: wizardSpecInputsToolbar.getControl().setLayoutData(gridData);
1054:
1055: gridData = new GridData();
1056: gridData.horizontalSpan = 2;
1057: WidgetFactory
1058: .createLabel(actionConfigComposite, "").setLayoutData(gridData);//$NON-NLS-1$
1059:
1060: WidgetFactory
1061: .createLabel(
1062: actionConfigComposite,
1063: Messages
1064: .getString("JFreeReportDetailsPage.UI_REPORT_FORMAT_LABEL"));//$NON-NLS-1$
1065: WidgetFactory.createLabel(actionConfigComposite, "");//$NON-NLS-1$
1066: gridData = new GridData(GridData.FILL_HORIZONTAL);
1067: gridData.verticalAlignment = GridData.BEGINNING;
1068: wizardReportFormat = new NewActionInputCombo(
1069: actionConfigComposite, gridData);
1070:
1071: return actionConfigComposite;
1072: }
1073:
1074: public boolean accepts(IActionSequenceElement element) {
1075: boolean result = false;
1076: if (element instanceof JFreeReportAction) {
1077: String actionDefClassName = ((ActionDefinition) element)
1078: .getComponentName();
1079: result = ("." + actionDefClassName).endsWith(".JFreeReportComponent") || ("." + actionDefClassName).endsWith(".ReportWizardSpecComponent"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
1080: }
1081: return result;
1082: }
1083:
1084: private void setResourcePath(String fileName, Text text) {
1085: String fileSolution = SolutionHelper.getSolutionName(fileName);
1086: Path filePath = new Path(fileName);
1087: String baseSolution = SolutionHelper.getSolutionName(basePath
1088: .toString());
1089: String solutionRoot = SolutionHelper.getSolutionRoot(basePath
1090: .toString());
1091:
1092: if ((baseSolution != null) && baseSolution.equals(fileSolution)) {
1093: if (filePath.matchingFirstSegments(basePath) == basePath
1094: .segmentCount()) {
1095: IPath relativeFilePath = filePath
1096: .removeFirstSegments(basePath.segmentCount());
1097: text.setText(relativeFilePath.setDevice(
1098: ActionSequenceResource.SOLUTION_SCHEME + ":")
1099: .toString());
1100: } else {
1101: Path solutionPath = new Path(solutionRoot);
1102: IPath relativePath = filePath
1103: .removeFirstSegments(solutionPath
1104: .segmentCount());
1105: IPath absPath = relativePath.makeAbsolute().setDevice(
1106: ActionSequenceResource.SOLUTION_SCHEME + ":"); //$NON-NLS-1$
1107: text.setText(absPath.toString());
1108: }
1109: } else {
1110: text.setText(ActionSequenceResource.FILE_SCHEME + ":"
1111: + fileName);
1112: }
1113: }
1114:
1115: public boolean checkResourceReferences(
1116: ActionDefinition actionDefinition) {
1117: return true;
1118: }
1119:
1120: public void fixResourceReferences(ActionDefinition actionDefinition) {
1121: //Do nothing
1122: }
1123:
1124: private void setPageTemplate(String fileName, Text text) {
1125: String fileSolution = SolutionHelper.getSolutionName(fileName);
1126: Path filePath = new Path(fileName);
1127: String baseSolution = SolutionHelper.getSolutionName(basePath
1128: .toString());
1129: String solutionRoot = SolutionHelper.getSolutionRoot(basePath
1130: .toString());
1131:
1132: if (fileName.endsWith(".xsl")) { //$NON-NLS-1$
1133: if ((baseSolution != null)
1134: && baseSolution.equals(fileSolution)) {
1135: boolean result = true;
1136: if (filePath.matchingFirstSegments(basePath) == basePath
1137: .segmentCount()) {
1138: IPath relativeFilePath = filePath
1139: .removeFirstSegments(basePath
1140: .segmentCount());
1141: if (relativeFilePath.segmentCount() != 1) {
1142: MessageDialog
1143: .openWarning(
1144: text.getShell(),
1145: Messages
1146: .getString("JFreeReportDetailsPage_Depricated.INVALID_FILE_LOCATION"), Messages.getString("JFreeReportDetailsPage_Depricated.INVALID_XSL_LOCATION")); //$NON-NLS-1$ //$NON-NLS-2$
1147: result = false;
1148: }
1149: } else {
1150: IPath solutionPath = new Path(solutionRoot);
1151: IPath defaultXslPath = solutionPath
1152: .removeLastSegments(1).append(
1153: "system/custom/xsl"); //$NON-NLS-1$
1154: if (!defaultXslPath.equals(filePath
1155: .removeLastSegments(1))) {
1156: MessageDialog
1157: .openWarning(
1158: text.getShell(),
1159: Messages
1160: .getString("JFreeReportDetailsPage_Depricated.INVALID_FILE_LOCATION"), Messages.getString("JFreeReportDetailsPage_Depricated.INVALID_XSL_LOCATION")); //$NON-NLS-1$ //$NON-NLS-2$
1161: result = false;
1162: }
1163: }
1164: if (result) {
1165: text.setText(filePath.lastSegment());
1166: }
1167: } else {
1168: text.setText(filePath.lastSegment());
1169: }
1170: } else {
1171: if ((baseSolution != null)
1172: && baseSolution.equals(fileSolution)) {
1173: if (filePath.matchingFirstSegments(basePath) == basePath
1174: .segmentCount()) {
1175: IPath relativeFilePath = filePath
1176: .removeFirstSegments(basePath
1177: .segmentCount());
1178: text.setText(relativeFilePath.setDevice(null)
1179: .toString());
1180: } else {
1181: Path solutionPath = new Path(solutionRoot);
1182: IPath relativePath = filePath
1183: .removeFirstSegments(solutionPath
1184: .segmentCount());
1185: IPath absPath = relativePath.makeAbsolute()
1186: .setDevice("solution:"); //$NON-NLS-1$
1187: text.setText(absPath.toString());
1188: }
1189: } else {
1190: text.setText(fileName);
1191: }
1192: }
1193: }
1194:
1195: public void widgetDefaultSelected(SelectionEvent e) {
1196: // TODO Auto-generated method stub
1197:
1198: }
1199:
1200: public void widgetSelected(SelectionEvent e) {
1201: if (e.getSource() == browseJFreeSpecBtn) {
1202: FileDialog fileChooser = new FileDialog(browseJFreeSpecBtn
1203: .getShell(), SWT.OPEN);
1204: fileChooser
1205: .setText(Messages
1206: .getString("JFreeReportDetailsPage.SELECT_REPORT_DEFINITION")); //$NON-NLS-1$
1207: fileChooser.setFilterExtensions(new String[] {
1208: "*.xml", "*.*" }); //$NON-NLS-1$ //$NON-NLS-2$
1209: fileChooser
1210: .setFilterNames(new String[] {
1211: Messages
1212: .getString("JFreeReportDetailsPage.REPORT_DEFINITION"), Messages.getString("JFreeReportDetailsPage.ALL_FILES") }); //$NON-NLS-1$ //$NON-NLS-2$
1213: fileChooser.setFilterPath(basePath.toString());
1214: String filename = fileChooser.open();
1215: if (filename != null) {
1216: setResourcePath(filename, (Text) reportDefText
1217: .getControl());
1218: }
1219: } else if (e.getSource() == browseWizardSpecBtn) {
1220: FileDialog fileChooser = new FileDialog(browseWizardSpecBtn
1221: .getShell(), SWT.OPEN);
1222: fileChooser
1223: .setText(Messages
1224: .getString("JFreeReportDetailsPage.SELECT_WIZARD_SPECIFICATION")); //$NON-NLS-1$
1225: fileChooser.setFilterExtensions(new String[] {
1226: "*.xreportspec", "*.*" }); //$NON-NLS-1$ //$NON-NLS-2$
1227: fileChooser
1228: .setFilterNames(new String[] {
1229: Messages
1230: .getString("JFreeReportDetailsPage.WIZARD_SPECIFICATION"), Messages.getString("JFreeReportDetailsPage.ALL_FILES") }); //$NON-NLS-1$ //$NON-NLS-2$
1231: fileChooser.setFilterPath(basePath.toString());
1232: String filename = fileChooser.open();
1233: if (filename != null) {
1234: setResourcePath(filename, (Text) wizardSpecText
1235: .getControl());
1236: }
1237: } else if (e.getSource() == browseXslBtn) {
1238: FileDialog fileChooser = new FileDialog(browseXslBtn
1239: .getShell(), SWT.OPEN);
1240: fileChooser
1241: .setText(Messages
1242: .getString("SecureFilterDetailsPage.SELECT_XSL_STYLESHEET")); //$NON-NLS-1$
1243: fileChooser.setFilterExtensions(new String[] {
1244: "*.xsl", "*.*" }); //$NON-NLS-1$ //$NON-NLS-2$
1245: fileChooser
1246: .setFilterNames(new String[] {
1247: Messages
1248: .getString("SecureFilterDetailsPage.STYLE_SHEET_FILE_TYPE_LABEL"), Messages.getString("SecureFilterDetailsPage.ALL_FILES_LABEL") }); //$NON-NLS-1$ //$NON-NLS-2$
1249: fileChooser.setFilterPath(basePath.toString());
1250: String filename = fileChooser.open();
1251: if (filename != null) {
1252: setPageTemplate(filename, (Text) xslFile.getControl());
1253: }
1254: }
1255: }
1256: }
|