org.openide.explorer.ExplorerManager Java Examples

The following examples show how to use org.openide.explorer.ExplorerManager. 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: InternationalizationResourceBundleBrandingPanel.java    From netbeans with Apache License 2.0 6 votes vote down vote up
public InternationalizationResourceBundleBrandingPanel(BrandingModel model) {
        super(getMessage("LBL_InternationalizationResourceBundleTab"), model); //NOI18N
        
        initComponents();

        searchField.getDocument().addDocumentListener(searchListener);
        searchField.addFocusListener(searchListener);

        manager = new ExplorerManager();
        rootNode = null;
        waitRoot = getWaitRoot();
        waitRoot.setName(getMessage("LBL_ResourceBundlesList")); // NOI18N
        waitRoot.setDisplayName(getMessage("LBL_ResourceBundlesList")); // NOI18N
        manager.setRootContext(waitRoot);

        branding = getBranding();
        prj = branding.getProject();
        
        attachListeners();
}
 
Example #2
Source File: ResourceBundleBrandingPanel.java    From netbeans with Apache License 2.0 6 votes vote down vote up
public ResourceBundleBrandingPanel(BrandingModel model) {
    super(getMessage("LBL_ResourceBundleTab"), model); //NOI18N
    
    initComponents();

    searchField.getDocument().addDocumentListener(searchListener);
    searchField.addFocusListener(searchListener);

    manager = new ExplorerManager();
    rootNode = null;
    waitRoot = getWaitRoot();
    waitRoot.setName(getMessage("LBL_ResourceBundlesList")); // NOI18N
    waitRoot.setDisplayName(getMessage("LBL_ResourceBundlesList")); // NOI18N
    manager.setRootContext(waitRoot);

    branding = getBranding();
    prj = branding.getProject();
}
 
Example #3
Source File: Browser.java    From netbeans with Apache License 2.0 6 votes vote down vote up
private boolean show() {
    final DialogDescriptor dialogDescriptor =
            new DialogDescriptor(getBrowserPanel(), NbBundle.getMessage(Browser.class, "CTL_Browser_BrowseFolders_Title")); // NOI18N
    dialogDescriptor.setModal(true);
    dialogDescriptor.setHelpCtx(new HelpCtx(helpID));
    dialogDescriptor.setValid(false);

    addPropertyChangeListener(new PropertyChangeListener() {
        @Override
        public void propertyChange(PropertyChangeEvent evt) {
            if( ExplorerManager.PROP_SELECTED_NODES.equals(evt.getPropertyName()) ) {
                Node[] nodes = getSelectedNodes();
                if (nodes != null && nodes.length > 0) {
                    selectedNodes = nodes;
                    dialogDescriptor.setValid(nodes.length > 0);
                }
            }
        }
    });

    Dialog dialog = DialogDisplayer.getDefault().createDialog(dialogDescriptor);
    dialog.getAccessibleContext().setAccessibleDescription(NbBundle.getMessage(Browser.class, "CTL_Browser_BrowseFolders_Title")); // NOI18N
    dialog.setVisible(true);

    return DialogDescriptor.OK_OPTION.equals(dialogDescriptor.getValue());
}
 
Example #4
Source File: SearchHistoryPanel.java    From netbeans with Apache License 2.0 6 votes vote down vote up
/** Creates new form SearchHistoryPanel */
public SearchHistoryPanel(File [] roots, SearchCriteriaPanel criteria) {
    this.bOutSearch = false;
    this.bIncomingSearch = false;
    this.roots = roots;
    this.criteria = criteria;
    this.diffViewFactory = new SearchHistoryTopComponent.DiffResultsViewFactory();
    criteriaVisible = true;
    explorerManager = new ExplorerManager ();
    initComponents();
    initializeFilter();
    filterTimer = new Timer(500, this);
    filterTimer.setRepeats(false);
    filterTimer.stop();
    setupComponents();
    aquaBackgroundWorkaround();
    refreshComponents(true);
}
 
Example #5
Source File: SdksCustomizer.java    From NBANDROID-V2 with Apache License 2.0 6 votes vote down vote up
private static void expandAllNodes(BeanTreeView btv, Node node, ExplorerManager mgr, AndroidSdk platform) {
    btv.expandNode(node);
    Children ch = node.getChildren();
    if (ch == Children.LEAF) {
        if (platform != null && platform.equals(node.getLookup().lookup(AndroidSdk.class))) {
            try {
                mgr.setSelectedNodes(new Node[]{node});
            } catch (PropertyVetoException e) {
                //Ignore it
            }
        }
        return;
    }
    Node nodes[] = ch.getNodes(true);
    for (int i = 0; i < nodes.length; i++) {
        expandAllNodes(btv, nodes[i], mgr, platform);
    }

}
 
Example #6
Source File: ResultPanelTree.java    From netbeans with Apache License 2.0 6 votes vote down vote up
ResultPanelTree(ResultDisplayHandler displayHandler, StatisticsPanel statPanel) {
        super(new BorderLayout());
        treeView = new ResultTreeView();
        treeView.getAccessibleContext().setAccessibleName(Bundle.ACSN_TestResults());
        treeView.getAccessibleContext().setAccessibleDescription(Bundle.ACSD_TestResults());
        treeView.setBorder(BorderFactory.createEtchedBorder());
//        resultBar.setPassedPercentage(0.0f);
        JToolBar toolBar = new JToolBar();
        toolBar.setFloatable(false);
        toolBar.add(resultBar);
        toolBar.setBorder(BorderFactory.createEtchedBorder());

        add(toolBar, BorderLayout.NORTH);
        add(treeView, BorderLayout.CENTER);

        explorerManager = new ExplorerManager();
        explorerManager.setRootContext(rootNode = new RootNode(displayHandler.getSession(), filterMask));
        explorerManager.addPropertyChangeListener(this);

        initAccessibility();

        this.displayHandler = displayHandler;
        this.statPanel = statPanel;
        displayHandler.setLookup(ExplorerUtils.createLookup(explorerManager, new ActionMap()));
    }
 
Example #7
Source File: BrowseFolders.java    From netbeans with Apache License 2.0 6 votes vote down vote up
/** Creates new form BrowseFolders */
public BrowseFolders( SourceGroup[] folders) {
    initComponents();
    this.folders = folders;
    manager = new ExplorerManager();        
    AbstractNode rootNode = new AbstractNode( new SourceGroupsChildren( folders ) );
    manager.setRootContext( rootNode );
    
    // Create the templates view
    BeanTreeView btv = new BeanTreeView();
    btv.setRootVisible( false );
    btv.setSelectionMode( javax.swing.tree.TreeSelectionModel.SINGLE_TREE_SELECTION );
    btv.setBorder( SAMPLE_SCROLL_PANE.getBorder() );
    btv.getAccessibleContext().setAccessibleDescription(
            NbBundle.getMessage(BrowseFolders.class, "ACSD_SelectFile"));
    folderPanel.add( btv, java.awt.BorderLayout.CENTER );
}
 
Example #8
Source File: NewPluginPanel.java    From netbeans with Apache License 2.0 6 votes vote down vote up
/** PropertyChangeListener impl, stores maven coordinates of selected artifact */
@Override
public void propertyChange(PropertyChangeEvent evt) {
    if (ExplorerManager.PROP_SELECTED_NODES.equals(evt.getPropertyName())) {
        Node[] selNodes = manager.getSelectedNodes();
        pluginPanel.selVi = null;
        if (selNodes.length == 1) {
            if (selNodes[0] instanceof MavenNodeFactory.VersionNode) {
                pluginPanel.selVi = ((MavenNodeFactory.VersionNode)selNodes[0]).getNBVersionInfo();
            } else if (selNodes[0] instanceof MavenNodeFactory.ArtifactNode) {
                List<NBVersionInfo> infos = ((MavenNodeFactory.ArtifactNode)selNodes[0]).getVersionInfos();
                if (infos.size() > 0) {
                    pluginPanel.selVi = infos.get(0);
                }
            }
        }
        pluginPanel.updateGoals();
    }
}
 
Example #9
Source File: SearchHistoryPanel.java    From netbeans with Apache License 2.0 6 votes vote down vote up
/** Creates new form SearchHistoryPanel */
public SearchHistoryPanel(File [] roots, SearchCriteriaPanel criteria) {
    this.roots = roots;
    this.repositoryUrl = null;
    this.criteria = criteria;
    this.diffViewFactory = new SearchHistoryTopComponent.DiffResultsViewFactory();
    criteriaVisible = true;
    explorerManager = new ExplorerManager ();
    initComponents();
    initializeFilter();
    filterTimer = new Timer(500, this);
    filterTimer.setRepeats(false);
    filterTimer.stop();
    aquaBackgroundWorkaround();
    setupComponents();
    refreshComponents(true);
}
 
Example #10
Source File: BrowseFolders.java    From netbeans with Apache License 2.0 6 votes vote down vote up
/** Creates new form BrowseFolders */
public BrowseFolders( SourceGroup[] folders, Project project, String preselectedFileName ) {
    initComponents();
    this.folders = folders;
    this.project = project;
    
    manager = new ExplorerManager();        
    AbstractNode rootNode = new AbstractNode( new SourceGroupsChildren( folders, project ) );
    manager.setRootContext( rootNode );
    
    // Create the templates view
    btv = new BeanTreeView();
    btv.setRootVisible( false );
    btv.setSelectionMode( javax.swing.tree.TreeSelectionModel.SINGLE_TREE_SELECTION );
    btv.setBorder( SAMPLE_SCROLL_PANE.getBorder() );        
    btv.setPopupAllowed( false );
    btv.getAccessibleContext ().setAccessibleName (NbBundle.getMessage(BrowseFolders.class, "ACSN_BrowseFolders_folderPanel"));
    btv.getAccessibleContext ().setAccessibleDescription (NbBundle.getMessage(BrowseFolders.class, "ACSD_BrowseFolders_folderPanel"));
    expandSelection( preselectedFileName );
    //expandAllNodes( btv, manager.getRootContext() );
    folderPanel.add( btv, java.awt.BorderLayout.CENTER );      
    jLabel1.setLabelFor(btv.getViewport().getView());
}
 
Example #11
Source File: ScreenshotComponent.java    From netbeans with Apache License 2.0 6 votes vote down vote up
@Override
public void propertyChange(PropertyChangeEvent evt) {
    logger.fine("propertyChange("+evt+") propertyName = "+evt.getPropertyName());
    String propertyName = evt.getPropertyName();
    if (ExplorerManager.PROP_SELECTED_NODES.equals(propertyName)) {
        Node[] nodes = ComponentHierarchy.getInstance().getExplorerManager().getSelectedNodes();
        ComponentInfo ci = null;
        if (nodes.length > 0) {
            ci = nodes[0].getLookup().lookup(ComponentInfo.class);
        }
        logger.fine("nodes = "+Arrays.toString(nodes)+" => selectComponent("+ci+")");
        selectComponent(ci, false);
    } else if (ExplorerManager.PROP_ROOT_CONTEXT.equals(propertyName)) {
        deactivated();
    }
}
 
Example #12
Source File: AbstractDesignEditor.java    From netbeans with Apache License 2.0 5 votes vote down vote up
public void propertyChange(PropertyChangeEvent evt) {
    if (contentView.isSectionHeaderClicked()) {
        contentView.setSectionHeaderClicked(false);
        return;
    }
    if (!ExplorerManager.PROP_SELECTED_NODES.equals(evt.getPropertyName()))
        return;

    Node[] selectedNodes = getExplorerManager().getSelectedNodes();
    if (selectedNodes!=null && selectedNodes.length>0)
        contentView.showSelection(selectedNodes);
}
 
Example #13
Source File: VariablesPanel.java    From netbeans with Apache License 2.0 5 votes vote down vote up
/** Creates new form VariablesPanel */
public VariablesPanel() {
    model = new VariablesModel();
    initComponents();
    tree.setRootVisible(false);
    explorer = new ExplorerManager();
}
 
Example #14
Source File: McTreeViewPanel.java    From Llunatic with GNU General Public License v3.0 5 votes vote down vote up
@Override
public void onChaseResultUpdate(McChaseResult result) {
    this.result = result;
    ChaseTreeRoot resultNode = result.getNode();
    explorerManager = ExplorerManager.find(this);
    statefulView.setRootNode(explorerManager, resultNode);
}
 
Example #15
Source File: Tab.java    From netbeans with Apache License 2.0 5 votes vote down vote up
/** Creates */
private Tab() {
    this.manager = new ExplorerManager();
    
    ActionMap map = this.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

    // following line tells the top component which lookup should be associated with it
    associateLookup (ExplorerUtils.createLookup (manager, map));
}
 
Example #16
Source File: ProjectServicesImpl.java    From netbeans with Apache License 2.0 5 votes vote down vote up
@Override
public boolean openProject(URL url) {
    Project p = getProject(url);
    if (p == null) {
        return false;
    }
    OpenProjects.getDefault().open(new Project[] { p }, false);
    TopComponent projectsTC = WindowManager.getDefault().findTopComponent("projectTabLogical_tc"); // NOI18N
    projectsTC.requestActive();
    ExplorerManager em = ((ExplorerManager.Provider) projectsTC).getExplorerManager();

    Node root = em.getRootContext();
    Node projNode = null;
    for (Node n : root.getChildren().getNodes()) {
        Project prj = n.getLookup().lookup(Project.class);
        if (prj != null && prj.getProjectDirectory().equals(p.getProjectDirectory())) {
            projNode = n;
            break;
        }
    }
    if (projNode == null) { // fallback
        projNode = root.getChildren().findChild(ProjectUtils.getInformation(p).getName());
    }
    if (projNode != null) {
        try {
            em.setSelectedNodes(new Node[] { projNode });
        } catch (Exception ignore) { // may ignore it
        }
    }
    return true;
}
 
Example #17
Source File: OutlineTable.java    From netbeans with Apache License 2.0 5 votes vote down vote up
@Override
public void propertyChange (PropertyChangeEvent evt) {
    String propertyName = evt.getPropertyName ();
    TopComponent tc = (TopComponent) SwingUtilities.
        getAncestorOfClass (TopComponent.class, this);
    if (tc == null) {
        return;
    }
    if (propertyName.equals (TopComponent.Registry.PROP_CURRENT_NODES)) {
        ExplorerUtils.activateActions(getExplorerManager(), equalNodes());
    } else
    if (propertyName.equals (ExplorerManager.PROP_SELECTED_NODES)) {
        tc.setActivatedNodes ((Node[]) evt.getNewValue ());
    }
}
 
Example #18
Source File: ServerManagerPanel.java    From netbeans with Apache License 2.0 5 votes vote down vote up
public void propertyChange(PropertyChangeEvent evt) {
    if (ExplorerManager.PROP_SELECTED_NODES.equals(evt.getPropertyName())) {
        Node[] nodes = (Node[]) evt.getNewValue();
        if (nodes.length != 1) {
            selectServer(null);
        } else {
            selectServer(nodes[0]);
        }
    }
}
 
Example #19
Source File: OutlineView.java    From netbeans with Apache License 2.0 5 votes vote down vote up
@Override
public void propertyChange(java.beans.PropertyChangeEvent evt) {
    synchronized (managerLock) {
        if (manager == null) return; // the tree view has been removed before the event got delivered
        if (evt.getPropertyName().equals(ExplorerManager.PROP_ROOT_CONTEXT)) {
            synchronizeRootContext();
        }
        if (evt.getPropertyName().equals(ExplorerManager.PROP_SELECTED_NODES)) {
            synchronizeSelectedNodes(true);
        }
    }
}
 
Example #20
Source File: ProjectUtilities.java    From netbeans with Apache License 2.0 5 votes vote down vote up
public static void selectAndExpandProject( final Project project ) {

        // invoke later to select the being opened project if the focus is outside ProjectTab
        SwingUtilities.invokeLater (new Runnable () {

            final TopComponent ptLogicalTC = findDefault(ProjectTab_ID_LOGICAL);
            final ExplorerManager.Provider ptLogicalExplorerManager = (ExplorerManager.Provider) ptLogicalTC;

            public void run () {
                if (ptLogicalExplorerManager == null) {
                    Logger.getLogger(this.getClass().getName()).log(Level.FINE, "Cannot find Project widnow, aborting.");
                    return;
                }
                Node root = ptLogicalExplorerManager.getExplorerManager ().getRootContext ();
                for(Node projNode : root.getChildren().getNodes()) {
                    Project p = projNode.getLookup().lookup(Project.class);
                    if(p != null && p.getProjectDirectory().equals(project.getProjectDirectory())) {
                        try {
                            ptLogicalExplorerManager.getExplorerManager ().setSelectedNodes( new Node[] { projNode } );
                            ptLogicalTC.requestActive();
                        } catch (Exception ignore) {
                            // may ignore it
                        }    
                    }
                }                
            }
        });
    }
 
Example #21
Source File: TableView.java    From netbeans with Apache License 2.0 5 votes vote down vote up
/** Registers in the tree of components.
 */
private void lookupExplorerManager () {
    // Enter key in the tree

    if (managerListener == null) {
        managerListener = new TableSelectionListener();
    }
    
    ExplorerManager newManager = ExplorerManager.find(this);
    if (newManager != manager) {
        if (manager != null) {
            manager.removeVetoableChangeListener (wlvc);
            manager.removePropertyChangeListener (wlpc);
        }

        manager = newManager;

        manager.addVetoableChangeListener(wlvc = WeakListeners.vetoableChange(managerListener, manager));
        manager.addPropertyChangeListener(wlpc = WeakListeners.propertyChange(managerListener, manager));

        synchronizeRootContext();
        synchronizeSelectedNodes ();
    }

    // Sometimes the listener is registered twice and we get the 
    // selection events twice. Removing the listener before adding it
    // should be a safe fix.
    table.getSelectionModel().removeListSelectionListener(managerListener);
    table.getSelectionModel().addListSelectionListener(managerListener);
}
 
Example #22
Source File: McTreeViewPanel.java    From Llunatic with GNU General Public License v3.0 5 votes vote down vote up
@Override
public void componentOpened() {
    listener.register(this);
    if (result != null) {
        ChaseTreeRoot resultNode = result.getNode();
        explorerManager = ExplorerManager.find(this);
        statefulView.setRootNode(explorerManager, resultNode, expandedPaths);
    }
}
 
Example #23
Source File: TreeModelRoot.java    From netbeans with Apache License 2.0 5 votes vote down vote up
/** The children evaluator for view of this root. *
private final Map<RequestProcessor, TreeModelNode.LazyEvaluator> childrenEvaluators
        = new WeakHashMap<RequestProcessor, TreeModelNode.LazyEvaluator>();
/** The values evaluator for view of this root. *
private final Map<RequestProcessor, TreeModelNode.LazyEvaluator> valuesEvaluators
        = new WeakHashMap<RequestProcessor, TreeModelNode.LazyEvaluator>();
 */

public TreeModelRoot (Models.CompoundModel model, TreeView treeView) {
    this.model = model;
    this.manager = ExplorerManager.find(treeView);
    this.treeFeatures = new DefaultTreeFeatures(treeView);
    modelListeners = new ModelChangeListener[] { new ModelChangeListener(model) };
    model.addModelListener (modelListeners[0]);
}
 
Example #24
Source File: AddDependencyPanel.java    From NBANDROID-V2 with Apache License 2.0 5 votes vote down vote up
private QueryPanel() {
    btv = new BeanTreeView();
    btv.setRootVisible(false);
    btv.setDefaultActionAllowed(true);
    btv.setSelectionMode(TreeSelectionModel.SINGLE_TREE_SELECTION);
    manager = new ExplorerManager();
    setLayout(new BorderLayout());
    add(btv, BorderLayout.CENTER);
    defSearchC = AddDependencyPanel.this.searchField.getForeground();
    manager.addPropertyChangeListener(this);
    AddDependencyPanel.this.resultsLabel.setLabelFor(btv);
    btv.getAccessibleContext().setAccessibleDescription(AddDependencyPanel.this.resultsLabel.getAccessibleContext().getAccessibleDescription());
    resultsRootNode = new ResultsRootNode();
    manager.setRootContext(resultsRootNode);
}
 
Example #25
Source File: DiffTreeTable.java    From netbeans with Apache License 2.0 5 votes vote down vote up
public void setResults(List<RepositoryRevision> results) {
    this.results = results;
    rootNode = new RevisionsRootNode();
    ExplorerManager em = ExplorerManager.find(this);
    if (em != null) {
        em.setRootContext(rootNode);
    }
}
 
Example #26
Source File: ProjectOpener.java    From netbeans with Apache License 2.0 5 votes vote down vote up
public void propertyChange(PropertyChangeEvent evt) {
    if (ExplorerManager.PROP_SELECTED_NODES.equals(evt.getPropertyName())) {
        // no selection - disable the Open button
        final Node [] nodes = (Node[]) evt.getNewValue();
        if (nodes.length == 0) {
            okButton.setEnabled(false);
        } else {
            okButton.setEnabled(true);
        }
    }
}
 
Example #27
Source File: Install.java    From netbeans with Apache License 2.0 5 votes vote down vote up
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 #28
Source File: TreeViewDragSupport.java    From netbeans with Apache License 2.0 5 votes vote down vote up
@Override
public void dragDropEnd(DragSourceDropEvent dsde) {
    // get the droped nodes
    Node[] dropedNodes = exDnD.getDraggedNodes();
    super.dragDropEnd(dsde);

    // if any original glass pane was stored (the DnD was broken e.g. by Esc)
    if (DropGlassPane.isOriginalPaneStored()) {
        // give back the orig glass pane
        DropGlassPane.putBackOriginal();

        // DnD is not active
        exDnD.setDnDActive(false);
    }

    // select the droped nodes
    try {
        if (dropedNodes != null) {
            ExplorerManager.Provider panel = (ExplorerManager.Provider) SwingUtilities.getAncestorOfClass(
                    ExplorerManager.Provider.class, view
                );

            if (panel != null) {
                panel.getExplorerManager().setSelectedNodes(dropedNodes);
            }
        }
    } catch (Exception e) {
        // don't care
    }

    // notify tree cell editor that DnD operationm is active
    // no more
    TreeCellEditor tce = tree.getCellEditor();

    if (tce instanceof TreeViewCellEditor) {
        ((TreeViewCellEditor) tce).setDnDActive(false);
    }
}
 
Example #29
Source File: SaasExplorerPanel.java    From netbeans with Apache License 2.0 5 votes vote down vote up
/** Creates new form SaasExplorerPanel */
public SaasExplorerPanel() {
    manager = new ExplorerManager();
    
    initComponents();
    initUserComponents();
}
 
Example #30
Source File: ProjectFileExplorer.java    From netbeans with Apache License 2.0 5 votes vote down vote up
public ProjectFileExplorer() {
    projects = OpenProjects.getDefault().getOpenProjects();
    rootChildren = new Children.Array();
    explorerClientRoot = new AbstractNode(rootChildren);
    projectNodeList = new ArrayList<Node>();
    manager = new ExplorerManager();

    initComponents();
    initUserComponents();
}