use of org.eclipse.ui.IWorkbenchPartSite in project statecharts by Yakindu.
the class RenameElementHandler method isEnabled.
@Override
public boolean isEnabled() {
IWorkbenchWindow window = PlatformUI.getWorkbench().getActiveWorkbenchWindow();
if (window == null) {
return false;
}
IWorkbenchPartSite site = window.getActivePage().getActiveEditor().getSite();
if (site == null) {
return false;
}
ISelectionProvider selectionProvider = site.getSelectionProvider();
if (selectionProvider == null) {
return false;
}
ISelection currentSelection = selectionProvider.getSelection();
setContext(refactoring, currentSelection);
return refactoring.isExecutable();
}
use of org.eclipse.ui.IWorkbenchPartSite in project dsl-devkit by dsldevkit.
the class FixedHighlightingReconciler method getDisplay.
private Display getDisplay() {
XtextEditor editor = this.editor;
if (editor == null) {
return null;
}
IWorkbenchPartSite site = editor.getSite();
if (site == null) {
return null;
}
Shell shell = site.getShell();
if (shell == null || shell.isDisposed()) {
return null;
}
Display display = shell.getDisplay();
if (display == null || display.isDisposed()) {
return null;
}
return display;
}
use of org.eclipse.ui.IWorkbenchPartSite in project pmd-eclipse-plugin by pmd.
the class CPDCheckProjectAction method run.
/*
* @see org.eclipse.ui.IActionDelegate#run(IAction)
*/
public void run(final IAction action) {
// NOPMD:UnusedFormalParameter
final IWorkbenchPartSite site = targetPartSite();
final ISelection sel = site.getSelectionProvider().getSelection();
final Shell shell = site.getShell();
final String[] languages = LanguageFactory.supportedLanguages;
final String[] formats = { SIMPLE_KEY, XML_KEY, CSV_KEY };
final CPDCheckDialog dialog = new CPDCheckDialog(shell, languages, formats);
if (dialog.open() == Dialog.OK && sel instanceof IStructuredSelection) {
final StructuredSelection ss = (StructuredSelection) sel;
final Iterator<?> i = ss.iterator();
while (i.hasNext()) {
final Object obj = i.next();
if (obj instanceof IAdaptable) {
final IAdaptable adaptable = (IAdaptable) obj;
final IProject project = (IProject) adaptable.getAdapter(IProject.class);
if (project == null) {
LOG.warn("The selected object cannot adapt to a project");
LOG.debug(" -> selected object : " + obj);
} else {
this.detectCutAndPaste(project, dialog);
}
} else {
LOG.warn("The selected object is not adaptable");
LOG.debug(" -> selected object : " + obj);
}
}
}
}
use of org.eclipse.ui.IWorkbenchPartSite in project dbeaver by serge-rider.
the class NavigatorHandlerFilterObjectType method updateElement.
@Override
public void updateElement(UIElement element, Map parameters) {
DatabaseNavigatorTreeFilterObjectType objectType = CommonUtils.valueOf(DatabaseNavigatorTreeFilterObjectType.class, CommonUtils.toString(parameters.get("type")), DatabaseNavigatorTreeFilterObjectType.table);
DatabaseNavigatorTreeFilterObjectType curObjectType = DatabaseNavigatorTreeFilterObjectType.table;
IWorkbenchPartSite partSite = UIUtils.getWorkbenchPartSite(element.getServiceLocator());
if (partSite != null && partSite.getPart() instanceof DatabaseNavigatorView) {
curObjectType = ((DatabaseNavigatorView) partSite.getPart()).getNavigatorTree().getFilterObjectType();
}
String text, toolTip;
switch(objectType) {
case connection:
text = "Filter connections";
toolTip = "Filter connections by name";
break;
case container:
text = "Filter databases or schemas";
toolTip = "Filter containers (databases or schemas) by name";
break;
case table:
text = "Filter tables, procedures";
toolTip = "Filter objects (tables, procedures, users, etc) by name";
break;
default:
return;
}
element.setText(text);
element.setTooltip(toolTip);
element.setChecked(objectType == curObjectType);
}
use of org.eclipse.ui.IWorkbenchPartSite in project dbeaver by serge-rider.
the class ItemListControl method fillCustomActions.
@Override
public void fillCustomActions(IContributionManager contributionManager) {
super.fillCustomActions(contributionManager);
final DBNNode rootNode = getRootNode();
if (rootNode instanceof DBNDatabaseFolder && ((DBNDatabaseFolder) rootNode).getItemsMeta() != null) {
contributionManager.add(new Action(UINavigatorMessages.obj_editor_properties_control_action_filter_setting, DBeaverIcons.getImageDescriptor(UIIcon.FILTER)) {
@Override
public void run() {
NavigatorHandlerFilterConfig.configureFilters(getShell(), rootNode);
}
});
}
addColumnConfigAction(contributionManager);
IWorkbenchSite workbenchSite = getWorkbenchSite();
if (rootNode instanceof DBNDatabaseFolder) {
contributionManager.add(new Separator());
contributionManager.add(ActionUtils.makeCommandContribution(workbenchSite, NavigatorCommands.CMD_OBJECT_OPEN));
{
if (ObjectPropertyTester.canCreateObject(rootNode, true)) {
contributionManager.add(ActionUtils.makeCommandContribution(workbenchSite, NavigatorCommands.CMD_OBJECT_CREATE));
} else if (ObjectPropertyTester.canCreateObject(rootNode, false)) {
contributionManager.add(new Action(null, Action.AS_DROP_DOWN_MENU) {
{
setActionDefinitionId(NavigatorCommands.CMD_OBJECT_CREATE);
}
@Override
public void run() {
super.run();
}
@Override
public IMenuCreator getMenuCreator() {
return new MenuCreator(control -> {
List<IContributionItem> items = NavigatorHandlerObjectCreateNew.fillCreateMenuItems((IWorkbenchPartSite) workbenchSite, rootNode);
MenuManager menuManager = new MenuManager();
for (IContributionItem cc : items) {
menuManager.add(cc);
}
return menuManager;
});
}
});
}
}
contributionManager.add(ActionUtils.makeCommandContribution(workbenchSite, NavigatorCommands.CMD_OBJECT_DELETE));
}
if (rootNode instanceof DBNDatabaseNode && rootNode.isPersisted()) {
boolean hasReorder = false;
List<Class<?>> childrenTypes = ((DBNDatabaseNode) rootNode).getChildrenTypes(null);
for (Class<?> chilType : childrenTypes) {
if (DBWorkbench.getPlatform().getEditorsRegistry().getObjectManager(chilType, DBEObjectReorderer.class) != null) {
hasReorder = true;
break;
}
}
if (hasReorder) {
contributionManager.add(new Separator());
contributionManager.add(ActionUtils.makeCommandContribution(workbenchSite, NavigatorCommands.CMD_OBJECT_MOVE_UP));
contributionManager.add(ActionUtils.makeCommandContribution(workbenchSite, NavigatorCommands.CMD_OBJECT_MOVE_DOWN));
}
}
if (rootNode instanceof DBNDatabaseNode) {
// Expand/collapse
final List<DBXTreeNode> inlineMetas = collectInlineMetas((DBNDatabaseNode) rootNode, ((DBNDatabaseNode) rootNode).getMeta());
if (!inlineMetas.isEmpty()) {
contributionManager.add(new Separator());
contributionManager.add(ActionUtils.makeCommandContribution(workbenchSite, IWorkbenchCommandConstants.NAVIGATE_COLLAPSE_ALL, null, UIIcon.TREE_COLLAPSE_ALL));
contributionManager.add(ActionUtils.makeCommandContribution(workbenchSite, IWorkbenchCommandConstants.NAVIGATE_EXPAND_ALL, null, UIIcon.TREE_EXPAND_ALL));
}
}
// Save/revert
if (workbenchSite instanceof MultiPageEditorSite) {
final MultiPageEditorPart editor = ((MultiPageEditorSite) workbenchSite).getMultiPageEditor();
if (editor instanceof EntityEditor) {
contributionManager.add(new Separator());
DatabaseEditorUtils.contributeStandardEditorActions(workbenchSite, contributionManager);
}
}
}
Aggregations