Example usage for java.awt Component toString

List of usage examples for java.awt Component toString

Introduction

In this page you can find the example usage for java.awt Component toString.

Prototype

public String toString() 

Source Link

Document

Returns a string representation of this component and its values.

Usage

From source file:org.eclipse.jubula.rc.swing.components.AUTSwingHierarchy.java

/**
 * Returns the path from the given component to root. The List contains
 * Strings (the name of the components).
 * @param component the component to start, it's an instance from the AUT, must not be null
 * @throws IllegalArgumentException if component is null
 * @throws ComponentNotManagedException if no hierarchy conatiner exists for the component
 * @return the path to root, the first elements contains the root, the last element contains the component itself.
 *///  w  w  w.j  av a2 s.c om
public List getPathToRoot(Component component) throws IllegalArgumentException, ComponentNotManagedException {

    if (log.isInfoEnabled()) {
        log.info("pathToRoot called for " + component); //$NON-NLS-1$            
    }
    Validate.notNull(component, "The component must not be null"); //$NON-NLS-1$ 
    List hierarchy = new ArrayList();
    SwingHierarchyContainer parent;
    SwingHierarchyContainer autContainer = getHierarchyContainer(component);
    if (autContainer != null) {
        // add the name of the container itself
        hierarchy.add(autContainer.getName());
        final String className = component.getClass().getName();
        if (MappingConstants.SWING_APPLICATION_CLASSNAME.equals(className)
                || MappingConstants.SWING_MENU_DEFAULT_MAPPING_CLASSNAME.equals(className)
                || MappingConstants.SWING_MENU_CLASSNAME.equals(className)) {

            return hierarchy;
        }
        parent = getHierarchyContainer(component.getParent());
        autContainer.setParent(parent);
        // prepend the name of the container up to the root container
        while (parent != null) {
            ((ArrayList) hierarchy).add(0, parent.getName());
            Component compo = parent.getComponentID().getRealComponent();
            parent = parent.getParent();
            if (parent == null && compo != null && compo.getParent() != null) {

                SwingComponent comp = new SwingComponent(compo.getParent());
                SwingHierarchyContainer container = new SwingHierarchyContainer(comp);
                name(container);
                parent = container;
                addToHierachyMap(container);
            }
        }
    } else {
        log.error("component '" + component //$NON-NLS-1$ 
                + "' is not managed by this hierarchy"); //$NON-NLS-1$
        throw new ComponentNotManagedException("unmanaged component " + component.toString(), //$NON-NLS-1$                    
                MessageIDs.E_COMPONENT_NOT_MANAGED);
    }
    return hierarchy;
}

From source file:org.sonar.scanner.protocol.viewer.ScannerReportViewerApp.java

private void updateDetails(Component component) {
    componentEditor.setText(component.toString());
    updateHighlighting(component);//w  ww .j  av a  2  s .c  o m
    updateSymbols(component);
    updateSource(component);
    updateCoverage(component);
    updateTests(component);
    updateDuplications(component);
    updateIssues(component);
    updateMeasures(component);
    updateScm(component);
}

From source file:org.springframework.richclient.layout.GridBagLayoutBuilder.java

private String getDebugString(Component component, GridBagConstraints gbc) {
    final StringBuffer buffer = new StringBuffer();

    if (component instanceof JComponent) {
        final JComponent jcomp = (JComponent) component;
        final String name = jcomp.getName();
        if (name != null && !"".equals(jcomp.getName())) {
            buffer.append(name);/*w ww . j  a va  2s.  c  o m*/
        } else {
            if (jcomp instanceof JLabel) {
                buffer.append(((JLabel) jcomp).getText());
            } else {
                buffer.append(jcomp.toString());
            }
        }
    } else {
        buffer.append(component.toString());
    }

    buffer.append(", ");
    buffer.append("GridBagConstraint[");
    buffer.append("anchor=").append(gbc.anchor).append(",");
    buffer.append("fill=").append(gbc.fill).append(",");
    buffer.append("gridheight=").append(gbc.gridheight).append(",");
    buffer.append("gridwidth=").append(gbc.gridwidth).append(",");
    buffer.append("gridx=").append(gbc.gridx).append(",");
    buffer.append("gridy=").append(gbc.gridy).append(",");
    buffer.append("weightx=").append(gbc.weightx).append(",");
    buffer.append("weighty=").append(gbc.weighty).append("]");
    return buffer.toString();
}