use of org.eclipse.ui.IWorkbenchPartSite in project liferay-ide by liferay.
the class IDEFormEditor method setSelection.
public void setSelection(ISelection selection) {
IWorkbenchPartSite site = getSite();
site.getSelectionProvider().setSelection(selection);
getContributor().updateSelectableActions(selection);
}
use of org.eclipse.ui.IWorkbenchPartSite in project dbeaver by serge-rider.
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 serge-rider.
the class ResultSetHandlerToggleMode method updateElement.
@Override
public void updateElement(UIElement element, Map parameters) {
if (element.getServiceLocator() instanceof IWorkbenchPartSite) {
IWorkbenchPartSite partSite = (IWorkbenchPartSite) element.getServiceLocator();
if (partSite.getPart() instanceof IResultSetContainer) {
IResultSetController rsv = ((IResultSetContainer) partSite.getPart()).getResultSetController();
if (rsv != null) {
if (!rsv.isRecordMode()) {
element.setText("Switch to record mode");
element.setChecked(true);
} else {
element.setText("Switch to grid mode");
element.setChecked(false);
}
}
}
}
}
use of org.eclipse.ui.IWorkbenchPartSite in project dbeaver by serge-rider.
the class OracleTaskHandler method getOracleSourceObjects.
protected List<OracleSourceObject> getOracleSourceObjects(UIElement element) {
List<OracleSourceObject> objects = new ArrayList<>();
IWorkbenchPartSite partSite = UIUtils.getWorkbenchPartSite(element.getServiceLocator());
if (partSite != null) {
final ISelectionProvider selectionProvider = partSite.getSelectionProvider();
if (selectionProvider != null) {
ISelection selection = selectionProvider.getSelection();
if (selection instanceof IStructuredSelection && !selection.isEmpty()) {
for (Iterator<?> iter = ((IStructuredSelection) selection).iterator(); iter.hasNext(); ) {
final Object item = iter.next();
final OracleSourceObject sourceObject = RuntimeUtils.getObjectAdapter(item, OracleSourceObject.class);
if (sourceObject != null) {
objects.add(sourceObject);
}
}
}
}
if (objects.isEmpty()) {
final IWorkbenchPart activePart = partSite.getPart();
final OracleSourceObject sourceObject = RuntimeUtils.getObjectAdapter(activePart, OracleSourceObject.class);
if (sourceObject != null) {
objects.add(sourceObject);
}
}
}
return objects;
}
use of org.eclipse.ui.IWorkbenchPartSite in project dbeaver by serge-rider.
the class ResultSetStatListener method handleResultSetSelectionChange.
@Override
public void handleResultSetSelectionChange(SelectionChangedEvent event) {
IResultSetSelection selection = viewer.getSelection();
IWorkbenchPartSite site = viewer.getSite();
if (site instanceof IEditorSite) {
// Use job with 100ms delay to avoid event spam
if (this.updateJob == null) {
this.updateJob = new SLUpdateJob();
}
this.updateJob.schedule(100);
}
}
Aggregations