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:org.eclipse.jubula.rc.swing.components.AUTSwingHierarchy.java

/**
 * {@inheritDoc}//from   w  w w .  j  av  a2 s . c o  m
 */
public IComponentIdentifier[] getAllComponentId() {
    checkDispatchThread();
    List result = new Vector();
    Set keys = getHierarchyMap().keySet();
    for (Iterator iter = keys.iterator(); iter.hasNext();) {
        Component component = ((SwingComponent) iter.next()).getRealComponent();
        try {
            if (AUTServerConfiguration.getInstance().isSupported(component)) {

                result.add(getComponentIdentifier(component));
            }
        } catch (IllegalArgumentException iae) {
            // from isSupported -> log
            log.error("hierarchy map contains null values", iae); //$NON-NLS-1$   
            // and continue
        } catch (ComponentNotManagedException e) {
            // from isSupported -> log
            log.error("component '" + component.getName() + "' not found!", e); //$NON-NLS-1$ //$NON-NLS-2$                    
            // and continue
        }
    }
    return (IComponentIdentifier[]) result.toArray(new IComponentIdentifier[result.size()]);
}

From source file:tufts.vue.RichTextBox.java

/**
 * This is what triggers the final save of the new text value to the LWComponent,
 * and notify's the UndoManager that a user action was completed.
 *///from   www . ja  va2s . c  o  m
public void focusLost(FocusEvent e) {

    final java.awt.Component opposite = e.getOppositeComponent();

    if (opposite != null) {
        if ((opposite.getName() != null && opposite.getName().equals(FontEditorPanel.SIZE_FIELD_NAME))
                || opposite.getClass() == ColorMenuButton.class)
            return;
        else if (opposite.getClass() == FontEditorPanel.class || DockWindow.isDockWindow(opposite) ||
        // todo: something more generic than this getName check: set a property on the JComponent tagging it as a tool/editor?
                opposite.getClass() == JComboBox.class || (opposite.getName() != null
                        && opposite.getName().equals(tufts.vue.gui.ColorMenuButton.COLOR_POPUP_NAME))
                ||
                //quaqua makes this a bit awkard, this is for quaqua's color chooser.
                (opposite.getName() != null && opposite.getName().equals("dialog0"))) {
            //Earlier i was just returning here, but this creates a problem
            //because the component has already lost the focus...and so it doesn't 
            //get another focusLost the next time....so re-request the focus if you've lost
            //it so that we get the event again when we really want to get rid of the focus
            //so we can properly remove the edit control.

            requestFocus();
            return;
        }

    } else if (opposite == null) {
        if (DEBUG.FOCUS)
            outc("Focus not lost because opposite component = null");
        requestFocus();
        return;
    }

    //System.out.println(e.getComponent().toString());
    //System.out.println(e.getOppositeComponent().toString());
    if (TestDebug || DEBUG.FOCUS)
        outc("focusLost to " + e.getOppositeComponent() + "   " + opposite.getName());
    if (TestHarness == false && getParent() != null) {
        getParent().remove(this);
        // VUE.getFormattingPanel().getTextPropsPane().getFontEditorPanel().updateFormatControlsTB(this);
    }
    if (keyWasPressed || !keyWasPressed) { // TODO: as per VueTextField, need to handle drag & drop detect
        // only do this if they typed something (so we don't wind up with "label"
        // for the label on an accidental edit activation)
        if (TestDebug || DEBUG.FOCUS)
            out("key was pressed; setting label to: [" + getText() + "]");
        String text = getText();
        if (revert) {
            text = mUnchangedText;
            revert = false;
            //   setText(text);
        }
        lwc.setLabel0(text, false);

        VUE.getUndoManager().mark();
    }
    ////        setSize(getPreferredSize());
    //  lwc.setSize(mBounds.width, mBounds.height);
    if (lwc.getParent() != null && lwc.getParent() instanceof LWNode)
        lwc.getParent().layout();
    lwc.notify(this, LWKey.Repaint);
}

From source file:org.zaproxy.zap.extension.zest.ExtensionZest.java

public boolean isScriptTree(Component component) {
    return this.getExtScript().getScriptUI() != null && component != null
            && this.getExtScript().getScriptUI().getTreeName().equals(component.getName());
}

From source file:org.datavyu.views.DatavyuView.java

/**
 * The action to invoke when the user selects 'scripts' from the main menu.
 *
 * @param evt// w w  w .ja v a  2s.  c  o  m
 *            The event that fired this action.
 */
private void populateFavourites(final javax.swing.event.MenuEvent evt) { // GEN-FIRST:event_populateFavourites

    // Favourite script list starts after the 'favScripts' menu item - which
    // is just a stub for a starting point. Search for the favScripts as the
    // starting point for deleting existing scripts from the menu.
    Component[] list = scriptMenu.getMenuComponents();
    int start = 0;

    for (Component c : list) {
        start++;

        if (c.getName().equals("favScripts")) {
            break;
        }
    }

    // Delete every menu item from 'favScripts' down to the end of the list.
    // Favscripts are
    int size = scriptMenu.getMenuComponentCount();

    for (int i = start; i < size; i++) {
        scriptMenu.remove(i);
    }

    // Get list of favourite scripts from the favourites folder.
    File favouritesDir = new File(FAV_DIR);
    String[] children = favouritesDir.list();

    if (children != null) {

        for (String s : children) {
            File f = new File(FAV_DIR + File.separatorChar + s);
            scriptMenu.add(createScriptMenuItemFromFile(f));
        }
    }
}

From source file:self.philbrown.javaQuery.$.java

/**
 * Finds a component that is identified by the given name
 * @param name/* w w  w .j a v a2 s. c  om*/
 * @return the found component, or {@code null} if it was not found.
 */
public static Component findComponentWithName(String name, Component parent)//FIXME: debug to ensure this is working!
{
    if (parent.getName() != null && parent.equals(name))
        return parent;
    else if (parent instanceof Container) {
        for (Component c : ((Container) parent).getComponents()) {
            Component found = findComponentWithName(name, c);
            if (found != null) {
                return found;
            }
        }
    }
    return null;
}

From source file:com.projity.pm.graphic.frames.GraphicManager.java

/** determines the parent graphic manager for a component
 *
 * @param component/*from   w w  w.j  av  a2 s . com*/
 * @return
 */
public static GraphicManager getInstance(Component component) {
    Component c = component;
    for (c = component; c != null; c = c.getParent()) {
        if (c instanceof FrameHolder)
            return ((FrameHolder) c).getGraphicManager();
        else if (c.getName() != null && c.getName().endsWith("BootstrapApplet")
                && c.getClass().getName().endsWith("BootstrapApplet")) {
            System.out.println("applet: " + c.getClass().getName());
            try {
                FrameHolder holder = (FrameHolder) Class.forName("com.projity.bootstrap.BootstrapApplet.class")
                        .getMethod("getObject", null).invoke(c, null);
                return holder.getGraphicManager();
            } catch (Exception e) {
                return null;
            }
        }
    }
    return lastGraphicManager; // if none found, use last used one
}

From source file:org.nuclos.client.layout.wysiwyg.LayoutMLGenerator.java

/**
 * Method converting the {@link WYSIWYGTabbedPane} to LayoutML XML.
 *
 *
 * @see LayoutMLBlock// w w  w .  j  av a  2 s.  co m
 * @param tabPane
 * @param tableLayout
 * @param blockDeep
 * @return {@link StringBuffer} with the LayoutML
 */
private synchronized StringBuffer getLayoutMLForTabbedPane(WYSIWYGTabbedPane tabPane, TableLayout tableLayout,
        int blockDeep) throws CommonValidationException {
    LayoutMLBlock block = new LayoutMLBlock(blockDeep);
    block.append("<" + ELEMENT_TABBEDPANE + " ");
    block.append(
            getLayoutMLAttributesFromProperties(tabPane.getPropertyAttributeLink(), tabPane.getProperties()));
    block.append(">");
    block.append(getLayoutMLTableLayoutConstraints(tabPane, tableLayout, blockDeep + 1));
    block.append(getLayoutMLBordersFromProperty(tabPane.getProperties(), blockDeep + 1));
    block.append(getLayoutMLMinimumSizeFromComponent(tabPane, blockDeep + 1));
    block.append(getLayoutMLPreferredSizeFromProperty(tabPane.getProperties(), blockDeep + 1));

    for (int i = 0; i < tabPane.getTabCount(); i++) {
        Component c = tabPane.getComponentAt(i);
        if (c instanceof WYSIWYGLayoutEditorPanel) {
            WYSIWYGLayoutEditorPanel panel = (WYSIWYGLayoutEditorPanel) c;
            String sTitle = null;
            if (panel.getName() != null) {
                sTitle = c.getName();
            } else {
                sTitle = tabPane.getTitleAt(i);
            }
            block.append(getLayoutMLForPanel((WYSIWYGLayoutEditorPanel) c, blockDeep + 1,
                    getLayoutMLTabbedPaneConstraints(tabPane.getTitleAt(i), tabPane.isEnabledAt(i),
                            blockDeep + 1, tabPane.getTabTranslations().get(i), sTitle,
                            tabPane.getMnemonicAt(i))));
        }
    }

    block.linebreak();
    block.append("</" + ELEMENT_TABBEDPANE + ">");

    return block.getStringBuffer();
}