⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 dsleditor.java

📁 jboss规则引擎
💻 JAVA
📖 第 1 页 / 共 2 页
字号:

            public void mouseDown(MouseEvent e) {}

            public void mouseUp(MouseEvent e) {}
            
        });        
        
    }

    private void createDescriptionField(Composite parent) {
        Label descLbl = new Label(parent, SWT.NONE);
        descLbl.setText( "Description:" );
        GridData gridData = new GridData (GridData.HORIZONTAL_ALIGN_BEGINNING);
        gridData.widthHint = 80;
        descLbl.setLayoutData(gridData);
        
        descriptionText = new Text(parent, SWT.BORDER);
        descriptionText.setLayoutData(new GridData (GridData.FILL_HORIZONTAL));
        descriptionText.setText(  "" + model.getDescription() ); //no nulls !
        descriptionText.addModifyListener( new ModifyListener() {

            public void modifyText(ModifyEvent e) {
                String text = descriptionText.getText();
                if (!text.equals( model.getDescription() )) {
                    model.setDescription( text );
                    makeDirty();
                }                
            }
            
        });
    }
    
    private void createMappingViewField(Composite parent) {        
        Label mapping = new Label(parent, SWT.NONE);
        mapping.setText( "Mapping:" );
        GridData gridData = new GridData (GridData.HORIZONTAL_ALIGN_BEGINNING);
        gridData.widthHint = 80;
        mapping.setLayoutData(gridData);
        
        mappingText = new Text(parent, SWT.BORDER);
        mappingText.setEditable( false );

        mappingText.setLayoutData(new GridData (GridData.FILL_HORIZONTAL));
    }    
    
    private void createExpressionViewField(Composite parent) {

        Label expr = new Label(parent, SWT.NONE);
        expr.setText( "Expression:" );
        GridData gridData = new GridData (GridData.HORIZONTAL_ALIGN_BEGINNING);
        gridData.widthHint = 80;
        expr.setLayoutData(gridData);
        
        exprText = new Text(parent, SWT.BORDER);
        exprText.setEditable( false );
        gridData = new GridData (GridData.FILL_HORIZONTAL);
        
        exprText.setLayoutData(gridData);

    }

    /** Refreshes the table do make sure it is up to date with the model. */
    private void refreshModel() {
        tableViewer.setInput( model );
    }
    
    private void createEditButton(Composite parent) {
        // Create and configure the "Add" button
        Button add = new Button(parent, SWT.PUSH | SWT.CENTER);
        add.setText("Edit");

        GridData gridData = new GridData (GridData.HORIZONTAL_ALIGN_BEGINNING);
        gridData.widthHint = 80;
        add.setLayoutData(gridData);
     
        add.addSelectionListener(new SelectionAdapter() {
        
            // Add a task to the ExampleTaskList and refresh the view
            public void widgetSelected(SelectionEvent e) {                
                showEditPopup();                
            }


        });
    }  
    
    private void showEditPopup() {
        MappingEditor editor = new MappingEditor(getSite().getShell());
        editor.create();
        editor.getShell().setText("Edit language mapping");
        editor.setTitle( "Edit an existing language mapping item." );
        editor.setTitleImage( getTitleImage() );
        
        editor.setNLMappingItem( getCurrentSelected() );
        
        editor.open();
        if (!editor.isCancelled()) {
            refreshModel();
            makeDirty();
        }
    }    
    
    private void createDeleteButton(Composite parent) {
        // Create and configure the "Add" button
        Button add = new Button(parent, SWT.PUSH | SWT.CENTER);
        add.setText("Remove");

        GridData gridData = new GridData (GridData.HORIZONTAL_ALIGN_BEGINNING);
        gridData.widthHint = 80;
        add.setLayoutData(gridData);
        add.addSelectionListener(new SelectionAdapter() {        
            // Add a task to the ExampleTaskList and refresh the view
            public void widgetSelected(SelectionEvent e) {
                model.removeMapping( getCurrentSelected() );
                refreshModel();
                makeDirty();
            }


        });
    }    

    
    /**
     * Return the selected item from the table grid thingy.
     */
    private NLMappingItem getCurrentSelected() {
        return (NLMappingItem) ((IStructuredSelection) 
                tableViewer.getSelection()).getFirstElement();
    }
    
    
    private void createAddButton(Composite parent) {
        // Create and configure the "Add" button
        Button add = new Button(parent, SWT.PUSH | SWT.CENTER);
        add.setText("Add");

        GridData gridData = new GridData (GridData.HORIZONTAL_ALIGN_BEGINNING);
        gridData.widthHint = 80;
        add.setLayoutData(gridData);
        
        add.addSelectionListener(new SelectionAdapter() {
        
            // Add an item, should pop up the editor
            public void widgetSelected(SelectionEvent e) {  
                
                NLMappingItem newItem = new NLMappingItem("", "", "*");
                
                MappingEditor editor = new MappingEditor(getSite().getShell());//shell);
                editor.create();
                editor.getShell().setText("New language mapping");
                editor.setTitle( "Create a new language element mapping." );
                editor.setTitleImage( getTitleImage() );
                
                editor.setNLMappingItem( newItem );
                
                editor.open();
                if (!editor.isCancelled()) {
                    model.addNLItem( newItem );
                    refreshModel();
                    makeDirty();
                }                
                
            }
        });
    }

    
    /**
     * Create the viewer.
     */
    private void createTableViewer() {
        tableViewer = new TableViewer(table);
        tableViewer.setUseHashlookup(true);
        //following is if we want default sorting... my thought is no...
        //tableViewer.setSorter(new DSLMappingSorter(DSLMappingSorter.EXPRESSION));
    }

    /**
     * Create the Table
     */
    private void createTable(Composite parent) {
        int style = SWT.SINGLE | SWT.BORDER | SWT.H_SCROLL | SWT.V_SCROLL | 
                    SWT.FULL_SELECTION | SWT.HIDE_SELECTION;

        table = new Table(parent, style);
        
        GridData gridData = new GridData(GridData.FILL_BOTH);
        gridData.grabExcessVerticalSpace = true;
        gridData.horizontalSpan = 3;
        table.setLayoutData(gridData);      
                    
        table.setLinesVisible(true);
        table.setHeaderVisible(true);

        TableColumn column;
        
        //Expression col
        column = new TableColumn(table, SWT.LEFT, 0);
        column.setText("Language Expression");
        column.setWidth(350);
        // Add listener to column so sorted when clicked 
        column.addSelectionListener(new SelectionAdapter() {
        
            public void widgetSelected(SelectionEvent e) {
                tableViewer.setSorter(new DSLMappingSorter(DSLMappingSorter.EXPRESSION));
            }
        });
        

        // 3rd column with task Owner
        column = new TableColumn(table, SWT.LEFT, 1);
        column.setText("Rule language mapping");
        column.setWidth(200);
        // Add listener to column so sorted when clicked
        column.addSelectionListener(new SelectionAdapter() {
        
            public void widgetSelected(SelectionEvent e) {
                tableViewer.setSorter(new DSLMappingSorter(DSLMappingSorter.MAPPING));
            }
        });

        // 4th column with task PercentComplete 
        column = new TableColumn(table, SWT.LEFT, 2);
        column.setText("Scope");
        column.setWidth(80);
        
        //  Add listener to column so tasks are sorted when clicked
        column.addSelectionListener(new SelectionAdapter() {
        
            public void widgetSelected(SelectionEvent e) {
                tableViewer.setSorter(new DSLMappingSorter(DSLMappingSorter.SCOPE));
            }
        });
        

    }
    
    
    public void setFocus() {
    }
    
    public void dispose() {
        super.dispose();
    }
    

}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -