001: package org.drools.brms.client.rulelist;
002:
003: /*
004: * Copyright 2005 JBoss Inc
005: *
006: * Licensed under the Apache License, Version 2.0 (the "License");
007: * you may not use this file except in compliance with the License.
008: * You may obtain a copy of the License at
009: *
010: * http://www.apache.org/licenses/LICENSE-2.0
011: *
012: * Unless required by applicable law or agreed to in writing, software
013: * distributed under the License is distributed on an "AS IS" BASIS,
014: * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
015: * See the License for the specific language governing permissions and
016: * limitations under the License.
017: */
018:
019: /**
020: * This class is fully deprecated. Move along, nothing to see here.
021: * (useful notes are in the comments).
022: * @deprecated
023: * @author Michael Neale
024: *
025: */
026: public class RuleListViewLegacy {
027:
028: }
029:
030: //package org.drools.brms.client.rulelist;
031: //
032: //import org.drools.brms.client.rpc.RepositoryServiceAsync;
033: //import org.drools.brms.client.rpc.RepositoryServiceFactory;
034: //import org.drools.brms.client.rpc.TableConfig;
035: //
036: //import com.google.gwt.user.client.rpc.AsyncCallback;
037: //import com.google.gwt.user.client.ui.ClickListener;
038: //import com.google.gwt.user.client.ui.Composite;
039: //import com.google.gwt.user.client.ui.Grid;
040: //import com.google.gwt.user.client.ui.HTML;
041: //import com.google.gwt.user.client.ui.HorizontalPanel;
042: //import com.google.gwt.user.client.ui.Image;
043: //import com.google.gwt.user.client.ui.SourcesTableEvents;
044: //import com.google.gwt.user.client.ui.TableListener;
045: //import com.google.gwt.user.client.ui.VerticalPanel;
046: //import com.google.gwt.user.client.ui.Widget;
047: //
048: ///**
049: // * NOTE: this is not currently used, but it worked OK.
050: // * It did NOT have sorting, but did have paging, and performed reasonably well.
051: // *
052: // * SO KEEP THIS AROUND IN CASE THE OTHER ONE BLOWS CHUNKS !
053: // * This one is based on the mail app example.
054: // *
055: // * A composite that displays an explorer and a list view.
056: // */
057: //public class RuleListView extends Composite
058: // implements
059: // TableListener,
060: // ClickListener {
061: //
062: //
063: // public static final String RULE_LIST_TABLE_ID = "ruleList";
064: //
065: // private int visibleItemCount = -1;
066: //
067: // private HTML countLabel = new HTML();
068: // private HTML prevButton = new HTML( "<a href='javascript:;'>< prev</a>",
069: // true );
070: // private HTML nextButton = new HTML( "<a href='javascript:;'>next ></a>",
071: // true );
072: // private HTML editButton = new HTML( "<a href='javascript:;'>edit</a>",
073: // true );
074: //
075: // private int startIndex, selectedRow = -1;
076: // private Grid table = new Grid();
077: // private HorizontalPanel navBar = new HorizontalPanel();
078: //
079: //
080: // private static final RepositoryServiceAsync service = RepositoryServiceFactory.getService();
081: // private String[][] data;
082: // protected int numberOfColumns;
083: // private EditItemEvent editEvent;
084: //
085: // public RuleListView(EditItemEvent event) {
086: //
087: // this.editEvent = event;
088: //
089: //
090: // // Setup the table.
091: // table.setCellSpacing( 0 );
092: // table.setCellPadding( 0 );
093: // table.setWidth( "100%" );
094: //
095: // // Hook up events.
096: // table.addTableListener( this );
097: // prevButton.addClickListener( this );
098: // nextButton.addClickListener( this );
099: // editButton.addClickListener( this );
100: //
101: // // Create the 'navigation' bar at the upper-right.
102: // HorizontalPanel innerNavBar = new HorizontalPanel();
103: // innerNavBar.setStyleName( "rule-ListNavBar" );
104: // innerNavBar.setSpacing( 8 );
105: //
106: // innerNavBar.add( prevButton );
107: // innerNavBar.add( countLabel );
108: // innerNavBar.add( nextButton );
109: // innerNavBar.add( editButton );
110: //
111: // navBar.setHorizontalAlignment( HorizontalPanel.ALIGN_RIGHT );
112: // navBar.add( innerNavBar );
113: // navBar.setWidth( "100%" );
114: //
115: // //this is so we can stack controls on top of the table
116: // VerticalPanel vert = new VerticalPanel();
117: // vert.add( navBar );
118: // vert.add( table );
119: // vert.setStyleName( "rule-List" );
120: // vert.setWidth( "100%" );
121: //
122: // table.setStyleName( "rule-List" );
123: // table.setWidth( "100%" );
124: //
125: // // needed for composite to work
126: // initWidget( vert );
127: // setStyleName( "rule-List" );
128: // initTable();
129: //
130: // }
131: //
132: // public void onCellClicked(SourcesTableEvents sender,
133: // int row,
134: // int cell) {
135: // // Select the row that was clicked (-1 to account for header row).
136: // if ( row > 0 ) selectRow( row - 1 );
137: // }
138: //
139: // public void onClick(Widget sender) {
140: // if ( sender == nextButton ) {
141: // // Move forward a page.
142: // startIndex += visibleItemCount;
143: // if ( startIndex >= data.length ) startIndex -= visibleItemCount;
144: // else {
145: // styleRow( selectedRow,
146: // false );
147: // selectedRow = -1;
148: // update();
149: // }
150: // } else if ( sender == prevButton ) {
151: // // Move back a page.
152: // startIndex -= visibleItemCount;
153: // if ( startIndex < 0 ) startIndex = 0;
154: // else {
155: // styleRow( selectedRow,
156: // false );
157: // selectedRow = -1;
158: // update();
159: // }
160: // } else if ( sender == editButton ) {
161: // openEditor();
162: // }
163: // }
164: //
165: // /**
166: // * Open the editor as pertains to the selected row !
167: // */
168: // private void openEditor() {
169: // if (selectedRow < data.length) {
170: // this.editEvent.open( data[selectedRow][0] );
171: // }
172: // }
173: //
174: // /**
175: // * Initializes the table. Will load the header config, initialise etc.
176: // */
177: // private void initTable() {
178: // // Create the header row.
179: //
180: // table.resize( 1, 1 );
181: // table.getRowFormatter().setStyleName( 0, "rule-ListHeader" );
182: // table.setText( 0, 0, "Please wait..." );
183: //
184: // service.loadTableConfig( RULE_LIST_TABLE_ID, new AsyncCallback() {
185: //
186: // public void onFailure(Throwable caught) {
187: // //TODO
188: // }
189: //
190: // public void onSuccess(Object result) {
191: // TableConfig config = (TableConfig) result;
192: //
193: // String[] header = config.headers;
194: // numberOfColumns = header.length;
195: //
196: // visibleItemCount = config.rowsPerPage;
197: // table.resize( visibleItemCount + 1, numberOfColumns);
198: //
199: // for ( int i = 0; i < numberOfColumns; i++ ) {
200: // table.setText( 0, i, header[i]);
201: // }
202: //
203: // data = new String[1][numberOfColumns];
204: // update();
205: //
206: // }
207: //
208: // });
209: //
210: // }
211: //
212: // /**
213: // * Selects the given row (relative to the current page).
214: // *
215: // * @param row the row to be selected
216: // */
217: // private void selectRow(int row) {
218: //
219: // //change the style flags
220: // styleRow( selectedRow,
221: // false );
222: // styleRow( row,
223: // true );
224: //
225: // //mark the selected row
226: // selectedRow = row;
227: //
228: // //TODO: also show "preview" view here of rule.
229: // System.out.println("[Preview rule now]");
230: // }
231: //
232: // private void styleRow(int row,
233: // boolean selected) {
234: // if ( row != -1 ) {
235: // if ( selected ) table.getRowFormatter().addStyleName( row + 1,
236: // "rule-SelectedRow" );
237: // else table.getRowFormatter().removeStyleName( row + 1,
238: // "rule-SelectedRow" );
239: // }
240: // }
241: //
242: //
243: //
244: //
245: //
246: //
247: // private void update() {
248: //
249: // if (this.numberOfColumns == -1) {
250: // //if it hasn't been setup, can't load data yet
251: // return;
252: // }
253: //
254: // // Update the older/newer buttons & label.
255: // int count = data.length;
256: // int max = startIndex + visibleItemCount;
257: // if ( max > count ) max = count;
258: //
259: // prevButton.setVisible( startIndex != 0 );
260: // nextButton.setVisible( startIndex + visibleItemCount < count );
261: // countLabel.setText( "" + (startIndex + 1) + " - " + max + " of " + count );
262: //
263: // // Show the selected emails.
264: // int i = 0;
265: // for ( ; i < visibleItemCount; ++i ) {
266: // // Don't read past the end.
267: // if ( startIndex + i >= count ) break;
268: //
269: // String[] rowData = data[startIndex + i];
270: //
271: // //RuleListItem item = data.getMailItem( startIndex + i );
272: //
273: // // Add a new row to the table, then set each of its columns value
274: //
275: // for ( int col = 0; col < rowData.length; col++ ) {
276: // table.setText( i + 1, col, rowData[col] );
277: // }
278: //
279: //// table.setText( i + 1,
280: //// 0,
281: //// item.name );
282: //// table.setText( i + 1,
283: //// 1,
284: //// item.status );
285: //// table.setText( i + 1,
286: //// 2,
287: //// item.changedBy );
288: //// table.setText( i + 1,
289: //// 3,
290: //// item.version );
291: // }
292: //
293: // // Clear any remaining slots.
294: // for ( ; i < visibleItemCount; ++i ) {
295: // table.setHTML( i + 1, 0, " " );
296: // }
297: //
298: // // Select the first row if none is selected.
299: // if ( selectedRow == -1 ) selectRow( 0 );
300: //
301: // }
302: //
303: // public void loadRulesForCategoryPath(String selectedPath) {
304: // service.loadRuleListForCategories( selectedPath, "", new AsyncCallback() {
305: //
306: // public void onFailure(Throwable caught) {
307: // // TODO Auto-generated method stub
308: // }
309: //
310: // public void onSuccess(Object result) {
311: // String[][] data = (String[][]) result;
312: // updateData(data);
313: // }
314: //
315: // });
316: //
317: // }
318: //
319: // private void updateData(String[][] data) {
320: // this.data = data;
321: // update();
322: // }
323: //}
|