Author: DartPeng
Date: 2008-09-09 05:20:22 -0400 (Tue, 09 Sep 2008)
New Revision: 10151
Added:
trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/ui/editors/SmooksMainContentEditFormPage.java
Modified:
trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/ui/editors/SmooksFormEditor.java
trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/ui/editors/SmooksGraphicalFormPage.java
Log:
add a new form page for editing other smooks configuration file contents
Modified:
trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/ui/editors/SmooksFormEditor.java
===================================================================
---
trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/ui/editors/SmooksFormEditor.java 2008-09-08
18:51:43 UTC (rev 10150)
+++
trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/ui/editors/SmooksFormEditor.java 2008-09-09
09:20:22 UTC (rev 10151)
@@ -33,7 +33,9 @@
try {
int index = this.addPage(this.graphicalPage);
this.setPageText(index, "Graph");
-
+ SmooksMainContentEditFormPage p = new
SmooksMainContentEditFormPage(this,"normal","Normal");
+ index = this.addPage( p);
+ setPageText(index, "Normal");
} catch (PartInitException e) {
e.printStackTrace();
}
Modified:
trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/ui/editors/SmooksGraphicalFormPage.java
===================================================================
---
trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/ui/editors/SmooksGraphicalFormPage.java 2008-09-08
18:51:43 UTC (rev 10150)
+++
trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/ui/editors/SmooksGraphicalFormPage.java 2008-09-09
09:20:22 UTC (rev 10151)
@@ -51,7 +51,6 @@
import org.eclipse.gef.ui.parts.ScrollingGraphicalViewer;
import org.eclipse.gef.ui.parts.SelectionSynchronizer;
import org.eclipse.jface.action.IAction;
-import org.eclipse.jface.dialogs.Dialog;
import org.eclipse.jface.dialogs.ErrorDialog;
import org.eclipse.jface.dialogs.MessageDialog;
import org.eclipse.jface.viewers.ISelection;
@@ -73,9 +72,11 @@
import org.eclipse.swt.layout.FillLayout;
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.Event;
+import org.eclipse.swt.widgets.Label;
import org.eclipse.swt.widgets.Listener;
import org.eclipse.swt.widgets.Tree;
import org.eclipse.swt.widgets.TreeItem;
@@ -204,8 +205,9 @@
try {
this.initTansformViewerModel((IEditorSite) getSite(),
getEditorInput());
- }catch(IOWrappedException ex){
- MessageDialog.openWarning(getSite().getShell(), "Waring", "Exceptions
occurd during parsing Smooks file, no worries");
+ } catch (IOWrappedException ex) {
+ MessageDialog.openWarning(getSite().getShell(), "Waring",
+ "Exceptions occurd during parsing Smooks file, no worries");
} catch (Throwable e) {
Status status = UIUtils.createErrorStatus(e);
ErrorDialog.openError(getSite().getShell(), "Error", "error",
@@ -305,10 +307,12 @@
}
{
- Composite underToolPanel = toolkit.createComposite(rootMainControl);
+ Composite underToolPanel = toolkit
+ .createComposite(mappingMainComposite);
GridData sgd1 = new GridData(GridData.FILL_HORIZONTAL);
GridLayout underLayout = new GridLayout();
underLayout.numColumns = 3;
+ sgd1.horizontalSpan = 3;
underToolPanel.setLayout(underLayout);
underToolPanel.setLayoutData(sgd1);
{
@@ -342,15 +346,20 @@
// other fragment edit panel
- Section section1 = this.createPageSectionHeader(rootMainControl,
- Section.TITLE_BAR | Section.DESCRIPTION | Section.TWISTIE,
- "Filter Edit Panel", "Edit the filter panel");
- Composite otherComposite = this.createUISectionContainer(section1, 1);
- section1.setClient(otherComposite);
+ // Section section1 = this.createPageSectionHeader(rootMainControl,
+ // Section.TITLE_BAR | Section.TWISTIE,
+ // "Other Edit Panel", "Edit the filter panel");
+ // Composite otherComposite = this.createUISectionContainer(section1,
+ // 1);
+ // section1.setClient(otherComposite);
+ // FillLayout otherFillLayout = new FillLayout();
+ // otherFillLayout.marginHeight = 0;
+ // otherFillLayout.marginWidth = 0;
+ // otherComposite.setLayout(otherFillLayout);
+ // createOtherSmooksGUI(otherComposite,toolkit);
+ // GridData sgd1 = new GridData(GridData.FILL_HORIZONTAL);
+ // section1.setLayoutData(sgd1);
- GridData sgd1 = new GridData(GridData.FILL_HORIZONTAL);
- section1.setLayoutData(sgd1);
-
toolkit.paintBordersFor(rootMainControl);
form.pack();
@@ -364,10 +373,47 @@
}
this.hookGraphicalViewer();
this.initGraphicalViewer();
+ }
- // getSite().setSelectionProvider(this);
+ protected void createOtherSmooksGUI(Composite parent, FormToolkit tool) {
+ Composite mainComposite = tool.createComposite(parent);
+ GridLayout gridLayout = new GridLayout();
+ gridLayout.numColumns = 2;
+ gridLayout.marginHeight = 0;
+ gridLayout.marginWidth = 0;
+ mainComposite.setLayout(gridLayout);
+
+ createSmooksTypeGUI(mainComposite, tool);
}
+ protected void createSmooksTypeGUI(Composite mainComposite, FormToolkit tool) {
+ Composite typeSelectComposite = tool.createComposite(mainComposite);
+ GridData gd = new GridData(GridData.FILL_HORIZONTAL);
+ gd.horizontalSpan = 2;
+ typeSelectComposite.setLayoutData(gd);
+ GridLayout layout = new GridLayout();
+ layout.numColumns = 3;
+ typeSelectComposite.setLayout(layout);
+
+ Label label = tool.createLabel(typeSelectComposite,
+ "Smooks Parse Type : ");
+ gd = new GridData();
+ gd.horizontalSpan = 3;
+
+ label.setLayoutData(gd);
+ createTypeSelectRadioButton(typeSelectComposite, tool, "SAX")
+ .setSelection(true);
+ createTypeSelectRadioButton(typeSelectComposite, tool, "DOM");
+ createTypeSelectRadioButton(typeSelectComposite, tool, "SAX/DOM");
+
+ }
+
+ private Button createTypeSelectRadioButton(Composite parent,
+ FormToolkit tool, String labelName) {
+ Button button = tool.createButton(parent, labelName, SWT.RADIO);
+ return button;
+ }
+
protected SmooksFileBuilder createSmooksFileBulder() {
return new SmooksFileBuilder();
}
@@ -446,7 +492,8 @@
Class<? extends Object> modelClass) {
for (int i = 0; i < items.length; i++) {
TreeItem item = (TreeItem) items[i];
- if(item == null) continue;
+ if (item == null)
+ continue;
if (item.getData(REFERENCE_MODEL) != null) {
} else {
@@ -555,8 +602,9 @@
exp = e;
}
if (exp != null) {
- MessageDialog.openError(getSite().getShell(), "Save Error",
- "Error! \n" + exp.getMessage());
+ ErrorDialog.openError(getSite().getShell(), "Save Error",
+ "Some errors occurs during saving the file.", UIUtils
+ .createErrorStatus(exp));
}
super.doSave(monitor);
commandStackChanged = false;
@@ -817,8 +865,6 @@
String typeID = cw.getInputDataTypeID();
if (UIUtils.setTheProvidersForTreeViewer(viewer, typeID)) {
viewer.setInput(cw.getTreeViewerInputContents());
- // the viewer must be expanded , then the graphics model can
- // calculate the location correctly
try {
// viewer.expandAll();
if (viewer == this.sourceViewer) {
Added:
trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/ui/editors/SmooksMainContentEditFormPage.java
===================================================================
---
trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/ui/editors/SmooksMainContentEditFormPage.java
(rev 0)
+++
trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/ui/editors/SmooksMainContentEditFormPage.java 2008-09-09
09:20:22 UTC (rev 10151)
@@ -0,0 +1,190 @@
+/*******************************************************************************
+ * Copyright (c) 2008 Red Hat, Inc.
+ * Distributed under license by Red Hat, Inc. All rights reserved.
+ * This program is made available under the terms of the
+ * Eclipse Public License v1.0 which accompanies this distribution,
+ * and is available at
http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Red Hat, Inc. - initial API and implementation
+ ******************************************************************************/
+package org.jboss.tools.smooks.ui.editors;
+
+import org.eclipse.jface.viewers.TableViewer;
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.layout.FillLayout;
+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.ui.forms.IManagedForm;
+import org.eclipse.ui.forms.editor.FormEditor;
+import org.eclipse.ui.forms.editor.FormPage;
+import org.eclipse.ui.forms.widgets.FormToolkit;
+import org.eclipse.ui.forms.widgets.ScrolledForm;
+import org.eclipse.ui.forms.widgets.Section;
+import org.jboss.tools.smooks.ui.gef.util.GraphicsConstants;
+import org.jboss.tools.smooks.utils.UIUtils;
+
+/**
+ * @author Dart Peng Date : 2008-9-9
+ */
+public class SmooksMainContentEditFormPage extends FormPage {
+
+ public SmooksMainContentEditFormPage(FormEditor editor, String id,
+ String title) {
+ super(editor, id, title);
+ }
+
+ public SmooksMainContentEditFormPage(String id, String title) {
+ super(id, title);
+ }
+
+ @Override
+ protected void createFormContent(IManagedForm managedForm) {
+ final ScrolledForm form = managedForm.getForm();
+ FormToolkit tool = managedForm.getToolkit();
+ tool.decorateFormHeading(form.getForm());
+ GridLayout gridLayout = UIUtils.createGeneralFormEditorLayout(2);
+ form.getBody().setLayout(gridLayout);
+ Composite rootMainControl = form.getBody();
+ form.setText("Normal Page");
+ createResourceConfigGUI(rootMainControl, tool);
+ createSmooksTypeGUI(rootMainControl, tool);
+ createDataTypeGUI(rootMainControl, tool);
+ }
+
+ protected void createDataTypeGUI(Composite rootMainControl, FormToolkit tool) {
+ Section section = tool.createSection(rootMainControl, Section.TITLE_BAR
+ | Section.DESCRIPTION);
+ section.setText("Data Type");
+
+ GridData gd = new GridData(GridData.FILL_HORIZONTAL);
+ section.setLayoutData(gd);
+ Composite dataTypeComposite = tool.createComposite(section);
+ section.setClient(dataTypeComposite);
+ GridLayout layout = new GridLayout();
+ layout.numColumns = 2;
+ layout.marginHeight = 0;
+ layout.marginWidth = 0;
+ dataTypeComposite.setLayout(layout);
+
+ Composite tableComposite = tool
+ .createComposite(dataTypeComposite);
+ FillLayout fillLayout = new FillLayout();
+ fillLayout.marginHeight = 1;
+ fillLayout.marginWidth = 1;
+ tableComposite.setLayout(fillLayout);
+ TableViewer tableTreeViewer = new TableViewer(tableComposite, SWT.NONE);
+ gd = new GridData(GridData.FILL_BOTH);
+ tableComposite.setLayoutData(gd);
+ tableComposite.setBackground(GraphicsConstants.groupBorderColor);
+ tool.paintBordersFor(tableComposite);
+
+ Composite buttonComposite = tool
+ .createComposite(dataTypeComposite);
+ gd = new GridData(GridData.FILL_VERTICAL);
+ buttonComposite.setLayoutData(gd);
+
+ GridLayout buttonLayout = new GridLayout();
+ buttonComposite.setLayout(buttonLayout);
+
+ Button addButton = tool.createButton(buttonComposite, "New", SWT.NONE);
+ gd = new GridData(GridData.FILL_HORIZONTAL);
+ addButton.setLayoutData(gd);
+ Button removeButton = tool.createButton(buttonComposite, "Delete",
+ SWT.NONE);
+ removeButton.setLayoutData(gd);
+
+ Button upButton = tool.createButton(buttonComposite, "Up", SWT.NONE);
+ upButton.setLayoutData(gd);
+
+ Button downButton = tool
+ .createButton(buttonComposite, "Down", SWT.NONE);
+ downButton.setLayoutData(gd);
+ }
+
+ protected void createResourceConfigGUI(Composite rootMainControl,
+ FormToolkit tool) {
+ Section section = tool
+ .createSection(rootMainControl, Section.TITLE_BAR);
+ section.setText("Resource Config");
+
+ GridData gd = new GridData(GridData.FILL_BOTH);
+ gd.verticalSpan = 2;
+ section.setLayoutData(gd);
+ Composite resourceConfigComposite = tool.createComposite(section);
+ section.setClient(resourceConfigComposite);
+ GridLayout layout = new GridLayout();
+ layout.numColumns = 2;
+ layout.marginHeight = 0;
+ layout.marginWidth = 0;
+ resourceConfigComposite.setLayout(layout);
+
+ Composite tableComposite = tool
+ .createComposite(resourceConfigComposite);
+ FillLayout fillLayout = new FillLayout();
+ fillLayout.marginHeight = 1;
+ fillLayout.marginWidth = 1;
+ tableComposite.setLayout(fillLayout);
+ TableViewer tableTreeViewer = new TableViewer(tableComposite, SWT.NONE);
+ gd = new GridData(GridData.FILL_BOTH);
+ tableComposite.setLayoutData(gd);
+ tableComposite.setBackground(GraphicsConstants.groupBorderColor);
+ tool.paintBordersFor(tableComposite);
+
+ Composite buttonComposite = tool
+ .createComposite(resourceConfigComposite);
+ gd = new GridData(GridData.FILL_VERTICAL);
+ buttonComposite.setLayoutData(gd);
+
+ GridLayout buttonLayout = new GridLayout();
+ buttonComposite.setLayout(buttonLayout);
+
+ Button addButton = tool.createButton(buttonComposite, "New", SWT.NONE);
+ gd = new GridData(GridData.FILL_HORIZONTAL);
+ addButton.setLayoutData(gd);
+ Button removeButton = tool.createButton(buttonComposite, "Delete",
+ SWT.NONE);
+ removeButton.setLayoutData(gd);
+
+ Button upButton = tool.createButton(buttonComposite, "Up", SWT.NONE);
+ upButton.setLayoutData(gd);
+
+ Button downButton = tool
+ .createButton(buttonComposite, "Down", SWT.NONE);
+ downButton.setLayoutData(gd);
+
+ }
+
+ protected void createSmooksTypeGUI(Composite mainComposite, FormToolkit tool) {
+ GridData gd = new GridData(GridData.FILL_HORIZONTAL);
+ Section section = tool.createSection(mainComposite, Section.TITLE_BAR);
+ section.setLayoutData(gd);
+ Composite typeSelectComposite = tool.createComposite(section);
+ section.setClient(typeSelectComposite);
+ section.setText("Smooks Parse Type");
+ GridLayout layout1 = new GridLayout();
+ typeSelectComposite.setLayout(layout1);
+
+ gd = new GridData(GridData.FILL_HORIZONTAL);
+ gd.horizontalSpan = 2;
+ typeSelectComposite.setLayoutData(gd);
+ GridLayout layout = new GridLayout();
+ layout.numColumns = 3;
+ typeSelectComposite.setLayout(layout);
+
+ createTypeSelectRadioButton(typeSelectComposite, tool, "SAX")
+ .setSelection(true);
+ createTypeSelectRadioButton(typeSelectComposite, tool, "DOM");
+ createTypeSelectRadioButton(typeSelectComposite, tool, "SAX/DOM");
+
+ }
+
+ private Button createTypeSelectRadioButton(Composite parent,
+ FormToolkit tool, String labelName) {
+ Button button = tool.createButton(parent, labelName, SWT.RADIO);
+ return button;
+ }
+
+}
Property changes on:
trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/ui/editors/SmooksMainContentEditFormPage.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain