Java Code Examples for javax.swing.JComponent#getName()

The following examples show how to use javax.swing.JComponent#getName() . These examples are extracted from open source projects. 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
@Override
public void actionPerformed(final ActionEvent e) {
    final Graph graph = context.getGraph();

    final WizardDescriptor.Panel<WizardDescriptor>[] panels = new WizardDescriptor.Panel[]{new ConnectionPanelController(graph), new TablesPanelController(), new MappingPanelController(graph, false)};
    final String[] steps = new String[panels.length];
    int i = 0;
    for (final WizardDescriptor.Panel<WizardDescriptor> panel : panels) {
        final JComponent jc = (JComponent) panel.getComponent();
        steps[i] = jc.getName();
        jc.putClientProperty(WizardDescriptor.PROP_CONTENT_SELECTED_INDEX, i);
        jc.putClientProperty(WizardDescriptor.PROP_CONTENT_DISPLAYED, true);
        jc.putClientProperty(WizardDescriptor.PROP_CONTENT_DATA, steps);
        jc.putClientProperty(WizardDescriptor.PROP_AUTO_WIZARD_STYLE, true);
        jc.putClientProperty(WizardDescriptor.PROP_CONTENT_NUMBERED, true);
        i++;
    }
    final WizardDescriptorData wd = new WizardDescriptorData(panels);
    wd.setTitleFormat(new MessageFormat("{0}"));
    wd.setTitle(Bundle.MSG_ImportFromJdbc());
    final Object result = DialogDisplayer.getDefault().notify(wd);
    if (result == DialogDescriptor.OK_OPTION) {
        final ImportFromJdbcPlugin exporter = new ImportFromJdbcPlugin(wd.data);
        PluginExecution.withPlugin(exporter).executeLater(graph);
    }
}
 
Example 2
@Override
public void actionPerformed(final ActionEvent e) {
    final Graph graph = context.getGraph();
    final WizardDescriptor.Panel<WizardDescriptor>[] panels = new WizardDescriptor.Panel[]{new ConnectionPanelController(graph), new TablesPanelController(), new MappingPanelController(graph, true)};
    final String[] steps = new String[panels.length];
    int i = 0;
    for (final WizardDescriptor.Panel<WizardDescriptor> panel : panels) {
        final JComponent jc = (JComponent) panel.getComponent();
        steps[i] = jc.getName();
        jc.putClientProperty(WizardDescriptor.PROP_CONTENT_SELECTED_INDEX, i);
        jc.putClientProperty(WizardDescriptor.PROP_CONTENT_DISPLAYED, true);
        jc.putClientProperty(WizardDescriptor.PROP_CONTENT_DATA, steps);
        jc.putClientProperty(WizardDescriptor.PROP_AUTO_WIZARD_STYLE, true);
        jc.putClientProperty(WizardDescriptor.PROP_CONTENT_NUMBERED, true);
        i++;
    }
    final WizardDescriptorData wd = new WizardDescriptorData(panels);
    wd.setTitleFormat(new MessageFormat("{0}"));
    wd.setTitle(Bundle.MSG_ExportToJdbc());
    final Object result = DialogDisplayer.getDefault().notify(wd);
    if (result == DialogDescriptor.OK_OPTION) {
        final ExportToJdbcPlugin exporter = new ExportToJdbcPlugin(wd.data);
        PluginExecution.withPlugin(exporter).executeLater(graph);
    }
}
 
Example 3
Source Project: raccoon4   File: MenuBarBuilder.java    License: Apache License 2.0 6 votes vote down vote up
/**
 * Add an item/menu to the menubar. Items are appended to their parent
 * container in the same order in which they are added. This implies that
 * parent items must be created before children can be added.
 * 
 * @param path
 *          where to add.
 * @param item
 *          what to add. NOTE: this should be an instance of {@link JMenu},
 *          {@link JMenuItem}, {@link JRadioButtonMenuItem},
 *          {@link JCheckBoxMenuItem} or {@link JSeparator}. Nesting menus is
 *          perfectly fine (though not from a usability point of view).
 * @return this reference for chaining.
 */
public MenuBarBuilder add(String path, JComponent item) {
	maps.put(path, item);
	if (localizer != null && item instanceof JMenuItem) {
		Action a = ((JMenuItem) item).getAction();
		localizer.localize(a, getLocalizationKey(path));
	}
	String parentPath = path.substring(0,
			Math.max(path.lastIndexOf(PATHSEPARATOR), 0));
	JComponent parent = maps.get(parentPath);
	if (item.getName() == null) {
		item.setName(path); // for unit tests
	}
	if (parent == null) {
		mbar.add(item);
	}
	else {
		parent.add(item);
	}
	return this;
}
 
Example 4
Source Project: pumpernickel   File: CustomizedToolbar.java    License: MIT License 6 votes vote down vote up
private boolean triggerDrag(JFrame f, Point p, DragGestureEvent dge,
		JComponent c) {
	Rectangle r = new Rectangle(0, 0, c.getWidth(), c.getHeight());
	r = SwingUtilities.convertRectangle(c, r, f);

	if (r.contains(p)) {
		draggingFromToolbar = true;
		draggingDefaults = false;
		draggingComponent = c.getName();
		MockComponent mc = new MockComponent(c);
		Transferable transferable = new MockComponentTransferable(mc);
		BufferedImage bi = mc.getBufferedImage();
		dge.startDrag(DragSource.DefaultMoveDrop, bi, new Point(r.x
				- p.x, r.y - p.y), transferable, dragSourceListener);
		return true;
	}
	return false;
}
 
Example 5
Source Project: netbeans   File: Wizards.java    License: Apache License 2.0 5 votes vote down vote up
private static void setSteps(WizardDescriptor.Panel[] panels, String[] steps, String[] resultSteps, int offset) {
    int n = steps == null ? 0 : steps.length;
    for (int i = 0; i < panels.length; i++) {
        final JComponent component = (JComponent) panels[i].getComponent();
        String step = i < n ? steps[i] : null;
        if (step == null) {
            step = component.getName();
        }
        component.putClientProperty(WIZARD_PANEL_CONTENT_DATA, resultSteps);
        component.putClientProperty(WIZARD_PANEL_CONTENT_SELECTED_INDEX, Integer.valueOf(i));
        component.getAccessibleContext().setAccessibleDescription(step);
        resultSteps[i + offset] = step;
    }
}
 
Example 6
Source Project: netbeans   File: Util.java    License: Apache License 2.0 5 votes vote down vote up
private static void setSteps(WizardDescriptor.Panel[] panels, String[] steps, String[] resultSteps, int offset) {
    int n = steps == null ? 0 : steps.length;
    for (int i = 0; i < panels.length; i++) {
        final JComponent component = (JComponent) panels[i].getComponent();
        String step = i < n ? steps[i] : null;
        if (step == null) {
            step = component.getName();
        }
        component.putClientProperty(WIZARD_PANEL_CONTENT_DATA, resultSteps);
        component.putClientProperty(WIZARD_PANEL_CONTENT_SELECTED_INDEX, i);
        component.getAccessibleContext().setAccessibleDescription(step);
        resultSteps[i + offset] = step;
    }
}
 
Example 7
Source Project: netbeans   File: Utils.java    License: Apache License 2.0 5 votes vote down vote up
private static void setSteps(WizardDescriptor.Panel[] panels, String[] steps, String[] resultSteps, int offset) {
    int n = steps == null ? 0 : steps.length;
    for (int i = 0; i < panels.length; i++) {
        final JComponent component = (JComponent) panels[i].getComponent();
        String step = i < n ? steps[i] : null;
        if (step == null) {
            step = component.getName();
        }
        component.putClientProperty (WIZARD_PANEL_CONTENT_DATA, resultSteps);
        component.putClientProperty(WIZARD_PANEL_CONTENT_SELECTED_INDEX, i);
        component.getAccessibleContext().setAccessibleDescription (step);
        resultSteps[i + offset] = step;
    }
}
 
Example 8
Source Project: netbeans   File: ManagedBeanIterator.java    License: Apache License 2.0 5 votes vote down vote up
@Override
public void initialize(TemplateWizard wizard) {
    index = 0;
    // obtaining target folder
    Project project = Templates.getProject(wizard);

    SourceGroup[] sourceGroups = ProjectUtils.getSources(project).getSourceGroups(JavaProjectConstants.SOURCES_TYPE_JAVA);
    managedBeanPanel = new ManagedBeanPanel(project, wizard);
    WizardDescriptor.Panel javaPanel;
    if (sourceGroups.length == 0) {
        wizard.putProperty(WizardDescriptor.PROP_ERROR_MESSAGE, NbBundle.getMessage(ManagedBeanIterator.class, "MSG_No_Sources_found"));
        javaPanel = managedBeanPanel;
    } else {
        javaPanel = JavaTemplates.createPackageChooser(project, sourceGroups, managedBeanPanel);

        javaPanel.addChangeListener(new ChangeListener() {
            @Override
            public void stateChanged(ChangeEvent e) {
                managedBeanPanel.updateManagedBeanName((WizardDescriptor.Panel) e.getSource());
            }
        });
    }
    panels = new WizardDescriptor.Panel[]{javaPanel};

    // Creating steps.
    Object prop = wizard.getProperty(WizardDescriptor.PROP_CONTENT_DATA); // NOI18N
    String[] beforeSteps = null;
    if (prop != null && prop instanceof String[]) {
        beforeSteps = (String[]) prop;
    }
    String[] steps = createSteps(beforeSteps, panels);
    for (int i = 0; i < panels.length; i++) {
        JComponent jc = (JComponent) panels[i].getComponent();
        if (steps[i] == null) {
            steps[i] = jc.getName();
        }
        jc.putClientProperty(WizardDescriptor.PROP_CONTENT_SELECTED_INDEX, new Integer(i)); // NOI18N
        jc.putClientProperty(WizardDescriptor.PROP_CONTENT_DATA, steps); // NOI18N
    }
}
 
Example 9
Source Project: netbeans   File: AbstractIterator.java    License: Apache License 2.0 5 votes vote down vote up
@Override
public void initialize(TemplateWizard wizard) {
    WizardDescriptor.Panel<WizardDescriptor> folderPanel;
    Project project = Templates.getProject(wizard);
    Sources sources = ProjectUtils.getSources(project);
    SourceGroup[] sourceGroups = sources.getSourceGroups(WebProjectConstants.TYPE_WEB_INF);
    if (sourceGroups.length == 0) {
        sourceGroups = sources.getSourceGroups(WebProjectConstants.TYPE_DOC_ROOT);
    }
    if (sourceGroups.length == 0) {
        sourceGroups = sources.getSourceGroups(Sources.TYPE_GENERIC);
    }
    folderPanel = Templates.buildSimpleTargetChooser(project, sourceGroups).create();
    folderPanel = new ValidationPanel(wizard, folderPanel);
    panels = new WizardDescriptor.Panel[]{folderPanel};

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

    for (int i = 0; i < panels.length; i++) {
        JComponent jc = (JComponent) panels[i].getComponent();
        if (steps[i] == null) {
            steps[i] = jc.getName();
        }
        jc.putClientProperty(WizardDescriptor.PROP_CONTENT_SELECTED_INDEX, new Integer (i)); // NOI18N
        jc.putClientProperty(WizardDescriptor.PROP_CONTENT_DATA, steps); // NOI18N
    }

    Templates.setTargetName(wizard, getDefaultName());
    Templates.setTargetFolder(wizard, getTargetFolder(project));
}
 
Example 10
Source Project: netbeans   File: RunTagWizard.java    License: Apache License 2.0 5 votes vote down vote up
@NbBundle.Messages({
    "MSG_ReceivingImageInfo=Receiving Image Details",
    "LBL_Run=Run {0}"
})
public void show() {
    DockerImageDetail info = BaseProgressUtils.showProgressDialogAndRun(
            new DockerImageInfoRunnable(tag.getImage()), Bundle.MSG_ReceivingImageInfo(), false);

    List<WizardDescriptor.Panel<WizardDescriptor>> panels = new ArrayList<>();
    panels.add(new RunContainerPropertiesPanel(info));
    panels.add(new RunPortBindingsPanel(info));
    String[] steps = new String[panels.size()];
    for (int i = 0; i < panels.size(); i++) {
        JComponent c = (JComponent) panels.get(i).getComponent();
        // Default step name to component name of panel.
        steps[i] = c.getName();
        c.putClientProperty(WizardDescriptor.PROP_CONTENT_SELECTED_INDEX, i);
        c.putClientProperty(WizardDescriptor.PROP_CONTENT_DATA, steps);
        c.putClientProperty(WizardDescriptor.PROP_AUTO_WIZARD_STYLE, true);
        c.putClientProperty(WizardDescriptor.PROP_CONTENT_DISPLAYED, true);
        c.putClientProperty(WizardDescriptor.PROP_CONTENT_NUMBERED, true);
    }
    final WizardDescriptor wiz = new WizardDescriptor(new WizardDescriptor.ArrayIterator<>(panels));
    // {0} will be replaced by WizardDesriptor.Panel.getComponent().getName()
    wiz.setTitleFormat(new MessageFormat("{0}"));
    wiz.setTitle(Bundle.LBL_Run(getImage(tag)));
    if (DialogDisplayer.getDefault().notify(wiz) == WizardDescriptor.FINISH_OPTION) {
        run(tag, wiz);
    }
}
 
Example 11
public void addSnippet(JComponent component) {
    SnippetPanel snippet = new SnippetPanel(component.getName(), component);
    snippet.setOpaque(false);
    snippets.add(snippet);
    updateSnippets();
}
 
Example 12
@Override
public void actionPerformed(ActionEvent e) {
	if (e.getSource() instanceof JComponent) {
		JComponent btn = (JComponent) e.getSource();
		String name = btn.getName();

		switch (name) {
		case "CLOSE":
			onClosed();
			break;
		case "FORMAT_SELECT":
			fmtWnd.setVisible(true);
			if (fmtWnd.isApproveOption()) {
				MediaFormat fmt = fmtWnd.getFormat();
				btnOutFormat.setText(fmt.getDescription());
				setDetails(fmt.getResolution(), fmt.getVideo_codec(), fmt.getAudio_codec());
				lblImg.setFormat(fmt.getFormat());
			}
			break;
		case "STOP":
			stop();
			break;
		case "CONVERT":
			for (int i = 0; i < model.size(); i++) {
				ConversionItem item = model.getElementAt(i);
				String file = XDMUtils.getFileNameWithoutExtension(item.inputFileName);
				String ext = fmtWnd.getFormat().getFormat();
				item.outFileName = file + "." + ext;
			}
			System.out.println("starting convert");
			mode = 1;
			t = new Thread(this);
			t.start();
			break;
		case "BROWSE_FOLDER":
			JFileChooser jfc = new JFileChooser();
			jfc.setFileSelectionMode(JFileChooser.DIRECTORIES_ONLY);
			if (jfc.showOpenDialog(this) == JFileChooser.APPROVE_OPTION) {
				txtOutFolder.setText(jfc.getSelectedFile().getAbsolutePath());
			}
			break;
		}
	}

}
 
Example 13
Source Project: netbeans   File: StatisticsPanel.java    License: Apache License 2.0 4 votes vote down vote up
public void addSnippet(JComponent component) {
    SnippetPanel snippet = new SnippetPanel(component.getName(), component);
    snippet.setOpaque(false);
    snippets.add(snippet);
    updateSnippets();
}
 
Example 14
Source Project: netbeans   File: ServletIterator.java    License: Apache License 2.0 4 votes vote down vote up
public void initialize(WizardDescriptor wiz) {
       this.wizard = (TemplateWizard) wiz;
       index = 0;

       if (fileType.equals(FileType.SERVLET) || fileType.equals(FileType.FILTER)) {
           deployData = new ServletData(fileType);
           if (Utilities.isJavaEE6Plus(wizard)) {
               deployData.setMakeEntry(false);
           }
           evaluator = new TargetEvaluator(fileType, deployData);
       }

       Project project = Templates.getProject(wizard);
       DataFolder targetFolder=null;
       try {
           targetFolder = wizard.getTargetFolder();
       }
       catch (IOException ex) {
           targetFolder = DataFolder.findFolder(project.getProjectDirectory());
       }
       evaluator.setInitialFolder(targetFolder,project); 
       boolean canCreate = ((ServletData)deployData).canCreate(wizard);
       
       if (fileType == FileType.SERVLET) {
           panels = new WizardDescriptor.Panel[]{
                       new FinishableProxyWizardPanel(
                       createPackageChooserPanel(wizard, null),
                       new HelpCtx(ServletIterator.class.getName() + "." + fileType), // #114487
                       canCreate ), 
                       ServletPanel.createServletPanel(evaluator, wizard)
                   };
       } else if (fileType == FileType.FILTER) {
           customPanel = new WrapperSelection(wizard);
           panels = new WizardDescriptor.Panel[]{ canCreate ? 
                       createPackageChooserPanel(wizard, customPanel):
                           new FinishableProxyWizardPanel( 
                                   createPackageChooserPanel(wizard, customPanel), 
                                   new HelpCtx(ServletIterator.class.getName() 
                                           + "." + fileType), false),
                       ServletPanel.createServletPanel(evaluator, wizard),
                       ServletPanel.createFilterPanel(evaluator, wizard)
                   };
       }
       
       // Creating steps.
       Object prop = wizard.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++) { 
           JComponent jc = (JComponent)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] = jc.getName();
           }
    jc.putClientProperty(WizardDescriptor.PROP_CONTENT_SELECTED_INDEX, Integer.valueOf(i));
    jc.putClientProperty(WizardDescriptor.PROP_CONTENT_DATA, steps);
}	
   }
 
Example 15
Source Project: netbeans   File: FacesConfigIterator.java    License: Apache License 2.0 4 votes vote down vote up
@Override
   public void initialize(TemplateWizard wizard) {
       // obtaining target folder
       Project project = Templates.getProject( wizard );
       Sources sources = ProjectUtils.getSources(project);
       SourceGroup[] sourceGroups = sources.getSourceGroups(WebProjectConstants.TYPE_WEB_INF);

       if (sourceGroups == null || sourceGroups.length == 0) {
           sourceGroups = sources.getSourceGroups(WebProjectConstants.TYPE_DOC_ROOT);
       }

       WizardDescriptor.Panel folderPanel;
       if (sourceGroups == null || sourceGroups.length == 0) {
           sourceGroups = sources.getSourceGroups(Sources.TYPE_GENERIC);
       }

       folderPanel = new FacesConfigValidationPanel(Templates.buildSimpleTargetChooser(project, sourceGroups).create());
       panels = new WizardDescriptor.Panel[] { folderPanel };

       // Creating steps.
       Object prop = wizard.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++) {
           JComponent jc = (JComponent)panels[i].getComponent ();
           if (steps[i] == null) {
               steps[i] = jc.getName ();
           }
    jc.putClientProperty (WizardDescriptor.PROP_CONTENT_SELECTED_INDEX, new Integer (i)); // NOI18N
    jc.putClientProperty (WizardDescriptor.PROP_CONTENT_DATA, steps); // NOI18N
}

       WebModule wm = WebModule.getWebModule(project.getProjectDirectory());
       if (wm != null) {
           FileObject webInf = wm.getWebInf();
           if (webInf == null) {
               try {
                   FileObject documentBase = wm.getDocumentBase();
                   if (documentBase == null) {
                       LOG.log(Level.INFO, "WebModule does not have valid documentBase");
                       return;
                   }
                   webInf = FileUtil.createFolder(documentBase, "WEB-INF"); //NOI18N
               } catch (IOException ex) {
                   Exceptions.printStackTrace(ex);
               }
           }
           FileObject targetFolder = Templates.getTargetFolder(wizard);
           String relativePath = (targetFolder == null) ? null : FileUtil.getRelativePath(webInf, targetFolder);
           if (relativePath == null) {
               Templates.setTargetFolder(wizard, webInf);
           }
       }
       Templates.setTargetName(wizard, defaultName);
   }
 
Example 16
@Override
    public void initialize(TemplateWizard wizard) {
        this.wizard = wizard;
        selectedText = (String) wizard.getProperty("selectedText"); //NOI18N

        Project project = Templates.getProject( wizard );
        Sources sources = project.getLookup().lookup(org.netbeans.api.project.Sources.class);

        SourceGroup[] sourceGroups = sources.getSourceGroups(WebProjectConstants.TYPE_DOC_ROOT);

        WizardDescriptor.Panel folderPanel;
        if (sourceGroups == null || sourceGroups.length == 0) {
            sourceGroups = sources.getSourceGroups(Sources.TYPE_GENERIC);
        }

        FileObject targetFolder = null;
        FileObject resourceFolder = sourceGroups[0].getRootFolder().getFileObject(RESOURCES_FOLDER);
        if (resourceFolder != null) {
            FileObject componentFolder = resourceFolder.getFileObject(COMPONENT_FOLDER);
            if (componentFolder !=null) {
                targetFolder = componentFolder;
            } else {
                targetFolder = resourceFolder;
            }
        }

        if (targetFolder !=null) {
            Templates.setTargetFolder(wizard, targetFolder);
        }
        folderPanel = new CompositeComponentWizardPanel(wizard, sourceGroups, selectedText);

        panels = new WizardDescriptor.Panel[] { folderPanel };

        Object prop = wizard.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++) {
            JComponent jc = (JComponent)panels[i].getComponent ();
            if (steps[i] == null) {
                steps[i] = jc.getName ();
            }
	    jc.putClientProperty (WizardDescriptor.PROP_CONTENT_SELECTED_INDEX, new Integer (i)); // NOI18N
	    jc.putClientProperty (WizardDescriptor.PROP_CONTENT_DATA, steps); // NOI18N
	}
}
 
Example 17
Source Project: netbeans   File: FormBeanIterator.java    License: Apache License 2.0 4 votes vote down vote up
public void initialize (TemplateWizard wizard) {
       if (debug) log ("initialize");                  //NOI18N
       index = 0;
       // obtaining target folder
       Project project = Templates.getProject( wizard );
       DataFolder targetFolder=null;
       try {
           targetFolder = wizard.getTargetFolder();
       } catch (IOException ex) {
           targetFolder = DataFolder.findFolder(project.getProjectDirectory());
       }
       
       SourceGroup[] sourceGroups = ProjectUtils.getSources(project).getSourceGroups(
                                   JavaProjectConstants.SOURCES_TYPE_JAVA);
       if (debug) {
           log ("\tproject: " + project);              //NOI18N
           log ("\ttargetFolder: " + targetFolder);    //NOI18N
           log ("\tsourceGroups.length: " + sourceGroups.length);  //NOI18N
       }
       
       WizardDescriptor.Panel secondPanel = new FormBeanNewPanel(project, wizard);  
       
       WizardDescriptor.Panel javaPanel;
       if (sourceGroups.length == 0)
           javaPanel = Templates.createSimpleTargetChooser(project, sourceGroups, secondPanel);
       else
           javaPanel = JavaTemplates.createPackageChooser(project, sourceGroups, secondPanel);

       
       panels = new WizardDescriptor.Panel[] {
           javaPanel
       };
       
       // Creating steps.
       Object prop = wizard.getProperty (WizardDescriptor.PROP_CONTENT_DATA); // NOI18N
       String[] beforeSteps = null;
       if (prop != null && prop instanceof String[]) {
           beforeSteps = (String[])prop;
       }
       String[] steps = createSteps (beforeSteps, panels);
       
       for (int i = 0; i < panels.length; i++) { 
           JComponent jc = (JComponent)panels[i].getComponent ();
           if (steps[i] == null) {
               steps[i] = jc.getName ();
           }
    jc.putClientProperty (WizardDescriptor.PROP_CONTENT_SELECTED_INDEX, new Integer (i)); // NOI18N 
    jc.putClientProperty (WizardDescriptor.PROP_CONTENT_DATA, steps); // NOI18N
}
   }
 
Example 18
Source Project: netbeans   File: ActionIterator.java    License: Apache License 2.0 4 votes vote down vote up
public void initialize (TemplateWizard wizard) {
       if (debug) log ("initialize");  //NOI18N
       index = 0;
       // obtaining target folder
       Project project = Templates.getProject( wizard );
       DataFolder targetFolder=null;
       try {
           targetFolder = wizard.getTargetFolder();
       } catch (IOException ex) {
           targetFolder = DataFolder.findFolder(project.getProjectDirectory());
       }
       
       SourceGroup[] sourceGroups = ProjectUtils.getSources(project).getSourceGroups(
                                   JavaProjectConstants.SOURCES_TYPE_JAVA);
       if (debug) {
           log ("\tproject: " + project);                          //NOI18N
           log ("\ttargetFolder: " + targetFolder);                //NOI18N
           log ("\tsourceGroups.length: " + sourceGroups.length);  //NOI18N
       }
       
       WizardDescriptor.Panel secondPanel = new ActionPanel(project, wizard);
       WizardDescriptor.Panel thirdPanel = new ActionPanel1(project);
       
       WizardDescriptor.Panel javaPanel;
       if (sourceGroups.length == 0)
           javaPanel = new FinishableProxyWizardPanel(Templates.createSimpleTargetChooser(project, sourceGroups, secondPanel));
       else
           javaPanel = new FinishableProxyWizardPanel(JavaTemplates.createPackageChooser(project, sourceGroups, secondPanel));
       
       panels = new WizardDescriptor.Panel[] { javaPanel, thirdPanel };
       
       // Creating steps.
       Object prop = wizard.getProperty (WizardDescriptor.PROP_CONTENT_DATA); // NOI18N
       String[] beforeSteps = null;
       if (prop != null && prop instanceof String[]) {
           beforeSteps = (String[])prop;
       }
       String[] steps = createSteps (beforeSteps, panels);
       
       for (int i = 0; i < panels.length; i++) { 
           JComponent jc = (JComponent)panels[i].getComponent ();
           if (steps[i] == null) {
               steps[i] = jc.getName ();
           }
    jc.putClientProperty (WizardDescriptor.PROP_CONTENT_SELECTED_INDEX, new Integer (i)); // NOI18N 
    jc.putClientProperty (WizardDescriptor.PROP_CONTENT_DATA, steps); // NOI18N
}
   }
 
Example 19
Source Project: netbeans   File: BeansXmlIterator.java    License: Apache License 2.0 4 votes vote down vote up
public void initialize(TemplateWizard wizard) {
    WizardDescriptor.Panel folderPanel;
    Project project = Templates.getProject( wizard );
    
    FileObject  targetFolder = getTargetFolder(project);
    
    Sources sources = project.getLookup().lookup(Sources.class);
    SourceGroup[] sourceGroups; 
    String parentFolder  = null;
    if ( type == J2eeProjectType.WAR){
        sourceGroups = sources.getSourceGroups(WebProjectConstants.TYPE_DOC_ROOT);
        if ( targetFolder!=null && targetFolder.getFileObject(defaultName+".xml")!=null){
            parentFolder = WEB_INF;
        }
    }
    else {
        if ( type != null && 
                targetFolder!=null && targetFolder.getFileObject(defaultName+".xml")!=null )
        {
            parentFolder = targetFolder.getName();
        }
        sourceGroups = sources.getSourceGroups(Sources.TYPE_GENERIC);
    }
    
    SimpleTargetChooserBuilder builder = Templates.
            buildSimpleTargetChooser(project, sourceGroups);
    
    builder = builder.bottomPanel( new FakePanel(parentFolder));
    folderPanel = builder.create();
    
    panels = new WizardDescriptor.Panel[] { folderPanel };

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

    for (int i = 0; i < panels.length; i++) {
        JComponent jc = (JComponent)panels[i].getComponent ();
        if (steps[i] == null) {
            steps[i] = jc.getName ();
        }
        jc.putClientProperty (WizardDescriptor.PROP_CONTENT_SELECTED_INDEX, Integer.valueOf(i));
        jc.putClientProperty (WizardDescriptor.PROP_CONTENT_DATA, steps); 
    }

    Templates.setTargetName(wizard, defaultName);
    Templates.setTargetFolder(wizard, targetFolder );
}
 
Example 20
Source Project: netbeans   File: BuildImageWizard.java    License: Apache License 2.0 4 votes vote down vote up
@NbBundle.Messages("LBL_BuildImage=Build Image")
public void show() {
    List<WizardDescriptor.Panel<WizardDescriptor>> panels = new ArrayList<>();
    if (instance == null) {
        panels.add(new BuildInstancePanel());
    }
    panels.add(new BuildContextPanel(fileSystem));
    panels.add(new BuildOptionsPanel());
    String[] steps = new String[panels.size()];
    for (int i = 0; i < panels.size(); i++) {
        JComponent c = (JComponent) panels.get(i).getComponent();
        // Default step name to component name of panel.
        steps[i] = c.getName();
        c.putClientProperty(WizardDescriptor.PROP_CONTENT_SELECTED_INDEX, i);
        c.putClientProperty(WizardDescriptor.PROP_CONTENT_DATA, steps);
        c.putClientProperty(WizardDescriptor.PROP_AUTO_WIZARD_STYLE, true);
        c.putClientProperty(WizardDescriptor.PROP_CONTENT_DISPLAYED, true);
        c.putClientProperty(WizardDescriptor.PROP_CONTENT_NUMBERED, true);
    }

    WizardDescriptor wiz = new WizardDescriptor(new WizardDescriptor.ArrayIterator<>(panels));
    // {0} will be replaced by WizardDesriptor.Panel.getComponent().getName()
    wiz.setTitleFormat(new MessageFormat("{0}"));
    wiz.setTitle(Bundle.LBL_BuildImage());

    if (instance != null) {
        wiz.putProperty(INSTANCE_PROPERTY, instance);
    }
    if (dockerfile != null && dockerfile.isData()) {
        wiz.putProperty(BUILD_CONTEXT_PROPERTY, dockerfile.getParent().getPath());
        wiz.putProperty(DOCKERFILE_PROPERTY, dockerfile.getName());
    }
    wiz.putProperty(FILESYSTEM_PROPERTY, fileSystem);

    if (DialogDisplayer.getDefault().notify(wiz) == WizardDescriptor.FINISH_OPTION) {
        Boolean pull = (Boolean) wiz.getProperty(PULL_PROPERTY);
        Boolean noCache = (Boolean) wiz.getProperty(NO_CACHE_PROPERTY);
        build((DockerInstance) wiz.getProperty(INSTANCE_PROPERTY),
                (String) wiz.getProperty(BUILD_CONTEXT_PROPERTY),
                (String) wiz.getProperty(DOCKERFILE_PROPERTY),
                (Map<String, String>) wiz.getProperty(BUILD_ARGUMENTS_PROPERTY),
                (String) wiz.getProperty(REPOSITORY_PROPERTY),
                (String) wiz.getProperty(TAG_PROPERTY),
                pull != null ? pull : PULL_DEFAULT,
                noCache != null ? noCache : NO_CACHE_DEFAULT);
    }
}