Java Code Examples for org.openide.util.HelpCtx#findHelp()

The following examples show how to use org.openide.util.HelpCtx#findHelp() . 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: HelpAction.java    From netbeans with Apache License 2.0 6 votes vote down vote up
private static HelpCtx findHelpCtx() {

        final TopComponent activeTC = TopComponent.getRegistry().getActivated();
        final Window win = WindowActivatedDetector.getCurrentActivatedWindow();
        final Container cont;
        if (activeTC != null && win != null && win.isAncestorOf(activeTC)) {
            cont = activeTC;
        } else {
            cont = win;
        }
        if (cont == null) {
            return HelpCtx.DEFAULT_HELP;
        } else {
            Component focused = SwingUtilities.findFocusOwner(cont);
            HelpCtx help = HelpCtx.findHelp(focused == null ? cont : focused);
            Installer.log.log(Level.FINE, "HelpCtx {0} from {1}",
                    new Object[]{help, focused});
            return help;
        }
    }
 
Example 2
Source File: NbPresenter.java    From netbeans with Apache License 2.0 6 votes vote down vote up
private void updateHelp() {
    //System.err.println ("Updating help for NbDialog...");
    HelpCtx help = getHelpCtx();
    // Handle help from the inner component automatically (see docs
    // in DialogDescriptor):
    if (HelpCtx.DEFAULT_HELP.equals(help)) {
        Object msg = descriptor.getMessage();
        if (msg instanceof Component) {
            help = HelpCtx.findHelp((Component) msg);
        }
        if (HelpCtx.DEFAULT_HELP.equals(help)) help = null;
    }
    if (! Utilities.compareObjects(currentHelp, help)) {
        currentHelp = help;
        if (help != null && help.getHelpID() != null) {
            //System.err.println ("New help ID for root pane: " + help.getHelpID ());
            HelpCtx.setHelpIDString(getRootPane(), help.getHelpID());
        }
        // Refresh button list if it had already been created.
        if (haveCalledInitializeButtons) initializeButtons();
    }
}
 
Example 3
Source File: FormCustomEditor.java    From netbeans with Apache License 2.0 5 votes vote down vote up
private void updateHelpAndAccessibleDescription() {
    HelpCtx.setHelpIDString(this, null);
    int i = editorsCombo.getSelectedIndex();
    HelpCtx helpCtx = i < 0 ? null : HelpCtx.findHelp(cardPanel.getComponent(i));
    String helpID = helpCtx != null && helpCtx != HelpCtx.DEFAULT_HELP ? helpCtx.getHelpID() : "f1_mat_prop_html"; // NOI18N
    HelpCtx.setHelpIDString(this, helpID);

    updateAccessibleDescription(i < 0 ? null : cardPanel.getComponent(i));
}
 
Example 4
Source File: HelpAction.java    From netbeans with Apache License 2.0 5 votes vote down vote up
@Override public void actionPerformed(ActionEvent ev) {
    Help h = (Help)Lookup.getDefault().lookup(Help.class);
    if (h == null) {
        Toolkit.getDefaultToolkit().beep();
        return;
    }

    HelpCtx help;
    
    final MenuElement[] path =
        MenuSelectionManager.defaultManager().getSelectedPath();

    if (path != null
        && path.length > 0
        && !(path[0].getComponent() instanceof javax.swing.plaf.basic.ComboPopup)
        ) {
        help = HelpCtx.findHelp(path[path.length - 1].getComponent());
        
        SwingUtilities.invokeLater(new Runnable() {
            public void run() {
                MenuElement[] newPath =
                    MenuSelectionManager.defaultManager().getSelectedPath();

                if (newPath.length != path.length)
                    return;
                for (int i = 0; i < newPath.length; i++) {
                    if (newPath[i] != path[i])
                        return;
                }
                MenuSelectionManager.defaultManager().clearSelectedPath();
            }
        });
    }
    else {
        help = findHelpCtx();
    }
    
    StatusDisplayer.getDefault().setStatusText(NbBundle.getMessage(HelpAction.class, "CTL_OpeningHelp"));
    h.showHelp (help);
}
 
Example 5
Source File: NodeOperationImpl.java    From netbeans with Apache License 2.0 5 votes vote down vote up
public HelpCtx getHelpCtx () {
    try {
        //??? eliminate recursion it delegates to parent (this)
        if (active) return null;
        active = true;
        return HelpCtx.findHelp(innerComp);  
    } finally  {
        active = false;
    }
}
 
Example 6
Source File: BeanNode.java    From netbeans with Apache License 2.0 5 votes vote down vote up
@Override
public HelpCtx getHelpCtx() {
    HelpCtx h = HelpCtx.findHelp(bean);

    if (h != HelpCtx.DEFAULT_HELP) {
        return h;
    } else {
        return new HelpCtx(BeanNode.class);
    }
}
 
Example 7
Source File: CIEntryEditPanel.java    From nb-ci-plugin with GNU General Public License v2.0 5 votes vote down vote up
private void setHelpToChooser(JFileChooser chooser) {
    HelpCtx help = HelpCtx.findHelp(this);

    if (help != null) {
        HelpCtx.setHelpIDString(chooser, help.getHelpID());
    }
}
 
Example 8
Source File: NbClassPathCustomEditor.java    From netbeans with Apache License 2.0 4 votes vote down vote up
private void setHelpToChooser( JFileChooser chooser ) {
    HelpCtx help = HelpCtx.findHelp( this );
    if ( help != null )
        HelpCtx.setHelpIDString(chooser, help.getHelpID());
}
 
Example 9
Source File: CustomizerPane.java    From netbeans with Apache License 2.0 4 votes vote down vote up
private void setCategory(final ProjectCustomizer.Category newCategory) {
    if ( newCategory == null ) {
        return;
    }
    
    if ( currentCustomizer != null ) {
        customizerPanel.remove( currentCustomizer );
    }

    JComponent newCustomizer = panelCache.get(newCategory);
    if (newCustomizer == null && !panelCache.containsKey(newCustomizer)) {
        newCustomizer = componentProvider.create( newCategory );
        panelCache.put(newCategory, newCustomizer);
    }

    if ( newCustomizer != null ) {
        Utilities.getCategoryChangeSupport(newCategory).addPropertyChangeListener(new PropertyChangeListener() {
            public @Override void propertyChange(PropertyChangeEvent evt) {
                setErrorMessage(newCategory.getErrorMessage(), newCategory.isValid());
            }
        });
        currentCustomizer = newCustomizer;            
        currentHelpCtx = HelpCtx.findHelp( currentCustomizer );
        /*if (previousDimension == null) {
            previousDimension = currentCustomizer.getSize();
        }
        int newWidth = 0;
        int newHeight = 0;
        if (previousDimension != null) {
            newWidth = previousDimension.width;
            newHeight = previousDimension.height;
            if (currentCustomizer.getPreferredSize().width > previousDimension.width) {
                newWidth = currentCustomizer.getPreferredSize().width;
                int maxWidth = WindowManager.getDefault().getMainWindow().getGraphicsConfiguration().getBounds().width * 3 / 4;
                if (newWidth > maxWidth) {
                    newWidth = maxWidth;
                }
            }
            if (currentCustomizer.getPreferredSize().height > previousDimension.height) {
                newHeight = currentCustomizer.getPreferredSize().height;
                int maxHeght = WindowManager.getDefault().getMainWindow().getGraphicsConfiguration().getBounds().height * 3 / 4;
                if (newHeight > maxHeght) {
                    newHeight = maxHeght;
                }
            }
        }

        Dimension newDim = new Dimension(newWidth, newHeight);
        currentCustomizer.setPreferredSize(newDim);
        previousDimension = newDim;*/

        /*Preferences prefs = NbPreferences.forModule(org.netbeans.modules.project.uiapi.CustomizerPane.class);
        prefs.put(CUSTOMIZER_DIALOG_WIDTH, Integer.toString(newDim.width));
        prefs.put(CUSTOMIZER_DIALOG_HEIGHT, Integer.toString(newDim.height));*/

        customizerPanel.add( currentCustomizer, fillConstraints );
        customizerPanel.validate();
        customizerPanel.repaint();

        /*if (customizerPanel != null) {
            Window window = SwingUtilities.getWindowAncestor(customizerPanel);
            if (window != null) {
                window.pack();
                window.setBounds(org.openide.util.Utilities.findCenterBounds(window.getSize()));
            }
        }*/
        
        setErrorMessage(newCategory.getErrorMessage(), newCategory.isValid());
        firePropertyChange( HELP_CTX_PROPERTY, null, getHelpCtx() );
    } else {
        currentCustomizer = null;
    }
}
 
Example 10
Source File: AddBreakpointPanel.java    From netbeans with Apache License 2.0 4 votes vote down vote up
private void update (BreakpointType t) {
    if (type == t) return ;
    pEvent.removeAll ();
    DebuggerManager d = DebuggerManager.getDebuggerManager ();
    BreakpointType old = type;
    type = t;
    customizer = type.getCustomizer ();
    if (customizer == null) return;

    //Set HelpCtx. This method must be called _before_ the customizer
    //is added to some container, otherwise HelpCtx.findHelp(...) would
    //query also the customizer's parents.
    // <RAVE>
    // The help IDs for the customizer panels have to be different from the
    // values returned by getHelpCtx() because they provide different help
    // in the 'Add Breakpoint' dialog and when invoked in the 'Breakpoints' view
    // helpCtx = HelpCtx.findHelp (customizer);
    // ====
    String hid = (String) customizer.getClientProperty("HelpID_AddBreakpointPanel"); // NOI18N
    if (hid != null) {
        helpCtx = new HelpCtx(hid);
    } else {
        helpCtx = HelpCtx.findHelp (customizer);
    }
    // </RAVE>

    pEvent.add (customizer, "Center"); // NOI18N
    pEvent.getAccessibleContext ().setAccessibleDescription (
        customizer.getAccessibleContext ().getAccessibleDescription ()
    );
    customizer.getAccessibleContext ().setAccessibleName (
        pEvent.getAccessibleContext ().getAccessibleName ()
    );
    revalidate ();
    SwingUtilities.invokeLater(new Runnable() {
        @Override
        public void run() {
            Window w = SwingUtilities.windowForComponent (AddBreakpointPanel.this);
            if (w == null) return;
            w.pack ();
        }
    });
    firePropertyChange (PROP_TYPE, old, type);
}