예제 #1
0
  /**
   * The framework calls this to create the contents of the wizard.
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   *
   * @generated
   */
  @Override
  public void addPages() {
    // Create a page, set the title, and the initial model file name.
    //
    newFileCreationPage = new ImlModelWizardNewFileCreationPage("Whatever", selection);
    newFileCreationPage.setTitle(ImlEditorPlugin.INSTANCE.getString("_UI_ImlModelWizard_label"));
    newFileCreationPage.setDescription(
        ImlEditorPlugin.INSTANCE.getString("_UI_ImlModelWizard_description"));
    newFileCreationPage.setFileName(
        ImlEditorPlugin.INSTANCE.getString("_UI_ImlEditorFilenameDefaultBase")
            + "."
            + FILE_EXTENSIONS.get(0));
    addPage(newFileCreationPage);

    // Try and get the resource selection to determine a current directory for the file dialog.
    //
    if (selection != null && !selection.isEmpty()) {
      // Get the resource...
      //
      Object selectedElement = selection.iterator().next();
      if (selectedElement instanceof IResource) {
        // Get the resource parent, if its a file.
        //
        IResource selectedResource = (IResource) selectedElement;
        if (selectedResource.getType() == IResource.FILE) {
          selectedResource = selectedResource.getParent();
        }

        // This gives us a directory...
        //
        if (selectedResource instanceof IFolder || selectedResource instanceof IProject) {
          // Set this for the container.
          //
          newFileCreationPage.setContainerFullPath(selectedResource.getFullPath());

          // Make up a unique new name here.
          //
          String defaultModelBaseFilename =
              ImlEditorPlugin.INSTANCE.getString("_UI_ImlEditorFilenameDefaultBase");
          String defaultModelFilenameExtension = FILE_EXTENSIONS.get(0);
          String modelFilename = defaultModelBaseFilename + "." + defaultModelFilenameExtension;
          for (int i = 1; ((IContainer) selectedResource).findMember(modelFilename) != null; ++i) {
            modelFilename = defaultModelBaseFilename + i + "." + defaultModelFilenameExtension;
          }
          newFileCreationPage.setFileName(modelFilename);
        }
      }
    }
    initialObjectCreationPage = new ImlModelWizardInitialObjectCreationPage("Whatever2");
    initialObjectCreationPage.setTitle(
        ImlEditorPlugin.INSTANCE.getString("_UI_ImlModelWizard_label"));
    initialObjectCreationPage.setDescription(
        ImlEditorPlugin.INSTANCE.getString("_UI_Wizard_initial_object_description"));
    addPage(initialObjectCreationPage);
  }
예제 #2
0
 /**
  * Get the file from the page.
  * <!-- begin-user-doc -->
  * <!-- end-user-doc -->
  *
  * @generated
  */
 public IFile getModelFile() {
   return newFileCreationPage.getModelFile();
 }