Package org.dyno.visual.swing.plugin.spi

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


import org.eclipse.jdt.core.dom.rewrite.ImportRewrite;

public class JToolBarParser extends CompositeParser {
  @Override
  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


      MethodInvocation mi = (MethodInvocation) exp;
      String getMethodName = mi.getName().getFullyQualifiedName();
      String fieldName = getFieldNameFromGetMethodName(methodInvocation,
          getMethodName);
      if (fieldName != null) {
        CompositeAdapter tabAdapter = (CompositeAdapter) adaptable;
        int count = tabAdapter.getChildCount();
        for (int i = 0; i < count; i++) {
          Component child = tabAdapter.getChild(i);
          WidgetAdapter childAdapter = WidgetAdapter
              .getWidgetAdapter(child);
          if (childAdapter.getName().equals(fieldName))
            return child;
        }
View Full Code Here

        builder.append(adapter.getID() + ".");
      builder.append("setLayout(");
      builder.append(getNewInstanceCode(imports));
      builder.append(");\n");
    }
    CompositeAdapter conAdapter = (CompositeAdapter) adapter;
    int count = conAdapter.getChildCount();
    for (int i = 0; i < count; i++) {
      Component child = conAdapter.getChild(i);
      builder.append(getAddChildCode(layoutAdapter, child, imports));
    }
    return builder.toString();
  }
View Full Code Here

public class JTabbedPaneParser extends CompositeParser {

  @Override
  protected void genAddCode(ImportRewrite imports, StringBuilder builder) {
    JTabbedPane jtp = (JTabbedPane) adaptable.getWidget();
    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("addTab(");
      String title = jtp.getTitleAt(i);
      String tip = jtp.getToolTipTextAt(i);
      Icon icon = jtp.getIconAt(i);
      builder.append("\"" + title + "\", ");
View Full Code Here

  private void parsePropertyValue(String lnfClassname, CompilationUnit cunit, WidgetAdapter adapter) {
    TypeDeclaration type = (TypeDeclaration) cunit.types().get(0);
    IWidgetASTParser widgetParser = (IWidgetASTParser) adapter.getAdapter(IWidgetASTParser.class);
    widgetParser.parse(lnfClassname, type);
    if (adapter instanceof CompositeAdapter) {
      CompositeAdapter compositeAdapter = (CompositeAdapter) adapter;
      int count = compositeAdapter.getChildCount();
      for (int i = 0; i < count; i++) {
        Component child = compositeAdapter.getChild(i);
        WidgetAdapter childAdapter = WidgetAdapter.getWidgetAdapter(child);
        parsePropertyValue(lnfClassname, cunit, childAdapter);
      }
    }
  }
View Full Code Here

      for (InvisibleAdapter invisible : root.getInvisibles()) {
        renameInvisible(type, invisible);
      }
    }
    if (root instanceof CompositeAdapter) {
      CompositeAdapter container = (CompositeAdapter) root;
      int count = container.getChildCount();
      for (int i = 0; i < count; i++) {
        Component child = container.getChild(i);
        WidgetAdapter childAdapter = WidgetAdapter.getWidgetAdapter(child);
        rename(type, childAdapter);
      }
    }
  }
View Full Code Here

import org.eclipse.jdt.core.dom.rewrite.ImportRewrite;

public class JScrollPaneParser extends CompositeParser {
  @Override
  protected void genAddCode(ImportRewrite imports, StringBuilder builder) {
    CompositeAdapter jspa = (CompositeAdapter) adaptable;
    if (jspa.getChildCount() > 0) {
      Component child = jspa.getChild(0);
      WidgetAdapter childAdapter = WidgetAdapter.getWidgetAdapter(child);
      IParser childParser = (IParser) childAdapter.getAdapter(IParser.class);
      String getMethodName = childParser.getCreationMethodName();
      if (!adaptable.isRoot())
        builder.append(jspa.getID() + ".");
      builder.append("setViewportView(" + getMethodName + "());\n");
    }
  }
View Full Code Here

          removeNameRecursively(jpmAdapter, names);
        }
      }
    }
    if(targetAdapter instanceof CompositeAdapter){
      CompositeAdapter composite = (CompositeAdapter)targetAdapter;
      int count = composite.getChildCount();
      for(int i=0;i<count;i++){
        Component child = composite.getChild(i);
        WidgetAdapter childAdapter = WidgetAdapter.getWidgetAdapter(child);
        removeNameRecursively(childAdapter, names);
      }
    }
  }
View Full Code Here

  protected String createGetCode(ImportRewrite imports) {
    StringBuilder builder = new StringBuilder();
    String id = adaptable.getID();
    builder.append(id + " = " + getNewInstanceCode(imports) + ";\n");
    builder.append(createSetCode(imports));
    CompositeAdapter conAdapter = adaptable.getParentAdapter();
    if (conAdapter.needGenBoundCode(adaptable.getWidget())) {
      Rectangle bounds = adaptable.getWidget().getBounds();
      String strBounds = id + ".setBounds(" + bounds.x + ", " + bounds.y + ", " + bounds.width + ", " + bounds.height + ");\n";
      builder.append(strBounds);
    }
    genAddCode(imports, builder);
View Full Code Here

  }

  @Override
  public IStatus execute(IProgressMonitor monitor, IAdaptable info) throws ExecutionException {
    GroupLayout layout = (GroupLayout) container.getLayout();
    CompositeAdapter containerAdapter = (CompositeAdapter) WidgetAdapter.getWidgetAdapter(container);
    WidgetAdapter post = widgets.get(0);
    Component postChild = post.getWidget();
    Constraints postConstraints = layout.getConstraints(postChild);
    Alignment postAlignment = postConstraints.getVertical();
    compcons = new ArrayList<CompCons>();
    Insets insets = container.getInsets();
    int innerHeight = container.getHeight() - insets.top - insets.bottom;
    if (postAlignment instanceof Leading) {
      Leading postLeading = (Leading)postAlignment;
      int postCenter = postLeading.getLeading() + postChild.getHeight() / 2;
      for (int i = 1; i < widgets.size(); i++) {
        WidgetAdapter adapter = widgets.get(i);
        Component child = adapter.getWidget();
        Constraints constraints = layout.getConstraints(child);
        CompCons cons = new CompCons();
        cons.component = child;
        cons.constraints = constraints;
        compcons.add(cons);
        int l = postCenter - child.getHeight() / 2;
        int t = innerHeight - postCenter - child.getHeight() / 2;
        Leading leading = new Leading(l, child.getHeight(), 10, t);
        constraints = new Constraints(constraints.getHorizontal(), leading);
        layout.setConstraints(child, constraints);
      }
    } else if (postAlignment instanceof Bilateral) {
      Bilateral postBilateral = (Bilateral)postAlignment;
      int postCenter = postBilateral.getLeading() + postChild.getHeight() / 2;
      for (int i = 1; i < widgets.size(); i++) {
        WidgetAdapter adapter = widgets.get(i);
        Component child = adapter.getWidget();
        Constraints constraints = layout.getConstraints(child);
        CompCons cons = new CompCons();
        cons.component = child;
        cons.constraints = constraints;
        compcons.add(cons);
        int l = postCenter - child.getHeight() / 2;
        int t = innerHeight - postCenter - child.getHeight()/2;
        Bilateral bilateral = new Bilateral(l, t, 10);
        constraints = new Constraints(constraints.getHorizontal(), bilateral);
        layout.setConstraints(child, constraints);
      }
    } else if (postAlignment instanceof Trailing) {
      int postCenter = postChild.getY() + postChild.getHeight()/2 - insets.top;
      for (int i = 1; i < widgets.size(); i++) {
        WidgetAdapter adapter = widgets.get(i);
        Component child = adapter.getWidget();
        Constraints constraints = layout.getConstraints(child);
        CompCons cons = new CompCons();
        cons.component = child;
        cons.constraints = constraints;
        compcons.add(cons);
        int l = postCenter - child.getHeight()/2;
        int t = innerHeight - postCenter - child.getHeight()/2;
        Trailing trailing= new Trailing(t, child.getHeight(), 10, l);
        constraints = new Constraints(constraints.getHorizontal(), trailing);
        layout.setConstraints(child, constraints);
      }
    }
    container.invalidate();
    containerAdapter.doLayout();
    containerAdapter.setDirty(true);
    containerAdapter.repaintDesigner();
    return Status.OK_STATUS;
  }
View Full Code Here

TOP

Related Classes of org.dyno.visual.swing.plugin.spi.CompositeAdapter

Copyright © 2018 www.massapicom. 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.