Example usage for javax.swing JScrollPane setVerticalScrollBarPolicy

List of usage examples for javax.swing JScrollPane setVerticalScrollBarPolicy

Introduction

In this page you can find the example usage for javax.swing JScrollPane setVerticalScrollBarPolicy.

Prototype

@BeanProperty(preferred = true, enumerationValues = { "ScrollPaneConstants.VERTICAL_SCROLLBAR_AS_NEEDED",
        "ScrollPaneConstants.VERTICAL_SCROLLBAR_NEVER",
        "ScrollPaneConstants.VERTICAL_SCROLLBAR_ALWAYS" }, description = "The scrollpane vertical scrollbar policy")
public void setVerticalScrollBarPolicy(int policy) 

Source Link

Document

Determines when the vertical scrollbar appears in the scrollpane.

Usage

From source file:it.imtech.metadata.MetaUtility.java

/**
 * Aggiunge il pannello delle classificazioni all'interfaccia dei metadati
 *
 * @param innerPanel Pannello sul quale aggiungere i metadati
 * @param kv Valori dei metadati/*from w  w  w .  j av a 2 s  .c  o  m*/
 */
private void addClassification(JPanel innerPanel, Integer kv, final String sequence, final String panelname)
        throws Exception {
    try {
        ResourceBundle bundle = ResourceBundle.getBundle(Globals.RESOURCES, Globals.CURRENT_LOCALE,
                Globals.loader);

        DefaultMutableTreeNode hierarchy = new DefaultMutableTreeNode("root");
        selected = null;
        String selectedPath = "";

        String link = selectedClassificationList.get(panelname + "---" + sequence);

        recursiveOefosTreeviewBuild(hierarchy, oefos.get(link), sequence, panelname);
        DefaultTreeModel model = new DefaultTreeModel(hierarchy);

        final JTree tree = new JTree(model);
        tree.setRootVisible(false);

        if (selected != null) {
            TreePath selpath = new TreePath(selected.getPath());
            tree.setSelectionPath(selpath);

            Object[] nodes = selpath.getPath();

            for (int i = 1; i < nodes.length; i++) {
                selectedPath += nodes[i].toString();
                selectedPath += (i != nodes.length - 1) ? "/" : "";
            }
        }

        tree.setName("MID_" + Integer.toString(kv) + "---" + sequence);
        tree.getSelectionModel().setSelectionMode(TreeSelectionModel.SINGLE_TREE_SELECTION);

        tree.addTreeSelectionListener(new TreeSelectionListener() {

            public void valueChanged(TreeSelectionEvent e) {
                try {
                    setOEFOS(tree, sequence, panelname);
                } catch (Exception ex) {
                    logger.error(ex.getMessage());
                }
            }
        });

        javax.swing.JScrollPane tree_scroller = new javax.swing.JScrollPane();
        tree_scroller
                .setHorizontalScrollBarPolicy(javax.swing.ScrollPaneConstants.HORIZONTAL_SCROLLBAR_AS_NEEDED);
        tree_scroller.setVerticalScrollBarPolicy(javax.swing.ScrollPaneConstants.VERTICAL_SCROLLBAR_AS_NEEDED);
        tree_scroller.setViewportView(tree);
        tree_scroller.setBorder(null);

        innerPanel.add(tree_scroller, "wrap, width 100:800:800");

        JPanel iPanel = new JPanel(new MigLayout());
        iPanel.setBorder(BorderFactory.createTitledBorder(BorderFactory.createEtchedBorder(),
                Utility.getBundleString("choose2", bundle), TitledBorder.LEFT, TitledBorder.TOP));
        JLabel label = new JLabel();
        label.setName("classification_path" + "---" + sequence);
        label.setText(selectedPath);
        iPanel.add(label, "wrap, growx, height 30:30:30");

        innerPanel.add(iPanel, "wrap, width 100:800:800");

        findLastClassification(panelname);

    } catch (Exception ex) {
        logger.error(ex.getMessage());
        throw new Exception("Exception in addClassification: " + ex.getStackTrace() + "\n");
    }
}

From source file:eu.apenet.dpt.standalone.gui.ead2edm.EdmOptionsPanel.java

private void createOptionPanel() {
    labels = dataPreparationToolGUI.getLabels();
    JPanel creativeCommonsPanel = new CreativeCommonsPanel();
    JPanel europeanaRightsPanel = new EuropeanaRightsPanel();
    JPanel emptyPanel = new JPanel();

    JPanel formPanel = new JPanel(new GridLayout(14, 1));

    JPanel extraLicenseCardLayoutPanel = new JPanel(new CardLayout());
    extraLicenseCardLayoutPanel.add(creativeCommonsPanel, CREATIVE_COMMONS);
    extraLicenseCardLayoutPanel.add(europeanaRightsPanel, EUROPEANA_RIGHTS_STATEMENTS);
    extraLicenseCardLayoutPanel.add(emptyPanel, EMPTY_PANEL);
    CardLayout cardLayout = (CardLayout) extraLicenseCardLayoutPanel.getLayout();
    cardLayout.show(extraLicenseCardLayoutPanel, EMPTY_PANEL);

    JPanel panel = new JPanel(new FlowLayout(FlowLayout.CENTER));
    conversionModeGroup = new ButtonGroup();
    JRadioButton radioButton;/* w w w .  ja v  a 2 s  .co  m*/

    panel.add(new Label(this.labels.getString("edm.panel.label.choose.mode")));
    radioButton = new JRadioButton(this.labels.getString("edm.panel.label.mode.minimal"));
    radioButton.setActionCommand(MINIMAL);
    radioButton.setSelected(true);
    radioButton.addActionListener(new ConversionModeListener());
    conversionModeGroup.add(radioButton);
    panel.add(radioButton);
    radioButton = new JRadioButton(this.labels.getString("edm.panel.label.mode.full"));
    radioButton.setActionCommand(FULL);
    radioButton.addActionListener(new ConversionModeListener());
    conversionModeGroup.add(radioButton);
    panel.add(radioButton);

    formPanel.add(panel);

    panel = new JPanel(new FlowLayout(FlowLayout.CENTER));
    cLevelIdSourceButtonGroup = new ButtonGroup();

    panel.add(new Label(this.labels.getString("edm.generalOptionsForm.identifierSource.header")));
    radioButton = new JRadioButton(this.labels.getString("edm.generalOptionsForm.identifierSource.unitid"));
    radioButton.setActionCommand(UNITID);
    if (retrieveFromDb.retrieveCIdentifierSource().equals(radioButton.getActionCommand())) {
        radioButton.setSelected(true);
    }
    cLevelIdSourceButtonGroup.add(radioButton);
    panel.add(radioButton);
    radioButton = new JRadioButton(this.labels.getString("edm.generalOptionsForm.identifierSource.cid"));
    radioButton.setActionCommand(CID);
    if (retrieveFromDb.retrieveCIdentifierSource().equals(radioButton.getActionCommand())) {
        radioButton.setSelected(true);
    }
    cLevelIdSourceButtonGroup.add(radioButton);
    panel.add(radioButton);

    formPanel.add(panel);

    panel = new JPanel(new FlowLayout(FlowLayout.CENTER));
    sourceOfFondsTitleGroup = new ButtonGroup();

    determineDaoInformation();
    panel.add(new Label(this.labels.getString("edm.generalOptionsForm.sourceOfFondsTitle")));
    if (!this.batch && StringUtils.isBlank(ead2EdmInformation.getArchdescUnittitle())
            && StringUtils.isBlank(ead2EdmInformation.getTitlestmtTitleproper())) {
        panel.add(new Label(
                this.labels.getString("edm.generalOptionsForm.sourceOfFondsTitle.noSourceAvailable")));
    } else {
        radioButton = new JRadioButton(
                this.labels.getString("edm.generalOptionsForm.sourceOfFondsTitle.archdescUnittitle"));
        radioButton.setActionCommand(ARCHDESC_UNITTITLE);
        radioButton.setSelected(true);
        radioButton.addActionListener(new ConversionModeListener());
        sourceOfFondsTitleGroup.add(radioButton);
        panel.add(radioButton);
        radioButton = new JRadioButton(
                this.labels.getString("edm.generalOptionsForm.sourceOfFondsTitle.titlestmtTitleproper"));
        radioButton.setActionCommand(TITLESTMT_TITLEPROPER);
        radioButton.addActionListener(new ConversionModeListener());
        sourceOfFondsTitleGroup.add(radioButton);
        panel.add(radioButton);
    }
    formPanel.add(panel);

    panel = new JPanel(new GridLayout(2, 2));
    landingPageButtonGroup = new ButtonGroup();

    panel.add(new Label(this.labels.getString("edm.generalOptionsForm.landingPages.header")));
    radioButton = new JRadioButton(this.labels.getString("edm.generalOptionsForm.landingPages.ape"));
    radioButton.setActionCommand(APE);
    if (retrieveFromDb.retrieveLandingPageBase().equals(APE_BASE)) {
        radioButton.setSelected(true);
    }
    landingPageButtonGroup.add(radioButton);
    panel.add(radioButton);
    panel.add(new Label());
    JPanel otherPanel = new JPanel(new GridLayout(1, 2));
    radioButton = new JRadioButton(this.labels.getString("edm.generalOptionsForm.landingPages.other"));
    radioButton.setActionCommand(OTHER);
    landingPageButtonGroup.add(radioButton);
    otherPanel.add(radioButton);
    landingPageTextArea = new JTextArea();
    landingPageTextArea.setLineWrap(true);
    landingPageTextArea.setWrapStyleWord(true);
    if (!retrieveFromDb.retrieveLandingPageBase().equals(APE_BASE)) {
        radioButton.setSelected(true);
        landingPageTextArea.setText(retrieveFromDb.retrieveLandingPageBase());
    }
    JScrollPane lptaScrollPane = new JScrollPane(landingPageTextArea);
    lptaScrollPane.setVerticalScrollBarPolicy(JScrollPane.VERTICAL_SCROLLBAR_AS_NEEDED);
    otherPanel.add(lptaScrollPane);
    panel.add(otherPanel);

    formPanel.add(panel);

    panel = new JPanel(new GridLayout(1, 1));
    panel.add(new Label(labels.getString("ese.mandatoryFieldsInfo")));
    panel.add(new Label(""));
    panel.setBorder(BLACK_LINE);
    formPanel.add(panel);

    panel = new JPanel(new GridLayout(1, 3));
    panel.add(new Label(labels.getString("ese.dataProvider") + ":" + "*"));
    dataProviderTextArea = new JTextArea();
    dataProviderTextArea.setLineWrap(true);
    dataProviderTextArea.setWrapStyleWord(true);
    JScrollPane dptaScrollPane = new JScrollPane(dataProviderTextArea);
    dptaScrollPane.setVerticalScrollBarPolicy(JScrollPane.VERTICAL_SCROLLBAR_AS_NEEDED);
    panel.add(dptaScrollPane);
    useExistingRepoCheckbox = new JCheckBox(labels.getString("ese.takeFromFileRepository"));
    useExistingRepoCheckbox.setSelected(true);
    useExistingRepoCheckbox.addItemListener(new ItemListener() {
        @Override
        public void itemStateChanged(ItemEvent e) {
            //empty method on purpose
        }
    });
    JPanel panel2 = new JPanel(new GridLayout(1, 1));
    panel2.add(useExistingRepoCheckbox);
    if (!batch) {
        String repository = ead2EdmInformation.getRepository();
        if (repository != null && !repository.equals("")) {
            dataProviderTextArea.setText(repository);
        } else {
            if (archdescRepository != null) {
                dataProviderTextArea.setText(archdescRepository);
            } else {
                useExistingRepoCheckbox.setSelected(false);
            }
        }
    }
    panel.add(panel2);
    panel.setBorder(BLACK_LINE);
    formPanel.add(panel);

    /*        panel = new JPanel(new GridLayout(1, 3));
     panel.add(new Label(labels.getString("ese.provider") + ":" + "*"));
     providerTextArea = new JTextArea();
     providerTextArea.setLineWrap(true);
     providerTextArea.setWrapStyleWord(true);
     JScrollPane ptaScrollPane = new JScrollPane(providerTextArea);
     ptaScrollPane.setVerticalScrollBarPolicy(JScrollPane.VERTICAL_SCROLLBAR_AS_NEEDED);
     panel.add(ptaScrollPane);
     panel.add(new Label(""));
     panel.setBorder(BLACK_LINE);
     formPanel.add(panel);
     */
    panel = new JPanel(new GridLayout(5, 3));
    typeGroup = new ButtonGroup();

    panel.add(new Label(labels.getString("ese.type") + ":" + "*"));
    String currentRoleType;
    if (batch) {
        currentRoleType = "";
    } else {
        currentRoleType = ead2EdmInformation.getRoleType();
    }
    radioButton = new JRadioButton(this.labels.getString("edm.panel.dao.role.text"));
    if (currentRoleType.equals(EdmOptionsPanel.TEXT)) {
        radioButton.setSelected(true);
    }
    radioButton.setActionCommand(TEXT);
    radioButton.addActionListener(new ConversionModeListener());
    typeGroup.add(radioButton);
    panel.add(radioButton);
    panel.add(new JLabel(""));

    panel.add(new JLabel(""));
    radioButton = new JRadioButton(this.labels.getString("edm.panel.dao.role.image"));
    if (currentRoleType.equals(EdmOptionsPanel.IMAGE)) {
        radioButton.setSelected(true);
    }
    radioButton.setActionCommand(IMAGE);
    radioButton.addActionListener(new ConversionModeListener());
    typeGroup.add(radioButton);
    panel.add(radioButton);
    panel.add(new JLabel(""));

    panel.add(new JLabel(""));
    radioButton = new JRadioButton(this.labels.getString("edm.panel.dao.role.video"));
    if (currentRoleType.equals(EdmOptionsPanel.VIDEO)) {
        radioButton.setSelected(true);
    }
    radioButton.setActionCommand(VIDEO);
    radioButton.addActionListener(new ConversionModeListener());
    typeGroup.add(radioButton);
    panel.add(radioButton);

    useExistingDaoRoleCheckbox = new JCheckBox(labels.getString("ese.takeFromFileDaoRole"));
    useExistingDaoRoleCheckbox.setSelected(true);
    useExistingDaoRoleCheckbox.addItemListener(new ItemListener() {
        @Override
        public void itemStateChanged(ItemEvent e) {
        }
    });
    panel.add(useExistingDaoRoleCheckbox);

    panel.add(new JLabel(""));
    radioButton = new JRadioButton(this.labels.getString("edm.panel.dao.role.sound"));
    if (currentRoleType.equals(EdmOptionsPanel.SOUND)) {
        radioButton.setSelected(true);
    }
    radioButton.setActionCommand(SOUND);
    radioButton.addActionListener(new ConversionModeListener());
    typeGroup.add(radioButton);
    panel.add(radioButton);
    panel.add(new JLabel(""));

    panel.add(new JLabel(""));
    radioButton = new JRadioButton(this.labels.getString("edm.panel.dao.role.threed"));
    if (currentRoleType.equals(EdmOptionsPanel.THREE_D)) {
        radioButton.setSelected(true);
    }
    radioButton.setActionCommand(THREE_D);
    radioButton.addActionListener(new ConversionModeListener());
    typeGroup.add(radioButton);
    panel.add(radioButton);
    panel.add(new JLabel(""));

    panel.setBorder(GREY_LINE);
    formPanel.add(panel);

    if (this.batch) {
        panel = new JPanel(new GridLayout(1, 3));
        panel.add(new Label(labels.getString("ese.selectLanguage") + ":" + "*"));
        panel.add(languageBoxPanel);
        useExistingLanguageCheckbox = new JCheckBox(labels.getString("ese.takeFromFileLanguage"));
        useExistingLanguageCheckbox.setSelected(true);
        useExistingLanguageCheckbox.addItemListener(new ItemListener() {
            @Override
            public void itemStateChanged(ItemEvent e) {
                //empty method on purpose
            }
        });
        panel.add(useExistingLanguageCheckbox);
        panel.setBorder(BLACK_LINE);
        formPanel.add(panel);
    } else {
        inheritLanguagePanel = new JPanel(new GridLayout(1, 3));
        inheritLanguagePanel.add(new Label(labels.getString("ese.inheritLanguage") + ":" + "*"));

        JPanel rbPanel = new JPanel(new GridLayout(4, 1));
        inheritLanguageGroup = new ButtonGroup();
        inhLanYesRadioButton = new JRadioButton(labels.getString("ese.yes"));
        inhLanYesRadioButton.setActionCommand(YES);
        inhLanYesRadioButton.addActionListener(new ChangePanelActionListener(languageBoxPanel));
        inheritLanguageGroup.add(inhLanYesRadioButton);
        rbPanel.add(inhLanYesRadioButton);
        inhLanNoRadioButton = new JRadioButton(labels.getString("ese.no"), true);
        inhLanNoRadioButton.setActionCommand(NO);
        inhLanNoRadioButton.addActionListener(new ChangePanelActionListener(languageBoxPanel));
        inheritLanguageGroup.add(inhLanNoRadioButton);
        rbPanel.add(inhLanNoRadioButton);
        inhLanProvideRadioButton = new JRadioButton(labels.getString("ese.provide"));
        inhLanProvideRadioButton.setActionCommand(PROVIDE);
        inhLanProvideRadioButton.addActionListener(new ChangePanelActionListener(languageBoxPanel));
        inheritLanguageGroup.add(inhLanProvideRadioButton);
        rbPanel.add(inhLanProvideRadioButton);
        useExistingLanguageCheckbox = new JCheckBox(labels.getString("ese.takeFromFileLanguage"));
        useExistingLanguageCheckbox.setSelected(true);
        useExistingLanguageCheckbox.addItemListener(new ItemListener() {
            @Override
            public void itemStateChanged(ItemEvent e) {
                //empty method on purpose
            }
        });
        rbPanel.add(useExistingLanguageCheckbox);
        inheritLanguagePanel.add(rbPanel, BorderLayout.WEST);

        languageBoxPanel.setVisible(true);
        inheritLanguagePanel.add(languageBoxPanel, BorderLayout.EAST);
        inheritLanguagePanel.setBorder(BLACK_LINE);
        inheritLanguagePanel.setVisible(true);
        formPanel.add(inheritLanguagePanel);
    }

    //        if (this.batch) {
    panel = new JPanel(new GridLayout(1, 3));
    panel.add(new JLabel(labels.getString("edm.panel.license.inheritLicense") + ":" + "*"));
    useExistingRightsInfoCheckbox = new JCheckBox(labels.getString("ese.takeFromFileLicense"));
    useExistingRightsInfoCheckbox.setSelected(true);
    useExistingRightsInfoCheckbox.addItemListener(new ItemListener() {
        @Override
        public void itemStateChanged(ItemEvent e) {
            //empty method on purpose
        }
    });
    panel.add(useExistingRightsInfoCheckbox);
    panel.add(new JLabel());
    panel.setBorder(BLACK_LINE);
    panel.setVisible(true);
    formPanel.add(panel);
    //        } else {
    //            panel = new JPanel(new GridLayout(3, 3));
    //            inheritLicenseGroup = new ButtonGroup();
    //
    //            panel.add(new Label(labels.getString("edm.panel.license.inheritLicense") + ":" + "*"));
    //            inhLicYesRadioButton = new JRadioButton(labels.getString("ese.yes"));
    //            inhLicYesRadioButton.setActionCommand(YES);
    ////        inhLicYesRadioButton.addActionListener(new ChangePanelActionListener(languageBoxPanel));
    //            inheritLicenseGroup.add(inhLicYesRadioButton);
    //            panel.add(inhLicYesRadioButton);
    //            panel.add(new JLabel());
    //
    //            panel.add(new JLabel());
    //            inhLicNoRadioButton = new JRadioButton(labels.getString("ese.no"), true);
    //            inhLicNoRadioButton.setActionCommand(NO);
    ////        inhLicNoRadioButton.addActionListener(new ChangePanelActionListener(languageBoxPanel));
    //            inheritLicenseGroup.add(inhLicNoRadioButton);
    //            panel.add(inhLicNoRadioButton);
    //            useExistingRightsInfoCheckbox = new JCheckBox(labels.getString("ese.takeFromFileLicense"));
    //            useExistingRightsInfoCheckbox.setSelected(true);
    //            useExistingRightsInfoCheckbox.addItemListener(new ItemListener() {
    //                @Override
    //                public void itemStateChanged(ItemEvent e) {
    //                    //empty method on purpose
    //                }
    //            });
    //
    //            panel.add(useExistingRightsInfoCheckbox);
    //
    //            panel.add(new JLabel());
    //            inhLicProvideRadioButton = new JRadioButton(labels.getString("ese.provide"));
    //            inhLicProvideRadioButton.setActionCommand(PROVIDE);
    ////        inhLicProvideRadioButton.addActionListener(new ChangePanelActionListener(languageBoxPanel));
    //            inheritLicenseGroup.add(inhLicProvideRadioButton);
    //            panel.add(inhLicProvideRadioButton);
    //            panel.add(new JLabel());
    //
    //            panel.setBorder(BLACK_LINE);
    //            panel.setVisible(true);
    //            formPanel.add(panel);
    //        }

    JPanel mainLicensePanel = new JPanel(new BorderLayout());
    panel = new JPanel(new GridLayout(5, 2));
    licenseGroup = new ButtonGroup();
    //        String currentRightsInformation;
    //        if (batch) {
    //            currentRightsInformation = "";
    //        } else {
    //            currentRightsInformation = ead2EdmInformation.getArchdescLicenceType();
    //        }

    panel.add(new Label(labels.getString("ese.specifyLicense") + ":" + "*"));
    radioButton = new JRadioButton(this.labels.getString("edm.panel.label.cc"));
    //        if (currentRightsInformation.equals(EdmOptionsPanel.CREATIVE_COMMONS)) {
    //            radioButton.setSelected(true);
    //        }
    radioButton.setActionCommand(CREATIVE_COMMONS);
    radioButton.addActionListener(new ChangePanelActionListener(extraLicenseCardLayoutPanel));
    licenseGroup.add(radioButton);
    panel.add(radioButton);

    panel.add(new JLabel(""));
    radioButton = new JRadioButton(this.labels.getString("edm.panel.label.cc.zero"));
    //        if (currentRightsInformation.equals(EdmOptionsPanel.CREATIVE_COMMONS_CC0)) {
    //            radioButton.setSelected(true);
    //        }
    radioButton.setActionCommand(CREATIVE_COMMONS_CC0);
    radioButton.addActionListener(new ChangePanelActionListener(extraLicenseCardLayoutPanel));
    licenseGroup.add(radioButton);
    panel.add(radioButton);

    panel.add(new JLabel(""));
    radioButton = new JRadioButton(this.labels.getString("edm.panel.label.cc.public"));
    //        if (currentRightsInformation.equals(EdmOptionsPanel.CREATIVE_COMMONS_PUBLIC_DOMAIN_MARK)) {
    //            radioButton.setSelected(true);
    //        }
    radioButton.setActionCommand(CREATIVE_COMMONS_PUBLIC_DOMAIN_MARK);
    radioButton.addActionListener(new ChangePanelActionListener(extraLicenseCardLayoutPanel));
    licenseGroup.add(radioButton);
    panel.add(radioButton);

    panel.add(new JLabel(""));
    radioButton = new JRadioButton(this.labels.getString("edm.panel.label.europeana.rights"));
    //        if (currentRightsInformation.equals(EdmOptionsPanel.EUROPEANA_RIGHTS_STATEMENTS)) {
    //            radioButton.setSelected(true);
    //        }
    radioButton.setActionCommand(EUROPEANA_RIGHTS_STATEMENTS);
    radioButton.addActionListener(new ChangePanelActionListener(extraLicenseCardLayoutPanel));
    licenseGroup.add(radioButton);
    panel.add(radioButton);

    panel.add(new JLabel(""));
    radioButton = new JRadioButton(this.labels.getString("edm.panel.label.out.copyright"));
    //        if (currentRightsInformation.equals(EdmOptionsPanel.OUT_OF_COPYRIGHT)) {
    //            radioButton.setSelected(true);
    //        }
    radioButton.setActionCommand(EdmOptionsPanel.OUT_OF_COPYRIGHT);
    radioButton.addActionListener(new ChangePanelActionListener(extraLicenseCardLayoutPanel));
    licenseGroup.add(radioButton);
    panel.add(radioButton);
    mainLicensePanel.add(panel, BorderLayout.WEST);

    mainLicensePanel.add(extraLicenseCardLayoutPanel, BorderLayout.EAST);
    //        if (currentRightsInformation.equals(EdmOptionsPanel.EUROPEANA_RIGHTS_STATEMENTS) || currentRightsInformation.equals(EdmOptionsPanel.CREATIVE_COMMONS)) {
    //            cardLayout.show(extraLicenseCardLayoutPanel, currentRightsInformation);
    //            if (currentRightsInformation.equals(EdmOptionsPanel.EUROPEANA_RIGHTS_STATEMENTS)) {
    //                if (ead2EdmInformation.getArchdescLicenceLink().endsWith("rr-f/")) {
    //                    europeanaRightsComboBox.setSelectedIndex(0);
    //                } else if (ead2EdmInformation.getArchdescLicenceLink().endsWith("orphan-work-eu/")) {
    //                    europeanaRightsComboBox.setSelectedIndex(1);
    //                } else if (ead2EdmInformation.getArchdescLicenceLink().endsWith("rr-p/")) {
    //                    europeanaRightsComboBox.setSelectedIndex(2);
    //                } else {
    //                    europeanaRightsComboBox.setSelectedIndex(3);
    //                }
    //            } else if (currentRightsInformation.equals(EdmOptionsPanel.CREATIVE_COMMONS)) {
    //                // get respective items from EAD2EDMInfo and set panel items appropriately
    //            }
    //        }
    mainLicensePanel.setBorder(BLACK_LINE);
    formPanel.add(mainLicensePanel);

    panel = new JPanel(new GridLayout(1, 1));
    panel.add(new Label(labels.getString("ese.specifyAdditionalRightsInfo") + ":"));
    additionalRightsTextArea = new JTextArea();
    additionalRightsTextArea.setLineWrap(true);
    additionalRightsTextArea.setWrapStyleWord(true);
    JScrollPane artaScrollPane = new JScrollPane(additionalRightsTextArea);
    artaScrollPane.setVerticalScrollBarPolicy(JScrollPane.VERTICAL_SCROLLBAR_AS_NEEDED);
    panel.add(artaScrollPane);
    panel.setBorder(GREY_LINE);
    formPanel.add(panel);

    inheritParentPanel = new JPanel(new GridLayout(2, 3));
    inheritParentCheckbox = new JCheckBox(labels.getString("ese.inheritParent") + ":" + "*");
    inheritParentCheckbox.setSelected(true);
    inheritParentCheckbox.addItemListener(new ItemListener() {
        @Override
        public void itemStateChanged(ItemEvent e) {
            if (e.getStateChange() == ItemEvent.SELECTED) {
                inhParYesRadioButton.setEnabled(true);
                inhParNoRadioButton.setEnabled(true);
            }
            if (e.getStateChange() == ItemEvent.DESELECTED) {
                inhParYesRadioButton.setEnabled(false);
                inhParNoRadioButton.setEnabled(false);
            }
        }
    });
    inheritParentPanel.add(inheritParentCheckbox);
    inheritParentGroup = new ButtonGroup();
    inhParYesRadioButton = new JRadioButton(labels.getString("ese.yes"));
    inhParYesRadioButton.setActionCommand(YES);
    inheritParentGroup.add(inhParYesRadioButton);
    inheritParentPanel.add(inhParYesRadioButton);
    inheritParentPanel.add(new JLabel(""));
    inhParNoRadioButton = new JRadioButton(labels.getString("ese.no"), true);
    inhParNoRadioButton.setActionCommand(NO);
    inheritParentGroup.add(inhParNoRadioButton);
    inheritParentPanel.add(inhParNoRadioButton);
    inheritParentPanel.setBorder(GREY_LINE);
    inheritParentPanel.setVisible(false);
    formPanel.add(inheritParentPanel);

    inheritOriginationPanel = new JPanel(new GridLayout(2, 3));
    inheritOriginationCheckbox = new JCheckBox(labels.getString("ese.inheritOrigination") + ":" + "*");
    inheritOriginationCheckbox.setSelected(true);
    inheritOriginationCheckbox.addItemListener(new ItemListener() {
        @Override
        public void itemStateChanged(ItemEvent e) {
            if (e.getStateChange() == ItemEvent.SELECTED) {
                inhOriYesRadioButton.setEnabled(true);
                inhOriNoRadioButton.setEnabled(true);
            }
            if (e.getStateChange() == ItemEvent.DESELECTED) {
                inhOriYesRadioButton.setEnabled(false);
                inhOriNoRadioButton.setEnabled(false);
            }
        }
    });
    inheritOriginationPanel.add(inheritOriginationCheckbox);
    inheritOriginationGroup = new ButtonGroup();
    inhOriYesRadioButton = new JRadioButton(labels.getString("ese.yes"));
    inhOriYesRadioButton.setActionCommand(YES);
    inheritOriginationGroup.add(inhOriYesRadioButton);
    inheritOriginationPanel.add(inhOriYesRadioButton);
    inheritOriginationPanel.add(new JLabel(""));
    inhOriNoRadioButton = new JRadioButton(labels.getString("ese.no"), true);
    inhOriNoRadioButton.setActionCommand(NO);
    inheritOriginationGroup.add(inhOriNoRadioButton);
    inheritOriginationPanel.add(inhOriNoRadioButton);
    inheritOriginationPanel.setBorder(BLACK_LINE);
    inheritOriginationPanel.setVisible(false);
    formPanel.add(inheritOriginationPanel);

    inheritUnittitlePanel = new JPanel(new GridLayout(2, 3));
    inheritUnittitleCheckbox = new JCheckBox(labels.getString("ese.inheritUnittitle") + ":" + "*");
    inheritUnittitleCheckbox.setSelected(true);
    inheritUnittitleCheckbox.addItemListener(new ItemListener() {
        @Override
        public void itemStateChanged(ItemEvent e) {
            if (e.getStateChange() == ItemEvent.SELECTED) {
                inhTitleYesRadioButton.setEnabled(true);
                inhTitleNoRadioButton.setEnabled(true);
            }
            if (e.getStateChange() == ItemEvent.DESELECTED) {
                inhTitleYesRadioButton.setEnabled(false);
                inhTitleNoRadioButton.setEnabled(false);
            }
        }
    });
    inheritUnittitlePanel.add(inheritUnittitleCheckbox);
    inheritUnittitleGroup = new ButtonGroup();
    inhTitleYesRadioButton = new JRadioButton(labels.getString("ese.yes"));
    inhTitleYesRadioButton.setActionCommand(YES);
    inheritUnittitleGroup.add(inhTitleYesRadioButton);
    inheritUnittitlePanel.add(inhTitleYesRadioButton);
    inheritUnittitlePanel.add(new JLabel(""));
    inhTitleNoRadioButton = new JRadioButton(labels.getString("ese.no"), true);
    inhTitleNoRadioButton.setActionCommand(NO);
    inheritUnittitleGroup.add(inhTitleNoRadioButton);
    inheritUnittitlePanel.add(inhTitleNoRadioButton);
    inheritUnittitlePanel.setBorder(BLACK_LINE);
    inheritUnittitlePanel.setVisible(false);
    formPanel.add(inheritUnittitlePanel);

    JButton createEdmBtn = new JButton(labels.getString("ese.createEseBtn"));
    JButton cancelBtn = new JButton(labels.getString("ese.cancelBtn"));

    createEdmBtn.addActionListener(new CreateEdmActionListener());
    cancelBtn.addActionListener(new ActionListener() {
        @Override
        public void actionPerformed(ActionEvent e) {
            for (Map.Entry<String, FileInstance> entry : fileInstances.entrySet()) {
                FileInstance fileInstance = entry.getValue();
                fileInstance.setEdm(false);
            }
            dataPreparationToolGUI.enableEdmConversionBtn();
            if (batch) {
                dataPreparationToolGUI.enableAllBatchBtns();
            }
            dataPreparationToolGUI.enableRadioButtons();
            close();
        }
    });

    JPanel buttonPanel = new JPanel(new GridLayout(1, 5));

    buttonPanel.add(new JLabel(""));
    buttonPanel.add(cancelBtn);
    buttonPanel.add(new JLabel(""));
    buttonPanel.add(createEdmBtn);
    buttonPanel.add(new JLabel(""));

    add(formPanel, BorderLayout.CENTER);
    add(buttonPanel, BorderLayout.SOUTH);
}

From source file:it.imtech.metadata.MetaUtility.java

/**
 * Metodo adibito alla creazione dinamica ricorsiva dell'interfaccia dei
 * metadati//w w  w  .  ja v a  2s . c o m
 *
 * @param submetadatas Map contente i metadati e i sottolivelli di metadati
 * @param vocabularies Map contenente i dati contenuti nel file xml
 * vocabulary.xml
 * @param parent Jpanel nel quale devono venir inseriti i metadati
 * @param level Livello corrente
 */
public void create_metadata_view(Map<Object, Metadata> submetadatas, JPanel parent, int level,
        final String panelname) throws Exception {
    ResourceBundle bundle = ResourceBundle.getBundle(Globals.RESOURCES, Globals.CURRENT_LOCALE, Globals.loader);
    int lenght = submetadatas.size();
    int labelwidth = 220;
    int i = 0;
    JButton addcontribute = null;

    for (Map.Entry<Object, Metadata> kv : submetadatas.entrySet()) {
        ArrayList<Component> tabobjects = new ArrayList<Component>();

        if (kv.getValue().MID == 17 || kv.getValue().MID == 23 || kv.getValue().MID == 18
                || kv.getValue().MID == 137) {
            continue;
        }

        //Crea un jpanel nuovo e fa appen su parent
        JPanel innerPanel = new JPanel(new MigLayout("fillx, insets 1 1 1 1"));
        innerPanel.setName("pannello" + level + i);

        i++;
        String datatype = kv.getValue().datatype.toString();

        if (kv.getValue().MID == 45) {
            JPanel choice = new JPanel(new MigLayout());

            JComboBox combo = addClassificationChoice(choice, kv.getValue().sequence, panelname);

            JLabel labelc = new JLabel();
            labelc.setText(Utility.getBundleString("selectclassif", bundle));
            labelc.setPreferredSize(new Dimension(100, 20));

            choice.add(labelc);

            findLastClassification(panelname);
            if (last_classification != 0 && classificationRemoveButton == null) {
                logger.info("Removing last clasification");
                classificationRemoveButton = new JButton("-");

                classificationRemoveButton.addActionListener(new ActionListener() {
                    @Override
                    public void actionPerformed(ActionEvent event) {
                        BookImporter.getInstance().setCursor(Cursor.getPredefinedCursor(Cursor.WAIT_CURSOR));
                        removeClassificationToMetadata(panelname);
                        BookImporter.getInstance().refreshMetadataTab(false, panelname);
                        findLastClassification(panelname); //update last_classification
                        BookImporter.getInstance().setCursor(null);
                    }
                });
                if (Integer.parseInt(kv.getValue().sequence) == last_classification) {
                    choice.add(classificationRemoveButton, "wrap, width :50:");
                }
            }

            if (classificationAddButton == null) {
                logger.info("Adding a new classification");
                choice.add(combo, "width 100:600:600");

                classificationAddButton = new JButton("+");

                classificationAddButton.addActionListener(new ActionListener() {
                    @Override
                    public void actionPerformed(ActionEvent event) {
                        BookImporter.getInstance().setCursor(Cursor.getPredefinedCursor(Cursor.WAIT_CURSOR));
                        addClassificationToMetadata(panelname);
                        BookImporter.getInstance().refreshMetadataTab(false, panelname);
                        BookImporter.getInstance().setCursor(null);
                    }
                });

                choice.add(classificationAddButton, "width :50:");
            } else {
                //choice.add(combo, "wrap,width 100:700:700");
                choice.add(combo, "width 100:700:700");
                if (Integer.parseInt(kv.getValue().sequence) == last_classification) {
                    choice.add(classificationRemoveButton, "wrap, width :50");
                }
            }
            parent.add(choice, "wrap,width 100:700:700");
            classificationMID = kv.getValue().MID;

            innerPanel.setName(panelname + "---ImPannelloClassif---" + kv.getValue().sequence);
            try {

                addClassification(innerPanel, classificationMID, kv.getValue().sequence, panelname);
            } catch (Exception ex) {
                logger.error("Errore nell'aggiunta delle classificazioni");
            }
            parent.add(innerPanel, "wrap, growx");
            BookImporter.policy.addIndexedComponent(combo);

            continue;
        }

        if (datatype.equals("Node")) {
            JLabel label = new JLabel();
            label.setText(kv.getValue().description);
            label.setPreferredSize(new Dimension(100, 20));

            int size = 16 - (level * 2);
            Font myFont = new Font("MS Sans Serif", Font.PLAIN, size);
            label.setFont(myFont);

            if (Integer.toString(kv.getValue().MID).equals("11")) {
                JPanel temppanel = new JPanel(new MigLayout());

                //update last_contribute
                findLastContribute(panelname);

                if (last_contribute != 0 && removeContribute == null) {
                    logger.info("Removing last contribute");
                    removeContribute = new JButton("-");

                    removeContribute.addActionListener(new ActionListener() {
                        @Override
                        public void actionPerformed(ActionEvent event) {
                            BookImporter.getInstance()
                                    .setCursor(Cursor.getPredefinedCursor(Cursor.WAIT_CURSOR));
                            removeContributorToMetadata(panelname);
                            BookImporter.getInstance().refreshMetadataTab(false, panelname);
                            BookImporter.getInstance().setCursor(null);
                        }
                    });

                    if (!kv.getValue().sequence.equals("")) {
                        if (Integer.parseInt(kv.getValue().sequence) == last_contribute) {
                            innerPanel.add(removeContribute, "width :50:");
                        }
                    }
                }

                if (addcontribute == null) {
                    logger.info("Adding a new contribute");
                    addcontribute = new JButton("+");

                    addcontribute.addActionListener(new ActionListener() {
                        @Override
                        public void actionPerformed(ActionEvent event) {
                            BookImporter.getInstance()
                                    .setCursor(Cursor.getPredefinedCursor(Cursor.WAIT_CURSOR));
                            addContributorToMetadata(panelname);
                            BookImporter.getInstance().refreshMetadataTab(false, panelname);
                            BookImporter.getInstance().setCursor(null);
                        }
                    });

                    temppanel.add(label, " width :200:");
                    temppanel.add(addcontribute, "width :50:");
                    innerPanel.add(temppanel, "wrap, growx");
                } else {
                    temppanel.add(label, " width :200:");
                    findLastContribute(panelname);
                    if (!kv.getValue().sequence.equals("")) {
                        if (Integer.parseInt(kv.getValue().sequence) == last_contribute) {
                            temppanel.add(removeContribute, "width :50:");
                        }
                    }
                    innerPanel.add(temppanel, "wrap, growx");
                }
            } else if (Integer.toString(kv.getValue().MID).equals("115")) {
                logger.info("Devo gestire una provenience!");
            }
        } else {
            String title = "";

            if (kv.getValue().mandatory.equals("Y") || kv.getValue().MID == 14 || kv.getValue().MID == 15) {
                title = kv.getValue().description + " *";
            } else {
                title = kv.getValue().description;
            }

            innerPanel.setBorder(BorderFactory.createTitledBorder(BorderFactory.createEtchedBorder(), title,
                    TitledBorder.LEFT, TitledBorder.TOP));

            if (datatype.equals("Vocabulary")) {
                TreeMap<String, String> entryCombo = new TreeMap<String, String>();
                int index = 0;
                String selected = null;

                if (!Integer.toString(kv.getValue().MID).equals("8"))
                    entryCombo.put(Utility.getBundleString("comboselect", bundle),
                            Utility.getBundleString("comboselect", bundle));

                for (Map.Entry<String, TreeMap<String, VocEntry>> vc : vocabularies.entrySet()) {
                    String tempmid = Integer.toString(kv.getValue().MID);

                    if (Integer.toString(kv.getValue().MID_parent).equals("11")
                            || Integer.toString(kv.getValue().MID_parent).equals("13")) {
                        String[] testmid = tempmid.split("---");
                        tempmid = testmid[0];
                    }

                    if (vc.getKey().equals(tempmid)) {
                        TreeMap<String, VocEntry> iEntry = vc.getValue();

                        for (Map.Entry<String, VocEntry> ivc : iEntry.entrySet()) {
                            entryCombo.put(ivc.getValue().description, ivc.getValue().ID);
                            if (kv.getValue().value != null) {
                                if (kv.getValue().value.equals(ivc.getValue().ID)) {
                                    selected = ivc.getValue().ID;
                                }
                            }
                            index++;
                        }
                    }
                }

                final ComboMapImpl model = new ComboMapImpl();
                model.setVocabularyCombo(true);
                model.putAll(entryCombo);

                final JComboBox voc = new javax.swing.JComboBox(model);
                model.specialRenderCombo(voc);

                if (Integer.toString(kv.getValue().MID_parent).equals("11")
                        || Integer.toString(kv.getValue().MID_parent).equals("13")) {
                    voc.setName("MID_" + Integer.toString(kv.getValue().MID) + "---" + kv.getValue().sequence);
                } else {
                    voc.setName("MID_" + Integer.toString(kv.getValue().MID));
                }

                if (Integer.toString(kv.getValue().MID).equals("8") && selected == null)
                    selected = "44";

                selected = (selected == null) ? Utility.getBundleString("comboselect", bundle) : selected;

                for (int k = 0; k < voc.getItemCount(); k++) {
                    Map.Entry<String, String> el = (Map.Entry<String, String>) voc.getItemAt(k);
                    if (el.getValue().equals(selected))
                        voc.setSelectedIndex(k);
                }

                voc.setPreferredSize(new Dimension(150, 30));
                innerPanel.add(voc, "wrap, width :400:");
                tabobjects.add(voc);
            } else if (datatype.equals("CharacterString") || datatype.equals("GPS")) {
                final JTextArea textField = new javax.swing.JTextArea();

                if (Integer.toString(kv.getValue().MID_parent).equals("11")
                        || Integer.toString(kv.getValue().MID_parent).equals("13")) {
                    textField.setName(
                            "MID_" + Integer.toString(kv.getValue().MID) + "---" + kv.getValue().sequence);
                } else {
                    textField.setName("MID_" + Integer.toString(kv.getValue().MID));
                }

                textField.setPreferredSize(new Dimension(230, 0));
                textField.setText(kv.getValue().value);
                textField.setLineWrap(true);
                textField.setWrapStyleWord(true);

                innerPanel.add(textField, "wrap, width :300:");

                textField.addKeyListener(new KeyAdapter() {
                    @Override
                    public void keyPressed(KeyEvent e) {
                        if (e.getKeyCode() == KeyEvent.VK_TAB) {
                            if (e.getModifiers() > 0) {
                                textField.transferFocusBackward();
                            } else {
                                textField.transferFocus();
                            }
                            e.consume();
                        }
                    }
                });

                tabobjects.add(textField);
            } else if (datatype.equals("LangString")) {
                JScrollPane inner_scroll = new javax.swing.JScrollPane();
                inner_scroll.setHorizontalScrollBarPolicy(
                        javax.swing.ScrollPaneConstants.HORIZONTAL_SCROLLBAR_NEVER);
                inner_scroll.setVerticalScrollBarPolicy(
                        javax.swing.ScrollPaneConstants.VERTICAL_SCROLLBAR_AS_NEEDED);
                inner_scroll.setPreferredSize(new Dimension(240, 80));
                inner_scroll.setName("langStringScroll");
                final JTextArea jTextArea1 = new javax.swing.JTextArea();
                jTextArea1.setName("MID_" + Integer.toString(kv.getValue().MID));
                jTextArea1.setText(kv.getValue().value);

                jTextArea1.setSize(new Dimension(350, 70));
                jTextArea1.setLineWrap(true);
                jTextArea1.setWrapStyleWord(true);

                inner_scroll.setViewportView(jTextArea1);
                innerPanel.add(inner_scroll, "width :300:");

                //Add combo language box
                JComboBox voc = getComboLangBox(kv.getValue().language);
                voc.setName("MID_" + Integer.toString(kv.getValue().MID) + "_lang");

                voc.setPreferredSize(new Dimension(200, 20));
                innerPanel.add(voc, "wrap, width :300:");

                jTextArea1.addKeyListener(new KeyAdapter() {
                    @Override
                    public void keyPressed(KeyEvent e) {
                        if (e.getKeyCode() == KeyEvent.VK_TAB) {
                            if (e.getModifiers() > 0) {
                                jTextArea1.transferFocusBackward();
                            } else {
                                jTextArea1.transferFocus();
                            }
                            e.consume();
                        }
                    }
                });
                tabobjects.add(jTextArea1);
                tabobjects.add(voc);
            } else if (datatype.equals("Language")) {
                final JComboBox voc = getComboLangBox(kv.getValue().value);
                voc.setName("MID_" + Integer.toString(kv.getValue().MID));

                voc.setPreferredSize(new Dimension(150, 20));
                voc.setBounds(5, 5, 150, 20);
                innerPanel.add(voc, "wrap, width :500:");

                //BookImporter.policy.addIndexedComponent(voc);
                tabobjects.add(voc);

            } else if (datatype.equals("Boolean")) {
                int selected = 0;
                TreeMap bin = new TreeMap<String, String>();
                bin.put("yes", Utility.getBundleString("voc1", bundle));
                bin.put("no", Utility.getBundleString("voc2", bundle));

                if (kv.getValue().value == null) {
                    switch (kv.getValue().MID) {
                    case 35:
                        selected = 0;
                        break;
                    case 36:
                        selected = 1;
                        break;
                    }
                } else if (kv.getValue().value.equals("yes")) {
                    selected = 1;
                } else {
                    selected = 0;
                }

                final ComboMapImpl model = new ComboMapImpl();
                model.putAll(bin);

                final JComboBox voc = new javax.swing.JComboBox(model);
                model.specialRenderCombo(voc);

                voc.setName("MID_" + Integer.toString(kv.getValue().MID));
                voc.setSelectedIndex(selected);

                voc.setPreferredSize(new Dimension(150, 20));
                voc.setBounds(5, 5, 150, 20);
                innerPanel.add(voc, "wrap, width :300:");
                //BookImporter.policy.addIndexedComponent(voc);
                tabobjects.add(voc);
            } else if (datatype.equals("License")) {
                String selectedIndex = null;
                int vindex = 0;
                int defaultIndex = 0;

                TreeMap<String, String> entryCombo = new TreeMap<String, String>();

                for (Map.Entry<String, TreeMap<String, VocEntry>> vc : vocabularies.entrySet()) {
                    if (vc.getKey().equals(Integer.toString(kv.getValue().MID))) {
                        TreeMap<String, VocEntry> iEntry = vc.getValue();

                        for (Map.Entry<String, VocEntry> ivc : iEntry.entrySet()) {
                            entryCombo.put(ivc.getValue().description, ivc.getValue().ID);

                            if (ivc.getValue().ID.equals("1"))
                                defaultIndex = vindex;

                            if (kv.getValue().value != null) {
                                if (ivc.getValue().ID.equals(kv.getValue().value)) {
                                    selectedIndex = Integer.toString(vindex);
                                }
                            }
                            vindex++;
                        }
                    }
                }

                if (selectedIndex == null)
                    selectedIndex = Integer.toString(defaultIndex);

                ComboMapImpl model = new ComboMapImpl();
                model.putAll(entryCombo);
                model.setVocabularyCombo(true);

                JComboBox voc = new javax.swing.JComboBox(model);
                model.specialRenderCombo(voc);

                voc.setName("MID_" + Integer.toString(kv.getValue().MID));
                voc.setSelectedIndex(Integer.parseInt(selectedIndex));
                voc.setPreferredSize(new Dimension(150, 20));

                voc.setBounds(5, 5, 150, 20);
                innerPanel.add(voc, "wrap, width :500:");
                //BookImporter.policy.addIndexedComponent(voc);
                tabobjects.add(voc);
            } else if (datatype.equals("DateTime")) {
                //final JXDatePicker datePicker = new JXDatePicker();
                JDateChooser datePicker = new JDateChooser();
                datePicker.setName("MID_" + Integer.toString(kv.getValue().MID));

                JPanel test = new JPanel(new MigLayout());
                JLabel lbefore = new JLabel(Utility.getBundleString("beforechristlabel", bundle));
                JCheckBox beforechrist = new JCheckBox();
                beforechrist.setName("MID_" + Integer.toString(kv.getValue().MID) + "_check");

                if (kv.getValue().value != null) {
                    try {
                        if (kv.getValue().value.charAt(0) == '-') {
                            beforechrist.setSelected(true);
                        }

                        Date date1 = new Date();
                        SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
                        if (kv.getValue().value.charAt(0) == '-') {
                            date1 = sdf.parse(adjustDate(kv.getValue().value));
                        } else {
                            date1 = sdf.parse(kv.getValue().value);
                        }
                        datePicker.setDate(date1);
                    } catch (Exception e) {
                        //Console.WriteLine("ERROR import date:" + ex.Message);
                    }
                }

                test.add(datePicker, "width :200:");
                test.add(lbefore, "gapleft 30");
                test.add(beforechrist, "wrap");

                innerPanel.add(test, "wrap");
            }
        }

        //Recursive call
        create_metadata_view(kv.getValue().submetadatas, innerPanel, level + 1, panelname);

        if (kv.getValue().editable.equals("Y")
                || (datatype.equals("Node") && kv.getValue().hidden.equals("0"))) {
            parent.add(innerPanel, "wrap, growx");

            for (Component tabobject : tabobjects) {
                BookImporter.policy.addIndexedComponent(tabobject);
            }
        }
    }
}

From source file:edu.ku.brc.af.ui.forms.ViewFactory.java

protected boolean createItem(final DBTableInfo parentTableInfo, final DBTableChildIFace childInfo,
        final MultiView parent, final ViewDefIFace viewDef, final FormValidator validator,
        final ViewBuilderIFace viewBldObj, final AltViewIFace.CreationMode mode,
        final HashMap<String, JLabel> labelsForHash, final Object currDataObj, final FormCellIFace cell,
        final boolean isEditOnCreateOnly, final int rowInx, final BuildInfoStruct bi) {
    bi.compToAdd = null;// w w w  . j a v a 2s. c  o  m
    bi.compToReg = null;
    bi.doAddToValidator = true;
    bi.doRegControl = true;

    DBRelationshipInfo relInfo = childInfo instanceof DBRelationshipInfo ? (DBRelationshipInfo) childInfo
            : null;

    if (isEditOnCreateOnly) {
        EditViewCompSwitcherPanel evcsp = new EditViewCompSwitcherPanel(cell);
        bi.compToAdd = evcsp;
        bi.compToReg = evcsp;

        if (validator != null) {
            //DataChangeNotifier dcn = validator.createDataChangeNotifer(cell.getIdent(), evcsp, null);
            DataChangeNotifier dcn = validator.hookupComponent(evcsp, cell.getIdent(), UIValidator.Type.Changed,
                    null, false);
            evcsp.setDataChangeNotifier(dcn);
        }

    } else if (cell.getType() == FormCellIFace.CellType.label) {
        FormCellLabel cellLabel = (FormCellLabel) cell;

        String lblStr = cellLabel.getLabel();
        if (cellLabel.isRecordObj()) {
            JComponent riComp = viewBldObj.createRecordIndentifier(lblStr, cellLabel.getIcon());
            bi.compToAdd = riComp;

        } else {
            String lStr = "  ";
            int align = SwingConstants.RIGHT;
            boolean useColon = StringUtils.isNotEmpty(cellLabel.getLabelFor());

            if (lblStr.equals("##")) {
                //lStr = "  ";
                bi.isDerivedLabel = true;
                cellLabel.setDerived(true);

            } else {
                String alignProp = cellLabel.getProperty("align");
                if (StringUtils.isNotEmpty(alignProp)) {
                    if (alignProp.equals("left")) {
                        align = SwingConstants.LEFT;

                    } else if (alignProp.equals("center")) {
                        align = SwingConstants.CENTER;

                    } else {
                        align = SwingConstants.RIGHT;
                    }
                } else if (useColon) {
                    align = SwingConstants.RIGHT;
                } else {
                    align = SwingConstants.LEFT;
                }

                if (isNotEmpty(lblStr)) {
                    if (useColon) {
                        lStr = lblStr + ":";
                    } else {
                        lStr = lblStr;
                    }
                } else {
                    lStr = "  ";
                }
            }

            if (lStr.indexOf(LF) > -1) {
                lStr = "<html>" + StringUtils.replace(lStr, LF, "<br>") + "</html>";
            }
            JLabel lbl = createLabel(lStr, align);
            String colorStr = cellLabel.getProperty("fg");
            if (StringUtils.isNotEmpty(colorStr)) {
                lbl.setForeground(UIHelper.parseRGB(colorStr));
            }
            labelsForHash.put(cellLabel.getLabelFor(), lbl);
            bi.compToAdd = lbl;
            viewBldObj.addLabel(cellLabel, lbl);
        }

        bi.doAddToValidator = false;
        bi.doRegControl = false;

    } else if (cell.getType() == FormCellIFace.CellType.field) {
        FormCellField cellField = (FormCellField) cell;

        bi.isRequired = bi.isRequired || cellField.isRequired()
                || (childInfo != null && childInfo.isRequired());

        DBFieldInfo fieldInfo = childInfo instanceof DBFieldInfo ? (DBFieldInfo) childInfo : null;
        if (fieldInfo != null && fieldInfo.isHidden()) {
            FormDevHelper.appendLocalizedFormDevError("ViewFactory.FORM_FIELD_HIDDEN", cellField.getIdent(),
                    cellField.getName(), viewDef.getName());
        } else {

            if (fieldInfo != null && fieldInfo.isHidden()) {
                FormDevHelper.appendLocalizedFormDevError("ViewFactory.FORM_REL_HIDDEN", cellField.getIdent(),
                        cellField.getName(), viewDef.getName());
            }
        }

        FormCellField.FieldType uiType = cellField.getUiType();

        // Check to see if there is a PickList and get it if there is
        PickListDBAdapterIFace adapter = null;

        String pickListName = cellField.getPickListName();
        if (childInfo != null && StringUtils.isEmpty(pickListName) && fieldInfo != null) {
            pickListName = fieldInfo.getPickListName();
        }

        if (isNotEmpty(pickListName)) {
            adapter = PickListDBAdapterFactory.getInstance().create(pickListName, false);

            if (adapter == null || adapter.getPickList() == null) {
                FormDevHelper.appendFormDevError("PickList Adapter [" + pickListName + "] cannot be null!");
                return false;
            }
        }

        /*if (uiType == FormCellFieldIFace.FieldType.text)
        {
        String weblink = cellField.getProperty("weblink");
        if (StringUtils.isNotEmpty(weblink))
        {
            String name = cellField.getProperty("name");
            if (StringUtils.isNotEmpty(name) && name.equals("WebLink"))
            {
                uiType
            }
        }
        }*/

        // The Default Display for combox is dsptextfield, except when there is a TableBased PickList
        // At the time we set the display we don't want to go get the picklist to find out. So we do it
        // here after we have the picklist and actually set the change into the cellField
        // because it uses the value to determine whether to convert the value into a text string 
        // before setting it.
        if (mode == AltViewIFace.CreationMode.VIEW) {
            if (uiType == FormCellFieldIFace.FieldType.combobox
                    && cellField.getDspUIType() != FormCellFieldIFace.FieldType.textpl) {
                if (adapter != null)// && adapter.isTabledBased())
                {
                    uiType = FormCellFieldIFace.FieldType.textpl;
                    cellField.setDspUIType(uiType);

                } else {
                    uiType = cellField.getDspUIType();
                }
            } else {
                uiType = cellField.getDspUIType();
            }
        } else if (uiType == FormCellField.FieldType.querycbx) {
            if (AppContextMgr.isSecurityOn()) {
                DBTableInfo tblInfo = childInfo != null
                        ? DBTableIdMgr.getInstance()
                                .getByShortClassName(childInfo.getDataClass().getSimpleName())
                        : null;
                if (tblInfo != null) {
                    PermissionSettings perm = tblInfo.getPermissions();
                    if (perm != null) {
                        //PermissionSettings.dumpPermissions("QCBX: "+tblInfo.getShortClassName(), perm.getOptions());
                        if (perm.isViewOnly() || !perm.canView()) {
                            uiType = FormCellField.FieldType.textfieldinfo;
                        }
                    }
                }
            }
        }

        Class<?> fieldClass = childInfo != null ? childInfo.getDataClass() : null;
        String uiFormatName = cellField.getUIFieldFormatterName();

        if (mode == AltViewIFace.CreationMode.EDIT && uiType == FormCellField.FieldType.text
                && fieldClass != null) {
            if (fieldClass == String.class && fieldInfo != null) {
                // check whether there's a formatter defined for this field in the schema
                if (fieldInfo.getFormatter() != null) {
                    uiFormatName = fieldInfo.getFormatter().getName();
                    uiType = FormCellField.FieldType.formattedtext;
                }
            } else if (fieldClass == Integer.class || fieldClass == Long.class || fieldClass == Short.class
                    || fieldClass == Byte.class || fieldClass == Double.class || fieldClass == Float.class
                    || fieldClass == BigDecimal.class) {
                //log.debug(cellField.getName()+"  is being changed to NUMERIC");
                uiType = FormCellField.FieldType.formattedtext;
                uiFormatName = "Numeric" + fieldClass.getSimpleName();
            }
        }

        // Create the UI Component

        boolean isReq = cellField.isRequired() || (fieldInfo != null && fieldInfo.isRequired())
                || (relInfo != null && relInfo.isRequired());
        cellField.setRequired(isReq);

        switch (uiType) {
        case text:

            bi.compToAdd = createTextField(validator, cellField, fieldInfo, isReq, adapter);
            bi.doAddToValidator = validator == null; // might already added to validator
            break;

        case formattedtext: {
            Class<?> tableClass = null;
            try {
                tableClass = Class.forName(viewDef.getClassName());
            } catch (Exception ex) {
            }

            JComponent tfStart = createFormattedTextField(validator, cellField, tableClass,
                    fieldInfo != null ? fieldInfo.getLength() : 0, uiFormatName,
                    mode == AltViewIFace.CreationMode.VIEW, isReq,
                    cellField.getPropertyAsBoolean("alledit", false));
            bi.compToAdd = tfStart;
            if (cellField.getPropertyAsBoolean("series", false)) {
                JComponent tfEnd = createFormattedTextField(validator, cellField, tableClass,
                        fieldInfo != null ? fieldInfo.getLength() : 0, uiFormatName,
                        mode == AltViewIFace.CreationMode.VIEW, isReq,
                        cellField.getPropertyAsBoolean("alledit", false));

                // Make sure we register it like a plugin not a regular control
                SeriesProcCatNumPlugin plugin = new SeriesProcCatNumPlugin((ValFormattedTextFieldIFace) tfStart,
                        (ValFormattedTextFieldIFace) tfEnd);
                bi.compToAdd = plugin.getUIComponent();
                viewBldObj.registerPlugin(cell, plugin);
                bi.doRegControl = false;
            }
            bi.doAddToValidator = validator == null; // might already added to validator
            break;
        }
        case label:
            JLabel label = createLabel("", SwingConstants.LEFT);
            bi.compToAdd = label;
            break;

        case dsptextfield:
            if (StringUtils.isEmpty(cellField.getPickListName())) {
                JTextField text = UIHelper.createTextField(cellField.getTxtCols());
                changeTextFieldUIForDisplay(text, cellField.getPropertyAsBoolean("transparent", false));
                bi.compToAdd = text;
            } else {
                bi.compToAdd = createTextField(validator, cellField, fieldInfo, isReq, adapter);
                bi.doAddToValidator = validator == null; // might already added to validator
            }
            break;

        case textfieldinfo:
            bi.compToAdd = createTextFieldWithInfo(cellField, parent);
            break;

        case image:
            bi.compToAdd = createImageDisplay(cellField, mode, validator);
            bi.doAddToValidator = (validator != null);
            break;

        case url:
            BrowserLauncherBtn blb = new BrowserLauncherBtn(cellField.getProperty("title"));
            bi.compToAdd = blb;
            bi.doAddToValidator = false;

            break;

        case combobox:
            bi.compToAdd = createValComboBox(validator, cellField, adapter, isReq);
            bi.doAddToValidator = validator != null; // might already added to validator
            break;

        case checkbox: {
            String lblStr = cellField.getLabel();
            if (lblStr.equals("##")) {
                bi.isDerivedLabel = true;
                cellField.setDerived(true);
            }
            ValCheckBox checkbox = new ValCheckBox(lblStr, isReq,
                    cellField.isReadOnly() || mode == AltViewIFace.CreationMode.VIEW);
            if (validator != null) {
                DataChangeNotifier dcn = validator.createDataChangeNotifer(cellField.getIdent(), checkbox,
                        validator.createValidator(checkbox, UIValidator.Type.Changed));
                checkbox.addActionListener(dcn);
                checkbox.addItemListener(dcn);
            }
            bi.compToAdd = checkbox;
            break;
        }

        case tristate: {
            String lblStr = cellField.getLabel();
            if (lblStr.equals("##")) {
                bi.isDerivedLabel = true;
                cellField.setDerived(true);
            }
            ValTristateCheckBox tristateCB = new ValTristateCheckBox(lblStr, isReq,
                    cellField.isReadOnly() || mode == AltViewIFace.CreationMode.VIEW);
            if (validator != null) {
                DataChangeNotifier dcn = validator.createDataChangeNotifer(cellField.getIdent(), tristateCB,
                        null);
                tristateCB.addActionListener(dcn);
            }
            bi.compToAdd = tristateCB;
            break;
        }

        case spinner: {
            String minStr = cellField.getProperty("min");
            int min = StringUtils.isNotEmpty(minStr) ? Integer.parseInt(minStr) : 0;

            String maxStr = cellField.getProperty("max");
            int max = StringUtils.isNotEmpty(maxStr) ? Integer.parseInt(maxStr) : 0;

            ValSpinner spinner = new ValSpinner(min, max, isReq,
                    cellField.isReadOnly() || mode == AltViewIFace.CreationMode.VIEW);
            if (validator != null) {
                DataChangeNotifier dcn = validator.createDataChangeNotifer(cellField.getIdent(), spinner,
                        validator.createValidator(spinner, UIValidator.Type.Changed));
                spinner.addChangeListener(dcn);
            }
            bi.compToAdd = spinner;
            break;
        }

        case password:
            bi.compToAdd = createPasswordField(validator, cellField, isReq);
            bi.doAddToValidator = validator == null; // might already added to validator
            break;

        case dsptextarea:
            bi.compToAdd = createDisplayTextArea(cellField);
            break;

        case textarea: {
            JTextArea ta = createTextArea(validator, cellField, isReq, fieldInfo);
            JScrollPane scrollPane = new JScrollPane(ta);
            scrollPane.setHorizontalScrollBarPolicy(ScrollPaneConstants.HORIZONTAL_SCROLLBAR_AS_NEEDED);
            scrollPane.setVerticalScrollBarPolicy(
                    UIHelper.isMacOS() ? ScrollPaneConstants.VERTICAL_SCROLLBAR_ALWAYS
                            : ScrollPaneConstants.VERTICAL_SCROLLBAR_AS_NEEDED);
            ta.setLineWrap(true);
            ta.setWrapStyleWord(true);

            bi.doAddToValidator = validator == null; // might already added to validator
            bi.compToReg = ta;
            bi.compToAdd = scrollPane;
            break;
        }

        case textareabrief: {
            String title = "";
            DBTableInfo ti = DBTableIdMgr.getInstance().getByClassName(viewDef.getClassName());
            if (ti != null) {
                DBFieldInfo fi = ti.getFieldByName(cellField.getName());
                if (fi != null) {
                    title = fi.getTitle();
                }
            }

            ValTextAreaBrief txBrief = createTextAreaBrief(validator, cellField, isReq, fieldInfo);
            txBrief.setTitle(title);

            bi.doAddToValidator = validator == null; // might already added to validator
            bi.compToReg = txBrief;
            bi.compToAdd = txBrief.getUIComponent();
            break;
        }

        case browse: {
            JTextField textField = createTextField(validator, cellField, null, isReq, null);
            if (textField instanceof ValTextField) {
                ValBrowseBtnPanel bbp = new ValBrowseBtnPanel((ValTextField) textField,
                        cellField.getPropertyAsBoolean("dirsonly", false),
                        cellField.getPropertyAsBoolean("forinput", true));
                String fileFilter = cellField.getProperty("filefilter");
                String fileFilterDesc = cellField.getProperty("filefilterdesc");
                String defaultExtension = cellField.getProperty("defaultExtension");
                if (fileFilter != null && fileFilterDesc != null) {
                    bbp.setUseNativeFileDlg(false);
                    bbp.setFileFilter(new FileNameExtensionFilter(fileFilterDesc, fileFilter));
                    bbp.setDefaultExtension(defaultExtension);
                    //bbp.setNativeDlgFilter(new FileNameExtensionFilter(fileFilterDesc, fileFilter));
                }
                bi.compToAdd = bbp;

            } else {
                BrowseBtnPanel bbp = new BrowseBtnPanel(textField,
                        cellField.getPropertyAsBoolean("dirsonly", false),
                        cellField.getPropertyAsBoolean("forinput", true));
                bi.compToAdd = bbp;
            }
            break;
        }

        case querycbx: {
            ValComboBoxFromQuery cbx = createQueryComboBox(validator, cellField, isReq,
                    cellField.getPropertyAsBoolean("adjustquery", true));
            cbx.setMultiView(parent);
            cbx.setFrameTitle(cellField.getProperty("title"));

            bi.compToAdd = cbx;
            bi.doAddToValidator = validator == null; // might already added to validator
            break;
        }

        case list: {
            JList list = createList(validator, cellField, isReq);

            JScrollPane scrollPane = new JScrollPane(list);
            scrollPane.setHorizontalScrollBarPolicy(ScrollPaneConstants.HORIZONTAL_SCROLLBAR_AS_NEEDED);
            scrollPane.setVerticalScrollBarPolicy(
                    UIHelper.isMacOS() ? ScrollPaneConstants.VERTICAL_SCROLLBAR_ALWAYS
                            : ScrollPaneConstants.VERTICAL_SCROLLBAR_AS_NEEDED);

            bi.doAddToValidator = validator == null;
            bi.compToReg = list;
            bi.compToAdd = scrollPane;
            break;
        }

        case colorchooser: {
            ColorChooser colorChooser = new ColorChooser(Color.BLACK);
            if (validator != null) {
                DataChangeNotifier dcn = validator.createDataChangeNotifer(cellField.getName(), colorChooser,
                        null);
                colorChooser.addPropertyChangeListener("setValue", dcn);
            }
            //setControlSize(colorChooser);
            bi.compToAdd = colorChooser;

            break;
        }

        case button:
            JButton btn = createFormButton(cellField, cellField.getProperty("title"));
            bi.compToAdd = btn;
            break;

        case progress:
            bi.compToAdd = createProgressBar(0, 100);
            break;

        case plugin:
            UIPluginable uip = createPlugin(parent, validator, cellField,
                    mode == AltViewIFace.CreationMode.VIEW, isReq);
            if (uip != null) {
                bi.compToAdd = uip.getUIComponent();
                viewBldObj.registerPlugin(cell, uip);
            } else {
                bi.compToAdd = new JPanel();
                log.error("Couldn't create UIPlugin [" + cellField.getName() + "] ID:" + cellField.getIdent());
            }
            bi.doRegControl = false;
            break;

        case textpl:
            JTextField txt = new TextFieldFromPickListTable(adapter, cellField.getTxtCols());
            changeTextFieldUIForDisplay(txt, cellField.getPropertyAsBoolean("transparent", false));
            bi.compToAdd = txt;
            break;

        default:
            FormDevHelper.appendFormDevError("Don't recognize uitype=[" + uiType + "]");

        } // switch

    } else if (cell.getType() == FormCellIFace.CellType.separator) {
        // still have compToAdd = null;
        FormCellSeparatorIFace fcs = (FormCellSeparatorIFace) cell;
        String collapsableName = fcs.getCollapseCompName();

        String label = fcs.getLabel();
        if (StringUtils.isEmpty(label) || label.equals("##")) {
            String className = fcs.getProperty("forclass");
            if (StringUtils.isNotEmpty(className)) {
                DBTableInfo ti = DBTableIdMgr.getInstance().getByShortClassName(className);
                if (ti != null) {
                    label = ti.getTitle();
                }
            }
        }
        Component sep = viewBldObj.createSeparator(label);
        if (isNotEmpty(collapsableName)) {
            CollapsableSeparator collapseSep = new CollapsableSeparator(sep, false, null);
            if (bi.collapseSepHash == null) {
                bi.collapseSepHash = new HashMap<CollapsableSeparator, String>();
            }
            bi.collapseSepHash.put(collapseSep, collapsableName);
            sep = collapseSep;

        }
        bi.doRegControl = cell.getName().length() > 0;
        bi.compToAdd = (JComponent) sep;
        bi.doRegControl = StringUtils.isNotEmpty(cell.getIdent());
        bi.doAddToValidator = false;

    } else if (cell.getType() == FormCellIFace.CellType.command) {
        FormCellCommand cellCmd = (FormCellCommand) cell;
        JButton btn = createFormButton(cell, cellCmd.getLabel());
        if (cellCmd.getCommandType().length() > 0) {
            btn.addActionListener(new CommandActionWrapper(
                    new CommandAction(cellCmd.getCommandType(), cellCmd.getAction(), "")));
        }
        bi.doAddToValidator = false;
        bi.compToAdd = btn;

    } else if (cell.getType() == FormCellIFace.CellType.iconview) {
        FormCellSubView cellSubView = (FormCellSubView) cell;

        String subViewName = cellSubView.getViewName();

        ViewIFace subView = AppContextMgr.getInstance().getView(cellSubView.getViewSetName(), subViewName);
        if (subView != null) {
            if (parent != null) {
                int options = MultiView.VIEW_SWITCHER
                        | (MultiView.isOptionOn(parent.getCreateOptions(), MultiView.IS_NEW_OBJECT)
                                ? MultiView.IS_NEW_OBJECT
                                : MultiView.NO_OPTIONS);

                options |= cellSubView.getPropertyAsBoolean("nosep", false) ? MultiView.DONT_USE_EMBEDDED_SEP
                        : 0;
                options |= cellSubView.getPropertyAsBoolean("nosepmorebtn", false)
                        ? MultiView.NO_MORE_BTN_FOR_SEP
                        : 0;

                MultiView multiView = new MultiView(parent, cellSubView.getName(), subView,
                        parent.getCreateWithMode(), options, null);
                parent.addChildMV(multiView);
                multiView.setClassToCreate(getClassToCreate(parent, cell));

                log.debug("[" + cell.getType() + "] [" + cell.getName() + "] col: " + bi.colInx + " row: "
                        + rowInx + " colspan: " + cell.getColspan() + " rowspan: " + cell.getRowspan());
                viewBldObj.addSubView(cellSubView, multiView, bi.colInx, rowInx, cellSubView.getColspan(), 1);
                viewBldObj.closeSubView(cellSubView);
                bi.curMaxRow = rowInx;
                bi.colInx += cell.getColspan() + 1;
            } else {
                log.error("buildFormView - parent is NULL for subview [" + subViewName + "]");
            }

        } else {
            log.error("buildFormView - Could find subview's with ViewSet[" + cellSubView.getViewSetName()
                    + "] ViewName[" + subViewName + "]");
        }
        // still have compToAdd = null;
        bi.colInx += 2;

    } else if (cell.getType() == FormCellIFace.CellType.subview) {
        FormCellSubView cellSubView = (FormCellSubView) cell;
        String subViewName = cellSubView.getViewName();
        ViewIFace subView = AppContextMgr.getInstance().getView(cellSubView.getViewSetName(), subViewName);

        if (subView != null) {
            // Check to see this view should be "flatten" meaning we are creating a grid from a form
            if (!viewBldObj.shouldFlatten()) {
                if (parent != null) {
                    ViewIFace parentView = parent.getView();
                    Properties props = cellSubView.getProperties();

                    boolean isSingle = cellSubView.isSingleValueFromSet();
                    boolean isACollection = false;

                    try {
                        Class<?> cls = Class.forName(parentView.getClassName());
                        Field fld = getFieldFromDotNotation(cellSubView, cls);
                        if (fld != null) {
                            isACollection = Collection.class.isAssignableFrom(fld.getType());
                        } else {
                            log.error("Couldn't find field [" + cellSubView.getName() + "] in class ["
                                    + parentView.getClassName() + "]");
                        }
                    } catch (Exception ex) {
                        log.error("Couldn't find field [" + cellSubView.getName() + "] in class ["
                                + parentView.getClassName() + "]");
                        edu.ku.brc.af.core.UsageTracker.incrHandledUsageCount();
                        edu.ku.brc.exceptions.ExceptionTracker.getInstance().capture(ViewFactory.class, ex);
                    }

                    if (isSingle) {
                        isACollection = true;
                    }

                    boolean useNoScrollbars = UIHelper.getProperty(props, "noscrollbars", false);
                    //Assume RecsetController will always be handled correctly for one-to-one
                    boolean hideResultSetController = relInfo == null ? false
                            : relInfo.getType().equals(DBRelationshipInfo.RelationshipType.ZeroOrOne);
                    /*XXX bug #9497: boolean canEdit = true;
                    boolean addAddBtn = isEditOnCreateOnly && relInfo != null;
                    if (AppContextMgr.isSecurityOn()) {
                    DBTableInfo tblInfo = childInfo != null ? DBTableIdMgr.getInstance().getByShortClassName(childInfo.getDataClass().getSimpleName()) : null;
                    if (tblInfo != null) {
                        PermissionSettings perm = tblInfo.getPermissions();
                        if (perm != null) {
                            //XXX whoa. What about view perms???
                           //if (perm.isViewOnly() || !perm.canView()) {
                            if (!perm.canModify()) {
                               canEdit = false;
                            }
                        }
                    }
                    }*/

                    int options = (isACollection && !isSingle ? MultiView.RESULTSET_CONTROLLER
                            : MultiView.IS_SINGLE_OBJ)
                            | MultiView.VIEW_SWITCHER
                            | (MultiView.isOptionOn(parent.getCreateOptions(), MultiView.IS_NEW_OBJECT)
                                    ? MultiView.IS_NEW_OBJECT
                                    : MultiView.NO_OPTIONS)
                            |
                            /* XXX bug #9497:(mode == AltViewIFace.CreationMode.EDIT && canEdit ? MultiView.IS_EDITTING : MultiView.NO_OPTIONS) |
                            (useNoScrollbars ? MultiView.NO_SCROLLBARS : MultiView.NO_OPTIONS)
                            //| (addAddBtn ? MultiView.INCLUDE_ADD_BTN : MultiView.NO_OPTIONS)
                            ; */

                            (mode == AltViewIFace.CreationMode.EDIT ? MultiView.IS_EDITTING
                                    : MultiView.NO_OPTIONS)
                            | (useNoScrollbars ? MultiView.NO_SCROLLBARS : MultiView.NO_OPTIONS)
                            | (hideResultSetController ? MultiView.HIDE_RESULTSET_CONTROLLER
                                    : MultiView.NO_OPTIONS);
                    //MultiView.printCreateOptions("HERE", options);

                    options |= cellSubView.getPropertyAsBoolean("nosep", false)
                            ? MultiView.DONT_USE_EMBEDDED_SEP
                            : 0;
                    options |= cellSubView.getPropertyAsBoolean("nosepmorebtn", false)
                            ? MultiView.NO_MORE_BTN_FOR_SEP
                            : 0;
                    options |= cellSubView.getPropertyAsBoolean("collapse", false)
                            ? MultiView.COLLAPSE_SEPARATOR
                            : 0;

                    if (!(isACollection && !isSingle)) {
                        options &= ~MultiView.ADD_SEARCH_BTN;
                    } else {
                        options |= cellSubView.getPropertyAsBoolean("addsearch", false)
                                ? MultiView.ADD_SEARCH_BTN
                                : 0;
                    }

                    //MultiView.printCreateOptions("_______________________________", parent.getCreateOptions());
                    //MultiView.printCreateOptions("_______________________________", options);
                    boolean useBtn = UIHelper.getProperty(props, "btn", false);
                    if (useBtn) {
                        SubViewBtn.DATA_TYPE dataType;
                        if (isSingle) {
                            dataType = SubViewBtn.DATA_TYPE.IS_SINGLESET_ITEM;

                        } else if (isACollection) {
                            dataType = SubViewBtn.DATA_TYPE.IS_SET;
                        } else {
                            dataType = cellSubView.getName().equals("this") ? SubViewBtn.DATA_TYPE.IS_THIS
                                    : SubViewBtn.DATA_TYPE.IS_SET;
                        }

                        SubViewBtn subViewBtn = getInstance().createSubViewBtn(parent, cellSubView, subView,
                                dataType, options, props, getClassToCreate(parent, cell), mode);
                        subViewBtn.setHelpContext(props.getProperty("hc", null));

                        bi.doAddToValidator = false;
                        bi.compToAdd = subViewBtn;

                        String visProp = cell.getProperty("visible");
                        if (StringUtils.isNotEmpty(visProp) && visProp.equalsIgnoreCase("false")
                                && bi.compToAdd != null) {
                            bi.compToAdd.setVisible(false);
                        }

                        try {
                            addControl(validator, viewBldObj, rowInx, cell, bi);

                        } catch (java.lang.IndexOutOfBoundsException ex) {
                            String msg = "Error adding control type: `" + cell.getType() + "` id: `"
                                    + cell.getIdent() + "` name: `" + cell.getName() + "` on row: " + rowInx
                                    + " column: " + bi.colInx + "\n" + ex.getMessage();
                            UIRegistry.showError(msg);
                            return false;
                        }

                        bi.doRegControl = false;
                        bi.compToAdd = null;

                    } else {

                        Color bgColor = getBackgroundColor(props, parent.getBackground());

                        //log.debug(cellSubView.getName()+"  "+UIHelper.getProperty(props, "addsearch", false));
                        if (UIHelper.getProperty(props, "addsearch", false)) {
                            options |= MultiView.ADD_SEARCH_BTN;
                        }

                        if (UIHelper.getProperty(props, "addadd", false)) {
                            options |= MultiView.INCLUDE_ADD_BTN;
                        }

                        //MultiView.printCreateOptions("SUBVIEW", options);
                        MultiView multiView = new MultiView(parent, cellSubView.getName(), subView,
                                parent.getCreateWithMode(), cellSubView.getDefaultAltViewType(), options,
                                bgColor, cellSubView);
                        multiView.setClassToCreate(getClassToCreate(parent, cell));
                        setBorder(multiView, cellSubView.getProperties());

                        parent.addChildMV(multiView);

                        //log.debug("["+cell.getType()+"] ["+cell.getName()+"] col: "+bi.colInx+" row: "+rowInx+" colspan: "+cell.getColspan()+" rowspan: "+cell.getRowspan());
                        viewBldObj.addSubView(cellSubView, multiView, bi.colInx, rowInx,
                                cellSubView.getColspan(), 1);
                        viewBldObj.closeSubView(cellSubView);

                        Viewable viewable = multiView.getCurrentView();
                        if (viewable != null) {
                            if (viewable instanceof TableViewObj) {
                                ((TableViewObj) viewable).setVisibleRowCount(cellSubView.getTableRows());
                            }
                            if (viewable.getValidator() != null && childInfo != null) {
                                viewable.getValidator().setRequired(childInfo.isRequired());
                            }
                        }
                        bi.colInx += cell.getColspan() + 1;
                    }
                    bi.curMaxRow = rowInx;

                    //if (hasColor)
                    //{
                    //    setMVBackground(multiView, multiView.getBackground());
                    //}

                } else {
                    log.error("buildFormView - parent is NULL for subview [" + subViewName + "]");
                    bi.colInx += 2;
                }
            } else {
                //log.debug("["+cell.getType()+"] ["+cell.getName()+"] col: "+bi.colInx+" row: "+rowInx+" colspan: "+cell.getColspan()+" rowspan: "+cell.getRowspan());
                viewBldObj.addSubView(cellSubView, parent, bi.colInx, rowInx, cellSubView.getColspan(), 1);

                AltViewIFace altView = subView.getDefaultAltView();
                DBTableInfo sbTableInfo = DBTableIdMgr.getInstance().getByClassName(subView.getClassName());
                ViewDefIFace altsViewDef = (ViewDefIFace) altView.getViewDef();

                if (altsViewDef instanceof FormViewDefIFace) {
                    FormViewDefIFace fvd = (FormViewDefIFace) altsViewDef;
                    processRows(sbTableInfo, parent, viewDef, validator, viewBldObj, altView.getMode(),
                            labelsForHash, currDataObj, fvd.getRows());

                } else if (altsViewDef == null) {
                    // This error is bad enough to have it's own dialog
                    String msg = String.format("The Altview '%s' has a null ViewDef!", altView.getName());
                    FormDevHelper.appendFormDevError(msg);
                    UIRegistry.showError(msg);
                }

                viewBldObj.closeSubView(cellSubView);
                bi.colInx += cell.getColspan() + 1;
            }

        } else {
            log.error("buildFormView - Could find subview's with ViewSet[" + cellSubView.getViewSetName()
                    + "] ViewName[" + subViewName + "]");
        }
        // still have compToAdd = null;

    } else if (cell.getType() == FormCellIFace.CellType.statusbar) {
        bi.compToAdd = new JStatusBar();
        bi.doRegControl = true;
        bi.doAddToValidator = false;

    } else if (cell.getType() == FormCellIFace.CellType.panel) {
        bi.doRegControl = false;
        bi.doAddToValidator = false;

        cell.setIgnoreSetGet(true);

        FormCellPanel cellPanel = (FormCellPanel) cell;
        PanelViewable.PanelType panelType = PanelViewable.getType(cellPanel.getPanelType());

        if (panelType == PanelViewable.PanelType.Panel) {
            PanelViewable panelViewable = new PanelViewable(viewBldObj, cellPanel);

            processRows(parentTableInfo, parent, viewDef, validator, panelViewable, mode, labelsForHash,
                    currDataObj, cellPanel.getRows());

            panelViewable.setVisible(cellPanel.getPropertyAsBoolean("visible", true));

            setBorder(panelViewable, cellPanel.getProperties());
            if (parent != null) {
                Color bgColor = getBackgroundColor(cellPanel.getProperties(), parent.getBackground());
                if (bgColor != null && bgColor != parent.getBackground()) {
                    panelViewable.setOpaque(true);
                    panelViewable.setBackground(bgColor);
                }
            }

            bi.compToAdd = panelViewable;
            bi.doRegControl = true;
            bi.compToReg = panelViewable;

        } else if (panelType == PanelViewable.PanelType.ButtonBar) {
            bi.compToAdd = PanelViewable.buildButtonBar(processRows(viewBldObj, cellPanel.getRows()));

        } else {
            FormDevHelper.appendFormDevError("Panel Type is not implemented.");
            return false;
        }
    }

    String visProp = cell.getProperty("visible");
    if (StringUtils.isNotEmpty(visProp) && visProp.equalsIgnoreCase("false") && bi.compToAdd != null) {
        bi.compToAdd.setVisible(false);
    }

    return true;
}

From source file:dpcs.Interface.java

public Interface() {
    setIconImage(Toolkit.getDefaultToolkit().getImage(Interface.class.getResource("/graphics/Icon.png")));
    setTitle("Droid PC Suite");
    setResizable(false);/*  ww w  . j ava  2s . c  om*/
    setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    setBounds(100, 100, 1088, 715);
    try {
        InputStreamReader reader2 = new InputStreamReader(
                getClass().getResourceAsStream("/others/app-version.txt"));
        String tmp = IOUtils.toString(reader2);
        AppVersion = Double.parseDouble(tmp);
    } catch (IOException e1) {
        e1.printStackTrace();
    }
    JMenuBar menuBar = new JMenuBar();
    setJMenuBar(menuBar);
    JMenu mnMenu = new JMenu("Menu");
    menuBar.add(mnMenu);
    JMenuItem mntmExit = new JMenuItem("Exit");

    mntmExit.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent arg0) {
            System.exit(0);
        }
    });

    JMenu mnADBandFastbootTools = new JMenu("ADB and Fastboot tools");
    mnMenu.add(mnADBandFastbootTools);
    mnADBandFastbootTools.setToolTipText("Access various ADB and Fastboot tools");

    JMenuItem mntmDevicestate = new JMenuItem("View device state");
    mntmDevicestate.setToolTipText("Check android device state");
    mntmDevicestate.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent arg0) {
            try {
                Process p1 = Runtime.getRuntime().exec("adb get-state");
                p1.waitFor();
                BufferedReader reader = new BufferedReader(new InputStreamReader(p1.getInputStream()));
                JOptionPane.showMessageDialog(null, "State: " + reader.readLine());
            } catch (Exception e1) {
                e1.printStackTrace();
            }
        }
    });

    JMenuItem mntmAdbHelp = new JMenuItem("View ADB help");
    mntmAdbHelp.setToolTipText("Get help regarding ADB");
    mntmAdbHelp.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent arg0) {
            ADBHelp obj = new ADBHelp();
            obj.setVisible(true);
        }
    });

    JMenuItem mntmNoOfUsers = new JMenuItem("Max user(s) supported?");
    mntmNoOfUsers.setToolTipText("Max no. of user(s) supported by android device");
    mntmNoOfUsers.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent arg0) {
            try {
                Process p1 = Runtime.getRuntime().exec("adb shell pm get-max-users");
                p1.waitFor();
                BufferedReader reader = new BufferedReader(new InputStreamReader(p1.getInputStream()));
                JOptionPane.showMessageDialog(null, reader.readLine());
            } catch (Exception e1) {
                e1.printStackTrace();
            }
        }
    });
    mnADBandFastbootTools.add(mntmNoOfUsers);
    mnADBandFastbootTools.add(mntmAdbHelp);

    JMenuItem mntmAdbVersion = new JMenuItem("View ADB version");
    mntmAdbVersion.setToolTipText("Check the version of ADB installed on your computer");
    mnADBandFastbootTools.add(mntmAdbVersion);
    mntmAdbVersion.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent arg0) {
            try {
                Process p1 = Runtime.getRuntime().exec("adb version");
                p1.waitFor();
                BufferedReader reader = new BufferedReader(new InputStreamReader(p1.getInputStream()));
                JOptionPane.showMessageDialog(null, reader.readLine());
            } catch (Exception e1) {
                e1.printStackTrace();
            }
        }
    });

    JMenuItem mntmViewDeviceList = new JMenuItem("View connected device");
    mntmViewDeviceList.setToolTipText(
            "Displays connected device, it will show name and serial no. of the only connected device because of connectivity limit");
    mntmViewDeviceList.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent e) {
            try {
                JTextArea Devicelistviewer = new JTextArea();
                Devicelistviewer.setEditable(false);
                Devicelistviewer.setForeground(Color.BLACK);
                Devicelistviewer.setOpaque(false);
                Process p1 = Runtime.getRuntime().exec("adb devices -l");
                p1.waitFor();
                int i = 0;
                String line;
                String[] array = new String[1024];
                BufferedReader reader = new BufferedReader(new InputStreamReader(p1.getInputStream()));
                while ((line = reader.readLine()) != null) {
                    array[i] = line;
                    Devicelistviewer.append(line + "\n");
                }
                JOptionPane.showMessageDialog(null, Devicelistviewer);
            } catch (Exception e1) {
                e1.printStackTrace();
            }
        }
    });
    mnADBandFastbootTools.add(mntmViewDeviceList);
    mnADBandFastbootTools.add(mntmDevicestate);

    JMenuItem mntmViewFastbootHelp = new JMenuItem("View fastboot help");
    mntmViewFastbootHelp.setToolTipText("Get help regarding fastboot");
    mntmViewFastbootHelp.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent e) {
            FastbootHelp obj = new FastbootHelp();
            obj.setVisible(true);
        }
    });
    mnADBandFastbootTools.add(mntmViewFastbootHelp);

    JMenuItem mntmSerialNo = new JMenuItem("View serial no.");
    mntmSerialNo.setToolTipText("Check ADB connectivity serial no. of your android device");
    mnADBandFastbootTools.add(mntmSerialNo);
    mntmSerialNo.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent e) {
            try {
                Process p1 = Runtime.getRuntime().exec("adb get-serialno");
                p1.waitFor();
                BufferedReader reader = new BufferedReader(new InputStreamReader(p1.getInputStream()));
                JOptionPane.showMessageDialog(null, "Serial No: " + reader.readLine());
            } catch (Exception e1) {
                e1.printStackTrace();
            }
        }
    });

    JMenuItem mntmWaitForDevice = new JMenuItem("Wait for device");
    mntmWaitForDevice.setToolTipText("Ask ADB to wait for your device until the device can accept commands");
    mntmWaitForDevice.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent arg0) {
            try {
                Process p1 = Runtime.getRuntime().exec("adb wait-for-device");
                p1.waitFor();
                JOptionPane.showMessageDialog(null, "Waiting...");
            } catch (Exception e1) {
                e1.printStackTrace();
            }
        }
    });
    mnADBandFastbootTools.add(mntmWaitForDevice);

    JMenuItem mntmDeviceFeatures = new JMenuItem("Device features");
    mnMenu.add(mntmDeviceFeatures);
    mntmDeviceFeatures.setToolTipText("View list of features supported by the android device");
    mntmDeviceFeatures.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent arg0) {
            Devicefeatures obj = new Devicefeatures();
            obj.setVisible(true);
        }
    });

    JMenu mnDeviceSpecificTools = new JMenu("Device specific tools");
    mnMenu.add(mnDeviceSpecificTools);
    mnDeviceSpecificTools.setToolTipText("View tools which only work with few  or specific devices");

    JMenu mnHTC = new JMenu("HTC");
    mnDeviceSpecificTools.add(mnHTC);
    mnHTC.setToolTipText("View list of tools which only work with HTC devices");

    JMenuItem mntmGetCidNo = new JMenuItem("Get CID no.");
    mntmGetCidNo.setToolTipText("Get CID Number of the device");
    mntmGetCidNo.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent e) {
            try {
                Process p1 = Runtime.getRuntime().exec("adb reboot fastboot");
                p1.waitFor();
                Process p2 = Runtime.getRuntime().exec("fastboot getvar cid");
                p2.waitFor();
                BufferedReader reader = new BufferedReader(new InputStreamReader(p2.getInputStream()));
                JOptionPane.showMessageDialog(null, reader.readLine());
                Process p3 = Runtime.getRuntime().exec("fastboot reboot");
                p3.waitFor();
            } catch (Exception e1) {
                e1.printStackTrace();
            }
        }
    });

    JMenuItem mntmBootloaderRelatedInfo = new JMenuItem("Bootloader related info");
    mntmBootloaderRelatedInfo.setToolTipText("View CID No.,Main-ver, bootloader info Etc.");
    mntmBootloaderRelatedInfo.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent e) {
            try {
                Process p1 = Runtime.getRuntime().exec("adb reboot fastboot");
                p1.waitFor();
                Process p2 = Runtime.getRuntime().exec("fastboot getvar all");
                p2.waitFor();
                BufferedReader reader = new BufferedReader(new InputStreamReader(p2.getInputStream()));
                JOptionPane.showMessageDialog(null, reader.readLine() + "\n");
                Process p3 = Runtime.getRuntime().exec("fastboot reboot");
                p3.waitFor();
            } catch (Exception e1) {
                e1.printStackTrace();
            }
        }
    });
    mnHTC.add(mntmBootloaderRelatedInfo);
    mnHTC.add(mntmGetCidNo);

    JMenuItem mntmWriteSuperCIDNo = new JMenuItem("Write Super CID no.");
    mntmWriteSuperCIDNo.setToolTipText("Write Super CID Number to device");
    mntmWriteSuperCIDNo.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent e) {
            try {
                int supercidno;
                Process p1 = Runtime.getRuntime().exec("adb reboot fastboot");
                p1.waitFor();
                supercidno = Integer.parseInt(JOptionPane.showInputDialog(null,
                        "Enter the Super CID Number to be written :\nfor ex. 11111111"));
                Process p2 = Runtime.getRuntime().exec("fastboot oem writecid " + supercidno);
                p2.waitFor();
                JOptionPane.showMessageDialog(null, "Done, Click OK to reboot");
                Process p3 = Runtime.getRuntime().exec("fastboot reboot");
                p3.waitFor();
            } catch (Exception e1) {
                e1.printStackTrace();
            }
        }
    });
    mnHTC.add(mntmWriteSuperCIDNo);

    JMenu mnSamsung = new JMenu("Samsung");
    mnSamsung.setToolTipText("View list of tools which only work with Samsung devices");
    mnDeviceSpecificTools.add(mnSamsung);

    JMenuItem mntmDownloadMode = new JMenuItem("Download Mode");
    mntmDownloadMode.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent e) {
            try {
                ApplicationStatus.setText("Rebooting...");
                Process p1 = Runtime.getRuntime().exec("adb reboot download");
                p1.waitFor();
                ApplicationStatus.setText("Done");
            } catch (Exception e1) {
                System.err.println(e1);
            }
        }
    });
    mntmDownloadMode.setToolTipText(
            "Reboot to Download Mode for flashing firmware to samsung device using Odin or Heimdall");
    mnSamsung.add(mntmDownloadMode);

    mnMenu.add(mntmExit);
    JMenu mnHelp = new JMenu("Help");
    menuBar.add(mnHelp);

    JMenuItem mntmCommonWorkarounds = new JMenuItem("Common workarounds");
    mntmCommonWorkarounds.setToolTipText(
            "View solutions and tips to avoid the common problems while using this application");
    mntmCommonWorkarounds.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent e) {
            Workarounds obj = new Workarounds();
            obj.setVisible(true);
        }
    });

    JMenuItem mntmAbout = new JMenuItem("About");
    mntmAbout.setToolTipText("Information about the application");
    mntmAbout.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent e) {
            About obj = new About();
            obj.setVisible(true);
        }
    });
    mnHelp.add(mntmAbout);

    JMenuItem mntmCheckForUpdates = new JMenuItem("Check for updates");
    mntmCheckForUpdates.setToolTipText("Check for the new updates of this application");
    mntmCheckForUpdates.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent e) {
            new Updater();
        }
    });

    JMenuItem mntmChangelog = new JMenuItem("Changelog");
    mntmChangelog.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent arg0) {
            Changelog obj = new Changelog();
            obj.setVisible(true);
        }
    });
    mntmChangelog.setToolTipText("View changes made to this application over the time");
    mnHelp.add(mntmChangelog);
    mnHelp.add(mntmCheckForUpdates);
    mnHelp.add(mntmCommonWorkarounds);

    JMenuItem mntmNeedHelp = new JMenuItem("Online help");
    mntmNeedHelp.setToolTipText("Get online help for Droid PC Suite");
    mntmNeedHelp.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent arg0) {
            try {
                JOptionPane.showMessageDialog(null, "Post your queries on XDA-Developers thread");
                Desktop.getDesktop().browse(new URL(
                        "http://forum.xda-developers.com/android/development/tool-droid-pc-suite-t3398599")
                                .toURI());
            } catch (Exception e) {
                System.err.println(e);
            }
        }
    });

    JMenuItem mntmForceConnect = new JMenuItem("Force connect");
    mnHelp.add(mntmForceConnect);
    mntmForceConnect.setToolTipText("Force connect android device to computer using ADB protocol");
    mntmForceConnect.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent e) {
            JOptionPane.showMessageDialog(null,
                    "Go to developer options and turn off android debugging and turn it on again");
            JOptionPane.showMessageDialog(null,
                    "Now tap on Revoke USB debugging authorizations and confirm it by tapping OK on android device");
            JOptionPane.showMessageDialog(null, "Now disconnect your android device and reconnect it via USB");
            JOptionPane.showMessageDialog(null, "Reboot your device. After it completely boots up click OK");
            try {
                adbconnected = false;
                Process p1 = Runtime.getRuntime().exec("adb kill-server");
                p1.waitFor();
                Process p2 = Runtime.getRuntime().exec("adb devices");
                p2.waitFor();
                JOptionPane.showMessageDialog(null, "Check if your device asks to Allow USB debugging");
                JOptionPane.showMessageDialog(null,
                        "If yes check always allow from this computer checkbox and tap OK on your android device");
                Process p3 = Runtime.getRuntime().exec("adb shell touch /sdcard/.CheckADBConnection");
                p3.waitFor();
                Process p4 = Runtime.getRuntime().exec("adb pull /sdcard/.CheckADBConnection");
                p4.waitFor();
                Process p5 = Runtime.getRuntime().exec("adb shell rm /sdcard/.CheckADBConnection");
                p5.waitFor();
                File file = new File(".CheckADBConnection");
                if (file.exists() && !file.isDirectory()) {
                    file.delete();
                    adbconnected = true;
                    ADBConnectionLabel.setText("Device is connected");
                    JOptionPane.showMessageDialog(null, "Success!");
                } else {
                    adbconnected = false;
                    ADBConnectionLabel.setText("");
                    ADBConnectionLabel.setText("Connect your device...");
                    JOptionPane.showMessageDialog(null,
                            "Please try again or perhaps try installing your android device adb drivers on PC");
                }
            } catch (Exception e1) {
                System.err.println(e1);
            }
            try {
                File file = new File("su");
                Process p1 = Runtime.getRuntime().exec("adb pull /system/xbin/su");
                p1.waitFor();
                if (file.exists() && !file.isDirectory()) {
                    file.delete();
                    rooted = true;
                    RootStatusLabel.setText("Device is rooted");
                } else {
                    if (adbconnected == true) {
                        rooted = false;
                        RootStatusLabel.setText("Device is not rooted");
                    } else {
                        rooted = false;
                        RootStatusLabel.setText("");
                    }
                }
            } catch (Exception e1) {
                e1.printStackTrace();
            }
        }
    });

    JMenu mnLegalInformation = new JMenu("Legal information");
    mnLegalInformation.setToolTipText("Vew legal information about the application");
    mnHelp.add(mnLegalInformation);

    JMenuItem mntmDroidPcSuite = new JMenuItem("Droid PC Suite license");
    mntmDroidPcSuite.setToolTipText("View Droid PC Suite licence");
    mntmDroidPcSuite.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent e) {
            GPLLicense obj = new GPLLicense();
            obj.setVisible(true);
        }
    });
    mnLegalInformation.add(mntmDroidPcSuite);

    JMenuItem mntmOpenSourceLicenses = new JMenuItem("Open source licenses");
    mntmOpenSourceLicenses
            .setToolTipText("View other open source licences for other softwares used with this application");
    mntmOpenSourceLicenses.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent arg0) {
            ApacheLicense obj = new ApacheLicense();
            obj.setVisible(true);
        }
    });
    mnLegalInformation.add(mntmOpenSourceLicenses);
    mnHelp.add(mntmNeedHelp);
    contentPane = new JPanel();
    contentPane.setBackground(Color.WHITE);
    contentPane.setBorder(new EmptyBorder(5, 5, 5, 5));
    setContentPane(contentPane);
    contentPane.setLayout(null);

    ApplicationStatus = new JLabel("");
    ApplicationStatus.addMouseListener(new MouseAdapter() {
        @Override
        public void mouseClicked(MouseEvent arg0) {
            if (!ApplicationStatus.getText().equals("")) {
                int dialogButton = JOptionPane.YES_NO_OPTION;
                int dialogResult = JOptionPane.showConfirmDialog(null,
                        "Do you want to clear application status?", "Application status", dialogButton);
                if (dialogResult == 0) {
                    ApplicationStatus.setText("");
                }
            }
        }
    });

    JLabel lblApplicationVersion = new JLabel("Version: " + AppVersion);
    lblApplicationVersion.setBounds(818, 150, 135, 22);
    contentPane.add(lblApplicationVersion);
    ApplicationStatus.setBounds(12, 230, 1062, 17);
    contentPane.add(ApplicationStatus);

    RootStatusLabel = new JLabel("");
    RootStatusLabel.setBounds(921, 12, 153, 17);
    RootStatusLabel.setForeground(Color.RED);
    contentPane.add(RootStatusLabel);

    ADBConnectionLabel = new JLabel("");
    ADBConnectionLabel.setBounds(900, 0, 175, 17);
    ADBConnectionLabel.setForeground(Color.GREEN);
    contentPane.add(ADBConnectionLabel);

    JTabbedPane tabbedPane = new JTabbedPane(JTabbedPane.TOP);
    tabbedPane.setBounds(0, 255, 1075, 447);
    contentPane.add(tabbedPane);

    JPanel panel_7 = new JPanel();
    panel_7.setBackground(Color.WHITE);
    tabbedPane.addTab("General", null, panel_7, null);
    panel_7.setLayout(null);

    JButton btnADBTerminal = new JButton("ADB Terminal");
    btnADBTerminal.setToolTipText("Send commands to your android device via ADB protocol, EXPERIMENTAL!");
    btnADBTerminal.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent e) {
            Terminal obj = new Terminal();
            obj.setVisible(true);
        }
    });

    JButton btnBuildpropeditor = new JButton("build.prop Editor");
    btnBuildpropeditor
            .setToolTipText("Editor for editing build properties of your android device, Use with Caution!");
    btnBuildpropeditor.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent arg0) {
            Buildpropeditor obj = new Buildpropeditor();
            obj.setVisible(true);
        }
    });
    btnBuildpropeditor.setBounds(541, 27, 220, 75);
    panel_7.add(btnBuildpropeditor);
    btnADBTerminal.setBounds(25, 27, 220, 75);
    panel_7.add(btnADBTerminal);

    JLabel lblNoteInstallationTo = new JLabel("# Only for android 4.4.x and higher");
    lblNoteInstallationTo.setBounds(20, 311, 1046, 15);
    panel_7.add(lblNoteInstallationTo);

    GeneralDone = new JLabel("");
    GeneralDone.setText("");
    GeneralDone.setBounds(766, 27, 300, 220);
    panel_7.add(GeneralDone);

    JButton btnFileManager = new JButton("File Manager");
    btnFileManager.setToolTipText("Access files on your android device");
    btnFileManager.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent e) {
            GeneralDone.setText("");
            filemanager.FileManager.main(null);
        }
    });
    btnFileManager.setBounds(25, 131, 220, 75);
    panel_7.add(btnFileManager);

    JLabel lblNeedsRoot = new JLabel(
            "* Needs root access, also may not work with some devices regardless of root access");
    lblNeedsRoot.setBounds(20, 326, 1046, 15);
    panel_7.add(lblNeedsRoot);

    JButton btnScreenshot = new JButton("Screenshot");
    btnScreenshot.setToolTipText("Screenshot your android device screen");
    btnScreenshot.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent arg0) {
            try {
                Process p1 = Runtime.getRuntime().exec("adb shell screencap -p /sdcard/screenshot.png");
                p1.waitFor();
                JFileChooser directorychooser = new JFileChooser();
                directorychooser.setFileSelectionMode(JFileChooser.DIRECTORIES_ONLY);
                directorychooser.setDialogTitle("Select path to save the screenshot");
                FileNameExtensionFilter filter = new FileNameExtensionFilter("PNG Files", "png");
                directorychooser.setFileFilter(filter);
                directorychooser.setApproveButtonText("Save");
                int returnVal = directorychooser.showOpenDialog(getParent());
                if (returnVal == JFileChooser.APPROVE_OPTION) {
                    Process p2 = Runtime.getRuntime().exec("adb pull /sdcard/screenshot.png "
                            + directorychooser.getSelectedFile().getAbsolutePath());
                    p2.waitFor();
                }
                Process p3 = Runtime.getRuntime().exec("adb shell rm /sdcard/screenshot.png");
                p3.waitFor();
            } catch (Exception e) {
                e.printStackTrace();
            }
        }
    });
    btnScreenshot.setBounds(282, 131, 220, 75);
    panel_7.add(btnScreenshot);

    JButton btnScreenRecorder = new JButton("Screen Recorder #");
    btnScreenRecorder.setToolTipText("Record android device screen");
    btnScreenRecorder.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent arg0) {
            String[] options = new String[] { "5 Sec", "30 Sec", "60 Sec", "180 Sec", "Custom" };
            int response = JOptionPane.showOptionDialog(null, "Select duration of recording", "Screen Recorder",
                    JOptionPane.DEFAULT_OPTION, JOptionPane.PLAIN_MESSAGE, null, options, options[0]);
            int time = 0, bitrate = 8000000;
            try {
                if (response == 0) {
                    time = 5;
                }
                if (response == 1) {
                    time = 30;
                }
                if (response == 2) {
                    time = 60;
                }
                if (response == 3) {
                    time = 180;
                }
                if (response == 4) {
                    time = Integer.parseInt(JOptionPane.showInputDialog(null,
                            "Enter the duration of recording in seconds (1 - 180): for ex. 25 for 25 Seconds"));
                    bitrate = Integer.parseInt(JOptionPane.showInputDialog(null,
                            "Enter the bitrate of recording (Default = 8000000 (8Mbps))"));
                }
                JOptionPane.showMessageDialog(null, "You will need to wait for " + time + " seconds, Click ok");
                Process p1 = Runtime.getRuntime().exec("adb shell screenrecord --bit-rate " + bitrate
                        + " --time-limit " + time + " /sdcard/videorecording.mp4");
                p1.waitFor();
                JOptionPane.showMessageDialog(null, "Recording finished, Select destination to save the file");
                JFileChooser directorychooser = new JFileChooser();
                directorychooser.setFileSelectionMode(JFileChooser.DIRECTORIES_ONLY);
                directorychooser.setDialogTitle("Select path to save the recording");
                FileNameExtensionFilter filter = new FileNameExtensionFilter("MP4 Files", "mp4");
                directorychooser.setFileFilter(filter);
                directorychooser.setApproveButtonText("Save");
                int returnVal = directorychooser.showOpenDialog(getParent());
                if (returnVal == JFileChooser.APPROVE_OPTION) {
                    Process p2 = Runtime.getRuntime().exec("adb pull /sdcard/videorecording.mp4 "
                            + directorychooser.getSelectedFile().getAbsolutePath());
                    p2.waitFor();
                }
                Process p3 = Runtime.getRuntime().exec("adb shell rm /sdcard/videorecording.mp4");
                p3.waitFor();
            } catch (Exception e) {
                e.printStackTrace();
            }
        }
    });
    btnScreenRecorder.setBounds(541, 131, 220, 75);
    panel_7.add(btnScreenRecorder);

    JButton btnAppManager = new JButton("App Manager");
    btnAppManager.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent e) {
            GeneralDone.setText("");
            String[] MainOptions = new String[] { "Install apps", "Uninstall apps" };
            int MainResponse = JOptionPane.showOptionDialog(null, "Select an operation", "App Manager",
                    JOptionPane.DEFAULT_OPTION, JOptionPane.PLAIN_MESSAGE, null, MainOptions, MainOptions[0]);
            if (MainResponse == 0) {
                try {
                    GeneralDone.setText("");
                    String[] options = new String[] { "User apps", "Priv-apps", "System apps" };
                    int response = JOptionPane.showOptionDialog(null, "Where to install the app?", "Installer",
                            JOptionPane.DEFAULT_OPTION, JOptionPane.PLAIN_MESSAGE, null, options, options[0]);
                    if (response == 0) {
                        try {
                            GeneralDone.setText("");
                            JFileChooser chooser = new JFileChooser();
                            FileNameExtensionFilter filter = new FileNameExtensionFilter("APK Files", "apk");
                            chooser.setFileFilter(filter);
                            int returnVal = chooser.showOpenDialog(getParent());
                            if (returnVal == JFileChooser.APPROVE_OPTION) {
                                File file = chooser.getSelectedFile();
                                String filename = chooser.getSelectedFile().getName();
                                try {
                                    ApplicationStatus.setText("Installing...");
                                    String[] commands = new String[3];
                                    commands[0] = "adb";
                                    commands[1] = "install";
                                    commands[2] = file.getAbsolutePath();
                                    ApplicationStatus.setText("Installing App...");
                                    Process p1 = Runtime.getRuntime().exec(commands, null);
                                    p1.waitFor();
                                    ApplicationStatus.setText(filename
                                            + " has been successfully installed on your android device!");
                                    GeneralDone.setIcon(
                                            new ImageIcon(Interface.class.getResource("/graphics/Done.png")));
                                } catch (Exception e1) {
                                    System.err.println(e1);
                                }
                            }
                        } catch (Exception e1) {
                        }
                    }
                    if (response == 1) {
                        GeneralDone.setText("");
                        JFileChooser chooser = new JFileChooser();
                        FileNameExtensionFilter filter = new FileNameExtensionFilter("APK Files", "apk");
                        chooser.setFileFilter(filter);
                        int returnVal = chooser.showOpenDialog(getParent());
                        if (returnVal == JFileChooser.APPROVE_OPTION) {
                            File file = chooser.getSelectedFile();
                            try {
                                ApplicationStatus.setText("Installing...");
                                Process p1 = Runtime.getRuntime().exec("adb remount");
                                p1.waitFor();
                                String[] pushcommand = new String[4];
                                pushcommand[0] = "adb";
                                pushcommand[1] = "push";
                                pushcommand[2] = file.getAbsolutePath();
                                pushcommand[3] = "/system/priv-app/";
                                ApplicationStatus.setText("Installing App...");
                                Process p2 = Runtime.getRuntime().exec(pushcommand, null);
                                p2.waitFor();
                                ApplicationStatus.setText("Rebooting your android device");
                                Process p3 = Runtime.getRuntime().exec("adb reboot");
                                p3.waitFor();
                                ApplicationStatus.setText("");
                                GeneralDone.setIcon(
                                        new ImageIcon(Interface.class.getResource("/graphics/Done.png")));
                            } catch (Exception e1) {
                                System.err.println(e1);
                            }
                        }
                    }
                    if (response == 2) {
                        GeneralDone.setText("");
                        JFileChooser chooser = new JFileChooser();
                        FileNameExtensionFilter filter = new FileNameExtensionFilter("APK Files", "apk");
                        chooser.setFileFilter(filter);
                        int returnVal = chooser.showOpenDialog(getParent());
                        if (returnVal == JFileChooser.APPROVE_OPTION) {
                            File file = chooser.getSelectedFile();
                            try {
                                ApplicationStatus.setText("Installing...");
                                Process p1 = Runtime.getRuntime().exec("adb remount");
                                p1.waitFor();
                                String[] pushcommand = new String[4];
                                pushcommand[0] = "adb";
                                pushcommand[1] = "push";
                                pushcommand[2] = file.getAbsolutePath();
                                pushcommand[3] = "/system/app/";
                                Process p2 = Runtime.getRuntime().exec(pushcommand, null);
                                p2.waitFor();
                                ApplicationStatus.setText("Rebooting your android device");
                                Process p3 = Runtime.getRuntime().exec("adb reboot");
                                p3.waitFor();
                                ApplicationStatus.setText("");
                                GeneralDone.setIcon(
                                        new ImageIcon(Interface.class.getResource("/graphics/Done.png")));
                            } catch (Exception e1) {
                                System.err.println(e1);
                            }
                        }
                    }
                } catch (Exception e1) {
                }
            }
            if (MainResponse == 1) {
                try {
                    GeneralDone.setText("");
                    String[] options = new String[] { "User apps", "Priv-apps", "System apps" };
                    int response = JOptionPane.showOptionDialog(null,
                            "Which kind of app you want to uninstall?", "Uninstaller",
                            JOptionPane.DEFAULT_OPTION, JOptionPane.PLAIN_MESSAGE, null, options, options[0]);
                    if (response == 0) {
                        try {
                            UninstallUserApps obj = new UninstallUserApps();
                            obj.setVisible(true);
                        } catch (Exception e1) {
                        }
                    }
                    if (response == 1) {
                        try {
                            UninstallPrivApps obj = new UninstallPrivApps();
                            obj.setVisible(true);
                        } catch (Exception e1) {
                        }
                    }
                    if (response == 2) {
                        try {
                            UninstallSystemApps obj = new UninstallSystemApps();
                            obj.setVisible(true);
                        } catch (Exception e1) {
                        }
                    }
                } catch (Exception e1) {
                }
            }
        }
    });
    btnAppManager.setToolTipText("Manage Apps on your android device");
    btnAppManager.setBounds(282, 27, 220, 75);
    panel_7.add(btnAppManager);

    JLabel lblInstallationAndUninstallation = new JLabel(
            "Installation and Uninstallation of apps to Priv-app is only for android 4.4 and higher, requires root and even simply may not work on your device!");
    lblInstallationAndUninstallation.setBounds(20, 356, 1046, 15);
    panel_7.add(lblInstallationAndUninstallation);

    JLabel lblInstallationAndUninstallation_1 = new JLabel(
            "Installation and Uninstallation of apps to System requires root, and may not work for your device!");
    lblInstallationAndUninstallation_1.setBounds(20, 341, 1046, 15);
    panel_7.add(lblInstallationAndUninstallation_1);

    JPanel panel_8 = new JPanel();
    panel_8.setBackground(Color.WHITE);
    tabbedPane.addTab("Advanced", null, panel_8, null);
    panel_8.setLayout(null);

    JButton btnMemoryInformation = new JButton("Memory Information");
    btnMemoryInformation.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent e) {
            Memoryinfo obj = new Memoryinfo();
            obj.setVisible(true);
        }
    });

    JButton btnClearBatteryStats = new JButton("Clear Battery Stats *");
    btnClearBatteryStats.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent arg0) {
            try {
                Process p1 = Runtime.getRuntime().exec("adb remount");
                p1.waitFor();
                Process p2 = Runtime.getRuntime().exec("adb shell su -c rm -r /data/system/batterystats.bin");
                p2.waitFor();
                String[] options = new String[] { "Yes", "No" };
                int response = JOptionPane.showOptionDialog(null, "Done, would you like to reboot your device?",
                        "Reboot device? (Recommended)", JOptionPane.DEFAULT_OPTION, JOptionPane.PLAIN_MESSAGE,
                        null, options, options[0]);
                if (response == 0) {
                    try {
                        Process p3 = Runtime.getRuntime().exec("adb reboot");
                        p3.waitFor();
                    } catch (Exception e1) {
                    }
                }
            } catch (Exception e1) {
                e1.printStackTrace();
            }
        }
    });
    btnClearBatteryStats.setToolTipText("Clear outdated or invalid battery stats");
    btnClearBatteryStats.setBounds(25, 131, 220, 75);
    panel_8.add(btnClearBatteryStats);
    btnMemoryInformation.setToolTipText("View current memory information of android device");
    btnMemoryInformation.setBounds(25, 236, 220, 75);
    panel_8.add(btnMemoryInformation);

    JButton btnBatteryInformation = new JButton("Battery Information");
    btnBatteryInformation.addActionListener(new ActionListener() {

        public void actionPerformed(ActionEvent e) {
            Batteryinfo obj = new Batteryinfo();
            obj.setVisible(true);
        }
    });
    btnBatteryInformation.setToolTipText("View current battery information of android device");
    btnBatteryInformation.setBounds(541, 27, 220, 75);
    panel_8.add(btnBatteryInformation);

    JButton btnCpuInformation = new JButton("CPU Information");
    btnCpuInformation.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent arg0) {
            CPUinfo obj = new CPUinfo();
            obj.setVisible(true);
        }
    });
    btnCpuInformation.setToolTipText("View current CPU information of android device");
    btnCpuInformation.setBounds(282, 131, 220, 75);
    panel_8.add(btnCpuInformation);

    JButton btnAppInformation = new JButton("App Information");
    btnAppInformation.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent e) {
            Appinfo obj = new Appinfo();
            obj.setVisible(true);
        }
    });
    btnAppInformation.setToolTipText("View current app information of android device");
    btnAppInformation.setBounds(25, 27, 220, 75);
    panel_8.add(btnAppInformation);

    JButton btnKillApps = new JButton("Kill Apps");
    btnKillApps.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent e) {
            String[] options = new String[] { "Enter package name", "Kill all apps" };
            int response = JOptionPane.showOptionDialog(null, "Which app(s) should be killed?", "Kill Apps",
                    JOptionPane.DEFAULT_OPTION, JOptionPane.PLAIN_MESSAGE, null, options, options[0]);
            if (response == 0) {
                try {
                    JOptionPane.showMessageDialog(null,
                            "You can find an app package name from App Packages List");
                    String selectedapp = (JOptionPane.showInputDialog(null, "Enter app's package name:"));
                    Process p1 = Runtime.getRuntime().exec("adb shell am force-stop " + selectedapp);
                    p1.waitFor();
                    JOptionPane.showMessageDialog(null, selectedapp + " has been killed");
                } catch (Exception e1) {
                }
            }
            if (response == 1) {
                try {
                    Process p1 = Runtime.getRuntime().exec("adb shell am kill-all");
                    p1.waitFor();
                    JOptionPane.showMessageDialog(null, "All 'safe to kill' apps have been killed");
                } catch (Exception e1) {
                }
            }
        }
    });
    btnKillApps.setToolTipText("Kill any app currently running on android device");
    btnKillApps.setBounds(541, 131, 220, 75);
    panel_8.add(btnKillApps);

    JButton btnWifiInformation = new JButton("WiFi Information");
    btnWifiInformation.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent e) {
            Wifiinfo obj = new Wifiinfo();
            obj.setVisible(true);
        }
    });
    btnWifiInformation.setToolTipText("View current wifi information of android device");
    btnWifiInformation.setBounds(541, 236, 220, 75);
    panel_8.add(btnWifiInformation);

    JButton btnAppPackageList = new JButton("App Packages List");
    btnAppPackageList.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent e) {
            AppPackagesList obj = new AppPackagesList();
            obj.setVisible(true);
        }
    });
    btnAppPackageList.setToolTipText("View all installed app packages list information");
    btnAppPackageList.setBounds(282, 27, 220, 75);
    panel_8.add(btnAppPackageList);

    JLabel lblAdvancedToolsNote = new JLabel(
            "Note: All of the above tools are not supported by every device or ROM");
    lblAdvancedToolsNote.setBounds(25, 345, 736, 15);
    panel_8.add(lblAdvancedToolsNote);

    JButton btnUnroot = new JButton("Unroot Device");
    btnUnroot.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent e) {
            try {
                File file1 = new File(".events");
                if (!file1.exists()) {
                    List<String> lines = Arrays.asList("Unroot_Warning_Shown = True");
                    Path file = Paths.get(".events");
                    Files.write(file, lines, Charset.forName("UTF-8"));
                    JOptionPane.showMessageDialog(null,
                            "Only the SU Binary will get removed since there are lot of different root management\napplications for android available, I can't regularly search for them and add their\nsupport to this application. If you think this concerns you, you can help me by sending\nme a list of root management applicationsfor android like supersu, kingroot, kingoroot,\netc. But I can't promise that I will add support for each of them. Cheers! :)");
                }
                JOptionPane.showMessageDialog(null, "Unrooting work only on non-production builds of android");
                Process p1 = Runtime.getRuntime().exec("adb pull /system/xbin/su");
                p1.waitFor();
                File file2 = new File("su");
                if (file2.exists() && !file2.isDirectory()) {
                    file2.delete();
                    Process p2 = Runtime.getRuntime().exec("adb remount");
                    p2.waitFor();
                    Process p3 = Runtime.getRuntime().exec("adb shell su -c rm -r /system/xbin/su");
                    p3.waitFor();
                    JOptionPane.showMessageDialog(null, "Operation completed");
                } else {
                    JOptionPane.showMessageDialog(null, "This device is not rooted");
                }
            } catch (Exception e1) {
                e1.printStackTrace();
            }
        }
    });
    btnUnroot.setToolTipText("Unroot device by removing SU binary from the device");
    btnUnroot.setBounds(282, 236, 220, 75);
    panel_8.add(btnUnroot);

    JLabel lblNewLabel_1 = new JLabel(
            "* Needs root access, also may not work with some devices regardless of root access");
    lblNewLabel_1.setBounds(25, 372, 736, 15);
    panel_8.add(lblNewLabel_1);

    JPanel panel_10 = new JPanel();
    panel_10.setBackground(Color.WHITE);
    tabbedPane.addTab("Developer", null, panel_10, null);
    panel_10.setLayout(null);

    JButton btnUnpackAPKs = new JButton("Unpack APKs");
    btnUnpackAPKs.addActionListener(new ActionListener() {
        private Component parentFrame;

        public void actionPerformed(ActionEvent e) {
            File path = null;
            JFileChooser chooser1 = new JFileChooser();
            chooser1.setDialogTitle("Select an APK file to extract");
            FileNameExtensionFilter filter = new FileNameExtensionFilter("APK Files", "apk");
            chooser1.setCurrentDirectory(new java.io.File("."));
            chooser1.setFileFilter(filter);
            int returnVal = chooser1.showOpenDialog(getParent());
            if (returnVal == JFileChooser.APPROVE_OPTION) {
                File file = chooser1.getSelectedFile();
                String filename = chooser1.getSelectedFile().getName();
                JFileChooser chooser2 = new JFileChooser();
                chooser2.setDialogTitle("Extract APK file to");
                chooser2.setCurrentDirectory(new java.io.File("."));
                chooser2.setAcceptAllFileFilterUsed(false);
                chooser2.setFileSelectionMode(JFileChooser.DIRECTORIES_ONLY);
                int userSelection = chooser2.showSaveDialog(parentFrame);
                if (userSelection == JFileChooser.APPROVE_OPTION) {
                    path = chooser2.getSelectedFile();
                }
                String outputDir = path.getAbsolutePath();
                java.util.zip.ZipFile zipFile = null;
                try {
                    zipFile = new ZipFile(file);
                    Enumeration<? extends ZipEntry> entries = zipFile.entries();
                    while (entries.hasMoreElements()) {
                        ZipEntry entry = entries.nextElement();
                        File entryDestination = new File(outputDir, entry.getName());
                        if (entry.isDirectory()) {
                            entryDestination.mkdirs();
                        } else {
                            entryDestination.getParentFile().mkdirs();
                            InputStream in = zipFile.getInputStream(entry);
                            OutputStream out = null;
                            out = new FileOutputStream(entryDestination);
                            IOUtils.copy(in, out);
                            IOUtils.closeQuietly(in);
                            out.close();
                        }
                    }
                    zipFile.close();
                    JOptionPane.showMessageDialog(null, filename + " has been successfully extracted");
                } catch (Exception e1) {
                    e1.printStackTrace();
                    JOptionPane.showMessageDialog(null, "An error occured");
                }
            }
        }
    });
    btnUnpackAPKs.setToolTipText("Unpack APKs stored on disk");
    btnUnpackAPKs.setBounds(541, 27, 220, 75);
    panel_10.add(btnUnpackAPKs);

    JButton btnRepackAPKs = new JButton("Repack APKs");
    btnRepackAPKs.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent e) {
            new Repacker();
        }
    });
    btnRepackAPKs.setToolTipText("Repack previously unpacked APKs and save to them to disk");
    btnRepackAPKs.setBounds(25, 27, 220, 75);
    panel_10.add(btnRepackAPKs);

    JButton btnStartAnActivity = new JButton("Start an activity *");
    btnStartAnActivity.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent e) {
            try {
                String packagename = JOptionPane.showInputDialog(null, "Enter the package name of the app",
                        "com.package.name");
                String activityname = JOptionPane.showInputDialog(null, "Enter the activity name of the app",
                        "MainActivity");
                Process p1 = Runtime.getRuntime().exec("adb shell am start -n " + packagename + "/"
                        + packagename + "com.package.name." + activityname);
                p1.waitFor();
            } catch (Exception e1) {
                e1.printStackTrace();
            }

        }
    });
    btnStartAnActivity.setToolTipText("Start an actvity of an android app on your android device");
    btnStartAnActivity.setBounds(282, 27, 220, 75);
    panel_10.add(btnStartAnActivity);

    JLabel lblActivityWill = new JLabel(
            "* An activity will not start if you enter wrong package name or activity name");
    lblActivityWill.setBounds(25, 381, 736, 15);
    panel_10.add(lblActivityWill);

    JPanel panel_5 = new JPanel();
    panel_5.setBackground(Color.WHITE);
    tabbedPane.addTab("Backup & Restore", null, panel_5, null);
    panel_5.setLayout(null);

    BackupAndRestoreDone = new JLabel("");
    BackupAndRestoreDone.setText("");
    BackupAndRestoreDone.setBounds(758, 70, 300, 220);
    panel_5.add(BackupAndRestoreDone);

    JLabel lblRestoreOperations = new JLabel("Restore Operations");
    lblRestoreOperations.setBounds(541, 12, 142, 36);
    panel_5.add(lblRestoreOperations);

    final JButton btnRestoreFromCustomLocationBackup = new JButton("From Custom Location");
    btnRestoreFromCustomLocationBackup
            .setToolTipText("Restore data to android device from the backup stored somewhere on the computer");
    btnRestoreFromCustomLocationBackup.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent arg0) {
            BackupAndRestoreDone.setText("");
            JFileChooser chooser = new JFileChooser();
            FileNameExtensionFilter filter = new FileNameExtensionFilter("Android Backup Files", "ab");
            chooser.setFileFilter(filter);
            int returnVal = chooser.showOpenDialog(getParent());
            if (returnVal == JFileChooser.APPROVE_OPTION) {
                File file = chooser.getSelectedFile();
                try {
                    ApplicationStatus.setText("Restoring may take upto several minutes, please be patient...");
                    JOptionPane.showMessageDialog(null,
                            "Unlock your device and confirm the restore operation when asked");
                    String[] commands = new String[3];
                    commands[0] = "adb";
                    commands[1] = "restore";
                    commands[2] = file.getAbsolutePath();
                    ApplicationStatus.setText("Restoring...");
                    Process p1 = Runtime.getRuntime().exec(commands, null);
                    p1.waitFor();
                    ApplicationStatus.setText("Restore completed successfully!");
                    BackupAndRestoreDone
                            .setIcon(new ImageIcon(Interface.class.getResource("/graphics/Done.png")));
                    btnRestoreFromCustomLocationBackup.setSelected(false);
                } catch (Exception e1) {
                    System.err.println(e1);
                }
            }
        }
    });

    btnRestoreFromCustomLocationBackup.setBounds(510, 70, 220, 75);
    panel_5.add(btnRestoreFromCustomLocationBackup);

    JLabel lblBackup = new JLabel("Backup Operations");
    lblBackup.setBounds(192, 12, 142, 36);
    panel_5.add(lblBackup);

    final JButton btnBackupInternelStorage = new JButton("Internel Storage");
    btnBackupInternelStorage.setToolTipText("Backup android device internal storage");
    btnBackupInternelStorage.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent arg0) {
            BackupAndRestoreDone.setText("");
            try {
                ApplicationStatus.setText("Backup can take upto several minutes, please be patient...");
                JOptionPane.showMessageDialog(null,
                        "Unlock your device and confirm the backup operation when asked");
                String[] commands = new String[3];
                commands[0] = "adb";
                commands[1] = "backup";
                commands[2] = "-shared";
                ApplicationStatus.setText("Performing backup...");
                Process p1 = Runtime.getRuntime().exec(commands, null);
                p1.waitFor();
                ApplicationStatus.setText("Backup completed successfully!");
                BackupAndRestoreDone.setIcon(new ImageIcon(Interface.class.getResource("/graphics/Done.png")));
                btnBackupInternelStorage.setSelected(false);
            } catch (Exception e1) {
                System.err.println(e1);
            }
        }
    });

    btnBackupInternelStorage.setBounds(270, 70, 220, 75);
    panel_5.add(btnBackupInternelStorage);

    final JButton btnBackupSingleApp = new JButton("Single App");
    btnBackupSingleApp.setToolTipText("Backup a single app from android device");
    btnBackupSingleApp.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent arg0) {
            BackupAndRestoreDone.setText("");
            try {
                String message = JOptionPane.showInputDialog(null, "Please specify a package name to backup");
                ApplicationStatus.setText("Backup can take upto several minutes, please be patient...");
                JOptionPane.showMessageDialog(null,
                        "Unlock your device and confirm the backup operation when asked");
                String[] commands = new String[3];
                commands[0] = "adb";
                commands[1] = "backup";
                commands[2] = message;
                ApplicationStatus.setText("Performing backup...");
                Process p1 = Runtime.getRuntime().exec(commands, null);
                p1.waitFor();
                ApplicationStatus.setText("Backup completed successfully!");
                BackupAndRestoreDone.setIcon(new ImageIcon(Interface.class.getResource("/graphics/Done.png")));
                btnBackupSingleApp.setSelected(false);
            } catch (Exception e1) {
                System.err.println(e1);
            }
        }
    });

    btnBackupSingleApp.setBounds(25, 184, 220, 75);
    panel_5.add(btnBackupSingleApp);

    final JButton btnBackupAppAndAppData = new JButton("App and App Data");
    btnBackupAppAndAppData.setToolTipText("Backup app and it's data from android device");
    btnBackupAppAndAppData.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent arg0) {
            BackupAndRestoreDone.setText("");
            try {
                ApplicationStatus.setText("Backup can take upto several minutes, please be patient...");
                JOptionPane.showMessageDialog(null,
                        "Unlock your device and confirm the backup operation when asked");
                String[] commands = new String[3];
                commands[0] = "adb";
                commands[1] = "backup";
                commands[2] = "-all";
                ApplicationStatus.setText("Performing backup...");
                Process p1 = Runtime.getRuntime().exec(commands, null);
                p1.waitFor();
                ApplicationStatus.setText("Backup completed successfully!");
                BackupAndRestoreDone.setIcon(new ImageIcon(Interface.class.getResource("/graphics/Done.png")));
                btnBackupAppAndAppData.setSelected(false);
            } catch (Exception e1) {
                System.err.println(e1);
            }
        }
    });

    btnBackupAppAndAppData.setBounds(25, 70, 220, 75);
    panel_5.add(btnBackupAppAndAppData);

    final JButton btnBackupWholeDevice = new JButton("Whole Device");
    btnBackupWholeDevice.setToolTipText("Backup whole android device");
    btnBackupWholeDevice.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent arg0) {
            BackupAndRestoreDone.setText("");
            try {
                ApplicationStatus.setText("Backup can take upto several minutes, please be patient...");
                JOptionPane.showMessageDialog(null,
                        "Unlock your device and confirm the backup operation when asked");
                String[] commands = new String[6];
                commands[0] = "adb";
                commands[1] = "backup";
                commands[2] = "-all";
                commands[3] = "-apk";
                commands[4] = "-shared";
                commands[5] = "-system";
                ApplicationStatus.setText("Performing backup...");
                Process p1 = Runtime.getRuntime().exec(commands, null);
                p1.waitFor();
                ApplicationStatus.setText("Backup completed successfully");
                BackupAndRestoreDone.setIcon(new ImageIcon(Interface.class.getResource("/graphics/Done.png")));
                btnBackupWholeDevice.setSelected(false);
            } catch (Exception e1) {
                System.err.println(e1);
            }
        }
    });

    btnBackupWholeDevice.setBounds(25, 303, 220, 75);
    panel_5.add(btnBackupWholeDevice);

    final JButton btnRestorePreviousBackup = new JButton("Previous Backup");
    btnRestorePreviousBackup.setToolTipText("Restore data to android device from the previous backup");
    btnRestorePreviousBackup.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent arg0) {
            BackupAndRestoreDone.setText("");
            try {
                ApplicationStatus.setText("Restoring can take upto several minutes, please be patient...");
                JOptionPane.showMessageDialog(null,
                        "Unlock your device and confirm the restore operation when asked");
                String[] commands = new String[3];
                commands[0] = "adb";
                commands[1] = "restore";
                commands[2] = "backup.ab";
                ApplicationStatus.setText("Restoring...");
                Process p1 = Runtime.getRuntime().exec(commands, null);
                p1.waitFor();
                ApplicationStatus.setText("Restore completed successfully!");
                BackupAndRestoreDone.setIcon(new ImageIcon(Interface.class.getResource("/graphics/Done.png")));
                btnRestorePreviousBackup.setSelected(false);
            } catch (Exception e1) {
                System.err.println(e1);
            }
        }
    });

    btnRestorePreviousBackup.setBounds(510, 184, 220, 75);
    panel_5.add(btnRestorePreviousBackup);

    final JButton btnBackupSystem = new JButton("System");
    btnBackupSystem.setToolTipText("Backup android device system");
    btnBackupSystem.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent arg0) {
            BackupAndRestoreDone.setText("");
            try {
                ApplicationStatus.setText("Backup can take upto several minutes, please be patient...");
                JOptionPane.showMessageDialog(null,
                        "Unlock your device and confirm the backup operation when asked");
                String[] commands = new String[3];
                commands[0] = "adb";
                commands[1] = "backup";
                commands[2] = "-system";
                ApplicationStatus.setText("Performing backup...");
                Process p1 = Runtime.getRuntime().exec(commands, null);
                p1.waitFor();
                ApplicationStatus.setText("Backup completed successfully!");
                BackupAndRestoreDone.setIcon(new ImageIcon(Interface.class.getResource("/graphics/Done.png")));
                btnBackupSystem.setSelected(false);
            } catch (Exception e1) {
                System.err.println(e1);
            }
        }
    });

    btnBackupSystem.setBounds(270, 184, 220, 75);
    panel_5.add(btnBackupSystem);

    JPanel panel_2 = new JPanel();
    panel_2.setBackground(Color.WHITE);
    tabbedPane.addTab("Rebooter", null, panel_2, null);
    panel_2.setLayout(null);

    JLabel lblRebootFrom = new JLabel("Reboot from :");
    lblRebootFrom.setBounds(25, 180, 220, 15);
    panel_2.add(lblRebootFrom);

    JLabel lblRebootTo = new JLabel("Reboot to :");
    lblRebootTo.setBounds(25, 12, 220, 15);
    panel_2.add(lblRebootTo);

    JLabel lblNotFor = new JLabel("# Not for Samsung devices");
    lblNotFor.setBounds(514, 359, 238, 19);
    panel_2.add(lblNotFor);

    JLabel lblDeviceMust_1 = new JLabel("Device must be in fastboot mode (Except for Reboot System)");
    lblDeviceMust_1.setBounds(25, 332, 479, 19);
    panel_2.add(lblDeviceMust_1);

    JLabel lblYouMust_1 = new JLabel("* You must have a bootloader that supports fastboot commands");
    lblYouMust_1.setBounds(25, 359, 470, 19);
    panel_2.add(lblYouMust_1);

    JButton btnRebootFromFastboot = new JButton("Fastboot *");
    btnRebootFromFastboot.setToolTipText("Reboot android device from fastboot mode to normal");
    btnRebootFromFastboot.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent arg0) {
            try {
                ApplicationStatus.setText("Rebooting...");
                Process p1 = Runtime.getRuntime().exec("fastboot reboot");
                p1.waitFor();
                ApplicationStatus.setText("Done");
            } catch (Exception e1) {
                System.err.println(e1);
            }
        }
    });

    btnRebootFromFastboot.setBounds(28, 232, 220, 75);
    panel_2.add(btnRebootFromFastboot);

    JButton btnRebootToBootloaderFromFastboot = new JButton("Fastboot to Bootloader *");
    btnRebootToBootloaderFromFastboot.setToolTipText("Reboot to Bootloader mode while accessing fastboot mode");
    btnRebootToBootloaderFromFastboot.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent arg0) {
            try {
                ApplicationStatus.setText("Rebooting...");
                Process p1 = Runtime.getRuntime().exec("fasboot reboot-bootloader");
                p1.waitFor();
                ApplicationStatus.setText("Done");
            } catch (Exception e1) {
                System.err.println(e1);
            }
        }
    });

    btnRebootToBootloaderFromFastboot.setBounds(281, 232, 220, 75);
    panel_2.add(btnRebootToBootloaderFromFastboot);

    JButton btnRebootToFastboot = new JButton("Fastboot");
    btnRebootToFastboot.setToolTipText("Reboot android device to fastboot mode");
    btnRebootToFastboot.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent arg0) {
            try {
                ApplicationStatus.setText("Rebooting...");
                Process p1 = Runtime.getRuntime().exec("adb reboot fastboot");
                p1.waitFor();
                ApplicationStatus.setText("Done");
            } catch (Exception e1) {
                System.err.println(e1);
            }
        }
    });

    btnRebootToFastboot.setBounds(281, 55, 220, 75);
    panel_2.add(btnRebootToFastboot);

    JButton btnRebootToBootloader = new JButton("Bootloader #");
    btnRebootToBootloader.setToolTipText("Reboot android device to bootloader mode");
    btnRebootToBootloader.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent e) {
            try {
                ApplicationStatus.setText("Rebooting...");
                Process p1 = Runtime.getRuntime().exec("adb reboot bootloader");
                p1.waitFor();
                ApplicationStatus.setText("Done");
            } catch (Exception e1) {
                System.err.println(e1);
            }
        }
    });

    btnRebootToBootloader.setBounds(28, 55, 220, 75);
    panel_2.add(btnRebootToBootloader);

    JButton btnRebootToRecovery = new JButton("Recovery");
    btnRebootToRecovery.setToolTipText("Reboot android device to recovery mode");
    btnRebootToRecovery.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent arg0) {
            try {
                ApplicationStatus.setText("Rebooting...");
                Process p1 = Runtime.getRuntime().exec("adb reboot recovery");
                p1.waitFor();
                ApplicationStatus.setText("Done");
            } catch (Exception e1) {
                System.err.println(e1);
            }
        }
    });

    btnRebootToRecovery.setBounds(532, 55, 220, 75);
    panel_2.add(btnRebootToRecovery);

    JButton btnRebootSystem = new JButton("System");
    btnRebootSystem.setToolTipText("Reboot android device normally");
    btnRebootSystem.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent arg0) {
            try {
                ApplicationStatus.setText("Rebooting...");
                Process p1 = Runtime.getRuntime().exec("adb reboot");
                p1.waitFor();
                ApplicationStatus.setText("Done");
            } catch (Exception e1) {
                System.err.println(e1);
            }
        }
    });

    btnRebootSystem.setBounds(785, 55, 220, 75);
    panel_2.add(btnRebootSystem);

    JPanel panel_9 = new JPanel();
    panel_9.setBackground(Color.WHITE);
    tabbedPane.addTab("Bypass Security", null, panel_9, null);
    panel_9.setLayout(null);

    JLabel lblRootOperationsexperimental = new JLabel(
            "Method #1 : Root Operations (Recommended) [EXPERIMENTAL] :");
    lblRootOperationsexperimental.setBounds(12, 12, 507, 15);
    panel_9.add(lblRootOperationsexperimental);

    JButton btnPattern = new JButton("Pattern #");
    btnPattern.setToolTipText("Remove pattern security from android device (Experimental)");
    btnPattern.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent e) {
            try {
                ApplicationStatus.setText("Trying to break into security...");
                Process p1 = Runtime.getRuntime().exec("adb shell su -c rm /data/system/gesture.key");
                p1.waitFor();
                ApplicationStatus.setText(
                        "Done, now try to unlock the device with a random pattern then change security manually from settings");
            } catch (Exception e1) {
            }
        }
    });

    btnPattern.setBounds(220, 75, 220, 75);
    panel_9.add(btnPattern);

    JButton btnPasswordPin = new JButton("Password/ PIN #");
    btnPasswordPin.setToolTipText("Remove password or pin security from android device (Experimental)");
    btnPasswordPin.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent e) {
            try {
                ApplicationStatus.setText("Trying to break into security...");
                Process p1 = Runtime.getRuntime().exec("adb shell su -c rm /data/system/password.key");
                p1.waitFor();
                ApplicationStatus.setText("Done, check your device...");
            } catch (Exception e1) {
                System.err.println(e1);
            }
        }
    });

    btnPasswordPin.setBounds(630, 75, 220, 75);
    panel_9.add(btnPasswordPin);

    JLabel lblMayNot = new JLabel("# Works on Android 4.4.x and lower");
    lblMayNot.setBounds(630, 250, 366, 15);
    panel_9.add(lblMayNot);

    JLabel lblNonRoot = new JLabel("Method # 2 : Non - Root/ Root Operations [EXPERIMENTAL] :");
    lblNonRoot.setBounds(12, 191, 507, 15);
    panel_9.add(lblNonRoot);

    JButton btnJellyBeanPatternPinPassword = new JButton("Pattern/ PIN/ Password *");
    btnJellyBeanPatternPinPassword
            .setToolTipText("Remove pattern, pin or password security from android device (Experimental)");
    btnJellyBeanPatternPinPassword.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent e) {
            try {
                ApplicationStatus.setText("Trying to break into security...");
                Process p1 = Runtime.getRuntime().exec(
                        "adb shell am start -n com.android.settings/com.android.settings.ChooseLockGeneric --ez confirm_credentials false --ei lockscreen.password_type 0 --activity-clear-task");
                p1.waitFor();
                ApplicationStatus.setText("Rebooting...");
                Process p2 = Runtime.getRuntime().exec("adb reboot");
                p2.waitFor();
                ApplicationStatus.setText("Done, check your device...");
            } catch (Exception e1) {
                System.err.println(e1);
            }
        }
    });

    btnJellyBeanPatternPinPassword.setBounds(220, 250, 220, 75);
    panel_9.add(btnJellyBeanPatternPinPassword);

    JLabel lblWorksWell = new JLabel("* Works well on Jelly Bean Devices but may or");
    lblWorksWell.setBounds(630, 273, 366, 15);
    panel_9.add(lblWorksWell);

    JLabel lblNewLabel = new JLabel("may not work for older/ newer android versions");
    lblNewLabel.setBounds(640, 293, 356, 15);
    panel_9.add(lblNewLabel);

    JPanel panel_4 = new JPanel();
    panel_4.setBackground(Color.WHITE);
    tabbedPane.addTab("Logger", null, panel_4, null);
    panel_4.setLayout(null);

    JScrollPane scrollPane = new JScrollPane();
    scrollPane.setBounds(0, 72, 1072, 285);
    panel_4.add(scrollPane);

    LogViewer = new JTextArea();
    LogViewer.setEditable(false);
    scrollPane.setViewportView(LogViewer);

    JButton btnSaveAsTextFile = new JButton("Save as a text file");
    btnSaveAsTextFile.setToolTipText("Save printed logcat as a text file on computer");
    btnSaveAsTextFile.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent arg0) {
            if (LogViewer.getText().equals("")) {
                JOptionPane.showMessageDialog(null, "No log found, please click view log");
            } else {
                ApplicationStatus.setText("");
                JFrame parentFrame = new JFrame();
                JFileChooser fileChooser = new JFileChooser();
                FileNameExtensionFilter filter = new FileNameExtensionFilter("Text Files", "txt");
                fileChooser.setFileFilter(filter);
                fileChooser.setDialogTitle("Save as a text file");
                int userSelection = fileChooser.showSaveDialog(parentFrame);
                if (userSelection == JFileChooser.APPROVE_OPTION) {
                    File fileToSave = fileChooser.getSelectedFile();
                    FileWriter write = null;
                    try {
                        write = new FileWriter(fileToSave.getAbsolutePath() + ".txt");
                        LogViewer.write(write);
                        ApplicationStatus.setText("Logcat saved");
                    } catch (Exception e) {
                        e.printStackTrace();
                    } finally {
                        if (write != null)
                            try {
                                write.close();
                            } catch (Exception e) {
                                e.printStackTrace();
                            }
                    }
                }
            }
        }
    });

    btnSaveAsTextFile.setBounds(420, 13, 220, 47);
    panel_4.add(btnSaveAsTextFile);

    JButton btnClearLogcat = new JButton("Clear");
    btnClearLogcat.setToolTipText("Clean the printed logcat from the screen");
    btnClearLogcat.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent arg0) {
            LogViewer.setText("");
            File file = new File(".logcat.txt");
            if (file.exists() && !file.isDirectory()) {
                file.delete();
            }
            ApplicationStatus.setText("Logcat cleared");
        }
    });
    btnClearLogcat.setBounds(12, 13, 220, 48);
    panel_4.add(btnClearLogcat);

    JButton btnViewLogcat = new JButton("View Logcat");
    btnViewLogcat.setToolTipText("Print android device logcat on screen");
    btnViewLogcat.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent arg0) {
            ApplicationStatus.setText("Generating logcat, please wait a moment...");
            try {
                Process p1 = Runtime.getRuntime().exec("adb logcat -d > /sdcard/.logcat.txt");
                p1.waitFor();
                Process p2 = Runtime.getRuntime().exec("adb logcat -c");
                p2.waitFor();
                Process p3 = Runtime.getRuntime().exec("adb pull /sdcard/.logcat.txt");
                p3.waitFor();
                Process p4 = Runtime.getRuntime().exec("adb shell rm /sdcard/.logcat.txt");
                p4.waitFor();
                try {
                    Reader reader = new FileReader(new File(".logcat.txt"));
                    LogViewer.read(reader, "");
                } catch (Exception e) {
                    e.printStackTrace();
                }
                File file = new File(".logcat.txt");
                if (file.exists() && !file.isDirectory()) {
                    file.delete();
                }
                ApplicationStatus.setText("");
            } catch (Exception e) {
                System.err.println(e);
            }
        }
    });

    btnViewLogcat.setBounds(838, 13, 220, 47);
    panel_4.add(btnViewLogcat);

    JLabel lblNoteLogcatG = new JLabel(
            "Note: Logcat generation takes some time, program may not respond for a few moments");
    lblNoteLogcatG.setBounds(12, 364, 1046, 15);
    panel_4.add(lblNoteLogcatG);

    JPanel panel = new JPanel();
    panel.setBackground(Color.WHITE);
    tabbedPane.addTab("Flasher", null, panel, null);
    panel.setLayout(null);

    final JButton btnFlashSystem = new JButton("System");
    btnFlashSystem.setToolTipText("Flash system partition");
    btnFlashSystem.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent e) {
            FlasherDone.setText("");
            JFileChooser chooser = new JFileChooser();
            FileNameExtensionFilter filter = new FileNameExtensionFilter("IMG Files", "img");
            chooser.setFileFilter(filter);
            int returnVal = chooser.showOpenDialog(getParent());
            if (returnVal == JFileChooser.APPROVE_OPTION) {
                File file = chooser.getSelectedFile();
                String filename = chooser.getSelectedFile().getName();
                try {
                    ApplicationStatus.setText("Flashing...");
                    Process p1 = Runtime.getRuntime().exec("fastboot erase system");
                    p1.waitFor();
                    String[] commands = new String[4];
                    commands[0] = "fastboot";
                    commands[1] = "flash";
                    commands[2] = "system";
                    commands[3] = file.getAbsolutePath();
                    Process p2 = Runtime.getRuntime().exec(commands, null);
                    p2.waitFor();
                    ApplicationStatus
                            .setText(filename + "has been successfully flashed on your android device");
                    FlasherDone.setIcon(new ImageIcon(Interface.class.getResource("/graphics/Done.png")));
                    btnFlashSystem.setSelected(false);
                } catch (Exception e1) {
                    System.err.println(e1);
                }
            }
        }
    });

    final JButton btnFlashData = new JButton("Data");
    btnFlashData.setToolTipText("Flash data partition");
    btnFlashData.addActionListener(new ActionListener() {

        public void actionPerformed(ActionEvent e) {
            FlasherDone.setText("");
            JFileChooser chooser = new JFileChooser();
            FileNameExtensionFilter filter = new FileNameExtensionFilter("IMG Files", "img");
            chooser.setFileFilter(filter);
            int returnVal = chooser.showOpenDialog(getParent());
            if (returnVal == JFileChooser.APPROVE_OPTION) {
                File file = chooser.getSelectedFile();
                String filename = chooser.getSelectedFile().getName();
                try {
                    ApplicationStatus.setText("Flashing...");
                    Process p1 = Runtime.getRuntime().exec("fastboot erase data");
                    p1.waitFor();
                    String[] commands = new String[4];
                    commands[0] = "fastboot";
                    commands[1] = "flash";
                    commands[2] = "data";
                    commands[3] = file.getAbsolutePath();
                    Process p2 = Runtime.getRuntime().exec(commands, null);
                    p2.waitFor();
                    ApplicationStatus
                            .setText(filename + "has been successfully flashed on your android device");
                    FlasherDone.setIcon(new ImageIcon(Interface.class.getResource("/graphics/Done.png")));
                    btnFlashData.setSelected(false);
                } catch (Exception e1) {
                    System.err.println(e1);
                }
            }
        }
    });

    final JButton btnFlashViaRecovery = new JButton("Flash via Recovery");
    btnFlashViaRecovery.setToolTipText("Flash a zip archive using recovery");
    btnFlashViaRecovery.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent arg0) {
            FlasherDone.setText("");
            JFileChooser chooser = new JFileChooser();
            FileNameExtensionFilter filter = new FileNameExtensionFilter("zip Files", "zip");
            chooser.setFileFilter(filter);
            int returnVal = chooser.showOpenDialog(getParent());
            if (returnVal == JFileChooser.APPROVE_OPTION) {
                File file = chooser.getSelectedFile();
                try {
                    JOptionPane.showMessageDialog(null,
                            "Select Update via ADB from recovery menu using physical keys on your device");
                    String[] commands = new String[3];
                    commands[0] = "adb";
                    commands[1] = "sideload";
                    commands[2] = file.getAbsolutePath();
                    ApplicationStatus.setText("Flashing...");
                    Process p1 = Runtime.getRuntime().exec(commands, null);
                    p1.waitFor();
                    ApplicationStatus.setText("Sideloaded...");
                    FlasherDone.setIcon(new ImageIcon(Interface.class.getResource("/graphics/Done.png")));
                    btnFlashViaRecovery.setSelected(false);
                } catch (Exception e1) {
                    System.err.println(e1);
                }
            }
        }
    });

    FlasherDone = new JLabel("");
    FlasherDone.setText("");
    FlasherDone.setBounds(760, 29, 300, 220);
    panel.add(FlasherDone);
    btnFlashViaRecovery.setBounds(25, 131, 220, 75);
    panel.add(btnFlashViaRecovery);
    btnFlashData.setBounds(541, 27, 220, 75);
    panel.add(btnFlashData);
    btnFlashSystem.setBounds(282, 236, 220, 75);
    panel.add(btnFlashSystem);

    final JButton btnFlashCache = new JButton("Cache");
    btnFlashCache.setToolTipText("Flash cache partition");
    btnFlashCache.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent e) {
            FlasherDone.setText("");
            JFileChooser chooser = new JFileChooser();
            FileNameExtensionFilter filter = new FileNameExtensionFilter("IMG Files", "img");
            chooser.setFileFilter(filter);
            int returnVal = chooser.showOpenDialog(getParent());
            if (returnVal == JFileChooser.APPROVE_OPTION) {
                File file = chooser.getSelectedFile();
                String filename = chooser.getSelectedFile().getName();
                try {
                    ApplicationStatus.setText("Flashing...");
                    Process p1 = Runtime.getRuntime().exec("fastboot erase cache");
                    p1.waitFor();
                    String[] commands = new String[4];
                    commands[0] = "fastboot";
                    commands[1] = "flash";
                    commands[2] = "cache";
                    commands[3] = file.getAbsolutePath();
                    Process p2 = Runtime.getRuntime().exec(commands, null);
                    p2.waitFor();
                    ApplicationStatus
                            .setText(filename + "has been successfully flashed on your android device");
                    FlasherDone.setIcon(new ImageIcon(Interface.class.getResource("/graphics/Done.png")));
                    btnFlashCache.setSelected(false);
                } catch (Exception e1) {
                    System.err.println(e1);
                }
            }
        }
    });

    btnFlashCache.setBounds(282, 27, 220, 75);
    panel.add(btnFlashCache);

    final JButton btnBootImage = new JButton("Boot");
    btnBootImage.setToolTipText("Flash boot partition");
    btnBootImage.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent arg0) {
            FlasherDone.setText("");
            JFileChooser chooser = new JFileChooser();
            FileNameExtensionFilter filter = new FileNameExtensionFilter("IMG Files", "img");
            chooser.setFileFilter(filter);
            int returnVal = chooser.showOpenDialog(getParent());
            if (returnVal == JFileChooser.APPROVE_OPTION) {
                File file = chooser.getSelectedFile();
                String filename = chooser.getSelectedFile().getName();
                try {
                    ApplicationStatus.setText("Flashing...");
                    Process p1 = Runtime.getRuntime().exec("fastboot erase boot");
                    p1.waitFor();
                    String[] commands = new String[4];
                    commands[0] = "fastboot";
                    commands[1] = "flash";
                    commands[2] = "boot";
                    commands[3] = file.getAbsolutePath();
                    Process p2 = Runtime.getRuntime().exec(commands, null);
                    p2.waitFor();
                    ApplicationStatus
                            .setText(filename + "has been successfully flashed on your android device");
                    FlasherDone.setIcon(new ImageIcon(Interface.class.getResource("/graphics/Done.png")));
                    btnBootImage.setSelected(false);
                } catch (Exception e1) {
                    System.err.println(e1);
                }
            }
        }
    });

    btnBootImage.setBounds(25, 27, 220, 75);
    panel.add(btnBootImage);

    final JButton btnFlashZipArchive = new JButton("Zip Archive");
    btnFlashZipArchive.setToolTipText("Flash a zip archive");
    btnFlashZipArchive.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent e) {
            FlasherDone.setText("");
            JFileChooser chooser = new JFileChooser();
            FileNameExtensionFilter filter = new FileNameExtensionFilter("zip Files", "zip");
            chooser.setFileFilter(filter);
            int returnVal = chooser.showOpenDialog(getParent());
            if (returnVal == JFileChooser.APPROVE_OPTION) {
                File file = chooser.getSelectedFile();
                String filename = chooser.getSelectedFile().getName();
                try {
                    ApplicationStatus.setText("Flashing...");
                    String[] commands = new String[3];
                    commands[0] = "fastboot";
                    commands[1] = "flash";
                    commands[2] = file.getAbsolutePath();
                    Process p1 = Runtime.getRuntime().exec(commands, null);
                    p1.waitFor();
                    ApplicationStatus
                            .setText(filename + "has been successfully flashed on your android device");
                    FlasherDone.setIcon(new ImageIcon(Interface.class.getResource("/graphics/Done.png")));
                    btnFlashZipArchive.setSelected(false);
                } catch (Exception e1) {
                    System.err.println(e1);
                }
            }
        }
    });

    btnFlashZipArchive.setBounds(541, 236, 220, 75);
    panel.add(btnFlashZipArchive);

    final JButton btnFlashRecovery = new JButton("Recovery");
    btnFlashRecovery.setToolTipText("Flash recovery partition");
    btnFlashRecovery.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent arg0) {
            FlasherDone.setText("");
            JFileChooser chooser = new JFileChooser();
            FileNameExtensionFilter filter = new FileNameExtensionFilter("IMG Files", "img");
            chooser.setFileFilter(filter);
            int returnVal = chooser.showOpenDialog(getParent());
            if (returnVal == JFileChooser.APPROVE_OPTION) {
                File file = chooser.getSelectedFile();
                String filename = chooser.getSelectedFile().getName();
                try {
                    ApplicationStatus.setText("Flashing...");
                    Process p1 = Runtime.getRuntime().exec("fastboot erase recovery");
                    p1.waitFor();
                    String[] commands = new String[4];
                    commands[0] = "fastboot";
                    commands[1] = "flash";
                    commands[2] = "recovery";
                    commands[3] = file.getAbsolutePath();
                    Process p2 = Runtime.getRuntime().exec(commands, null);
                    p2.waitFor();
                    ApplicationStatus
                            .setText(filename + "has been successfully flashed on your android device");
                    FlasherDone.setIcon(new ImageIcon(Interface.class.getResource("/graphics/Done.png")));
                    btnFlashRecovery.setSelected(false);
                } catch (Exception e1) {
                    System.err.println(e1);
                }
            }
        }
    });

    btnFlashRecovery.setBounds(541, 131, 220, 75);
    panel.add(btnFlashRecovery);

    JLabel lblYouMust = new JLabel(
            "Note: Your device's bootloader must support fastboot commands and should be in fastboot mode");
    lblYouMust.setBounds(25, 356, 835, 19);
    panel.add(lblYouMust);

    final JButton btnFlashSplash = new JButton("Splash");
    btnFlashSplash.setToolTipText("Flash splash partition");
    btnFlashSplash.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent e) {
            FlasherDone.setIcon(new ImageIcon(Interface.class.getResource("/graphics/Done.png")));
            JFileChooser chooser = new JFileChooser();
            FileNameExtensionFilter filter = new FileNameExtensionFilter("IMG Files", "img");
            chooser.setFileFilter(filter);
            int returnVal = chooser.showOpenDialog(getParent());
            if (returnVal == JFileChooser.APPROVE_OPTION) {
                File file = chooser.getSelectedFile();
                String filename = chooser.getSelectedFile().getName();
                try {
                    ApplicationStatus.setText("Flashing...");
                    Process p1 = Runtime.getRuntime().exec("fastboot erase splash");
                    p1.waitFor();
                    String[] commands = new String[4];
                    commands[0] = "fastboot";
                    commands[1] = "flash";
                    commands[2] = "splash";
                    commands[3] = file.getAbsolutePath();
                    Process p2 = Runtime.getRuntime().exec(commands, null);
                    p2.waitFor();
                    ApplicationStatus
                            .setText(filename + "has been successfully flashed on your android device");
                    FlasherDone.setIcon(new ImageIcon(Interface.class.getResource("/graphics/Done.png")));
                    btnFlashSplash.setSelected(false);
                } catch (Exception e1) {
                    System.err.println(e1);
                }
            }
        }
    });

    btnFlashSplash.setBounds(25, 236, 220, 75);
    panel.add(btnFlashSplash);

    JButton btnFlashRadio = new JButton("Radio");
    btnFlashRadio.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent e) {
            FlasherDone.setIcon(new ImageIcon(Interface.class.getResource("/graphics/Done.png")));
            JFileChooser chooser = new JFileChooser();
            FileNameExtensionFilter filter = new FileNameExtensionFilter("IMG Files", "img");
            chooser.setFileFilter(filter);
            int returnVal = chooser.showOpenDialog(getParent());
            if (returnVal == JFileChooser.APPROVE_OPTION) {
                File file = chooser.getSelectedFile();
                String filename = chooser.getSelectedFile().getName();
                try {
                    ApplicationStatus.setText("Flashing...");
                    Process p1 = Runtime.getRuntime().exec("fastboot erase radio");
                    p1.waitFor();
                    String[] commands = new String[4];
                    commands[0] = "fastboot";
                    commands[1] = "flash";
                    commands[2] = "radio";
                    commands[3] = file.getAbsolutePath();
                    Process p2 = Runtime.getRuntime().exec(commands, null);
                    p2.waitFor();
                    ApplicationStatus
                            .setText(filename + "has been successfully flashed on your android device");
                    FlasherDone.setIcon(new ImageIcon(Interface.class.getResource("/graphics/Done.png")));
                    btnFlashSplash.setSelected(false);
                } catch (Exception e1) {
                    System.err.println(e1);
                }
            }
        }
    });
    btnFlashRadio.setToolTipText("Flash radio partition");
    btnFlashRadio.setBounds(282, 131, 220, 75);
    panel.add(btnFlashRadio);

    JPanel panel_1 = new JPanel();
    panel_1.setBackground(Color.WHITE);
    tabbedPane.addTab("Wiper", null, panel_1, null);
    panel_1.setLayout(null);

    WiperDone = new JLabel("");
    WiperDone.setText("");
    WiperDone.setBounds(758, 26, 300, 220);
    panel_1.add(WiperDone);

    JLabel label_13 = new JLabel("** Device must be rooted");
    label_13.setBounds(25, 336, 252, 19);
    panel_1.add(label_13);

    JButton btnWipeRecovery = new JButton("Recovery");
    btnWipeRecovery.setToolTipText("Wipe recovery partition");
    btnWipeRecovery.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent e) {
            WiperDone.setText("");
            try {
                ApplicationStatus.setText("Wiping...");
                Process p1 = Runtime.getRuntime().exec("fastboot erase cache");
                p1.waitFor();
                ApplicationStatus.setText("Recovery has been wiped");
                WiperDone.setIcon(new ImageIcon(Interface.class.getResource("/graphics/Done.png")));
            } catch (Exception e1) {
                System.err.println(e1);
            }
        }
    });

    btnWipeRecovery.setBounds(541, 131, 220, 75);
    panel_1.add(btnWipeRecovery);

    JButton btnWipeBoot = new JButton("Boot");
    btnWipeBoot.setToolTipText("Flash boot partition");
    btnWipeBoot.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent e) {
            WiperDone.setText("");
            try {
                ApplicationStatus.setText("Wiping...");
                Process p1 = Runtime.getRuntime().exec("fastboot erase boot");
                p1.waitFor();
                ApplicationStatus.setText("Boot has been wiped");
                WiperDone.setIcon(new ImageIcon(Interface.class.getResource("/graphics/Done.png")));
            } catch (Exception e1) {
                System.err.println(e1);
            }
        }
    });

    btnWipeBoot.setBounds(25, 27, 220, 75);
    panel_1.add(btnWipeBoot);

    JButton btnWipeSystem = new JButton("System");
    btnWipeSystem.setToolTipText("Wipe system partition");
    btnWipeSystem.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent arg0) {
            WiperDone.setText("");
            try {
                ApplicationStatus.setText("Wiping...");
                Process p1 = Runtime.getRuntime().exec("fastboot erase system");
                p1.waitFor();
                ApplicationStatus.setText("System has been wiped");
                WiperDone.setIcon(new ImageIcon(Interface.class.getResource("/graphics/Done.png")));
            } catch (Exception e1) {
                System.err.println(e1);
            }
        }
    });

    btnWipeSystem.setBounds(282, 236, 220, 75);
    panel_1.add(btnWipeSystem);

    JButton btnWipeSplash = new JButton("Splash");
    btnWipeSplash.setToolTipText("Wipe splash partition");
    btnWipeSplash.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent arg0) {
            WiperDone.setText("");
            try {
                ApplicationStatus.setText("Wiping...");
                Process p1 = Runtime.getRuntime().exec("fastboot erase splash");
                p1.waitFor();
                ApplicationStatus.setText("Splash has been wiped");
                WiperDone.setIcon(new ImageIcon(Interface.class.getResource("/graphics/Done.png")));
            } catch (Exception e1) {
                System.err.println(e1);
            }
        }
    });

    btnWipeSplash.setBounds(25, 236, 220, 75);
    panel_1.add(btnWipeSplash);

    JButton btnWipeData = new JButton("Data");
    btnWipeData.setToolTipText("Wipe data partition");
    btnWipeData.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent arg0) {
            WiperDone.setText("");
            try {
                ApplicationStatus.setText("Wiping...");
                Process p1 = Runtime.getRuntime().exec("fastboot erase data");
                p1.waitFor();
                ApplicationStatus.setText("Data has been wiped");
                WiperDone.setIcon(new ImageIcon(Interface.class.getResource("/graphics/Done.png")));
            } catch (Exception e1) {
                System.err.println(e1);
            }
        }
    });

    btnWipeData.setBounds(25, 131, 220, 75);
    panel_1.add(btnWipeData);

    JButton btnFlashDalvikCache = new JButton("Dalvik Cache **");
    btnFlashDalvikCache.setToolTipText("Wipe dalvik cache");
    btnFlashDalvikCache.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent e) {
            WiperDone.setText("");
            try {
                ApplicationStatus.setText("Wiping...");
                Process p1 = Runtime.getRuntime().exec("adb shell su -c rm * /data/dalvik-cache");
                p1.waitFor();
                Process p2 = Runtime.getRuntime().exec("adb shell su -c rm * /cache/dalvik-cache");
                p2.waitFor();
                ApplicationStatus.setText("Dalvik Cache has been wiped! Now rebooting device...");
                Process p3 = Runtime.getRuntime().exec("adb reboot");
                p3.waitFor();
                ApplicationStatus.setText("Done");
                WiperDone.setIcon(new ImageIcon(Interface.class.getResource("/graphics/Done.png")));
            } catch (Exception e1) {
                System.err.println(e1);
            }
        }
    });

    btnFlashDalvikCache.setBounds(541, 27, 220, 75);
    panel_1.add(btnFlashDalvikCache);

    JButton btnWipeCache = new JButton("Cache");
    btnWipeCache.setToolTipText("Wipe cache partition");
    btnWipeCache.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent arg0) {
            WiperDone.setText("");
            try {
                ApplicationStatus.setText("Wiping...");
                Process p1 = Runtime.getRuntime().exec("fastboot erase cache");
                p1.waitFor();
                ApplicationStatus.setText("Cache has been wiped! Now rebooting device...");
                Process p2 = Runtime.getRuntime().exec("adb reboot");
                p2.waitFor();
                ApplicationStatus.setText("Done");
                WiperDone.setIcon(new ImageIcon(Interface.class.getResource("/graphics/Done.png")));
            } catch (Exception e1) {
                System.err.println(e1);
            }
        }
    });

    btnWipeCache.setBounds(282, 27, 220, 75);
    panel_1.add(btnWipeCache);

    JButton btnWipeRadio = new JButton("Radio");
    btnWipeRadio.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent e) {
            WiperDone.setText("");
            try {
                ApplicationStatus.setText("Wiping...");
                Process p1 = Runtime.getRuntime().exec("fastboot erase radio");
                p1.waitFor();
                ApplicationStatus.setText("Radio has been wiped");
                WiperDone.setIcon(new ImageIcon(Interface.class.getResource("/graphics/Done.png")));
            } catch (Exception e1) {
                System.err.println(e1);
            }
        }
    });
    btnWipeRadio.setToolTipText("Wipe radio partition");
    btnWipeRadio.setBounds(282, 131, 220, 75);
    panel_1.add(btnWipeRadio);

    JLabel lblNoteYourDevices = new JLabel(
            "Note: Your device's bootloader must support fastboot commands and should be in fastboot mode");
    lblNoteYourDevices.setBounds(25, 357, 835, 19);
    panel_1.add(lblNoteYourDevices);

    JPanel panel_3 = new JPanel();
    panel_3.setBackground(Color.WHITE);
    tabbedPane.addTab("Bootloader", null, panel_3, null);
    panel_3.setLayout(null);

    JLabel label_17 = new JLabel("Note: Don't worry if the app says to connect your device while");
    label_17.setBounds(66, 320, 600, 19);
    panel_3.add(label_17);

    JLabel label_18 = new JLabel("android is not booted ex. fastboot, bootloader, booting etc.");
    label_18.setBounds(66, 337, 600, 19);
    panel_3.add(label_18);

    JLabel lblOnlyForNexus = new JLabel(
            "Works only with specific devices ex. Nexus, Android One, FEW MTK devices etc.");
    lblOnlyForNexus.setBounds(66, 351, 600, 24);
    panel_3.add(lblOnlyForNexus);

    JButton btnUnlockBootloader = new JButton("Unlock Bootloader");
    btnUnlockBootloader.setToolTipText("Unlock android device bootloader");
    btnUnlockBootloader.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent arg0) {
            try {
                ApplicationStatus.setText(
                        "Unlocking bootloader will factory reset your device and may void your device warranty!");
                JOptionPane.showMessageDialog(null,
                        "You will need to re-enable USB debugging later as your device will get factory reset");
                Process p1 = Runtime.getRuntime().exec("adb reboot bootloader");
                p1.waitFor();
                Process p2 = Runtime.getRuntime().exec("fastboot oem unlock");
                p2.waitFor();
            } catch (Exception e1) {
                System.err.println(e1);
            }
        }
    });

    btnUnlockBootloader.setBounds(282, 27, 220, 75);
    panel_3.add(btnUnlockBootloader);

    JButton btnLockBootloader = new JButton("Lock Bootloader");
    btnLockBootloader.setToolTipText("Lock android device bootloader");
    btnLockBootloader.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent arg0) {
            try {
                Process p1 = Runtime.getRuntime().exec("adb reboot bootloader");
                p1.waitFor();
                Process p2 = Runtime.getRuntime().exec("fastboot oem lock");
                p2.waitFor();
            } catch (Exception e1) {
                System.err.println(e1);
            }
        }
    });

    btnLockBootloader.setBounds(25, 27, 220, 75);
    panel_3.add(btnLockBootloader);

    JPanel panel_6 = new JPanel();
    panel_6.setBackground(Color.WHITE);
    tabbedPane.addTab("Crypto", null, panel_6, null);
    panel_6.setLayout(null);

    JButton btnSHA512 = new JButton("SHA-512");
    btnSHA512.setToolTipText("Calculate SHA-512 sum of a file");
    btnSHA512.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent arg0) {
            JFileChooser chooser = new JFileChooser();
            int returnVal = chooser.showOpenDialog(getParent());
            if (returnVal == JFileChooser.APPROVE_OPTION) {
                File file = new File("");
                ApplicationStatus.setText("Calculating...");
                CalculatedCrypto.setText(DigestUtils.sha512Hex(file.getAbsolutePath()));
                ApplicationStatus.setText("");
            }
        }
    });

    btnSHA512.setBounds(541, 131, 220, 75);
    panel_6.add(btnSHA512);

    JScrollPane scrollPane_2 = new JScrollPane();
    scrollPane_2.setBounds(12, 332, 900, 25);
    panel_6.add(scrollPane_2);

    InputCrypto = new JTextArea();
    InputCrypto.setToolTipText("Input sum to be compared with calculated sum");
    scrollPane_2.setViewportView(InputCrypto);

    JLabel lblLabelCalculatedSum = new JLabel("Calculated Sum :");
    lblLabelCalculatedSum.setBounds(12, 240, 235, 17);
    panel_6.add(lblLabelCalculatedSum);

    JScrollPane scrollPane_1 = new JScrollPane();
    scrollPane_1.setVerticalScrollBarPolicy(ScrollPaneConstants.VERTICAL_SCROLLBAR_NEVER);
    scrollPane_1.setBounds(12, 268, 900, 28);
    panel_6.add(scrollPane_1);

    CalculatedCrypto = new JTextArea();
    CalculatedCrypto.setToolTipText("Calclated sum");
    scrollPane_1.setViewportView(CalculatedCrypto);
    CalculatedCrypto.setEditable(false);

    JButton btnSHA384 = new JButton("SHA-384");
    btnSHA384.setToolTipText("Calculate SHA-384 sum of a file");
    btnSHA384.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent arg0) {
            JFileChooser chooser = new JFileChooser();
            int returnVal = chooser.showOpenDialog(getParent());
            if (returnVal == JFileChooser.APPROVE_OPTION) {
                File file = new File("");
                ApplicationStatus.setText("Calculating...");
                CalculatedCrypto.setText(DigestUtils.sha384Hex(file.getAbsolutePath()));
                ApplicationStatus.setText("");
            }
        }
    });

    btnSHA384.setBounds(282, 131, 220, 75);
    panel_6.add(btnSHA384);

    JButton btnSHA256 = new JButton("SHA-256");
    btnSHA256.setToolTipText("Calculate SHA-256 sum of a file");
    btnSHA256.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent arg0) {
            JFileChooser chooser = new JFileChooser();
            int returnVal = chooser.showOpenDialog(getParent());
            if (returnVal == JFileChooser.APPROVE_OPTION) {
                File file = new File("");
                ApplicationStatus.setText("Calculating...");
                CalculatedCrypto.setText(DigestUtils.sha256Hex(file.getAbsolutePath()));
                ApplicationStatus.setText("");
            }
        }
    });

    btnSHA256.setBounds(25, 131, 220, 75);
    panel_6.add(btnSHA256);

    JButton btnSHA1 = new JButton("SHA-1");
    btnSHA1.setToolTipText("Calculate SHA-1 sum of a file");
    btnSHA1.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent arg0) {
            JFileChooser chooser = new JFileChooser();
            int returnVal = chooser.showOpenDialog(getParent());
            if (returnVal == JFileChooser.APPROVE_OPTION) {
                File file = new File("");
                ApplicationStatus.setText("Calculating...");
                CalculatedCrypto.setText(DigestUtils.sha1Hex(file.getAbsolutePath()));
                ApplicationStatus.setText("");
            }
        }
    });

    btnSHA1.setBounds(541, 27, 220, 75);
    panel_6.add(btnSHA1);

    JButton btnMD5 = new JButton("MD5");
    btnMD5.setToolTipText("Calculate MD5 sum of a file");
    btnMD5.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent arg0) {
            JFileChooser chooser = new JFileChooser();
            int returnVal = chooser.showOpenDialog(getParent());
            if (returnVal == JFileChooser.APPROVE_OPTION) {
                File file = new File("");
                ApplicationStatus.setText("Calculating...");
                CalculatedCrypto.setText(DigestUtils.md5Hex(file.getAbsolutePath()));
                ApplicationStatus.setText("");
            }
        }
    });

    btnMD5.setBounds(282, 27, 220, 75);
    panel_6.add(btnMD5);

    JLabel lblInputSumTo = new JLabel("Input Sum to be compared :");
    lblInputSumTo.setBounds(12, 308, 235, 15);
    panel_6.add(lblInputSumTo);

    JButton btnCompare = new JButton("Compare");
    btnCompare.setToolTipText("Click to compare calculated sum and input sum");
    btnCompare.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent e) {
            if (InputCrypto.getText().equals("")) {
                JOptionPane.showMessageDialog(null, "Please select algorithm and a file");
            }
            if (CalculatedCrypto.getText().equals("")) {
                JOptionPane.showMessageDialog(null, "Please input a sum to be compared");
            } else {
                if (InputCrypto.getText().equalsIgnoreCase(CalculatedCrypto.getText())) {
                    JOptionPane.showMessageDialog(null, "Both sums are matched");
                } else {
                    JOptionPane.showMessageDialog(null, "Sums are not matched!");
                }
            }
        }
    });
    btnCompare.setBounds(924, 268, 134, 89);
    panel_6.add(btnCompare);

    JButton btnClearCalculatedCrypto = new JButton("Clear");
    btnClearCalculatedCrypto.setToolTipText("Clear the calculated sum");
    btnClearCalculatedCrypto.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent e) {
            CalculatedCrypto.setText("");
            InputCrypto.setText("");
        }
    });
    btnClearCalculatedCrypto.setBounds(25, 27, 220, 75);
    panel_6.add(btnClearCalculatedCrypto);

    JLabel label_2 = new JLabel("");
    label_2.setBounds(50, 0, 1038, 256);
    label_2.setIcon(new ImageIcon(Interface.class.getResource("/graphics/Interface_logo.png")));
    contentPane.add(label_2);

    new Updater();

    Thread t = new Thread(r); // Background services
    t.start();

    Runtime.getRuntime().addShutdownHook(new Thread() { // Exit sequence
        public void run() {
            try {
                System.out.println("Killing ADB instance...");
                Process p1 = Runtime.getRuntime().exec("adb kill-server");
                p1.waitFor();
                System.out.println("Cleaning cache...");
                File file2 = new File(".CheckADBConnection");
                if (file2.exists() && !file2.isDirectory()) {
                    file2.delete();
                }
                File file3 = new File("su");
                if (file3.exists() && !file3.isDirectory()) {
                    file3.delete();
                }
                File file4 = new File(".logcat.txt");
                if (file4.exists() && !file4.isDirectory()) {
                    file4.delete();
                }
                File file5 = new File(".userapps.txt");
                if (file5.exists() && !file5.isDirectory()) {
                    file5.delete();
                }
                File file6 = new File(".privapps.txt");
                if (file6.exists() && !file6.isDirectory()) {
                    file6.delete();
                }
                File file7 = new File(".systemapps.txt");
                if (file7.exists() && !file7.isDirectory()) {
                    file4.delete();
                }
                System.out.println("Droid PC Suite terminated");
            } catch (Exception e1) {
                e1.printStackTrace();
            }
        }
    });
}

From source file:com.mirth.connect.client.ui.Frame.java

/**
 * Builds the content panel with a title bar and settings.
 *//*from w ww.  j a v  a2s .c o  m*/
private void buildContentPanel(JXTitledPanel container, JScrollPane component, boolean opaque) {
    container.getContentContainer().setLayout(new BorderLayout());
    container.setBorder(null);
    container.setTitleFont(new Font("Tahoma", Font.BOLD, 18));
    container.setTitleForeground(UIConstants.HEADER_TITLE_TEXT_COLOR);
    JLabel mirthConnectImage = new JLabel();
    mirthConnectImage.setIcon(UIConstants.MIRTHCONNECT_LOGO_GRAY);
    mirthConnectImage.setText(" ");
    mirthConnectImage.setToolTipText(UIConstants.MIRTHCONNECT_TOOLTIP);
    mirthConnectImage.setCursor(new Cursor(Cursor.HAND_CURSOR));

    mirthConnectImage.addMouseListener(new java.awt.event.MouseAdapter() {

        public void mouseClicked(java.awt.event.MouseEvent evt) {
            BareBonesBrowserLaunch.openURL(UIConstants.MIRTHCONNECT_URL);
        }
    });

    ((JPanel) container.getComponent(0)).add(mirthConnectImage);

    component.setBorder(new LineBorder(Color.GRAY, 1));
    component.setHorizontalScrollBarPolicy(JScrollPane.HORIZONTAL_SCROLLBAR_NEVER);
    component.setVerticalScrollBarPolicy(JScrollPane.VERTICAL_SCROLLBAR_NEVER);

    container.getContentContainer().add(component);
}

From source file:net.sourceforge.pmd.cpd.GUI.java

private JPanel makeResultsPanel() {
    JPanel resultsPanel = new JPanel();
    resultsPanel.setLayout(new BorderLayout());
    JScrollPane areaScrollPane = new JScrollPane(resultsTextArea);
    resultsTextArea.setEditable(false);/*w w w.ja va2s  . co m*/
    areaScrollPane.setVerticalScrollBarPolicy(ScrollPaneConstants.VERTICAL_SCROLLBAR_ALWAYS);
    areaScrollPane.setPreferredSize(new Dimension(600, 300));

    resultsPanel.add(makeMatchList(), BorderLayout.WEST);
    resultsPanel.add(areaScrollPane, BorderLayout.CENTER);
    return resultsPanel;
}

From source file:net.sourceforge.pmd.util.designer.Designer.java

private JPanel createXPathQueryPanel() {
    JPanel p = new JPanel();
    p.setLayout(new BorderLayout());
    xpathQueryArea.setBorder(BorderFactory.createLineBorder(Color.black));
    makeTextComponentUndoable(xpathQueryArea);
    JScrollPane scrollPane = new JScrollPane(xpathQueryArea);
    scrollPane.setHorizontalScrollBarPolicy(ScrollPaneConstants.HORIZONTAL_SCROLLBAR_AS_NEEDED);
    scrollPane.setVerticalScrollBarPolicy(ScrollPaneConstants.VERTICAL_SCROLLBAR_AS_NEEDED);
    final JButton b = createGoButton();

    JPanel topPanel = new JPanel();
    topPanel.setLayout(new BorderLayout());
    topPanel.add(new JLabel("XPath Query (if any):"), BorderLayout.WEST);
    topPanel.add(createXPathVersionPanel(), BorderLayout.EAST);

    p.add(topPanel, BorderLayout.NORTH);
    p.add(scrollPane, BorderLayout.CENTER);
    p.add(b, BorderLayout.SOUTH);

    return p;/*  ww  w  . j  a va2 s  .co  m*/
}

From source file:nl.detoren.ijsco.ui.Mainscreen.java

public JPanel createPanelGroepen() {
    JPanel panel = new JPanel();
    panel.setLayout(new GridLayout(1, 0));
    groepenText = new JTextArea(40, 40);
    groepenText.setBorder(BorderFactory.createLineBorder(Color.BLACK));
    groepenText.setFont(new Font("courier new", Font.PLAIN, 12));
    groepenText.setLineWrap(false);//  w  ww .ja v a  2 s .com
    if (status.groepen != null) {
        groepenText.setText(status.groepen.getDescription());
        groepenText.setCaretPosition(0);
    }
    JScrollPane scrollpane = new JScrollPane(groepenText);
    scrollpane.setAutoscrolls(true);
    scrollpane.setVerticalScrollBarPolicy(ScrollPaneConstants.VERTICAL_SCROLLBAR_ALWAYS);
    panel.add(scrollpane);
    return panel;
}

From source file:nz.govt.natlib.ndha.manualdeposit.metadata.MetaDataConfigurator.java

private void initComponents() {

    tabMain = new javax.swing.JTabbedPane();
    pnlApplicationData = new javax.swing.JPanel();
    pnlUsers = new javax.swing.JPanel();
    pnlUserGroupData = new javax.swing.JPanel();
    pnlMetaData = new javax.swing.JPanel();
    pnlSipStatusData = new javax.swing.JPanel();

    setTitle("Indigo MetaData Configurator");
    setDefaultCloseOperation(3);/*  w w  w. j  a  va 2  s. co m*/
    addWindowListener(new java.awt.event.WindowAdapter() {
        public void windowOpened(java.awt.event.WindowEvent evt) {
            formWindowOpened(evt);
        }

        public void windowClosing(java.awt.event.WindowEvent evt) {
            formWindowClosing(evt);
        }
    });

    javax.swing.GroupLayout pnlApplicationDataLayout = new javax.swing.GroupLayout(pnlApplicationData);
    pnlApplicationData.setLayout(pnlApplicationDataLayout);
    pnlApplicationDataLayout.setHorizontalGroup(pnlApplicationDataLayout
            .createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING).addGap(0, 884, Short.MAX_VALUE));
    pnlApplicationDataLayout.setVerticalGroup(pnlApplicationDataLayout
            .createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING).addGap(0, 429, Short.MAX_VALUE));

    tabMain.addTab("Maintain Application Data", pnlApplicationData);

    javax.swing.GroupLayout pnlUsersLayout = new javax.swing.GroupLayout(pnlUsers);
    pnlUsers.setLayout(pnlUsersLayout);
    pnlUsersLayout.setHorizontalGroup(pnlUsersLayout
            .createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING).addGap(0, 884, Short.MAX_VALUE));
    pnlUsersLayout.setVerticalGroup(pnlUsersLayout
            .createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING).addGap(0, 429, Short.MAX_VALUE));

    tabMain.addTab("Maintain Users", pnlUsers);

    javax.swing.GroupLayout pnlUserGroupDataLayout = new javax.swing.GroupLayout(pnlUserGroupData);
    pnlUserGroupData.setLayout(pnlUserGroupDataLayout);
    pnlUserGroupDataLayout.setHorizontalGroup(pnlUserGroupDataLayout
            .createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING).addGap(0, 884, Short.MAX_VALUE));
    pnlUserGroupDataLayout.setVerticalGroup(pnlUserGroupDataLayout
            .createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING).addGap(0, 429, Short.MAX_VALUE));

    tabMain.addTab("User Group Data", pnlUserGroupData);

    javax.swing.GroupLayout pnlMetaDataLayout = new javax.swing.GroupLayout(pnlMetaData);
    pnlMetaData.setLayout(pnlMetaDataLayout);
    pnlMetaDataLayout.setHorizontalGroup(pnlMetaDataLayout
            .createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING).addGap(0, 884, Short.MAX_VALUE));
    pnlMetaDataLayout.setVerticalGroup(pnlMetaDataLayout
            .createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING).addGap(0, 429, Short.MAX_VALUE));

    tabMain.addTab("Maintain Meta Data", pnlMetaData);

    javax.swing.GroupLayout pnlSipStatusDataLayout = new javax.swing.GroupLayout(pnlSipStatusData);
    pnlSipStatusData.setLayout(pnlSipStatusDataLayout);
    pnlSipStatusDataLayout.setHorizontalGroup(pnlSipStatusDataLayout
            .createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING).addGap(0, 884, Short.MAX_VALUE));
    pnlSipStatusDataLayout.setVerticalGroup(pnlSipStatusDataLayout
            .createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING).addGap(0, 429, Short.MAX_VALUE));

    tabMain.addTab("Maintain SIP status definitions", pnlSipStatusData);

    // Added by Ben - 6.12.2013
    // Surround main content in a scroll pane - to handle display on smaller screen resolutions.
    tabMain.setTabLayoutPolicy(JTabbedPane.SCROLL_TAB_LAYOUT);
    javax.swing.JScrollPane scrollFrame = new JScrollPane(tabMain);
    tabMain.setAutoscrolls(true);
    scrollFrame.setHorizontalScrollBarPolicy(JScrollPane.HORIZONTAL_SCROLLBAR_ALWAYS);
    scrollFrame.setVerticalScrollBarPolicy(JScrollPane.VERTICAL_SCROLLBAR_ALWAYS);

    javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
    getContentPane().setLayout(layout);
    layout.setHorizontalGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addComponent(scrollFrame, javax.swing.GroupLayout.DEFAULT_SIZE, 889, Short.MAX_VALUE));
    layout.setVerticalGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addComponent(scrollFrame, javax.swing.GroupLayout.DEFAULT_SIZE, 454, Short.MAX_VALUE));

    pack();
}