Example usage for java.awt Component getName

List of usage examples for java.awt Component getName

Introduction

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

Prototype

public String getName() 

Source Link

Document

Gets the name of the component.

Usage

From source file:es.emergya.ui.base.plugins.DetachedTab.java

/**
 * @param original_pane/*from w  ww . jav a2s .  c  om*/
 * @param title
 * @param tip
 * @param original_positon
 * @param detached_tab
 * @param icon
 * @throws HeadlessException
 */
public DetachedTab(PluggableJTabbedPane original_pane, String title, String tip, int original_positon,
        Component detached_tab, Icon icon) throws HeadlessException {
    super(title);
    this.setIconImage(window.getFrame().getIconImage());
    this.original_pane = original_pane;
    this.tip = tip;
    this.original_positon = original_positon;
    this.detached_tab = detached_tab;
    this.icon = icon;

    this.setDefaultCloseOperation(JFrame.DO_NOTHING_ON_CLOSE);

    this.addWindowListener(new WindowAdapter() {

        @Override
        public void windowClosing(WindowEvent e) {
            if (retatch_on_close) {
                DetachedTab.this.original_pane.reattach(DetachedTab.this);
                DetachedTab.this.dispose();
            }

            Authentication.logOut();
            super.windowClosing(e);
        }
    });

    addTab(detached_tab.getName(), icon, detached_tab);

    this.addWindowListener(new WindowAdapter() {
    });
    this.setMinimumSize(new Dimension(800, 600));

    // this.addComponentListener(new ComponentAdapter() {
    // @Override
    // public void componentResized(ComponentEvent e) {
    // super.componentResized(e);
    // Dimension d = DetachedTab.this.getSize();
    // DetachedTab.log.info("Size actual: " + d);
    // if (d.width < 800)
    // d.width = 800;
    // if (d.height < 200)
    // d.height = 200;
    // DetachedTab.log.info("Size after: " + d);
    // DetachedTab.this.setSize(d.width, d.height);
    // }
    // });
    this.add(pane);
    pack();
    this.setExtendedState(JFrame.MAXIMIZED_BOTH);
}

From source file:com.mac.tarchan.desktop.event.EventQuery.java

/**
 * ?????/*from   www. ja  v  a 2 s .  co  m*/
 * 
 * @param target ?
 * @return ??
 * @see #dblclick(Object, String)
 */
public EventQuery dblclick(Object target) {
    for (Component child : list) {
        String action = child.getName();
        if (action != null)
            find(action).dblclick(target, action);
    }
    return this;
}

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

/**
 * Checks for uniqueness of <code>name</code> for the components in
 * <code>parent</code>.<br>
 * If parent is null every name is unique, a null name is NEVER unique. If
 * both parameters are null, false is returned. <br>
 * @param parent the hierarchy container containing the components which are checked.
 * @param name the name to check/*from  w  ww . ja  v a2  s.co  m*/
 * @param swingComponent The component for which the name is being checked.
 * @return true if the name is treated as unique, false otherwise.
 */
private boolean isUniqueName(SwingHierarchyContainer parent, String name, Component swingComponent) {

    if (name == null) {
        return false;
    }
    if (parent == null) {
        return true;
    }
    SwingHierarchyContainer[] compIDs = parent.getComponents();
    final int length = compIDs.length;

    for (int index = 0; index < length; index++) {
        Component childComponent = compIDs[index].getComponentID().getRealComponent();
        Object childName = childComponent.getName();

        if (name.equals(childName) && childComponent != swingComponent) {
            return false;
        }
    }

    for (int index = 0; index < length; index++) {
        if (name.equals(compIDs[index].getName())) {
            return false;
        }
    }

    return true;
}

From source file:com.mac.tarchan.desktop.event.EventQuery.java

/**
 * ?????// w  ww  .j a va2 s .  co  m
 * 
 * @param target ?
 * @return ??
 * @see #click(Object, String)
 */
public EventQuery click(Object target) {
    //      System.out.println("click: " + list(list));
    for (Component child : list) {
        String action = child.getName();
        if (action != null)
            find(action).click(target, action);
    }
    return this;
}

From source file:com.mac.tarchan.desktop.event.EventQuery.java

/**
 * ????//from w  w  w.j av a  2s. c  om
 * 
 * @return ?
 */
public Map<String, String> values() {
    LinkedHashMap<String, String> map = new LinkedHashMap<String, String>();
    for (Component child : list) {
        String name = child.getName();
        if (name == null)
            continue;

        if (child instanceof TextComponent) {
            String value = ((TextComponent) child).getText();
            map.put(name, value);
        } else if (child instanceof JTextComponent) {
            String value = ((JTextComponent) child).getText();
            map.put(name, value);
        } else if (child instanceof JToggleButton) {
            boolean value = ((JToggleButton) child).isSelected();
            map.put(name, String.valueOf(value));
        } else {
            //            String value = child.toString();
            //            map.put(name, value != null ? value : "");
        }
    }

    return map;
}

From source file:com.mac.tarchan.desktop.event.EventQuery.java

List<String> list(Collection<Component> list) {
    ArrayList<String> buf = new ArrayList<String>();
    for (Component child : list) {
        buf.add(String.format("%s (%s)", child.getName(), child.getClass().getName()));
    }/*  w ww.j a v  a2s. c  o  m*/

    return buf;
}

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

/**
 * Names the given hierarchy container. <br>
 * If the managed component has a unique name, this name is used. Otherwise
 * a name (unique for the hierachy level) is created.
 * @param hierarchyContainer the SwingHierarchyContainer to name, if SwingHierarchyContainer is null,
 *            no action is performed and no exception is thrown.
 *///from   ww w  .j  a  v  a  2  s  .  co  m
private void name(SwingHierarchyContainer hierarchyContainer) {
    checkDispatchThread();
    if (hierarchyContainer != null) {
        final Component component = hierarchyContainer.getComponentID().getRealComponent();
        String compName = component.getName();
        // SPECIAL HANDLING !!! -----------------------------------
        if (component instanceof Dialog && compName != null && compName.startsWith("dialog")) { //$NON-NLS-1$

            compName = null;
        } else if (component instanceof JToolBar && compName != null && compName.startsWith("Tool Bar ")) { //$NON-NLS-1$

            compName = null;
        }
        // --------------------------------------------------------
        SwingHierarchyContainer hierarchyParent = null;
        final Container parent = component.getParent();
        if (parent != null) {
            hierarchyParent = getHierarchyContainer(parent);
        }
        if (hierarchyContainer.getName() != null && hierarchyContainer.getName().length() != 0) {

            return;
        }
        // isUniqueName is null safe, see description there
        int count = 1;
        String originalName = null;
        String newName = null;
        boolean newNameGenerated = (compName == null);
        if (compName != null) {
            originalName = compName;
            newName = compName;
        }
        if (newName == null) {
            while (!isUniqueName(hierarchyParent, newName, component)) {
                newName = createName(component, count);
                count++;
            }
        } else {
            while (!isUniqueName(hierarchyParent, newName, component)) {
                count++;
                newName = createName(originalName, count);
            }
        }
        hierarchyContainer.setName(newName, newNameGenerated);
    }
}

From source file:com.mac.tarchan.desktop.event.EventQuery.java

/**
 * ????????//from  w  w  w  . ja va  2 s .  c o m
 * 
 * @param out 
 * @return ??
 */
public EventQuery dump(PrintStream out) {
    String head = String.format("Parent: %s", parent);
    out.println(head);
    for (Component child : list) {
        String info = String.format("%s, %s", child.getName(), child.getClass().getName());
        out.println(info);
    }

    return this;
}

From source file:the.bytecode.club.bytecodeviewer.gui.WorkPane.java

@Override
public void actionPerformed(final ActionEvent arg0) {
    Thread t = new Thread() {
        public void run() {
            if (BytecodeViewer.viewer.autoCompileOnRefresh.isSelected())
                try {
                    if (!BytecodeViewer.compile(false))
                        return;
                } catch (java.lang.NullPointerException e) {

                }/*from w  w  w.j  a v  a  2 s  .  c o m*/
            final JButton src = (JButton) arg0.getSource();
            if (src == refreshClass) {
                final Component tabComp = tabs.getSelectedComponent();
                if (tabComp != null) {
                    if (tabComp instanceof ClassViewer) {
                        src.setEnabled(false);
                        BytecodeViewer.viewer.setIcon(true);
                        ((ClassViewer) tabComp).startPaneUpdater(src);
                        BytecodeViewer.viewer.setIcon(false);
                    } else if (tabComp instanceof FileViewer) {
                        src.setEnabled(false);
                        BytecodeViewer.viewer.setIcon(true);
                        ((FileViewer) tabComp).refresh(src);
                        BytecodeViewer.viewer.setIcon(false);
                    }
                }
            }

            //Xposed Generator
            if (src == generateXposedClass) {
                //Get actual file class content
                final Component tabComp = tabs.getSelectedComponent();
                String className = tabComp.getName();
                String containerName = BytecodeViewer.files.get(0).name;
                ClassNode classnode = BytecodeViewer.getCurrentlyOpenedClassNode();
                if (tabComp != null) {
                    //Call XposedGenerator class
                    XposedGenerator xposed = new XposedGenerator();
                    xposed.ParseChosenFileContent(className, containerName, classnode);
                }
            }
        }
    };
    t.start();
}

From source file:com.mac.tarchan.desktop.event.EventQuery.java

/**
 * ??????????//from   ww w. j  a  va  2  s .c  o  m
 * 
 * @param base ??
 * @param name ???
 * @return ??
 */
protected EventQuery find(Component base, String name) {
    log.debug(String.format("find: name=%s, list=(%s), parent=%s", name, list(list), parent));
    if (base instanceof Container) {
        Container parent = (Container) base;
        //         System.out.format("Container: %s\n", parent.getName());
        for (Component child : getComponents(parent)) {
            find(child, name);
        }
    }

    //      System.out.format("Component: %s [%s]\n", base.getName(),  base.getClass().getName());
    if (base.getName() != null && base.getName().matches(name)) {
        //         System.out.format("add list: %s [%s]\n", base.getName(),  name);
        list.add(base);
    }

    return this;
}