Start line:  
End line:  

Snippet Preview

Snippet HTML Code

Stack Overflow Questions
  /*
   * Copyright 2008-2011 the original author or authors.
   *
   * 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 info.joseluismartin.gui.table;
 
 
 import java.util.List;
 
 
A Panel with PageableTable, Filter and Button Box to hold TablePanelActions. Hold a Paginator to navigate across pages.

Author(s):
Jose Luis Martin - (jlm@joseluismartin.info)
 
 @SuppressWarnings({ "unchecked""rawtypes" })
 public class TablePanel<T> extends JPanel implements ReportDataProvider {
 
 	private static final long serialVersionUID = 1L;
 	private static final Log log = LogFactory.getLog(TablePanel.class);
GuiFactory to get model editor
 
 	private GuiFactory guiFactory;
TablePanel name
 
 	private String name;
Pageable table used to show records
 
 	private PageableTable<T> table;
A filter view
 
 	private View<ObjectfilterView;
ComboBox with reports available to execute on filtered data
 
the TablePanelAction list
 
 	private List<Actionactions = new ArrayList<Action>();
property values to configure new created editors
 
Action component holder
 
 	private Box controlBox;

Creates new TablePanel
 
 	public TablePanel() {
 		BorderLayout layout = new BorderLayout();
 		layout.setVgap(10);
 		layout.setHgap(10);
 		setLayout(layout);
 	}

Initialize TablePanel after property set. Usally called by container.
 
 	public void init() {
 		// Header
 		
 		if ( != null)
 		
 		if ( != null)
 		
		// Key Bindings
		getActionMap().put("addAction"new AddAction());
	}


Creates a new Component that holds the ReportListView

Returns:
ReportListView Component
		Box tableBox = Box.createHorizontalBox();
		return tableBox;
	}

Creates a new Component with PageableTable.

Returns:
PageableTableComponent.
		Box tableBox = Box.createVerticalBox();
		tableBox.add(createControlBox());
		tableBox.add(Box.createVerticalStrut(5));
		tableBox.add();
		return tableBox;
	}

Creates a new Component with FilterView.

Returns:
new Component.
		Box header = Box.createVerticalBox();
		if ( != null) {
			header.add(Box.createVerticalStrut(10));
		}
		return header;
	}

Create the control button Box from action list.

Returns:
Box with buttons from actions
	protected Box createControlBox() {
		return ;
	}
	public void populateControlBox() {
		if ( != null) {
			for (Action a : ) {
				if (a instanceof TablePanelAction)
				JButton b = new JButton(a);
			}
		}
	}

Refresh View
	public void refresh() {
		if ( != null
		if ( != null)
	}

Selects records in all pages. Query only forkeys and check them in PageableTable.
	public void selectAll() {
	}
	public void unSelectAll() {
	}
	// Getters and Setters

Returns:
the PagebleTable.
	public PageableTable<T> getTable() {
		return ;
	}

Parameters:
table the PageableTable to set.
	public void setTable(PageableTable table) {
		this. = table;
	}
	public View<ObjectgetFilterView() {
		return ;
	}
	public void setFilterView(View<ObjectfilterView) {
		this. = filterView;
	}
	public String getName() {
		return ;
	}
	public void setName(String name) {
		this. = name;
	}
		return getDataSource();
	}
	public void setPersistentService(PersistentService<T, ?extends Serializableps) {
	}
	public Window getDialog() {
		try {
			if (dlg instanceof View &&  != null) {
				View view = (Viewdlg;
				view.refresh();
			}
			return dlg;
		}
		catch (BeanCreationException bce) {
				.warn("Can't get editor [" + .getEditorName() + "]");
			.error(bce);
		}
		return null;
	}
	public Window getDialog(Object toEdit) {
		try {
			return .getEditor(toEdit);
		}
		catch (BeanCreationException bce) {
				.warn("Can't get editor [" + .getEditorName() + "]");
		}
		return null;
	}
	public String getEditorName() {
	}
	public void setEditorName(String editorName) {
		.setEditorName(editorName);
	}
	}
	public void setReportListView(ReportListView reportListView) {
		this. = reportListView;
	}
	}
	public Object getFilter() {
		return .getFilter();
	}
	public String getSortProperty() {
	}
	public Page.Order getSortOrder() {
		return .getOrder();
	}


Returns:
the actions
	public List<ActiongetActions() {
		return ;
	}


Parameters:
actions the actions to set
	public void setActions(List<Actionactions) {
		this. = actions;
		if ( != null) {
		}
	}


Returns:
the guiFactory
		return ;
	}


Parameters:
guiFactory the guiFactory to set
	public void setGuiFactory(GuiFactory guiFactory) {
		this. = guiFactory;
	}

Returns:
List of selected models
	public List<T> getSelected() {
		List<T> selected = new ArrayList();
		for (Serializable id : keys) {
t = getPersistentService().get(id);
			if (t != null)
				selected.add(getPersistentService().get(id));
		}
		return selected;
	}
	public List<T> getVisibleSelected() {
	}

Returns:
the propertyValues
	}

Parameters:
propertyValues the propertyValues to set
	public void setPropertyValues(PropertyValues propertyValues) {
		this. = propertyValues;
	}

	public void addEditorListener(EditorListener listener) {
	}

	public void removeEditorListener(EditorListener listener) {
	}
New to GrepCode? Check out our FAQ X