Package net.sf.graphiti.model

Examples of net.sf.graphiti.model.AbstractObject


  }

  @Override
  @SuppressWarnings("unchecked")
  protected void buttonAddSelected() {
    AbstractObject model = getModel();

    String dialogTitle = "New value";
    String dialogMessage = "Please enter a value:";
    String initialValue = "";
    InputDialog dialog = new InputDialog(getShell(), dialogTitle,
        dialogMessage, initialValue, new IInputValidator() {

          @Override
          public String isValid(String newText) {
            return newText.isEmpty() ? "" : null;
          }

        });

    if (dialog.open() == InputDialog.OK) {
      List<Object> oldList = (List<Object>) model.getValue(parameterName);
      List<Object> newList = new ArrayList<Object>(oldList);
      newList.add(dialog.getValue());

      IWorkbenchPart part = getPart();
      if (part instanceof GraphEditor) {
View Full Code Here


  protected void buttonRemoveSelected() {
    IStructuredSelection ssel = getTableSelection();
    if (ssel != null && !ssel.isEmpty()) {
      Object obj = ssel.getFirstElement();

      AbstractObject model = getModel();
      List<Object> oldList = (List<Object>) model.getValue(parameterName);
      List<Object> newList = new ArrayList<Object>(oldList);
      newList.remove(obj);

      IWorkbenchPart part = getPart();
      if (part instanceof GraphEditor) {
View Full Code Here

    public void dispose() {
    }

    @Override
    public Object[] getElements(Object inputElement) {
      AbstractObject model = (AbstractObject) inputElement;
      Map<?, ?> map = (Map<?, ?>) model.getValue(parameterName);
      return map.entrySet().toArray();
    }
View Full Code Here

      // if value only contains spaces, ignore it
      if (((String) value).trim().isEmpty()) {
        return;
      }

      AbstractObject model = (AbstractObject) getViewer().getInput();
      Map<Object, Object> oldMap = (Map<Object, Object>) model
          .getValue(parameterName);

      Entry<Object, Object> entry = (Entry<Object, Object>) element;
      if (value.equals(key ? entry.getKey() : entry.getValue())) {
        return;
View Full Code Here

  private void shiftValue(int offset) {
    IStructuredSelection ssel = getTableSelection();
    if (ssel != null && !ssel.isEmpty()) {
      Object obj = ssel.getFirstElement();

      AbstractObject model = getModel();
      List<Object> oldList = (List<Object>) model.getValue(parameterName);
      List<Object> newList = new ArrayList<Object>(oldList);

      int index = newList.indexOf(obj);
      Object element = newList.remove(index);
      newList.add(index + offset, element);
View Full Code Here

    public void dispose() {
    }

    @Override
    public Object[] getElements(Object inputElement) {
      AbstractObject model = (AbstractObject) inputElement;
      java.util.List<?> list = (java.util.List<?>) model
          .getValue(parameterName);
      return list.toArray();
    }
View Full Code Here

    }

    @Override
    @SuppressWarnings("unchecked")
    protected void setValue(Object element, Object value) {
      AbstractObject model = (AbstractObject) getViewer().getInput();
      java.util.List<Object> oldList = (java.util.List<Object>) model
          .getValue(parameterName);
      int index = oldList.indexOf(element);
      if (index == -1 || oldList.get(index).equals(value)) {
        return;
      }
View Full Code Here

    return table;
  }

  @Override
  public void dispose() {
    AbstractObject model = getModel();
    if (model != null) {
      model.removePropertyChangeListener(this);
    }

    if (form != null) {
      form.dispose();
    }
View Full Code Here

  @Override
  public void setInput(IWorkbenchPart part, ISelection selection) {
    super.setInput(part, selection);

    // remove property listener on old model
    AbstractObject oldModel = getModel();
    if (oldModel != null) {
      oldModel.removePropertyChangeListener(this);
    }

    if (selection instanceof IStructuredSelection) {
      Object object = ((IStructuredSelection) selection)
          .getFirstElement();
      if (object instanceof EditPart) {
        Object editPartModel = ((EditPart) object).getModel();
        if (editPartModel instanceof AbstractObject) {
          AbstractObject model = (AbstractObject) editPartModel;

          if (model.getParameter(parameterName) == null) {
            tableViewer.getTable().setEnabled(false);
            buttonAdd.setEnabled(false);
            buttonRemove.setEnabled(false);
          } else {
            tableViewer.getTable().setEnabled(true);
            buttonAdd.setEnabled(true);
            buttonRemove.setEnabled(true);

            model.addPropertyChangeListener(this);
            tableViewer.setInput(model);
          }
        }
      }
    }
View Full Code Here

          }

        });

    if (dialog.open() == InputDialog.OK) {
      AbstractObject model = getModel();
      Map<Object, Object> oldMap = (Map<Object, Object>) model
          .getValue(parameterName);
      Map<Object, Object> newMap = new TreeMap<Object, Object>(oldMap);
      newMap.put(dialog.getValue(), "");

      IWorkbenchPart part = getPart();
View Full Code Here

TOP

Related Classes of net.sf.graphiti.model.AbstractObject

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.