<commit_before>package org.drools.brms.client.ruleeditor;

import org.drools.brms.client.common.ErrorPopup;
import org.drools.brms.client.common.LoadingPopup;
import org.drools.brms.client.rpc.RepositoryServiceFactory;
import org.drools.brms.client.rpc.RuleAsset;

import com.google.gwt.user.client.Command;
import com.google.gwt.user.client.rpc.AsyncCallback;
import com.google.gwt.user.client.ui.Composite;
import com.google.gwt.user.client.ui.FlexTable;
import com.google.gwt.user.client.ui.HasHorizontalAlignment;
import com.google.gwt.user.client.ui.HasVerticalAlignment;
import com.google.gwt.user.client.ui.Widget;
import com.google.gwt.user.client.ui.FlexTable.FlexCellFormatter;

/**
 * The main layout parent/controller the rule viewer.
 * 
 * @author <NAME>
 */
public class RuleViewer extends Composite {

    private Command           closeCommand;

    protected RuleAsset       asset;

    private final FlexTable layout;
    private boolean readOnly;

    private MetaDataWidget metaWidget;

    private ActionToolbar toolbar;

    private Widget editor;

    private RuleDocumentWidget doco;

    public RuleViewer(RuleAsset asset) {
        this(asset, false);
    }
    
    /**
     * @param UUID The resource to open.
     * @param format The type of resource (may determine what editor is used).
     * @param name The name to be displayed.
     * @param historicalReadOnly true if this is a read only view for historical purposes.
     */
    public RuleViewer(RuleAsset asset, boolean historicalReadOnly) {
        this.asset = asset;
        this.readOnly = historicalReadOnly;
        layout = new FlexTable();
        
        doWidgets();
        
        initWidget( this.layout );
        
        LoadingPopup.close();
    }

    /**
     * This will actually load up the data (this is called by the callback 
     * when we get the data back from the server,
     * also determines what widgets to load up).
     */
    private void doWidgets() {
        this.layout.clear();
        
        metaWidget = new MetaDataWidget( this.asset.metaData,
                                                              readOnly, this.asset.uuid, new Command() {

                                                                public void execute() {
                                                                    refreshDataAndView();
                                                                }
            
        });


        //metaWidget.setWidth( "100%" );

        //now the main layout table
        FlexCellFormatter formatter = layout.getFlexCellFormatter();
        layout.setWidget( 0,
                          1,
                          metaWidget );
        formatter.setRowSpan( 0,
                              1,
                              3 );
        formatter.setVerticalAlignment( 0, 0, HasVerticalAlignment.ALIGN_TOP );<commit_msg>fixed alignment cockup<commit_after>package org.drools.brms.client.ruleeditor;

import org.drools.brms.client.common.ErrorPopup;
import org.drools.brms.client.common.LoadingPopup;
import org.drools.brms.client.rpc.RepositoryServiceFactory;
import org.drools.brms.client.rpc.RuleAsset;

import com.google.gwt.user.client.Command;
import com.google.gwt.user.client.rpc.AsyncCallback;
import com.google.gwt.user.client.ui.Composite;
import com.google.gwt.user.client.ui.FlexTable;
import com.google.gwt.user.client.ui.HasHorizontalAlignment;
import com.google.gwt.user.client.ui.HasVerticalAlignment;
import com.google.gwt.user.client.ui.Widget;
import com.google.gwt.user.client.ui.FlexTable.FlexCellFormatter;

/**
 * The main layout parent/controller the rule viewer.
 * 
 * @author <NAME>
 */
public class RuleViewer extends Composite {

    private Command           closeCommand;

    protected RuleAsset       asset;

    private final FlexTable layout;
    private boolean readOnly;

    private MetaDataWidget metaWidget;

    private ActionToolbar toolbar;

    private Widget editor;

    private RuleDocumentWidget doco;

    public RuleViewer(RuleAsset asset) {
        this(asset, false);
    }
    
    /**
     * @param UUID The resource to open.
     * @param format The type of resource (may determine what editor is used).
     * @param name The name to be displayed.
     * @param historicalReadOnly true if this is a read only view for historical purposes.
     */
    public RuleViewer(RuleAsset asset, boolean historicalReadOnly) {
        this.asset = asset;
        this.readOnly = historicalReadOnly;
        layout = new FlexTable();
        
        doWidgets();
        
        initWidget( this.layout );
        
        LoadingPopup.close();
    }

    /**
     * This will actually load up the data (this is called by the callback 
     * when we get the data back from the server,
     * also determines what widgets to load up).
     */
    private void doWidgets() {
        this.layout.clear();
        
        metaWidget = new MetaDataWidget( this.asset.metaData,
                                                              readOnly, this.asset.uuid, new Command() {

                                                                public void execute() {
                                                                    refreshDataAndView();
                                                                }
            
        });


        //metaWidget.setWidth( "100%" );

        //now the main layout table
        FlexCellFormatter formatter = layout.getFlexCellFormatter();
        layout.setWidget( 0,
                          1,
                          metaWidget );
        formatter.setRowSpan( 0,
                              1,
                              3 );
        formatter.setVerticalAlignment( 0, 1, HasVerticalAlignment.ALIGN_TOP );
{'fraction_non_alphanumeric': 0.08283002588438308, 'fraction_numerical': 0.003451251078515962, 'mean_word_length': 1.8204379562043795, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 5, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 16, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '7490091', 'n_tokens_mistral': 1502, 'n_tokens_neox': 1451, 'n_words': 384}