Esempio n. 1
0
  public SQLQueryJob(
      @NotNull IWorkbenchPartSite partSite,
      @NotNull String name,
      @NotNull DBCExecutionContext executionContext,
      @NotNull DBSDataContainer dataContainer,
      @NotNull List<SQLQuery> queries,
      @NotNull SQLResultsConsumer resultsConsumer,
      @Nullable SQLQueryListener listener) {
    super(name, DBeaverIcons.getImageDescriptor(UIIcon.SQL_SCRIPT_EXECUTE), executionContext);
    this.dataContainer = dataContainer;
    this.partSite = partSite;
    this.queries = queries;
    this.resultsConsumer = resultsConsumer;
    this.listener = listener;

    {
      // Read config form preference store
      DBPPreferenceStore preferenceStore = getDataSourceContainer().getPreferenceStore();
      this.commitType =
          SQLScriptCommitType.valueOf(
              preferenceStore.getString(DBeaverPreferences.SCRIPT_COMMIT_TYPE));
      this.errorHandling =
          SQLScriptErrorHandling.valueOf(
              preferenceStore.getString(DBeaverPreferences.SCRIPT_ERROR_HANDLING));
      this.fetchResultSets =
          queries.size() == 1
              || preferenceStore.getBoolean(DBeaverPreferences.SCRIPT_FETCH_RESULT_SETS);
      this.rsMaxRows = preferenceStore.getInt(DBeaverPreferences.RESULT_SET_MAX_ROWS);
    }
  }
 public static void contributeContentActions(
     @NotNull IContributionManager manager, @NotNull final IValueController controller)
     throws DBCException {
   if (controller.getValue() instanceof DBDContent
       && !((DBDContent) controller.getValue()).isNull()) {
     manager.add(
         new Action(
             CoreMessages.model_jdbc_save_to_file_,
             DBeaverIcons.getImageDescriptor(UIIcon.SAVE_AS)) {
           @Override
           public void run() {
             DialogUtils.saveToFile(controller);
           }
         });
   }
   manager.add(
       new Action(
           CoreMessages.model_jdbc_load_from_file_, DBeaverIcons.getImageDescriptor(UIIcon.LOAD)) {
         @Override
         public void run() {
           DialogUtils.loadFromFile(controller);
         }
       });
 }
 private static void fillToolsMenu(
     List<IContributionItem> menuItems, List<ToolDescriptor> tools, ISelection selection) {
   boolean hasTools = false;
   if (!CommonUtils.isEmpty(tools)) {
     IWorkbenchWindow workbenchWindow = DBeaverUI.getActiveWorkbenchWindow();
     if (workbenchWindow.getActivePage() != null) {
       IWorkbenchPart activePart = workbenchWindow.getActivePage().getActivePart();
       if (activePart != null) {
         Map<ToolGroupDescriptor, MenuManager> groupsMap = new HashMap<>();
         for (ToolDescriptor tool : tools) {
           hasTools = true;
           MenuManager parentMenu = null;
           if (tool.getGroup() != null) {
             parentMenu = getGroupMenu(menuItems, groupsMap, tool.getGroup());
           }
           IAction action =
               ActionUtils.makeAction(
                   new NavigatorActionExecuteTool(workbenchWindow, tool),
                   activePart.getSite(),
                   selection,
                   tool.getLabel(),
                   tool.getIcon() == null ? null : DBeaverIcons.getImageDescriptor(tool.getIcon()),
                   tool.getDescription());
           if (parentMenu == null) {
             menuItems.add(new ActionContributionItem(action));
           } else {
             parentMenu.add(new ActionContributionItem(action));
           }
         }
       }
     }
   }
   if (!hasTools) {
     menuItems.add(new ActionContributionItem(new EmptyListAction()));
   }
 }
Esempio n. 4
0
 @Override
 public ImageDescriptor getImageDescriptor() {
   return DBeaverIcons.getImageDescriptor(node.getNodeIconDefault());
 }