Java Code Examples for org.openide.explorer.ExplorerUtils#createLookup()
The following examples show how to use
org.openide.explorer.ExplorerUtils#createLookup() .
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: ErrorNavigatorProviderImpl.java From netbeans with Apache License 2.0 | 6 votes |
public JComponent getComponent() { if (panel == null) { final BeanTreeView view = new BeanTreeView(); view.setRootVisible(false); view.setSelectionMode(ListSelectionModel.SINGLE_SELECTION); class Panel extends JPanel implements ExplorerManager.Provider, Lookup.Provider { // Make sure action context works correctly: private final Lookup lookup = ExplorerUtils.createLookup(manager, new ActionMap()); { setLayout(new BorderLayout()); add(view, BorderLayout.CENTER); } public ExplorerManager getExplorerManager() { return manager; } public Lookup getLookup() { return lookup; } } panel = new Panel(); } return panel; }
Example 2
Source File: ElementNavigatorProviderImpl.java From netbeans with Apache License 2.0 | 6 votes |
public JComponent getComponent() { if (panel == null) { final BeanTreeView view = new BeanTreeView(); view.setRootVisible(true); view.setSelectionMode(ListSelectionModel.SINGLE_SELECTION); class Panel extends JPanel implements ExplorerManager.Provider, Lookup.Provider { // Make sure action context works correctly: private final Lookup lookup = ExplorerUtils.createLookup(manager, new ActionMap()); { setLayout(new BorderLayout()); add(view, BorderLayout.CENTER); } public ExplorerManager getExplorerManager() { return manager; } public Lookup getLookup() { return lookup; } } panel = new Panel(); } return panel; }
Example 3
Source File: ClasspathNavigatorProviderImpl.java From netbeans with Apache License 2.0 | 6 votes |
public JComponent getComponent() { if (panel == null) { final PropertySheetView view = new PropertySheetView(); class Panel extends JPanel implements ExplorerManager.Provider, Lookup.Provider { // Make sure action context works correctly: private final Lookup lookup = ExplorerUtils.createLookup(manager, new ActionMap()); { setLayout(new BorderLayout()); add(view, BorderLayout.CENTER); } public ExplorerManager getExplorerManager() { return manager; } public Lookup getLookup() { return lookup; } } panel = new Panel(); } return panel; }
Example 4
Source File: TreeNavigatorProviderImpl.java From netbeans with Apache License 2.0 | 6 votes |
public JComponent getComponent() { if (panel == null) { final BeanTreeView view = new BeanTreeView(); view.setRootVisible(true); view.setSelectionMode(ListSelectionModel.SINGLE_SELECTION); class Panel extends JPanel implements ExplorerManager.Provider, Lookup.Provider { // Make sure action context works correctly: private final Lookup lookup = ExplorerUtils.createLookup(manager, new ActionMap()); { setLayout(new BorderLayout()); add(view, BorderLayout.CENTER); } public ExplorerManager getExplorerManager() { return manager; } public Lookup getLookup() { return lookup; } } panel = new Panel(); } return panel; }
Example 5
Source File: AbstractSearchResultsPanel.java From netbeans with Apache License 2.0 | 6 votes |
/** * Creates new form AbstractSearchResultsPanel */ public AbstractSearchResultsPanel(SearchComposition<?> searchComposition, SearchProvider.Presenter searchProviderPresenter) { this.searchComposition = searchComposition; this.searchProviderPresenter = searchProviderPresenter; initComponents(); explorerManager = new ExplorerManager(); ActionMap map = this.getActionMap(); // map delete key to delete action map.put("delete", //NOI18N ExplorerUtils.actionDelete(explorerManager, false)); map.put(DefaultEditorKit.copyAction, ExplorerUtils.actionCopy(explorerManager)); map.put(DefaultEditorKit.cutAction, ExplorerUtils.actionCut(explorerManager)); lookup = ExplorerUtils.createLookup(explorerManager, ResultView.getInstance().getActionMap()); initActions(); initToolbar(); initSelectionListeners(); }
Example 6
Source File: ListViewNavigatorPanel.java From netbeans with Apache License 2.0 | 6 votes |
public ListViewNavigatorPanel () { manager = new ExplorerManager(); ActionMap map = getActionMap(); copyAction = ExplorerUtils.actionCopy(manager); map.put(DefaultEditorKit.copyAction, copyAction); map.put(DefaultEditorKit.cutAction, ExplorerUtils.actionCut(manager)); map.put(DefaultEditorKit.pasteAction, ExplorerUtils.actionPaste(manager)); map.put("delete", ExplorerUtils.actionDelete(manager, true)); // or false lookup = ExplorerUtils.createLookup(manager, map); listView = new ListView(); fillListView(listView); add(listView); }
Example 7
Source File: ComponentHierarchy.java From netbeans with Apache License 2.0 | 5 votes |
private void createComponents() { explorerManager = new ExplorerManager(); lookup = ExplorerUtils.createLookup(explorerManager, getActionMap()); setLayout(new java.awt.BorderLayout()); treeView = new BeanTreeView(); add(treeView, BorderLayout.CENTER); }
Example 8
Source File: PhadhailViews.java From netbeans with Apache License 2.0 | 5 votes |
public ExpPanel() { manager = new ExplorerManager(); ActionMap map = getActionMap(); map.put(DefaultEditorKit.copyAction, ExplorerUtils.actionCopy(manager)); map.put(DefaultEditorKit.cutAction, ExplorerUtils.actionCut(manager)); map.put(DefaultEditorKit.pasteAction, ExplorerUtils.actionPaste(manager)); map.put("delete", ExplorerUtils.actionDelete(manager, true)); lookup = ExplorerUtils.createLookup(manager, map); InputMap keys = getInputMap(JComponent.WHEN_ANCESTOR_OF_FOCUSED_COMPONENT); keys.put(KeyStroke.getKeyStroke("control c"), DefaultEditorKit.copyAction); keys.put(KeyStroke.getKeyStroke("control x"), DefaultEditorKit.cutAction); keys.put(KeyStroke.getKeyStroke("control v"), DefaultEditorKit.pasteAction); keys.put(KeyStroke.getKeyStroke("DELETE"), "delete"); }
Example 9
Source File: Install.java From netbeans with Apache License 2.0 | 5 votes |
public EM() { manager = new ExplorerManager(); ActionMap map = getActionMap(); map.put(DefaultEditorKit.copyAction, ExplorerUtils.actionCopy(manager)); map.put(DefaultEditorKit.cutAction, ExplorerUtils.actionCut(manager)); map.put(DefaultEditorKit.pasteAction, ExplorerUtils.actionPaste(manager)); map.put("delete", ExplorerUtils.actionDelete(manager, true)); // or false lookup = ExplorerUtils.createLookup(manager, map); initComponent(); }
Example 10
Source File: KnockoutPanel.java From netbeans with Apache License 2.0 | 5 votes |
/** * Creates a lookup provider (that provides the lookup that corresponds * to the selected tab). * * @param actionMap action map to use in the creation of returned lookups. * @return lookup provider. */ Lookup.Provider createLookupProvider(ActionMap actionMap) { final Lookup bindingContextLookup = ExplorerUtils.createLookup(manager, actionMap); final Lookup unusedBindingLookup = ExplorerUtils.createLookup(unusedBindingsPanel.getExplorerManager(), actionMap); return new Lookup.Provider() { @Override public Lookup getLookup() { synchronized (KnockoutPanel.this) { return bindingContextShown ? bindingContextLookup : unusedBindingLookup; } } }; }
Example 11
Source File: ClassMemberPanelUI.java From netbeans with Apache License 2.0 | 5 votes |
/** Creates new form ClassMemberPanelUi */ public ClassMemberPanelUI(final Language language) { initComponents(); // Tree view of the elements elementView = createBeanTreeView(); add(elementView, BorderLayout.CENTER); filters = new ClassMemberFilters( this ); filters.getInstance().hookChangeListener(this); // See http://www.netbeans.org/issues/show_bug.cgi?id=186407 // Making the calls to getStructure() out of AWT EDT RP.post(new UpdateFilterState(language)); // filters filtersPanel = new TapPanel(); filtersLbl = new JLabel(NbBundle.getMessage(ClassMemberPanelUI.class, "LBL_Filter")); //NOI18N filtersLbl.setBorder(new EmptyBorder(0, 5, 5, 0)); filtersPanel.add(filtersLbl); filtersPanel.setOrientation(TapPanel.DOWN); // tooltip KeyStroke toggleKey = KeyStroke.getKeyStroke(KeyEvent.VK_T, Toolkit.getDefaultToolkit().getMenuShortcutKeyMask()); String keyText = Utilities.keyToString(toggleKey); filtersPanel.setToolTipText(NbBundle.getMessage(ClassMemberPanelUI.class, "TIP_TapPanel", keyText)); filtersPanel.add(filters.getComponent()); add(filtersPanel, BorderLayout.SOUTH); manager.setRootContext(ElementNode.getWaitNode()); lookup = ExplorerUtils.createLookup(manager, getActionMap()); }
Example 12
Source File: ToolBarDesignEditor.java From netbeans with Apache License 2.0 | 5 votes |
ToolBarView(final ExplorerManager manager, org.openide.nodes.Node root, javax.swing.Action helpAction) { super(); this.manager=manager; this.helpAction=helpAction; // same as before... setLayout(new java.awt.GridBagLayout()); ActionMap map = getActionMap(); // ...and initialization of lookup variable lookup = ExplorerUtils.createLookup (manager, map); ChoiceView cView = new ChoiceView(); ((NodeListModel)(cView.getModel())).setNode(root); setFloatable(false); ((NodeListModel)(cView.getModel())).setDepth(5); java.awt.GridBagConstraints gridBagConstraints = new java.awt.GridBagConstraints(); gridBagConstraints.gridx = 0; gridBagConstraints.gridy = 0; gridBagConstraints.insets = new java.awt.Insets(0, 2, 4, 0); add(cView,gridBagConstraints); gridBagConstraints = new java.awt.GridBagConstraints(); gridBagConstraints.gridx = 1; gridBagConstraints.gridy = 0; gridBagConstraints.weightx = 1.0; JPanel filler = new JPanel(); add(filler,gridBagConstraints); javax.swing.JButton helpButton = new javax.swing.JButton(helpAction); helpButton.setText(""); helpButton.setContentAreaFilled(false); helpButton.setFocusPainted(false); helpButton.setBorderPainted(false); gridBagConstraints = new java.awt.GridBagConstraints(); gridBagConstraints.gridx = 2; gridBagConstraints.gridy = 0; //gridBagConstraints.weightx = 1.0; add(helpButton,gridBagConstraints); }
Example 13
Source File: FormDesigner.java From netbeans with Apache License 2.0 | 4 votes |
private void initLookup() { Lookup explorerLookup; // lookup for EpxlorerManager Lookup plainContentLookup; // lookup with various fixed instances Lookup paletteLookup; // lookup for palette Lookup saveCookieLookup; // to make sure Save action is enabled Lookup dataObjectLookup; // to make sure DO is in lookup even if no node selected if (lookup == null) { lookup = new FormProxyLookup(); explorerLookup = null; lookupContent = new InstanceContent(); lookupContent.add(new NavigatorLookupPanelsPolicy() { @Override public int getPanelsPolicy() { return NavigatorLookupPanelsPolicy.LOOKUP_HINTS_ONLY; } }); lookupContent.add(new NavigatorLookupHint() { @Override public String getContentType() { return "text/x-form"; // NOI18N } }); plainContentLookup = new AbstractLookup(lookupContent); paletteLookup = PaletteUtils.getPaletteLookup(formEditor.getFormDataObject().getPrimaryFile()); saveCookieLookup = new Lookup() { @Override public <T> T lookup(final Class<T> clazz) { if (clazz.isAssignableFrom(SaveCookie.class) && formEditor != null) { return formEditor.getFormDataObject().getLookup().lookup(clazz); } else { return null; } } @Override public <T> Result<T> lookup(Template<T> template) { if (template.getType().isAssignableFrom(SaveCookie.class) && formEditor != null) { return formEditor.getFormDataObject().getLookup().lookup(template); } else { return Lookup.EMPTY.lookup(template); } } }; dataObjectLookup = null; } else { Lookup[] lookups = lookup.getSubLookups(); explorerLookup = lookups[0]; plainContentLookup = lookups[1]; paletteLookup = lookups[2]; saveCookieLookup = lookups[3]; dataObjectLookup = lookups[4]; } if (!initialized) { explorerLookup = Lookup.EMPTY; } else if (explorerLookup == Lookup.EMPTY) { // TODO ActionMap from TC? There was some close action in it. But works even without that... ActionMap map = ComponentInspector.getInstance().setupActionMap(canvasRoot.getActionMap()); explorerLookup = ExplorerUtils.createLookup(explorerManager, map); } if (dataObjectLookup == null || (dataObjectLookup == Lookup.EMPTY && !initialized)) { FormDataObject formDataObject = formEditor.getFormDataObject(); dataObjectLookup = formDataObject.getNodeDelegate().getLookup(); } lookup.setSubLookups(new Lookup[] { explorerLookup, plainContentLookup, paletteLookup, saveCookieLookup, dataObjectLookup }); }
Example 14
Source File: MainFrame.java From procamcalib with GNU General Public License v2.0 | 4 votes |
/** Creates new form MainFrame */ public MainFrame(String[] args) throws Exception { // same as before... manager = new ExplorerManager(); ActionMap map = getRootPane().getActionMap(); map.put(DefaultEditorKit.copyAction, ExplorerUtils.actionCopy(manager)); map.put(DefaultEditorKit.cutAction, ExplorerUtils.actionCut(manager)); map.put(DefaultEditorKit.pasteAction, ExplorerUtils.actionPaste(manager)); map.put("delete", ExplorerUtils.actionDelete(manager, true)); // or false // ...but add e.g.: InputMap keys = getRootPane().getInputMap(JComponent.WHEN_ANCESTOR_OF_FOCUSED_COMPONENT); keys.put(KeyStroke.getKeyStroke("control C"), DefaultEditorKit.copyAction); keys.put(KeyStroke.getKeyStroke("control X"), DefaultEditorKit.cutAction); keys.put(KeyStroke.getKeyStroke("control V"), DefaultEditorKit.pasteAction); keys.put(KeyStroke.getKeyStroke("DELETE"), "delete"); // ...and initialization of lookup variable lookup = ExplorerUtils.createLookup(manager, map); settingsFile = args.length > 0 ? new File(args[0]) : null; try { Logger.getLogger("").addHandler(new Handler() { { setFormatter(new SimpleFormatter()); } @Override public void publish(final LogRecord record) { final String title; final int messageType; if (record.getLevel().equals(Level.SEVERE)) { title = "SEVERE Logging Message"; messageType = JOptionPane.ERROR_MESSAGE; } else if (record.getLevel().equals(Level.WARNING)) { title = "WARNING Logging Message"; messageType = JOptionPane.WARNING_MESSAGE; } else if (record.getLevel().equals(Level.INFO)) { title = "INFO Logging Message"; messageType = JOptionPane.INFORMATION_MESSAGE; } else { title = "Tracing Logging Message"; messageType = JOptionPane.PLAIN_MESSAGE; } String[] messageLines = getFormatter().format(record).split("\r\n|\r|\n"); StringBuilder messageBuilder = new StringBuilder(); for (int i = 0; i < Math.min(5, messageLines.length); i++) { messageBuilder.append(messageLines[i] + '\n'); } if (messageLines.length > 5) { messageBuilder.append("..."); } final String message = messageBuilder.toString(); EventQueue.invokeLater(new Runnable() { public void run() { JOptionPane.showMessageDialog(MainFrame.this, message, title, messageType); } }); } @Override public void flush() { } @Override public void close() throws SecurityException { } }); cvRedirectError(new JavaCvErrorCallback() { @Override public int call(int status, BytePointer func_name, BytePointer err_msg, BytePointer file_name, int line, Pointer userdata) { super.call(status, func_name, err_msg, file_name, line, userdata); if (calibrationWorker != null) { calibrationWorker.cancel(false); } return 0; // please don't terminate } }, null, null); initComponents(); loadSettings(settingsFile); } catch (IOException ex) { Logger.getLogger(MainFrame.class.getName()).log(Level.SEVERE, "Could not load settings from \"" + settingsFile + "\"", ex); loadSettings(null); } catch (LinkageError e) { throw new Exception(e); } beanTreeView.requestFocusInWindow(); }
Example 15
Source File: MainFrame.java From procamtracker with GNU General Public License v2.0 | 4 votes |
/** Creates new form MainFrame */ public MainFrame(String[] args) throws Exception { // same as before... manager = new ExplorerManager(); ActionMap map = getRootPane().getActionMap(); map.put(DefaultEditorKit.copyAction, ExplorerUtils.actionCopy(manager)); map.put(DefaultEditorKit.cutAction, ExplorerUtils.actionCut(manager)); map.put(DefaultEditorKit.pasteAction, ExplorerUtils.actionPaste(manager)); map.put("delete", ExplorerUtils.actionDelete(manager, true)); // or false // ...but add e.g.: InputMap keys = getRootPane().getInputMap(JComponent.WHEN_ANCESTOR_OF_FOCUSED_COMPONENT); keys.put(KeyStroke.getKeyStroke("control C"), DefaultEditorKit.copyAction); keys.put(KeyStroke.getKeyStroke("control X"), DefaultEditorKit.cutAction); keys.put(KeyStroke.getKeyStroke("control V"), DefaultEditorKit.pasteAction); keys.put(KeyStroke.getKeyStroke("DELETE"), "delete"); // ...and initialization of lookup variable lookup = ExplorerUtils.createLookup(manager, map); settingsFile = args.length > 0 ? new File(args[0]) : null; try { Logger.getLogger("").addHandler(new Handler() { { setFormatter(new SimpleFormatter()); } @Override public void publish(final LogRecord record) { final String title; final int messageType; if (record.getLevel().equals(Level.SEVERE)) { title = "SEVERE Logging Message"; messageType = JOptionPane.ERROR_MESSAGE; } else if (record.getLevel().equals(Level.WARNING)) { title = "WARNING Logging Message"; messageType = JOptionPane.WARNING_MESSAGE; } else if (record.getLevel().equals(Level.INFO)) { title = "INFO Logging Message"; messageType = JOptionPane.INFORMATION_MESSAGE; } else { title = "Tracing Logging Message"; messageType = JOptionPane.PLAIN_MESSAGE; } String[] messageLines = getFormatter().format(record).split("\r\n|\r|\n"); StringBuilder messageBuilder = new StringBuilder(); for (int i = 0; i < Math.min(5, messageLines.length); i++) { messageBuilder.append(messageLines[i] + '\n'); } if (messageLines.length > 5) { messageBuilder.append("..."); } final String message = messageBuilder.toString(); EventQueue.invokeLater(new Runnable() { public void run() { if (messageType == JOptionPane.INFORMATION_MESSAGE) { messagesio.getOut().println(getFormatter().formatMessage(record)); } else { JOptionPane.showMessageDialog(MainFrame.this, message, title, messageType); } } }); } @Override public void flush() { } @Override public void close() throws SecurityException { } }); cvRedirectError(new JavaCvErrorCallback() { @Override public int call(int status, BytePointer func_name, BytePointer err_msg, BytePointer file_name, int line, Pointer userdata) { super.call(status, func_name, err_msg, file_name, line, userdata); if (trackingWorker != null) { trackingWorker.cancel(); } return 0; // please don't terminate } }, null, null); initComponents(); loadSettings(settingsFile); } catch (IOException ex) { Logger.getLogger(MainFrame.class.getName()).log(Level.SEVERE, "Could not load settings from \"" + settingsFile + "\"", ex); loadSettings(null); } catch (LinkageError e) { throw new Exception(e); } // initialize the messages window IOContainer container = IOContainer.getDefault(); Field f = container.getClass().getDeclaredField("provider"); f.setAccessible(true); IOContainer.Provider prov = (IOContainer.Provider)f.get(container); f = prov.getClass().getDeclaredField("frame"); f.setAccessible(true); f.set(prov, this); verticalSplitPane.setRightComponent((JComponent)prov); beanTreeView.requestFocusInWindow(); }
Example 16
Source File: DomTC.java From netbeans with Apache License 2.0 | 2 votes |
/** * Updates the content of this lookup according to the given panel. * * @param panel new panel to display in {@code DomTC}. */ void setPanel(DomPanel panel) { Lookup lookup = ExplorerUtils.createLookup(panel.getExplorerManager(), getActionMap()); setLookups(lookup); }