/*
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation. Oracle designates this
* particular file as subject to the "Classpath" exception as provided
* by Oracle in the LICENSE file that accompanied this code.
*
* This code 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 General Public License
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
* You should have received a copy of the GNU General Public License version
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
*/
/*IMPORTANT :
There is a deadlock issue there if we don't synchronize well loadAttributes,
refresh attributes and empty table methods since a UI thread can call
loadAttributes and at the same time a JMX notification can raise an
emptyTable. Since there are synchronization in the JMX world it's
COMPULSORY to not call the JMX world in synchronized blocks */
@SuppressWarnings("serial")
super();
attributesListener = new AttributesListener(this);
getTableHeader().setReorderingAllowed(false);
}
//In case we have a repaint thread that is in the process of
//repainting an obsolete table, just ignore the call.
//It can happen when MBean selection is switched at a very quick rate
if(row >= getRowCount())
return null;
else
}
if(obj instanceof ZoomedCell) {
else
if(rowMinHeight != - 1)
} else
if(rowMinHeight != - 1)
}
int column) {
//In case we have a repaint thread that is in the process of
//repainting an obsolete table, just ignore the call.
//It can happen when MBean selection is switched at a very quick rate
if (row >= getRowCount()) {
return null;
} else {
if (column == VALUE_COLUMN) {
if (obj instanceof ZoomedCell) {
return renderer;
}
}
}
}
}
return renderer;
}
}
private void setColumnEditors() {
if (isColumnEditable(i)) {
} else {
}
}
}
public void cancelCellEditing() {
}
if (tableCellEditor != null) {
}
}
public void stopCellEditing() {
}
if (tableCellEditor != null) {
}
}
", e="+e+")");
}
}
if (retVal) {
final TableCellEditor tableCellEditor =
if (tableCellEditor == valueCellEditor) {
}
}
return retVal;
}
// All the cells in non-editable columns are editable
if (!isColumnEditable(col)) {
return true;
}
// Maximized zoomed cells are editable
if (obj instanceof ZoomedCell) {
return cell.isMaximized();
}
return true;
}
}
}
}
//Table methods
public boolean isTableEditable() {
return true;
}
}
if (column < getColumnCount()) {
}
else {
return false;
}
}
if (index != -1) {
}
else {
return null;
}
}
if (index != -1) {
}
else {
return null;
}
}
return val;
}
//tool tip only for editable column
}
if (isColumnEditable(column)) {
". " + tip;
}
return tip;
}
if(column == NAME_COLUMN) {
if (index != -1) {
}
}
return null;
}
if (index != -1) {
}
else {
return false;
}
}
/**
* Override JTable method in order to make any call to this method
* atomic with TableModel elements.
*/
public synchronized int getRowCount() {
return super.getRowCount();
}
if (index != -1) {
}
else {
return false;
}
}
return (isColumnEditable(col) &&
}
boolean isViewable = false;
if(col == VALUE_COLUMN) {
if(obj instanceof ZoomedCell)
isViewable = true;
}
return isViewable;
}
// Call this in EDT
}
protected void done() {
try {
} catch (RuntimeException x) {
throw x;
} catch (ExecutionException x) {
"Exception raised while loading attributes: "
+x.getCause());
x.printStackTrace();
}
} catch (InterruptedException x) {
"Interrupted while loading attributes: "+x);
x.printStackTrace();
}
}
}
};
}
// Don't call this in EDT, but execute returned Runnable inside
// EDT - typically in the done() method of a SwingWorker
// This method can return null.
throws JMException, IOException {
// To avoid deadlock with events coming from the JMX side,
// we retrieve all JMX stuff in a non synchronized block.
final MBeanInfo curMBeanInfo =
try {
}catch(Exception e) {
"try to get them individually calling " +
"getAttribute() instead. Exception:");
}
list = new AttributeList();
//Can't load all attributes, do it one after each other.
try {
if(attrsInfo[i].isReadable()) {
}
}
}
}
try {
for (int i=0;i<att_length;i++) {
if(isViewable(attribute)) {
}
else
}
// if not all attributes are accessible,
// check them one after the other.
getName()) &&
getName())) {
if (attributeInfo.isReadable()) {
// getAttributes didn't help resolving the
// exception.
// We must call it again to understand what
// went wrong.
try {
Object v =
//What happens if now it is ok?
// Be pragmatic, add it to readable...
v);
}catch(Exception e) {
//Put the exception that will be displayed
// in tooltip
}
}
}
}
}
}
catch(Exception e) {
//sets all attributes unavailable except the writable ones
if (attributeInfo.isReadable()) {
toString());
}
}
}
//end of retrieval
//one update at a time
return new Runnable() {
public void run() {
synchronized (XMBeanAttributes.this) {
// add attribute information
// update the model with the new data
// re-register for change events
}
}
};
}
final int row = getSelectedRow();
if(obj instanceof ZoomedCell) {
invalidate();
repaint();
}
}
int col) {
if(obj instanceof ZoomedCell) {
if(rowMinHeight == -1)
comp,
} else
return cell;
}
cell.switchState();
if(!cell.isMaximized()) {
//Back to simple editor.
}
invalidate();
repaint();
}
return cell;
}
// This is called by XSheet when the "refresh" button is pressed.
// In this case we will commit any pending attribute values by
// calling 'stopCellEditing'.
//
public void refreshAttributes() {
refreshAttributes(true);
}
// refreshAttributes(false) is called by tableChanged().
// in this case we must not call stopCellEditing, because it's already
// been called - e.g.
// lostFocus/mousePressed -> stopCellEditing -> setValueAt -> tableChanged
// -> refreshAttributes(false)
//
// Can be called in EDT - as long as the implementation of
// mbeansTab.getCachedMBeanServerConnection() and mbsc.flush() doesn't
// change
//
return null;
}
protected void done() {
try {
get();
if (stopCellEditing) stopCellEditing();
} catch (Exception x) {
x.printStackTrace();
}
}
}
};
}
// We need to call stop editing here - otherwise edits are lost
// when resizing the table.
//
if (isEditing()) stopCellEditing();
super.columnMarginChanged(e);
}
// We need to call stop editing here - otherwise the edited value
// is transferred to the wrong row...
//
if (isEditing()) stopCellEditing();
super.sortRequested(column);
}
public synchronized void emptyTable() {
}
// Call this in synchronized block.
super.emptyTable();
}
}
synchronized void removeAttributes() {
if (attributes != null) {
attributes.clear();
}
if (unavailableAttributes != null) {
}
if (viewableAttributes != null) {
}
}
synchronized (viewersCache) {
} else {
}
// Plotters are the only viewers with auto update capabilities.
// Other viewers need to be updated manually.
}
} else {
}
return cell;
}
}
//will be called in a synchronized block
int col1Width = 0;
int col2Width = 0;
if (!attributesInfo[i].isWritable() ||
}
} else {
}
//Update column width
//
}
}
}
}
//Get the column at index pColumn, and set its preferred width.
(int) getPreferredScrollableViewportSize().getWidth())
- col1Width;
}
if(e.getClickCount() >= 2) {
if(col != VALUE_COLUMN) return;
}
}
}
}
// implements javax.swing.table.TableCellEditor
boolean isSelected,
int row,
int column) {
if(column == VALUE_COLUMN) {
column);
if(obj instanceof ZoomedCell) {
return zr.getComponent();
}
} else {
!isWritable(row) ||
textField.setEditable(false);
}
return comp;
}
}
return super.getTableCellEditorComponent(table,
val,
row,
column);
}
public boolean stopCellEditing() {
int editingRow = getEditingRow();
int editingColumn = getEditingColumn();
if (editingColumn == VALUE_COLUMN) {
if (obj instanceof ZoomedCell) {
if (cell.isMaximized()) {
this.cancelCellEditing();
return true;
}
}
}
return super.stopCellEditing();
}
}
if (d.getHeight() > 220) {
}
}
boolean isSelected,
boolean hasFocus,
int row,
int column) {
return comp;
}
return comp;
}
}
class ZoomedCell {
int minHeight;
boolean minimized = true;
boolean init = false;
int type;
}
boolean isInited() {
return init;
}
return value;
}
}
int minHeight) {
this.minRenderer = minRenderer;
init = true;
}
int getType() {
return type;
}
void reset() {
init = false;
minimized = true;
}
void switchState() {
}
boolean isMaximized() {
return !minimized;
}
void minimize() {
minimized = true;
}
void maximize() {
minimized = false;
}
int getHeight() {
else
return (int) maxRenderer.getComponent().
getPreferredSize().getHeight() ;
}
int getMinHeight() {
return minHeight;
}
}
if(value instanceof CompositeData ||
value instanceof TabularData)
}
if(minimized) return minRenderer;
else return maxRenderer;
}
return minRenderer;
}
}
}
// Call this in EDT
// only post changes to the draggable column
if (isColumnEditable(e.getColumn())) {
e.getColumn());
", value="+tableValue);
}
// if it's a String, try construct new value
// using the defined type.
if (tableValue instanceof String) {
try {
}
}
}
}
// Call this in EDT
try {
}
}
return null;
}
protected void done() {
try {
get();
} catch (Exception x) {
x.printStackTrace();
}
refreshAttributes(false);
}
};
}
// Call this outside EDT
}
}
}