public GenerateRestWarAction() {
   this.setText(UTIL.getString(I18N_PREFIX + "text")); // $NON-NLS-1$
   this.setToolTipText(UTIL.getString(I18N_PREFIX + "tooltip")); // $NON-NLS-1$
   this.setImageDescriptor(
       DqpUiPlugin.getDefault().getImageDescriptor(DqpUiConstants.Images.CREATE_WAR));
   setDisabledImageDescriptor(
       DqpUiPlugin.getDefault().getImageDescriptor(DqpUiConstants.Images.CREATE_WAR));
   setEnabled(false);
 }
 /** @since 5.0 */
 public ExecuteVdbAction() {
   super();
   setImageDescriptor(
       DqpUiPlugin.getDefault().getImageDescriptor(DqpUiConstants.Images.EXECUTE_VDB));
   setToolTipText(DqpUiConstants.UTIL.getString(THIS_CLASS + "tooltip")); // $NON-NLS-1$
   worker = new ExecuteVdbWorker();
 }
 /**
  * Default Constructor
  *
  * <p>Used when called by the {@link IHandlerService}. Calls to the accompanying command should
  * provide an {@link Event} when executing the command and reference an {@link ITeiidServer} in
  * the event's data. Otherwise, the dialog for choosing a server will be displayed.
  */
 public EditServerAction() {
   super(UTIL.getString("editServerActionText")); // $NON-NLS-1$
   setToolTipText(UTIL.getString("editServerActionToolTip")); // $NON-NLS-1$
   setImageDescriptor(
       DqpUiPlugin.getDefault().getImageDescriptor(DqpUiPlugin.Images.EDIT_SERVER_ICON));
   setEnabled(true);
 }
  /** Ask the user to select the vdb and deploy it */
  public void queryUserAndRun() {
    // Make sure default teiid instance is connected
    if (!checkForConnectedServer()) return;

    ITeiidServer teiidServer = getServerManager().getDefaultServer();

    DeployVdbDialog dialog =
        new DeployVdbDialog(
            DqpUiPlugin.getDefault().getCurrentWorkbenchWindow().getShell(), designerProperties);

    dialog.open();

    if (dialog.getReturnCode() == Window.OK) {
      IFile vdb = dialog.getSelectedVdb();
      boolean doCreateDS = dialog.doCreateVdbDataSource();
      String jndiName = dialog.getVdbDataSourceJndiName();
      if (vdb != null) {
        boolean doDeploy = VdbRequiresSaveChecker.insureOpenVdbSaved(vdb);
        if (doDeploy) {
          deployVdb(teiidServer, vdb, true);
        }

        String vdbName = vdb.getFullPath().removeFileExtension().lastSegment();
        try {
          if (teiidServer.hasVdb(vdbName) && doCreateDS) {
            createVdbDataSource(vdb, jndiName, jndiName);
          }
        } catch (Exception ex) {
          DqpPlugin.Util.log(ex);
          Shell shell = UiUtil.getWorkbenchShellOnlyIfUiThread();
          String title =
              UTIL.getString(
                  I18N_PREFIX + "problemDeployingVdbDataSource.title",
                  vdbName,
                  teiidServer); //$NON-NLS-1$
          String message =
              UTIL.getString(
                  I18N_PREFIX + "problemDeployingVdbDataSource.msg",
                  vdbName,
                  teiidServer); //$NON-NLS-1$
          ErrorDialog.openError(
              shell, title, null, new Status(IStatus.ERROR, PLUGIN_ID, message, ex));
        }
      }
    }
  }
 /**
  * Create a new instance with given properties
  *
  * @param properties the properties
  */
 public DeployVdbAction(Properties properties) {
   super();
   setImageDescriptor(
       DqpUiPlugin.getDefault().getImageDescriptor(DqpUiConstants.Images.DEPLOY_VDB));
   designerProperties = properties;
 }
 /** Create a new instance */
 public DeployVdbAction() {
   super();
   setImageDescriptor(
       DqpUiPlugin.getDefault().getImageDescriptor(DqpUiConstants.Images.DEPLOY_VDB));
 }
 /** The constructor. */
 public TeiidView() {
   this.setPartName(getString("title.text")); // $NON-NLS-1$
   this.setTitleImage(DqpUiPlugin.getDefault().getImage(Images.SOURCE_BINDING_ICON));
   this.setTitleToolTip(getString("title.tooltip")); // $NON-NLS-1$
 }
 private static Shell getShell() {
   return DqpUiPlugin.getDefault().getCurrentWorkbenchWindow().getShell();
 }
  /**
   * @see org.eclipse.jface.viewers.ILabelProvider#getImage(java.lang.Object)
   * @since 4.2
   */
  @Override
  public Image getImage(Object element) {
    if (element instanceof Server) {
      Server server = (Server) element;
      boolean isOKtoConnect = isOkToConnect(server);
      // System.out.println(" >>>> TVTP.getImage() IS CONNECTED = " + server.isConnected() + " IS OK
      // TO CONNECT = " + isOKtoConnect + "  Server = " + server.getUrl());
      boolean isError = false;
      if (isOKtoConnect) {
        // decorate server if can't connect
        if (!server.isConnected()) {
          addOfflineServer(server);
          isError = true;
        }
      } else {
        if (!server.isConnected()) {
          isError = true;
        }
      }
      // isError = false;
      if (getServerManager() != null) {
        if (this.serverMgr.isDefaultServer((Server) element)) {
          if (isError)
            return DqpUiPlugin.getDefault()
                .getAnImage(DqpUiConstants.Images.SET_DEFAULT_SERVER_ERROR_ICON);
          return DqpUiPlugin.getDefault().getAnImage(DqpUiConstants.Images.SET_DEFAULT_SERVER_ICON);
        }
      }
      if (isError) {
        if (server.getConnectionError() != null)
          return DqpUiPlugin.getDefault().getAnImage(DqpUiConstants.Images.SERVER_ERROR_ICON);
        return DqpUiPlugin.getDefault()
            .getAnImage(DqpUiConstants.Images.SET_DEFAULT_SERVER_ERROR_ICON);
      }
      return DqpUiPlugin.getDefault().getAnImage(DqpUiConstants.Images.SERVER_ICON);
    }

    if (element instanceof TeiidFolder) {
      return DqpUiPlugin.getDefault().getAnImage(DqpUiConstants.Images.FOLDER_OBJ);
    }

    if (element instanceof TeiidTranslator) {
      return DqpUiPlugin.getDefault().getAnImage(DqpUiConstants.Images.CONNECTOR_BINDING_ICON);
    }

    if (element instanceof TeiidDataSource) {
      return DqpUiPlugin.getDefault().getAnImage(DqpUiConstants.Images.CONNECTION_SOURCE_ICON);
    }

    if (element instanceof TeiidVdb) {
      if (((TeiidVdb) element).isActive()) {
        return DqpUiPlugin.getDefault().getAnImage(DqpUiConstants.Images.DEPLOY_VDB);
      }
      return DqpUiPlugin.getDefault().getAnImage(DqpUiConstants.Images.INACTIVE_DEPLOYED_VDB);
    }

    if (element instanceof SourceConnectionBinding) {
      return DqpUiPlugin.getDefault()
          .getAnImage(DqpUiConstants.Images.SOURCE_CONNECTOR_BINDING_ICON);
    }
    return null;
  }
 /** @since 5.0 */
 public CreateDataSourceAction() {
   super(label, SWT.DEFAULT);
   setImageDescriptor(DqpUiPlugin.getDefault().getImageDescriptor(Images.SOURCE_BINDING_ICON));
   providerFactory = new ConnectionInfoProviderFactory();
 }
  /** @see org.eclipse.ui.IActionDelegate#run(org.eclipse.jface.action.IAction) */
  @Override
  public void run() {

    final IWorkbenchWindow window =
        DqpUiPlugin.getDefault().getWorkbench().getActiveWorkbenchWindow();

    JavaCompiler compiler = ToolProvider.getSystemJavaCompiler();

    boolean cont = true;
    if (compiler == null) {
      cont =
          MessageDialog.openConfirm(
              window.getShell(),
              UTIL.getString(I18N_PREFIX + "javaWarningTitle"), // $NON-NLS-1$
              UTIL.getString(I18N_PREFIX + "invalidJDKMessage")); // $NON-NLS-1$
    }

    if (!cont) {
      notifyResult(false);
      return;
    }

    RestWarDeploymentInfoDialog dialog = null;
    dialog =
        new RestWarDeploymentInfoDialog(
            window.getShell(),
            this.selectedVDB,
            this.restfulProcedureMap,
            null,
            this.designerProperties);

    int rc = dialog.open();

    // Retrieve the file name for the confirmation dialog
    String warFileName = dialog.getWarFileName();

    final String successMessage =
        UTIL.getString(I18N_PREFIX + "warFileCreated", warFileName); // $NON-NLS-1$

    boolean wasSuccessful = (rc == Window.OK);
    if (wasSuccessful) {
      Display.getDefault()
          .asyncExec(
              new Runnable() {
                @Override
                public void run() {
                  MessageDialog.openInformation(
                      window.getShell(),
                      UTIL.getString(I18N_PREFIX + "creationCompleteTitle"), // $NON-NLS-1$
                      successMessage);
                }
              });
    } else {
      if (rc != Window.CANCEL) {

        MessageDialog.openError(
            window.getShell(),
            UTIL.getString(I18N_PREFIX + "creationFailedTitle"), // $NON-NLS-1$
            dialog.getMessage());
      }
    }
    notifyResult(rc == Window.OK);
  }