use of org.eclipse.ui.IWorkbenchPartSite in project dbeaver by serge-rider.
the class AbstractPresentation method trackPresentationControl.
protected void trackPresentationControl() {
final Control control = getControl();
final IWorkbenchPartSite site = controller.getSite();
UIUtils.addFocusTracker(site, PRESENTATION_CONTROL_ID, control);
// RSV control context
EditorUtils.trackControlContext(site, control, RESULTS_CONTROL_CONTEXT_ID);
// Enable horizontal scrolling
control.addMouseWheelListener(e -> {
boolean shift = ((e.stateMask & SWT.MOD2) != 0);
if (shift) {
performHorizontalScroll(e.count);
}
});
// Register DnD handlers for this presentation
controller.getDecorator().registerDragAndDrop(this);
}
use of org.eclipse.ui.IWorkbenchPartSite in project dbeaver by serge-rider.
the class NavigatorHandlerConnectionFilter method updateElement.
@Override
public void updateElement(UIElement element, Map parameters) {
IWorkbenchPartSite partSite = UIUtils.getWorkbenchPartSite(element.getServiceLocator());
if (partSite != null && partSite.getPart() instanceof DatabaseNavigatorView) {
DatabaseNavigatorTree navigatorTree = ((DatabaseNavigatorView) partSite.getPart()).getNavigatorTree();
element.setIcon(DBeaverIcons.getImageDescriptor(navigatorTree.isFilterShowConnected() ? UIIcon.FILTER_RESET : UIIcon.FILTER_APPLY));
String actionName = navigatorTree.isFilterShowConnected() ? "Show all" : "Show connected only";
element.setText(actionName);
element.setTooltip(actionName);
}
}
use of org.eclipse.ui.IWorkbenchPartSite in project dbeaver by serge-rider.
the class UIServiceSQLImpl method createSQLPanel.
@Override
public Object createSQLPanel(Object site, Object parent, DBPContextProvider contextProvider, String panelName, boolean showVerticalBar, String sqlText) throws DBException {
IWorkbenchPartSite partSite = (IWorkbenchPartSite) site;
Composite editorPH = (Composite) parent;
final SQLEditorBase editor = new SQLEditorBase() {
@Nullable
@Override
public DBCExecutionContext getExecutionContext() {
return contextProvider.getExecutionContext();
}
@Override
public void createPartControl(Composite parent) {
super.createPartControl(parent);
getAction(ITextEditorActionConstants.CONTEXT_PREFERENCES).setEnabled(false);
}
@Override
public boolean isFoldingEnabled() {
return false;
}
};
editor.setHasVerticalRuler(showVerticalBar);
try {
editor.init(new SubEditorSite(partSite), new StringEditorInput(panelName, sqlText, true, GeneralUtils.getDefaultFileEncoding()));
} catch (PartInitException e) {
throw new DBException("Error initializing SQL panel", e);
}
editor.createPartControl(editorPH);
editor.reloadSyntaxRules();
TextViewer textViewer = editor.getTextViewer();
textViewer.setData("editor", editor);
TextEditorUtils.enableHostEditorKeyBindingsSupport(partSite, textViewer.getTextWidget());
return textViewer;
}
use of org.eclipse.ui.IWorkbenchPartSite in project dbeaver by dbeaver.
the class ResultSetHandlerCopyAs method fillCopyAsMenu.
public static void fillCopyAsMenu(ResultSetViewer viewer, IContributionManager copyAsMenu) {
IWorkbenchPartSite site = viewer.getSite();
copyAsMenu.add(ActionUtils.makeCommandContribution(site, ResultSetHandlerCopySpecial.CMD_COPY_SPECIAL));
copyAsMenu.add(ActionUtils.makeCommandContribution(site, ResultSetHandlerCopySpecial.CMD_COPY_COLUMN_NAMES));
copyAsMenu.add(ActionUtils.makeCommandContribution(site, ResultSetHandlerMain.CMD_COPY_ROW_NAMES));
// Add copy commands for different formats
copyAsMenu.add(new Separator());
ResultSetDataContainerOptions options = new ResultSetDataContainerOptions();
ResultSetDataContainer dataContainer = new ResultSetDataContainer(viewer, options);
List<DataTransferProcessorDescriptor> appProcessors = new ArrayList<>();
for (final DataTransferNodeDescriptor consumerNode : DataTransferRegistry.getInstance().getAvailableConsumers(Collections.singleton(dataContainer))) {
for (DataTransferProcessorDescriptor processor : consumerNode.getProcessors()) {
if (processor.isBinaryFormat()) {
continue;
}
appProcessors.add(processor);
}
}
appProcessors.sort(Comparator.comparing(DataTransferProcessorDescriptor::getName));
for (DataTransferProcessorDescriptor processor : appProcessors) {
CommandContributionItemParameter params = new CommandContributionItemParameter(site, processor.getId(), ResultSetHandlerCopyAs.CMD_COPY_AS, CommandContributionItem.STYLE_PUSH);
params.label = processor.getName();
if (processor.getIcon() != null) {
params.icon = DBeaverIcons.getImageDescriptor(processor.getIcon());
}
Map<String, Object> parameters = new HashMap<>();
parameters.put(ResultSetHandlerCopyAs.PARAM_PROCESSOR_ID, processor.getFullId());
params.parameters = parameters;
copyAsMenu.add(new CommandContributionItem(params));
}
}
use of org.eclipse.ui.IWorkbenchPartSite in project dbeaver by dbeaver.
the class UIServiceSQLImpl method createSQLPanel.
@Override
public Object createSQLPanel(Object site, Object parent, DBPContextProvider contextProvider, String panelName, boolean showVerticalBar, String sqlText) throws DBException {
IWorkbenchPartSite partSite = (IWorkbenchPartSite) site;
Composite editorPH = (Composite) parent;
final SQLEditorBase editor = new SQLEditorBase() {
@Nullable
@Override
public DBCExecutionContext getExecutionContext() {
return contextProvider.getExecutionContext();
}
@Override
public void createPartControl(Composite parent) {
super.createPartControl(parent);
getAction(ITextEditorActionConstants.CONTEXT_PREFERENCES).setEnabled(false);
}
@Override
public boolean isFoldingEnabled() {
return false;
}
};
editor.setHasVerticalRuler(showVerticalBar);
try {
editor.init(new SubEditorSite(partSite), new StringEditorInput(panelName, sqlText, true, GeneralUtils.getDefaultFileEncoding()));
} catch (PartInitException e) {
throw new DBException("Error initializing SQL panel", e);
}
editor.createPartControl(editorPH);
editor.reloadSyntaxRules();
TextViewer textViewer = editor.getTextViewer();
textViewer.setData("editor", editor);
TextEditorUtils.enableHostEditorKeyBindingsSupport(partSite, textViewer.getTextWidget());
return textViewer;
}
Aggregations