use of org.jkiss.dbeaver.ui.controls.resultset.panel.ResultSetPanelDescriptor in project dbeaver by dbeaver.
the class ResultSetPresentationRegistry method getSupportedPanels.
public List<ResultSetPanelDescriptor> getSupportedPanels(IResultSetContext context, DBPDataSource dataSource, String presentationId, IResultSetPresentation.PresentationType presentationType) {
List<ResultSetPanelDescriptor> result = new ArrayList<>();
for (ResultSetPanelDescriptor panel : panels) {
if (panel.supportedBy(context, dataSource, presentationId, presentationType)) {
result.add(panel);
}
}
result.sort(Comparator.comparing(ResultSetPanelDescriptor::getLabel));
return result;
}
use of org.jkiss.dbeaver.ui.controls.resultset.panel.ResultSetPanelDescriptor in project dbeaver by serge-rider.
the class ResultSetViewer method fillPanelsMenu.
private List<IContributionItem> fillPanelsMenu() {
List<IContributionItem> items = new ArrayList<>();
for (final ResultSetPanelDescriptor panel : availablePanels) {
CommandContributionItemParameter params = new CommandContributionItemParameter(site, panel.getId(), ResultSetHandlerTogglePanel.CMD_TOGGLE_PANEL, CommandContributionItem.STYLE_CHECK);
Map<String, String> parameters = new HashMap<>();
parameters.put(ResultSetHandlerTogglePanel.PARAM_PANEL_ID, panel.getId());
params.parameters = parameters;
items.add(new CommandContributionItem(params));
}
items.add(new Separator());
// if (viewerSash.getMaximizedControl() == null) {
// items.add(ActionUtils.makeCommandContribution(site, ResultSetHandlerMain.CMD_TOGGLE_LAYOUT));
// }
items.add(ActionUtils.makeCommandContribution(site, ResultSetHandlerMain.CMD_TOGGLE_MAXIMIZE));
// items.add(ActionUtils.makeCommandContribution(site, ResultSetHandlerMain.CMD_TOGGLE_PANELS));
items.add(ActionUtils.makeCommandContribution(site, ResultSetHandlerMain.CMD_ACTIVATE_PANELS));
return items;
}
use of org.jkiss.dbeaver.ui.controls.resultset.panel.ResultSetPanelDescriptor in project dbeaver by serge-rider.
the class ResultSetViewer method updatePanelsButtons.
private void updatePanelsButtons() {
boolean panelsVisible = isPanelsVisible();
for (Control child : panelSwitchFolder.getChildren()) {
if (child instanceof VerticalButton && child.getData() instanceof ResultSetPanelDescriptor) {
boolean newChecked = panelsVisible && isPanelVisible(((ResultSetPanelDescriptor) child.getData()).getId());
if (((VerticalButton) child).isChecked() != newChecked) {
((VerticalButton) child).setChecked(newChecked);
child.redraw();
}
}
}
}
use of org.jkiss.dbeaver.ui.controls.resultset.panel.ResultSetPanelDescriptor in project dbeaver by serge-rider.
the class ResultSetViewer method activatePanel.
@Override
public boolean activatePanel(String id, boolean setActive, boolean showPanels) {
if (!supportsPanels()) {
return false;
}
if (showPanels && !isPanelsVisible()) {
showPanels(true, false, false);
}
PresentationSettings presentationSettings = getPresentationSettings();
IResultSetPanel panel = activePanels.get(id);
if (panel != null) {
CTabItem panelTab = getPanelTab(id);
if (panelTab != null) {
if (setActive) {
panelFolder.setSelection(panelTab);
presentationSettings.activePanelId = id;
if (showPanels) {
panel.setFocus();
}
// panelTab.getControl().setFocus();
}
return true;
} else {
log.debug("Panel '" + id + "' tab not found");
}
}
// Create panel
ResultSetPanelDescriptor panelDescriptor = getPanelDescriptor(id);
if (panelDescriptor == null) {
log.debug("Panel '" + id + "' not found");
return false;
}
try {
panel = panelDescriptor.createInstance();
} catch (DBException e) {
DBWorkbench.getPlatformUI().showError("Can't show panel", "Can't create panel '" + id + "'", e);
return false;
}
activePanels.put(id, panel);
// Create control and tab item
panelFolder.setRedraw(false);
try {
Control panelControl = panel.createContents(activePresentation, panelFolder);
boolean firstPanel = panelFolder.getItemCount() == 0;
CTabItem panelTab = new CTabItem(panelFolder, SWT.CLOSE);
panelTab.setData(id);
panelTab.setText(panelDescriptor.getLabel());
panelTab.setImage(DBeaverIcons.getImage(panelDescriptor.getIcon()));
panelTab.setToolTipText(panelDescriptor.getDescription());
panelTab.setControl(panelControl);
UIUtils.disposeControlOnItemDispose(panelTab);
if (setActive || firstPanel) {
panelFolder.setSelection(panelTab);
}
if (showPanels) {
panel.setFocus();
}
} finally {
panelFolder.setRedraw(true);
}
presentationSettings.enabledPanelIds.add(id);
if (setActive) {
setActivePanel(id);
}
updatePanelsButtons();
return true;
}
use of org.jkiss.dbeaver.ui.controls.resultset.panel.ResultSetPanelDescriptor in project dbeaver by dbeaver.
the class ResultSetViewer method updatePanelsButtons.
private void updatePanelsButtons() {
boolean panelsVisible = isPanelsVisible();
for (Control child : panelSwitchFolder.getChildren()) {
if (child instanceof VerticalButton && child.getData() instanceof ResultSetPanelDescriptor) {
boolean newChecked = panelsVisible && isPanelVisible(((ResultSetPanelDescriptor) child.getData()).getId());
if (((VerticalButton) child).isChecked() != newChecked) {
((VerticalButton) child).setChecked(newChecked);
child.redraw();
}
}
}
}
Aggregations