use of org.jkiss.dbeaver.ui.controls.CustomSashForm in project dbeaver by serge-rider.
the class MySQLExportWizardPageObjects method createControl.
@Override
public void createControl(Composite parent) {
Composite composite = UIUtils.createPlaceholder(parent, 1);
Group objectsGroup = UIUtils.createControlGroup(composite, MySQLUIMessages.tools_db_export_wizard_page_settings_group_objects, 1, GridData.FILL_HORIZONTAL, 0);
objectsGroup.setLayoutData(new GridData(GridData.FILL_BOTH));
SashForm sash = new CustomSashForm(objectsGroup, SWT.VERTICAL);
sash.setLayoutData(new GridData(GridData.FILL_BOTH));
{
Composite catPanel = UIUtils.createComposite(sash, 1);
catPanel.setLayoutData(new GridData(GridData.FILL_BOTH));
catalogTable = new Table(catPanel, SWT.BORDER | SWT.CHECK);
catalogTable.addListener(SWT.Selection, event -> {
TableItem item = (TableItem) event.item;
if (item != null) {
MySQLCatalog catalog = (MySQLCatalog) item.getData();
if (event.detail == SWT.CHECK) {
catalogTable.select(catalogTable.indexOf(item));
checkedObjects.remove(catalog);
}
loadTables(catalog);
updateState();
}
});
GridData gd = new GridData(GridData.FILL_BOTH);
gd.heightHint = 50;
catalogTable.setLayoutData(gd);
Composite buttonsPanel = UIUtils.createComposite(catPanel, 3);
buttonsPanel.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
new Label(buttonsPanel, SWT.NONE).setLayoutData(new GridData(GridData.GRAB_HORIZONTAL));
createCheckButtons(buttonsPanel, catalogTable);
}
{
Composite tablesPanel = UIUtils.createComposite(sash, 1);
tablesPanel.setLayoutData(new GridData(GridData.FILL_BOTH));
tablesTable = new Table(tablesPanel, SWT.BORDER | SWT.CHECK);
GridData gd = new GridData(GridData.FILL_BOTH);
gd.heightHint = 50;
tablesTable.setLayoutData(gd);
tablesTable.addListener(SWT.Selection, event -> {
if (event.detail == SWT.CHECK) {
updateCheckedTables();
updateState();
}
});
Composite buttonsPanel = UIUtils.createComposite(tablesPanel, 3);
buttonsPanel.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
exportViewsCheck = UIUtils.createCheckbox(buttonsPanel, "Show views", false);
exportViewsCheck.addSelectionListener(new SelectionAdapter() {
@Override
public void widgetSelected(SelectionEvent e) {
wizard.getSettings().setShowViews(exportViewsCheck.getSelection());
loadTables(null);
}
});
exportViewsCheck.setLayoutData(new GridData(GridData.GRAB_HORIZONTAL));
createCheckButtons(buttonsPanel, tablesTable);
}
loadSettings();
setControl(composite);
}
use of org.jkiss.dbeaver.ui.controls.CustomSashForm in project dbeaver by serge-rider.
the class PrefPageProjectNetworkProfiles method createContents.
@Override
protected Control createContents(final Composite parent) {
CustomSashForm divider = UIUtils.createPartDivider(null, parent, SWT.HORIZONTAL);
{
Composite profilesGroup = new Composite(divider, SWT.BORDER);
GridLayout gl = new GridLayout(1, false);
gl.marginWidth = 0;
gl.marginHeight = 0;
profilesGroup.setLayout(gl);
GridData gd = new GridData(GridData.FILL_BOTH);
profilesGroup.setLayoutData(gd);
{
ToolBar toolbar = new ToolBar(profilesGroup, SWT.HORIZONTAL | SWT.RIGHT);
UIUtils.createToolItem(toolbar, "Create", "Create new profile", UIIcon.ROW_ADD, new SelectionAdapter() {
@Override
public void widgetSelected(SelectionEvent e) {
String profileName = "";
while (true) {
profileName = EnterNameDialog.chooseName(getShell(), "Profile name", profileName);
if (CommonUtils.isEmptyTrimmed(profileName)) {
return;
}
if (projectMeta.getDataSourceRegistry().getNetworkProfile(profileName) != null) {
UIUtils.showMessageBox(getShell(), "Wrong profile name", "Profile '" + profileName + "' already exist in project '" + projectMeta.getName() + "'", SWT.ICON_ERROR);
continue;
}
break;
}
DBWNetworkProfile newProfile = new DBWNetworkProfile();
newProfile.setProfileName(profileName);
projectMeta.getDataSourceRegistry().updateNetworkProfile(newProfile);
projectMeta.getDataSourceRegistry().flushConfig();
TableItem item = new TableItem(profilesTable, SWT.NONE);
item.setText(newProfile.getProfileName());
item.setImage(DBeaverIcons.getImage(DBIcon.TYPE_DOCUMENT));
item.setData(newProfile);
if (profilesTable.getItemCount() == 1) {
selectedProfile = newProfile;
profilesTable.select(0);
updateControlsState();
}
}
});
UIUtils.createToolItem(toolbar, "Delete", "Delete profile", UIIcon.ROW_DELETE, new SelectionAdapter() {
@Override
public void widgetSelected(SelectionEvent e) {
if (selectedProfile != null) {
List<? extends DBPDataSourceContainer> usedBy = projectMeta.getDataSourceRegistry().getDataSourcesByProfile(selectedProfile);
if (!usedBy.isEmpty()) {
UIUtils.showMessageBox(getShell(), "Can't delete profile", "Configuration profile '" + selectedProfile.getProfileName() + "' used by " + usedBy.size() + " connections:\n" + usedBy, SWT.ICON_ERROR);
return;
}
if (!UIUtils.confirmAction(getShell(), "Delete profile", "Are you sure you want to delete configuration profile '" + selectedProfile.getProfileName() + "'?")) {
return;
}
projectMeta.getDataSourceRegistry().removeNetworkProfile(selectedProfile);
projectMeta.getDataSourceRegistry().flushConfig();
profilesTable.remove(profilesTable.getSelectionIndex());
selectedProfile = null;
updateControlsState();
} else {
UIUtils.showMessageBox(getShell(), "No profile", "Select profile first", SWT.ICON_ERROR);
}
}
});
}
profilesTable = new Table(profilesGroup, SWT.SINGLE);
gd = new GridData(GridData.FILL_BOTH);
gd.minimumWidth = 150;
profilesTable.setLayoutData(gd);
profilesTable.addSelectionListener(new SelectionAdapter() {
@Override
public void widgetSelected(SelectionEvent e) {
saveHandlerSettings();
TableItem[] selection = profilesTable.getSelection();
if (ArrayUtils.isEmpty(selection)) {
selectedProfile = null;
} else {
selectedProfile = (DBWNetworkProfile) selection[0].getData();
}
updateControlsState();
}
});
}
{
handlersFolder = new TabFolder(divider, SWT.TOP | SWT.FLAT);
handlersFolder.setLayoutData(new GridData(GridData.FILL_BOTH));
for (NetworkHandlerDescriptor nhd : NetworkHandlerRegistry.getInstance().getDescriptors()) {
if (!nhd.hasObjectTypes()) {
createHandlerTab(nhd);
}
}
handlersFolder.addSelectionListener(new SelectionAdapter() {
@Override
public void widgetSelected(SelectionEvent e) {
updateControlsState();
}
});
}
divider.setWeights(new int[] { 300, 700 });
performDefaults();
return divider;
}
use of org.jkiss.dbeaver.ui.controls.CustomSashForm in project dbeaver by serge-rider.
the class PostgreBackupWizardPageObjects method createControl.
@Override
public void createControl(Composite parent) {
Composite composite = UIUtils.createPlaceholder(parent, 1);
Group objectsGroup = UIUtils.createControlGroup(composite, PostgreMessages.wizard_backup_page_object_group_object, 1, GridData.FILL_HORIZONTAL, 0);
objectsGroup.setLayoutData(new GridData(GridData.FILL_BOTH));
SashForm sash = new CustomSashForm(objectsGroup, SWT.VERTICAL);
sash.setLayoutData(new GridData(GridData.FILL_BOTH));
{
Composite catPanel = UIUtils.createComposite(sash, 1);
catPanel.setLayoutData(new GridData(GridData.FILL_BOTH));
schemasTable = new Table(catPanel, SWT.BORDER | SWT.CHECK);
schemasTable.addListener(SWT.Selection, event -> {
TableItem item = (TableItem) event.item;
PostgreSchema catalog = (PostgreSchema) item.getData();
if (event.detail == SWT.CHECK) {
schemasTable.select(schemasTable.indexOf(item));
checkedObjects.remove(catalog);
}
loadTables(catalog);
updateState();
});
GridData gd = new GridData(GridData.FILL_BOTH);
gd.heightHint = 50;
schemasTable.setLayoutData(gd);
Composite buttonsPanel = UIUtils.createComposite(catPanel, 3);
buttonsPanel.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
new Label(buttonsPanel, SWT.NONE).setLayoutData(new GridData(GridData.GRAB_HORIZONTAL));
createCheckButtons(buttonsPanel, schemasTable);
}
{
Composite tablesPanel = UIUtils.createComposite(sash, 1);
tablesPanel.setLayoutData(new GridData(GridData.FILL_BOTH));
tablesTable = new Table(tablesPanel, SWT.BORDER | SWT.CHECK);
GridData gd = new GridData(GridData.FILL_BOTH);
gd.heightHint = 50;
tablesTable.setLayoutData(gd);
tablesTable.addListener(SWT.Selection, event -> {
if (event.detail == SWT.CHECK) {
updateCheckedTables();
updateState();
}
});
Composite buttonsPanel = UIUtils.createComposite(tablesPanel, 3);
buttonsPanel.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
exportViewsCheck = UIUtils.createCheckbox(buttonsPanel, PostgreMessages.wizard_backup_page_object_checkbox_show_view, false);
exportViewsCheck.addSelectionListener(new SelectionAdapter() {
@Override
public void widgetSelected(SelectionEvent e) {
wizard.getSettings().setShowViews(exportViewsCheck.getSelection());
loadTables(null);
}
});
exportViewsCheck.setLayoutData(new GridData(GridData.GRAB_HORIZONTAL));
createCheckButtons(buttonsPanel, tablesTable);
}
setControl(composite);
}
use of org.jkiss.dbeaver.ui.controls.CustomSashForm in project dbeaver by serge-rider.
the class ErrorPresentation method createPresentation.
@Override
public void createPresentation(@NotNull IResultSetController controller, @NotNull Composite parent) {
super.createPresentation(controller, parent);
CustomSashForm partDivider = UIUtils.createPartDivider(controller.getSite().getPart(), parent, SWT.HORIZONTAL);
partDivider.setLayoutData(new GridData(GridData.FILL_BOTH));
errorComposite = UIUtils.createComposite(partDivider, 1);
errorComposite.setLayoutData(new GridData(GridData.FILL_BOTH));
statusPart = new StatusPart(errorComposite, status);
for (Control child : errorComposite.getChildren()) {
if (child instanceof Text) {
TextEditorUtils.enableHostEditorKeyBindingsSupport(controller.getSite(), child);
}
}
sqlPanel = UIUtils.createComposite(partDivider, 1);
sqlPanel.setLayout(new FillLayout());
UIServiceSQL serviceSQL = DBWorkbench.getService(UIServiceSQL.class);
try {
editorPanel = serviceSQL.createSQLPanel(controller.getSite(), sqlPanel, controller, "SQL", true, sqlText);
if (editorPanel instanceof TextViewer) {
textWidget = ((TextViewer) editorPanel).getTextWidget();
}
} catch (DBException e) {
textWidget = new StyledText(sqlPanel, SWT.BORDER | SWT.READ_ONLY);
textWidget.setText(sqlText);
}
try {
boolean widthSet = false;
IDialogSettings viewSettings = ResultSetUtils.getViewerSettings(SETTINGS_SECTION_ERROR_PANEL);
String errorWidth = viewSettings.get(PROP_ERROR_WIDTH);
if (errorWidth != null) {
String[] widthStrs = errorWidth.split(":");
if (widthStrs.length == 2) {
partDivider.setWeights(new int[] { Integer.parseInt(widthStrs[0]), Integer.parseInt(widthStrs[1]) });
}
widthSet = true;
}
if (!widthSet) {
partDivider.setWeights(new int[] { 700, 300 });
}
partDivider.addCustomSashFormListener((firstControlWeight, secondControlWeight) -> {
int[] weights = partDivider.getWeights();
viewSettings.put(PROP_ERROR_WIDTH, weights[0] + ":" + weights[1]);
});
} catch (Throwable e) {
log.debug(e);
}
}
use of org.jkiss.dbeaver.ui.controls.CustomSashForm in project dbeaver by dbeaver.
the class PrefPageProjectNetworkProfiles method createContents.
@Override
protected Control createContents(final Composite parent) {
CustomSashForm divider = UIUtils.createPartDivider(null, parent, SWT.HORIZONTAL);
{
Composite profilesGroup = new Composite(divider, SWT.BORDER);
GridLayout gl = new GridLayout(1, false);
gl.marginWidth = 0;
gl.marginHeight = 0;
profilesGroup.setLayout(gl);
GridData gd = new GridData(GridData.FILL_BOTH);
profilesGroup.setLayoutData(gd);
{
ToolBar toolbar = new ToolBar(profilesGroup, SWT.HORIZONTAL | SWT.RIGHT);
UIUtils.createToolItem(toolbar, "Create", "Create new profile", UIIcon.ROW_ADD, new SelectionAdapter() {
@Override
public void widgetSelected(SelectionEvent e) {
String profileName = "";
while (true) {
profileName = EnterNameDialog.chooseName(getShell(), "Profile name", profileName);
if (CommonUtils.isEmptyTrimmed(profileName)) {
return;
}
if (projectMeta.getDataSourceRegistry().getNetworkProfile(profileName) != null) {
UIUtils.showMessageBox(getShell(), "Wrong profile name", "Profile '" + profileName + "' already exist in project '" + projectMeta.getName() + "'", SWT.ICON_ERROR);
continue;
}
break;
}
DBWNetworkProfile newProfile = new DBWNetworkProfile();
newProfile.setProfileName(profileName);
projectMeta.getDataSourceRegistry().updateNetworkProfile(newProfile);
projectMeta.getDataSourceRegistry().flushConfig();
TableItem item = new TableItem(profilesTable, SWT.NONE);
item.setText(newProfile.getProfileName());
item.setImage(DBeaverIcons.getImage(DBIcon.TYPE_DOCUMENT));
item.setData(newProfile);
if (profilesTable.getItemCount() == 1) {
selectedProfile = newProfile;
profilesTable.select(0);
updateControlsState();
}
}
});
UIUtils.createToolItem(toolbar, "Delete", "Delete profile", UIIcon.ROW_DELETE, new SelectionAdapter() {
@Override
public void widgetSelected(SelectionEvent e) {
if (selectedProfile != null) {
List<? extends DBPDataSourceContainer> usedBy = projectMeta.getDataSourceRegistry().getDataSourcesByProfile(selectedProfile);
if (!usedBy.isEmpty()) {
UIUtils.showMessageBox(getShell(), "Can't delete profile", "Configuration profile '" + selectedProfile.getProfileName() + "' used by " + usedBy.size() + " connections:\n" + usedBy, SWT.ICON_ERROR);
return;
}
if (!UIUtils.confirmAction(getShell(), "Delete profile", "Are you sure you want to delete configuration profile '" + selectedProfile.getProfileName() + "'?")) {
return;
}
projectMeta.getDataSourceRegistry().removeNetworkProfile(selectedProfile);
projectMeta.getDataSourceRegistry().flushConfig();
profilesTable.remove(profilesTable.getSelectionIndex());
selectedProfile = null;
updateControlsState();
} else {
UIUtils.showMessageBox(getShell(), "No profile", "Select profile first", SWT.ICON_ERROR);
}
}
});
}
profilesTable = new Table(profilesGroup, SWT.SINGLE);
gd = new GridData(GridData.FILL_BOTH);
gd.minimumWidth = 150;
profilesTable.setLayoutData(gd);
profilesTable.addSelectionListener(new SelectionAdapter() {
@Override
public void widgetSelected(SelectionEvent e) {
saveHandlerSettings();
TableItem[] selection = profilesTable.getSelection();
if (ArrayUtils.isEmpty(selection)) {
selectedProfile = null;
} else {
selectedProfile = (DBWNetworkProfile) selection[0].getData();
}
updateControlsState();
}
});
}
{
handlersFolder = new TabFolder(divider, SWT.TOP | SWT.FLAT);
handlersFolder.setLayoutData(new GridData(GridData.FILL_BOTH));
for (NetworkHandlerDescriptor nhd : NetworkHandlerRegistry.getInstance().getDescriptors()) {
if (!nhd.hasObjectTypes()) {
createHandlerTab(nhd);
}
}
handlersFolder.addSelectionListener(new SelectionAdapter() {
@Override
public void widgetSelected(SelectionEvent e) {
updateControlsState();
}
});
}
divider.setWeights(new int[] { 300, 700 });
performDefaults();
return divider;
}
Aggregations