use of org.jkiss.dbeaver.model.DBPImage in project dbeaver by serge-rider.
the class DataTransferPageFinal method activatePage.
@Override
public void activatePage() {
resultTable.removeAll();
DataTransferSettings settings = getWizard().getSettings();
List<DataTransferPipe> dataPipes = settings.getDataPipes();
IDataTransferSettings consumerSettings = null, producerSettings = null;
for (int i = 0; i < dataPipes.size(); i++) {
DataTransferPipe pipe = dataPipes.get(i);
try {
pipe.initPipe(settings, i, dataPipes.size());
} catch (DBException e) {
DBWorkbench.getPlatformUI().showError(DTUIMessages.data_transfer_page_final_title_error_initializing_transfer_pipe, DTUIMessages.data_transfer_page_final_message_error_initializing_data_transfer_pipe, e);
continue;
}
IDataTransferConsumer consumer = pipe.getConsumer();
IDataTransferProducer producer = pipe.getProducer();
if (consumerSettings == null) {
consumerSettings = settings.getNodeSettings(settings.getConsumer());
}
if (producerSettings == null) {
producerSettings = settings.getNodeSettings(settings.getProducer());
}
DataTransferProcessorDescriptor processorDescriptor = settings.getProcessor();
TableItem item = new TableItem(resultTable, SWT.NONE);
{
item.setText(0, producer.getObjectContainerName());
if (producer.getObjectContainerIcon() != null) {
item.setImage(0, DBeaverIcons.getImage(producer.getObjectContainerIcon()));
}
item.setText(1, CommonUtils.notEmpty(producer.getObjectName()));
DBPImage producerObjectIcon = producer.getObjectIcon();
if (producerObjectIcon == null) {
producerObjectIcon = settings.getProducer().getIcon();
}
if (producerObjectIcon != null) {
item.setImage(1, DBeaverIcons.getImage(producerObjectIcon));
}
Color producerColor = getNodeColor(producer);
if (producerColor != null) {
item.setBackground(0, producerColor);
item.setBackground(1, producerColor);
}
}
{
item.setText(2, consumer.getObjectContainerName());
if (consumer.getObjectContainerIcon() != null) {
item.setImage(2, DBeaverIcons.getImage(consumer.getObjectContainerIcon()));
}
item.setText(3, consumer.getObjectName());
DBPImage consumerObjectIcon = consumer.getObjectIcon();
if (consumerObjectIcon == null && processorDescriptor != null) {
consumerObjectIcon = processorDescriptor.getIcon();
}
if (consumerObjectIcon == null && settings.getConsumer() != null) {
consumerObjectIcon = settings.getConsumer().getIcon();
}
if (consumerObjectIcon != null) {
item.setImage(3, DBeaverIcons.getImage(consumerObjectIcon));
}
Color consumerColor = getNodeColor(consumer);
if (consumerColor != null) {
item.setBackground(2, consumerColor);
item.setBackground(3, consumerColor);
}
}
}
printSummary(sourceSettingsText, settings.getProducer(), producerSettings, settings.isProducerProcessor() ? settings.getProcessor() : null);
printSummary(targetSettingsText, settings.getConsumer(), consumerSettings, settings.isProducerProcessor() ? null : settings.getProcessor());
activated = true;
int tableWidth = resultTable.getSize().x;
TableColumn[] columns = resultTable.getColumns();
for (TableColumn column : columns) {
column.setWidth(tableWidth / columns.length - 1);
}
updatePageCompletion();
getWizard().updateSaveTaskButtons();
}
use of org.jkiss.dbeaver.model.DBPImage in project dbeaver by serge-rider.
the class SQLToolTaskWizardPageStatus method createControl.
@Override
public void createControl(Composite parent) {
Composite composite = new Composite(parent, SWT.BORDER);
composite.setLayoutData(new GridData(GridData.FILL_BOTH));
composite.setLayout(new FillLayout());
SashForm partDivider = new SashForm(composite, SWT.VERTICAL);
partDivider.setSashWidth(5);
statusTable = new ObjectListControl<SQLToolStatistics>(partDivider, SWT.SHEET, new ListContentProvider()) {
@NotNull
@Override
protected String getListConfigId(List<Class<?>> classList) {
return "SQLToolStatus." + getWizard().getTaskType().getId();
}
@Override
protected DBPImage getObjectImage(SQLToolStatistics item) {
return DBValueFormatting.getObjectImage(item.getObject());
}
@Override
protected LoadingJob<Collection<SQLToolStatistics>> createLoadService() {
return LoadingJob.createService(new DummyLoadService(), new ObjectsLoadVisualizer());
}
};
console = new MessageConsole(TasksSQLUIMessages.sql_tool_task_wizard_page_status_message_console_name_tool_log, null);
LogConsoleViewer consoleViewer = new LogConsoleViewer(partDivider);
console.setWaterMarks(1024 * 1024 * 3, 1024 * 1024 * 4);
try {
writer = new PrintStream(console.newMessageStream(), true, StandardCharsets.UTF_8.name());
} catch (UnsupportedEncodingException e) {
writer = new PrintStream(console.newMessageStream(), true);
}
setControl(composite);
}
use of org.jkiss.dbeaver.model.DBPImage in project dbeaver by serge-rider.
the class DashboardDatabaseSelectDialog method createDialogArea.
@Override
protected Composite createDialogArea(Composite parent) {
Composite dialogArea = super.createDialogArea(parent);
{
treeViewer = DialogUtils.createFilteredTree(dialogArea, SWT.BORDER, new NamedObjectPatternFilter(), null);
GridData gd = new GridData(GridData.FILL_BOTH);
gd.heightHint = 300;
gd.widthHint = 300;
treeViewer.getControl().setLayoutData(gd);
treeViewer.getTree().setHeaderVisible(true);
UIUtils.createTreeColumn(treeViewer.getTree(), SWT.LEFT, UIDashboardMessages.dialog_dashboard_database_select_column_name);
UIUtils.createTreeColumn(treeViewer.getTree(), SWT.LEFT, UIDashboardMessages.dialog_dashboard_database_select_column_description);
treeViewer.setContentProvider(new TreeContentProvider() {
@Override
public Object[] getChildren(Object parentElement) {
List<? extends DBPNamedObject> result = null;
if (parentElement instanceof List) {
result = (List) parentElement;
} else if (parentElement instanceof DBPDataSourceProviderDescriptor) {
result = ((DBPDataSourceProviderDescriptor) parentElement).getEnabledDrivers();
if (result.size() <= 1) {
result = null;
}
}
if (result == null) {
return new Object[0];
}
result.sort(DBUtils.nameComparator());
return result.toArray();
}
@Override
public boolean hasChildren(Object element) {
if (element instanceof DBPDriver) {
return false;
}
return ((DBPDataSourceProviderDescriptor) element).getEnabledDrivers().size() > 1;
}
});
treeViewer.setLabelProvider(new CellLabelProvider() {
@Override
public void update(ViewerCell cell) {
DBPNamedObject element = (DBPNamedObject) cell.getElement();
if (cell.getColumnIndex() == 0) {
cell.setText(element.getName());
DBPImage icon = null;
if (element instanceof DBPDriver) {
icon = ((DBPDriver) element).getIcon();
} else if (element instanceof DBPDataSourceProviderDescriptor) {
icon = ((DBPDataSourceProviderDescriptor) element).getIcon();
}
if (icon != null) {
cell.setImage(DBeaverIcons.getImage(icon));
}
} else {
if (element instanceof DBPDriver) {
cell.setText(CommonUtils.notEmpty(((DBPDriver) element).getDescription()));
} else if (element instanceof DBPDataSourceProviderDescriptor) {
cell.setText(((DBPDataSourceProviderDescriptor) element).getDescription());
}
}
}
});
treeViewer.setInput(DBWorkbench.getPlatform().getDataSourceProviderRegistry().getDataSourceProviders());
treeViewer.addDoubleClickListener(event -> {
if (target != null) {
okPressed();
}
});
treeViewer.addSelectionChangedListener(event -> {
this.target = null;
ISelection selection = event.getSelection();
if (selection instanceof IStructuredSelection) {
Object selectedObject = ((IStructuredSelection) selection).getFirstElement();
if (selectedObject instanceof DBPNamedObject) {
this.target = (DBPNamedObject) selectedObject;
}
}
this.updateButtons();
});
UIUtils.asyncExec(() -> {
treeViewer.expandAll();
UIUtils.packColumns(treeViewer.getTree(), true, null);
});
}
return dialogArea;
}
use of org.jkiss.dbeaver.model.DBPImage in project dbeaver by serge-rider.
the class DashboardManagerDialog method createDialogArea.
@Override
protected Composite createDialogArea(Composite parent) {
getShell().setMinimumSize(300, 300);
Composite dialogArea = super.createDialogArea(parent);
Composite group = UIUtils.createPlaceholder(dialogArea, 2);
group.setLayoutData(new GridData(GridData.FILL_BOTH));
{
treeViewer = new TreeViewer(group, SWT.BORDER);
GridData gd = new GridData(GridData.FILL_BOTH);
gd.heightHint = 300;
gd.widthHint = 300;
treeViewer.getControl().setLayoutData(gd);
treeViewer.getTree().setHeaderVisible(true);
UIUtils.createTreeColumn(treeViewer.getTree(), SWT.LEFT, UIDashboardMessages.dialog_dashboard_manager_treecolumn_name);
// UIUtils.createTreeColumn(treeViewer.getTree(), SWT.LEFT, "Description");
treeViewer.setContentProvider(new TreeContentProvider() {
@Override
public Object[] getChildren(Object parentElement) {
List<? extends DBPNamedObject> result = null;
if (parentElement instanceof List) {
result = (List) parentElement;
} else if (parentElement instanceof DBPDataSourceProviderDescriptor) {
result = DashboardRegistry.getInstance().getDashboards((DBPDataSourceProviderDescriptor) parentElement, false);
} else if (parentElement instanceof DBPDriver) {
result = DashboardRegistry.getInstance().getDashboards((DBPDriver) parentElement, false);
}
if (result == null) {
return new Object[0];
}
result.sort(DBUtils.nameComparator());
return result.toArray();
}
@Override
public boolean hasChildren(Object element) {
if (element instanceof DashboardDescriptor) {
return false;
}
return true;
}
});
treeViewer.setLabelProvider(new CellLabelProvider() {
@Override
public void update(ViewerCell cell) {
DBPNamedObject element = (DBPNamedObject) cell.getElement();
if (cell.getColumnIndex() == 0) {
cell.setText(element.getName());
if (element instanceof DBPDriver) {
cell.setImage(DBeaverIcons.getImage(((DBPDriver) element).getIcon()));
} else if (element instanceof DBPDataSourceProviderDescriptor) {
cell.setImage(DBeaverIcons.getImage(((DBPDataSourceProviderDescriptor) element).getIcon()));
} else if (element instanceof DashboardDescriptor) {
DashboardDescriptor dashboardDescriptor = (DashboardDescriptor) element;
DBPImage icon;
if (dashboardDescriptor.isCustom()) {
icon = DBIcon.TYPE_OBJECT;
} else {
icon = dashboardDescriptor.getDefaultViewType().getIcon();
}
if (icon != null) {
cell.setImage(DBeaverIcons.getImage(icon));
}
}
} else {
if (element instanceof DBPDriver) {
cell.setText(CommonUtils.notEmpty(((DBPDriver) element).getDescription()));
} else if (element instanceof DBPDataSourceProviderDescriptor) {
cell.setText(((DBPDataSourceProviderDescriptor) element).getDescription());
}
}
}
});
treeViewer.setInput(DashboardRegistry.getInstance().getAllSupportedSources());
treeViewer.addDoubleClickListener(event -> {
if (selectedDashboard != null) {
editDashboard();
}
});
treeViewer.addSelectionChangedListener(event -> {
this.selectedDashboard = null;
ISelection selection = event.getSelection();
if (selection instanceof IStructuredSelection) {
Object selectedObject = ((IStructuredSelection) selection).getFirstElement();
if (selectedObject instanceof DashboardDescriptor) {
this.selectedDashboard = (DashboardDescriptor) selectedObject;
}
}
this.updateButtons();
});
UIUtils.asyncExec(() -> {
treeViewer.expandAll();
UIUtils.packColumns(treeViewer.getTree(), true, null);
});
}
{
Composite buttonBar = new Composite(group, SWT.TOP);
buttonBar.setLayout(new GridLayout(1, false));
GridData gd = new GridData(GridData.FILL_VERTICAL);
buttonBar.setLayoutData(gd);
newButton = UIUtils.createPushButton(buttonBar, UIDashboardMessages.dialog_dashboard_manager_button_new, null, new SelectionAdapter() {
@Override
public void widgetSelected(SelectionEvent e) {
createDashboard();
}
});
newButton.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
copyButton = UIUtils.createPushButton(buttonBar, UIDashboardMessages.dialog_dashboard_manager_button_copy, null, new SelectionAdapter() {
@Override
public void widgetSelected(SelectionEvent e) {
copyDashboard();
}
});
copyButton.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
editButton = UIUtils.createPushButton(buttonBar, UIDashboardMessages.dialog_dashboard_manager_button_edit, null, new SelectionAdapter() {
@Override
public void widgetSelected(SelectionEvent e) {
editDashboard();
}
});
editButton.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
deleteButton = UIUtils.createPushButton(buttonBar, UIDashboardMessages.dialog_dashboard_manager_button_delete, null, new SelectionAdapter() {
@Override
public void widgetSelected(SelectionEvent e) {
deleteDashboard();
}
});
deleteButton.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
}
UIUtils.createInfoLabel(dialogArea, UIDashboardMessages.dialog_dashboard_manager_infolabel_predifined_dashboard);
this.updateButtons();
return group;
}
use of org.jkiss.dbeaver.model.DBPImage in project dbeaver by serge-rider.
the class ObjectListDialog method createObjectSelector.
@NotNull
protected static <T extends DBPObject> DatabaseObjectListControl<T> createObjectSelector(Composite group, boolean singleSelection, String listId, List<T> selectedObjects, DBRRunnableWithResult<List<T>> objectReader) {
return new DatabaseObjectListControl<T>(group, (singleSelection ? SWT.SINGLE : SWT.MULTI), null, new ListContentProvider()) {
private Font boldFont;
private ISearchExecutor searcher = new SearcherFilter();
@NotNull
@Override
protected String getListConfigId(List<Class<?>> classList) {
return listId;
}
@Override
protected LoadingJob<Collection<T>> createLoadService() {
return LoadingJob.createService(new AbstractLoadService<Collection<T>>() {
@Override
public Collection<T> evaluate(DBRProgressMonitor monitor) throws InvocationTargetException, InterruptedException {
objectReader.run(monitor);
return objectReader.getResult();
}
@Override
public Object getFamily() {
return ObjectListDialog.class;
}
}, new ObjectsLoadVisualizer() {
@Override
public void completeLoading(Collection<T> items) {
super.completeLoading(items);
performSearch(SearchType.NONE);
getItemsViewer().getControl().setFocus();
}
});
}
protected CellLabelProvider getColumnLabelProvider(ObjectColumn objectColumn) {
return new ObjectLabelProvider(objectColumn);
}
@Override
protected Object getObjectValue(T item) {
if (item instanceof DBSWrapper) {
return ((DBSWrapper) item).getObject();
}
return super.getObjectValue(item);
}
@Override
protected DBPImage getObjectImage(T item) {
if (item instanceof DBNDatabaseNode) {
return ((DBNDatabaseNode) item).getNodeIcon();
}
return null;
}
@Override
protected void setListData(Collection<T> items, boolean append) {
super.setListData(items, append);
if (selectedObjects != null) {
getItemsViewer().setSelection(new StructuredSelection(selectedObjects), true);
}
}
@Override
public void fillCustomActions(IContributionManager contributionManager) {
super.fillCustomActions(contributionManager);
addColumnConfigAction(contributionManager);
}
protected void addSearchAction(IContributionManager contributionManager) {
contributionManager.add(new Action("Filter objects", DBeaverIcons.getImageDescriptor(UIIcon.SEARCH)) {
@Override
public void run() {
performSearch(SearchType.NONE);
}
});
}
@Override
protected ISearchExecutor getSearchRunner() {
return searcher;
}
class ObjectLabelProvider extends ObjectColumnLabelProvider implements IFontProvider {
ObjectLabelProvider(ObjectColumn objectColumn) {
super(objectColumn);
}
@Override
public Font getFont(Object element) {
if (selectedObjects.contains(element)) {
if (boldFont == null) {
boldFont = UIUtils.makeBoldFont(group.getFont());
group.addDisposeListener(e -> boldFont.dispose());
}
return boldFont;
}
return null;
}
}
};
}
Aggregations