use of com.intellij.ide.impl.DataManagerImpl in project intellij-community by JetBrains.
the class ModuleRule method getData.
@Override
public Object getData(DataProvider dataProvider) {
Object moduleContext = LangDataKeys.MODULE_CONTEXT.getData(dataProvider);
if (moduleContext != null) {
return moduleContext;
}
Project project = CommonDataKeys.PROJECT.getData(dataProvider);
if (project == null) {
PsiElement element = CommonDataKeys.PSI_ELEMENT.getData(dataProvider);
if (element == null) {
PsiElement[] psiElements = LangDataKeys.PSI_ELEMENT_ARRAY.getData(dataProvider);
if (psiElements != null && psiElements.length > 0) {
element = psiElements[0];
}
}
if (element == null || !element.isValid())
return null;
project = element.getProject();
}
VirtualFile[] files = CommonDataKeys.VIRTUAL_FILE_ARRAY.getData(dataProvider);
if (files == null) {
GetDataRule dataRule = ((DataManagerImpl) DataManager.getInstance()).getDataRule(CommonDataKeys.VIRTUAL_FILE_ARRAY.getName());
if (dataRule != null) {
files = (VirtualFile[]) dataRule.getData(dataProvider);
}
}
if (files == null) {
return null;
}
Module singleModule = null;
for (VirtualFile file : files) {
Module module = ModuleUtilCore.findModuleForFile(file, project);
if (module == null) {
return null;
}
if (singleModule == null) {
singleModule = module;
} else if (module != singleModule) {
return null;
}
}
return singleModule;
}
use of com.intellij.ide.impl.DataManagerImpl in project intellij-community by JetBrains.
the class IdeMenuBar method updateMenuActions.
void updateMenuActions() {
myNewVisibleActions.clear();
if (!myDisabled) {
DataContext dataContext = ((DataManagerImpl) myDataManager).getDataContextTest(this);
expandActionGroup(dataContext, myNewVisibleActions, myActionManager);
}
if (!myNewVisibleActions.equals(myVisibleActions)) {
// should rebuild UI
final boolean changeBarVisibility = myNewVisibleActions.isEmpty() || myVisibleActions.isEmpty();
final List<AnAction> temp = myVisibleActions;
myVisibleActions = myNewVisibleActions;
myNewVisibleActions = temp;
removeAll();
final boolean enableMnemonics = !UISettings.getInstance().getDisableMnemonics();
for (final AnAction action : myVisibleActions) {
add(new ActionMenu(null, ActionPlaces.MAIN_MENU, (ActionGroup) action, myPresentationFactory, enableMnemonics, true));
}
fixMenuBackground();
updateMnemonicsVisibility();
if (myClockPanel != null) {
add(myClockPanel);
add(myButton);
}
validate();
if (changeBarVisibility) {
invalidate();
final JFrame frame = (JFrame) SwingUtilities.getAncestorOfClass(JFrame.class, this);
if (frame != null) {
frame.validate();
}
}
}
}
Aggregations