private void addComponent(int x, int y) { if (m_toolBarBean instanceof MetaBean) { // need to add the MetaBean's internal connections // to BeanConnection's vector Vector<BeanConnection> associatedConnections = ((MetaBean) m_toolBarBean) .getAssociatedConnections(); BeanConnection.getConnections(m_mainKFPerspective.getCurrentTabIndex()) .addAll(associatedConnections); // ((MetaBean)m_toolBarBean).setXDrop(x); // ((MetaBean)m_toolBarBean).setYDrop(y); ((MetaBean) m_toolBarBean) .addPropertyChangeListenersSubFlow(KnowledgeFlowApp.this); } if (m_toolBarBean instanceof BeanContextChild) { m_bcSupport.add(m_toolBarBean); } BeanInstance bi = new BeanInstance(m_beanLayout, m_toolBarBean, x, y, m_mainKFPerspective.getCurrentTabIndex()); // addBean((JComponent)bi.getBean()); m_toolBarBean = null; addComponent(bi, true); }
private void addComponent(int x, int y) { if (m_toolBarBean instanceof MetaBean) { // need to add the MetaBean's internal connections // to BeanConnection's vector Vector associatedConnections = ((MetaBean)m_toolBarBean).getAssociatedConnections(); BeanConnection.getConnections(m_mainKFPerspective.getCurrentTabIndex()). addAll(associatedConnections); //((MetaBean)m_toolBarBean).setXDrop(x); //((MetaBean)m_toolBarBean).setYDrop(y); ((MetaBean)m_toolBarBean).addPropertyChangeListenersSubFlow(KnowledgeFlowApp.this); } if (m_toolBarBean instanceof BeanContextChild) { m_bcSupport.add(m_toolBarBean); } BeanInstance bi = new BeanInstance(m_beanLayout, m_toolBarBean, x, y, m_mainKFPerspective.getCurrentTabIndex()); // addBean((JComponent)bi.getBean()); m_toolBarBean = null; addComponent(bi, true); }
/** * Layer method, enhanced to check if the PlugIn is interested in being * added to the BeanContext. */ public boolean getAddToBeanContext() { boolean ret = false; if (plugin != null && (plugin instanceof BeanContextChild || plugin instanceof BeanContextMembershipListener)) { if (plugin instanceof AbstractPlugIn) { ret = ((AbstractPlugIn) plugin).getAddToBeanContext(); } else { ret = true; } } else { ret = super.getAddToBeanContext(); } if (Debug.debugging("plugin")) { Debug.output(getName() + ".addToBeanContext is " + ret); } return ret; }
/** * Gets the current BeanContext from itself, if it's been set and the * provided PlugIn wants/can be added to the BeanContext, it assumes it was * and removes it from the BeanContext. */ public void removePlugInFromBeanContext(PlugIn pi) { BeanContext bc = getBeanContext(); if (bc != null && pi != null && (pi instanceof BeanContextChild || (pi instanceof AbstractPlugIn && ((AbstractPlugIn) pi).getAddToBeanContext()))) { // Of course, we don't need all these conditions met to // order the removal, but they are the ones in place that would // cause it to be added, so we don't waste the effort // unless the same conditions are met. bc.remove(pi); } }
public void testAdd_BCC() { MockBeanContextSupport support = new MockBeanContextSupport(); MockBeanContextMembershipListener l1 = new MockBeanContextMembershipListener(); MockPropertyChangeListener l2 = new MockPropertyChangeListener(); MockVetoableChangeListener l3 = new MockVetoableChangeListener(); support.addBeanContextMembershipListener(l1); support.addPropertyChangeListener("children", l2); support.addVetoableChangeListener("children", l3); BeanContextChild child = new MockBeanContextChild(); support.add(child); support.records.assertRecord("initialize", null); support.records.assertRecord("validatePendingAdd", child, Boolean.TRUE); support.records.assertRecord("createBCSChild", child, null, support .children().get(child)); support.records.assertRecord("childJustAddedHook", child, support .children().get(child), null); support.records.assertEndOfRecords(); assertTrue(l1.lastEventAdd); assertMembershipEvent(l1.lastEvent, support, null, child); assertNull(l2.lastEvent); assertNull(l3.lastEvent); assertSame(support, child.getBeanContext()); }
public void testGetChildBeanContextChild_BeanContextChild() { MockBeanContextChild child = new MockBeanContextChild(); BeanContextChild result = MockBeanContextSupport .publicGetChildBeanContextChild(child); assertSame(child, result); // Regression for HARMONY-1393 class TestBeanException extends BeanContextChildSupport implements BeanContextProxy { private static final long serialVersionUID = -8544245159647566063L; private final BeanContextChildSupport childSupport = new BeanContextChildSupport(); public BeanContextChild getBeanContextProxy() { return childSupport; } } TestBeanException bean = new TestBeanException(); try { MockBeanContextSupport.publicGetChildBeanContextChild(bean); fail("IllegalArgumentException expected"); } catch (IllegalArgumentException e) { // expected } }
private void addComponent(int x, int y) { if (m_toolBarBean instanceof MetaBean) { // need to add the MetaBean's internal connections // to BeanConnection's vector Vector associatedConnections = ((MetaBean) m_toolBarBean) .getAssociatedConnections(); BeanConnection.getConnections().addAll(associatedConnections); } if (m_toolBarBean instanceof BeanContextChild) { m_bcSupport.add(m_toolBarBean); } BeanInstance bi = new BeanInstance(m_beanLayout, m_toolBarBean, x, y); // addBean((JComponent)bi.getBean()); m_toolBarBean = null; addComponent(bi, true); }
public void testIsDelegated() throws Exception { BeanContextChildSupport support = new MockBeanContextChildSupport(); assertFalse(support.isDelegated()); BeanContextChild mockChild = new MockBeanContextChild(); support = new MockBeanContextChildSupport(mockChild); assertTrue(support.isDelegated()); support.beanContextChildPeer = support; assertFalse(support.isDelegated()); BeanContextChildSupport sup = new BeanContextChildSupport(); assertFalse("Child is not supposed to be delegated", sup.isDelegated()); }
/** * @see java.beans.beancontext.BeanContextServicesSupport#getService() */ public Result testGetServiceException() throws Exception { BeanContextChild child = null; Object requestor = null; Class serviceClass = null; Object serviceSelector = null; BeanContextServiceRevokedListener bcsrl = null; BeanContextServicesSupport context = new BeanContextServicesSupport(); serviceBean = null; try { context.getService(child, requestor ,serviceClass,serviceSelector,bcsrl); } catch (NullPointerException e) { return passed(); } return failed("testGetServiceException"); }
/** * @see java.beans.beancontext.BeanContextServicesSupport#releaseService() */ public Result testReleaseServiceException() throws Exception { BeanContextChild child = null; Object requestor = null; Object service = null; BeanContextServicesSupport context = new BeanContextServicesSupport(); serviceBean = null; try { context.releaseService(child, requestor ,service); } catch (NullPointerException e) { return passed(); } return failed("testGetServiceException"); }
private void annotateCurrentPosition(final JPDAThread currentThread, final SourcePath sourcePath, final CallStackFrame csf, final String language, final String url, final int lineNumber) { final Runnable updateCurrentAnnotation = new Runnable () { @Override public void run () { // show current line synchronized (currentPCLock) { if (currentPC != null) EditorContextBridge.getContext().removeAnnotation (currentPC); if (csf != null && sourcePath != null && currentThread != null && url != null && lineNumber >= 0) { // annotate current line currentPC = sourcePath.annotate (currentThread, language, url, lineNumber); } else { currentPC = null; } } } }; PropertyChangeListener operationsUpdateListener = new PropertyChangeListener() { @Override public void propertyChange(PropertyChangeEvent evt) { String name = evt.getPropertyName(); if (PROP_OPERATIONS_UPDATE.equals(name)) { SwingUtilities.invokeLater (updateCurrentAnnotation); } if (PROP_OPERATIONS_SET.equals(name)) { ((BeanContextChild) currentThread).removePropertyChangeListener(PROP_OPERATIONS_UPDATE, this); ((BeanContextChild) currentThread).removePropertyChangeListener(PROP_OPERATIONS_SET, this); } } }; ((BeanContextChild) currentThread).addPropertyChangeListener(PROP_OPERATIONS_UPDATE, operationsUpdateListener); ((BeanContextChild) currentThread).addPropertyChangeListener(PROP_OPERATIONS_SET, operationsUpdateListener); SwingUtilities.invokeLater (updateCurrentAnnotation); }
private static Children getChildren(Object bean) { if (bean instanceof BeanContext) { return new BeanChildren((BeanContext) bean); } if (bean instanceof BeanContextProxy) { BeanContextChild bch = ((BeanContextProxy) bean).getBeanContextProxy(); if (bch instanceof BeanContext) { return new BeanChildren((BeanContext) bch); } } return Children.LEAF; }
public static void main(String[] args) { for (int i = 0; i < 10; i++) { BeanContextServices container = new BeanContextServicesSupport(); BeanContextChild ms1 = new MyService1(); BeanContextServices ms2 = new MyService2(); BeanContextChild mb = new MyBean(); container.add(ms1); container.add(ms2); ms2.add(mb); // exception thrown here container.remove(ms2); } }
/** * Gets the current BeanContext from itself, if it's been set and the * provided PlugIn wants/can be added to the BeanContext, it will be added.. */ public void addPlugInToBeanContext(PlugIn pi) { BeanContext bc = getBeanContext(); if (bc != null && pi != null && (pi instanceof BeanContextChild || (pi instanceof AbstractPlugIn && ((AbstractPlugIn) pi).getAddToBeanContext()))) { bc.add(pi); } }
/** * @param bcc */ public MockBeanContextChildSupport(BeanContextChild bcc) { super(bcc); assertNull(this.beanContext); assertSame(bcc, this.beanContextChildPeer); assertFalse(this.rejectedSetBCOnce); }
public void testGetBeanContextChildPeer() throws Exception { BeanContextChildSupport support = new MockBeanContextChildSupport(); assertSame(support, support.beanContextChildPeer); assertSame(support, support.getBeanContextChildPeer()); BeanContextChild mockChild = new MockBeanContextChild(); support = new MockBeanContextChildSupport(mockChild); assertSame(mockChild, support.beanContextChildPeer); assertSame(mockChild, support.getBeanContextChildPeer()); BeanContextChildSupport sup = new BeanContextChildSupport(); assertEquals(sup, sup.getBeanContextChildPeer()); }
public void testAdd_BCP() { MockBeanContextSupport support = new MockBeanContextSupport(); support.waitOnChildInHooks = false; MockBeanContextMembershipListener l1 = new MockBeanContextMembershipListener(); MockPropertyChangeListener l2 = new MockPropertyChangeListener(); MockVetoableChangeListener l3 = new MockVetoableChangeListener(); support.addBeanContextMembershipListener(l1); support.addPropertyChangeListener("children", l2); support.addVetoableChangeListener("children", l3); BeanContextChild childPeer = new MockBeanContextChild(); BeanContextProxy child = new MockBeanContextProxy(childPeer); support.add(child); support.records.assertRecord("initialize", null); support.records.assertRecord("validatePendingAdd", child, Boolean.TRUE); support.records.assertRecord("createBCSChild", child, childPeer, support.children().get(child)); support.records.assertRecord("createBCSChild", childPeer, child, support.children().get(childPeer)); support.records.assertRecord("childJustAddedHook", child, support .children().get(child), null); support.records.assertRecord("childJustAddedHook", childPeer, support .children().get(childPeer), null); support.records.assertEndOfRecords(); assertTrue(l1.lastEventAdd); assertMembershipEvent(l1.lastEvent, support, null, Arrays .asList(new Object[] { child, childPeer })); assertNull(l2.lastEvent); assertNull(l3.lastEvent); assertSame(support, childPeer.getBeanContext()); assertEquals(2, support.size()); }
public void testAdd_Veto() { MockBeanContextSupport support = new MockBeanContextSupport(); MockBeanContextMembershipListener l1 = new MockBeanContextMembershipListener(); MockPropertyChangeListener l2 = new MockPropertyChangeListener(); MockVetoableChangeListener l3 = new MockVetoableChangeListener(); support.addBeanContextMembershipListener(l1); support.addPropertyChangeListener("children", l2); support.addVetoableChangeListener("children", l3); support.vetoAddRemove = true; BeanContextChild child = new MockBeanContextChild(); try { support.add(child); fail(); } catch (IllegalStateException e) { // expected } support.records.assertRecord("initialize", null); support.records .assertRecord("validatePendingAdd", child, Boolean.FALSE); support.records.assertEndOfRecords(); assertNull(l1.lastEvent); assertNull(l2.lastEvent); assertNull(l3.lastEvent); assertNull(child.getBeanContext()); }
public void testGetChildBeanContextChild_BeanContextProxy() { MockBeanContextChild child = new MockBeanContextChild(); MockBeanContextProxy proxy = new MockBeanContextProxy(child); BeanContextChild result = MockBeanContextSupport .publicGetChildBeanContextChild(proxy); assertSame(child, result); }
public void testRemoveObject_BCC() { MockBeanContextSupport support = new MockBeanContextSupport(); MockBeanContextMembershipListener l1 = new MockBeanContextMembershipListener(); support.addBeanContextMembershipListener(l1); BeanContextChild child = new MockBeanContextChild(); support.add(child); support.records.assertRecord("initialize", null); support.records.assertRecord("validatePendingAdd", child, Boolean.TRUE); support.records.assertRecord("createBCSChild", child, null, support .children().get(child)); support.records.assertRecord("childJustAddedHook", child, support .children().get(child), null); support.records.assertEndOfRecords(); assertTrue(l1.lastEventAdd); assertMembershipEvent(l1.lastEvent, support, null, child); support.records.clear(); l1.clearLastEvent(); Object bcsChild = support.children().get(child); support.remove(child); support.records.assertRecord("validatePendingRemove", child, Boolean.TRUE); support.records.assertRecord("childJustRemovedHook", child, bcsChild, null); support.records.assertEndOfRecords(); assertTrue(l1.lastEventRemove); assertMembershipEvent(l1.lastEvent, support, null, child); assertNull(child.getBeanContext()); assertEquals(0, support.size()); }
public void testRemoveObject_Veto() { MockBeanContextSupport support = new MockBeanContextSupport(); MockBeanContextMembershipListener l1 = new MockBeanContextMembershipListener(); support.addBeanContextMembershipListener(l1); BeanContextChild child = new MockBeanContextChild(); support.add(child); support.records.assertRecord("initialize", null); support.records.assertRecord("validatePendingAdd", child, Boolean.TRUE); support.records.assertRecord("createBCSChild", child, null, support .children().get(child)); support.records.assertRecord("childJustAddedHook", child, support .children().get(child), null); support.records.assertEndOfRecords(); assertTrue(l1.lastEventAdd); assertMembershipEvent(l1.lastEvent, support, null, child); support.records.clear(); l1.clearLastEvent(); support.children().get(child); support.vetoAddRemove = true; try { support.remove(child); fail("IllegalStateException expected"); } catch (IllegalStateException e) { // expected } support.records.assertRecord("validatePendingRemove", child, Boolean.FALSE); support.records.assertEndOfRecords(); assertNull(l1.lastEvent); assertSame(support, child.getBeanContext()); assertEquals(1, support.size()); }
public void testRemoveObjectboolean() { MockBeanContextSupport support = new MockBeanContextSupport(); MockBeanContextMembershipListener l1 = new MockBeanContextMembershipListener(); support.addBeanContextMembershipListener(l1); BeanContextChild child = new MockBeanContextChild(); support.add(child); support.records.assertRecord("initialize", null); support.records.assertRecord("validatePendingAdd", child, Boolean.TRUE); support.records.assertRecord("createBCSChild", child, null, support .children().get(child)); support.records.assertRecord("childJustAddedHook", child, support .children().get(child), null); support.records.assertEndOfRecords(); assertTrue(l1.lastEventAdd); assertMembershipEvent(l1.lastEvent, support, null, child); support.records.clear(); l1.clearLastEvent(); Object bcsChild = support.children().get(child); support.publicRemove(child, false); // don't call child's setBeanContext support.records.assertRecord("validatePendingRemove", child, Boolean.TRUE); support.records.assertRecord("childJustRemovedHook", child, bcsChild, null); support.records.assertEndOfRecords(); assertTrue(l1.lastEventRemove); assertMembershipEvent(l1.lastEvent, support, null, child); assertSame(support, child.getBeanContext()); assertEquals(0, support.size()); }
public void testSize() { @SuppressWarnings("serial") class TestBean extends Component implements BeanContextProxy { public BeanContextChildSupport childSupport = new BeanContextChildSupport(); public BeanContextChild getBeanContextProxy() { return childSupport; } } // Regression test for HARMONY-1829 BeanContextSupport obj = new BeanContextSupport(); obj.add(new TestBean()); assertEquals(2, obj.size()); }
public Object getService(BeanContextChild child, Object requestor, Class serviceClass, Object serviceSelector, BeanContextServiceRevokedListener bcsrl) throws TooManyListenersException { // Auto-generated method stub return null; }
private void integrateFlow(Vector beans, Vector connections) { java.awt.Color bckC = getBackground(); m_bcSupport = new BeanContextSupport(); m_bcSupport.setDesignTime(true); // register this panel as a property change listener with each // bean for (int i = 0; i < beans.size(); i++) { BeanInstance tempB = (BeanInstance) beans.elementAt(i); if (tempB.getBean() instanceof Visible) { ((Visible) (tempB.getBean())).getVisual().addPropertyChangeListener( this); // A workaround to account for JPanel's with their default // background colour not being serializable in Apple's JRE ((Visible) (tempB.getBean())).getVisual().setBackground(bckC); ((JComponent) (tempB.getBean())).setBackground(bckC); } if (tempB.getBean() instanceof BeanCommon) { ((BeanCommon) (tempB.getBean())).setLog(m_logPanel); } if (tempB.getBean() instanceof BeanContextChild) { m_bcSupport.add(tempB.getBean()); } } BeanInstance.setBeanInstances(beans, m_beanLayout); BeanConnection.setConnections(connections); m_beanLayout.revalidate(); m_beanLayout.repaint(); }