コード例 #1
0
  /**
   * If the preview preference is disabled or a Teiid server does not exist, a dialog is shown
   * asking the user if they want to enable preview and create a server.
   *
   * @param shell the shell used to display dialog if necessary
   * @return <code>true</code> if preview is enabled, a Teiid server exists, and a connection to the
   *     server has been made
   */
  public static boolean ensurePreviewEnabled(Shell shell) {
    boolean previewEnabled = isPreviewEnabled();
    boolean previewServerExists = previewServerExists();

    // dialog message (null if preview preference enabled and server exists)
    String msg = null;

    if (!previewEnabled && !previewServerExists) {
      msg = UTIL.getString(PREFIX + "previewDisabledNoTeiidInstanceMsg"); // $NON-NLS-1$
    } else if (!previewEnabled) {
      msg = UTIL.getString(PREFIX + "previewDisabledMsg"); // $NON-NLS-1$
    } else if (!previewServerExists) {
      msg = UTIL.getString(PREFIX + "noTeiidInstanceMsg"); // $NON-NLS-1$
    }

    // if necessary open question dialog
    if ((msg != null)
        && MessageDialog.openQuestion(
            shell, UTIL.getString(PREFIX + "confirmEnablePreviewTitle"), msg)) { // $NON-NLS-1$
      // if necessary change preference
      if (!previewEnabled) {
        IEclipsePreferences prefs = DqpPlugin.getInstance().getPreferences();
        prefs.putBoolean(PreferenceConstants.PREVIEW_ENABLED, true);

        // save
        try {
          prefs.flush();
        } catch (BackingStoreException e) {
          UTIL.log(e);
        }
      }

      // if necessary create new server
      if (!previewServerExists) {
        runNewServerAction(shell);
      }
    }

    // if dialog was shown get values again
    if (msg != null) {
      previewEnabled = isPreviewEnabled();
      previewServerExists = previewServerExists();

      // if preview is not enabled or server does not exist then user canceled the dialog or the new
      // server wizard
      if (!previewEnabled || !previewServerExists) {
        return false;
      }
    }

    // abort preview if server is not connected
    return serverConnectionExists(shell);
  }
コード例 #2
0
  /**
   * If a Teiid server does not exist, a dialog is shown asking the user if they want to create a
   * server.
   *
   * @param shell the shell used to display dialog if necessary
   * @param dialogMessage the localized question to ask the user if they want to create a new Teiid
   *     instance in order to continue on with task
   * @return <code>true</code> if a Teiid server exists and can be connected to
   */
  public static boolean ensureServerConnection(Shell shell, String dialogMessage) {
    if (!previewServerExists()) {
      if (MessageDialog.openQuestion(
          shell,
          UTIL.getString(PREFIX + "confirmCreateTeiidInstanceTitle"),
          dialogMessage)) { //$NON-NLS-1$
        runNewServerAction(shell);
      }

      // if server does not exist then user canceled the dialog or the new server wizard
      if (!previewServerExists()) {
        return false;
      }
    }

    // abort preview if server is not connected
    return serverConnectionExists(shell);
  }
コード例 #3
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$
  }