use of com.intellij.openapi.fileEditor.impl.FileEditorManagerImpl in project intellij-community by JetBrains.
the class ProjectImpl method distributeProgress.
private void distributeProgress() {
ProgressIndicator indicator = ProgressManager.getInstance().getProgressIndicator();
if (indicator == null)
return;
ModuleManager moduleManager = ModuleManager.getInstance(this);
if (!(moduleManager instanceof ModuleManagerImpl)) {
return;
}
double toDistribute = 1 - indicator.getFraction();
int modulesCount = ((ModuleManagerImpl) moduleManager).getModulePathsCount();
EditorsSplitters splitters = ((FileEditorManagerImpl) FileEditorManager.getInstance(this)).getMainSplitters();
int editors = splitters.getEditorsCount();
double modulesPart = ourClassesAreLoaded || editors == 0 ? toDistribute : toDistribute * 0.5;
if (modulesCount != 0) {
double step = modulesPart / modulesCount;
((ModuleManagerImpl) moduleManager).setProgressStep(step);
}
if (editors != 0) {
splitters.setProgressStep(toDistribute - modulesPart / editors);
}
}
use of com.intellij.openapi.fileEditor.impl.FileEditorManagerImpl in project intellij-community by JetBrains.
the class EditorNotificationActions method collectDescriptorsForEditor.
public static void collectDescriptorsForEditor(@NotNull Editor editor, @NotNull List<HighlightInfo.IntentionActionDescriptor> descriptors) {
Project project = editor.getProject();
if (project == null)
return;
FileEditorManager fileEditorManager = FileEditorManager.getInstance(project);
if (!(fileEditorManager instanceof FileEditorManagerImpl))
return;
TextEditor fileEditor = TextEditorProvider.getInstance().getTextEditor(editor);
List<JComponent> components = ((FileEditorManagerImpl) fileEditorManager).getTopComponents(fileEditor);
for (JComponent component : components) {
if (component instanceof IntentionActionProvider) {
IntentionActionWithOptions action = ((IntentionActionProvider) component).getIntentionAction();
if (action != null) {
descriptors.add(new HighlightInfo.IntentionActionDescriptor(action, action.getOptions(), null));
}
}
}
}
use of com.intellij.openapi.fileEditor.impl.FileEditorManagerImpl in project android by JetBrains.
the class ConfigurationMatcher method selectConfigMatch.
@NotNull
private ConfigMatch selectConfigMatch(@NotNull List<ConfigMatch> matches) {
List<String> deviceIds = myManager.getStateManager().getProjectState().getDeviceIds();
Map<String, Integer> idRank = Maps.newHashMapWithExpectedSize(deviceIds.size());
int rank = 0;
for (String id : deviceIds) {
idRank.put(id, rank++);
}
// API 11-13: look for a x-large device
Comparator<ConfigMatch> comparator = null;
IAndroidTarget projectTarget = myManager.getProjectTarget();
if (projectTarget != null) {
int apiLevel = projectTarget.getVersion().getFeatureLevel();
if (apiLevel >= 11 && apiLevel < 14) {
// TODO: Maybe check the compatible-screen tag in the manifest to figure out
// what kind of device should be used for display.
comparator = new TabletConfigComparator(idRank);
}
}
if (comparator == null) {
// lets look for a high density device
comparator = new PhoneConfigComparator(idRank);
}
Collections.sort(matches, comparator);
// Look at the currently active editor to see if it's a layout editor, and if so,
// look up its configuration and if the configuration is in our match list,
// use it. This means we "preserve" the current configuration when you open
// new layouts.
// TODO: This is running too late for the layout preview; the new editor has
// already taken over so getSelectedTextEditor() returns self. Perhaps we
// need to fish in the open editors instead.
// We use FileEditorManagerImpl instead of FileEditorManager to get access to the lock-free version
// (also used by DebuggerContextUtil) since the normal method only works from the dispatch thread
// (grabbing a read lock is not enough).
FileEditorManager editorManager = FileEditorManager.getInstance(myManager.getProject());
if (editorManager instanceof FileEditorManagerImpl) {
// not the case under test fixtures apparently
Editor activeEditor = ((FileEditorManagerImpl) editorManager).getSelectedTextEditor(true);
if (activeEditor != null) {
FileDocumentManager documentManager = FileDocumentManager.getInstance();
VirtualFile file = documentManager.getFile(activeEditor.getDocument());
if (file != null && !file.equals(myFile) && file.getFileType() == StdFileTypes.XML && ResourceHelper.getFolderType(myFile) == ResourceHelper.getFolderType(file)) {
Configuration configuration = myManager.getConfiguration(file);
FolderConfiguration fullConfig = configuration.getFullConfig();
for (ConfigMatch match : matches) {
if (fullConfig.equals(match.testConfig)) {
return match;
}
}
}
}
}
// the list has been sorted so that the first item is the best config
return matches.get(0);
}
use of com.intellij.openapi.fileEditor.impl.FileEditorManagerImpl in project android by JetBrains.
the class HprofEditorFixture method findByFileName.
@NotNull
public static HprofEditorFixture findByFileName(@NotNull Robot robot, @NotNull final IdeFrameFixture frame, @NotNull final String hprofFileName) {
HprofEditor hprofEditor = GuiQuery.getNonNull(() -> {
FileEditor[] openEditors = null;
FileEditorManagerImpl fileEditorManager = (FileEditorManagerImpl) FileEditorManager.getInstance(frame.getProject());
for (EditorsSplitters splitters : fileEditorManager.getAllSplitters()) {
for (EditorWindow window : splitters.getWindows()) {
for (EditorWithProviderComposite editorWithProviderComposite : window.getEditors()) {
if (editorWithProviderComposite.getFile().getName().endsWith(hprofFileName)) {
if (openEditors != null) {
throw new ComponentLookupException(String.format("More than one Hprof editor for file '%s' found", hprofFileName));
}
openEditors = editorWithProviderComposite.getEditors();
}
}
}
}
if (openEditors == null) {
throw new ComponentLookupException(String.format("Cannot find any open Hprof editors for file '%s'", hprofFileName));
}
HprofEditor targetEditor = null;
for (FileEditor editor : openEditors) {
if (editor instanceof HprofEditor) {
if (targetEditor != null) {
throw new ComponentLookupException(String.format("More than one Hprof editor pane for file '%s' found", hprofFileName));
} else {
targetEditor = (HprofEditor) editor;
}
}
}
return targetEditor;
});
return new HprofEditorFixture(robot, frame, hprofEditor);
}
use of com.intellij.openapi.fileEditor.impl.FileEditorManagerImpl in project intellij-community by JetBrains.
the class EditSourceInNewWindowAction method actionPerformed.
@Override
public void actionPerformed(AnActionEvent e) {
Project project = e.getRequiredData(CommonDataKeys.PROJECT);
final FileEditorManager manager = FileEditorManager.getInstance(project);
((FileEditorManagerImpl) manager).openFileInNewWindow(getVirtualFiles(e)[0]);
}
Aggregations