001 /** 002 * planningtool - A Planning Tool with Critiquing Support. 003 * 004 * Copyright (C) 2006 olale 005 006 * This program is free software; you can redistribute it and/or 007 * modify it under the terms of the GNU General Public License 008 * as published by the Free Software Foundation; either version 2 009 * of the License, or (at your option) any later version. 010 011 * This program is distributed in the hope that it will be useful, 012 * but WITHOUT ANY WARRANTY; without even the implied warranty of 013 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 014 * GNU General Public License for more details. 015 016 * You should have received a copy of the GNU General Public License 017 * along with this program; if not, write to the Free Software 018 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. 019 020 * Contact information: 021 * E-mail: olale@ida.liu.se 022 * olale@lysator.liu.se 023 */ 024 package se.liu.ida.critiquer.gui; 025 026 import javax.swing.tree.DefaultTreeSelectionModel; 027 import javax.swing.tree.TreePath; 028 029 public class FreezableTreeSelection extends DefaultTreeSelectionModel { 030 031 /** 032 * 033 */ 034 private static final long serialVersionUID = 1L; 035 private boolean freezed = false; 036 037 /* (non-Javadoc) 038 * @see javax.swing.tree.DefaultTreeSelectionModel#addSelectionPath(javax.swing.tree.TreePath) 039 */ 040 @Override 041 public void addSelectionPath(TreePath path) { 042 if (!freezed) { 043 super.addSelectionPath(path); 044 } 045 } 046 047 /* (non-Javadoc) 048 * @see javax.swing.tree.DefaultTreeSelectionModel#addSelectionPaths(javax.swing.tree.TreePath[]) 049 */ 050 @Override 051 public void addSelectionPaths(TreePath[] paths) { 052 if (!freezed) { 053 super.addSelectionPaths(paths); 054 } 055 } 056 057 /* (non-Javadoc) 058 * @see javax.swing.tree.DefaultTreeSelectionModel#setSelectionPath(javax.swing.tree.TreePath) 059 */ 060 @Override 061 public void setSelectionPath(TreePath path) { 062 if (!freezed) { 063 super.setSelectionPath(path); 064 } 065 } 066 067 /* (non-Javadoc) 068 * @see javax.swing.tree.DefaultTreeSelectionModel#setSelectionPaths(javax.swing.tree.TreePath[]) 069 */ 070 @Override 071 public void setSelectionPaths(TreePath[] pPaths) { 072 if (!freezed) { 073 super.setSelectionPaths(pPaths); 074 } 075 } 076 077 /** 078 * @return Returns the freezed. 079 */ 080 public boolean isFreezed() { 081 return freezed; 082 } 083 084 /** 085 * @param freezed The freezed to set. 086 */ 087 public void setFreezed(boolean freezed) { 088 this.freezed = freezed; 089 } 090 091 092 }