Author: DartPeng
Date: 2008-08-16 04:36:34 -0400 (Sat, 16 Aug 2008)
New Revision: 9751
Added:
workspace/dart/plugins/org.jboss.tools.smooks.xml/src/org/jboss/tools/smooks/xml/ui/XSDStructuredDataWizardPage.java
Removed:
workspace/dart/plugins/org.jboss.tools.smooks.xml/src/org/jboss/tools/smooks/xml/ui/XMLStructuredDataWizardPage.java
Modified:
workspace/dart/plugins/org.jboss.tools.smooks.xml/src/org/jboss/tools/smooks/xml/ui/XMLStructuredDataWizard.java
Log:
change the name of java file
Modified:
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 2008-08-16
08:32:29 UTC (rev 9750)
+++
workspace/dart/plugins/org.jboss.tools.smooks.xml/src/org/jboss/tools/smooks/xml/ui/XMLStructuredDataWizard.java 2008-08-16
08:36:34 UTC (rev 9751)
@@ -18,7 +18,7 @@
*/
public class XMLStructuredDataWizard extends Wizard implements
IStrucutredDataCreationWizard {
- XMLStructuredDataWizardPage page = null;
+ XSDStructuredDataWizardPage page = null;
Object xsdElement = null;
/**
*
@@ -30,7 +30,7 @@
@Override
public void addPages() {
if(page == null){
- page = new XMLStructuredDataWizardPage("XML");
+ page = new XSDStructuredDataWizardPage("XML");
}
this.addPage(page);
}
@@ -42,7 +42,7 @@
*/
@Override
public boolean performFinish() {
- xsdElement = this.page.getReturnRootElementDec();
+ xsdElement = this.page.getReturnValue();
return true;
}
Deleted:
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 2008-08-16
08:32:29 UTC (rev 9750)
+++
workspace/dart/plugins/org.jboss.tools.smooks.xml/src/org/jboss/tools/smooks/xml/ui/XMLStructuredDataWizardPage.java 2008-08-16
08:36:34 UTC (rev 9751)
@@ -1,387 +0,0 @@
-/**
- *
- */
-package org.jboss.tools.smooks.xml.ui;
-
-import java.io.IOException;
-import java.util.Collections;
-
-import org.eclipse.emf.common.util.URI;
-import org.eclipse.emf.ecore.resource.Resource;
-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.eclipse.xsd.XSDSchema;
-import org.eclipse.xsd.util.XSDResourceFactoryImpl;
-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
- }
-
- public Object getReturnRootElementDec(){
- return this.tableViewer.getInput();
- }
-
- /*
- * (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");
- loadXSDButton.addSelectionListener(new SelectionAdapter(){
-
- @Override
- public void widgetSelected(SelectionEvent e) {
- super.widgetSelected(e);
- Resource resource = new XSDResourceFactoryImpl().createResource(URI
- .createFileURI(xsdFileText.getText()));
- try {
- resource.load(Collections.EMPTY_MAP);
- XSDSchema schema = (XSDSchema) resource.getContents().get(0);
- tableViewer.setInput(schema);
- changeWizardPageStatus();
- } catch (IOException e1) {
- //ignore
- }
- }
-
- });
-
- 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(false);
- tableViewer.setChecked(checkObject, check);
- flag = true;
- changeWizardPageStatus();
- }
- }
- });
- 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();
- }
-
- public CheckboxTableViewer getTableViewer() {
- return tableViewer;
- }
-
- public void setTableViewer(CheckboxTableViewer tableViewer) {
- this.tableViewer = tableViewer;
- }
-
-}
Copied:
workspace/dart/plugins/org.jboss.tools.smooks.xml/src/org/jboss/tools/smooks/xml/ui/XSDStructuredDataWizardPage.java
(from rev 9749,
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/XSDStructuredDataWizardPage.java
(rev 0)
+++
workspace/dart/plugins/org.jboss.tools.smooks.xml/src/org/jboss/tools/smooks/xml/ui/XSDStructuredDataWizardPage.java 2008-08-16
08:36:34 UTC (rev 9751)
@@ -0,0 +1,317 @@
+/**
+ *
+ */
+package org.jboss.tools.smooks.xml.ui;
+
+import java.util.Collections;
+
+import org.eclipse.emf.common.util.URI;
+import org.eclipse.emf.ecore.resource.Resource;
+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.eclipse.xsd.XSDSchema;
+import org.eclipse.xsd.util.XSDResourceFactoryImpl;
+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 XSDStructuredDataWizardPage extends WizardPage implements
+ SelectionListener {
+
+ protected Object returnObject = null;
+ protected Text fileText;
+ protected Composite fileTextComposite;
+ protected CheckboxTableViewer tableViewer = null;
+ protected Button fileSystemBrowseButton;
+ protected boolean reasourceLoaded = false;
+ private Button workspaceBrowseButton;
+
+ public XSDStructuredDataWizardPage(String pageName, String title,
+ ImageDescriptor titleImage) {
+ super(pageName, title, titleImage);
+ // TODO Auto-generated constructor stub
+ }
+
+ public XSDStructuredDataWizardPage(String pageName) {
+ super(pageName);
+ // TODO Auto-generated constructor stub
+ }
+
+ public Object getReturnValue() {
+ return returnObject;
+ }
+
+ /*
+ * (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
+ .createFileSelectionComposite(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 void hookFileTextModifyListener() {
+ final ModifyListener modifyListener = new ModifyListener() {
+ @Override
+ public void modifyText(ModifyEvent e) {
+ changeWizardPageStatus();
+ }
+ };
+ // xmlFileText.addModifyListener(modifyListener);
+ fileText.addModifyListener(modifyListener);
+ }
+
+ protected void hookRadioButtonSelectionAdapter() {
+ // 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() == fileSystemBrowseButton) {
+ relationT = fileText;
+ }
+ openFileSelection(relationT);
+ }
+ };
+ // xmlFileSystemBrowseButton
+ // .addSelectionListener(browseButtonSelectionAdapter);
+ fileSystemBrowseButton
+ .addSelectionListener(browseButtonSelectionAdapter);
+ }
+
+ protected Composite createFileSelectionComposite(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);
+
+ fileSystemBrowseButton = new Button(browseButtonComposite, SWT.NONE);
+ fileSystemBrowseButton.setText("Browse File System...");
+
+ workspaceBrowseButton = new Button(
+ browseButtonComposite, SWT.NONE);
+ workspaceBrowseButton.setText("Browse workspace file..");
+ gd = new GridData(GridData.FILL_HORIZONTAL);
+ gd.horizontalAlignment = GridData.END;
+ gd.grabExcessHorizontalSpace = true;
+ workspaceBrowseButton.setLayoutData(gd);
+
+ gd = new GridData();
+ gd.grabExcessHorizontalSpace = true;
+ fileSystemBrowseButton.setLayoutData(gd);
+
+ Label nfileLanel = new Label(xsdComposite, SWT.NONE);
+ nfileLanel.setText("XSD File Path :");
+ fileTextComposite = new Composite(xsdComposite, SWT.NONE);
+ gd = new GridData(GridData.FILL_HORIZONTAL);
+ gd.grabExcessHorizontalSpace = true;
+ fileTextComposite.setLayoutData(gd);
+ GridLayout xsdtgl = new GridLayout();
+ xsdtgl.marginWidth = 0;
+ xsdtgl.marginHeight = 0;
+ xsdtgl.numColumns = 1;
+ fileTextComposite.setLayout(xsdtgl);
+
+ fileText = new Text(fileTextComposite, SWT.BORDER);
+ gd = new GridData(GridData.FILL_HORIZONTAL);
+ fileText.setLayoutData(gd);
+ gd.grabExcessHorizontalSpace = true;
+
+ final Button loadXSDButton = new Button(fileTextComposite, SWT.NONE);
+ loadXSDButton.setText("Load");
+ loadXSDButton.addSelectionListener(new SelectionAdapter() {
+
+ @Override
+ public void widgetSelected(SelectionEvent e) {
+ super.widgetSelected(e);
+ reasourceLoaded = false;
+ try {
+ returnObject = loadedTheObject(fileText.getText());
+ reasourceLoaded = true;
+ } catch (Throwable e2) {
+ // ignore
+ e2.printStackTrace();
+ }
+ changeWizardPageStatus();
+ }
+
+ });
+
+ // 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 Object loadedTheObject(String path) throws Exception {
+ Resource resource = new XSDResourceFactoryImpl().createResource(URI
+ .createFileURI(path));
+ resource.load(Collections.EMPTY_MAP);
+ XSDSchema schema = (XSDSchema) resource.getContents().get(0);
+ return schema;
+ }
+
+ 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(false);
+ tableViewer.setChecked(checkObject, check);
+ flag = true;
+ changeWizardPageStatus();
+ }
+ }
+ });
+ 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 = this.fileText.getText();
+ String error = null;
+ if (text == null || "".equals(text))
+ error = "Please Select a file";
+ if (!reasourceLoaded) {
+ error = "Resource must be loaded";
+ }
+ this.setErrorMessage(error);
+ this.setPageComplete(error == null);
+
+ }
+
+ @Override
+ public void widgetDefaultSelected(SelectionEvent e) {
+ widgetSelected(e);
+ }
+
+ @Override
+ public void widgetSelected(SelectionEvent e) {
+ changeWizardPageStatus();
+ }
+
+ public CheckboxTableViewer getTableViewer() {
+ return tableViewer;
+ }
+
+ public void setTableViewer(CheckboxTableViewer tableViewer) {
+ this.tableViewer = tableViewer;
+ }
+
+}