Esempio n. 1
0
        /**
         * {@inheritDoc}
         *
         * @see org.eclipse.jface.viewers.ViewerFilter#select(org.eclipse.jface.viewers.Viewer,
         *     java.lang.Object, java.lang.Object)
         */
        @Override
        public boolean select(Viewer viewer, Object parentElement, Object element) {
          TeiidTranslator teiidTranslator = RuntimeAssistant.adapt(element, TeiidTranslator.class);
          if (teiidTranslator != null) return false;

          return true;
        }
Esempio n. 2
0
        /**
         * {@inheritDoc}
         *
         * @see org.eclipse.jface.viewers.ViewerFilter#select(org.eclipse.jface.viewers.Viewer,
         *     java.lang.Object, java.lang.Object)
         */
        @Override
        public boolean select(Viewer viewer, Object parentElement, Object element) {
          TeiidVdb vdb = RuntimeAssistant.adapt(element, TeiidVdb.class);
          if (vdb != null && vdb.isPreviewVdb()) return false;

          return true;
        }
Esempio n. 3
0
        /**
         * {@inheritDoc}
         *
         * @see org.eclipse.jface.viewers.ViewerFilter#select(org.eclipse.jface.viewers.Viewer,
         *     java.lang.Object, java.lang.Object)
         */
        @Override
        public boolean select(Viewer viewer, Object parentElement, Object element) {
          TeiidDataSource dataSource = RuntimeAssistant.adapt(element, TeiidDataSource.class);
          if (dataSource != null && dataSource.isPreview()) return false;

          return true;
        }
  /**
   * {@inheritDoc}
   *
   * @see org.eclipse.jface.action.Action#run()
   */
  @Override
  public void run() {
    // Server may have already been selected by the action
    // having its updateSelection called. If it hasn't then find
    // a server to edit accordingly
    if (this.serverBeingEdited == null) {
      // Choose Server to Edit
      serverBeingEdited = RuntimeAssistant.selectServer(getShell(), false);
      if (RuntimeAssistant.selectServerWasCancelled()) return;
    }

    if (serverBeingEdited == null) {
      String title = UTIL.getString("noServerAvailableTitle"); // $NON-NLS-1$
      String message = UTIL.getString("noServerAvailableMessage"); // $NON-NLS-1$
      MessageDialog.openError(getShell(), title, message);
      return;
    }

    ServerUIPlugin.editServer(serverBeingEdited.getParent());
  }
  /**
   * {@inheritDoc}
   *
   * @see
   *     org.eclipse.ui.actions.BaseSelectionListenerAction#updateSelection(org.eclipse.jface.viewers.IStructuredSelection)
   */
  @Override
  protected boolean updateSelection(IStructuredSelection selection) {
    // disable if empty selection or multiple objects selected
    if (selection.isEmpty() || (selection.size() > 1)) {
      this.serverBeingEdited = null;
      return false;
    }

    ITeiidServer teiidServer = RuntimeAssistant.getServerFromSelection(selection);

    // enable if server is selected
    if (teiidServer != null) {
      this.serverBeingEdited = teiidServer;
      return true;
    }

    // disable if non-server is selected
    this.serverBeingEdited = null;
    return false;
  }
  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$
  }