/*******************************************************************************
* Copyright (c) 1998, 2015 Oracle and/or its affiliates. All rights reserved.
* This program and the accompanying materials are made available under the
* terms of the Eclipse Public License v1.0 and Eclipse Distribution License v. 1.0
* which accompanies this distribution.
* The Eclipse Public License is available at http://www.eclipse.org/legal/epl-v10.html
* and the Eclipse Distribution License is available at
* http://www.eclipse.org/org/documents/edl-v10.php.
*
* Contributors:
* Oracle - initial API and implementation from Oracle TopLink
******************************************************************************/
package org.eclipse.persistence.tools.workbench.uitools.cell;
import java.awt.Component;
import java.util.EventObject;
import javax.swing.JTree;
import javax.swing.event.CellEditorListener;
import javax.swing.tree.TreeCellEditor;
/**
* Null implementation of TreeCellEditor - useful for
* nodes that should not be edited.
*
* Implemented as a singleton.
*/
public final class NullTreeCellEditor implements TreeCellEditor {
// singleton
private static NullTreeCellEditor INSTANCE;
/**
* Return the singleton.
*/
public static synchronized TreeCellEditor instance() {
if (INSTANCE == null) {
INSTANCE = new NullTreeCellEditor();
}
return INSTANCE;
}
/**
* Ensure non-instantiability.
*/
private NullTreeCellEditor() {
super();
}
/**
* @see javax.swing.tree.TreeCellEditor#getTreeCellEditorComponent(javax.swing.JTree, java.lang.Object, boolean, boolean, boolean, int)
*/
public Component getTreeCellEditorComponent(JTree tree, Object value, boolean isSelected, boolean expanded, boolean leaf, int row) {
throw new UnsupportedOperationException();
}
/**
* @see javax.swing.CellEditor#cancelCellEditing()
*/
public void cancelCellEditing() {
// do nothing
}
/**
* @see javax.swing.CellEditor#stopCellEditing()
*/
public boolean stopCellEditing() {
return false;
}
/**
* @see javax.swing.CellEditor#getCellEditorValue()
*/
public Object getCellEditorValue() {
return null;
}
/**
* @see javax.swing.CellEditor#isCellEditable(java.util.EventObject)
*/
public boolean isCellEditable(EventObject anEvent) {
return false;
}
/**
* @see javax.swing.CellEditor#shouldSelectCell(java.util.EventObject)
*/
public boolean shouldSelectCell(EventObject anEvent) {
return false;
}
/**
* @see javax.swing.CellEditor#addCellEditorListener(javax.swing.event.CellEditorListener)
*/
public void addCellEditorListener(CellEditorListener l) {
// we don't fire any events, so ignore any listeners
}
/**
* @see javax.swing.CellEditor#removeCellEditorListener(javax.swing.event.CellEditorListener)
*/
public void removeCellEditorListener(CellEditorListener l) {
// we don't fire any events, so ignore any listeners
}
}