org.databene.edifatto.gui.EdiNameTreeCellRenderer Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of edifatto Show documentation
Show all versions of edifatto Show documentation
'Edifatto' is an open source software library for parsing,
generating and verifying EDIFACT and X12 documents written by Volker Bergmann.
The newest version!
/*
* Copyright (C) 2013-2015 Volker Bergmann ([email protected]).
* All rights reserved.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
* http://www.apache.org/licenses/LICENSE-2.0
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.databene.edifatto.gui;
import java.awt.event.MouseEvent;
import javax.swing.tree.TreeCellRenderer;
import org.databene.edifatto.definition.Definition;
import org.databene.edifatto.model.EdiItem;
/**
* Displays the EDI node type symbols and element type names in a {@link TreeCellRenderer} implementation.
* Created: 28.06.2014 15:07:56
* @since 2.0.0
* @author Volker Bergmann
*/
public class EdiNameTreeCellRenderer extends EdiTreeCellRenderer {
private static final long serialVersionUID = 1L;
EdiItem item;
@Override
public String getToolTipText(MouseEvent event) {
if (item == null || item.getDefinition() == null)
return null;
Definition definition = item.getDefinition();
StringBuilder builder = new StringBuilder("");
builder.append("Name: ").append(definition.getName());
builder.append("Description: ").append(definition.getDocumentation());
String propName = ParameterizationHelper.getPropertyName(item);
if (propName != null)
builder.append("Property: ").append(propName);
String itemName = ParameterizationHelper.getItemName(item);
if (propName != null)
builder.append("Item: ").append(itemName);
String className = ParameterizationHelper.getBeanClassName(item);
if (className != null)
builder.append("Class: ").append(className);
return builder.append("").toString();
}
@Override
protected String textForValue(Object value) {
this.item = (EdiItem) value;
Definition definition = (value != null ? ((EdiItem) value).getDefinition() : null);
return (definition != null ? definition.getName() : null);
}
}