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

The following are Jave code examples for showing how to use putClientProperty() of the javax.swing.JComponent class. You can vote up the examples you like. Your votes will be used in our system to get more good examples.
+ Save this method
Example 1
Project: incubator-netbeans   File: EditorUI.java   View Source Code Vote up 7 votes
protected JComponent createExtComponent() {
    setLineNumberEnabled(true); // enable line numbering

    // extComponent will be a panel
    JComponent ec = new JPanel(new BorderLayout());
    ec.putClientProperty(JTextComponent.class, component);

    // Add the scroll-pane with the component to the center
    JScrollPane scroller = new JScrollPane(component);
    scroller.getViewport().setMinimumSize(new Dimension(4,4));
    
    // remove default scroll-pane border, winsys will handle borders itself           
    scroller.setBorder(null);
    
    setGlyphGutter(new GlyphGutter(this));
    scroller.setRowHeaderView(glyphGutter);

    initGlyphCorner(scroller);
    
    ec.add(scroller);

    // Install the status-bar panel to the bottom
    ec.add(getStatusBar().getPanel(), BorderLayout.SOUTH);
    
    return ec;
}
 
Example 2
Project: Pogamut3   File: TemplateBotProjectWizardIterator.java   View Source Code Vote up 6 votes
@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("WizardPanel_contentSelectedIndex", new Integer(i));
            // Step name (actually the whole list for reference).
            jc.putClientProperty("WizardPanel_contentData", steps);
        }
    }
}
 
Example 3
Project: incubator-netbeans   File: XSLWizardIterator.java   View Source Code Vote up 5 votes
/**
 * Initialization of the wizard iterator.
 */
public void initialize(TemplateWizard wizard) {
    index = 0;
    Project project = Templates.getProject( wizard );
    panels = createPanels (project, wizard);
    
    // Creating steps.
    Object prop = wizard.getProperty (WizardDescriptor.PROP_CONTENT_DATA); // NOI18N
    String[] beforeSteps = null;
    if (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, Integer.valueOf(i)); // NOI18N
            // Step name (actually the whole list for reference).
            jc.putClientProperty (WizardDescriptor.PROP_CONTENT_DATA, steps); // NOI18N
        }
    }        
}
 
Example 4
Project: incubator-netbeans   File: CheckoutWizard.java   View Source Code Vote up 5 votes
@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 5
Project: chipKIT-importer   File: ChipKitImportWizardIterator.java   View Source Code Vote up 5 votes
@Override
public void initialize( WizardDescriptor wd ) {
    this.wiz = wd;
    
    importWorker = new ImportWorker(languageToolchain, wiz);
    
    wiz.putProperty(WizardProperty.APPLICATION_TYPE.key(), (Integer) TYPE_APPLICATION);
    wiz.setTitleFormat(new MessageFormat("{0}"));
    wiz.setTitle( NbBundle.getMessage(ChipKitImportWizardIterator.class, "WizardTitle") );        
    
    panels = new WizardDescriptor.Panel[]{            
        new ProjectSetupStep( arduinoConfig ),
        new ProgrammerDebuggerSelectionStep(),
        new ProgressTrackingStep( importWorker )
    };
    
    String[] steps = new String[panels.length];

    for (int i = 0; i < panels.length; i++) {
        Component c = panels[i].getComponent();
        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, 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
        }
    }

}
 
Example 6
Project: incubator-netbeans   File: JavaFXSampleProjectIterator.java   View Source Code Vote up 5 votes
void updateStepsList() {
    JComponent component = (JComponent) current().getComponent();
    if (component == null) {
        return;
    }
    String[] list;
    list = new String[]{
        NbBundle.getMessage(PanelConfigureProject.class, "LBL_NWP1_ProjectTitleName"), // NOI18N
    };
    component.putClientProperty(WizardDescriptor.PROP_CONTENT_DATA, list); // NOI18N
    component.putClientProperty(WizardDescriptor.PROP_CONTENT_SELECTED_INDEX, new Integer(currentIndex)); // NOI18N
}
 
Example 7
Project: incubator-netbeans   File: NewJ2SEModularProjectWizardIterator.java   View Source Code Vote up 5 votes
@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 8
Project: incubator-netbeans   File: Wizards.java   View Source Code Vote up 5 votes
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 9
Project: openjdk-jdk10   File: SwingUtilities3.java   View Source Code Vote up 5 votes
/**
  * Registers delegate RepaintManager for {@code JComponent}.
  */
public static void setDelegateRepaintManager(JComponent component,
                                            RepaintManager repaintManager) {
    /* setting up flag in AppContext to speed up lookups in case
     * there are no delegate RepaintManagers used.
     */
    AppContext.getAppContext().put(DELEGATE_REPAINT_MANAGER_KEY,
                                   Boolean.TRUE);

    component.putClientProperty(DELEGATE_REPAINT_MANAGER_KEY,
                                repaintManager);
}
 
Example 10
Project: incubator-netbeans   File: ImporterWizardPanel.java   View Source Code Vote up 5 votes
void initPanel(JComponent comp, int wizardNumber) {
    comp.putClientProperty(WizardDescriptor.PROP_AUTO_WIZARD_STYLE, Boolean.TRUE); // NOI18N
    comp.putClientProperty(WizardDescriptor.PROP_CONTENT_DISPLAYED, Boolean.TRUE); // NOI18N
    comp.putClientProperty(WizardDescriptor.PROP_CONTENT_NUMBERED, Boolean.TRUE); // NOI18N
    comp.putClientProperty(WizardDescriptor.PROP_CONTENT_SELECTED_INDEX,  // NOI18N
            new Integer(wizardNumber));
    comp.putClientProperty(WizardDescriptor.PROP_CONTENT_DATA, new String[] { // NOI18N
        WORKSPACE_LOCATION_STEP, PROJECTS_SELECTION_STEP
    });
    comp.setPreferredSize(new java.awt.Dimension(500, 380));
}
 
Example 11
Project: incubator-netbeans   File: FetchWizard.java   View Source Code Vote up 5 votes
@Override
@SuppressWarnings("unchecked")
protected Panel<WizardDescriptor>[] initializePanels () {
    selectUriStep = new SelectUriStep(repository, remotes, SelectUriStep.Mode.FETCH);
    selectUriStep.addChangeListener(FetchWizard.this);
    fetchBranchesStep = new FetchBranchesStep(repository, FetchBranchesStep.Mode.ACCEPT_NON_EMPTY_SELECTION_ONLY);
    fetchBranchesStep.addChangeListener(FetchWizard.this);
    Panel[] panels = new Panel[] { selectUriStep, fetchBranchesStep };

    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 12
Project: incubator-netbeans   File: NewFileIterator.java   View Source Code Vote up 5 votes
@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 13
Project: incubator-netbeans   File: PushWizard.java   View Source Code Vote up 5 votes
@Override
@SuppressWarnings("unchecked")
protected Panel<WizardDescriptor>[] initializePanels () {
    selectUriStep = new SelectUriStep(repository, remotes, SelectUriStep.Mode.PUSH);
    selectUriStep.addChangeListener(PushWizard.this);
    pushBranchesStep = new PushBranchesStep(repository);
    pushBranchesStep.addChangeListener(PushWizard.this);
    updateBranchReferencesStep = new UpdateBranchReferencesStep(repository);
    updateBranchReferencesStep.addChangeListener(PushWizard.this);
    Panel[] panels = new Panel[] { selectUriStep, pushBranchesStep, updateBranchReferencesStep };

    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 14
Project: incubator-netbeans   File: PullWizard.java   View Source Code Vote up 5 votes
@Override
@SuppressWarnings("unchecked")
protected Panel<WizardDescriptor>[] initializePanels () {
    selectUriStep = new SelectUriStep(repository, remotes, SelectUriStep.Mode.PULL);
    selectUriStep.addChangeListener(PullWizard.this);
    pullBranchesStep = new PullBranchesStep(repository);
    pullBranchesStep.addChangeListener(PullWizard.this);
    Panel[] panels = new Panel[] { selectUriStep, pullBranchesStep };

    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 15
Project: incubator-netbeans   File: BuildImageWizard.java   View Source Code Vote up 4 votes
@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);
    }
}
 
Example 16
Project: incubator-netbeans   File: SimpleTestCaseWizardIterator.java   View Source Code Vote up 4 votes
@Override
    public void initialize(WizardDescriptor wizard) {
        this.wizard = wizard;
        index = 0;
        panels = createPanels(wizard);
        FileObject targetFolder = Templates.getTargetFolder(wizard);
//	DataFolder targetFolder = null;
//	try {
//	    targetFolder = wizard.getTargetFolder();
//	} catch (IOException ex) {
//	    Exceptions.printStackTrace(ex);
//	}
	
        loadSettings(wizard);
        // Make sure list of steps is accurate.
        String[] beforeSteps = null;
        Object prop = wizard.getProperty(WizardDescriptor.PROP_CONTENT_DATA); // 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(WizardDescriptor.PROP_CONTENT_SELECTED_INDEX, i);
                // Step name (actually the whole list for reference).
                jc.putClientProperty(WizardDescriptor.PROP_CONTENT_DATA, steps);
            }
        }

//        String [] panelNames =  new String [] {
//          NbBundle.getMessage(EmptyTestCaseWizardIterator.class,"LBL_panel_chooseFileType"),
//          NbBundle.getMessage(EmptyTestCaseWizardIterator.class,"LBL_panel_ChooseClass")};
//
//        ((javax.swing.JComponent)getClassChooserPanel().getComponent()).putClientProperty(WizardDescriptor.PROP_CONTENT_DATA, panelNames); 
//        ((javax.swing.JComponent)getClassChooserPanel().getComponent()).putClientProperty(WizardDescriptor.PROP_CONTENT_SELECTED_INDEX, new Integer(0));
        if(targetFolder == null) {
            // No test folders yet? Let's try one more time.
            targetFolder = Templates.getTargetFolder(wizard);
//            try {
//                targetFolder = wizard.getTargetFolder();
//            } catch (IOException ex1) {
//                Exceptions.printStackTrace(ex1);
//            }
        }
        WizardDescriptor.Panel<WizardDescriptor> chooserPanel = getClassChooserPanel();
        if(chooserPanel instanceof SimpleTestStepLocation) {
            if(targetFolder != null) {// No test folders yet. IOExceptions already loggged.
                ((SimpleTestStepLocation) chooserPanel).selectLocation(targetFolder);
            }
        }
    }
 
Example 17
Project: openjdk-jdk10   File: bug4337267.java   View Source Code Vote up 4 votes
void setShaping(JComponent c) {
    c.putClientProperty(TextAttribute.NUMERIC_SHAPING,
                NumericShaper.getContextualShaper(NumericShaper.ARABIC));
}
 
Example 18
Project: incubator-netbeans   File: AbstractToolbarFactory.java   View Source Code Vote up 4 votes
public void componentAdded(ContainerEvent e) {
    JComponent jc = (JComponent) e.getChild();
    JToolBar tb = (JToolBar) e.getContainer();
    String ctx = (String) tb.getClientProperty(KEY_CONTAINERCTX);
    jc.putClientProperty (KEY_CONTAINERCTX, ctx);
}
 
Example 19
Project: incubator-netbeans   File: NbEditorUI.java   View Source Code Vote up 4 votes
@Override
    protected JComponent createExtComponent() {

        JTextComponent component = getComponent();
        
        JLayeredPane layers = new LayeredEditorPane(component);
        layers.add(component, JLayeredPane.DEFAULT_LAYER, 0);
//        MyInternalFrame window = new MyInternalFrame();
//        layers.add(window, JLayeredPane.PALETTE_LAYER);
//        window.show();

        // Add the scroll-pane with the component to the center
        JScrollPane scroller = new JScrollPane(layers);
        scroller.getViewport().setMinimumSize(new Dimension(4,4));

        // remove default scroll-pane border, winsys will handle borders itself 
        Border empty = BorderFactory.createEmptyBorder();
        // Important:  Do not delete or use null instead, will cause
        //problems on GTK L&F.  Must set both scroller border & viewport
        //border! - Tim
        scroller.setBorder(empty);
        scroller.setViewportBorder(empty);
        
        if (component.getClientProperty("nbeditorui.vScrollPolicy") != null) {
            scroller.setVerticalScrollBarPolicy(
                    (Integer)component.getClientProperty("nbeditorui.vScrollPolicy"));
        }
        if (component.getClientProperty("nbeditorui.hScrollPolicy") != null) {
            scroller.setHorizontalScrollBarPolicy(
                    (Integer)component.getClientProperty("nbeditorui.hScrollPolicy"));
        }
        // extComponent will be a panel
        JComponent ec = new JPanel(new BorderLayout());
        ec.putClientProperty(JTextComponent.class, component);
        ec.add(scroller);

        // Initialize sidebars
        // Need to clear the cache - it's null at this point when opening file but the sidebars
        // would be reused during L&F change (see BaseTextUI.UIWatcher) which would not work properly.
        CustomizableSideBar.resetSideBars(component);
        Map<SideBarPosition, JComponent> sideBars = CustomizableSideBar.getSideBars(component);
        processSideBars(sideBars, ec, scroller);
        
        if (listener == null){
            listener = new SideBarsListener(component);
            CustomizableSideBar.addChangeListener(NbEditorUtilities.getMimeType(component), listener);
        }
        
        // Initialize the corner component
        initGlyphCorner(scroller);

        return ec;
    }
 
Example 20
Project: incubator-netbeans   File: HibernateRevengWizard.java   View Source Code Vote up 4 votes
/**
 * Initialize panels representing individual wizard's steps and sets
 * various properties for them influencing wizard appearance.
 */
private WizardDescriptor.Panel[] getPanels() {
    if (panels == null) {
        HibernateEnvironment hibernateEnv = (HibernateEnvironment) project.getLookup().lookup(HibernateEnvironment.class);
        // Check for unsupported projects. #142296
        if (hibernateEnv == null) {
            logger.info("Unsupported project " + project + ". Existing config wizard.");
            panels = new WizardDescriptor.Panel[]{
                        WizardErrorPanel.getWizardErrorWizardPanel()
                    };

        } else {
            Project prj = Templates.getProject(wizardDescriptor);

            SourceGroup[] groups = ProjectUtils.getSources(prj).getSourceGroups(Sources.TYPE_GENERIC);
            WizardDescriptor.Panel targetChooser = Templates.createSimpleTargetChooser(prj, groups);

            panels = new WizardDescriptor.Panel[]{
                        targetChooser,
                        dbTablesDescriptor                            
                    };
        }
        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, 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;
}