private void showSelectedType(DBPConnectionType connectionType) {
    colorPicker.select(UIUtils.getConnectionTypeColor(connectionType));
    typeName.setText(connectionType.getName());
    typeDescription.setText(connectionType.getDescription());
    autocommitCheck.setSelection(connectionType.isAutocommit());
    confirmCheck.setSelection(connectionType.isConfirmExecute());

    deleteButton.setEnabled(!connectionType.isPredefined());
  }
 private void addTypeToTable(DBPConnectionType source, DBPConnectionType connectionType) {
   changedInfo.put(connectionType, source);
   TableItem item = new TableItem(typeTable, SWT.LEFT);
   item.setText(0, connectionType.getName());
   item.setText(1, CommonUtils.toString(connectionType.getDescription()));
   if (connectionType.getColor() != null) {
     Color connectionColor = UIUtils.getConnectionTypeColor(connectionType);
     item.setBackground(0, connectionColor);
     item.setBackground(1, connectionColor);
     colorPicker.add(null, COLOR_TEXT, connectionColor, connectionColor);
   }
   item.setData(connectionType);
 }
 private void updateTableInfo() {
   DBPConnectionType connectionType = getSelectedType();
   for (TableItem item : typeTable.getItems()) {
     if (item.getData() == connectionType) {
       item.setText(0, connectionType.getName());
       item.setText(1, connectionType.getDescription());
       Color connectionColor = UIUtils.getConnectionTypeColor(connectionType);
       item.setBackground(0, connectionColor);
       item.setBackground(1, connectionColor);
       break;
     }
   }
 }
Example #4
0
 public static Color getConnectionTypeColor(DBPConnectionType connectionType) {
   String rgbString = connectionType.getColor();
   if (CommonUtils.isEmpty(rgbString)) {
     return null;
   }
   return DBeaverUI.getSharedTextColors().getColor(StringConverter.asRGB(rgbString));
 }
  @Override
  public boolean performOk() {
    DataSourceProviderRegistry registry = DataSourceProviderRegistry.getInstance();
    java.util.List<DBPConnectionType> toRemove = new ArrayList<>();
    for (DBPConnectionType type : registry.getConnectionTypes()) {
      if (!changedInfo.values().contains(type)) {
        // Remove
        toRemove.add(type);
      }
    }
    for (DBPConnectionType connectionType : toRemove) {
      registry.removeConnectionType(connectionType);
    }

    for (DBPConnectionType changed : changedInfo.keySet()) {
      DBPConnectionType source = changedInfo.get(changed);
      if (source == changed) {
        // New type
        registry.addConnectionType(changed);
      } else {
        // Changed type
        source.setName(changed.getName());
        source.setDescription(changed.getDescription());
        source.setAutocommit(changed.isAutocommit());
        source.setConfirmExecute(changed.isConfirmExecute());
        source.setColor(changed.getColor());
      }
    }
    registry.saveConnectionTypes();
    return super.performOk();
  }