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);
  }
 // parameter isFileMandatory is used to determine if at least one file must be selected
 // before being able to proceed to the next page
 public SelectMultiFilePage(
     IWorkbench workbench, IStructuredSelection selection, boolean isFileMandatory) {
   super("SelectMultiFilePage");
   this.workbench = workbench;
   this.selection = selection;
   this.isFileMandatory = isFileMandatory;
   this.workspaceRoot = ResourcesPlugin.getWorkspace().getRoot();
   this.fileNames = null;
 }
 public void setVisible(boolean visible) {
   if (visible == true) {
     if (fFilters != null) {
       sourceFileViewer.resetFilters();
       for (Iterator i = fFilters.iterator(); i.hasNext(); )
         sourceFileViewer.addFilter((ViewerFilter) i.next());
     }
     sourceFileViewer.setInput(ResourcesPlugin.getWorkspace().getRoot());
   }
   super.setVisible(visible);
 }
Ejemplo n.º 4
0
 /**
  * Uses the standard container selection dialog to choose the new value for the container field.
  */
 private void handleBrowse() {
   ContainerSelectionDialog dialog =
       new ContainerSelectionDialog(
           getShell(),
           ResourcesPlugin.getWorkspace().getRoot(),
           false,
           "Select a project as a container");
   if (dialog.open() == Window.OK) {
     Object[] result = dialog.getResult();
     if (result.length == 1) {
       containerText.setText(((Path) result[0]).toString());
     }
   }
 }