Author: DartPeng
Date: 2008-08-14 02:20:17 -0400 (Thu, 14 Aug 2008)
New Revision: 9711
Added:
workspace/dart/plugins/org.jboss.tools.smooks.xml/src/org/jboss/tools/smooks/xml/ui/
workspace/dart/plugins/org.jboss.tools.smooks.xml/src/org/jboss/tools/smooks/xml/ui/XMLStructuredDataWizard.java
workspace/dart/plugins/org.jboss.tools.smooks.xml/src/org/jboss/tools/smooks/xml/ui/XMLStructuredDataWizardPage.java
Log:
new xml structure data creation wizard
Added:
workspace/dart/plugins/org.jboss.tools.smooks.xml/src/org/jboss/tools/smooks/xml/ui/XMLStructuredDataWizard.java
===================================================================
---
workspace/dart/plugins/org.jboss.tools.smooks.xml/src/org/jboss/tools/smooks/xml/ui/XMLStructuredDataWizard.java
(rev 0)
+++
workspace/dart/plugins/org.jboss.tools.smooks.xml/src/org/jboss/tools/smooks/xml/ui/XMLStructuredDataWizard.java 2008-08-14
06:20:17 UTC (rev 9711)
@@ -0,0 +1,57 @@
+/**
+ *
+ */
+package org.jboss.tools.smooks.xml.ui;
+
+import org.eclipse.jface.wizard.Wizard;
+import org.eclipse.ui.IEditorInput;
+import org.eclipse.ui.IEditorSite;
+import org.jboss.tools.smooks.ui.IStrucutredDataCreationWizard;
+import org.jboss.tools.smooks.xml.XmlActivator;
+
+/**
+ * @author Dart
+ *
+ */
+public class XMLStructuredDataWizard extends Wizard implements
+ IStrucutredDataCreationWizard {
+ XMLStructuredDataWizardPage page = null;
+ /**
+ *
+ */
+ public XMLStructuredDataWizard() {
+ // TODO Auto-generated constructor stub
+ }
+
+ @Override
+ public void addPages() {
+ if(page == null){
+ page = new XMLStructuredDataWizardPage("XML");
+ }
+ this.addPage(page);
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see org.eclipse.jface.wizard.Wizard#performFinish()
+ */
+ @Override
+ public boolean performFinish() {
+ return true;
+ }
+
+ public String getInputDataTypeID() {
+ return XmlActivator.TYPE_ID;
+ }
+
+ public Object getTreeViewerInputContents() {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ public void init(IEditorSite site, IEditorInput input) {
+
+ }
+
+}
Property changes on:
workspace/dart/plugins/org.jboss.tools.smooks.xml/src/org/jboss/tools/smooks/xml/ui/XMLStructuredDataWizard.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Added:
workspace/dart/plugins/org.jboss.tools.smooks.xml/src/org/jboss/tools/smooks/xml/ui/XMLStructuredDataWizardPage.java
===================================================================
---
workspace/dart/plugins/org.jboss.tools.smooks.xml/src/org/jboss/tools/smooks/xml/ui/XMLStructuredDataWizardPage.java
(rev 0)
+++
workspace/dart/plugins/org.jboss.tools.smooks.xml/src/org/jboss/tools/smooks/xml/ui/XMLStructuredDataWizardPage.java 2008-08-14
06:20:17 UTC (rev 9711)
@@ -0,0 +1,349 @@
+/**
+ *
+ */
+package org.jboss.tools.smooks.xml.ui;
+
+import org.eclipse.jface.resource.ImageDescriptor;
+import org.eclipse.jface.viewers.CheckStateChangedEvent;
+import org.eclipse.jface.viewers.CheckboxTableViewer;
+import org.eclipse.jface.viewers.ICheckStateListener;
+import org.eclipse.jface.wizard.WizardPage;
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.events.ModifyEvent;
+import org.eclipse.swt.events.ModifyListener;
+import org.eclipse.swt.events.SelectionAdapter;
+import org.eclipse.swt.events.SelectionEvent;
+import org.eclipse.swt.events.SelectionListener;
+import org.eclipse.swt.layout.GridData;
+import org.eclipse.swt.layout.GridLayout;
+import org.eclipse.swt.widgets.Button;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.swt.widgets.Control;
+import org.eclipse.swt.widgets.FileDialog;
+import org.eclipse.swt.widgets.Label;
+import org.eclipse.swt.widgets.Text;
+import org.jboss.tools.smooks.xml.model.XMLStructuredModelContentProvider;
+import org.jboss.tools.smooks.xml.model.XMLStructuredModelLabelProvider;
+
+/**
+ *
+ * @author Dart Peng Date : 2008-8-13
+ */
+public class XMLStructuredDataWizardPage extends WizardPage implements
+ SelectionListener {
+
+ private Text xmlFileText;
+ private Text xsdFileText;
+ private Button xmlButton;
+ private Button xsdButton;
+ private Composite fileTextComposite;
+ private Composite xsdfileTextComposite;
+ private CheckboxTableViewer tableViewer = null;
+ private Button xsdFileSystemBrowseButton;
+ protected Button xmlFileSystemBrowseButton;
+
+ public XMLStructuredDataWizardPage(String pageName, String title,
+ ImageDescriptor titleImage) {
+ super(pageName, title, titleImage);
+ // TODO Auto-generated constructor stub
+ }
+
+ public XMLStructuredDataWizardPage(String pageName) {
+ super(pageName);
+ // TODO Auto-generated constructor stub
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see
org.eclipse.jface.dialogs.IDialogPage#createControl(org.eclipse.swt.widgets.Composite)
+ */
+ @Override
+ public void createControl(Composite parent) {
+
+ Composite mainComposite = new Composite(parent, SWT.NONE);
+ GridLayout layout = new GridLayout();
+ layout.numColumns = 1;
+ mainComposite.setLayout(layout);
+
+ GridData gd = new GridData(GridData.FILL_BOTH);
+ gd.grabExcessHorizontalSpace = true;
+ gd.grabExcessVerticalSpace = true;
+ mainComposite.setLayoutData(gd);
+
+ xmlButton = new Button(mainComposite, SWT.RADIO);
+ xmlButton.setText("Select a XML file");
+
+ Composite xmlComposite = this
+ .createXMLFileSelectionComposite(mainComposite);
+
+ Label sp = new Label(mainComposite, SWT.HORIZONTAL | SWT.SEPARATOR);
+ gd = new GridData(GridData.FILL_HORIZONTAL);
+ sp.setLayoutData(gd);
+
+ xsdButton = new Button(mainComposite, SWT.RADIO);
+ xsdButton.setText("Select a XSD file");
+
+ Composite xsdComposite = this
+ .createXSDFileSelectionComposite(mainComposite);
+
+ // init the panel status (XSD file selection composite is disabled)
+ xsdButton.setSelection(true);
+
+ setCompositeChildrenEnabled(xmlComposite, false);
+
+ // registe the listener for controls
+ hookBrowseButtonSelectionAdapter();
+ hookFileTextModifyListener();
+ hookRadioButtonSelectionAdapter();
+ this.setControl(mainComposite);
+ }
+
+ protected Composite createXMLFileSelectionComposite(Composite parent) {
+ Composite xmlComposite = new Composite(parent, SWT.NONE);
+ GridData gd = new GridData(GridData.FILL_HORIZONTAL);
+ xmlComposite.setLayoutData(gd);
+ GridLayout xmlLayout = new GridLayout();
+ xmlLayout.numColumns = 2;
+ xmlLayout.marginWidth = 0;
+ xmlComposite.setLayout(xmlLayout);
+
+ Composite browseXMLComposite = new Composite(xmlComposite, SWT.NONE);
+
+ gd = new GridData(GridData.FILL_HORIZONTAL);
+ gd.horizontalSpan = 2;
+ browseXMLComposite.setLayoutData(gd);
+
+ GridLayout bg1 = new GridLayout();
+ bg1.numColumns = 2;
+ bg1.marginHeight = 0;
+ bg1.marginWidth = 0;
+ bg1.makeColumnsEqualWidth = false;
+ browseXMLComposite.setLayout(bg1);
+
+ xmlFileSystemBrowseButton = new Button(browseXMLComposite, SWT.NONE);
+ xmlFileSystemBrowseButton.setText("Browse File System...");
+
+ final Button xmlWorkspaceBrowseButton = new Button(browseXMLComposite,
+ SWT.NONE);
+ xmlWorkspaceBrowseButton.setText("Browse workspace file..");
+ gd = new GridData(GridData.FILL_HORIZONTAL);
+ gd.horizontalAlignment = GridData.END;
+ gd.grabExcessHorizontalSpace = true;
+ xmlWorkspaceBrowseButton.setLayoutData(gd);
+
+ gd = new GridData();
+ gd.grabExcessHorizontalSpace = true;
+ xmlFileSystemBrowseButton.setLayoutData(gd);
+
+ Label fileLanel = new Label(xmlComposite, SWT.NONE);
+ fileLanel.setText("XML File Path :");
+ fileTextComposite = new Composite(xmlComposite, SWT.NONE);
+ gd = new GridData(GridData.FILL_HORIZONTAL);
+ gd.grabExcessHorizontalSpace = true;
+ fileTextComposite.setLayoutData(gd);
+ GridLayout tgl = new GridLayout();
+ tgl.marginWidth = 0;
+ tgl.marginHeight = 0;
+ tgl.numColumns = 2;
+ fileTextComposite.setLayout(tgl);
+
+ xmlFileText = new Text(fileTextComposite, SWT.BORDER);
+
+ gd = new GridData(GridData.FILL_HORIZONTAL);
+ xmlFileText.setLayoutData(gd);
+ gd.grabExcessHorizontalSpace = true;
+
+ return xmlComposite;
+ }
+
+ protected void hookFileTextModifyListener() {
+ final ModifyListener modifyListener = new ModifyListener() {
+ @Override
+ public void modifyText(ModifyEvent e) {
+ changeWizardPageStatus();
+ }
+ };
+ xmlFileText.addModifyListener(modifyListener);
+ xsdFileText.addModifyListener(modifyListener);
+ }
+
+ protected void hookRadioButtonSelectionAdapter() {
+ xmlButton.addSelectionListener(this);
+ xsdButton.addSelectionListener(this);
+ }
+
+ protected void hookBrowseButtonSelectionAdapter() {
+ SelectionAdapter browseButtonSelectionAdapter = new SelectionAdapter() {
+ @Override
+ public void widgetSelected(SelectionEvent e) {
+ Text relationT = null;
+ if (e.getSource() == xmlFileSystemBrowseButton) {
+ relationT = xmlFileText;
+ }
+ if (e.getSource() == xsdFileSystemBrowseButton) {
+ relationT = xsdFileText;
+ }
+ openFileSelection(relationT);
+ }
+ };
+ xmlFileSystemBrowseButton
+ .addSelectionListener(browseButtonSelectionAdapter);
+ xsdFileSystemBrowseButton
+ .addSelectionListener(browseButtonSelectionAdapter);
+ }
+
+ protected Composite createXSDFileSelectionComposite(Composite parent) {
+ Composite xsdComposite = new Composite(parent, SWT.NONE);
+ GridData gd = new GridData(GridData.FILL_HORIZONTAL);
+ xsdComposite.setLayoutData(gd);
+ GridLayout xsdLayout = new GridLayout();
+ xsdLayout.numColumns = 2;
+ xsdLayout.marginWidth = 0;
+ xsdComposite.setLayout(xsdLayout);
+
+ Composite browseButtonComposite = new Composite(xsdComposite, SWT.NONE);
+ gd = new GridData(GridData.FILL_HORIZONTAL);
+ gd.horizontalSpan = 2;
+ browseButtonComposite.setLayoutData(gd);
+
+ GridLayout bg = new GridLayout();
+ bg.numColumns = 2;
+ bg.marginHeight = 0;
+ bg.marginWidth = 0;
+ bg.makeColumnsEqualWidth = false;
+ browseButtonComposite.setLayout(bg);
+
+ xsdFileSystemBrowseButton = new Button(browseButtonComposite, SWT.NONE);
+ xsdFileSystemBrowseButton.setText("Browse File System...");
+
+ final Button xsdWorkspaceBrowseButton = new Button(
+ browseButtonComposite, SWT.NONE);
+ xsdWorkspaceBrowseButton.setText("Browse workspace file..");
+ gd = new GridData(GridData.FILL_HORIZONTAL);
+ gd.horizontalAlignment = GridData.END;
+ gd.grabExcessHorizontalSpace = true;
+ xsdWorkspaceBrowseButton.setLayoutData(gd);
+
+ gd = new GridData();
+ gd.grabExcessHorizontalSpace = true;
+ xsdFileSystemBrowseButton.setLayoutData(gd);
+
+ Label nfileLanel = new Label(xsdComposite, SWT.NONE);
+ nfileLanel.setText("XSD File Path :");
+ xsdfileTextComposite = new Composite(xsdComposite, SWT.NONE);
+ gd = new GridData(GridData.FILL_HORIZONTAL);
+ gd.grabExcessHorizontalSpace = true;
+ xsdfileTextComposite.setLayoutData(gd);
+ GridLayout xsdtgl = new GridLayout();
+ xsdtgl.marginWidth = 0;
+ xsdtgl.marginHeight = 0;
+ xsdtgl.numColumns = 2;
+ xsdfileTextComposite.setLayout(xsdtgl);
+
+ xsdFileText = new Text(xsdfileTextComposite, SWT.BORDER);
+ gd = new GridData(GridData.FILL_HORIZONTAL);
+ xsdFileText.setLayoutData(gd);
+ gd.grabExcessHorizontalSpace = true;
+
+ final Button loadXSDButton = new Button(xsdfileTextComposite, SWT.NONE);
+ loadXSDButton.setText("Load");
+
+ tableViewer = CheckboxTableViewer.newCheckList(xsdComposite,
+ SWT.FULL_SELECTION | SWT.BORDER);
+ gd = new GridData(GridData.FILL_BOTH);
+ gd.heightHint = 200;
+ gd.horizontalSpan = 2;
+ tableViewer.getControl().setLayoutData(gd);
+
+ initTableViewer();
+
+ return xsdComposite;
+ }
+
+ protected void initTableViewer() {
+ tableViewer.addCheckStateListener(new ICheckStateListener() {
+ boolean flag = true;
+ @Override
+ public void checkStateChanged(CheckStateChangedEvent event) {
+ if (flag) {
+ Object checkObject = event.getElement();
+ boolean check = event.getChecked();
+ flag = false;
+ tableViewer.setAllChecked(true);
+ tableViewer.setChecked(checkObject, check);
+ flag = true;
+ }
+ }
+ });
+ tableViewer.setContentProvider(new XMLStructuredModelContentProvider());
+ tableViewer.setLabelProvider(new XMLStructuredModelLabelProvider());
+ }
+
+ protected void setCompositeChildrenEnabled(Composite composite,
+ boolean enabled) {
+ Control[] children = composite.getChildren();
+ for (int i = 0; i < children.length; i++) {
+ Control child = children[i];
+ if (child instanceof Text) {
+ child.setEnabled(enabled);
+ }
+ if (child instanceof Button) {
+ child.setEnabled(enabled);
+ }
+ if (child instanceof Composite) {
+ setCompositeChildrenEnabled((Composite) child, enabled);
+ }
+ }
+ }
+
+ protected void openFileSelection(Text relationText) {
+ FileDialog dialog = new FileDialog(this.getShell());
+ String path = dialog.open();
+ if (path != null) {
+ relationText.setText(path);
+ } else {
+ relationText.setText("");
+ }
+ }
+
+ protected void changeWizardPageStatus() {
+ String text = null;
+ if (xmlButton.getSelection()) {
+ text = xmlFileText.getText();
+ }
+ if (xsdButton.getSelection()) {
+ text = xsdFileText.getText();
+ }
+ String error = null;
+ if (text == null || "".equals(text))
+ error = "Please Select a file";
+ if (xsdButton.getSelection()) {
+ if (this.tableViewer.getCheckedElements() == null)
+ error = "please select one root element";
+ else {
+ if (this.tableViewer.getCheckedElements().length == 0) {
+ error = "please select one root element";
+ }
+ }
+ }
+ this.setErrorMessage(error);
+ this.setPageComplete(error == null);
+
+ }
+
+ @Override
+ public void widgetDefaultSelected(SelectionEvent e) {
+ widgetSelected(e);
+ }
+
+ @Override
+ public void widgetSelected(SelectionEvent e) {
+ setCompositeChildrenEnabled(fileTextComposite.getParent(), xmlButton
+ .getSelection());
+ setCompositeChildrenEnabled(xsdfileTextComposite.getParent(), xsdButton
+ .getSelection());
+ changeWizardPageStatus();
+ }
+
+}
Property changes on:
workspace/dart/plugins/org.jboss.tools.smooks.xml/src/org/jboss/tools/smooks/xml/ui/XMLStructuredDataWizardPage.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Show replies by date