Example usage for java.awt Component getParent

List of usage examples for java.awt Component getParent

Introduction

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

Prototype

public Container getParent() 

Source Link

Document

Gets the parent of this component.

Usage

From source file:edu.ku.brc.specify.config.init.SpecifyDBSetupWizard.java

/**
 * @param wizardType/*from w w w.j  a  v a  2  s .co m*/
 * @param listener
 */
public SpecifyDBSetupWizard(final WizardType wizardType, final WizardListener listener) {
    super();

    this.wizardType = wizardType;
    this.listener = listener;

    System.setProperty(DBMSUserMgr.factoryName, "edu.ku.brc.dbsupport.MySQLDMBSUserMgr");

    /*setupXMLPath = UIRegistry.getUserHomeAppDir() + File.separator + "setup_prefs.xml";
    try
    {
    props.loadFromXML(new FileInputStream(new File(setupXMLPath)));
            
    } catch (Exception ex)
    {
    edu.ku.brc.af.core.UsageTracker.incrHandledUsageCount();
    edu.ku.brc.exceptions.ExceptionTracker.getInstance().capture(SpecifyDBSetupWizard.class, ex);
    }*/

    HelpMgr.setLoadingPage("Load");

    cardPanel = new JPanel(cardLayout);

    cancelBtn = createButton(UIRegistry.getResourceString("CANCEL"));
    helpBtn = createButton(UIRegistry.getResourceString("HELP"));

    JPanel btnBar;
    backBtn = createButton(UIRegistry.getResourceString("BACK"));
    nextBtn = createButton(UIRegistry.getResourceString("NEXT"));

    CellConstraints cc = new CellConstraints();
    PanelBuilder bbpb = new PanelBuilder(new FormLayout("f:p:g,p,4px,p,4px,p,4px,p,4px", "p"));

    bbpb.add(helpBtn, cc.xy(2, 1));
    bbpb.add(backBtn, cc.xy(4, 1));
    bbpb.add(nextBtn, cc.xy(6, 1));
    bbpb.add(cancelBtn, cc.xy(8, 1));

    btnBar = bbpb.getPanel();

    boolean doTesting = AppPreferences.getLocalPrefs().getBoolean("wizard.defaults", false);
    if (doTesting && wizardType == WizardType.Institution) {
        props.put("hostName", "localhost");
        props.put("dbName", "testfish");
        props.put("dbUserName", "Specify");
        props.put("dbPassword", "Specify");

        props.put("saUserName", "Master");
        props.put("saPassword", "Master");

        props.put("firstName", "Test");
        props.put("lastName", "User");
        props.put("middleInitial", "a");
        props.put("email", "tester@ku.edu");
        props.put("usrUsername", "testuser");
        props.put("usrPassword", "testuser");

        props.put("instName", "KU natural History Museum");
        props.put("instAbbrev", "KU-NHM");

        props.put("divName", "Fish");
        props.put("divAbbrev", "IT");

        props.put("collName", "Fish");
        props.put("collPrefix", "KUFSH");

        // Address
        props.put("addr1", "1345 Jayhawk Blvd");
        props.put("addr2", "606 Dyche Hall");
        props.put("city", "Lawrence");
        props.put("state", "KS");
        props.put("country", "USA");
        props.put("zip", "66044");
        props.put("phone", "785-864-5555");

        props.put("addtaxon", true);
    } else {
        props.put("hostName", "localhost");
        props.put("dbName", "specify");
    }

    props.put("userType", SpecifyUserTypes.UserType.Manager.toString());

    UIFieldFormatterMgr.setDoingLocal(true);

    String accessionFmt = null;

    if (wizardType == WizardType.Institution) {
        props.put("fromwizard", "true");

        dbPanel = new DatabasePanel(nextBtn, backBtn, getHelpCntxt("wizard_mysql_username"), true);
        panels.add(dbPanel);
        HelpMgr.registerComponent(helpBtn, dbPanel.getHelpContext());
        if (listener != null) {
            listener.helpContextChanged(dbPanel.getHelpContext());
        }
        panels.add(new MasterUserPanel("SA", "ENTER_SA_INFO", getHelpCntxt("wizard_master_username"),
                new String[] { "SA_USERNAME", "SA_PASSWORD" }, new String[] { "saUserName", "saPassword" },
                new Integer[] { 32, 32 }, nextBtn, backBtn, true));

        panels.add(new GenericFormPanel("SECURITY", "SECURITY_INFO", getHelpCntxt("wizard_security_on"),
                new String[] { "SECURITY_ON" }, new String[] { "security_on" }, new String[] { "checkbox" },
                nextBtn, backBtn, true));

        userInfoPanel = new UserInfoPanel("AGENT", "ENTER_COLMGR_INFO", getHelpCntxt("wizard_create_it_user"),
                new String[] { "FIRSTNAME", "LASTNAME", "MIDNAME", "EMAIL", null, "USERLOGININFO", "USERNAME",
                        "PASSWORD" },
                new String[] { "firstName", "lastName", "middleInitial", "email", " ", "-", "usrUsername",
                        "usrPassword" },
                new boolean[] { true, true, false, true, true, false, true, true },
                new Integer[] { 50, 120, 50, 50, null, null, 64, 32 }, nextBtn, backBtn);
        panels.add(userInfoPanel);

        panels.add(new GenericFormPanel("INST", "ENTER_INST_INFO", getHelpCntxt("wizard_create_institution"),
                new String[] { "NAME", "ABBREV", null, "INST_ADDR", "ADDR1", "ADDR2", "CITY", "STATE",
                        "COUNTRY", "ZIP", "PHONE" },
                new String[] { "instName", "instAbbrev", " ", "-", "addr1", "addr2", "city", "state", "country",
                        "zip", "phone" },
                new boolean[] { true, true, false, false, true, false, true, true, true, true, true },
                new Integer[] { 255, 32, 50, null, 255, 255, 64, 64, 64, 32, 50 }, nextBtn, backBtn, true));

        accessionPanel = new GenericFormPanel("ACCESSIONGLOBALLY", "ENTER_ACC_INFO",
                getHelpCntxt("wizard_choose_accession_level"), new String[] { "ACCGLOBALLY" },
                new String[] { "accglobal" }, new String[] { "checkbox" }, nextBtn, backBtn, true);
        panels.add(accessionPanel);

        if (wizardType == WizardType.Institution) {
            accessionPickerGbl = new FormatterPickerPanel("ACCNOFMT",
                    getHelpCntxt("wizard_create_accession_number"), nextBtn, backBtn, false, null);
            panels.add(accessionPickerGbl);

        }

        storageTDPanel = new TreeDefSetupPanel(StorageTreeDef.class, getResourceString("Storage"), "Storage",
                getHelpCntxt("wizard_configure_storage_tree"), "CONFIG_TREEDEF", nextBtn, backBtn, null);
        panels.add(storageTDPanel);

        panels.add(new InstSetupPanel("CREATEINST", "CREATEINST", getHelpCntxt("wizard_create_institution"),
                new String[] {}, new String[] {}, new Integer[] {}, nextBtn, backBtn, true));
    }

    if (wizardType == WizardType.Institution || wizardType == WizardType.Division) {
        DivisionPanel divPanel = new DivisionPanel("DIV", "ENTER_DIV_INFO",
                getHelpCntxt("wizard_enter_division"), new String[] { "NAME", "ABBREV" },
                new String[] { "divName", "divAbbrev" }, new Integer[] { 255, 64 }, nextBtn, backBtn, true);
        panels.add(divPanel);

        if (wizardType == WizardType.Division) {
            HelpMgr.registerComponent(helpBtn, divPanel.getHelpContext());
        }
    }

    if (wizardType != WizardType.Institution) {
        Institution institution = AppContextMgr.getInstance().getClassObject(Institution.class);
        Division division = AppContextMgr.getInstance().getClassObject(Division.class);
        if (!institution.getIsAccessionsGlobal()) {
            String sql = "SELECT ans.FormatName FROM autonumberingscheme ans  Inner Join autonumsch_div ad ON ans.AutoNumberingSchemeID = ad.AutoNumberingSchemeID "
                    + "INNER JOIN division d ON ad.DivisionID = d.UserGroupScopeId WHERE d.DivisionID = "
                    + division.getId();
            log.debug(sql);
            Vector<Object> rows = BasicSQLUtils.querySingleCol(sql);
            if (rows.size() == 1) {
                accessionFmt = rows.get(0).toString();
            } else {
                log.error("The return " + rows.size());
            }
        }
    }

    if (wizardType == WizardType.Institution || wizardType == WizardType.Division
            || wizardType == WizardType.Discipline) {
        nextBtn.setEnabled(false);
        disciplinePanel = new DisciplinePanel(getHelpCntxt("wizard_choose_discipline_type"), nextBtn, backBtn);
        panels.add(disciplinePanel);

        if (wizardType == WizardType.Discipline) {
            HelpMgr.registerComponent(helpBtn, disciplinePanel.getHelpContext());
        }

        taxonTDPanel = new TreeDefSetupPanel(TaxonTreeDef.class, getResourceString("Taxon"), "Taxon",
                getHelpCntxt("wizard_configure_taxon_tree"), "CONFIG_TREEDEF", nextBtn, backBtn,
                disciplinePanel);
        panels.add(taxonTDPanel);

        panels.add(new TaxonLoadSetupPanel(getHelpCntxt("wizard_preload_taxon"), nextBtn, backBtn));

        geoTDPanel = new TreeDefSetupPanel(GeographyTreeDef.class, getResourceString("Geography"), "Geography",
                getHelpCntxt("wizard_configure_geography_tree"), "CONFIG_TREEDEF", nextBtn, backBtn,
                disciplinePanel);
        panels.add(geoTDPanel);
    }

    CollectionPanel colPanel = new CollectionPanel("COLLECTION", "ENTER_COL_INFO",
            getHelpCntxt("wizard_create_collection"), new String[] { "NAME", "PREFIX", },
            new String[] { "collName", "collPrefix", }, new Integer[] { 50, 50 }, nextBtn, backBtn, true);
    panels.add(colPanel);

    if (wizardType == WizardType.Collection) {
        HelpMgr.registerComponent(helpBtn, colPanel.getHelpContext());
    }

    catNumPicker = new FormatterPickerPanel("CATNOFMT", getHelpCntxt("wizard_create_catalog_number"), nextBtn,
            backBtn, true, null);
    panels.add(catNumPicker);

    if (wizardType != WizardType.Institution) {
        Division division = AppContextMgr.getInstance().getClassObject(Division.class);
        String sql = "SELECT COUNT(*) FROM division d INNER JOIN collection c ON d.UserGroupScopeId = c.DisciplineID WHERE d.UserGroupScopeId = "
                + division.getId();
        log.debug(sql);
        int numCollectionsByDiv = BasicSQLUtils.getCountAsInt(sql);

        if (numCollectionsByDiv == 0) {
            Institution inst = AppContextMgr.getInstance().getClassObject(Institution.class);
            if (inst != null && !inst.getIsAccessionsGlobal()) {
                //if (wizardType != WizardType.Division)
                {
                    accessionPickerCol = new FormatterPickerPanel("ACCNOFMT",
                            getHelpCntxt("wizard_create_accession_number"), nextBtn, backBtn, false,
                            accessionFmt);
                    accessionPickerCol.setDoingDisciplineCollection(wizardType != WizardType.Division);
                    panels.add(accessionPickerCol);
                }
            }
        }
    } else {
        accessionPickerCol = new FormatterPickerPanel("ACCNOFMT",
                getHelpCntxt("wizard_create_accession_number"), nextBtn, backBtn, false, null);
        panels.add(accessionPickerCol);
    }

    panels.add(new SummaryPanel("SUMMARY", getHelpCntxt("wizard_summary"), nextBtn, backBtn, panels));

    lastStep = panels.size();

    if (backBtn != null) {
        backBtn.addActionListener(new ActionListener() {
            public void actionPerformed(ActionEvent ae) {
                if (step > 0) {
                    if (disciplinePanel != null) {
                        DisciplineType disciplineType = disciplinePanel.getDisciplineType();
                        if (disciplineType != null && disciplineType.isPaleo()
                                && panels.get(step - 1) instanceof TaxonLoadSetupPanel) {
                            //step--;
                        }
                    }

                    if (panels.get(step - 1) == accessionPickerGbl) {
                        if (!((Boolean) props.get("accglobal"))) {
                            step--;
                        }
                    }

                    if (panels.get(step - 1) == accessionPickerCol) {
                        boolean isAccGlobal;
                        if (accessionPanel != null) {
                            accessionPanel.getValues(props);
                            isAccGlobal = (Boolean) props.get("accglobal");
                        } else {
                            Institution inst = AppContextMgr.getInstance().getClassObject(Institution.class);
                            isAccGlobal = inst != null && !inst.getIsAccessionsGlobal();
                        }
                        if (isAccGlobal) {
                            step--;
                        }
                    }

                    step--;
                    panels.get(step).doingPrev();
                    HelpMgr.registerComponent(helpBtn, panels.get(step).getHelpContext());
                    cardLayout.show(cardPanel, Integer.toString(step));
                }
                updateBtnBar();
                if (listener != null) {
                    listener.panelChanged(getResourceString(panels.get(step).getPanelName() + ".TITLE"));
                    listener.helpContextChanged(panels.get(step).getHelpContext());
                }
            }
        });

        backBtn.setEnabled(false);
    }

    nextBtn.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent ae) {
            if (step == lastStep - 2) {
                SwingUtilities.invokeLater(new Runnable() {
                    @Override
                    public void run() {
                        Component c = SpecifyDBSetupWizard.this.getParent();
                        while (!(c instanceof Window) && c != null) {
                            c = c.getParent();
                        }
                        if (c != null) {
                            ((Window) c).pack();
                        }
                    }
                });
            }

            if (step < lastStep - 1) {
                DisciplineType disciplineType = null;
                if (disciplinePanel == null) {
                    Discipline discipline = AppContextMgr.getInstance().getClassObject(Discipline.class);
                    disciplineType = DisciplineType.getByName(discipline.getType());

                } else {
                    disciplineType = disciplinePanel.getDisciplineType();
                }

                panels.get(step).getValues(props);
                panels.get(step).aboutToLeave();

                if (step == 1) {
                    String isCnvUploadVal = props.getProperty(DatabasePanel.DB_STRUCT_ONLY);
                    boolean isCnvUpload = StringUtils.isNotEmpty(isCnvUploadVal) ? isCnvUploadVal.equals("true")
                            : false;
                    if (isCnvUpload) {
                        setupLoginPrefs();

                        JOptionPane.showMessageDialog(UIRegistry.getTopWindow(),
                                getResourceString("CONVUPLD_DONE"), getResourceString("COMPLETE"),
                                JOptionPane.INFORMATION_MESSAGE);
                        SpecifyDBSetupWizard.this.listener.finished();
                        return;
                    }
                }

                if (disciplineType != null && disciplineType.isPaleo()
                        && panels.get(step) instanceof TreeDefSetupPanel
                        && ((TreeDefSetupPanel) panels.get(step)).getClassType() == TaxonTreeDef.class) {
                    //step++;
                }

                if (panels.get(step) == accessionPanel) {
                    accessionPanel.getValues(props);
                    if (!((Boolean) props.get("accglobal"))) {
                        step++;
                    }
                }

                if (panels.get(step) == catNumPicker) {

                    if (accessionPanel != null) {
                        accessionPanel.getValues(props);
                        boolean isAccGlobal = (Boolean) props.get("accglobal");
                        if (isAccGlobal) {
                            step++;
                        }
                    }
                }

                advanceToNextPanel();

            } else {
                nextBtn.setEnabled(false);

                if (wizardType == WizardType.Institution) {
                    configSetup();

                    configureDatabase();
                } else {
                    //SpecifyDBSetupWizard.this.listener.hide();
                    SpecifyDBSetupWizard.this.listener.finished();
                }
            }
        }
    });

    cancelBtn.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent ae) {
            if (SpecifyDBSetupWizard.this.listener != null) {
                if (step == lastStep) {
                    SpecifyDBSetupWizard.this.listener.finished();
                } else {
                    if (UIHelper.promptForAction("QUIT", "NO", "CANCEL", getResourceString("SURE_QUIT"))) {
                        SpecifyDBSetupWizard.this.listener.cancelled();
                    }
                }
            }
        }
    });

    for (int i = 0; i < panels.size(); i++) {
        cardPanel.add(Integer.toString(i), panels.get(i));
        panels.get(i).setValues(props);
    }
    cardLayout.show(cardPanel, "0");

    if (dbPanel != null) {
        dbPanel.updateBtnUI();
    }

    PanelBuilder builder = new PanelBuilder(new FormLayout("f:p:g", "f:p:g,10px,p"));
    builder.add(cardPanel, cc.xy(1, 1));
    builder.add(btnBar, cc.xy(1, 3));

    builder.setDefaultDialogBorder();

    setLayout(new BorderLayout());
    PanelBuilder iconBldr = new PanelBuilder(new FormLayout("20px, f:p:g,p,f:p:g,8px", "20px,t:p,f:p:g, 8px"));
    JLabel iconLbl = new JLabel(IconManager.getIcon(getIconName()));
    iconLbl.setVerticalAlignment(SwingConstants.TOP);
    iconBldr.add(iconLbl, cc.xy(2, 3));
    add(iconBldr.getPanel(), BorderLayout.WEST);
    add(builder.getPanel(), BorderLayout.CENTER);

    progressBar = new JProgressBar(0, lastStep - 1);
    progressBar.setStringPainted(true);
    add(progressBar, BorderLayout.SOUTH);

    panels.get(0).updateBtnUI();

}

From source file:game.Clue.ClueGameUI.java

public void mouseReleased(MouseEvent e) {

    System.out.println("Mouse clicked/released on chosen room" + e.getSource().toString());

    if (player == null) {
        return;//  w ww  .  ja  v a2s.  co m
    }

    //validate move by sending move request to Server before allowing move
    int valid = 1;

    player.setVisible(false);

    Component c = jPanel5.findComponentAt(e.getX(), e.getY());

    if (c instanceof JLabel) {
        Container parent = c.getParent();
        if (parent.getComponentCount() == 0) {
            System.out.println("------");
            //parent.remove(0);
            parent.add(player);

        } else {
            System.out.println("%%%%%");
            parent.add(player);
            parent.validate();
            //return;
        }

    } else {
        Container parent = (Container) c;
        if (parent.getComponentCount() == 1) {
            System.out.println("*****");
            return;
        } else {
            System.out.println("&&&&&");
            parent.add(player);
        }

    }
    if (valid != 0) {
        System.out.println("Player move allowed" + " x:" + e.getX() + "y: " + e.getY());
        System.out.println("Previous x:" + previous_room_x + "  Y:" + previous_room_y);
        player.setLocation(previous_room_x, previous_room_y);
        // player.setLocation(e.getX(),e.getY());
    } else {

    }
    player.setHorizontalAlignment(SwingConstants.CENTER);
    player.setVisible(true);

}

From source file:game.Clue.ClueGameUI.java

public void mousePressed(MouseEvent e) {
    //player=null;
    Component j = e.getComponent();
    //System.out.println("Click component is : \n"+j.toString()+"\n "+(e.getSource().toString());
    Component c = gameBoard.findComponentAt(e.getX(), e.getY());
    if (c instanceof JPanel) {
        System.out.println("No character chosen");
        return;/*from  w w  w  .  j  a va  2s . c om*/
    }

    Point parentLocation = c.getParent().getLocation();
    xAdjustment = parentLocation.x - e.getX();
    yAdjustment = parentLocation.y - e.getY();
    player = (JLabel) c;
    previous_room_x = parentLocation.x + xAdjustment;
    previous_room_y = parentLocation.y + yAdjustment;
    player.setLocation(e.getX() + xAdjustment, e.getY() + yAdjustment);
    player.setSize(player.getWidth(), player.getHeight());
    jLayeredPane5.add(player, JLayeredPane.DRAG_LAYER);

}

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.
 *//*  w ww.j  av  a 2 s .  c o  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:edu.ku.brc.af.ui.db.DatabaseLoginPanel.java

/**
 * Indicates the login is OK and closes the dialog for the user to continue on
 *//*from  w  w  w  . j  ava 2  s .c o m*/
protected void loginOK() {
    Component parent = getParent();
    while (!(parent instanceof Window)) {
        parent = parent.getParent();
    }

    isCancelled = false;
    if (dbListener != null) {
        dbListener.loggedIn((Window) parent, getDatabaseName(), getUserName());
    } else {
        log.debug("listener is NULL"); //$NON-NLS-1$
    }
}

From source file:org.jets3t.apps.uploader.Uploader.java

/**
 * Prepares application to run as a GUI by finding/creating a root owner JFrame, and
 * (if necessary) creating a directory for storing remembered logins.
 *//*from  w w w  . j  a v  a 2  s  .  c  om*/
@Override
public void init() {
    super.init();

    boolean isMissingRequiredInitProperty = false;

    // Find or create a Frame to own modal dialog boxes.
    if (this.ownerFrame == null) {
        Component c = this;
        while (!(c instanceof Frame) && c.getParent() != null) {
            c = c.getParent();
        }
        if (!(c instanceof Frame)) {
            this.ownerFrame = new JFrame();
        } else {
            this.ownerFrame = (Frame) c;
        }
    }

    // Read properties from uploader.properties in classpath.
    uploaderProperties = Jets3tProperties.getInstance(UPLOADER_PROPERTIES_FILENAME);

    if (isRunningAsApplet) {
        // Read parameters for Applet, based on names specified in the uploader properties.
        String appletParamNames = uploaderProperties.getStringProperty("applet.params", "");
        StringTokenizer st = new StringTokenizer(appletParamNames, ",");
        while (st.hasMoreTokens()) {
            String paramName = st.nextToken();
            String paramValue = this.getParameter(paramName);

            // Fatal error if a parameter is missing.
            if (null == paramValue) {
                log.error("Missing required applet parameter: " + paramName);
                isMissingRequiredInitProperty = true;
            } else {
                log.debug("Found applet parameter: " + paramName + "='" + paramValue + "'");

                // Set params as properties in the central properties source for this application.
                // Note that parameter values will over-write properties with the same name.
                uploaderProperties.setProperty(paramName, paramValue);

                // Store params in a separate map, which is used to build XML document.
                parametersMap.put(paramName, paramValue);
            }
        }
    } else {
        // Add application parameters properties.
        if (standAloneArgumentProperties != null) {
            Enumeration e = standAloneArgumentProperties.keys();
            while (e.hasMoreElements()) {
                String propName = (String) e.nextElement();
                String propValue = standAloneArgumentProperties.getProperty(propName);

                // Fatal error if a parameter is missing.
                if (null == propValue) {
                    log.error("Missing required command-line property: " + propName);
                    isMissingRequiredInitProperty = true;
                } else {
                    log.debug("Using command-line property: " + propName + "='" + propValue + "'");

                    // Set arguments as properties in the central properties source for this application.
                    // Note that argument values will over-write properties with the same name.
                    uploaderProperties.setProperty(propName, propValue);

                    // Store arguments in a separate map, which is used to build XML document.
                    parametersMap.put(propName, propValue);
                }
            }
        }
    }

    // Determine the file constraints.
    fileMaxCount = uploaderProperties.getIntProperty("file.maxCount", 1);
    fileMaxSizeMB = uploaderProperties.getLongProperty("file.maxSizeMB", 200);
    fileMinSizeMB = uploaderProperties.getLongProperty("file.minSizeMB", 0);

    // Initialise the GUI.
    initGui();

    // Jump to error page if there was an exception raised during initialisation.
    if (isMissingRequiredInitProperty) {
        failWithFatalError(ERROR_CODE__MISSING_REQUIRED_PARAM);
        return;
    }

    // Determine valid file extensions.
    String validFileExtensionsStr = uploaderProperties.getStringProperty("file.extensions", "");
    if (validFileExtensionsStr != null) {
        StringTokenizer st = new StringTokenizer(validFileExtensionsStr, ",");
        while (st.hasMoreTokens()) {
            validFileExtensions.add(st.nextToken().toLowerCase(Locale.getDefault()));
        }
    }
}

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.
 *///www . ja  v  a2s  .c o  m
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:brainflow.app.toplevel.BrainFlow.java

private void showActionMenu(MouseEvent e) {
    Component c = SwingUtilities.getDeepestComponentAt(e.getComponent(), e.getX(), e.getY());
    java.util.List<Action> actionList = new ArrayList<Action>();
    while (true) {
        if (c instanceof IActionProvider) {
            IActionProvider provider = (IActionProvider) c;
            provider.addActions(e, actionList);
        } else if (c instanceof JComponent) {
            JComponent jc = (JComponent) c;

            Object provider = jc.getClientProperty(IActionProvider.KEY);
            if (provider != null) {
                ((IActionProvider) provider).addActions(e, actionList);
            }/* w  w  w . j av  a2 s.c  om*/
        }

        Component p = c.getParent();
        if (p != null) {
            c = p;
        } else {
            break;
        }

    }

    if (actionList.size() > 0) {
        createPopup(actionList).setVisible(true);
    }

}

From source file:freemind.controller.Controller.java

public void setLeftToolbarVisible(boolean visible) {
    leftToolbarVisible = visible;//from   www  .j av a2  s .  c  o m
    if (getMode() == null) {
        return;
    }
    final Component leftToolBar = getModeController().getLeftToolBar();
    if (leftToolBar != null) {
        leftToolBar.setVisible(leftToolbarVisible);
        ((JComponent) leftToolBar.getParent()).revalidate();
    }
}

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 ava 2s .  c o  m
 * @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
}