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

The following examples show how to use javax.swing.JComponent#putClientProperty() . 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: ExportToJdbcAction.java    From constellation with Apache License 2.0 6 votes vote down vote up
@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 2
Source File: CordovaSampleIterator.java    From netbeans with Apache License 2.0 6 votes vote down vote up
@Override
public void initialize(WizardDescriptor wizard) {
    descriptor = wizard;
    myPanels = createPanels(wizard);

    String[] steps = createSteps();
    for (int i = 0; i < myPanels.length; i++) {
        Component c = myPanels[i].getComponent();
        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 3
Source File: NewFileWizardIterator.java    From netbeans with Apache License 2.0 6 votes vote down vote up
@Override
public void initialize(WizardDescriptor wizard) {
    this.descriptor = wizard;
    setTargetFolder();
    panels = getPanels();

    // make sure list of steps is accurate.
    String[] beforeSteps = (String[]) wizard.getProperty(WizardDescriptor.PROP_CONTENT_DATA);
    int beforeStepLength = beforeSteps.length - 1;
    String[] steps = createSteps(beforeSteps);
    for (int i = 0; i < panels.length; i++) {
        Component c = panels[i].getComponent();
        if (c instanceof JComponent) { // assume Swing components
            JComponent jc = (JComponent) c;
            jc.putClientProperty(WizardDescriptor.PROP_CONTENT_SELECTED_INDEX, Integer.valueOf(i + beforeStepLength - 1));
            jc.putClientProperty(WizardDescriptor.PROP_CONTENT_DATA, steps);
        }
    }
}
 
Example 4
Source File: NewFileWizardIterator.java    From netbeans with Apache License 2.0 6 votes vote down vote up
@Override
public void initialize(WizardDescriptor wizard) {
    this.wizard = wizard;
    phpProject = getPhpProject();
    checkPhpProject();
    setTargetFolder();
    wizardPanels = getPanels();

    // Make sure list of steps is accurate.
    String[] beforeSteps = (String[]) wizard.getProperty(WizardDescriptor.PROP_CONTENT_DATA);
    int beforeStepLength = beforeSteps.length - 1;
    String[] steps = createSteps(beforeSteps);
    for (int i = 0; i < wizardPanels.length; i++) {
        Component c = wizardPanels[i].getComponent();
        if (c instanceof JComponent) { // assume Swing components
            JComponent jc = (JComponent) c;
            jc.putClientProperty(WizardDescriptor.PROP_CONTENT_SELECTED_INDEX, Integer.valueOf(i + beforeStepLength - 1)); // NOI18N
            jc.putClientProperty(WizardDescriptor.PROP_CONTENT_DATA, steps); // NOI18N
        }
    }
}
 
Example 5
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 = createSteps();
    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", Integer.valueOf(i)); //NOI18N
            // Step name (actually the whole list for reference).
            jc.putClientProperty("WizardPanel_contentData", steps); //NOI18N
        }
    }
}
 
Example 6
Source File: IDENativeMavenWizardIterator.java    From netbeans with Apache License 2.0 6 votes vote down vote up
@Override
@Messages("LBL_CreateProjectStep2=Name and Location")
public void initialize(WizardDescriptor wiz) {
    this.wiz = wiz;
    if (titlename != null) {
        wiz.putProperty ("NewProjectWizard_Title", titlename); // NOI18N        
    }
    index = 0;
    ValidationGroup vg = ValidationGroup.create(new WizardDescriptorAdapter(wiz));
    panels = new ArrayList<WizardDescriptor.Panel<WizardDescriptor>>();
    List<String> steps = new ArrayList<String>();
    
    panels.add(new BasicWizardPanel(vg, null, true, false, null)); //only download archetype (for additional props) when unknown archetype is used.
    steps.add(LBL_CreateProjectStep2());
    for (int i = 0; i < panels.size(); i++) {
        JComponent c = (JComponent) panels.get(i).getComponent();
        c.putClientProperty(WizardDescriptor.PROP_CONTENT_SELECTED_INDEX, i);
        c.putClientProperty(WizardDescriptor.PROP_CONTENT_DATA, steps.toArray(new String[0]));
  }
    
}
 
Example 7
Source File: NewBloomFilterAction.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 BloomWizardPanel1()
        };
        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 8
Source File: WLInstantiatingIterator.java    From netbeans with Apache License 2.0 5 votes vote down vote up
private void initComponent(Component c, int step) {
    if (c instanceof JComponent) {
        JComponent jc = (JComponent) c;
        // Step #.
        jc.putClientProperty(
            WizardDescriptor.PROP_CONTENT_SELECTED_INDEX, step);

        // Step name (actually the whole list for reference).
        jc.putClientProperty(WizardDescriptor.PROP_CONTENT_DATA, steps);
    }
}
 
Example 9
Source File: CreateAvdWizardIterator.java    From NBANDROID-V2 with Apache License 2.0 5 votes vote down vote up
private List<WizardDescriptor.Panel<WizardDescriptor>> getPanels() {
    if (panels == null) {
        panels = new ArrayList<>();
        panels.add(new CreateAvdWizardPanel1(wizard));
        panels.add(new CreateAvdWizardPanel2(wizard));
        panels.add(new CreateAvdWizardPanel3(wizard));
        String[] steps = createSteps();
        for (int i = 0; i < panels.size(); i++) {
            Component c = panels.get(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;
                jc.putClientProperty(WizardDescriptor.PROP_CONTENT_SELECTED_INDEX, i);
                jc.putClientProperty(WizardDescriptor.PROP_CONTENT_DATA, steps);
                jc.putClientProperty(WizardDescriptor.PROP_AUTO_WIZARD_STYLE, true);
                jc.putClientProperty(WizardDescriptor.PROP_CONTENT_DISPLAYED, true);
                jc.putClientProperty(WizardDescriptor.PROP_CONTENT_NUMBERED, true);
            }
        }
    }
    return panels;
}
 
Example 10
Source File: ListenerIterator.java    From netbeans with Apache License 2.0 5 votes vote down vote up
public void initialize (WizardDescriptor wiz) {
    this.wiz = (TemplateWizard) wiz;
    index = 0;
    panels = createPanels (this.wiz);
    
    // 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 11
Source File: PaddingInfo.java    From pumpernickel with MIT License 5 votes vote down vote up
/**
 * Should be called shortly after <code>prep()</code>.
 */
private static void restore(Component c) {
	if (c instanceof JComponent) {
		JComponent jc = (JComponent) c;
		Boolean b = (Boolean) jc.getClientProperty(USED_TO_BE_OPAQUE);
		if (b != null && b.booleanValue()) {
			jc.setOpaque(true);
		}
		jc.putClientProperty(USED_TO_BE_OPAQUE, null);

		Dimension d = (Dimension) jc.getClientProperty(SIZE);
		if (d != null) {
			jc.setSize(d);
			jc.putClientProperty(SIZE, null);
		}
	}
	if (c instanceof JSlider) {
		JSlider s = (JSlider) c;
		ChangeListener[] listeners = (ChangeListener[]) s
				.getClientProperty(CHANGE_LISTENERS);
		Integer i = (Integer) s.getClientProperty(SLIDER_VALUE);
		if (i != null)
			s.setValue(i.intValue());
		if (listeners != null) {
			for (int a = 0; a < listeners.length; a++) {
				s.addChangeListener(listeners[a]);
			}
		}
		s.putClientProperty(SLIDER_VALUE, null);
		s.putClientProperty(CHANGE_LISTENERS, null);
	}
	if (c instanceof Container) {
		Container c2 = (Container) c;
		for (int a = 0; a < c2.getComponentCount(); a++) {
			restore(c2.getComponent(a));
		}
	}
}
 
Example 12
Source File: TemplateClientIterator.java    From netbeans with Apache License 2.0 5 votes vote down vote up
@Override
public void initialize(TemplateWizard wiz) {
    index = 0;
    Project project = Templates.getProject( wiz );
    panels = createPanels(project, wiz);
    
    // 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 = 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, new Integer(i));
            // Step name (actually the whole list for reference).
            jc.putClientProperty(WizardDescriptor.PROP_CONTENT_DATA, steps);
        }
    }
}
 
Example 13
Source File: SeaGlassMenuUI.java    From seaglass with Apache License 2.0 5 votes vote down vote up
/**
 * @inheritDoc
 */
@Override
public void uninstallUI(JComponent c) {
    super.uninstallUI(c);
    // Remove values from the parent's Client Properties.
    JComponent p = MenuItemLayoutHelper.getMenuItemParent((JMenuItem) c);
    if (p != null) {
        p.putClientProperty(SeaGlassMenuItemLayoutHelper.MAX_ACC_OR_ARROW_WIDTH, null);
    }
}
 
Example 14
Source File: PayaraDDWizardIterator.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 PayaraDDWizardPanel()
        };
        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
                jc.putClientProperty(WizardDescriptor.PROP_CONTENT_SELECTED_INDEX, Integer.valueOf(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 15
Source File: BrightnessIncreaseDemo.java    From filthy-rich-clients with BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
public static void increaseTextBrightness(JComponent c) {
    Color color = c.getForeground();
    c.putClientProperty("mouseover_brightness", color);
    float[] hsb = Color.RGBtoHSB(color.getRed(), color.getGreen(), color.getBlue(), null);
    
    hsb[2] = Math.min(1.0f, hsb[2] * 2.0f);
    c.setForeground(Color.getHSBColor(hsb[0], hsb[1], hsb[2]));
}
 
Example 16
Source File: AddInstanceIterator.java    From netbeans with Apache License 2.0 4 votes vote down vote up
private void setContentSelectedIndex(JComponent component) {
    if (component.getClientProperty(PROP_CONTENT_SELECTED_INDEX) == null) {
        component.putClientProperty(PROP_CONTENT_SELECTED_INDEX, Integer.valueOf(0));
    }
}
 
Example 17
Source File: InitializrProjectWizardIterator.java    From nb-springboot with Apache License 2.0 4 votes vote down vote up
@Override
public void initialize(WizardDescriptor wiz) {
    this.wiz = wiz;
    wiz.putProperty("NewProjectWizard_Title", NbBundle.getMessage(InitializrProjectWizardIterator.class, "LBL_WizardTitle")); //NOI18N
    index = 0;
    // set other defaults
    this.wiz.putProperty(WIZ_USE_SB_MVN_PLUGIN, true);
    this.wiz.putProperty(WIZ_REMOVE_MVN_WRAPPER, true);
    // create the wizard panels
    panels = new WizardDescriptor.Panel[]{
        new InitializrProjectWizardPanel1(),
        new InitializrProjectWizardPanel2(),
        new InitializrProjectWizardPanel3()
    };
    // Make sure list of steps is accurate.
    String[] steps = new String[]{
        NbBundle.getMessage(InitializrProjectWizardIterator.class, "LBL_BasePropsStep"),
        NbBundle.getMessage(InitializrProjectWizardIterator.class, "LBL_DependenciesStep"),
        NbBundle.getMessage(InitializrProjectWizardIterator.class, "LBL_CreateProjectStep")
    };
    // create wizard steps gui components
    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);
        }
    }
    // schedule async retrieval of initializr metadata in panel visual 1
    Utilities.attachInitJob(panels[0].getComponent(), (AsyncGUIJob) panels[0].getComponent());
}
 
Example 18
Source File: QComboBoxUI.java    From pumpernickel with MIT License 4 votes vote down vote up
@Override
public void mouseExited(MouseEvent e) {
	JComponent jc = (JComponent) e.getComponent();
	jc.putClientProperty(PROPERTY_IS_MOUSE_ROLLOVER, Boolean.FALSE);
}
 
Example 19
Source File: FileList.java    From pumpernickel with MIT License 4 votes vote down vote up
protected synchronized void updateFileListComponents() {
	throbber.setVisible(!finishedSearch);
	removeAll();
	GridBagConstraints c = new GridBagConstraints();
	c.gridx = getColumnCount() - 1;
	c.gridy = 0;
	c.weightx = 0;
	c.weighty = 0;
	c.insets = new Insets(5, 5, 5, 5);
	c.anchor = GridBagConstraints.EAST;
	add(throbber, c);

	c.gridx = 0;
	c.weightx = 1;
	c.anchor = GridBagConstraints.WEST;
	c.fill = GridBagConstraints.BOTH;
	if (constrainedList.getSize() == 0) {
		if (finishedSearch) {
			add(emptyLabel, c);
		} else {
			add(searchingLabel, c);
		}
	}

	for (int a = 0; a < constrainedList.getSize(); a++) {
		File file = constrainedList.getElementAt(a);
		JComponent jc = componentCache.get(file);
		if (jc == null) {
			jc = createComponent(file);
			jc.putClientProperty(KEY_FILE, file);
			componentCache.put(file, jc);
		}

		add(jc, c);
		c.gridx = (c.gridx + 1) % getColumnCount();
		if (c.gridx == 0)
			c.gridy++;
	}
	c.gridy++;
	c.weighty = 1;
	add(fluff, c);

	revalidate();
	repaint();
}
 
Example 20
Source File: GridUtils.java    From netbeans with Apache License 2.0 3 votes vote down vote up
/**
 * Creates a padding component.
 *
 * @param horizontalPadding determines whether we are interested in horizontal padding.
 * @param verticalPadding determines whether we are interested in vertical padding.
 * @param paddingSize determines padding component size in pixels.
 * @return new padding component.
 */
private static Component createPaddingComponent(boolean horizontalPadding, boolean verticalPadding, int paddingSize) {
    Dimension dim = new Dimension(horizontalPadding ? paddingSize : 0, verticalPadding ? paddingSize : 0);
    JComponent padding = (JComponent)Box.createRigidArea(dim);
    padding.putClientProperty(PADDING_COMPONENT, Boolean.TRUE);
    return padding;
}