/**
  * Create connection from the data-source selected at this view
  *
  * @return
  * @throws SQLException
  */
 public static Connection getConnectionFromSelectedDatasource() throws SQLException {
   String datasourceName = CommonIDEParameters.get(SELECTED_DATASOURCE_NAME);
   DataSource dataSource = null;
   if ((datasourceName == null) || datasourceName.equals(DEFAULT_DATASOURCE_NAME)) {
     logger.debug("No selected datasource found. Make use of the default one");
     dataSource = DataSourceFacade.getInstance().getDataSource(CommonIDEParameters.getRequest());
     if (dataSource != null) {
       Connection connection = dataSource.getConnection();
       return connection;
     }
     logger.error("Trying to use the default datasource, but it is null");
   } else {
     logger.debug(String.format("Selected datasource found %s", datasourceName));
     dataSource =
         DataSourceFacade.getInstance()
             .getNamedDataSource(CommonIDEParameters.getRequest(), datasourceName);
     if (dataSource != null) {
       Connection connection = dataSource.getConnection();
       return connection;
     }
     logger.error(
         String.format(
             "Selected datasource found %s, but the datasource itself is null", datasourceName));
   }
   return null;
 }
  public static void createToolBarMenu(Composite parent, Shell shell) {
    if (CommonIDEParameters.isRAP()) {
      int style = SWT.FLAT | SWT.WRAP | SWT.RIGHT | SWT.BORDER | SWT.SHADOW_OUT;

      final ToolBar toolBar = new ToolBar(parent, style);

      if (CommonIDEParameters.isSandboxEnabled()) {
        createActivateToolItem(toolBar, shell);
        createSeparator(toolBar);
      }

      createPublishToolItem(toolBar, shell);

      createSeparator(toolBar);

      createSaveToolItem(toolBar);

      createSeparator(toolBar);

      createSaveAllToolItem(toolBar);

      createSeparator(toolBar);

      createNewToolItem(parent, toolBar);
    }
  }
 @Override
 public void selectionChanged(SelectionChangedEvent event) {
   if (event.getSource() instanceof DatabaseViewerToolBar) {
     String datasourceName =
         (String) ((IStructuredSelection) event.getSelection()).getFirstElement();
     CommonIDEParameters.set(SELECTED_DATASOURCE_NAME, datasourceName);
     viewer.setContentProvider(initContentProvider());
     viewer.refresh();
   }
 }
  private static IResource getFromRepository(IFile file) {
    IRepository repository = RepositoryFacade.getInstance().getRepository();

    String resourcePath =
        IRepositoryPaths.DB_DIRIGIBLE_USERS
            + CommonIDEParameters.getUserName()
            + IRepositoryPaths.SEPARATOR
            + IRepositoryPaths.WORKSPACE_FOLDER_NAME
            + file.getFullPath();
    IResource resource = repository.getResource(resourcePath);
    return resource;
  }
Example #5
0
  @Override
  protected void execute(ExecutionEvent event, SortedSet<IEntity> resources) {
    if (resources.size() == 0) {
      return;
    }

    if (!CommonIDEParameters.isRolesEnabled()) {
      // assume trial instance, hence disable this function
      MessageDialog.openInformation(null, PASTE_ERROR, PASTE_FUNCTION_IS_DISABLED_IN_THIS_INSTANCE);
      return;
    }

    IRepository repository = RepositoryFacade.getInstance().getRepository();

    String targetReposiotryPath = resources.first().getPath().toString();

    Clipboard clipboard = Clipboard.getInstance();

    String command = clipboard.getCommand();

    Throwable throwable = null;
    if (CUT.equals(command) || COPY.equals(command)) {

      for (Object name : clipboard) {
        IEntity resource = (IEntity) name;
        String sourceRepositoryPath = resource.getPath().toString();
        try {
          byte[] data = repository.exportZip(sourceRepositoryPath, true);
          repository.importZip(data, targetReposiotryPath);
        } catch (IOException e) {
          if (throwable == null) {
            throwable = e;
          }
        }
        if (CUT.equals(command)) {
          try {
            resource.delete();
          } catch (IOException e) {
            if (throwable == null) {
              throwable = e;
            }
          }
        }
      }
    }

    if (throwable != null) {
      MessageDialog.openWarning(null, PASTE_ERROR, SOME_OR_ALL_OF_THE_FILES_COULD_NOT_BE_PASTED);
    }

    RefreshHandler.refreshActivePart(event);
  }
 /** The constructor. */
 public DatabaseViewer() {
   isOperator = CommonIDEParameters.isUserInRole(IRoles.ROLE_OPERATOR);
 }
 public static String getSelectedDatasourceName() throws SQLException {
   return CommonIDEParameters.get(SELECTED_DATASOURCE_NAME);
 }