Start line:  
End line:  

Snippet Preview

Snippet HTML Code

Stack Overflow Questions
Copyright (c) 2011 Michael Ruflin, Andr´┐Ż Locher, Claudia von Bastian. This file is part of Tatool. Tatool is free software: you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. Tatool is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. You should have received a copy of the GNU Lesser General Public License along with Tatool. If not, see <http://www.gnu.org/licenses/>. /
 
 package ch.tatool.core.display.swing.status;
 
 import java.util.List;
 import java.util.Map;
 
Status region component implementation.
 
 public class StatusRegionImpl extends JPanel implements StatusRegion {
 
 	private static final long serialVersionUID = 1L;
 	
 	private List<StatusPanelpanels;
 	private List<Stringids;
 	private GridLayout gridLayout;
 	
 	public StatusRegionImpl() {
 		 = new ArrayList<String>();
 		 = new GridLayout();
 		setOpaque(false);
 	}
 	
 		return Collections.unmodifiableList();
 	}
 	
 	public void addStatusPanel(String idStatusPanel statusPanel) {
 		addStatusPanel(idstatusPanel.size());
 	}
 
 	public void addStatusPanel(String idStatusPanel statusPanelint index) {
 		// make sure we remove the current statuspanel with the given id (if any)
 		
 		// add the status panel at the given position
 		int position = index;
 		if (position < 0) {
 			position = 0;
 		}
 		if (position > .size()) {
 			position = .size();
 		}
 		
 		// add the panel now
 		.put(idstatusPanel);
 		.add(positionstatusPanel);
 		.add(positionid);
 		this.add(statusPanel.getView(), position);
 		
 		this.revalidate();
 		this.repaint();
 	}
 
 	public StatusPanel getStatusPanel(String id) {
 		return .get(id);
 	}
 
 	public List<StringgetStatusPanelIds() {
 		// create a new list as the caller might want to reorder the list
 		return new ArrayList<String>();
 	}
 
 
 	public void reoderStatusPanels(List<StringstatusPanelIds) {
 		// create the new ids array, taking statusPanelIds into account
 		List<StringnewIds = new ArrayList<String>(statusPanelIds);
 		newIds.retainAll(); // now newIds only contains valid ids
 		.removeAll(statusPanelIds);
 		newIds.addAll(); // now we added all ids that were missing in statusPanelIds
		 = newIds;
		// remove all panels and add them again in the requested order
		this.removeAll();
		for (String id : ) {
			StatusPanel statusPanel = .get(id);
			.add(statusPanel);
			this.add(statusPanel.getView());
		}
		this.revalidate();
		this.repaint();
	}
	public void removeStatusPanel(String id) {
			.remove(panel);
			this.remove(panel.getView());
		}
		this.revalidate();
		this.repaint();
	}
	public void removeAllPanels() {
		this.revalidate();
		this.repaint();
	}
New to GrepCode? Check out our FAQ X