@Override
  protected void bindAttribute(
      Composite parent, EObject object, EAttribute attribute, String label) {
    if ("independent".equals(attribute.getName())) {
      independentEditor = new BooleanObjectEditor(this, object, attribute);
      independentCheckbox = (Button) independentEditor.createControl(parent, label);
      if (waitForCompletionCheckbox != null && waitForCompletionCheckbox.getSelection() == false) {
        independentCheckbox.setEnabled(false);
      }
    } else if ("waitForCompletion".equals(attribute.getName())) {
      ObjectEditor editor = new BooleanObjectEditor(this, object, attribute);
      waitForCompletionCheckbox = (Button) editor.createControl(parent, label);
      waitForCompletionCheckbox.addSelectionListener(
          new SelectionListener() {

            @Override
            public void widgetSelected(SelectionEvent e) {
              boolean checked = waitForCompletionCheckbox.getSelection();
              if (!checked) {
                independentCheckbox.setEnabled(false);
                independentEditor.setValue(Boolean.TRUE);
              } else {
                independentCheckbox.setEnabled(true);
              }
            }

            @Override
            public void widgetDefaultSelected(SelectionEvent e) {}
          });
      if (waitForCompletionCheckbox.getSelection() == false) {
        if (independentCheckbox != null) independentCheckbox.setEnabled(false);
      }
    } else super.bindAttribute(parent, object, attribute, label);
  }
  /**
   * Create an OCL condition from the given {@link Object} of type {@link EAttribute}.<br>
   * Subclasses may use information from the <code>eAttribute</code> to refine the condition.
   *
   * <p>Example:<br>
   * A String attribute called <code>foo</code> containing the value <code>"bar"</code> results in
   * the condition <code>self.foo = 'bar'</code> .
   *
   * @param eAttribute The type of the object.
   * @param obj The object for which the condition should be created.
   * @return An ocl condition which describes this object.
   */
  protected String eAttributeToCondition(EAttribute eAttribute, Object obj) {
    final String prefix = ""; // "self.";
    if (obj instanceof List<?>) {
      // recursive call for lists :-)
      return prefix
          + eAttribute.getName()
          + "->asSequence() = "
          + listAttributeToString((List<?>) obj);

    } else if (obj instanceof Enum) {
      final Class<?> declaringClass = ((Enum<?>) obj).getDeclaringClass();
      /*
       *  the quotes " are required to escape keywords, e.g. VisibilityKind::"package".
       *  if the quotes are missing, then the visibility 'package' collides with the ocl keyword 'package'.
       */
      return prefix
          + eAttribute.getName()
          + " = "
          + declaringClass.getSimpleName()
          + "::\""
          + ((Enum<?>) obj).toString()
          + "\"";

    } else if (obj == null) {
      // FIXME: unfortunately, the OCL implementation does not work with
      // OclVoid as null! workaround: create set and check if it is empty :o)
      return prefix + eAttribute.getName() + "->asSet()->isEmpty()";

    } else {
      // handle primitive types
      return prefix + eAttribute.getName() + " = " + primitiveAttributeToString(obj);
    }
  }
  @Override
  protected Object doExecute() throws Exception {
    final Map<String, SysConfig> sysConfigMap = appCtx.getBean("sysConfigMap", Map.class);
    if (sysConfigMap.isEmpty()) {
      System.err.println("No tenant SysConfigs found");
      return null;
    }
    System.out.print(ansi().render("@|negative_on %3s|%-15s|@", "№", "Tenant ID"));
    final SysConfig first = sysConfigMap.values().iterator().next();
    final List<EAttribute> attrs = new ArrayList<>();
    for (EAttribute attr : first.eClass().getEAttributes()) {
      attrs.add(attr);
      System.out.print(ansi().render("@|negative_on |%-25s|@", attr.getName()));
    }
    System.out.println();

    int i = 0;
    for (final Entry<String, SysConfig> entry : sysConfigMap.entrySet()) {
      SysConfig sysConfig = entry.getValue();
      System.out.print(ansi().render("@|bold,black %3d||@%-15s", ++i, entry.getKey()));
      for (EAttribute attr : attrs) {
        System.out.print(ansi().render("@|bold,black ||@%-25s", sysConfig.eGet(attr)));
      }
      System.out.println();
    }
    System.out.println(ansi().render("@|bold %d|@ tenant SysConfigs", i));
    return null;
  }
예제 #4
0
  @Override
  public Object caseEAttribute(EAttribute object) {
    Attribute attrib = new Attribute(object.getName());

    attrib.type = getType(object.getEType());
    attrib.setBounds(object.getLowerBound(), object.getUpperBound());
    attrib.setStatic(false);
    attrib.setScope(Scope.PUBLIC);
    return attrib;
  }
 protected void handleNotificationEvent(Notification event) {
   Object feature = event.getFeature();
   if (feature instanceof EAttribute) {
     EAttribute attr = (EAttribute) feature;
     if ("name".equals(attr.getName())) {
       ((DisplayOutTypeFigure) this.getConnectionFigure()).refresh();
     }
   }
   super.handleNotificationEvent(event);
 }
예제 #6
0
  private static void checkObject(
      EObject expected,
      EObject actual,
      Set<EStructuralFeature> excludeFeatures,
      Set<EObject> visited) {
    if (expected == null) {
      assertThat(actual, is(nullValue()));
      return;
    }

    if (visited.contains(expected)) return;

    visited.add(expected);

    assertThat(
        "Actual instance for type '" + expected.eClass().getName() + "' must not be null",
        actual,
        is(notNullValue()));

    for (EAttribute attribute : expected.eClass().getEAllAttributes()) {
      if (!excludeFeatures.contains(attribute))
        assertThat(
            "Attribute '"
                + attribute.getName()
                + "' on class '"
                + expected.eClass().getName()
                + "' did not match",
            actual.eGet(attribute),
            is(expected.eGet(attribute)));
    }

    for (EReference reference : expected.eClass().getEAllReferences()) {
      if (excludeFeatures.contains(reference)) continue;

      if (reference.isMany()) {
        @SuppressWarnings("unchecked")
        EList<EObject> expectedObjects = (EList<EObject>) expected.eGet(reference);
        @SuppressWarnings("unchecked")
        EList<EObject> actualObjects = (EList<EObject>) actual.eGet(reference);
        assertThat(
            "Reference size for '" + reference.getName() + "' does not match",
            actualObjects.size(),
            is(expectedObjects.size()));

        for (int i = 0; i < expectedObjects.size(); i++)
          checkObject(expectedObjects.get(i), actualObjects.get(i), excludeFeatures, visited);
      } else
        checkObject(
            (EObject) expected.eGet(reference),
            (EObject) actual.eGet(reference),
            excludeFeatures,
            visited);
    }
  }
 public Object[] getDefaultValues(org.eclipse.emf.ecore.EAttribute attribute) {
   String typeName = attribute.getEType().getName();
   if ("EString".equals(typeName)) {
     return new Object[] {
       "some" + ASPMM.resource.ASPMM.util.ASPMMStringUtil.capitalize(attribute.getName())
     };
   }
   if ("EBoolean".equals(typeName)) {
     return new Object[] {Boolean.TRUE, Boolean.FALSE};
   }
   return new Object[] {attribute.getDefaultValue()};
 }
  /**
   * Returns true if we can set the given attribute with a "name" feature of an
   * instanciationInstruction.
   *
   * @param attribute the attribute to inspect
   * @return true if the given attribute is of type EString and is named 'name' or is an ID
   *     attribute
   */
  private static boolean isConcernedByNameAttribute(EAttribute attribute) {

    // Case 1 : true if the attribute is defined as ID and is of type EString
    boolean isConcernedByNameAttribute =
        attribute.isID() && ("EString".equals(attribute.getEAttributeType().getName()));

    // Case 2 : true if the attribute's name is "name" and is of type EString
    isConcernedByNameAttribute =
        isConcernedByNameAttribute
            || ("name".equals(attribute.getName())
                && ("EString".equals(attribute.getEAttributeType().getName())));
    return isConcernedByNameAttribute;
  }
 /**
  * {@inheritDoc}
  *
  * @see org.eclipse.emf.compare.diff.merge.api.AbstractMerger#applyInOrigin()
  */
 @Override
 public void applyInOrigin() {
   final AttributeChangeLeftTarget theDiff = (AttributeChangeLeftTarget) this.diff;
   final EObject origin = theDiff.getLeftElement();
   final Object value = theDiff.getLeftTarget();
   final EAttribute attr = theDiff.getAttribute();
   try {
     EFactory.eRemove(origin, attr.getName(), value);
   } catch (FactoryException e) {
     EMFComparePlugin.log(e, true);
   }
   super.applyInOrigin();
 }
예제 #10
0
  private static JsonNode findNode(URI nodeURI, EClass eClass, JsonNode root) {
    EAttribute eID = eClass.getEIDAttribute();
    if (eID == null) {
      final EStructuralFeature featureName = eClass.getEStructuralFeature("name");
      if (featureName != null && featureName instanceof EAttribute) {
        eID = (EAttribute) featureName;
      } else {
        return null;
      }
    }

    String fragment =
        nodeURI.fragment().startsWith("//") ? nodeURI.fragment().substring(2) : nodeURI.fragment();

    for (JsonNode node : root.findParents(eID.getName())) {
      String value = node.get(eID.getName()).getTextValue();
      if (value.equals(fragment)) {
        return node;
      }
    }
    return null;
  }
예제 #11
0
 public static void printAttributeValues(EObject object) {
   EClass eClass = object.eClass();
   System.out.println(eClass.getName());
   for (Iterator iter = eClass.getEAllAttributes().iterator(); iter.hasNext(); ) {
     EAttribute attribute = (EAttribute) iter.next();
     Object value = object.eGet(attribute);
     System.out.print("  " + attribute.getName() + ": " + value);
     if (object.eIsSet(attribute)) {
       System.out.println(); // attribute is set
     } else {
       System.out.println(" (default)"); // attribute is not set
     }
   }
 } // printAttributeValues
 public Object[] getDefaultValues(EAttribute attribute) {
   String typeName = attribute.getEType().getName();
   if ("EString".equals(typeName)) {
     return new Object[] {
       "some"
           + org.dresdenocl.language.ocl.resource.ocl.util.OclStringUtil.capitalize(
               attribute.getName())
     };
   }
   if ("EBoolean".equals(typeName)) {
     return new Object[] {Boolean.TRUE, Boolean.FALSE};
   }
   return new Object[] {attribute.getDefaultValue()};
 }
 public java.lang.Object[] getDefaultValues(org.eclipse.emf.ecore.EAttribute attribute) {
   String typeName = attribute.getEType().getName();
   if ("EString".equals(typeName)) {
     return new java.lang.Object[] {
       "some"
           + west.twouse.language.sparqlas.resource.sparqlas.util.SparqlasStringUtil.capitalize(
               attribute.getName())
     };
   }
   if ("EBoolean".equals(typeName)) {
     return new java.lang.Object[] {Boolean.TRUE, Boolean.FALSE};
   }
   return new java.lang.Object[] {attribute.getDefaultValue()};
 }
 public boolean isIsUnsetMethodFor(Method method, EAttribute attribute) {
   if (method.getParameterTypes().length != 0) {
     return false;
   }
   Class returnType = method.getReturnType();
   if (!returnType.equals(boolean.class)) {
     return false;
   }
   String attributeName = attribute.getName();
   String isUnsetMethodName = "isUnset" + new MethodNameHelper().titleCase(attributeName);
   if (!method.getName().equals(isUnsetMethodName)) {
     return false;
   }
   return true;
 }
 @Override
 public T execute()
     throws UserException, BimserverLockConflictException, BimserverDatabaseException {
   T result = super.execute();
   if (result == null) {
     throw new UserException(
         "No "
             + getClazz().getSimpleName()
             + " found where "
             + eAttribute.getName()
             + " = "
             + value);
   }
   return result;
 }
 public void testErrorMessage_04() {
   EClass eClass = createEClass();
   eClass.setName("EClassName");
   EAttribute attribute = EcoreFactory.eINSTANCE.createEAttribute();
   attribute.setName("Attribute");
   eClass.getEStructuralFeatures().add(attribute);
   IEObjectDescription description =
       EObjectDescription.create(QualifiedName.create(attribute.getName()), attribute);
   String errorMessage =
       helper.getDuplicateNameErrorMessage(
           description,
           EcorePackage.Literals.EATTRIBUTE,
           EcorePackage.Literals.ENAMED_ELEMENT__NAME);
   assertEquals("Duplicate EAttribute 'Attribute' in EClass 'EClassName'", errorMessage);
 }
예제 #17
0
 public static String getName(EObject obj) {
   if (obj == null) return null;
   if (obj instanceof ENamedElement) return ((ENamedElement) obj).getName();
   List allAtts = obj.eClass().getEAllAttributes();
   int size = allAtts.size();
   EAttribute att, nameAttribute = null;
   for (int i = 0; i < size; i++) {
     att = (EAttribute) allAtts.get(i);
     if (NAME_ATTRIBUTE_STRING.equals(att.getName())) {
       nameAttribute = att;
       break;
     }
   }
   if (nameAttribute != null) return (String) obj.eGet(nameAttribute);
   return null;
 }
  private void setEnabledAll(boolean enabled) {
    for (EClass e : elementSet) {
      prefs.putBoolean(e.getName(), enabled);

      for (EAttribute a : e.getEAllAttributes()) {
        prefs.putBoolean(e.getName() + "." + a.getName(), enabled);
      }

      for (EReference a : e.getEAllContainments()) {
        prefs.putBoolean(e.getName() + "." + a.getName(), enabled);
      }

      for (EReference a : e.getEAllReferences()) {
        prefs.putBoolean(e.getName() + "." + a.getName(), enabled);
      }
    }
  }
 protected EStructuralFeature getLabelFeature(EClass eClass) {
   EAttribute result = null;
   for (EAttribute eAttribute : eClass.getEAllAttributes()) {
     if (!eAttribute.isMany()
         && eAttribute.getEType().getInstanceClass() != FeatureMap.Entry.class) {
       if ("name".equalsIgnoreCase(eAttribute.getName())) {
         result = eAttribute;
         break;
       } else if (result == null) {
         result = eAttribute;
       } else if (eAttribute.getEAttributeType().getInstanceClass() == String.class
           && result.getEAttributeType().getInstanceClass() != String.class) {
         result = eAttribute;
       }
     }
   }
   return result;
 }
예제 #20
0
 public CharSequence idAssignment(final EClass it) {
   CharSequence _xblockexpression = null;
   {
     final EAttribute idAttr = Ecore2XtextExtensions.idAttribute(it);
     CharSequence _xifexpression = null;
     boolean _notEquals = (!Objects.equal(idAttr, null));
     if (_notEquals) {
       StringConcatenation _builder = new StringConcatenation();
       String _name = idAttr.getName();
       _builder.append(_name, "");
       _builder.append("=");
       String _assignedRuleCall = Ecore2XtextExtensions.assignedRuleCall(idAttr);
       _builder.append(_assignedRuleCall, "");
       _xifexpression = _builder;
     }
     _xblockexpression = (_xifexpression);
   }
   return _xblockexpression;
 }
예제 #21
0
  CommonDatePropsEditor(EAttribute attribute, Composite parent, int style) {

    super(parent, style);
    setLayout(new GridLayout(3, false));

    this.calendarValue = Calendar.getInstance();

    Label lblName = new Label(this, SWT.NONE);
    lblName.setLayoutData(new GridData(SWT.CENTER, SWT.CENTER, false, false, 1, 1));
    lblName.setText(attribute.getName());

    final Composite calendarAndTimeComposite = new Composite(this, SWT.NONE);
    calendarAndTimeComposite.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false, 1, 1));
    calendarAndTimeComposite.setLayout(new FillLayout(SWT.HORIZONTAL));

    this.initDateCalendar(calendarAndTimeComposite);

    this.initDateTime(calendarAndTimeComposite);

    this.initComboTimezones(parent);
  }
예제 #22
0
 public String getClassAttributes(EClass eClass) {
   // if attributes exist
   if (eClass.getEAttributes().size() > 0) {
     StringBuilder sb = new StringBuilder();
     sb.append("\\subsubsection*{Attributes}\n");
     sb.append("\\begin{itemize}\n");
     // for each attribute
     for (EAttribute eAttribute : eClass.getEAttributes()) {
       sb.append("\\item ");
       // Name
       sb.append(eAttribute.getName()).append(": ");
       // Type
       if (eAttribute.getEAttributeType().getInstanceClass() != null) {
         sb.append(eAttribute.getEAttributeType().getInstanceClass().getSimpleName()).append(" ");
       } else {
         sb.append("\\nameref{").append(eAttribute.getEAttributeType().getName()).append("} ");
       }
       // Mult
       sb.append(getMultiplicity(eAttribute)).append(" ");
       // Default Value
       if (eAttribute.getDefaultValue() != null) {
         sb.append(" \\textit{~=~").append(eAttribute.getDefaultValue()).append("} ");
       }
       // Description
       if (getLatexDocAnnotation(
               eAttribute, prefs.getPreferenceString(PreferenceConstants.P_DESCRIPTION_KEY))
           != null) {
         sb.append("\\newline\n")
             .append(
                 getLatexDocAnnotation(
                     eAttribute,
                     prefs.getPreferenceString(PreferenceConstants.P_DESCRIPTION_KEY)));
       }
       sb.append("\n");
     } // for each attribute
     sb.append("\\end{itemize}");
     return sb.toString();
   }
   return "\\subsubsection*{Attributes} ~\\\\ No additional attributes";
 }
 public String getHoverText(org.eclipse.emf.ecore.EObject object) {
   if (object == null) {
     return null;
   }
   org.eclipse.emf.ecore.EClass eClass = object.eClass();
   String label = "<strong>" + eClass.getName() + "</strong>";
   String documentation = org.eclipse.emf.ecore.util.EcoreUtil.getDocumentation(eClass);
   String documentationHTML = documentation == null ? "" : " (" + documentation + ")";
   label += documentationHTML;
   for (org.eclipse.emf.ecore.EAttribute attribute : eClass.getEAllAttributes()) {
     Object value = null;
     try {
       value = object.eGet(attribute);
     } catch (Exception e) {
       // Exception in eGet, do nothing
     }
     if (value != null && value.toString() != null && !value.toString().equals("[]")) {
       label += "<br />" + attribute.getName() + ": " + object.eGet(attribute).toString();
     }
   }
   return label;
 }
 /**
  * {@inheritDoc}
  *
  * @see org.eclipse.emf.compare.diff.merge.api.AbstractMerger#undoInTarget()
  */
 @Override
 public void undoInTarget() {
   final AttributeChangeLeftTarget theDiff = (AttributeChangeLeftTarget) this.diff;
   final EObject target = theDiff.getRightElement();
   final Object value = theDiff.getLeftTarget();
   final EAttribute attr = theDiff.getAttribute();
   try {
     int valueIndex = -1;
     if (attr.isMany()) {
       final EObject leftElement = theDiff.getLeftElement();
       final Object leftValues = leftElement.eGet(attr);
       if (leftValues instanceof List) {
         final List leftValuesList = (List) leftValues;
         valueIndex = leftValuesList.indexOf(value);
       }
     }
     EFactory.eAdd(target, attr.getName(), value, valueIndex);
   } catch (FactoryException e) {
     EMFComparePlugin.log(e, true);
   }
   super.undoInTarget();
 }
  public static String getEObjectLabel(EObject eObject) {
    String name = null;
    String label = null;
    String id = null;

    for (EAttribute attribute : eObject.eClass().getEAllAttributes()) {
      if (attribute.getName().equalsIgnoreCase("name")) {
        name = (String) eObject.eGet(attribute);
        break;
      }
    }

    for (EOperation operation : eObject.eClass().getEAllOperations()) {
      try {
        if (operation.getName().equals("getName") && name == null)
          name = (String) eObject.eInvoke(operation, null);
        if (operation.getName().equals("getLabel") && label == null)
          label = (String) eObject.eInvoke(operation, null);
        if (operation.getName().equals("getID") && id == null)
          id = (String) eObject.eInvoke(operation, null);
        if (operation.getName().equals("getId") && id == null)
          id = (String) eObject.eInvoke(operation, null);
      } catch (Exception e) {
      }
    }

    if (name != null && !name.isEmpty()) return name;
    if (label != null && !label.isEmpty()) return label;
    if (id != null && !id.isEmpty()) return id;

    if (eObject instanceof ENamedElement)
      if (((ENamedElement) eObject).getName() != null
          && !((ENamedElement) eObject).getName().equals(""))
        return ((ENamedElement) eObject).getName();
      else return eObject.toString();
    else return eObject.toString();
  }
  /** Open. */
  public void open() {
    try {
      attribute2Value = new HashMap<EAttribute, String>();
      Shell parent = getParent();
      dialogShell = new Shell(parent, SWT.DIALOG_TRIM | SWT.APPLICATION_MODAL);

      dialogShell.setLayout(new FormLayout());
      {
        button2 = new Button(dialogShell, SWT.PUSH | SWT.CENTER);
        FormData button2LData = new FormData();
        button2LData.left = new FormAttachment(0, 1000, 330);
        button2LData.top = new FormAttachment(0, 1000, 310);
        button2LData.width = 99;
        button2LData.height = 25;
        button2.setLayoutData(button2LData);
        button2.setText("Cancel");
        button2.addListener(
            SWT.Selection,
            new Listener() {

              @Override
              public void handleEvent(Event event) {
                cancel = true;
                dialogShell.close();
              }
            });
      }

      {
        button1 = new Button(dialogShell, SWT.PUSH | SWT.CENTER);
        FormData button1LData = new FormData();
        button1LData.left = new FormAttachment(0, 1000, 229);
        button1LData.top = new FormAttachment(0, 1000, 310);
        button1LData.width = 95;
        button1LData.height = 25;
        button1.setLayoutData(button1LData);
        button1.setText("Ok");
        button1.setEnabled(true);
        button1.addListener(
            SWT.Selection,
            new Listener() {

              @Override
              public void handleEvent(Event event) {
                cancel = false;
                for (int i = 0, n = table1.getItemCount(); i < n; i++) {
                  TableItem item = table1.getItem(i);
                  if (item.getChecked()) {
                    EAttribute attribut = attributeTypen.get(i);
                    attribute2Value.put(attribut, item.getText(2));
                  }
                }
                dialogShell.close();
              }
            });
      }
      {
        FormData table1LData = new FormData();
        table1LData.left = new FormAttachment(0, 1000, 12);
        table1LData.top = new FormAttachment(0, 1000, 12);
        table1LData.width = 400;
        table1LData.height = 269;
        table1 =
            new Table(
                dialogShell,
                SWT.CHECK
                    | SWT.SINGLE
                    | SWT.FULL_SELECTION
                    | SWT.V_SCROLL
                    | SWT.H_SCROLL
                    | SWT.VIRTUAL);
        table1.setLayoutData(table1LData);
        table1.setHeaderVisible(true);
        table1.setLinesVisible(true);
        {
          tableColumn1 = new TableColumn(table1, SWT.CENTER);
          tableColumn1.setText("Create");
          tableColumn1.setWidth(60);
        }
        {
          tableColumn2 = new TableColumn(table1, SWT.LEFT);
          tableColumn2.setText("Attribute");
          tableColumn2.setWidth(200);
        }
        {
          tableColumn3 = new TableColumn(table1, SWT.LEFT);
          tableColumn3.setText("Value");
          tableColumn3.setWidth(140);
        }

        vavueCorect = new HashMap<TypeEditorValidator, Boolean>();
        typeEditorValidators = new ArrayList<TypeEditorValidator>();

        for (EAttribute attr : attributeTypen) {
          TableItem tableItem = new TableItem(table1, SWT.NONE);
          TypeEditorValidator typeEditorValidator = new TypeEditorValidator(node, attr);

          tableItem.setText(1, attr.getName());
          tableItem.setText(2, typeEditorValidator.getDefaultValue());
          table1.addListener(
              SWT.Selection,
              new Listener() {

                @Override
                public void handleEvent(Event event) {
                  if (event.detail == SWT.CHECK) {
                    TableItem tItem = (TableItem) event.item;
                    corectValueTest(tItem, tItem.getText(2));
                    refreshOkButton();
                  }
                }
              });
          typeEditorValidators.add(typeEditorValidator);
          /*
           * if (typeEditorValidator.isValid(typeEditorValidator
           * .getDefaultValue()) == null) {
           * vavueCorect.put(typeEditorValidator, corect); } else {
           * vavueCorect.put(typeEditorValidator, incorect);
           * button1.setEnabled(false); }
           */
        }
        final TableEditor editor = new TableEditor(table1);
        editor.horizontalAlignment = SWT.LEFT;
        editor.grabHorizontal = true;

        table1.addMouseListener(
            new MouseAdapter() {
              @Override
              public void mouseDown(MouseEvent event) {
                // Dispose any existing editor
                Control old = editor.getEditor();
                if (old != null) old.dispose();

                // Determine where the mouse was clicked
                Point pt = new Point(event.x, event.y);

                // Determine which row was selected
                final TableItem item = table1.getItem(pt);
                if (item != null) {
                  // Determine which column was selected
                  int column = -1;
                  for (int i = 0, n = table1.getColumnCount(); i < n; i++) {
                    Rectangle rect = item.getBounds(i);
                    if (rect.contains(pt)) {
                      // This is the selected column
                      column = i;
                      break;
                    }
                  }
                  // Column 2 holds dropdowns
                  if (column == 2) {
                    // Create the Text object for our editor
                    final Text text = new Text(table1, SWT.NONE);
                    text.setForeground(item.getForeground());

                    // Transfer any text from the cell to the Text
                    // control,
                    // set the color to match this row, select the
                    // text,
                    // and set focus to the control
                    text.setText(item.getText(column));
                    text.setForeground(item.getForeground());
                    text.selectAll();
                    text.setFocus();

                    // Recalculate the minimum width for the editor
                    editor.minimumWidth = text.getBounds().width;

                    // Set the control into the editor
                    editor.setEditor(text, item, column);

                    // Add a handler to transfer the text back to
                    // the cell
                    // any time it's modified
                    final int col = column;
                    text.addModifyListener(
                        new ModifyListener() {

                          @Override
                          public void modifyText(ModifyEvent e) {
                            item.setChecked(true);
                            corectValueTest(item, text.getText());
                            item.setText(col, text.getText());
                          }
                        });
                  }
                }
              }
            });
      }
      dialogShell.layout();
      dialogShell.setSize(450, 380);
      Rectangle shellBounds = getParent().getBounds();
      Point dialogSize = dialogShell.getSize();
      dialogShell.setLocation(
          shellBounds.x + (shellBounds.width - dialogSize.x) / 2,
          shellBounds.y + (shellBounds.height - dialogSize.y) / 2);
      dialogShell.open();
      Display display = dialogShell.getDisplay();
      while (!dialogShell.isDisposed()) {
        if (!display.readAndDispatch()) display.sleep();
      }
    } catch (Exception e) {
      e.printStackTrace();
    }
  }