Package org.dyno.visual.swing.layouts

Examples of org.dyno.visual.swing.layouts.GroupLayout


    return "new " + name + "()";
  }

  @Override
  protected String getChildConstraints(Component child, ImportRewrite imports) {
    GroupLayout layout = (GroupLayout) layoutAdapter.getContainer().getLayout();
    Constraints constraints = layout.getConstraints(child);
    StringBuilder builder = new StringBuilder();
    String strConstraints = imports
        .addImport("org.dyno.visual.swing.layouts.Constraints");
    builder.append("new " + strConstraints + "(");
    genAlignmentCode(builder, constraints.getHorizontal(), imports);
View Full Code Here


    super(Messages.MiddleAlignmentOperation_Align_Middle, container, glAdapter);
  }

  @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);
View Full Code Here

    super(Messages.LeftAlignmentOperation_Align_Left, container, glAdapter);
  }

  @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.getHorizontal();
    compcons = new ArrayList<CompCons>();
    if (postAlignment instanceof Leading || postAlignment instanceof Bilateral) {
      int postLead;
      if (postAlignment instanceof Leading)
        postLead = ((Leading) postAlignment).getLeading();
      else
        postLead = ((Bilateral) postAlignment).getLeading();
      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);
        Alignment alignment = constraints.getHorizontal();
        if (alignment instanceof Leading) {
          Leading leading = (Leading) alignment.clone();
          leading.setLeading(postLead);
          constraints = new Constraints(leading, constraints.getVertical());
        } else if (alignment instanceof Bilateral) {
          Bilateral bilateral = (Bilateral) alignment.clone();
          bilateral.setLeading(postLead);
          constraints = new Constraints(bilateral, constraints.getVertical());
        } else if (alignment instanceof Trailing) {
          Bilateral bilateral = new Bilateral(postLead, ((Trailing) alignment).getTrailing(), ((Trailing) alignment).getSize());
          constraints = new Constraints(bilateral, constraints.getVertical());
        }
        layout.setConstraints(child, constraints);
      }
    } else if (postAlignment instanceof Trailing) {
      Trailing postTrailing = (Trailing) postAlignment;
      int postTrail = postTrailing.getTrailing() + postChild.getWidth();
      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);
        Alignment alignment = constraints.getHorizontal();
        if (alignment instanceof Leading) {
          int t = postTrail - child.getWidth();
          Trailing trailing = new Trailing(t, 10, child.getWidth());
          constraints = new Constraints(trailing, constraints.getVertical());
        } else if (alignment instanceof Bilateral) {
          int t = postTrail - child.getWidth();
          Trailing trailing = new Trailing(t, 10, child.getWidth());
          constraints = new Constraints(trailing, constraints.getVertical());
        } else if (alignment instanceof Trailing) {
          Trailing trailing = (Trailing) alignment.clone();
          trailing.setTrailing(postTrail - child.getWidth());
          constraints = new Constraints(trailing, constraints.getVertical());
        }
        layout.setConstraints(child, constraints);
      }
    }
    container.invalidate();
    containerAdapter.doLayout();
    containerAdapter.setDirty(true);
View Full Code Here

    super(Messages.SameHeightOperation_Same_Height, container, glAdapter);
  }

  @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();
    int postSize = postChild.getHeight();
    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) {
      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);
        Alignment alignment = constraints.getVertical();
        if (alignment instanceof Leading) {
          Leading leading = (Leading) alignment.clone();
          leading.setSize(postSize);
          constraints = new Constraints(constraints.getHorizontal(), leading);
        } else if (alignment instanceof Bilateral) {
          Bilateral bilateral = (Bilateral) alignment;
          int lead = bilateral.getLeading();
          Leading leading = new Leading(lead, postSize, 10, innerHeight - postSize - lead);
          constraints = new Constraints(constraints.getHorizontal(), leading);
        } else if (alignment instanceof Trailing) {
          Trailing trailing = (Trailing) alignment.clone();
          trailing.setSize(postSize);
          constraints = new Constraints(constraints.getHorizontal(), trailing);
        }
        layout.setConstraints(child, constraints);
      }
    } else if (postAlignment instanceof Trailing) {
      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);
        Alignment alignment = constraints.getVertical();
        if (alignment instanceof Leading) {
          Leading leading = (Leading) alignment.clone();
          leading.setSize(postSize);
          constraints = new Constraints(constraints.getHorizontal(), leading);
        } else if (alignment instanceof Bilateral) {
          Bilateral bilateral = (Bilateral) alignment;
          int trail = bilateral.getTrailing();
          Trailing leading = new Trailing(trail, postSize, 10, innerHeight - postSize - trail);
          constraints = new Constraints(constraints.getHorizontal(), leading);
        } else if (alignment instanceof Trailing) {
          Trailing trailing = (Trailing) alignment.clone();
          trailing.setSize(postSize);
          constraints = new Constraints(constraints.getHorizontal(), trailing);
        }
        layout.setConstraints(child, constraints);
      }
    } else if (postAlignment instanceof Bilateral) {
      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);
        Alignment alignment = constraints.getVertical();
        if (alignment instanceof Leading) {
          Leading leading = (Leading) alignment;
          Bilateral bilateral = (Bilateral) postAlignment.clone();
          bilateral.setLeading(leading.getLeading());
          bilateral.setTrailing(innerHeight-leading.getLeading()-child.getHeight());
          constraints = new Constraints(constraints.getHorizontal(), bilateral);
        } else if (alignment instanceof Bilateral) {
          Bilateral leading = (Bilateral) alignment;
          Bilateral bilateral = (Bilateral) postAlignment.clone();
          bilateral.setTrailing(leading.getTrailing());
          bilateral.setLeading(leading.getLeading());
          constraints = new Constraints(constraints.getHorizontal(), bilateral);
        } else if (alignment instanceof Trailing) {
          Trailing trailing = (Trailing) alignment;
          Bilateral bilateral = (Bilateral) postAlignment.clone();
          bilateral.setTrailing(trailing.getTrailing());
          bilateral.setLeading(innerHeight-trailing.getTrailing()-child.getHeight());
          constraints = new Constraints(constraints.getHorizontal(), bilateral);
        }
        layout.setConstraints(child, constraints);
      }
    }
    container.invalidate();
    containerAdapter.doLayout();
    containerAdapter.setDirty(true);
View Full Code Here

    super(Messages.CenterAlignmentOperation_Align_Center, container, glAdapter);
  }

  @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.getHorizontal();
    compcons = new ArrayList<CompCons>();
    Insets insets = container.getInsets();
    int innerWidth = container.getWidth() - insets.left - insets.right;
    if (postAlignment instanceof Leading) {
      Leading postLeading = (Leading)postAlignment;
      int postCenter = postLeading.getLeading() + postChild.getWidth() / 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.getWidth() / 2;
        int t = innerWidth - postCenter - child.getWidth() / 2;
        Leading leading = new Leading(l, child.getWidth(), 10, t);
        constraints = new Constraints(leading, constraints.getVertical());
        layout.setConstraints(child, constraints);
      }
    } else if (postAlignment instanceof Bilateral) {
      Bilateral postBilateral = (Bilateral) postAlignment;
      int postCenter = postBilateral.getLeading() + postChild.getWidth() / 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.getWidth() / 2;
        int t = innerWidth - postCenter - child.getWidth()/2;
        Bilateral bilateral = new Bilateral(l, t, 10);
        constraints = new Constraints(bilateral, constraints.getVertical());
        layout.setConstraints(child, constraints);
      }
    } else if (postAlignment instanceof Trailing) {
      int postCenter = postChild.getX() + postChild.getWidth() / 2 - insets.left;
      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.getWidth() / 2;
        int t = innerWidth - postCenter - child.getWidth()/2;
        Trailing trailing= new Trailing(t, child.getWidth(), 10, l);
        constraints = new Constraints(trailing, constraints.getVertical());
        layout.setConstraints(child, constraints);
      }
    }
    container.invalidate();
    containerAdapter.doLayout();
    containerAdapter.setDirty(true);
View Full Code Here

    return execute(monitor, info);
  }

  @Override
  public IStatus undo(IProgressMonitor monitor, IAdaptable info) throws ExecutionException {
    GroupLayout layout = (GroupLayout) container.getLayout();
    for (CompCons cons : compcons) {
      layout.setConstraints(cons.component, cons.constraints);
    }
    container.invalidate();
    CompositeAdapter containerAdapter = (CompositeAdapter) WidgetAdapter.getWidgetAdapter(container);
    containerAdapter.doLayout();
    containerAdapter.setDirty(true);
View Full Code Here

    super(Messages.TopAlignmentOperation_Align_Top, container, glAdapter);
  }

  @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>();
    if (postAlignment instanceof Leading || postAlignment instanceof Bilateral) {
      int postLead;
      if (postAlignment instanceof Leading)
        postLead = ((Leading) postAlignment).getLeading();
      else
        postLead = ((Bilateral) postAlignment).getLeading();
      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);
        Alignment alignment = constraints.getVertical();
        if (alignment instanceof Leading) {
          Leading leading = (Leading) alignment.clone();
          leading.setLeading(postLead);
          constraints = new Constraints(constraints.getHorizontal(), leading);
        } else if (alignment instanceof Bilateral) {
          Bilateral bilateral = (Bilateral) alignment.clone();
          bilateral.setLeading(postLead);
          constraints = new Constraints(constraints.getHorizontal(), bilateral);
        } else if (alignment instanceof Trailing) {
          Bilateral bilateral = new Bilateral(postLead, ((Trailing) alignment).getTrailing(), ((Trailing) alignment).getSize());
          constraints = new Constraints(constraints.getHorizontal(), bilateral);
        }
        layout.setConstraints(child, constraints);
      }
    } else if (postAlignment instanceof Trailing) {
      Trailing postTrailing = (Trailing) postAlignment;
      int postTrail = postTrailing.getTrailing() + postChild.getHeight();
      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);
        Alignment alignment = constraints.getVertical();
        if (alignment instanceof Leading) {
          int t = postTrail - child.getHeight();
          Trailing trailing = new Trailing(t, 10, child.getHeight());
          constraints = new Constraints(constraints.getHorizontal(), trailing);
        } else if (alignment instanceof Bilateral) {
          int t = postTrail - child.getHeight();
          Trailing trailing = new Trailing(t, 10, child.getHeight());
          constraints = new Constraints(constraints.getHorizontal(), trailing);
        } else if (alignment instanceof Trailing) {
          Trailing trailing = (Trailing) alignment.clone();
          trailing.setTrailing(postTrail - child.getHeight());
          constraints = new Constraints(constraints.getHorizontal(), trailing);
        }
        layout.setConstraints(child, constraints);
      }
    }
    container.invalidate();
    containerAdapter.doLayout();
    containerAdapter.setDirty(true);
View Full Code Here

    super(Messages.RightAlignmentOperation_Align_Top, container, glAdapter);
  }

  @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.getHorizontal();
    compcons = new ArrayList<CompCons>();
    if (postAlignment instanceof Trailing || postAlignment instanceof Bilateral) {
      int postTrail;
      if (postAlignment instanceof Trailing)
        postTrail = ((Trailing) postAlignment).getTrailing();
      else
        postTrail = ((Bilateral) postAlignment).getTrailing();
      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);
        Alignment alignment = constraints.getHorizontal();
        if (alignment instanceof Trailing) {
          Trailing trailing = (Trailing) alignment.clone();
          trailing.setTrailing(postTrail);
          constraints = new Constraints(trailing, constraints.getVertical());
        } else if (alignment instanceof Bilateral) {
          Bilateral bilateral = (Bilateral) alignment.clone();
          bilateral.setTrailing(postTrail);
          constraints = new Constraints(bilateral, constraints.getVertical());
        } else if (alignment instanceof Leading) {
          Bilateral bilateral = new Bilateral(((Leading)alignment).getLeading(), postTrail, ((Leading) alignment).getSize());
          constraints = new Constraints(bilateral, constraints.getVertical());
        }
        layout.setConstraints(child, constraints);
      }
    } else if (postAlignment instanceof Leading) {
      Leading postLeading = (Leading) postAlignment;
      int postLead = postLeading.getLeading() + postChild.getWidth();
      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);
        Alignment alignment = constraints.getHorizontal();
        if (alignment instanceof Trailing) {
          int l = postLead - child.getWidth();
          Leading trailing = new Leading(l, 10, child.getWidth());
          constraints = new Constraints(trailing,constraints.getVertical());
        } else if (alignment instanceof Bilateral) {
          int l = postLead - child.getWidth();
          Leading leading = new Leading(l, 10, child.getWidth());
          constraints = new Constraints(leading, constraints.getVertical());
        } else if (alignment instanceof Leading) {
          Leading leading = (Leading) alignment.clone();
          leading.setLeading(postLead - child.getWidth());
          constraints = new Constraints(leading, constraints.getVertical());
        }
        layout.setConstraints(child, constraints);
      }
    }
    container.invalidate();
    containerAdapter.doLayout();
    containerAdapter.setDirty(true);
View Full Code Here

    super(Messages.SameWidthOperation_Same_Width, container, glAdapter);
  }

  @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();
    int postSize = postChild.getWidth();
    Constraints postConstraints = layout.getConstraints(postChild);
    Alignment postAlignment = postConstraints.getHorizontal();
    compcons = new ArrayList<CompCons>();
    Insets insets = container.getInsets();
    int innerWidth = container.getWidth() - insets.left - insets.right;
    if (postAlignment instanceof Leading) {
      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);
        Alignment alignment = constraints.getHorizontal();
        if (alignment instanceof Leading) {
          Leading leading = (Leading) alignment.clone();
          leading.setSize(postSize);
          constraints = new Constraints(leading, constraints.getVertical());
        } else if (alignment instanceof Bilateral) {
          Bilateral bilateral = (Bilateral) alignment;
          int lead = bilateral.getLeading();
          Leading leading = new Leading(lead, postSize, 10, innerWidth - postSize - lead);
          constraints = new Constraints(leading, constraints.getVertical());
        } else if (alignment instanceof Trailing) {
          Trailing trailing = (Trailing) alignment.clone();
          trailing.setSize(postSize);
          constraints = new Constraints(trailing, constraints.getVertical());
        }
        layout.setConstraints(child, constraints);
        glAdapter.adjustLayout(child);
      }
    } else if (postAlignment instanceof Trailing) {
      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);
        Alignment alignment = constraints.getHorizontal();
        if (alignment instanceof Leading) {
          Leading leading = (Leading) alignment.clone();
          leading.setSize(postSize);
          constraints = new Constraints(leading, constraints.getVertical());
        } else if (alignment instanceof Bilateral) {
          Bilateral bilateral = (Bilateral) alignment;
          int trail = bilateral.getTrailing();
          Trailing leading = new Trailing(trail, postSize, 10, innerWidth - postSize - trail);
          constraints = new Constraints(leading, constraints.getVertical());
        } else if (alignment instanceof Trailing) {
          Trailing trailing = (Trailing) alignment.clone();
          trailing.setSize(postSize);
          constraints = new Constraints(trailing, constraints.getVertical());
        }
        layout.setConstraints(child, constraints);
        glAdapter.adjustLayout(child);
      }
    } else if (postAlignment instanceof Bilateral) {
      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);
        Alignment alignment = constraints.getHorizontal();
        if (alignment instanceof Leading) {
          Leading leading = (Leading) alignment;
          Bilateral bilateral = (Bilateral) postAlignment.clone();
          bilateral.setLeading(leading.getLeading());
          bilateral.setTrailing(innerWidth - leading.getLeading() - child.getWidth());
          constraints = new Constraints(bilateral, constraints.getVertical());
        } else if (alignment instanceof Bilateral) {
          Bilateral leading = (Bilateral) alignment;
          Bilateral bilateral = (Bilateral) postAlignment.clone();
          bilateral.setTrailing(leading.getTrailing());
          bilateral.setLeading(leading.getLeading());
          constraints = new Constraints(bilateral, constraints.getVertical());
        } else if (alignment instanceof Trailing) {
          Trailing trailing = (Trailing) alignment;
          Bilateral bilateral = (Bilateral) postAlignment.clone();
          bilateral.setTrailing(trailing.getTrailing());
          bilateral.setLeading(innerWidth - trailing.getTrailing() - child.getWidth());
          constraints = new Constraints(bilateral, constraints.getVertical());
        }
        layout.setConstraints(child, constraints);
        glAdapter.adjustLayout(child);
      }
    }
    container.invalidate();
    containerAdapter.doLayout();
View Full Code Here

    super(Messages.BottomAlignmentOperation_Align_Bottom, container, glAdapter);
  }

  @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>();
    if (postAlignment instanceof Trailing || postAlignment instanceof Bilateral) {
      int postTrail;
      if (postAlignment instanceof Trailing)
        postTrail = ((Trailing) postAlignment).getTrailing();
      else
        postTrail = ((Bilateral) postAlignment).getTrailing();
      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);
        Alignment alignment = constraints.getVertical();
        if (alignment instanceof Trailing) {
          Trailing trailing = (Trailing) alignment.clone();
          trailing.setTrailing(postTrail);
          constraints = new Constraints(constraints.getHorizontal(), trailing);
        } else if (alignment instanceof Bilateral) {
          Bilateral bilateral = (Bilateral) alignment.clone();
          bilateral.setTrailing(postTrail);
          constraints = new Constraints(constraints.getHorizontal(), bilateral);
        } else if (alignment instanceof Leading) {
          Bilateral bilateral = new Bilateral(((Leading)alignment).getLeading(), postTrail, ((Leading) alignment).getSize());
          constraints = new Constraints(constraints.getHorizontal(), bilateral);
        }
        layout.setConstraints(child, constraints);
      }
    } else if (postAlignment instanceof Leading) {
      Leading postLeading = (Leading) postAlignment;
      int postLead = postLeading.getLeading() + postChild.getHeight();
      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);
        Alignment alignment = constraints.getVertical();
        if (alignment instanceof Trailing) {
          int l = postLead - child.getHeight();
          Leading trailing = new Leading(l, 10, child.getHeight());
          constraints = new Constraints(constraints.getHorizontal(), trailing);
        } else if (alignment instanceof Bilateral) {
          int l = postLead - child.getHeight();
          Leading leading = new Leading(l, 10, child.getHeight());
          constraints = new Constraints(constraints.getHorizontal(), leading);
        } else if (alignment instanceof Leading) {
          Leading leading = (Leading) alignment.clone();
          leading.setLeading(postLead - child.getHeight());
          constraints = new Constraints(constraints.getHorizontal(), leading);
        }
        layout.setConstraints(child, constraints);
      }
    }
    container.invalidate();
    containerAdapter.doLayout();
    containerAdapter.setDirty(true);
View Full Code Here

TOP

Related Classes of org.dyno.visual.swing.layouts.GroupLayout

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.