Package org.objectstyle.wolips.eomodeler.core.model

Examples of org.objectstyle.wolips.eomodeler.core.model.EOModelVerificationFailure


  public void createEOModel(IProgressMonitor monitor) throws CoreException, IOException, EOModelException, InvocationTargetException, PropertyListParserException {
    Set<EOModelVerificationFailure> failures = new HashSet<EOModelVerificationFailure>();
    IContainer parentContainer = (IContainer) _parentResource;
    IFolder existingModelFolder = parentContainer.getFolder(new Path(_modelName + ".eomodeld"));
    if (existingModelFolder.exists()) {
      failures.add(new EOModelVerificationFailure(null, "There's already a model in " + existingModelFolder.getLocation().toOSString() + ".", true, null));
      EOModelErrorDialog errors = new EOModelErrorDialog(Display.getDefault().getActiveShell(), failures);
      errors.open();
      return;
    }

    boolean createModelGroup = false;
    EOModelGroup modelGroup = new EOModelGroup();
    try {
      IEOModelGroupFactory.Utility.loadModelGroup(_parentResource, modelGroup, failures, true, existingModelFolder.getLocation().toFile().toURL(), new NullProgressMonitor());
    } catch (Exception e) {
      failures.clear();
      failures.add(new EOModelVerificationFailure(null, "Creating empty EOModelGroup for this model because " + e.getMessage(), true, e));
      modelGroup = new EOModelGroup();
      createModelGroup = true;
      EOModelErrorDialog errors = new EOModelErrorDialog(Display.getDefault().getActiveShell(), failures);
      errors.open();
    }
View Full Code Here


    int count = 0;
    while (failuresIter.hasNext()) {
      if (++count > 100) {
        break;
      }
      EOModelVerificationFailure failure = failuresIter.next();
      Label iconLabel = new Label(failuresComposite, SWT.NONE);
      iconLabel.setBackground(failuresComposite.getBackground());
      if (failure.isWarning()) {
        iconLabel.setImage(composite.getDisplay().getSystemImage(SWT.ICON_WARNING));
      } else {
        iconLabel.setImage(composite.getDisplay().getSystemImage(SWT.ICON_ERROR));
      }
      GridData iconLabelData = new GridData();
      iconLabelData.verticalIndent = 3;
      iconLabelData.verticalAlignment = SWT.BEGINNING;
      iconLabelData.horizontalIndent = 3;
      iconLabel.setLayoutData(iconLabelData);

      Composite groupFailureComposite = new Composite(failuresComposite, SWT.NONE);
      groupFailureComposite.setBackground(failuresComposite.getBackground());
      groupFailureComposite.setLayout(new GridLayout(1, true));
      GridData groupFailureLabelData = new GridData(GridData.FILL_HORIZONTAL);
      //groupFailureLabelData.verticalIndent = 3;
      // failureLabelData.verticalAlignment = SWT.BEGINNING;
      groupFailureLabelData.horizontalIndent = 3;
      groupFailureComposite.setLayoutData(groupFailureLabelData);
     
      Label failedObjectLabel = new Label(groupFailureComposite, SWT.NONE);
      failedObjectLabel.setBackground(failuresComposite.getBackground());
      EOModelObject failedObject = failure.getFailedObject();
      if (failedObject != null) {
        failedObjectLabel.setText(failedObject.getFullyQualifiedName());
      }
      else {
        failedObjectLabel.setText("General Failure");
      }
      failedObjectLabel.setFont(JFaceResources.getFontRegistry().getBold(JFaceResources.DIALOG_FONT));
      failedObjectLabel.setForeground(failuresComposite.getDisplay().getSystemColor(SWT.COLOR_DARK_GRAY));
      failedObjectLabel.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
     
      StyledText failureLabel = new StyledText(groupFailureComposite, SWT.WRAP);
      failureLabel.setEditable(false);
      failureLabel.setWordWrap(true);
      failureLabel.setEnabled(false);
      String failureMessage = failure.getMessage();
      failureLabel.setText(failureMessage);
      GridData failureLabelData = new GridData(GridData.FILL_HORIZONTAL);
      //failureLabelData.verticalIndent = 3;
      // failureLabelData.verticalAlignment = SWT.BEGINNING;
      //failureLabelData.horizontalIndent = 3;
      failureLabel.setLayoutData(failureLabelData);

      if (_editor != null && failure.getFailedObject() != null) {
        Button showButton = new Button(failuresComposite, SWT.PUSH);
        showButton.setText("Show");
        GridData showButtonData = new GridData();
        showButtonData.verticalAlignment = SWT.CENTER;
        showButtonData.horizontalIndent = 3;
        showButton.setLayoutData(showButtonData);
        showButton.setData(failure);
        showButton.addSelectionListener(new SelectionListener() {
          public void widgetDefaultSelected(SelectionEvent e) {
            widgetSelected(e);
          }
 
          public void widgetSelected(SelectionEvent e) {
            EOModelVerificationFailure selectedFailure = (EOModelVerificationFailure) ((Widget) e.getSource()).getData();
            if (selectedFailure != null && _editor != null && selectedFailure.getFailedObject() != null) {
              _editor.getContentOutlinePage().showModelGroup();
              _editor.setSelection(new StructuredSelection(selectedFailure.getFailedObject()));
              EOModelErrorDialog.this.close();
            }
          }
        });
      }
View Full Code Here

    public Image getImage(Object element) {
      return null;
    }

    public String getText(Object element) {
      EOModelVerificationFailure failure = (EOModelVerificationFailure) element;
      return failure.getMessage();
    }
View Full Code Here

  protected void addModelsFromProject(EOModelGroup modelGroup, IProject project, Set<Object> searchedResources, Set<IProject> searchedProjects, Set<EOModelVerificationFailure> failures, boolean skipOnDuplicates, IProgressMonitor progressMonitor, int depth) throws IOException, EOModelException, CoreException {
    if (!searchedProjects.contains(project)) {
      progressMonitor.setTaskName("Adding models from " + project.getName() + " ...");
      searchedProjects.add(project);
      if (!project.exists()) {
        failures.add(new EOModelVerificationFailure(null, "The dependent project '" + project.getName() + "' does not exist.", false));
      } else if (!project.isOpen()) {
        failures.add(new EOModelVerificationFailure(null, "The dependent project '" + project.getName() + "' exists but is not open.", false));
      } else {
        boolean visitedProject = false;
        boolean isJavaProject = project.getNature(JavaCore.NATURE_ID) != null;
        IClasspathEntry[] classpathEntries = null;
        if (isJavaProject) {
View Full Code Here

        Set<EOModelVerificationFailure> failures = new HashSet<EOModelVerificationFailure>();
        //IContainer parentContainer = (IContainer) _parentResource;
        File modelFolder = new File(modelContainerPath, modelName + ".eomodeld");
        if (modelFolder.exists()) {
          failures.add(new EOModelVerificationFailure(null, "There's already a model in " + modelFolder + ".", true, null));
          EOModelErrorDialog errors = new EOModelErrorDialog(Display.getDefault().getActiveShell(), failures);
          errors.open();
          return;
        }

        EOModelGroup modelGroup = new EOModelGroup();
        try {
          IEOModelGroupFactory.Utility.loadModelGroup(modelFolder, modelGroup, failures, true, modelFolder.toURI().toURL(), new NullProgressMonitor());
        }
        catch (Exception e) {
          failures.clear();
          failures.add(new EOModelVerificationFailure(null, "Creating empty EOModelGroup for this model because " + e.getMessage(), true, e));
          modelGroup = new EOModelGroup();
          EOModelErrorDialog errors = new EOModelErrorDialog(Display.getDefault().getActiveShell(), failures);
          errors.open();
        }
View Full Code Here

            }
          });
        }
      }
    } catch (Throwable e) {
      myLoadFailures.add(new EOModelVerificationFailure(null, "Failed to load model.", false, e));
      handleModelErrors(myLoadFailures, true, null);
      e.printStackTrace();
      // throw new PartInitException("Failed to create EOModelEditorInput
      // for " + getEditorInput() + ".", e);
    }
View Full Code Here

          if (model == myModel || saveAllModels) {
            monitor.beginTask("Checking " + model.getName() + " ...", IProgressMonitor.UNKNOWN);
            try {
              model.verify(failures);
              if (!model.canSave()) {
                failures.add(new EOModelVerificationFailure(model, "You modified the model '" + model.getName() + "', but you are not able to save it to '" + model.getIndexURL() + "'.", false));
              }
            } finally {
              monitor.done();
            }
          }
View Full Code Here

    }

    if (!Activator.getDefault().getPreferenceStore().getBoolean(PreferenceConstants.SHOW_RELATIONSHIP_ATTRIBUTE_OPTIONALITY_MISMATCH)) {
      Iterator<EOModelVerificationFailure> failuresIter = failures.iterator();
      while (failuresIter.hasNext()) {
        EOModelVerificationFailure failure = failuresIter.next();
        if (failure instanceof EORelationshipOptionalityMismatchFailure) {
          failuresIter.remove();
        }
      }
    }

    boolean warnings = false;
    boolean errors = false;
    for (EOModelVerificationFailure failure : failures) {
      if (failure.isWarning()) {
        warnings = true;
      } else {
        errors = true;
      }
    }
View Full Code Here

TOP

Related Classes of org.objectstyle.wolips.eomodeler.core.model.EOModelVerificationFailure

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.