Java Code Examples for java.awt.Component#getName()

The following examples show how to use java.awt.Component#getName() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: PopupDuplicateScript.java    From zap-extensions with Apache License 2.0 6 votes vote down vote up
@Override
public boolean isEnableForComponent(Component invoker) {
    if (invoker.getName() != null && invoker.getName().equals(ScriptsListPanel.TREE)) {
        try {
            JTree tree = (JTree) invoker;
            ScriptNode node = (ScriptNode) tree.getLastSelectedPathComponent();

            if (node == null
                    || node.isTemplate()
                    || node.getUserObject() == null
                    || !(node.getUserObject() instanceof ScriptWrapper)) {
                return false;
            }

            if (((ScriptWrapper) node.getUserObject()).getEngine() == null) {
                return false;
            }

            return extension.getScriptsPanel().getSelectedScript() != null;
        } catch (Exception e) {
        }
    }
    return false;
}
 
Example 2
Source File: BaseWizardIterator.java    From netbeans with Apache License 2.0 6 votes vote down vote up
private void updateSteps() {
    // Make sure list of steps is accurate.
    String[] steps = new String[panels.length];
    String[] basicOnes = new String[]{
        getMessage(BaseWizardIterator.class, "LBL_MavenProjectSettings"),
        getMessage(BaseWizardIterator.class, "LBL_PayaraMicroSettings")
    };
    System.arraycopy(basicOnes, 0, steps, 0, basicOnes.length);
    for (int i = 0; i < panels.length; i++) {
        Component c = panels[i].getComponent();
        if (i >= basicOnes.length || steps[i] == null) {
            // Default step name to component name of panel.
            // Mainly useful for getting the name of the target
            // chooser to appear in the list of steps.
            steps[i] = c.getName();
        }
        if (c instanceof JComponent) {
            // assume Swing components
            JComponent jc = (JComponent) c;
            // Step #.
            jc.putClientProperty("WizardPanel_contentSelectedIndex", i); //NOI18N
            // Step name (actually the whole list for reference).
            jc.putClientProperty("WizardPanel_contentData", steps); //NOI18N
        }
    }
}
 
Example 3
Source File: PropertySheetOperator.java    From netbeans with Apache License 2.0 6 votes vote down vote up
public boolean checkComponent(Component comp) {
    if (comp == null) {
        return false;
    }
    if(comp instanceof PropertySheet || comp.getClass().getSimpleName().equals("NbSheet")) {
        if(sheetName == null) {
            return true;
        } else {
            if(comp instanceof TopComponent) {
                String name = ((TopComponent)comp).getDisplayName();
                if(name == null) {
                    name = comp.getName();
                }
                return comparator.equals(name, sheetName);
            }
        }
    }
    return false;          
}
 
Example 4
Source File: CakePHP3NewProjectWizardIterator.java    From cakephp3-netbeans with Apache License 2.0 6 votes vote down vote up
@Override
public void initialize(WizardDescriptor wiz) {
    this.wiz = wiz;
    index = 0;
    panels = createPanels();
    // Make sure list of steps is accurate.
    String[] steps = createSteps();
    for (int i = 0; i < panels.length; i++) {
        Component c = panels[i].getComponent();
        if (steps[i] == null) {
            // Default step name to component name of panel.
            // Mainly useful for getting the name of the target
            // chooser to appear in the list of steps.
            steps[i] = c.getName();
        }
        if (c instanceof JComponent) { // assume Swing components
            JComponent jc = (JComponent) c;
            // Step #.
            // TODO if using org.openide.dialogs >= 7.8, can use WizardDescriptor.PROP_*:
            jc.putClientProperty(WizardDescriptor.PROP_CONTENT_SELECTED_INDEX, i);
            // Step name (actually the whole list for reference).
            jc.putClientProperty(WizardDescriptor.PROP_CONTENT_DATA, steps);
        }
    }
}
 
Example 5
Source File: PopupInstantiateTemplate.java    From zap-extensions with Apache License 2.0 6 votes vote down vote up
@Override
public boolean isEnableForComponent(Component invoker) {
    if (invoker.getName() != null && invoker.getName().equals(ScriptsListPanel.TREE)) {
        try {
            JTree tree = (JTree) invoker;
            ScriptNode node = (ScriptNode) tree.getLastSelectedPathComponent();

            if (node == null
                    || !node.isTemplate()
                    || node.getUserObject() == null
                    || !(node.getUserObject() instanceof ScriptWrapper)) {
                return false;
            }

            if (((ScriptWrapper) node.getUserObject()).getEngine() == null) {
                return false;
            }

            return extension.getScriptsPanel().getSelectedScript() != null;
        } catch (Exception e) {
        }
    }
    return false;
}
 
Example 6
Source File: datasourceWizardIterator.java    From visualvm with GNU General Public License v2.0 6 votes vote down vote up
public void initialize(WizardDescriptor wiz) {
    this.wiz = wiz;
    index = 0;
    panels = createPanels();
    // Make sure list of steps is accurate.
    String[] steps = createSteps();
    for (int i = 0; i < panels.length; i++) {
        Component c = panels[i].getComponent();
        if (steps[i] == null) {
            // Default step name to component name of panel.
            // Mainly useful for getting the name of the target
            // chooser to appear in the list of steps.
            steps[i] = c.getName();
        }
        if (c instanceof JComponent) { // assume Swing components

            JComponent jc = (JComponent) c;
            // Step #.
            jc.putClientProperty("WizardPanel_contentSelectedIndex", new Integer(i));
            // Step name (actually the whole list for reference).
            jc.putClientProperty("WizardPanel_contentData", steps);
        }
    }
}
 
Example 7
Source File: PopupRemoveScript.java    From zap-extensions with Apache License 2.0 6 votes vote down vote up
@Override
public boolean isEnableForComponent(Component invoker) {
    if (invoker.getName() != null && invoker.getName().equals(ScriptsListPanel.TREE)) {
        try {
            JTree tree = (JTree) invoker;
            ScriptNode node = (ScriptNode) tree.getLastSelectedPathComponent();

            if (node == null
                    || node.isTemplate()
                    || node.getUserObject() == null
                    || !(node.getUserObject() instanceof ScriptWrapper)) {
                return false;
            }

            return extension.getScriptsPanel().getSelectedScript() != null;
        } catch (Exception e) {
        }
    }
    return false;
}
 
Example 8
Source File: hostviewWizardIterator.java    From visualvm with GNU General Public License v2.0 6 votes vote down vote up
public void initialize(WizardDescriptor wiz) {
    this.wiz = wiz;
    index = 0;
    panels = createPanels();
    // Make sure list of steps is accurate.
    String[] steps = createSteps();
    for (int i = 0; i < panels.length; i++) {
        Component c = panels[i].getComponent();
        if (steps[i] == null) {
            // Default step name to component name of panel.
            // Mainly useful for getting the name of the target
            // chooser to appear in the list of steps.
            steps[i] = c.getName();
        }
        if (c instanceof JComponent) { // assume Swing components

            JComponent jc = (JComponent) c;
            // Step #.
            jc.putClientProperty("WizardPanel_contentSelectedIndex", new Integer(i));
            // Step name (actually the whole list for reference).
            jc.putClientProperty("WizardPanel_contentData", steps);
        }
    }
}
 
Example 9
Source File: GrailsProjectWizardIterator.java    From netbeans with Apache License 2.0 5 votes vote down vote up
@Override
public void initialize(WizardDescriptor wizard) {
    this.wiz = wizard;
    index = 0;

    // get project counter from GrailsConfiguration
    baseCount = GrailsProjectSettings.getDefault().getNewProjectCount() + 1;
    wizard.putProperty("WizardPanel_GrailsProjectCounter", Integer.valueOf(baseCount));

    panels = createPanels();
    String[] steps = createSteps();

    for (int i = 0; i < panels.length; i++) {
        Component c = panels[i].getComponent();
        if (steps[i] == null) {
            // Default step name to component name of panel.
            // Mainly useful for getting the name of the target
            // chooser to appear in the list of steps.
            steps[i] = c.getName();
        }
        if (c instanceof JComponent) { // assume Swing components
            JComponent jc = (JComponent) c;
            // Step #.
            jc.putClientProperty(WizardDescriptor.PROP_CONTENT_SELECTED_INDEX, Integer.valueOf(i)); // NOI18N
            // Step name (actually the whole list for reference).
            jc.putClientProperty(WizardDescriptor.PROP_CONTENT_DATA, steps); // NOI18N
        }
    }
}
 
Example 10
Source File: NewJ2SEModularProjectWizardIterator.java    From netbeans with Apache License 2.0 5 votes vote down vote up
@Override
public void initialize(WizardDescriptor wiz) {
    this.wiz = wiz;
    index = 0;
    panels = createPanels();
    // Make sure list of steps is accurate.
    String[] steps = createSteps();
    for (int i = 0; i < panels.length; i++) {
        Component c = panels[i].getComponent();
        if (steps[i] == null) {
            // Default step name to component name of panel.
            // Mainly useful for getting the name of the target
            // chooser to appear in the list of steps.
            steps[i] = c.getName();
        }
        if (c instanceof JComponent) { // assume Swing components
            JComponent jc = (JComponent)c;
            // Step #.
            jc.putClientProperty(WizardDescriptor.PROP_CONTENT_SELECTED_INDEX, i);
            // Step name (actually the whole list for reference).
            jc.putClientProperty(WizardDescriptor.PROP_CONTENT_DATA, steps);
        }
    }
    //set the default values of the sourceRoot and the testRoot properties
    this.wiz.putProperty("sourceRoot", new File[0]);    //NOI18N
    this.wiz.putProperty("testRoot", new File[0]);      //NOI18N
}
 
Example 11
Source File: NewFileIterator.java    From netbeans with Apache License 2.0 5 votes vote down vote up
@Override
public void initialize(WizardDescriptor wiz) {
    panel = getPanel(wiz);
    this.wiz = wiz;
    
    // Make sure list of steps is accurate.
    String[] beforeSteps = null;
    Object prop = wiz.getProperty (WizardDescriptor.PROP_CONTENT_DATA);
    if (prop != null && prop instanceof String[]) {
        beforeSteps = (String[])prop;
    }
    String[] steps = createSteps (beforeSteps);
    for (int i = 0; i < 1; i++) { // XXX what was this loop for, exactly? panels.length was always 1
        Component c = panel.getComponent();
        if (steps[i] == null) {
            // Default step name to component name of panel.
            // Mainly useful for getting the name of the target
            // chooser to appear in the list of steps.
            steps[i] = c.getName();
        }
        if (c instanceof JComponent) { // assume Swing components
            JComponent jc = (JComponent)c;
            // Step #.
            jc.putClientProperty(WizardDescriptor.PROP_CONTENT_SELECTED_INDEX, new Integer(i));
            // Step name (actually the whole list for reference).
            jc.putClientProperty(WizardDescriptor.PROP_CONTENT_DATA, steps);
        }
    }
}
 
Example 12
Source File: NewTestWizardIterator.java    From netbeans with Apache License 2.0 5 votes vote down vote up
public void initialize(WizardDescriptor wiz) {
    this.wiz = wiz;
    index = 0;
    panels = createPanels(wiz);
    loadSettings(wiz);
    // Make sure list of steps is accurate.
    String[] beforeSteps = null;
    Object prop = wiz.getProperty("WizardPanel_contentData"); // NOI18N
    if (prop != null && prop instanceof String[]) {
        beforeSteps = (String[]) prop;
    }
    String[] steps = createSteps(beforeSteps, panels);
    for (int i = 0; i < panels.length; i++) {
        Component c = panels[i].getComponent();
        if (steps[i] == null) {
            // Default step name to component name of panel.
            // Mainly useful for getting the name of the target
            // chooser to appear in the list of steps.
            steps[i] = c.getName();
        }
        if (c instanceof JComponent) { // assume Swing components
            JComponent jc = (JComponent) c;
            // Step #.
            jc.putClientProperty("WizardPanel_contentSelectedIndex", Integer.valueOf(i)); // NOI18N
            // Step name (actually the whole list for reference).
            jc.putClientProperty("WizardPanel_contentData", steps); // NOI18N
        }
    }
}
 
Example 13
Source File: JPanelButtons.java    From nordpos with GNU General Public License v3.0 5 votes vote down vote up
public void setPermissions(AppUser user) {
    for (Component c : this.getComponents()) {
        String sKey = c.getName();
        if (sKey == null || sKey.equals("")) {
            c.setEnabled(true);
        } else {
            c.setEnabled(user.hasPermission(c.getName()));
        }
    }
}
 
Example 14
Source File: CreateProjectWizardIterator.java    From MikuMikuStudio with BSD 2-Clause "Simplified" License 5 votes vote down vote up
/**
 * Initialize panels representing individual wizard's steps and sets
 * various properties for them influencing wizard appearance.
 */
private WizardDescriptor.Panel[] getPanels() {
    if (panels == null) {
        panels = new WizardDescriptor.Panel[]{
                    new CreateProjectWizardPanel1(),
                    new CreateProjectWizardPanel2()
                };
        String[] steps = new String[panels.length];
        for (int i = 0; i < panels.length; i++) {
            Component c = panels[i].getComponent();
            // Default step name to component name of panel. Mainly useful
            // for getting the name of the target chooser to appear in the
            // list of steps.
            steps[i] = c.getName();
            if (c instanceof JComponent) { // assume Swing components
                JComponent jc = (JComponent) c;
                // Sets step number of a component
                // TODO if using org.openide.dialogs >= 7.8, can use WizardDescriptor.PROP_*:
                jc.putClientProperty("WizardPanel_contentSelectedIndex", new Integer(i));
                // Sets steps names for a panel
                jc.putClientProperty("WizardPanel_contentData", steps);
                // Turn on subtitle creation on each step
                jc.putClientProperty("WizardPanel_autoWizardStyle", Boolean.TRUE);
                // Show steps on the left side with the image on the background
                jc.putClientProperty("WizardPanel_contentDisplayed", Boolean.TRUE);
                // Turn on numbering of all steps
                jc.putClientProperty("WizardPanel_contentNumbered", Boolean.TRUE);
            }
        }
    }
    return panels;
}
 
Example 15
Source File: WebFragmentXmlWizardIterator.java    From netbeans with Apache License 2.0 5 votes vote down vote up
/**
 * Initialize panels representing individual wizard's steps and sets
 * various properties for them influencing wizard appearance.
 */
private WizardDescriptor.Panel[] getPanels() {
    if (panels == null) {
        panels = new WizardDescriptor.Panel[] {
            new WebFragmentXmlWizardPanel1()
        };
        String[] steps = createSteps();
        for (int i = 0; i < panels.length; i++) {
            Component component = panels[i].getComponent();
            if (steps[i] == null) {
                // Default step name to component name of panel. Mainly
                // useful for getting the name of the target chooser to
                // appear in the list of steps.
                steps[i] = component.getName();
            }
            if (component instanceof JComponent) { // assume Swing components
                JComponent jComponent = (JComponent) component;
                // Sets step number of a component
                jComponent.putClientProperty(WizardDescriptor.PROP_CONTENT_SELECTED_INDEX, Integer.valueOf(i));
                // Sets steps names for a panel
                jComponent.putClientProperty(WizardDescriptor.PROP_CONTENT_DATA, steps);
                // Turn on subtitle creation on each step
                jComponent.putClientProperty(WizardDescriptor.PROP_AUTO_WIZARD_STYLE, Boolean.TRUE);
                // Show steps on the left side with the image on the background
                jComponent.putClientProperty(WizardDescriptor.PROP_CONTENT_DISPLAYED, Boolean.TRUE);
                // Turn on numbering of all steps
                jComponent.putClientProperty(WizardDescriptor.PROP_CONTENT_NUMBERED, Boolean.TRUE);
            }
        }
    }
    return panels;
}
 
Example 16
Source File: CheckoutWizard.java    From netbeans with Apache License 2.0 5 votes vote down vote up
@Override
protected WizardDescriptor.Panel[] initializePanels() {
    WizardDescriptor.Panel[] panels = new WizardDescriptor.Panel[3];
    repositoryStep = new RepositoryStep(Repository.FLAG_ACCEPT_REVISION, RepositoryStep.CHECKOUT_HELP_ID);
    repositoryStep.addChangeListener(CheckoutWizard.this);
    checkoutStep = new CheckoutStep();            
    checkoutStep.addChangeListener(CheckoutWizard.this);
    
    panels = new  WizardDescriptor.Panel[] {repositoryStep, checkoutStep};

    String[] steps = new String[panels.length];
    for (int i = 0; i < panels.length; i++) {
        Component c = panels[i].getComponent();
        // Default step name to component name of panel. Mainly useful
        // for getting the name of the target chooser to appear in the
        // list of steps.
        steps[i] = c.getName();
        if (c instanceof JComponent) { // assume Swing components
            JComponent jc = (JComponent) c;
            // Sets step number of a component
            jc.putClientProperty(WizardDescriptor.PROP_CONTENT_SELECTED_INDEX, new Integer(i)); // NOI18N
            // Sets steps names for a panel
            jc.putClientProperty(WizardDescriptor.PROP_CONTENT_DATA, steps); // NOI18N
            // Turn on subtitle creation on each step
            jc.putClientProperty(WizardDescriptor.PROP_AUTO_WIZARD_STYLE, Boolean.TRUE); // NOI18N
            // Show steps on the left side with the image on the background
            jc.putClientProperty(WizardDescriptor.PROP_CONTENT_DISPLAYED, Boolean.TRUE); // NOI18N
            // Turn on numbering of all steps
            jc.putClientProperty(WizardDescriptor.PROP_CONTENT_NUMBERED, Boolean.TRUE); // NOI18N
        }
    }
    return panels;
}
 
Example 17
Source File: PopupEncoderMenu.java    From zap-extensions with Apache License 2.0 5 votes vote down vote up
private boolean isInvokerFromEncodeDecode(Component invoker) {
    if (invoker.getName() == null) {
        return false;
    }

    return invoker.getName().equals(EncodeDecodeDialog.ENCODE_DECODE_FIELD)
            || invoker.getName().equals(EncodeDecodeDialog.ENCODE_DECODE_RESULTFIELD);
}
 
Example 18
Source File: AddSkyboxAction.java    From MikuMikuStudio with BSD 2-Clause "Simplified" License 5 votes vote down vote up
/**
 * Initialize panels representing individual wizard's steps and sets
 * various properties for them influencing wizard appearance.
 */
private WizardDescriptor.Panel[] getPanels() {
    if (panels == null) {
        panels = new WizardDescriptor.Panel[]{
                    new SkyboxWizardPanel1(),
                    new SkyboxWizardPanel2()
                };
        String[] steps = new String[panels.length];
        for (int i = 0; i < panels.length; i++) {
            Component c = panels[i].getComponent();
            // Default step name to component name of panel. Mainly useful
            // for getting the name of the target chooser to appear in the
            // list of steps.
            steps[i] = c.getName();
            if (c instanceof JComponent) { // assume Swing components
                JComponent jc = (JComponent) c;
                // Sets step number of a component
                // TODO if using org.openide.dialogs >= 7.8, can use WizardDescriptor.PROP_*:
                jc.putClientProperty("WizardPanel_contentSelectedIndex", new Integer(i));
                // Sets steps names for a panel
                jc.putClientProperty("WizardPanel_contentData", steps);
                // Turn on subtitle creation on each step
                jc.putClientProperty("WizardPanel_autoWizardStyle", Boolean.TRUE);
                // Show steps on the left side with the image on the background
                jc.putClientProperty("WizardPanel_contentDisplayed", Boolean.TRUE);
                // Turn on numbering of all steps
                jc.putClientProperty("WizardPanel_contentNumbered", Boolean.TRUE);
            }
        }
    }
    return panels;
}
 
Example 19
Source File: PageIterator.java    From netbeans with Apache License 2.0 5 votes vote down vote up
public void initialize(TemplateWizard wiz) {
    this.wiz = wiz;
    index = 0;
    Project project = Templates.getProject(wiz);
    panels = createPanels(project);

    // Creating steps.
    Object prop = wiz.getProperty(WizardDescriptor.PROP_CONTENT_DATA); // NOI18N
    String[] beforeSteps = null;
    if (prop != null && prop instanceof String[]) {
        beforeSteps = (String[]) prop;
    }
    String[] steps = Utilities.createSteps(beforeSteps, panels);

    for (int i = 0; i < panels.length; i++) {
        Component c = panels[i].getComponent();
        if (steps[i] == null) {
            // Default step name to component name of panel.
            // Mainly useful for getting the name of the target
            // chooser to appear in the list of steps.
            steps[i] = c.getName();
        }
        if (c instanceof JComponent) { // assume Swing components
            JComponent jc = (JComponent) c;
            // Step #.
            jc.putClientProperty(WizardDescriptor.PROP_CONTENT_SELECTED_INDEX, Integer.valueOf(i));
            // Step name (actually the whole list for reference).
            jc.putClientProperty(WizardDescriptor.PROP_CONTENT_DATA, steps);
        }
    }
}
 
Example 20
Source File: JerseyClientWizardIterator.java    From netbeans with Apache License 2.0 4 votes vote down vote up
@Override
public void initialize(WizardDescriptor wizard) {
    this.wizard = wizard;
    Project project = Templates.getProject(wizard);

    SourceGroup[] sourceGroups = SourceGroups.getJavaSourceGroups(project);
    bottomPanel = new JerseyClientWizardPanel();
    //WizardDescriptor.Panel firstPanel; //special case: use Java Chooser
    if (sourceGroups.length == 0) {
        SourceGroup[] genericSourceGroups = ProjectUtils.
                getSources(project).getSourceGroups(Sources.TYPE_GENERIC);
        firstPanel = new FinishableProxyWizardPanel(Templates.
                createSimpleTargetChooser(project, genericSourceGroups, bottomPanel), 
                sourceGroups, false);
    } else {
        firstPanel = new FinishableProxyWizardPanel(
                JavaTemplates.createPackageChooser(project, sourceGroups, 
                bottomPanel, true));
    }
    panels = new WizardDescriptor.Panel[] { firstPanel };
    String[] steps = createSteps();
    for (int i = 0; i < panels.length; i++) {
        Component c = panels[i].getComponent();
        if (steps[i] == null) {
            // Default step name to component name of panel. Mainly
            // useful for getting the name of the target chooser to
            // appear in the list of steps.
            steps[i] = c.getName();
        }
        if (c instanceof JComponent) { // assume Swing components
            JComponent jc = (JComponent) c;
            // Sets step number of a component
            // TODO if using org.openide.dialogs >= 7.8, can use
            // WizardDescriptor.PROP_*:
            jc.putClientProperty("WizardPanel_contentSelectedIndex",i);
            // Sets steps names for a panel
            jc.putClientProperty("WizardPanel_contentData", steps);
            // Turn on subtitle creation on each step
            jc.putClientProperty("WizardPanel_autoWizardStyle",
                    Boolean.TRUE);
            // Show steps on the left side with the image on the background
            jc.putClientProperty("WizardPanel_contentDisplayed",
                    Boolean.TRUE);
            // Turn on numbering of all steps
            jc.putClientProperty("WizardPanel_contentNumbered",
                    Boolean.TRUE);
        }
    }

}