Start line:  
End line:  

Snippet Preview

Snippet HTML Code

Stack Overflow Questions
Copyright 2010 JBoss Inc Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.
 
 
 package org.drools.guvnor.client.ruleeditor;
 
 /*
  * Copyright 2005 JBoss Inc
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
  * You may obtain a copy of the License at
  *
  *      http://www.apache.org/licenses/LICENSE-2.0
  *
  * Unless required by applicable law or agreed to in writing, software
  * distributed under the License is distributed on an "AS IS" BASIS,
  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  * See the License for the specific language governing permissions and
  * limitations under the License.
  */
 
 import  org.drools.guvnor.client.common.DirtyableComposite;
 import  org.drools.guvnor.client.rpc.RuleAsset;
 import  org.drools.guvnor.client.rpc.RuleContentText;
 
 import  com.google.gwt.user.client.ui.ChangeListener;
 import  com.google.gwt.user.client.ui.KeyboardListenerAdapter;
 import  com.google.gwt.user.client.ui.TextArea;
 import  com.google.gwt.user.client.ui.Widget;

This is the default rule editor widget (just text editor based) - more to come later.

Author(s):
michael neale
 
 public class DefaultRuleContentWidget extends DirtyableComposite {
 
     private TextArea              text;
     final private RuleContentText data;
 
     final private RuleAsset       asset;
 
     public DefaultRuleContentWidget(RuleAsset aRuleViewer v) {
         this(a);
     }
 
 
     public DefaultRuleContentWidget(RuleAsset a) {
     	this(a, -1);
     }
 
     public DefaultRuleContentWidget(RuleAsset aint visibleLines) {
          = a;
          = (RuleContentText) .;
 
         if (. == null) {
         	. = "";
         }
 
 
          = new TextArea();
         .setWidth( "100%" );
         .setVisibleLines((visibleLines == -1) ?  16 : visibleLines );
         .setText( . );
 
         .getElement().setAttribute("spellcheck""false");    //NON-NLS
 
         .setStyleName( "default-text-Area" ); //NON-NLS
 
         .addChangeListener( new ChangeListener() {
             public void onChange(Widget w) {
                 . = .getText();
                 makeDirty();
             }
         } );
 
         .addKeyboardListener( new KeyboardListenerAdapter() {
             public void onKeyDown(Widget arg0,
                                   char arg1,
                                   int arg2) {
                 ..println(arg1);
                 if ( arg1 == KEY_TAB ) {
                 	int pos = .getCursorPos();
                     insertText"\t" );
                     .setCursorPos( pos + 1 );
                     .cancelKey();
                     .setFocus(true);
                }
            }
        } );
        initWidget(  );
    }
    void insertText(String ins) {
        int i = .getCursorPos();
        String left = .getText().substring( 0,
                                                i );
        String right = .getText().substring( i,
                                                 .getText().length() );
        .setText( left + ins + right );
        this..content = .getText();
    }
New to GrepCode? Check out our FAQ X