Package es.iiia.shapegrammar.rule

Examples of es.iiia.shapegrammar.rule.RuleModel


      if (selection != null && selection instanceof IStructuredSelection) {
        Object obj = ((IStructuredSelection) selection)
            .getFirstElement();
        // If we had a selection lets open the editor
        if (obj != null) {
          RuleModel rule = (RuleModel) obj;
          ShapeGrammarModel grammar = (ShapeGrammarModel) rule
              .getParent();
          grammar.deleteRule(rule);

          // now close the editor holding this rule
          for (IEditorReference editor : window.getActivePage()
              .getEditorReferences()) {
            if (editor.getEditor(false) instanceof RuleEditor) {
              RuleModel model = (RuleModel) ((RuleEditor) editor.getEditor(false))
                  .getModel();
              if (model.equals(rule)) {
                window.getActivePage().closeEditor(
                    editor.getEditor(false), false);
              }
            }
          }
View Full Code Here


    RuleView rules = (RuleView) workbenchWindow.getActivePage().findView(
        RuleView.ID);

    try {
      // Add rule
      RuleModel model = ((RuleContentProvider) rules.getContentProvider())
          .addRule(type);

      if (model != null) {
        // Create input
        ShapeGrammarInput input = new ShapeGrammarInput(model);

        // opens editor
        RuleEditor editor = (RuleEditor) workbenchWindow
            .getActivePage().openEditor(input, RuleEditor.ID);

        // hook the listener
        model.addPropertyChangeListener(editor);

        // shows properties
        workbenchWindow.getActivePage().showView(
            IPageLayout.ID_PROP_SHEET);
      }
View Full Code Here

         
          // now close the editor holding this rule
          for (IEditorReference editor : window.getActivePage()
              .getEditorReferences()) {
            if (editor.getEditor(false) instanceof ShapeEditor) {
              RuleModel model = (RuleModel) ((ShapeEditor) editor.getEditor(false))
                  .getModel();
              if (model.equals(shape)) {
                window.getActivePage().closeEditor(
                    editor.getEditor(false), false);
              }
            }
          }
View Full Code Here

        .getSelection();
    if (selection != null && selection instanceof IStructuredSelection) {
      Object obj = ((IStructuredSelection) selection).getFirstElement();
      // If we had a selection lets open the editor
      if (obj != null) {
        RuleModel model = (RuleModel) obj;
               
        ShapeGrammarInput input = new ShapeGrammarInput(model);
        try {
          // get Editor ID (it can be specific for different geometry)
          String editorID = model.getEditorId();
         
          // opens editor
          RuleEditor editor = (RuleEditor) page.openEditor(input, editorID == null ? RuleEditor.ID : editorID);
         
          // hook the listener
          model.addPropertyChangeListener(editor);
         
          // shows properties
          page.showView(IPageLayout.ID_PROP_SHEET);
         
        } catch (PartInitException e) {
View Full Code Here

public class AddToRightHandler extends AbstractHandler implements IHandler {

  public Object execute(ExecutionEvent event) throws ExecutionException {
    // get current model
    RuleEditor editor = (RuleEditor) HandlerUtil.getActiveEditor(event);
    RuleModel rule = (RuleModel) editor.getModel();

    // notify user that shape could be replaced
    if (rule.getRightShape() != null) {

    }

    // replace current left shape with the one selected
    ISelection selection = HandlerUtil.getActivePart(event).getSite()
        .getSelectionProvider().getSelection();
    if (selection != null && selection instanceof IStructuredSelection) {
      Object obj = ((IStructuredSelection) selection).getFirstElement();
      // If we had a selection lets open the editor
      if (obj != null) {
        ShapeModel shape = (ShapeModel) obj;
       
        // find the window centre
//        IFigure part = ((RuleEditPart)editor.getGraphicalViewer().getContents()).getFigure();
//        rule.setCenter(new PointModel(part.getBounds().getCenter().x, part.getBounds().getCenter().y));
        rule.setRightShape(shape);
      }
    }

    return null;
  }
View Full Code Here

      parent.setLayout(new FillLayout());
      cmp = new Composite(parent, SWT.EMBEDDED);
      Frame jframe = SWT_AWT.new_Frame(cmp);         
      panel = new JPanel() {
        public void paint(java.awt.Graphics g) {
          RuleModel rule = (RuleModel) model;
          if (rule.getLeftShape() != null) {
            int iconSize = getWidth() < getHeight() ? getWidth() : getHeight();
           
            ControllerBase ctr = null;
            try {
              ctr = ControllerFactory.CreateController(rule);
View Full Code Here

    this.setDirty(false);
  }
 
  @Override
  protected void initModel() {
    RuleModel rule = (RuleModel) model;
    getEditControllers().clear();
   
    try {
      // init left side shape
      if (rule.getLeftShape() != null) {
        ControllerBase ctrl = ControllerFactory.CreateController(rule.getLeftShape());
        ctrl.addPropertyChangeListener(this);
        getEditControllers().add(ctrl);
        ctrl.getModel().setColor(Color.red);
      }
     
      // init right side shape
      if (rule.getRightShape() != null) {
        ControllerBase ctrr = ControllerFactory.CreateController(rule.getRightShape());
        ctrr.addPropertyChangeListener(this);
        getEditControllers().add(ctrr);
      }
    } catch (Exception e1) {
      e1.printStackTrace();
View Full Code Here

  @Override
  public boolean test(Object receiver, String property, Object[] args,
      Object expectedValue) {
    if (receiver instanceof RuleEditor) {
      RuleModel rule = (RuleModel) ((RuleEditor) receiver).getModel();
      System.out.println("[IsRuleModification]" + (rule instanceof RuleModification));
      return !(rule instanceof RuleModification);
    }
    return false;
  }
View Full Code Here

  // operations

  public RuleModel addRule(ShapeGrammarRuleType type) {
    // create new shape
    RuleModel model = ShapeGrammarModel.ACTIVE_SHAPE_GRAMMAR.addRule(type);

    if (model != null) {
      // add new listener
      model.addPropertyChangeListener(this);
    }
    return model;
  }
View Full Code Here

      for (int i = 0; i < nl.getLength(); i++) {
        // get the shape element
        Element el = (Element) nl.item(i);

        // initialize it and add it to collection
        RuleModel model = initRule(el);
        this.grammar.getRules().add(model);
      }
    }
  }
View Full Code Here

TOP

Related Classes of es.iiia.shapegrammar.rule.RuleModel

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.