[33053] | 1 | /**
|
---|
| 2 | *#########################################################################
|
---|
| 3 | *
|
---|
| 4 | * A component of the Gatherer application, part of the Greenstone digital
|
---|
| 5 | * library suite from the New Zealand Digital Library Project at the
|
---|
| 6 | * University of Waikato, New Zealand.
|
---|
| 7 | *
|
---|
| 8 | *
|
---|
| 9 | * Copyright (C) 2006 New Zealand Digital Library Project
|
---|
| 10 | *
|
---|
| 11 | * <BR><BR>
|
---|
| 12 | *
|
---|
| 13 | * This program is free software; you can redistribute it and/or modify
|
---|
| 14 | * it under the terms of the GNU General Public License as published by
|
---|
| 15 | * the Free Software Foundation; either version 2 of the License, or
|
---|
| 16 | * (at your option) any later version.
|
---|
| 17 | *
|
---|
| 18 | * <BR><BR>
|
---|
| 19 | *
|
---|
| 20 | * This program is distributed in the hope that it will be useful,
|
---|
| 21 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
|
---|
| 22 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
---|
| 23 | * GNU General Public License for more details.
|
---|
| 24 | *
|
---|
| 25 | * <BR><BR>
|
---|
| 26 | *
|
---|
| 27 | * You should have received a copy of the GNU General Public License
|
---|
| 28 | * along with this program; if not, write to the Free Software
|
---|
| 29 | * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
|
---|
| 30 | *########################################################################
|
---|
| 31 | */
|
---|
| 32 | package org.greenstone.gatherer.gui;
|
---|
| 33 |
|
---|
| 34 | import java.awt.*;
|
---|
| 35 | import java.awt.event.*;
|
---|
| 36 | import javax.swing.*;
|
---|
| 37 | import java.util.*;
|
---|
| 38 |
|
---|
| 39 | public class GUIUtils {
|
---|
| 40 |
|
---|
| 41 | /** The name of the mouse listener that initiates editing on a double click. */
|
---|
| 42 | static final private String SINGLE_CLICK_LISTENER = "SingleClickListener";
|
---|
| 43 |
|
---|
| 44 | /** Neat method to disable file renaming in filechooser.
|
---|
| 45 | * Thanks to: vladi21 from www.experts-exchange.com
|
---|
| 46 | */
|
---|
| 47 | static public void disableRename(Component c) {
|
---|
| 48 | if (c instanceof JList){
|
---|
| 49 | EventListener[] listeners=c.getListeners(MouseListener.class);
|
---|
| 50 | for(int i=0; listeners != null && i < listeners.length; i++) {
|
---|
| 51 | if (listeners[i].toString().indexOf(SINGLE_CLICK_LISTENER) != -1) {
|
---|
| 52 | c.removeMouseListener((MouseListener)listeners[i]);
|
---|
| 53 | }
|
---|
| 54 | }
|
---|
| 55 | return;
|
---|
| 56 | }
|
---|
| 57 | if (c instanceof Container) {
|
---|
| 58 | Component[] children = null;
|
---|
| 59 | children = ((Container)c).getComponents();
|
---|
| 60 | if (children != null) {
|
---|
| 61 | for(int i = 0; children != null && i < children.length; i++) {
|
---|
| 62 | disableRename(children[i]);
|
---|
| 63 | }
|
---|
| 64 | }
|
---|
| 65 | }
|
---|
| 66 | }
|
---|
| 67 |
|
---|
| 68 |
|
---|
| 69 | }
|
---|