use of org.eclipse.ui.testing.ContributionInfo in project eclipse.platform.ui by eclipse-platform.
the class CompatibilityEditor method createPartControl.
@Override
protected boolean createPartControl(final IWorkbenchPart legacyPart, Composite parent) {
super.createPartControl(legacyPart, parent);
clearMenuItems();
part.getContext().set(IEditorPart.class, (IEditorPart) legacyPart);
EditorDescriptor descriptor = reference.getDescriptor();
if (descriptor != null) {
IConfigurationElement element = descriptor.getConfigurationElement();
if (element != null) {
String iconURI = MenuHelper.getIconURI(element, IWorkbenchRegistryConstants.ATT_ICON);
part.setIconURI(iconURI);
}
if (descriptor.getPluginId() != null) {
parent.setData(new ContributionInfo(descriptor.getPluginId(), ContributionInfoMessages.ContributionInfo_Editor, null));
}
}
if (legacyPart instanceof AbstractMultiEditor && !(legacyPart instanceof MultiEditor)) {
try {
createMultiEditorChildren(legacyPart, reference.getEditorInput());
} catch (PartInitException e) {
handlePartInitException(e);
return false;
}
}
return true;
}
use of org.eclipse.ui.testing.ContributionInfo in project eclipse.platform.ui by eclipse-platform.
the class CompatibilityView method createPartControl.
@Override
protected boolean createPartControl(IWorkbenchPart legacyPart, Composite parent) {
clearMenuItems();
part.getContext().set(IViewPart.class, (IViewPart) legacyPart);
final IEclipseContext partContext = getModel().getContext();
IRendererFactory rendererFactory = partContext.get(IRendererFactory.class);
// Some views (i.e. Console) require that the actual ToolBar be
// instantiated before they are
final IActionBars actionBars = ((IViewPart) legacyPart).getViewSite().getActionBars();
ToolBarManager tbm = (ToolBarManager) actionBars.getToolBarManager();
Composite toolBarParent = new Composite(parent, SWT.NONE);
tbm.createControl(toolBarParent);
MenuManager mm = (MenuManager) actionBars.getMenuManager();
MMenu menu = getViewMenu();
if (menu == null) {
menu = modelService.createModelElement(MMenu.class);
// If the id contains a ':' use the part before it as the descriptor
// id
String partId = part.getElementId();
int colonIndex = partId.indexOf(':');
String descId = colonIndex == -1 ? partId : partId.substring(0, colonIndex);
menu.setElementId(descId);
menu.getTags().add(StackRenderer.TAG_VIEW_MENU);
menu.getTags().add(ContributionsAnalyzer.MC_MENU);
part.getMenus().add(menu);
}
AbstractPartRenderer apr = rendererFactory.getRenderer(menu, parent);
if (apr instanceof MenuManagerRenderer) {
MenuManagerRenderer renderer = (MenuManagerRenderer) apr;
renderer.linkModelToManager(menu, mm);
}
// Construct the toolbar (if necessary)
MToolBar toolbar = part.getToolbar();
if (toolbar == null) {
toolbar = modelService.createModelElement(MToolBar.class);
// If the id contains a ':' use the part before it as the descriptor
// id
String partId = part.getElementId();
int colonIndex = partId.indexOf(':');
String descId = colonIndex == -1 ? partId : partId.substring(0, colonIndex);
toolbar.setElementId(descId);
part.setToolbar(toolbar);
} else {
// clear out the model entries so they can be re-created by
// contributions
// see https://bugs.eclipse.org/bugs/show_bug.cgi?id=402561
toolbar.getChildren().clear();
}
apr = rendererFactory.getRenderer(toolbar, parent);
if (apr instanceof ToolBarManagerRenderer) {
((ToolBarManagerRenderer) apr).linkModelToManager(toolbar, tbm);
}
super.createPartControl(legacyPart, parent);
ViewDescriptor desc = reference.getDescriptor();
if (desc != null && desc.getPluginId() != null) {
parent.setData(new ContributionInfo(desc.getPluginId(), ContributionInfoMessages.ContributionInfo_View, null));
}
// dispose the tb, it will be re-created when the tab is shown
toolBarParent.dispose();
apr = rendererFactory.getRenderer(menu, parent);
if (apr instanceof MenuManagerRenderer) {
MenuManagerRenderer renderer = (MenuManagerRenderer) apr;
// create opaque items for any contribution items that were added
// directly to the manager
renderer.reconcileManagerToModel(mm, menu);
}
apr = rendererFactory.getRenderer(toolbar, parent);
if (apr instanceof ToolBarManagerRenderer) {
// create opaque items for any contribution items that were added
// directly to the manager
((ToolBarManagerRenderer) apr).reconcileManagerToModel(tbm, toolbar);
}
final AtomicBoolean toolbarContributed = new AtomicBoolean();
final IContextFunction func = new ContextFunction() {
@Override
public Object compute(IEclipseContext context, String contextKey) {
if (toolbarContributed.getAndSet(true)) {
// fix for bug 448873: don't contribute to the toolbar twice
return null;
}
final ViewActionBuilder actionBuilder = new ViewActionBuilder();
actionBuilder.readActionExtensions(getView());
ActionDescriptor[] actionDescriptors = actionBuilder.getExtendedActions();
if (actionDescriptors != null) {
IHandlerService hs = partContext.get(IHandlerService.class);
for (ActionDescriptor actionDescriptor : actionDescriptors) {
if (actionDescriptor != null) {
IAction action = actionDescriptor.getAction();
if (action != null && action.getActionDefinitionId() != null) {
hs.activateHandler(action.getActionDefinitionId(), new ActionHandler(action));
}
}
}
}
actionBars.updateActionBars();
Runnable dispose = actionBuilder::dispose;
return dispose;
}
};
if (toolbar.getWidget() == null) {
toolbar.getTransientData().put(ToolBarManagerRenderer.POST_PROCESSING_FUNCTION, func);
} else {
toolbar.getTransientData().put(ToolBarManagerRenderer.POST_PROCESSING_DISPOSE, func.compute(partContext, null));
}
return true;
}
use of org.eclipse.ui.testing.ContributionInfo in project eclipse.platform.ui by eclipse-platform.
the class PluginContributionAdapterFactory method getAdapter.
@Override
public <T> T getAdapter(Object adaptableObject, Class<T> adapterType) {
if (adapterType != ContributionInfo.class) {
return null;
}
if (adaptableObject instanceof IPluginContribution) {
IPluginContribution contribution = (IPluginContribution) adaptableObject;
String elementType;
if (contribution instanceof EditorDescriptor) {
elementType = ContributionInfoMessages.ContributionInfo_Editor;
} else if (contribution instanceof ViewDescriptor) {
elementType = ContributionInfoMessages.ContributionInfo_View;
} else if (contribution instanceof ActionSetDescriptor) {
elementType = ContributionInfoMessages.ContributionInfo_ActionSet;
} else if (contribution instanceof Category) {
elementType = ContributionInfoMessages.ContributionInfo_Category;
} else if (contribution instanceof IViewCategory) {
elementType = ContributionInfoMessages.ContributionInfo_Category;
} else if (contribution instanceof ThemeElementCategory) {
elementType = ContributionInfoMessages.ContributionInfo_Category;
} else if (contribution instanceof WizardCollectionElement) {
elementType = ContributionInfoMessages.ContributionInfo_Category;
} else if (contribution instanceof ColorDefinition) {
elementType = ContributionInfoMessages.ContributionInfo_ColorDefinition;
} else if (contribution instanceof WorkbenchWizardElement) {
elementType = ContributionInfoMessages.ContributionInfo_Wizard;
} else if (contribution instanceof PerspectiveDescriptor) {
elementType = ContributionInfoMessages.ContributionInfo_Perspective;
} else if (contribution instanceof WorkbenchPreferenceExpressionNode) {
elementType = ContributionInfoMessages.ContributionInfo_Page;
} else if (contribution instanceof DecoratorDefinition) {
elementType = ContributionInfoMessages.ContributionInfo_LabelDecoration;
} else {
elementType = ContributionInfoMessages.ContributionInfo_Unknown;
}
return adapterType.cast(new ContributionInfo(contribution.getPluginId(), elementType, null));
}
if (adaptableObject instanceof JobInfo) {
JobInfo jobInfo = (JobInfo) adaptableObject;
Job job = jobInfo.getJob();
if (job != null) {
Bundle bundle = FrameworkUtil.getBundle(job.getClass());
if (bundle != null) {
return adapterType.cast(new ContributionInfo(bundle.getSymbolicName(), ContributionInfoMessages.ContributionInfo_Job, null));
}
}
}
return null;
}
use of org.eclipse.ui.testing.ContributionInfo in project eclipse.platform.ui by eclipse-platform.
the class StartupPreferencePage method createEarlyStartupSelection.
protected void createEarlyStartupSelection(Composite parent) {
Label label = new Label(parent, SWT.NONE);
label.setText(WorkbenchMessages.StartupPreferencePage_label);
label.setFont(parent.getFont());
GridData data = new GridData(GridData.FILL_HORIZONTAL);
label.setLayoutData(data);
pluginsList = new Table(parent, SWT.BORDER | SWT.CHECK | SWT.H_SCROLL | SWT.V_SCROLL);
data = new GridData(GridData.FILL_BOTH);
pluginsList.setFont(parent.getFont());
pluginsList.setLayoutData(data);
TableViewer viewer = new TableViewer(pluginsList);
viewer.setLabelProvider(new LabelProvider() {
@Override
public String getText(Object element) {
return Platform.getBundle(((ContributionInfo) element).getBundleId()).getHeaders().get(Constants.BUNDLE_NAME);
}
});
viewer.setContentProvider(ArrayContentProvider.getInstance());
viewer.setInput(workbench.getEarlyActivatedPlugins());
updateCheckState();
}
use of org.eclipse.ui.testing.ContributionInfo in project eclipse.platform.ui by eclipse-platform.
the class StartupPreferencePage method updateCheckState.
private void updateCheckState() {
HashSet<String> disabledPlugins = new HashSet<>(Arrays.asList(workbench.getDisabledEarlyActivatedPlugins()));
for (int i = 0; i < pluginsList.getItemCount(); i++) {
TableItem item = pluginsList.getItem(i);
String pluginId = ((ContributionInfo) item.getData()).getBundleId();
item.setChecked(!disabledPlugins.contains(pluginId));
}
}
Aggregations