public static boolean enableDelete(IStructuredSelection graphicalSelection) {

    boolean enableDel = false;
    List<Object> elements = new ArrayList<Object>();
    IStructuredSelection selection = Selection.getInstance().getStructuredSelection();

    if (!selection.isEmpty()) {
      if (graphicalSelection.getFirstElement() instanceof DiagramEditPart) return false;
      enableDel = true;
      // Iterate through removing elements that are only graphical
      for (Iterator<?> iter = selection.iterator(); iter.hasNext(); ) {
        Object current = iter.next();
        if (current instanceof GraphicalElement_c) {
          GraphicalElement_c ge = (GraphicalElement_c) current;
          if (ge.getRepresents() == null) {
            elements.add(current);
            Selection.getInstance().removeFromSelection(ge);
          }
        }
      }
    }

    selection = Selection.getInstance().getStructuredSelection();
    if (!selection.isEmpty()) {
      // Check the remaining items against the usual DeleteAction,
      enableDel = DeleteAction.canDeleteAction();
    }

    // Add the graphical only elements back to the selection
    for (int i = 0; i < elements.size(); ++i) {
      Selection.getInstance().addToSelection(elements.get(i));
    }

    return enableDel;
  }
  private void performDiagramTest(
      final NonRootModelElement element, int expectedGraphicalElementCount) {
    Model_c model =
        Model_c.ModelInstance(
            Ooaofgraphics.getInstance(element.getModelRoot().getId()),
            new ClassQueryInterface_c() {

              @Override
              public boolean evaluate(Object candidate) {
                return ((Model_c) candidate).getOoa_id().equals(element.Get_ooa_id());
              }
            });
    assertNotNull(
        "Could not locate diagram for element : " + element.getClass().getSimpleName(), model);
    // if the element is a package assert the Ooa type for the model
    if (element instanceof Package_c) {
      assertTrue(
          "Found a diagram representing a package with an improper ooa type.",
          model.getOoa_type() == Ooatype_c.Package);
    }
    GraphicalElement_c[] elements = GraphicalElement_c.getManyGD_GEsOnR1(model);
    assertEquals(
        "Did not find the expected graphical element count for : "
            + element.getClass().getSimpleName(),
        expectedGraphicalElementCount,
        elements.length);
    for (GraphicalElement_c ge : elements) {
      // if the represents value is a package assert the proper ooa type
      if (ge.getRepresents() instanceof Package_c) {
        assertTrue(
            "Found a graphical element representing a package with an improper ooa type.",
            ge.getOoa_type() == Ooatype_c.Package);
      }
    }
  }