Search in sources :

Example 1 with TopComponent

use of org.openide.windows.TopComponent in project enclojure by EricThorsen.

the class ReplTopComponent method findInstance.

/**
 * Obtain the ReplTopComponent instance. Never call {@link #getDefault} directly!
 */
public static synchronized ReplTopComponent findInstance() {
    String ideReplID = PREFERRED_ID_prefix + IDE_REPL;
    TopComponent win = WindowManager.getDefault().findTopComponent(ideReplID);
    if (win == null) {
        LOG.log(Level.WARNING, "Cannot find " + ideReplID + " component. It will not be located properly in the window system.");
        return getDefault();
    }
    if (win instanceof ReplTopComponent) {
        return (ReplTopComponent) win;
    }
    LOG.log(Level.WARNING, "There seem to be multiple components with the '" + ideReplID + "' ID. That is a potential source of errors and unexpected behavior.");
    return getDefault();
}
Also used : TopComponent(org.openide.windows.TopComponent)

Example 2 with TopComponent

use of org.openide.windows.TopComponent in project netbeans-mmd-plugin by raydac.

the class MMDGraphEditor method copyNameToCallbackTopComponent.

private void copyNameToCallbackTopComponent() {
    final MultiViewElementCallback c = this.callback;
    if (c != null) {
        final TopComponent tc = c.getTopComponent();
        if (tc != null) {
            tc.setHtmlDisplayName(this.getHtmlDisplayName());
            tc.setDisplayName(this.getDisplayName());
            tc.setName(this.getName());
            tc.setToolTipText(this.getToolTipText());
        }
    }
    if (this.editorSupport != null) {
        this.editorSupport.updateTitles();
    }
}
Also used : MultiViewElementCallback(org.netbeans.core.spi.multiview.MultiViewElementCallback) TopComponent(org.openide.windows.TopComponent)

Example 3 with TopComponent

use of org.openide.windows.TopComponent in project netbeans-mmd-plugin by raydac.

the class MMDNavigator method extractDataFromContextAndUpdate.

private void extractDataFromContextAndUpdate() {
    final Lookup.Result<? extends MMDEditorSupport> ctx = this.context;
    if (ctx == null) {
        this.currentSupport = null;
    } else {
        Collection<? extends MMDEditorSupport> clct = ctx.allInstances();
        if (clct.isEmpty()) {
            final TopComponent active = TopComponent.getRegistry().getActivated();
            if (active != null) {
                clct = active.getLookup().lookupAll(MMDEditorSupport.class);
            }
        }
        if (clct.isEmpty()) {
            this.currentSupport = null;
        } else {
            this.currentSupport = clct.iterator().next();
            if (this.currentSupport != null) {
                this.currentSupport.getDataObject().getPrimaryFile().removeFileChangeListener(this);
                this.currentSupport.getDataObject().getPrimaryFile().addFileChangeListener(this);
            }
        }
    }
    updateContent();
}
Also used : MMDEditorSupport(com.igormaznitsa.nbmindmap.nb.editor.MMDEditorSupport) Lookup(org.openide.util.Lookup) TopComponent(org.openide.windows.TopComponent)

Example 4 with TopComponent

use of org.openide.windows.TopComponent in project ACS by ACS-Community.

the class TestActionButtons method main.

public static void main(String[] args) {
    TopComponent tc = new TopComponent();
    tc.setName("TestActionButtions");
    tc.setLayout(new BorderLayout());
    tc.setPreferredSize(new Dimension(DEFAULT_WIDTH, DEFAULT_HEIGHT));
    JLabel lab = new JLabel("Actions are enabled if you select nodes in the IDE", JLabel.CENTER);
    tc.add(lab, BorderLayout.CENTER);
    JPanel panel = ActionUtils.createJButtonPanel(new Class[] { OpenLocalExplorerAction.class, PropertiesAction.class });
    tc.add(panel, BorderLayout.SOUTH);
    WindowUtils.openInMode(tc, "TestActionButtons");
}
Also used : JPanel(javax.swing.JPanel) BorderLayout(java.awt.BorderLayout) JLabel(javax.swing.JLabel) Dimension(java.awt.Dimension) TopComponent(org.openide.windows.TopComponent)

Example 5 with TopComponent

use of org.openide.windows.TopComponent in project ACS by ACS-Community.

the class WindowUtils method findTopComponent.

/**
   * Utility method: Returns the TopComponent with the given programmatic name in the given workspace, 
   * or <code>null</code> if there is no such TopComponent.
   * @param workspace the workspace in which to look for the TopComponent
   * @param componentName the programmatic name of the TopComponent
   * @return Returns the TopComponent with the given programmatic name, 
   * or <code>null</code> if there is no such TopComponent
   */
public static TopComponent findTopComponent(Workspace workspace, String componentName) {
    Assertion.assertTrue(workspace != null, "workspace != null");
    Assertion.assertTrue(componentName != null, "componentName != null");
    Iterator modesIterator = workspace.getModes().iterator();
    while (modesIterator.hasNext()) {
        Mode mode = (Mode) modesIterator.next();
        TopComponent[] tcs = mode.getTopComponents();
        for (int i = 0; i < tcs.length; i++) {
            TopComponent element = tcs[i];
            if (element.getName().equals(componentName)) {
                return element;
            }
        }
    }
    return null;
}
Also used : Mode(org.openide.windows.Mode) Iterator(java.util.Iterator) TopComponent(org.openide.windows.TopComponent)

Aggregations

TopComponent (org.openide.windows.TopComponent)7 MMDEditorSupport (com.igormaznitsa.nbmindmap.nb.editor.MMDEditorSupport)1 BorderLayout (java.awt.BorderLayout)1 Dimension (java.awt.Dimension)1 ArrayList (java.util.ArrayList)1 Iterator (java.util.Iterator)1 JLabel (javax.swing.JLabel)1 JPanel (javax.swing.JPanel)1 MultiViewElementCallback (org.netbeans.core.spi.multiview.MultiViewElementCallback)1 EditorCookie (org.openide.cookies.EditorCookie)1 Node (org.openide.nodes.Node)1 Lookup (org.openide.util.Lookup)1 Mode (org.openide.windows.Mode)1