Examples of ObjectRegistry


Examples of chrriis.common.ObjectRegistry

  }

  @Override
  public void destroy() {
    // Dispose all SWT controls (simulate dead peer).
    ObjectRegistry controlRegistry = SWTNativeComponent.getControlRegistry();
    for(int instanceID: controlRegistry.getInstanceIDs()) {
      final Control control = (Control)controlRegistry.get(instanceID);
      controlRegistry.remove(instanceID);
      control.getDisplay().asyncExec(new Runnable() {
        public void run() {
          control.getShell().dispose();
        }
      });
View Full Code Here

Examples of chrriis.common.ObjectRegistry

  /**
   * Get the control, which is only valid when in the native context.
   * @return the control, or null.
   */
  public Control getControl() {
    ObjectRegistry controlRegistry = SWTNativeComponent.getControlRegistry();
    return controlRegistry == null? null: (Control)controlRegistry.get(componentID);
  }
View Full Code Here

Examples of chrriis.common.ObjectRegistry

  /**
   * Get the native component, which is only valid when in the local context.
   * @return the native component, or null.
   */
  public NativeComponent getNativeComponent() {
    ObjectRegistry nativeComponentRegistry = SWTNativeComponent.getNativeComponentRegistry();
    return nativeComponentRegistry == null? null: (NativeComponent)nativeComponentRegistry.get(componentID);
  }
View Full Code Here

Examples of chrriis.common.ObjectRegistry

    }
  }

  static Control[] getControls() {
    List<Control> controlList = new ArrayList<Control>();
    ObjectRegistry controlRegistry = getControlRegistry();
    for(int instanceID: controlRegistry.getInstanceIDs()) {
      Control nativeComponent = (Control)controlRegistry.get(instanceID);
      if(nativeComponent != null) {
        controlList.add(nativeComponent);
      }
    }
    return controlList.toArray(new Control[0]);
View Full Code Here

Examples of chrriis.common.ObjectRegistry

      throw new IllegalStateException("Failed to create a Shell!");
    }
    @Override
    public Object run(Object[] args) throws Exception {
      // We need to synchronize: a non-UI thread may send a message thinking the component is valid, but the message would be invalid as the control is not yet in the registry.
      ObjectRegistry controlRegistry = SWTNativeComponent.getControlRegistry();
      synchronized(controlRegistry) {
        final int componentID = (Integer)args[0];
        Object canvasHandle = args[1];
        final Shell shell = createShell(canvasHandle);
        shell.addControlListener(new ControlAdapter() {
          private boolean isAdjusting;
          @Override
          public void controlMoved(ControlEvent e) {
            if(isAdjusting) {
              return;
            }
            Shell shell = (Shell)e.widget;
            Point location = shell.getLocation();
            if(location.x != 0 || location.y != 0) {
              // On Linux Ubuntu, I found that the location cannot be forced and this would cause a stack overflow.
              isAdjusting = true;
              shell.setLocation(0, 0);
              isAdjusting = false;
            }
          }
        });
        shell.setLayout(new FillLayout());
        Composite controlComposite = new Composite(shell, SWT.NONE);
        controlComposite.setLayout(new FillLayout());
        Control control = (Control)controlRegistry.get(componentID);
        if(control != null) {
          Shell oldShell = control.getShell();
          control.setParent(controlComposite);
          oldShell.dispose();
        } else {
          String nativeComponentClassName = (String)args[2];
          Object nativePeerCreationParameters = args[3];
          Method createControlMethod = Class.forName(nativeComponentClassName).getDeclaredMethod("createControl", Composite.class, Object[].class);
          createControlMethod.setAccessible(true);
          control = (Control)createControlMethod.invoke(null, controlComposite, nativePeerCreationParameters);
          if(Boolean.parseBoolean(NSSystemPropertySWT.COMPONENTS_DEBUG_PRINTCREATION.get())) {
            System.err.println("Created control: " + componentID);
          }
          control.addDisposeListener(new DisposeListener() {
            public void widgetDisposed(DisposeEvent e) {
              if(Boolean.parseBoolean(NSSystemPropertySWT.COMPONENTS_DEBUG_PRINTDISPOSAL.get())) {
                System.err.println("Disposed control: " + componentID);
              }
            }
          });
          controlRegistry.add(control, componentID);
          configureControl(control, componentID);
        }
        shell.setVisible (true);
        shell.getDisplay().asyncExec(new Runnable() {
          public void run() {
View Full Code Here

Examples of org.apache.bsf.util.ObjectRegistry

     * (non-Javadoc)
     * @see xdoclet.templateutil.SubTemplateEngine#getVariable(java.lang.String)
     */
    public Object getVariable(String name)
    {
        ObjectRegistry objreg = bsfManager.getObjectRegistry();

        return objreg.lookup(name);
    }
View Full Code Here

Examples of org.apache.bsf.util.ObjectRegistry

     */
    public void setVariable(String name, Object value)
    {
        // can't store null value in BSF registry
        if (value != null) {
            ObjectRegistry objreg = bsfManager.getObjectRegistry();

            objreg.register(name, value);
        }
    }
View Full Code Here

Examples of org.apache.bsf.util.ObjectRegistry

     * (non-Javadoc)
     * @see xdoclet.templateutil.SubTemplateEngine#clearVariables()
     */
    public void clearVariables()
    {
        bsfManager.setObjectRegistry(new ObjectRegistry());
    }
View Full Code Here

Examples of org.apache.tez.runtime.api.ObjectRegistry

  }

  @Test
  public void testBasicCRUD() {
    ObjectRegistry objectRegistry = new ObjectRegistryImpl();
    testCRUD(objectRegistry);
  }
View Full Code Here

Examples of org.apache.tez.runtime.api.ObjectRegistry

    testCRUD(objectRegistry);
  }

  @Test
  public void testClearCache() {
    ObjectRegistry objectRegistry = new ObjectRegistryImpl();
    testCRUD(objectRegistry);

    String one = "one";
    String two = "two";
    objectRegistry.cacheForVertex(one, one);
    objectRegistry.cacheForDAG(two, two);

    ((ObjectRegistryImpl)objectRegistry).clearCache(ObjectRegistryImpl.ObjectLifeCycle.VERTEX);
    Assert.assertNull(objectRegistry.get(one));
    Assert.assertNotNull(objectRegistry.get(two));

    objectRegistry.cacheForVertex(one, one);
    ((ObjectRegistryImpl)objectRegistry).clearCache(ObjectRegistryImpl.ObjectLifeCycle.DAG);
    Assert.assertNotNull(objectRegistry.get(one));
    Assert.assertNull(objectRegistry.get(two));
  }
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.