[jboss-svn-commits] JBL Code SVN: r12342 - labs/jbossrules/trunk/drools-eclipse/drools-guided-editor-plugin/src/org/drools/eclipse/rulebuilder/ui.
jboss-svn-commits at lists.jboss.org
jboss-svn-commits at lists.jboss.org
Tue Jun 5 16:02:12 EDT 2007
Author: arhan
Date: 2007-06-05 16:02:11 -0400 (Tue, 05 Jun 2007)
New Revision: 12342
Added:
labs/jbossrules/trunk/drools-eclipse/drools-guided-editor-plugin/src/org/drools/eclipse/rulebuilder/ui/LHSDSLSentenceWidget.java
labs/jbossrules/trunk/drools-eclipse/drools-guided-editor-plugin/src/org/drools/eclipse/rulebuilder/ui/RHSDSLSentenceWidget.java
Modified:
labs/jbossrules/trunk/drools-eclipse/drools-guided-editor-plugin/src/org/drools/eclipse/rulebuilder/ui/DSLSentenceWidget.java
labs/jbossrules/trunk/drools-eclipse/drools-guided-editor-plugin/src/org/drools/eclipse/rulebuilder/ui/RuleModeller.java
Log:
rhs and lhs split for DSLSentenseWidget
Modified: labs/jbossrules/trunk/drools-eclipse/drools-guided-editor-plugin/src/org/drools/eclipse/rulebuilder/ui/DSLSentenceWidget.java
===================================================================
--- labs/jbossrules/trunk/drools-eclipse/drools-guided-editor-plugin/src/org/drools/eclipse/rulebuilder/ui/DSLSentenceWidget.java 2007-06-05 17:53:19 UTC (rev 12341)
+++ labs/jbossrules/trunk/drools-eclipse/drools-guided-editor-plugin/src/org/drools/eclipse/rulebuilder/ui/DSLSentenceWidget.java 2007-06-05 20:02:11 UTC (rev 12342)
@@ -20,116 +20,109 @@
import org.eclipse.ui.forms.widgets.FormToolkit;
import org.eclipse.ui.forms.widgets.ImageHyperlink;
-
/**
* This displays a widget to edit a DSL sentence.
*
- * @author Michael Neale
* @author Ahti Kitsik
* @author Anton Arhipov
*/
-public class DSLSentenceWidget extends Widget {
+public abstract class DSLSentenceWidget extends Widget {
- private final DSLSentence sentence;
-
- private List widgets = new ArrayList();
-
- public DSLSentenceWidget(FormToolkit toolkit,
- Composite parent,
- DSLSentence sentence, RuleModeller modeller, int index) {
- super(parent,toolkit,modeller,index);
-
- this.sentence = sentence;
-
- GridLayout l = new GridLayout();
- l.numColumns = sentence.sentence.length() + 1;
- l.verticalSpacing = 0;
- l.marginTop = 0;
- l.marginHeight = 2;
- l.marginBottom = 0;
- parent.setLayout( l );
-
- makeWidget(sentence.sentence);
-
- //TODO: add
- //addDeleteAction(parent);
- }
+ private final DSLSentence sentence;
- private void addDeleteAction(Composite parent) {
- ImageHyperlink delLink = addImage( parent, "icons/delete_obj.gif" );
- delLink.addHyperlinkListener( new IHyperlinkListener() {
+ private List widgets = new ArrayList();
- public void linkActivated(HyperlinkEvent e) {
- MessageBox dialog = new MessageBox( Display.getCurrent().getActiveShell(),
- SWT.YES | SWT.NO | SWT.ICON_WARNING );
- dialog.setMessage( "Remove this DSL sentense?" );
- dialog.setText( "Remove this DSL sentense?" );
- if ( dialog.open() == SWT.YES ) {
- //TODO: remove the current sentense from model
- getModeller().reloadLhs();
- getModeller().reloadRhs();
- getModeller().setDirty( true );
- }
- }
+ public DSLSentenceWidget(FormToolkit toolkit, Composite parent,
+ DSLSentence sentence, RuleModeller modeller, int index) {
+ super(parent, toolkit, modeller, index);
+ this.sentence = sentence;
+ GridLayout l = new GridLayout();
+ l.numColumns = sentence.sentence.length() + 1;
+ l.verticalSpacing = 0;
+ l.marginTop = 0;
+ l.marginHeight = 2;
+ l.marginBottom = 0;
+ parent.setLayout(l);
+
+ makeWidget();
+ addDeleteAction();
+ }
+
+ protected abstract void updateModel();
+
+ private void addDeleteAction() {
+ ImageHyperlink delLink = addImage(parent, "icons/delete_obj.gif");
+ delLink.addHyperlinkListener(new IHyperlinkListener() {
+
+ public void linkActivated(HyperlinkEvent e) {
+ MessageBox dialog = new MessageBox(Display.getCurrent()
+ .getActiveShell(), SWT.YES | SWT.NO | SWT.ICON_WARNING);
+ dialog.setMessage("Remove this DSL sentense?");
+ dialog.setText("Remove this DSL sentense?");
+ if (dialog.open() == SWT.YES){
+ updateModel();
+ }
+ }
+
public void linkEntered(HyperlinkEvent e) {
}
public void linkExited(HyperlinkEvent e) {
- }}
- );
- delLink.setToolTipText( "Remove this condition." );
+ }
+ });
+ delLink.setToolTipText("Remove this condition.");
}
- private void makeWidget(String dslLine) {
- char[] chars = dslLine.toCharArray();
- Text currentBox = null;
- Label currentLabel = null;
- for ( int i = 0; i < chars.length; i++ ) {
- char c = chars[i];
- if (c == '{') {
- currentLabel = null;
- currentBox = toolkit.createText(parent, "");
-
- currentBox.addModifyListener(new ModifyListener(){
+ private void makeWidget() {
+ char[] chars = this.sentence.sentence.toCharArray();
+ Text currentBox = null;
+ Label currentLabel = null;
+ for (int i = 0; i < chars.length; i++) {
+ char c = chars[i];
+ if (c == '{') {
+ currentLabel = null;
+ currentBox = toolkit.createText(parent, "");
+
+ currentBox.addModifyListener(new ModifyListener() {
public void modifyText(ModifyEvent e) {
updateSentence();
+ getModeller().setDirty(true);
}
- });
-
- widgets.add(currentBox);
-
- } else if (c == '}') {
- currentBox = null;
- } else {
- if (currentBox == null && currentLabel == null) {
- currentLabel = toolkit.createLabel(parent, "");
- widgets.add(currentLabel);
- }
- if (currentLabel != null) {
- currentLabel.setText( currentLabel.getText() + c );
- } else if (currentBox != null) {
- currentBox.setText( currentBox.getText() + c );
- }
- }
- }
-
- toolkit.paintBordersFor( parent );
+ });
+
+ widgets.add(currentBox);
+
+ } else if (c == '}') {
+ currentBox = null;
+ } else {
+ if (currentBox == null && currentLabel == null) {
+ currentLabel = toolkit.createLabel(parent, "");
+ widgets.add(currentLabel);
+ }
+ if (currentLabel != null) {
+ currentLabel.setText(currentLabel.getText() + c);
+ } else if (currentBox != null) {
+ currentBox.setText(currentBox.getText() + c);
+ }
+ }
+ }
+
+ toolkit.paintBordersFor(parent);
}
-
- protected void updateSentence() {
- String newSentence = "";
- for ( Iterator iter = widgets.iterator(); iter.hasNext(); ) {
- Control wid = (Control) iter.next();
- if (wid instanceof Label) {
- newSentence = newSentence + ((Label) wid).getText();
- } else if (wid instanceof Text) {
- newSentence = newSentence + " {" + ((Text) wid).getText() + "} ";
- }
- }
- this.sentence.sentence = newSentence.trim();
- }
-
+ protected void updateSentence() {
+ String newSentence = "";
+ for (Iterator iter = widgets.iterator(); iter.hasNext();) {
+ Control wid = (Control) iter.next();
+ if (wid instanceof Label) {
+ newSentence = newSentence + ((Label) wid).getText();
+ } else if (wid instanceof Text) {
+ newSentence = newSentence + "{" + ((Text) wid).getText() + "}";
+ }
+ }
+ this.sentence.sentence = newSentence.trim();
+ }
+
}
Added: labs/jbossrules/trunk/drools-eclipse/drools-guided-editor-plugin/src/org/drools/eclipse/rulebuilder/ui/LHSDSLSentenceWidget.java
===================================================================
--- labs/jbossrules/trunk/drools-eclipse/drools-guided-editor-plugin/src/org/drools/eclipse/rulebuilder/ui/LHSDSLSentenceWidget.java (rev 0)
+++ labs/jbossrules/trunk/drools-eclipse/drools-guided-editor-plugin/src/org/drools/eclipse/rulebuilder/ui/LHSDSLSentenceWidget.java 2007-06-05 20:02:11 UTC (rev 12342)
@@ -0,0 +1,25 @@
+package org.drools.eclipse.rulebuilder.ui;
+
+import org.drools.brms.client.modeldriven.brxml.DSLSentence;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.ui.forms.widgets.FormToolkit;
+
+public class LHSDSLSentenceWidget extends DSLSentenceWidget {
+
+ public LHSDSLSentenceWidget(FormToolkit toolkit, Composite parent,
+ DSLSentence sentence, RuleModeller modeller, int index) {
+ super(toolkit, parent, sentence, modeller, index);
+
+ }
+
+ protected void updateModel() {
+ if ( getModeller().getModel().removeLhsItem( index ) ) {
+ getModeller().reloadLhs();
+ } else {
+ showMessage( "Can't remove that item as it is used in the action part of the rule." );
+ }
+ getModeller().reloadLhs();
+ getModeller().setDirty(true);
+ }
+
+}
Added: labs/jbossrules/trunk/drools-eclipse/drools-guided-editor-plugin/src/org/drools/eclipse/rulebuilder/ui/RHSDSLSentenceWidget.java
===================================================================
--- labs/jbossrules/trunk/drools-eclipse/drools-guided-editor-plugin/src/org/drools/eclipse/rulebuilder/ui/RHSDSLSentenceWidget.java (rev 0)
+++ labs/jbossrules/trunk/drools-eclipse/drools-guided-editor-plugin/src/org/drools/eclipse/rulebuilder/ui/RHSDSLSentenceWidget.java 2007-06-05 20:02:11 UTC (rev 12342)
@@ -0,0 +1,20 @@
+package org.drools.eclipse.rulebuilder.ui;
+
+import org.drools.brms.client.modeldriven.brxml.DSLSentence;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.ui.forms.widgets.FormToolkit;
+
+public class RHSDSLSentenceWidget extends DSLSentenceWidget {
+
+ public RHSDSLSentenceWidget(FormToolkit toolkit, Composite parent,
+ DSLSentence sentence, RuleModeller modeller, int index) {
+ super(toolkit, parent, sentence, modeller, index);
+ }
+
+ protected void updateModel() {
+ getModeller().getModel().removeRhsItem( index );
+ getModeller().reloadRhs();
+ getModeller().setDirty( true );
+ }
+
+}
Modified: labs/jbossrules/trunk/drools-eclipse/drools-guided-editor-plugin/src/org/drools/eclipse/rulebuilder/ui/RuleModeller.java
===================================================================
--- labs/jbossrules/trunk/drools-eclipse/drools-guided-editor-plugin/src/org/drools/eclipse/rulebuilder/ui/RuleModeller.java 2007-06-05 17:53:19 UTC (rev 12341)
+++ labs/jbossrules/trunk/drools-eclipse/drools-guided-editor-plugin/src/org/drools/eclipse/rulebuilder/ui/RuleModeller.java 2007-06-05 20:02:11 UTC (rev 12342)
@@ -41,306 +41,262 @@
*/
public class RuleModeller {
- private Composite ifComposite;
+ private Composite ifComposite;
- private Composite thenComposite;
-
- private Composite optionsComposite;
+ private Composite thenComposite;
- private final ScrolledForm form;
+ private Composite optionsComposite;
- private final FormToolkit toolkit;
+ private final ScrolledForm form;
- private RuleModel model;
+ private final FormToolkit toolkit;
- private boolean dirty;
+ private RuleModel model;
- private RuleEditor editor;
+ private boolean dirty;
- public boolean isDirty() {
- return dirty;
- }
+ private RuleEditor editor;
- public void setDirty(boolean dirty) {
- this.dirty = dirty;
- editor.dirtyPropertyChanged();
- }
+ public boolean isDirty() {
+ return dirty;
+ }
- public RuleModeller(ScrolledForm form,
- FormToolkit toolkit,
- RuleModel model,
- RuleEditor editor) {
+ public void setDirty(boolean dirty) {
+ this.dirty = dirty;
+ editor.dirtyPropertyChanged();
+ }
- this.form = form;
- this.toolkit = toolkit;
- this.model = model;
- this.editor = editor;
+ public RuleModeller(ScrolledForm form, FormToolkit toolkit,
+ RuleModel model, RuleEditor editor) {
- form.setText( "Rule Builder" );
+ this.form = form;
+ this.toolkit = toolkit;
+ this.model = model;
+ this.editor = editor;
- ColumnLayout colLayout = new ColumnLayout();
- colLayout.minNumColumns = 1;
- colLayout.maxNumColumns = 1;
+ form.setText("Rule Builder");
- form.getBody().setLayout( colLayout );
+ ColumnLayout colLayout = new ColumnLayout();
+ colLayout.minNumColumns = 1;
+ colLayout.maxNumColumns = 1;
- // addToolBar(toolkit, form);
+ form.getBody().setLayout(colLayout);
- Shell shell = new Shell( Display.getCurrent() );
- Window conditionPopup = new AddNewConditionDialog( shell,
- toolkit,
- this );
- Window actionPopup = new AddNewActionDialog( shell,
- toolkit,
- this );
+ // addToolBar(toolkit, form);
- Window optionsPopup = new RuleAttributesDialog(shell, toolkit, this);
-
- Section ifSection = createMainSection( form,
- toolkit,
- "IF",
- conditionPopup );
- Section thenSection = createMainSection( form,
- toolkit,
- "THEN",
- actionPopup );
- Section optionsSection = createMainSection( form,
- toolkit,
- "(options)",
- optionsPopup );
-
- ColumnLayout layout = new ColumnLayout();
- layout.minNumColumns = 1;
- layout.maxNumColumns = 1;
- // layout.verticalSpacing = 0;
+ Shell shell = new Shell(Display.getCurrent());
+ Window conditionPopup = new AddNewConditionDialog(shell, toolkit, this);
+ Window actionPopup = new AddNewActionDialog(shell, toolkit, this);
- ((Composite) (ifSection.getClient())).setLayout( layout );
- ((Composite) (thenSection.getClient())).setLayout( layout );
- ((Composite) (optionsSection.getClient())).setLayout( layout );
- ifSection.setLayout( layout );
- thenSection.setLayout( layout );
- optionsSection.setLayout( layout );
+ Window optionsPopup = new RuleAttributesDialog(shell, toolkit, this);
- ifComposite = (Composite) ifSection.getClient();
- thenComposite = (Composite) thenSection.getClient();
- optionsComposite = (Composite) optionsSection.getClient();
+ Section ifSection = createMainSection(form, toolkit, "IF",
+ conditionPopup);
+ Section thenSection = createMainSection(form, toolkit, "THEN",
+ actionPopup);
+ Section optionsSection = createMainSection(form, toolkit, "(options)",
+ optionsPopup);
- }
+ ColumnLayout layout = new ColumnLayout();
+ layout.minNumColumns = 1;
+ layout.maxNumColumns = 1;
+ // layout.verticalSpacing = 0;
- public SuggestionCompletionEngine getSuggestionCompletionEngine() {
- return editor.getCompletionEngine();
- }
+ ((Composite) (ifSection.getClient())).setLayout(layout);
+ ((Composite) (thenSection.getClient())).setLayout(layout);
+ ((Composite) (optionsSection.getClient())).setLayout(layout);
+ ifSection.setLayout(layout);
+ thenSection.setLayout(layout);
+ optionsSection.setLayout(layout);
- public RuleModel getModel() {
- return model;
- }
+ ifComposite = (Composite) ifSection.getClient();
+ thenComposite = (Composite) thenSection.getClient();
+ optionsComposite = (Composite) optionsSection.getClient();
- public void setModel(RuleModel model) {
- this.model = model;
- }
+ }
- private void clearComposite(Composite composite) {
- if ( composite != null ) {
- Control[] c = composite.getChildren();
- for ( int i = 0; i < c.length; i++ ) {
- Control c2 = c[i];
- c2.dispose();
- }
- }
- }
+ public SuggestionCompletionEngine getSuggestionCompletionEngine() {
+ return editor.getCompletionEngine();
+ }
- private void reloadCommon() {
- toolkit.paintBordersFor( form.getBody() );
- form.redraw();
- Dialog.applyDialogFont( form.getBody() );
- form.reflow( true );
- }
+ public RuleModel getModel() {
+ return model;
+ }
- public void reloadRhs() {
- clearComposite( thenComposite );
- redrawRhs();
- reloadCommon();
- }
+ public void setModel(RuleModel model) {
+ this.model = model;
+ }
- public void reloadLhs() {
- clearComposite( ifComposite );
- redrawLhs();
- reloadCommon();
- }
-
- public void reloadOptions() {
- clearComposite( optionsComposite );
- redrawOptions();
- reloadCommon();
- }
+ private void clearComposite(Composite composite) {
+ if (composite != null) {
+ Control[] c = composite.getChildren();
+ for (int i = 0; i < c.length; i++) {
+ Control c2 = c[i];
+ c2.dispose();
+ }
+ }
+ }
- public void reloadWidgets() {
- reloadLhs();
- reloadRhs();
- reloadOptions();
- }
+ private void reloadCommon() {
+ toolkit.paintBordersFor(form.getBody());
+ form.redraw();
+ Dialog.applyDialogFont(form.getBody());
+ form.reflow(true);
+ }
- private void redrawOptions(){
- Composite comp = toolkit.createComposite( optionsComposite );
- new RuleAttributeWidget(toolkit, comp, this);
- }
-
-
- private void redrawRhs() {
- for ( int i = 0; i < model.rhs.length; i++ ) {
- IAction action = model.rhs[i];
+ public void reloadRhs() {
+ clearComposite(thenComposite);
+ redrawRhs();
+ reloadCommon();
+ }
- if ( action instanceof ActionSetField ) {
- addActionSetFieldWidget( action,
- i );
- } else if ( action instanceof ActionAssertFact ) {
- addActionAssertFactWidget( action,
- i );
- } else if ( action instanceof ActionRetractFact ) {
- addActionRetractFactWidget( action,
- i );
- } else if ( action instanceof DSLSentence ) {
- addDSLSentenceWidget( i, (DSLSentence) action, thenComposite );
- }
+ public void reloadLhs() {
+ clearComposite(ifComposite);
+ redrawLhs();
+ reloadCommon();
+ }
- }
- }
+ public void reloadOptions() {
+ clearComposite(optionsComposite);
+ redrawOptions();
+ reloadCommon();
+ }
- private void redrawLhs() {
- for ( int i = 0; i < model.lhs.length; i++ ) {
- IPattern pattern = model.lhs[i];
+ public void reloadWidgets() {
+ reloadLhs();
+ reloadRhs();
+ reloadOptions();
+ }
- if ( pattern instanceof FactPattern ) {
- addFactPatternWidget( i,
- (FactPattern) pattern );
- }
- if ( pattern instanceof CompositeFactPattern ) {
- addCompositeFactPatternWidget( i,
- (CompositeFactPattern) pattern );
- } else if ( pattern instanceof DSLSentence ) {
- // skip for now
- } else {
- // dont' care
- }
- }
+ private void redrawOptions() {
+ Composite comp = toolkit.createComposite(optionsComposite);
+ new RuleAttributeWidget(toolkit, comp, this);
+ }
- for ( int i = 0; i < model.lhs.length; i++ ) {
- IPattern pattern = model.lhs[i];
- if ( pattern instanceof DSLSentence ) {
- addDSLSentenceWidget( i, (DSLSentence) pattern, ifComposite );
- }
- }
- }
+ private void redrawRhs() {
+ for (int i = 0; i < model.rhs.length; i++) {
+ IAction action = model.rhs[i];
- private void addActionRetractFactWidget(IAction action,
- int i) {
- Composite comp = toolkit.createComposite( thenComposite );
- new ActionRetractFactWidget( toolkit,
- comp,
- this,
- (ActionRetractFact) action,
- i );
- }
+ if (action instanceof ActionSetField) {
+ addActionSetFieldWidget(action, i);
+ } else if (action instanceof ActionAssertFact) {
+ addActionAssertFactWidget(action, i);
+ } else if (action instanceof ActionRetractFact) {
+ addActionRetractFactWidget(action, i);
+ } else if (action instanceof DSLSentence) {
+ addRHSDSLSentenceWidget(i, (DSLSentence) action);
+ }
- private void addActionAssertFactWidget(IAction action,
- int i) {
- Composite comp = toolkit.createComposite( thenComposite );
- new ActionAssertFactWidget( toolkit,
- comp,
- this,
- (ActionAssertFact) action,
- i );
+ }
+ }
- }
+ private void redrawLhs() {
+ for (int i = 0; i < model.lhs.length; i++) {
+ IPattern pattern = model.lhs[i];
- private void addActionSetFieldWidget(IAction action,
- int i) {
- Composite comp = toolkit.createComposite( thenComposite );
- new ActionSetFieldWidget( toolkit,
- comp,
- this,
- model,
- (ActionSetField) action,
- i );
- }
+ if (pattern instanceof FactPattern) {
+ addFactPatternWidget(i, (FactPattern) pattern);
+ }
+ if (pattern instanceof CompositeFactPattern) {
+ addCompositeFactPatternWidget(i, (CompositeFactPattern) pattern);
+ } else if (pattern instanceof DSLSentence) {
+ // skip for now
+ } else {
+ // dont' care
+ }
+ }
- private void addDSLSentenceWidget(int idx,
- DSLSentence pattern, Composite sectionComposite) {
- Composite comp = toolkit.createComposite( sectionComposite );
- new DSLSentenceWidget( toolkit,
- comp,
- pattern,
- this,
- idx );
- }
+ for (int i = 0; i < model.lhs.length; i++) {
+ IPattern pattern = model.lhs[i];
+ if (pattern instanceof DSLSentence) {
+ addLHSDSLSentenceWidget(i, (DSLSentence) pattern);
+ }
+ }
+ }
- private void addCompositeFactPatternWidget(int idx,
- CompositeFactPattern pattern) {
- Composite comp = toolkit.createComposite( ifComposite );
- new CompositeFactPatternWidget( toolkit,
- comp,
- this,
- pattern,
- idx );
- }
+ private void addActionRetractFactWidget(IAction action, int i) {
+ Composite comp = toolkit.createComposite(thenComposite);
+ new ActionRetractFactWidget(toolkit, comp, this,
+ (ActionRetractFact) action, i);
+ }
- private void addFactPatternWidget(int idx,
- FactPattern pattern) {
- Composite comp = toolkit.createComposite( ifComposite );
- new FactPatternWidget( toolkit,
- comp,
- this,
- pattern,
- null,
- idx );
- }
+ private void addActionAssertFactWidget(IAction action, int i) {
+ Composite comp = toolkit.createComposite(thenComposite);
+ new ActionAssertFactWidget(toolkit, comp, this,
+ (ActionAssertFact) action, i);
- private Section createMainSection(final ScrolledForm form,
- FormToolkit toolkit,
- String title,
- Window popup) {
- ColumnLayout layout = new ColumnLayout();
- layout.minNumColumns = 1;
- layout.maxNumColumns = 1;
- Section l1Sect = toolkit.createSection( form.getBody(),
- ExpandableComposite.TWISTIE | ExpandableComposite.TITLE_BAR | ExpandableComposite.EXPANDED );
- l1Sect.setActiveToggleColor( toolkit.getHyperlinkGroup().getActiveForeground() );
- l1Sect.setToggleColor( toolkit.getColors().getColor( FormColors.SEPARATOR ) );
- l1Sect.setText( title );
- createAddToolItem( l1Sect, popup );
- Composite comp = toolkit.createComposite( l1Sect );
- l1Sect.setClient( comp );
- return l1Sect;
- }
+ }
- private void createAddToolItem(Section sect,
- final Window popup) {
- ToolBar tbar = new ToolBar( sect,
- SWT.FLAT | SWT.HORIZONTAL );
- ToolItem titem = new ToolItem( tbar,
- SWT.SEPARATOR );
- titem = new ToolItem( tbar,
- SWT.PUSH );
- titem.setImage( PlatformUI.getWorkbench().getSharedImages().getImage( ISharedImages.IMG_TOOL_NEW_WIZARD ) );
+ private void addActionSetFieldWidget(IAction action, int i) {
+ Composite comp = toolkit.createComposite(thenComposite);
+ new ActionSetFieldWidget(toolkit, comp, this, model,
+ (ActionSetField) action, i);
+ }
- titem.addListener( SWT.Selection,
- new Listener() {
- public void handleEvent(Event event) {
- popup.open();
- }
- } );
- sect.setTextClient( tbar );
- }
+ private void addRHSDSLSentenceWidget(int idx, DSLSentence pattern) {
+ Composite comp = toolkit.createComposite(thenComposite);
+ new RHSDSLSentenceWidget(toolkit, comp, pattern, this, idx);
+ }
- public void refresh() {
- ifComposite.layout();
- ifComposite.redraw();
-
- thenComposite.layout();
- thenComposite.redraw();
-
- optionsComposite.layout();
- optionsComposite.redraw();
- }
+ private void addLHSDSLSentenceWidget(int idx, DSLSentence pattern) {
+ Composite comp = toolkit.createComposite(ifComposite);
+ new LHSDSLSentenceWidget(toolkit, comp, pattern, this, idx);
+ }
+ private void addCompositeFactPatternWidget(int idx,
+ CompositeFactPattern pattern) {
+ Composite comp = toolkit.createComposite(ifComposite);
+ new CompositeFactPatternWidget(toolkit, comp, this, pattern, idx);
+ }
+
+ private void addFactPatternWidget(int idx, FactPattern pattern) {
+ Composite comp = toolkit.createComposite(ifComposite);
+ new FactPatternWidget(toolkit, comp, this, pattern, null, idx);
+ }
+
+ private Section createMainSection(final ScrolledForm form,
+ FormToolkit toolkit, String title, Window popup) {
+ ColumnLayout layout = new ColumnLayout();
+ layout.minNumColumns = 1;
+ layout.maxNumColumns = 1;
+ Section l1Sect = toolkit.createSection(form.getBody(),
+ ExpandableComposite.TWISTIE | ExpandableComposite.TITLE_BAR
+ | ExpandableComposite.EXPANDED);
+ l1Sect.setActiveToggleColor(toolkit.getHyperlinkGroup()
+ .getActiveForeground());
+ l1Sect.setToggleColor(toolkit.getColors()
+ .getColor(FormColors.SEPARATOR));
+ l1Sect.setText(title);
+ createAddToolItem(l1Sect, popup);
+ Composite comp = toolkit.createComposite(l1Sect);
+ l1Sect.setClient(comp);
+ return l1Sect;
+ }
+
+ private void createAddToolItem(Section sect, final Window popup) {
+ ToolBar tbar = new ToolBar(sect, SWT.FLAT | SWT.HORIZONTAL);
+ ToolItem titem = new ToolItem(tbar, SWT.SEPARATOR);
+ titem = new ToolItem(tbar, SWT.PUSH);
+ titem.setImage(PlatformUI.getWorkbench().getSharedImages().getImage(
+ ISharedImages.IMG_TOOL_NEW_WIZARD));
+
+ titem.addListener(SWT.Selection, new Listener() {
+ public void handleEvent(Event event) {
+ popup.open();
+ }
+ });
+ sect.setTextClient(tbar);
+ }
+
+ public void refresh() {
+ ifComposite.layout();
+ ifComposite.redraw();
+
+ thenComposite.layout();
+ thenComposite.redraw();
+
+ optionsComposite.layout();
+ optionsComposite.redraw();
+ }
+
}
More information about the jboss-svn-commits
mailing list