use of org.eclipse.ui.IWorkbenchPartSite in project liferay-ide by liferay.
the class EditorSiteAdapterService method convert.
@Override
public <A> A convert(Object object, Class<A> adapterType) {
A retval = null;
if (IEditorSite.class.equals(adapterType)) {
SapphirePart sapphirePart = context(SapphirePart.class);
Element localElement = sapphirePart.getLocalModelElement();
ITextEditor editor = localElement.adapt(ITextEditor.class);
IWorkbenchPartSite editorSite = editor.getSite();
if (editorSite instanceof IEditorSite) {
retval = adapterType.cast(editorSite);
}
}
return retval;
}
use of org.eclipse.ui.IWorkbenchPartSite in project liferay-ide by liferay.
the class IDEFormEditor method _validateEdit.
private void _validateEdit(IEditorInput input) {
InputContext context = fInputContextManager.getContext(input);
if (!context.validateEdit()) {
IWorkbenchPartSite site = getSite();
Shell shell = site.getShell();
shell.getDisplay().asyncExec(new Runnable() {
public void run() {
doRevert(context.getInput());
context.setValidated(false);
}
});
}
}
use of org.eclipse.ui.IWorkbenchPartSite in project webtools.sourceediting by eclipse.
the class ConfigurationPointCalculator method getConfigurationPoints.
public String[] getConfigurationPoints() {
List points = new ArrayList(2);
IWorkbenchPartSite site = null;
if (fPart != null) {
site = fPart.getSite();
if (site != null) {
String id = site.getId();
if (id != null && id.length() > 0 && !id.equals(fRootClass.getName()))
points.add(id);
}
if (site instanceof MultiPageEditorSite) {
String multipageID = ((MultiPageEditorSite) site).getMultiPageEditor().getSite().getId();
if (!points.contains(multipageID))
points.add(multipageID);
// $NON-NLS-1$
String sourcePageID = ((MultiPageEditorSite) site).getMultiPageEditor().getSite().getId() + ".source";
if (!points.contains(sourcePageID))
points.add(sourcePageID);
}
if (site instanceof MultiPageEditorSite) {
String multipageClassName = ((MultiPageEditorSite) site).getMultiPageEditor().getClass().getName();
if (!points.contains(multipageClassName))
points.add(multipageClassName);
}
Class editorClass = fPart.getClass();
while (editorClass != null && fRootClass != null && !editorClass.equals(fRootClass)) {
if (!points.contains(editorClass.getName()))
points.add(editorClass.getName());
editorClass = editorClass.getSuperclass();
}
}
if (fContentType != null) {
IContentType contentType = Platform.getContentTypeManager().getContentType(fContentType);
while (contentType != null && !contentType.getId().equals(IContentTypeManager.CT_TEXT)) {
if (!points.contains(contentType.getId()))
points.add(contentType.getId());
contentType = contentType.getBaseType();
}
}
if (fRootClass != null && !points.contains(fRootClass.getName()))
points.add(fRootClass.getName());
return (String[]) points.toArray(new String[0]);
}
use of org.eclipse.ui.IWorkbenchPartSite in project webtools.sourceediting by eclipse.
the class XSDMultiPageEditorContributor method setActivePage.
/*
* (non-JavaDoc) Method declared in
* AbstractMultiPageEditorActionBarContributor.
*/
public void setActivePage(IEditorPart part) {
if (activeEditorPart == part)
return;
activeEditorPart = part;
IActionBars actionBars = getActionBars();
boolean isSource = false;
if (activeEditorPart != null && activeEditorPart instanceof ITextEditor) {
isSource = true;
zoomInRetargetAction.setEnabled(false);
zoomOutRetargetAction.setEnabled(false);
captureScreenAction.setEnabled(false);
activateSourcePage(activeEditorPart, true);
} else {
activateSourcePage(xsdEditor, false);
if (part instanceof InternalXSDMultiPageEditor) {
xsdEditor = (InternalXSDMultiPageEditor) part;
}
if (xsdEditor != null) {
// cs: here's we ensure the UNDO and REDO actions are available when
// the design view is active
IWorkbenchPartSite site = xsdEditor.getSite();
if (site instanceof IEditorSite) {
ITextEditor textEditor = xsdEditor.getTextEditor();
IActionBars siteActionBars = ((IEditorSite) site).getActionBars();
siteActionBars.setGlobalActionHandler(ITextEditorActionConstants.UNDO, getAction(textEditor, ITextEditorActionConstants.UNDO));
siteActionBars.setGlobalActionHandler(ITextEditorActionConstants.REDO, getAction(textEditor, ITextEditorActionConstants.REDO));
siteActionBars.updateActionBars();
}
Object adapter = xsdEditor.getAdapter(ActionRegistry.class);
if (adapter instanceof ActionRegistry) {
ActionRegistry registry = (ActionRegistry) adapter;
actionBars.setGlobalActionHandler(ActionFactory.DELETE.getId(), registry.getAction(DeleteAction.ID));
actionBars.setGlobalActionHandler(GEFActionConstants.ZOOM_IN, registry.getAction(GEFActionConstants.ZOOM_IN));
actionBars.setGlobalActionHandler(GEFActionConstants.ZOOM_OUT, registry.getAction(GEFActionConstants.ZOOM_OUT));
actionBars.setGlobalActionHandler(ActionFactory.PRINT.getId(), registry.getAction(ActionFactory.PRINT.getId()));
actionBars.setGlobalActionHandler(ActionFactory.SELECT_ALL.getId(), registry.getAction(ActionFactory.SELECT_ALL.getId()));
zoomInRetargetAction.setEnabled(true);
zoomOutRetargetAction.setEnabled(true);
captureScreenAction.setEnabled(true);
}
}
}
if (actionBars != null) {
// update menu bar and tool bar
actionBars.updateActionBars();
}
if (zoomComboContributionItem != null) {
zoomComboContributionItem.setVisible(!isSource);
zoomComboContributionItem.update();
// Bug 254772 - parent contribution manager should not be null. We added this item already.
// Force the ToolBarManager to update/redraw the items
zoomComboContributionItem.getParent().update(true);
}
}
use of org.eclipse.ui.IWorkbenchPartSite in project webtools.sourceediting by eclipse.
the class XSDSearchReferencesGroupActionDelegate method fillMenu.
protected void fillMenu(Menu menu) {
try {
if (fSelection == null) {
return;
}
if (workbenchPart != null) {
IWorkbenchPartSite site = workbenchPart.getSite();
if (site == null)
return;
IEditorPart editor = site.getPage().getActiveEditor();
if (editor != null) {
ReferencesSearchGroup referencesGroup = new ReferencesSearchGroup(editor);
XSDSearchGroupSubMenu subMenu = new XSDSearchGroupSubMenu(referencesGroup);
subMenu.fill(menu, -1);
}
}
} catch (Exception e) {
e.printStackTrace();
}
}
Aggregations