java.awt.event.HierarchyBoundsListener#org.openide.util.lookup.AbstractLookup源码实例Demo

下面列出了java.awt.event.HierarchyBoundsListener#org.openide.util.lookup.AbstractLookup 实例代码,或者点击链接到github查看源代码,也可以在右侧发表评论。

源代码1 项目: constellation   文件: GraphNode.java
/**
 * Private constructor: recommended pattern for using InstanceContent.
 *
 * @param content This object's Lookup.
 * @param graph The Graph.
 * @param gdo The GraphDataObject.
 * @param visual The visual interface to the graph.
 * @param tc The graph's TopComponent.
 */
private GraphNode(final InstanceContent content, final Graph graph, final GraphDataObject gdo, final TopComponent tc, final VisualManager visualManager) {
    super(Children.LEAF, new AbstractLookup(content));
    content.add(graph);
    content.add(this);
    this.graph = graph;
    this.visualManager = visualManager;
    this.gdo = gdo;
    this.undoRedoManager = new UndoRedo.Manager();
    this.tc = tc;

    graph.setUndoManager(undoRedoManager);

    GRAPHS.put(graph.getId(), GraphNode.this);

    for (GraphManagerListener listener : LISTENERS) {
        listener.graphOpened(graph);
    }

    MemoryManager.newObject(GraphNode.class);
}
 
源代码2 项目: netbeans   文件: SessionNode.java
private SessionNode(InstanceContent instanceContent, EjbViewController controller, String ejbName) {
    super(new SessionChildren(controller), new AbstractLookup(instanceContent));
    ejbViewController = controller;
    setIconBaseWithExtension("org/netbeans/modules/j2ee/ejbcore/ui/logicalview/ejb/session/SessionNodeIcon.gif");
    setName(ejbName + "");
    setDisplayName();
    instanceContent.add(this);
    ElementHandle<TypeElement> beanClassHandle = ejbViewController.getBeanClass();
    if (beanClassHandle != null) {
        instanceContent.add(beanClassHandle);
    }
    DataObject dataObject = ejbViewController.getBeanDo();
    if (dataObject != null && dataObject.getPrimaryFile() != null) {
        instanceContent.add(dataObject.getPrimaryFile());
    }
    try {
        instanceContent.add(ejbViewController.createEjbReference());
    } catch (IOException ioe) {
        Exceptions.printStackTrace(ioe);
    }
}
 
源代码3 项目: netbeans   文件: CMPFieldNode.java
private CMPFieldNode(CmpField field, EntityMethodController controller, FileObject ddFile, InstanceContent instanceContent) {
        super(Children.LEAF, new AbstractLookup(instanceContent));
        instanceContent.add(this); // for enabling Open action
        
        //TODO: RETOUCHE
//        try {
//            ic.add(DataObject.find(JavaModel.getFileObject(controller.getBeanClass().getResource()))); // for enabling SafeDelete action
//        } catch (DataObjectNotFoundException ex) {
//            // ignore
//        }
//        Method getterMethod = controller.getGetterMethod(controller.getBeanClass(), field.getFieldName());
//        if (getterMethod != null) {
//            ic.add(getterMethod); // for SafeDelete refactoring to find Method element
//        }
        this.field = field;
        this.ddFile = ddFile;
        this.controller = controller;
        field.addPropertyChangeListener(WeakListeners.propertyChange(this, field));
    }
 
源代码4 项目: TencentKona-8   文件: FilterNode.java
private FilterNode(Filter filter, InstanceContent content) {
    super(Children.LEAF, new AbstractLookup(content));
    content.add(filter);

    content.add(filter.getEditor());
    this.filter = filter;
    filter.getChangedEvent().addListener(new ChangedListener<Filter>() {

        public void changed(Filter source) {
            update();
        }
    });

    update();

    Lookup.Template<FilterChain> tpl = new Lookup.Template<FilterChain>(FilterChain.class);
    result = Utilities.actionsGlobalContext().lookup(tpl);
    result.addLookupListener(this);

    FilterTopComponent.findInstance().getFilterSettingsChangedEvent().addListener(this);
    resultChanged(null);
}
 
源代码5 项目: netbeans   文件: JaxWsClientNode.java
private JaxWsClientNode(JaxWsModel jaxWsModel, Client client, FileObject srcRoot, InstanceContent content) {
    super(new JaxWsClientChildren(client, srcRoot),new AbstractLookup(content));
    this.jaxWsModel=jaxWsModel;
    this.client=client;
    this.srcRoot=srcRoot;
    this.content = content;
    setName(client.getName());
    setDisplayName(client.getName());
    content.add(this);
    content.add(client);
    content.add(srcRoot);
    WsdlModeler modeler = getWsdlModeler();
    if (modeler!=null) {
        changeIcon();
        modeler.generateWsdlModel(new WsdlModelListener(){
            public void modelCreated(WsdlModel model) {
                modelGenerationFinished=true;
                changeIcon();
            }
        });
    }
    content.add(new EditWSAttributesCookieImpl(this, jaxWsModel));
    setValue("wsdl-url",client.getWsdlUrl());
}
 
源代码6 项目: jdk8u60   文件: GraphNode.java
private GraphNode(final InputGraph graph, InstanceContent content) {
    super(Children.LEAF, new AbstractLookup(content));
    this.graph = graph;
    this.setDisplayName(graph.getName());
    content.add(graph);

    final GraphViewer viewer = Lookup.getDefault().lookup(GraphViewer.class);

    if (viewer != null) {
        // Action for opening the graph
        content.add(new OpenCookie() {

            public void open() {
                viewer.view(graph);
            }
        });
    }

    // Action for removing a graph
    content.add(new RemoveCookie() {

        public void remove() {
            graph.getGroup().removeGraph(graph);
        }
    });
}
 
源代码7 项目: openjdk-jdk8u   文件: GraphNode.java
private GraphNode(final InputGraph graph, InstanceContent content) {
    super(Children.LEAF, new AbstractLookup(content));
    this.graph = graph;
    this.setDisplayName(graph.getName());
    content.add(graph);

    final GraphViewer viewer = Lookup.getDefault().lookup(GraphViewer.class);

    if (viewer != null) {
        // Action for opening the graph
        content.add(new OpenCookie() {

            public void open() {
                viewer.view(graph);
            }
        });
    }

    // Action for removing a graph
    content.add(new RemoveCookie() {

        public void remove() {
            graph.getGroup().removeGraph(graph);
        }
    });
}
 
源代码8 项目: jeddict   文件: JPQLExternalEditorController.java
public void init() {
    JPQLEditorTopComponent editorTopComponent = new JPQLEditorTopComponent(this);
    editorTopComponent.open();
    editorTopComponent.requestActive();
    editorTopComponent.setFocusToEditor();

    try {
        InstanceContent lookupContent = new InstanceContent();
        lookupContent.add(pud);
        AbstractLookup lookup = new AbstractLookup(lookupContent);
        AbstractNode node = new AbstractNode(Children.LEAF, lookup);
        editorTopComponent.fillPersistenceConfigurations(new Node[]{node});
    } catch (Exception ex) {
        modelerFile.handleException(ex);
    }
}
 
源代码9 项目: netbeans   文件: ActionInvocationTest.java
public void testRenameAction() throws InterruptedException, InvocationTargetException, IOException {
    DataObject testdo = DataObject.find(f);
    final Node node = testdo.getNodeDelegate();
    
    InstanceContent ic = new InstanceContent();
    Lookup lookup = new AbstractLookup(ic);
    ic.add(node);
    final Action rename = RefactoringActionsFactory.renameAction().createContextAwareInstance(lookup);
    SwingUtilities.invokeAndWait(new Runnable() {
        @Override
        public void run() {
            if (rename.isEnabled()) {
                rename.actionPerformed(RefactoringActionsFactory.DEFAULT_EVENT);
                if (!((RenameRefactoring) DD.rui.getRefactoring()).getRefactoringSource().lookup(FileObject.class).equals(f))
                    fail("Rename dialog was opened with wrong data");
            } else {
                fail("Action is not enabled.");
            }
        }
    });
}
 
源代码10 项目: netbeans   文件: ContextManagerTest.java
@RandomlyFails
public void testListenerGCedAfterActionGCed () throws Exception {
    InstanceContent ic = new InstanceContent();
    lkp = new AbstractLookup(ic);
    Lookup.Result<Integer> lookupResult = lkp.lookupResult(Integer.class);

    Action action = ((ContextAwareAction) Actions.forID("cat", "survive")).createContextAwareInstance(lkp);
    Action fallbackAction = ((GeneralAction.DelegateAction) action).fallback;
    WeakReference<Action> fallbackActionRef = new WeakReference<Action>(fallbackAction);
    WeakReference<Action> clone = new WeakReference<Action>(action);
    cm = ContextManager.findManager(lkp, true);
    WeakReference lsetRef = new WeakReference<Object>(cm.findLSet(Integer.class));

    // both delegate and delegating actions are GCed before WeakListenerSupport is triggered in ActiveRefQueue:
    // fallbackAction.removePropertyChangeListener(delegating.weakL);
    fallbackAction = null;
    action = null;
    assertGC("Action should be GCed", clone);

    assertGC("Fallback action should be GCed", fallbackActionRef);
    assertGC("Action LSet Should be GCed", lsetRef);
    lookupResult.allInstances();
}
 
源代码11 项目: netbeans   文件: ActionProcessorTest.java
public void testContextAction() throws Exception {
    Action a = Actions.forID("Tools", "on.int");
    assertTrue("It is context aware action", a instanceof ContextAwareAction);

    InstanceContent ic = new InstanceContent();
    AbstractLookup lkp = new AbstractLookup(ic);
    Action clone = ((ContextAwareAction) a).createContextAwareInstance(lkp);
    NumberLike ten = new NumberLike(10);
    ic.add(ten);

    assertEquals("Number lover!", clone.getValue(Action.NAME));
    clone.actionPerformed(new ActionEvent(this, 300, ""));
    assertEquals("Global Action not called", 10, Context.cnt);

    ic.remove(ten);
    clone.actionPerformed(new ActionEvent(this, 200, ""));
    assertEquals("Global Action stays same", 10, Context.cnt);
}
 
源代码12 项目: netbeans   文件: StatefulActionProcessorTest.java
public void testCustomContextAwareInstance() {
    Action a = Actions.forID("Foo", "test.ListAction");
    DefaultListSelectionModel model = new DefaultListSelectionModel();
    
    InstanceContent localContent1 = new InstanceContent();
    AbstractLookup localLookup1 = new AbstractLookup(localContent1);
    
    Action la = ((ContextAwareAction)a).createContextAwareInstance(localLookup1);
    
    assertFalse(a.isEnabled());
    assertFalse(la.isEnabled());
    
    localContent1.add(model);
    
    assertFalse(a.isEnabled());
    assertTrue(la.isEnabled());
    assertFalse((Boolean)la.getValue(Action.SELECTED_KEY));
    
    // checks that the context-bound instance changes its selected state
    // if the model changes (relevant property change event is fired)
    model.setSelectionInterval(1, 2);
    assertTrue((Boolean)la.getValue(Action.SELECTED_KEY));
}
 
源代码13 项目: netbeans   文件: ClassPathProviderMergerTest.java
public void testMissingEvents() throws Exception {
    InstanceContent ic = new InstanceContent();
    Lookup lookup = new AbstractLookup(ic);
    ProviderImpl defaultCP = new ProviderImpl();

    final URL root1 = FileUtil.urlForArchiveOrDir(FileUtil.normalizeFile(new File(getWorkDir(),"root1")));
    final URL root2 = FileUtil.urlForArchiveOrDir(FileUtil.normalizeFile(new File(getWorkDir(),"root2")));
    final MutableCPImpl cpImpl = new MutableCPImpl(root1);

    defaultCP.paths.put(ClassPath.COMPILE, ClassPathFactory.createClassPath(cpImpl));
    ClassPathProviderMerger instance = new ClassPathProviderMerger(defaultCP);
    ClassPathProvider result = instance.merge(lookup);

    ClassPath compile = result.findClassPath(null, ClassPath.COMPILE);
    assertNotNull(compile);
    assertEquals(1, compile.entries().size());

    cpImpl.add(root2);
    assertEquals(2, compile.entries().size());
}
 
源代码14 项目: netbeans   文件: FolderRenameHandlerImpl.java
@Override
public void handleRename(DataFolder folder, String newName) {
    InstanceContent ic = new InstanceContent();
    ic.add(folder.getNodeDelegate());
    ExplorerContext d = new ExplorerContext();
    d.setNewName(newName);
    ic.add(d);
    final Lookup l = new AbstractLookup(ic);
    if (ActionsImplementationFactory.canRename(l)) {
        SwingUtilities.invokeLater(new Runnable() {
            @Override
            public void run() {
                Action a = RefactoringActionsFactory.renameAction().createContextAwareInstance(l);
                a.actionPerformed(RefactoringActionsFactory.DEFAULT_EVENT);
            }
        });
    } else {
        FileObject fo = folder.getPrimaryFile();
        try {
            folder.rename(newName);
        } catch (IOException ioe) {
            ErrorManager.getDefault().notify(ioe);
        }
    }
}
 
源代码15 项目: netbeans   文件: CompilerOptionsQueryMergerTest.java
public void testLkpEvents() {
    final CompilerOptionsQueryImpl impl1 = new CompilerOptionsQueryImpl();
    final CompilerOptionsQueryImpl impl2 = new CompilerOptionsQueryImpl();
    impl1.addRoot(root1).addArgs("a1", "a2");   //NOI18N
    impl2.addRoot(root1).addArgs("b1", "b2");   //NOI18N

    final InstanceContent ic = new InstanceContent();
    final Lookup baseLkp = new AbstractLookup(ic);
    final CompilerOptionsQueryImplementation merged =
            LookupMergerSupport.createCompilerOptionsQueryMerger()
            .merge(baseLkp);
    assertNull(merged.getOptions(root1));
    ic.add(impl1);
    final CompilerOptionsQueryImplementation.Result res = merged.getOptions(root1);
    assertEquals(
            Arrays.asList("a1","a2"), //NOI18N
            res.getArguments());
    final MockChangeListener listener = new MockChangeListener();
    res.addChangeListener(listener);
    ic.add(impl2);
    listener.assertEventCount(1);
    assertEquals(
            Arrays.asList("a1","a2","b1","b2"), //NOI18N
            res.getArguments());
}
 
源代码16 项目: netbeans   文件: RestServiceNode.java
private RestServiceNode(Project project, RestServicesModel model,
        final RestServiceDescription desc, InstanceContent content) {
    super(new RestServiceChildren(project, model, desc.getName()), new AbstractLookup(content));
    this.serviceName = desc.getName();
    this.uriTemplate = desc.getUriTemplate();
    this.className = desc.getClassName();
    
    content.add(this);
    content.add(desc);
    content.add(new ResourceUriProvider() {
        public String getResourceUri() {
            return desc.getUriTemplate();
        }           
    });
    content.add(project);
    content.add(OpenCookieFactory.create(project, className));
    editorDrop = new ResourceToEditorDrop(this);
}
 
源代码17 项目: netbeans   文件: ContextActionInjectTest.java
public void testContextAction() throws Exception {
    Context.cnt = 0;
    
    FileObject fo = FileUtil.getConfigFile(
        "actions/support/test/testInjectContext.instance"
    );
    assertNotNull("File found", fo);
    Object obj = fo.getAttribute("instanceCreate");
    assertNotNull("Attribute present", obj);
    assertTrue("It is context aware action", obj instanceof ContextAwareAction);
    ContextAwareAction a = (ContextAwareAction)obj;

    InstanceContent ic = new InstanceContent();
    AbstractLookup lkp = new AbstractLookup(ic);
    Action clone = a.createContextAwareInstance(lkp);
    ic.add(10);

    assertEquals("Number lover!", clone.getValue(Action.NAME));
    clone.actionPerformed(new ActionEvent(this, 300, ""));
    assertEquals("Global Action not called", 10, Context.cnt);

    ic.remove(10);
    clone.actionPerformed(new ActionEvent(this, 200, ""));
    assertEquals("Global Action stays same", 10, Context.cnt);
}
 
源代码18 项目: netbeans   文件: ContextManagerTest.java
public void testSurviveFocusChange() throws Exception {
    InstanceContent ic = new InstanceContent();
    Lookup lkp = new AbstractLookup(ic);

    Action clone = ((ContextAwareAction) Actions.forID("cat", "survive")).createContextAwareInstance(lkp);
    L listener = new L();
    clone.addPropertyChangeListener(listener);

    assertFalse("Disabled", clone.isEnabled());
    Object val = Integer.valueOf(1);
    ic.add(val);
    assertTrue("Enabled now", clone.isEnabled());
    assertEquals("One change", 1, listener.cnt);
    ic.remove(val);
    assertTrue("Still Enabled", clone.isEnabled());

    Survival.value = 0;
    clone.actionPerformed(new ActionEvent(this, 0, ""));
    assertEquals("Added one", 1, Survival.value);
}
 
源代码19 项目: openjdk-jdk8u-backup   文件: FolderNode.java
private FolderNode(String name, GroupOrganizer organizer, List<String> oldSubFolders, final List<Group> groups, FolderChildren children, InstanceContent content) {
    super(children, new AbstractLookup(content));
    children.setParent(this);
    this.content = content;
    this.children = children;
    content.add(new RemoveCookie() {

        public void remove() {
            for (Group g : groups) {
                if (g.getDocument() != null) {
                    g.getDocument().removeGroup(g);
                }
            }
        }
    });
    init(name, organizer, oldSubFolders, groups);
}
 
@Override
protected void setUp() throws Exception {
    MockServices.setServices(DD.class);


    clearWorkDir();
    LocalFileSystem fs = new LocalFileSystem();
    fs.setRootDirectory(getWorkDir());

    FileObject fo = fs.getRoot().createData("Ahoj", "txt");

    ic = new InstanceContent();
    support = new CES(this, new AbstractLookup(ic));
    edit = support;
    assertNotNull("we have editor", edit);

    DD.type = -1;
    DD.toReturn = new Stack<Object>();
}
 
@Override
protected void setUp () throws Exception {
    MockServices.setServices(DD.class);
    
    
    clearWorkDir();
    LocalFileSystem fs = new LocalFileSystem();
    fs.setRootDirectory(getWorkDir());
    
    FileObject fo = fs.getRoot().createData("Ahoj", "txt");

    ic = new InstanceContent();
    support = new CES(this, new AbstractLookup(ic));
    edit = support;
    assertNotNull("we have editor", edit);

    DD.type = -1;
    DD.toReturn = new Stack<Object>();
}
 
源代码22 项目: netbeans   文件: CallbackActionTest.java
public void testWithFallback() throws Exception {
    MyAction myAction = new MyAction();
    MyAction fallAction = new MyAction();
    
    ActionMap other = new ActionMap();
    ActionMap tc = new ActionMap();
    tc.put("somekey", myAction);
    
    InstanceContent ic = new InstanceContent();
    AbstractLookup al = new AbstractLookup(ic);
    ic.add(tc);
    
    ContextAwareAction a = callback("somekey", fallAction, al, false);
    CntListener l = new CntListener();
    a.addPropertyChangeListener(l);

    assertTrue("My action is on", myAction.isEnabled());
    assertTrue("Callback is on", a.isEnabled());
    
    l.assertCnt("No change yet", 0);
    
    ic.remove(tc);
    assertTrue("fall is on", fallAction.isEnabled());
    assertTrue("My is on as well", a.isEnabled());

    l.assertCnt("Still enabled, so no change", 0);
    
    fallAction.setEnabled(false);
    
    l.assertCnt("Now there was one change", 1);
    
    assertFalse("fall is off", fallAction.isEnabled());
    assertFalse("My is off as well", a.isEnabled());
    
    
    Action a2 = a.createContextAwareInstance(Lookup.EMPTY);
    assertEquals("Both actions are equal", a, a2);
    assertEquals("and have the same hash", a.hashCode(), a2.hashCode());
}
 
源代码23 项目: constellation   文件: SimpleGraphTopComponent.java
public SimpleGraphTopComponent(final GraphDataObject gdo, final Graph graph) {
    initComponents();
    setName(gdo.getName());
    setToolTipText(gdo.getToolTipText());

    this.graph = graph;
    graphText.setText(gdo.getPrimaryFile().getName());
    schemaText.setText(graph.getSchema().getFactory().getName());

    graphChanged(null);

    graphNode = new GraphNode(graph, gdo, this, null);

    content = new InstanceContent();
    content.add(getActionMap());
    content.add(graphNode.getDataObject());
    content.add(graph);
    content.add(graphNode);

    associateLookup(new AbstractLookup(content));

    setActivatedNodes(new Node[]{
        graphNode
    });

    graph.addGraphChangeListener(SimpleGraphTopComponent.this);
}
 
源代码24 项目: netbeans   文件: NavigatorTCTest.java
public ActNodeLookupProvider () {
    this.node1 = new AbstractNode(Children.LEAF);
    this.node1.setDisplayName(FIRST_NAME);
    this.node2 = new AbstractNode(Children.LEAF);
    this.node2.setDisplayName(SECOND_NAME);
    
    ic = new InstanceContent();
    ic.add(node1);
    lookup = new AbstractLookup(ic);
}
 
源代码25 项目: snap-desktop   文件: DocumentTopComponent.java
public DocumentTopComponent(D document) {
    if (document == null) {
        throw new NullPointerException("document");
    }
    this.document = document;
    this.dynamicContent = new InstanceContent();
    associateLookup(new ProxyLookup(Lookups.fixed(document), new AbstractLookup(dynamicContent)));
}
 
源代码26 项目: netbeans   文件: GlobalSharabilityQueryImplTest.java
private Lookup getInstanceLookup() {
    InstanceContent instanceContent = new InstanceContent();
    instanceContent.add(sq);
    instanceContent.add(vq);
    Lookup instanceLookup = new AbstractLookup(instanceContent);
    return instanceLookup;
}
 
源代码27 项目: netbeans   文件: ResourceBundleBrandingPanel.java
public BundleNode(Node orig, String bundlepath, String codenamebase, InstanceContent content) {
    super(orig, new BundleChildren (orig, bundlepath, codenamebase), new AbstractLookup(content));
    content.add(this);
    
    disableDelegation(DELEGATE_GET_DISPLAY_NAME | DELEGATE_SET_DISPLAY_NAME
            | DELEGATE_GET_SHORT_DESCRIPTION | DELEGATE_SET_SHORT_DESCRIPTION
            | DELEGATE_GET_ACTIONS);

    setDisplayName(bundlepath);
    setShortDescription(codenamebase);

    this.bundlepath = bundlepath;
    this.codenamebase = codenamebase;
    this.bundleChildren = (BundleChildren) getChildren();
}
 
源代码28 项目: netbeans   文件: MultiModuleNodeFactory.java
ContentLkp(
        @NonNull final ModuleNode node,
        @NonNull final Object... fixedContent) {
    Parameters.notNull("node", node);                 //NOI18N
    Parameters.notNull("fixedContent", fixedContent); //NOI18N
    this.node = node;
    this.fos = new AtomicReference<>(Pair.of(new InstanceContent(),Collections.emptyList()));
    this.dos = new AtomicReference<>(Pair.of(new InstanceContent(),Collections.emptyList()));
    this.setLookups(
            new AbstractLookup(fos.get().first()),
            new AbstractLookup(dos.get().first()),
            Lookups.fixed(fixedContent));
}
 
源代码29 项目: netbeans   文件: HtmlRefactoringGlobalAction.java
protected Lookup getLookup(Node[] n) {
    InstanceContent ic = new InstanceContent();
    for (Node node:n)
        ic.add(node);
    if (n.length>0) {
        EditorCookie tc = getTextComponent(n[0]);
        if (tc != null) {
            ic.add(tc);
        }
    }
    ic.add(new Hashtable(0));
    return new AbstractLookup(ic);
}
 
源代码30 项目: netbeans   文件: Nodes.java
@NonNull
private static Lookup createLookup (@NonNull Description desc) {
    final InstanceContent ic = new InstanceContent();
    ic.add(desc);
    ic.add(desc, ConvertDescription2TreePathHandle);
    ic.add(desc, ConvertDescription2FileObject);
    ic.add(desc, ConvertDescription2DataObject);
    return new AbstractLookup(ic);
}