use of com.intellij.openapi.fileEditor.impl.FileEditorManagerImpl in project intellij-community by JetBrains.
the class StructureViewWrapperImpl method checkUpdate.
private void checkUpdate() {
if (myProject.isDisposed())
return;
final Component owner = KeyboardFocusManager.getCurrentKeyboardFocusManager().getFocusOwner();
final boolean insideToolwindow = SwingUtilities.isDescendingFrom(myToolWindow.getComponent(), owner);
if (!myFirstRun && (insideToolwindow || JBPopupFactory.getInstance().isPopupActive())) {
return;
}
final DataContext dataContext = DataManager.getInstance().getDataContext(owner);
if (dataContext.getData(myKey) == this)
return;
if (CommonDataKeys.PROJECT.getData(dataContext) != myProject)
return;
final VirtualFile[] files = hasFocus() ? null : CommonDataKeys.VIRTUAL_FILE_ARRAY.getData(dataContext);
if (!myToolWindow.isVisible()) {
if (files != null && files.length > 0) {
myFile = files[0];
}
return;
}
if (files != null && files.length == 1) {
setFile(files[0]);
} else if (files != null && files.length > 1) {
setFile(null);
} else if (myFirstRun) {
final FileEditorManagerImpl editorManager = (FileEditorManagerImpl) FileEditorManager.getInstance(myProject);
final List<Pair<VirtualFile, EditorWindow>> history = editorManager.getSelectionHistory();
if (!history.isEmpty()) {
setFile(history.get(0).getFirst());
}
}
myFirstRun = false;
}
use of com.intellij.openapi.fileEditor.impl.FileEditorManagerImpl in project intellij-community by JetBrains.
the class HeavyFileEditorManagerTestCase method setUp.
public void setUp() throws Exception {
super.setUp();
myManager = new FileEditorManagerImpl(getProject(), DockManager.getInstance(getProject()));
((ComponentManagerImpl) getProject()).registerComponentInstance(FileEditorManager.class, myManager);
}
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]);
}
use of com.intellij.openapi.fileEditor.impl.FileEditorManagerImpl in project intellij-community by JetBrains.
the class FileEditorManagerEx method refreshIcons.
public void refreshIcons() {
if (this instanceof FileEditorManagerImpl) {
final FileEditorManagerImpl mgr = (FileEditorManagerImpl) this;
Set<EditorsSplitters> splitters = mgr.getAllSplitters();
for (EditorsSplitters each : splitters) {
for (VirtualFile file : mgr.getOpenFiles()) {
each.updateFileIcon(file);
}
}
}
}
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);
}
Aggregations