From: Lukas P. <pe...@us...> - 2002-08-31 08:47:08
|
Update of /cvsroot/javaprofiler/module/net/sourceforge/javaprofiler/module/sheets In directory usw-pr-cvs1:/tmp/cvs-serv4351 Added Files: PSelectorSheet.java Log Message: 'Sort by' property --- NEW FILE: PSelectorSheet.java --- /* * Sun Public License Notice * * The contents of this file are subject to the Sun Public License * Version 1.0 (the "License"); you may not use this file except * in compliance with the License. A copy of the License is available * at http://www.sun.com/ * * The Original Code is the Java Profiler module. The Initial Developers * of the Original Code are Jan Stola, Pavel Vacha, Michal Pise, Petr Luner, * Lukas Petru and Marek Przeczek. * * Portions created by Jan Stola are Copyright (C) 2000-2001. * All Rights Reserved. * * Portions created by Pavel Vacha are Copyright (C) 2000-2001. * All Rights Reserved. * * Portions created by Michal Pise are Copyright (C) 2000-2001. * All Rights Reserved. * * Portions created by Petr Luner are Copyright (C) 2000-2001. * All Rights Reserved. * * Portions created by Lukas Petru are Copyright (C) 2000-2001. * All Rights Reserved. * * Portions created by Marek Przeczek are Copyright (C) 2000-2001. * All Rights Reserved. * * Contributors: Jan Stola, Pavel Vacha, Michal Pise, Petr Luner, * Lukas Petru and Marek Przeczek. */ package net.sourceforge.javaprofiler.module.sheets; import org.openide.nodes.Sheet; import org.openide.nodes.Node; import org.openide.nodes.PropertySupport; import java.util.ResourceBundle; import org.openide.util.NbBundle; import java.lang.reflect.InvocationTargetException; import net.sourceforge.javaprofiler.module.nodes.PDataChildren; import net.sourceforge.javaprofiler.module.nodes.InterfaceRepository; import java.beans.PropertyEditor; import java.beans.PropertyEditorSupport; public class PSelectorSheet implements SheetFactory { private final PDataChildren children; private final int type; public PSelectorSheet(PDataChildren reference, int childType) { children=reference; type=childType; } public Sheet create() { ResourceBundle bundle=NbBundle.getBundle(getClass()); Sheet sh=new Sheet(); Sheet.Set set=Sheet.createPropertiesSet(); Node.Property pr; pr=new PropertySupport.ReadWrite("sorting", Integer.class, "Sort by", "What criterion to sort by") { public Object getValue() throws IllegalAccessException, InvocationTargetException { return children.getSortMode(); } public void setValue(Object val) throws IllegalAccessException, IllegalArgumentException, InvocationTargetException { children.setSortMode((Integer) val); } public PropertyEditor getPropertyEditor() { return new DataSortEditor(type); } }; set.put(pr); sh.put(set); return sh; } } class DataSortEditor extends PropertyEditorSupport { private static String[] texts={"(unsorted)", "Name", "Alloc", "CPU", "Mon"}; private final int type; public DataSortEditor(int childType) { type=childType; } public String getAsText() { return texts[((Integer) getValue()).intValue()]; } public void setAsText(String text) throws IllegalArgumentException { for (int i=0; i<texts.length; i++) { if (text.compareTo(texts[i])==0) { setValue(new Integer(i)); return; } } throw new IllegalArgumentException("DataSort mode"); } public String[] getTags() { String[] res=new String[5]; int i=0; res[i++]=texts[0]; res[i++]=texts[1]; if (InterfaceRepository.hasAlloc(type)) res[i++]=texts[2]; if (InterfaceRepository.hasCPU(type)) res[i++]=texts[3]; if (InterfaceRepository.hasMon(type)) res[i++]=texts[4]; String[] res2=new String[i]; System.arraycopy(res, 0, res2, 0, i); return res2; } } /* * $Log: PSelectorSheet.java,v $ * Revision 1.1 2002/08/31 08:47:05 petrul * 'Sort by' property * */ |