Examples of WidgetAdapter


Examples of avm.WidgetAdapter

      Node node = widgetNodeList.item(i);
      //System.out.println("node:" + node + "---" + "Node type:" + node.getNodeType()); //debug
      if (node.getNodeType() == Node.ELEMENT_NODE) {
        //It is a widget node. Process its properties.
        String widgetTypeName = node.getNodeName();
        WidgetAdapter adapter = adapterForWidgetType.get(widgetTypeName);
       
        String widgetName = null;
        JComponent widget = adapter.New();
        Set<String> readProperties = new HashSet<String>();
       
        NodeList propertyNodeList = node.getChildNodes();
        for (int j = 0; j < propertyNodeList.getLength(); j++) {
          Node propertyNode = propertyNodeList.item(j);
          if (propertyNode.getNodeType() == Node.ELEMENT_NODE) {
            String propertyName = propertyNode.getNodeName();
            if (readProperties.contains(propertyName)) {
              // TODO Output an error message or throw an exception?
              System.err.println("The property '" + propertyName + "' is duplicated.");
            } else {
              if (propertyName.equals("name")) {
                 widgetName = propertyNode.getTextContent();
                 widget.setName(widgetName);
              } else {
                String str = propertyNode.getTextContent();
                String type = adapter.getPropertyType(propertyName);
                try {
                  adapter.setProperty(widget, propertyName,
                    convertToObject(type, str));
                } catch (Exception e) {
                  System.err.println("invalid conversion: " + str + " as " + type);
                }
              }
            }
           
            readProperties.add(propertyName);
          }
        }
       
        // Set a property to the default value if it is not found in the AVM XML.
        for (String property : adapter.getAllPropertyNames()) {
          if (!readProperties.contains(property)) {
            adapter.resetPropertyToDefaultValue(widget, property);
          }
        }
       
        parent.add(widget);
      }
View Full Code Here

Examples of net.sourceforge.squirrel_sql.client.gui.desktopcontainer.WidgetAdapter

  /**
   * Initialize plugins.
   */
  public void initializePlugins()
  {
    _app.getWindowManager().addSessionWidgetListener(new WidgetAdapter()
    {
      public void widgetOpened(WidgetEvent e)
      {
        onWidgetOpened(e);
      }
View Full Code Here

Examples of net.sourceforge.squirrel_sql.client.gui.desktopcontainer.WidgetAdapter

      int hight = Preferences.userRoot().getInt(PREF_KEY_OVERVIEW_FRAME_HIGHT, 300);

      setSize(new Dimension(width, hight));


      addWidgetListener(new WidgetAdapter()
      {
         @Override
         public void widgetClosing(WidgetEvent evt)
         {
            onWidgetClosing();
View Full Code Here

Examples of net.xoetrope.xui.WidgetAdapter

   * @param attribValue the value of the attribute
   * @return 0 for success, non zero for failure or to require some further action
   */
  public static int setAttribute( XProject project, Object comp, String attribName, Object attribValue )
  {
    WidgetAdapter adapter = WidgetAdapter.getInstance();
   
    if ( attribName.equals( "preferredsize" )) {
      String[] vals = attribValue.toString().split( "," );
      adapter.setPreferredSize( comp, Integer.parseInt( vals[ 0 ] ), Integer.parseInt( vals[ 1 ] ));
    }
    else if ( attribName.equals( "minimumsize" )) {
      String[] vals = attribValue.toString().split( "," );
      adapter.setMinimumSize( comp, Integer.parseInt( vals[ 0 ] ), Integer.parseInt( vals[ 1 ] ));
    }
    else if ( attribName.equals( "maximumsize" )) {
      String[] vals = attribValue.toString().split( "," );
      adapter.setMaximumSize( comp, Integer.parseInt( vals[ 0 ] ), Integer.parseInt( vals[ 1 ] ));
    }
    else if ( attribName.equals( "tooltip" ))
      adapter.setTooltip( comp, XuiUtilities.translate( project, attribValue.toString()));
    else if ( attribName.equals( "opaque" ))
      adapter.setOpaque( comp, attribValue.toString().equals( "true" ));
    else if ( attribName.equals( "visible" ))
      adapter.setVisible( comp, attribValue.toString().equals( "true" ));
    else if ( attribName.equals( "enabled" ))
      adapter.setEnabled( comp, attribValue.toString().equals( "true" ));
    else if ( attribName.equals( "alignment" ))
      adapter.setHorizontalAlignment( comp, attribValue.toString());
    else if ( attribName.equals( "border" ))
      adapter.setBorderType( comp, attribValue.toString());
   
    return -1;
  }
View Full Code Here

Examples of org.dyno.visual.swing.plugin.spi.WidgetAdapter

  @Override
  public boolean generateCode(IType type, ImportRewrite imports, IProgressMonitor monitor) {
    int count = ((CompositeAdapter)adaptable).getChildCount();
    for (int i = 0; i < count; i++) {
      Component child = ((CompositeAdapter)adaptable).getChild(i);
      WidgetAdapter childAdapter = WidgetAdapter.getWidgetAdapter(child);
      IParser parser = (IParser) childAdapter.getAdapter(IParser.class);
      if (parser!=null&&!parser.generateCode(type, imports, monitor))
        return false;
    }
    if (!adaptable.isCodeDirty())
      return true;
View Full Code Here

Examples of org.dyno.visual.swing.plugin.spi.WidgetAdapter

  @Override
  protected void genAddCode(ImportRewrite imports, StringBuilder builder) {
    int count = ((CompositeAdapter) adaptable).getChildCount();
    for (int i = 0; i < count; i++) {
      Component child = ((CompositeAdapter) adaptable).getChild(i);
      WidgetAdapter childAdapter = WidgetAdapter.getWidgetAdapter(child);
      IParser childParser = (IParser) childAdapter.getAdapter(IParser.class);
      String getMethodName = childParser.getCreationMethodName();
      if (!adaptable.isRoot())
        builder.append(((CompositeAdapter) adaptable).getID() + ".");
      builder.append("add(" + getMethodName + "());\n");
    }
View Full Code Here

Examples of org.dyno.visual.swing.plugin.spi.WidgetAdapter

  protected void genAddCode(ImportRewrite imports, StringBuilder builder) {
    CompositeAdapter ca = (CompositeAdapter) adaptable;
    int count = ca.getChildCount();
    for (int i = 0; i < count; i++) {
      Component child = ca.getChild(i);
      WidgetAdapter childAdapter = WidgetAdapter.getWidgetAdapter(child);
      IParser childParser = (IParser) childAdapter.getAdapter(IParser.class);
      String getMethodName = childParser.getCreationMethodName();
      if (!adaptable.isRoot())
        builder.append(ca.getID() + ".");
      builder.append("add(");
      builder.append(getMethodName + "());\n");
View Full Code Here

Examples of org.dyno.visual.swing.plugin.spi.WidgetAdapter

  private WidgetProperty property;
 
  public String getJavaCode(Object bean, ImportRewrite imports) {
    if (bean instanceof Component) {
      Component comp = (Component) bean;
      WidgetAdapter adapter = WidgetAdapter.getWidgetAdapter(comp);
      if (adapter != null) {
        StringBuilder builder = new StringBuilder();
        Object value = property.getFieldValue(bean);
        ICodeGen gen = property.getCodeGenerator();
        if (gen != null && value != null) {
          String initCode = gen.getInitJavaCode(value, imports);
          if (initCode != null)
            builder.append(initCode);
        }
        if (!adapter.isRoot()) {
          String name = adapter.getID();
          builder.append(name + ".");
        }
        String code;
        if (gen != null) {
          code = value == null ? "null" : gen.getJavaCode(value, imports);
View Full Code Here

Examples of org.dyno.visual.swing.plugin.spi.WidgetAdapter

    String fqcn ="javax.swing.ButtonGroup";
    String beanName = imports.addImport(fqcn);
    builder.append(id+" = new "+beanName+"();\n");
    List buttons = adapter.getElements();
    for(int i=0;i<buttons.size();i++){
      WidgetAdapter btnAdapter = (WidgetAdapter) buttons.get(i);
      AbstractButton button = (AbstractButton) btnAdapter.getWidget();
      WidgetAdapter buttonAdapter = WidgetAdapter.getWidgetAdapter(button);
      IParser btnParser = (IParser) buttonAdapter.getAdapter(IParser.class);
      builder.append(id+".add("+btnParser.getCreationMethodName()+"());\n");
    }
    builder.append("}\n");
    try {
      if (sibling == null)
View Full Code Here

Examples of org.dyno.visual.swing.plugin.spi.WidgetAdapter

  private FieldProperty property;
 
  public String getJavaCode(Object bean, ImportRewrite imports) {
    if (bean instanceof Component) {
      Component comp = (Component) bean;
      WidgetAdapter adapter = WidgetAdapter.getWidgetAdapter(comp);
      if (adapter != null) {
        StringBuilder builder = new StringBuilder();
        Class typeClass = property.getPropertyType();
        TypeAdapter typeAdapter = ExtensionRegistry.getTypeAdapter(typeClass);
        Object value = property.getFieldValue(bean);
        if (typeAdapter != null && typeAdapter.getCodegen() != null) {
          String initCode = typeAdapter.getCodegen().getInitJavaCode(value, imports);
          if (initCode != null)
            builder.append(initCode);
        }
        if (!adapter.isRoot()) {
          String name = adapter.getID();
          builder.append(name + ".");
        }
        builder.append(property.getFieldName() + "=");
        if (typeAdapter != null && typeAdapter.getCodegen() != null) {
          if (value == null) {
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.