コード例 #1
0
  /**
   * @see org.eclipse.ui.IWorkbenchWizard#init(org.eclipse.ui.IWorkbench,
   *     org.eclipse.jface.viewers.IStructuredSelection)
   * @since 4.0
   */
  @Override
  public void init(final IWorkbench workbench, final IStructuredSelection selection) {

    IStructuredSelection finalSelection = selection;
    if (!ModelerUiViewUtils.workspaceHasOpenModelProjects()) {
      IProject newProject = ModelerUiViewUtils.queryUserToCreateModelProject();

      if (newProject != null) {
        finalSelection = new StructuredSelection(newProject);
      }
    }

    if (importLicensed) {
      importTextMainPage = new ImportTextMainPage(finalSelection);
      addPage(importTextMainPage);
      //
      for (int i = 0; i < importers.length; i++) {
        addPage((IWizardPage) importers[i]);
      }
    } else {
      // Create empty page
      WizardPage page =
          new WizardPage(ImportTextWizard.class.getSimpleName(), TITLE, null) {

            @Override
            public void createControl(final Composite parent) {
              setControl(createEmptyPageControl(parent));
            }
          };
      page.setMessage(NOT_LICENSED_MSG, IMessageProvider.ERROR);
      page.setPageComplete(false);
      addPage(page);
    }
  }
コード例 #2
0
  /**
   * @see org.eclipse.ui.IWorkbenchWizard#init(org.eclipse.ui.IWorkbench,
   *     org.eclipse.jface.viewers.IStructuredSelection)
   * @since 4.0
   */
  @Override
  public void init(final IWorkbench workbench, final IStructuredSelection originalSelection) {

    IStructuredSelection selection = originalSelection;
    openProjectExists = ModelerUiViewUtils.workspaceHasOpenModelProjects();
    if (!openProjectExists) {
      newProject = ModelerUiViewUtils.queryUserToCreateModelProject();

      if (newProject != null) {
        selection = new StructuredSelection(newProject);
        openProjectExists = true;
      } else {
        openProjectExists = false;
      }
    }

    if (isAllModelsSelected(selection)) {
      initialSelection = new StructuredSelection(selection.toArray());
    }
    if (selection != null && !selection.isEmpty()) {
      this.folder = ModelUtil.getContainer(selection.getFirstElement());
    }

    if (folder != null && !folderInModelProject()) {
      // Create empty page
      this.mainPage =
          new WizardPage(NewVdbWizard.class.getSimpleName(), PAGE_TITLE, null) {
            @Override
            public void createControl(final Composite parent) {
              setControl(createEmptyPageControl(parent));
            }
          };
      this.mainPage.setMessage(NOT_MODEL_PROJECT_MSG, IMessageProvider.ERROR);
    } else {

      // Create and add page
      this.mainPage =
          new WizardPage(NewVdbWizard.class.getSimpleName(), PAGE_TITLE, null) {
            @Override
            public void createControl(final Composite parent) {
              setControl(createPageControl(parent));
            }
          };
      this.mainPage.setMessage(INITIAL_MESSAGE);

      // If current selection not null, set folder to selection if a folder, or to containing folder
      // if not
      if (this.folder != null) {
        if (!projectValidator.validate(new Object[] {this.folder}).isOK()) {
          this.folder = null;
        }
      } else { // folder == null
        this.mainPage.setMessage(SELECT_FOLDER_MESSAGE, IMessageProvider.ERROR);
      }
    }

    this.mainPage.setPageComplete(false);
    addPage(mainPage);
  }
コード例 #3
0
  private static void createConnection(final String id, final Properties properties) {
    // Add then remove profile changed listener so new CP name can be set in properties
    IProfileListener listener = new PropertiesProfileChangedListener(properties);
    ProfileManager.getInstance().addProfileListener(listener);

    if (id.equalsIgnoreCase(CONNECTION_PROFILE_IDS.CATEGORY_JDBC)) {
      NewJDBCFilteredCPWizard wiz = new NewJDBCFilteredCPWizard();
      ModelerUiViewUtils.launchWizard(wiz, new StructuredSelection(), properties, true);
    } else {
      INewWizard wiz = new NewTeiidFilteredCPWizard(id);
      ModelerUiViewUtils.launchWizard(wiz, new StructuredSelection(), properties, true);
    }

    ProfileManager.getInstance().removeProfileListener(listener);
  }
コード例 #4
0
 private static void launchWizard(String id, Properties properties, boolean synchronous) {
   ModelerUiViewUtils.launchWizard(id, new StructuredSelection(), properties, synchronous);
 }
コード例 #5
0
  public static void executeAction(String id, Properties properties, boolean synchronous) {

    // IMPORT OPTIONS
    if (id.equalsIgnoreCase(COMMAND_IDS.IMPORT_DDL)) {
      launchWizard(ImportMetadataAction.DDL_TO_RELATIONAL, properties, synchronous);
      return;
    }
    if (id.equalsIgnoreCase(COMMAND_IDS.IMPORT_FLAT_FILE)) {
      launchWizard(ImportMetadataAction.TEIID_FLAT_FILE, properties, synchronous);
      return;
    }
    if (id.equalsIgnoreCase(COMMAND_IDS.IMPORT_JDBC)) {
      launchWizard(ImportMetadataAction.JDBC, properties, synchronous);
      return;
    }
    if (id.equalsIgnoreCase(COMMAND_IDS.IMPORT_SALESFORCE)) {
      launchWizard(ImportMetadataAction.SALESFORCE_TO_RELATIONAL, properties, synchronous);
      return;
    }
    if (id.equalsIgnoreCase(COMMAND_IDS.IMPORT_XML_FILE)) {
      properties.put(IPropertiesContext.KEY_IMPORT_XML_TYPE, IPropertiesContext.IMPORT_XML_LOCAL);
      launchWizard(ImportMetadataAction.TEIID_XML_FILE, properties, synchronous);
      return;
    }

    if (id.equalsIgnoreCase(COMMAND_IDS.IMPORT_XML_FILE_URL)) {
      properties.put(IPropertiesContext.KEY_IMPORT_XML_TYPE, IPropertiesContext.IMPORT_XML_REMOTE);
      launchWizard(ImportMetadataAction.TEIID_XML_FILE, properties, synchronous);
      return;
    }

    if (id.equalsIgnoreCase(COMMAND_IDS.IMPORT_WSDL_TO_SOURCE)) {
      launchWizard(ImportMetadataAction.WSDL_TO_RELATIONAL, properties, synchronous);
      return;
    }
    if (id.equalsIgnoreCase(COMMAND_IDS.IMPORT_WSDL_TO_WS)) {
      launchWizard(ImportMetadataAction.WSDL_TO_WEB_SERVICE, properties, synchronous);
      return;
    }

    // NEW MODEL OPTIONS
    if (id.equalsIgnoreCase(COMMAND_IDS.NEW_MODEL_RELATIONAL_SOURCE)) {
      createNewModel(ModelType.PHYSICAL_LITERAL, MODEL_CLASSES.RELATIONAL, properties);
      return;
    }

    if (id.equalsIgnoreCase(COMMAND_IDS.NEW_MODEL_RELATIONAL_VIEW)) {
      createNewModel(ModelType.VIRTUAL_LITERAL, MODEL_CLASSES.RELATIONAL, properties);
      return;
    }

    if (id.equalsIgnoreCase(COMMAND_IDS.NEW_MODEL_WS)) {
      createNewModel(ModelType.VIRTUAL_LITERAL, MODEL_CLASSES.WEB_SERVICE, properties);
      return;
    }

    if (id.equalsIgnoreCase(COMMAND_IDS.NEW_MODEL_XML_DOC)) {
      createNewModel(ModelType.VIRTUAL_LITERAL, MODEL_CLASSES.XML, properties);
      return;
    }

    // NEW OBJECT OPTIONS
    if (id.equalsIgnoreCase(COMMAND_IDS.DEFINE_VIEW_TABLE)) {
      DefineViewTableAction action = new DefineViewTableAction(properties);
      action.run();
      return;
    }

    // CONNECTIONPROFILE OPTIONS
    if (id.equalsIgnoreCase(COMMAND_IDS.CREATE_CONNECTION_JDBC)) {
      createConnection(CONNECTION_PROFILE_IDS.CATEGORY_JDBC, properties);
      return;
    }
    if (id.equalsIgnoreCase(COMMAND_IDS.CREATE_CONNECTION_FLAT_FILE)) {
      createConnection(CONNECTION_PROFILE_IDS.CATEGORY_ODA_FLAT_FILE_ID, properties);
      return;
    }
    if (id.equalsIgnoreCase(COMMAND_IDS.CREATE_CONNECTION_LDAP)) {
      createConnection(CONNECTION_PROFILE_IDS.CATEGORY_LDAP_CONNECTION, properties);
      return;
    }
    if (id.equalsIgnoreCase(COMMAND_IDS.CREATE_CONNECTION_MODESHAPE)) {
      createConnection(CONNECTION_PROFILE_IDS.CATEGORY_MODESHAPE, properties);
      return;
    }
    if (id.equalsIgnoreCase(COMMAND_IDS.CREATE_CONNECTION_SALESFORCE)) {
      createConnection(CONNECTION_PROFILE_IDS.CATEGORY_SALESFORCE_CONNECTION, properties);
      return;
    }
    if (id.equalsIgnoreCase(COMMAND_IDS.CREATE_CONNECTION_WEB_SERVICE)) {
      createConnection(CONNECTION_PROFILE_IDS.CATEGORY_WS_CONNECTION, properties);
      return;
    }
    if (id.equalsIgnoreCase(COMMAND_IDS.CREATE_CONNECTION_WEB_SERVICE_ODA)) {
      createConnection(CONNECTION_PROFILE_IDS.CATEGORY_ODA_WS_ID, properties);
      return;
    }
    if (id.equalsIgnoreCase(COMMAND_IDS.CREATE_CONNECTION_XML_FILE_LOCAL)) {
      createConnection(CONNECTION_PROFILE_IDS.CATEGORY_XML_FILE_LOCAL, properties);
      return;
    }
    if (id.equalsIgnoreCase(COMMAND_IDS.CREATE_CONNECTION_XML_FILE_URL)) {
      createConnection(CONNECTION_PROFILE_IDS.CATEGORY_XML_FILE_URL, properties);
      return;
    }
    if (id.equalsIgnoreCase(COMMAND_IDS.GENERATE_WS_MODELS_FROM_WSDL)) {
      launchWizard(ImportMetadataAction.WSDL_TO_RELATIONAL, properties, synchronous);
      return;
    }

    if (id.equalsIgnoreCase(COMMAND_IDS.CREATE_VDB)) {
      ModelerUiViewUtils.launchWizard(
          "newVdbWizard", new StructuredSelection(), properties, synchronous); // $NON-NLS-1$
      return;
    }

    if (id.equalsIgnoreCase(COMMAND_IDS.DEFINE_VDB)) {
      DefineVdbAction action = new DefineVdbAction(properties);
      action.run();
      return;
    }

    if (id.equalsIgnoreCase(COMMAND_IDS.EDIT_VDB)) {
      EditVdbAction action = new EditVdbAction();
      action.run();
      return;
    }

    if (id.equalsIgnoreCase(COMMAND_IDS.EXECUTE_VDB)) {
      ExecuteVdbAction action = new ExecuteVdbAction(properties);
      action.run();
      return;
    }

    if (id.equalsIgnoreCase(COMMAND_IDS.DEPLOY_VDB)) {
      DeployVdbAction action = new DeployVdbAction(properties);
      action.queryUserAndRun();
      return;
    }

    if (id.equalsIgnoreCase(COMMAND_IDS.NEW_TEIID_MODEL_PROJECT)) {
      ModelerUiViewUtils.launchWizard(
          "newModelProject", new StructuredSelection(), properties, synchronous); // $NON-NLS-1$
      return;
    }

    if (id.equalsIgnoreCase(COMMAND_IDS.DEFINE_TEIID_MODEL_PROJECT)) {
      DefineProjectAction action = new DefineProjectAction(properties);
      action.run();
      return;
    }

    if (id.equalsIgnoreCase(COMMAND_IDS.OPEN_DATA_SOURCE_EXPLORER_VIEW)) {
      try {
        UiUtil.getWorkbenchPage()
            .showView(
                "org.eclipse.datatools.connectivity.DataSourceExplorerNavigator"); //$NON-NLS-1$
      } catch (final PartInitException err) {
        AdvisorUiConstants.UTIL.log(err);
        WidgetUtil.showError(err.getLocalizedMessage());
      }
      return;
    }

    if (id.equalsIgnoreCase(COMMAND_IDS.PREVIEW_DATA)) {
      PreviewDataAction action = new PreviewDataAction(properties);
      action.run();
      return;
    }

    if (id.equalsIgnoreCase(COMMAND_IDS.NEW_TEIID_SERVER)) {
      RuntimeAssistant.runNewServerAction(
          PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell());
      return;
    }

    if (id.equalsIgnoreCase(COMMAND_IDS.EDIT_TEIID_SERVER)) {
      RuntimeAssistant.runEditServerAction(
          PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell());
      return;
    }

    if (id.equalsIgnoreCase(COMMAND_IDS.CREATE_DATA_SOURCE)) {
      // make sure there is a Teiid connection
      if (RuntimeAssistant.ensureServerConnection(
          PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell(),
          Messages.CreateDataSource_NoServerMessage)) {
        try {
          TeiidServer teiidServer = DqpPlugin.getInstance().getServerManager().getDefaultServer();

          CreateDataSourceAction action = new CreateDataSourceAction();
          action.setAdmin(teiidServer.getAdmin());

          action.setSelection(new StructuredSelection());

          action.setEnabled(true);
          action.run();
        } catch (Exception ex) {
          AdvisorUiConstants.UTIL.log(ex);
        }
      }

      return;
    }

    if (id.equalsIgnoreCase(COMMAND_IDS.DEFINE_SOURCE)) {
      DefineSourceAction action = new DefineSourceAction(properties);
      action.run();
      return;
    }

    if (id.equalsIgnoreCase(COMMAND_IDS.GENERATE_REST_WAR)) {
      GenerateRESTWarAction action = new GenerateRESTWarAction(properties);
      action.run();
      return;
    }

    //		if( id.equalsIgnoreCase(COMMAND_IDS.GENERATE_SOAP_WAR)) {
    //			// TODO
    //	        return;
    //		}

    if (id.equalsIgnoreCase(COMMAND_IDS.DEPLOY_WAR)) {
      LaunchInstructionsAction action = new LaunchInstructionsAction(INSTRUCTIONS.DEPLOY_WAR_FILE);
      action.run();
      return;
    }

    if (id.equalsIgnoreCase(CHEAT_SHEET_IDS.CONSUME_SOAP_SERVICE)
        || id.equalsIgnoreCase(CHEAT_SHEET_IDS.CREATE_AND_TEST_VDB)
        || id.equalsIgnoreCase(CHEAT_SHEET_IDS.MODEL_FLAT_FILE_SOURCE)
        || id.equalsIgnoreCase(CHEAT_SHEET_IDS.MODEL_FROM_JDBC_SOURCE)
        || id.equalsIgnoreCase(CHEAT_SHEET_IDS.MODEL_XML_LOCAL_SOURCE)
        || id.equalsIgnoreCase(CHEAT_SHEET_IDS.MODEL_XML_REMOTE_SOURCE)
        || id.equalsIgnoreCase(CHEAT_SHEET_IDS.MULTI_SOURCE_VDB)) {
      executeCheatSheet(id);
      return;
    }

    MessageDialog.openWarning(
        PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell(),
        "Unimplemented Action", //$NON-NLS-1$
        "Action for ID [" + id + "] is not yet implemented"); // $NON-NLS-1$ //$NON-NLS-2$
  }
コード例 #6
0
 public void launchWizard(String wizardID) {
   ModelerUiViewUtils.launchWizard(wizardID, new StructuredSelection(), true);
 }