Ejemplo n.º 1
0
  /** Ensures that controls are correctly set. */
  private void dialogChanged() {
    IResource resource =
        ResourcesPlugin.getWorkspace().getRoot().findMember(new Path(getContainerName()));
    if (resource == null) {
      updateStatus("File container must be specified");
      return;
    }
    IContainer container = (IContainer) resource;
    String fileName = getFileName();
    String author = getAuthor();
    String titleName = getModelName();

    final IFile modelfile = container.getFile(new Path("models/" + fileName));
    final IFile htmlfile = container.getFile(new Path("doc/" + titleName + ".html"));

    if (getContainerName().length() == 0) {
      updateStatus("File container must be specified");
      return;
    }
    if ((resource.getType() & (IResource.PROJECT | IResource.FOLDER)) == 0) {
      updateStatus("File container must exist");
      return;
    }
    if (!resource.isAccessible()) {
      updateStatus("Project must be writable");
      return;
    }
    if (fileName.length() == 0) {
      updateStatus("File name must be specified");
      return;
    }
    if (fileName.replace('\\', '/').indexOf('/', 1) > 0) {
      updateStatus("File name must be valid");
      return;
    }
    if (!fileName.endsWith(".gaml")) {
      updateStatus("File extension must be \".gaml\"");
      return;
    }
    if (author.length() == 0) {
      updateStatus("Author name must be specified");
      return;
    }
    if (modelfile.exists()) {
      updateStatus("File already exists");
      return;
    }
    if (htmlfile.exists()) {
      updateStatus("Model name already defined");
      return;
    }

    if (titleName.length() == 0) {
      updateStatus("Model name must be specified");
      return;
    }
    updateStatus(null);
  }
Ejemplo n.º 2
0
 /** Tests if the current workbench selection is a suitable container to use. */
 private void initialize() {
   if (selection != null
       && selection.isEmpty() == false
       && selection instanceof IStructuredSelection) {
     IStructuredSelection ssel = (IStructuredSelection) selection;
     if (ssel.size() > 1) {
       return;
     }
     Object obj = ssel.getFirstElement();
     if (obj instanceof IResource) {
       IContainer container;
       if (obj instanceof IContainer) {
         container = (IContainer) obj;
       } else {
         container = ((IResource) obj).getParent();
       }
       containerText.setText(container.getFullPath().toString());
     }
   }
   fileText.setText("new.gaml");
 }