use of com.intellij.openapi.ui.ThreeComponentsSplitter in project intellij-community by JetBrains.
the class EditorWindow method closeFile.
public void closeFile(@NotNull final VirtualFile file, final boolean disposeIfNeeded, final boolean transferFocus) {
final FileEditorManagerImpl editorManager = getManager();
editorManager.runChange(splitters -> {
final List<EditorWithProviderComposite> editors = splitters.findEditorComposites(file);
if (editors.isEmpty())
return;
try {
final EditorWithProviderComposite editor = findFileComposite(file);
final FileEditorManagerListener.Before beforePublisher = editorManager.getProject().getMessageBus().syncPublisher(FileEditorManagerListener.Before.FILE_EDITOR_MANAGER);
beforePublisher.beforeFileClosed(editorManager, file);
if (myTabbedPane != null && editor != null) {
final int componentIndex = findComponentIndex(editor.getComponent());
if (componentIndex >= 0) {
final int indexToSelect = calcIndexToSelect(file, componentIndex);
Pair<String, Integer> pair = Pair.create(file.getUrl(), componentIndex);
myRemovedTabs.push(pair);
if (myTabsHidingInProgress.get()) {
myHiddenTabs.push(pair);
}
myTabbedPane.removeTabAt(componentIndex, indexToSelect, transferFocus);
editorManager.disposeComposite(editor);
}
} else {
if (inSplitter()) {
Splitter splitter = (Splitter) myPanel.getParent();
JComponent otherComponent = splitter.getOtherComponent(myPanel);
if (otherComponent != null) {
IdeFocusManager.findInstance().requestFocus(otherComponent, true);
}
}
myPanel.removeAll();
if (editor != null) {
editorManager.disposeComposite(editor);
}
}
if (disposeIfNeeded && getTabCount() == 0) {
removeFromSplitter();
if (UISettings.getInstance().getEditorTabPlacement() == UISettings.TABS_NONE) {
final EditorsSplitters owner = getOwner();
if (owner != null) {
final ThreeComponentsSplitter splitter = UIUtil.getParentOfType(ThreeComponentsSplitter.class, owner);
if (splitter != null) {
splitter.revalidate();
splitter.repaint();
}
}
}
} else {
myPanel.revalidate();
if (myTabbedPane == null) {
myPanel.repaint();
}
}
} finally {
editorManager.removeSelectionRecord(file, this);
editorManager.notifyPublisher(() -> {
final Project project = editorManager.getProject();
if (!project.isDisposed()) {
final FileEditorManagerListener afterPublisher = project.getMessageBus().syncPublisher(FileEditorManagerListener.FILE_EDITOR_MANAGER);
afterPublisher.fileClosed(editorManager, file);
}
});
splitters.afterFileClosed(file);
}
}, myOwner);
}
use of com.intellij.openapi.ui.ThreeComponentsSplitter in project android by JetBrains.
the class WorkBenchTest method before.
@Before
public void before() {
initMocks(this);
myContent = new JPanel();
myContent.setPreferredSize(new Dimension(500, 400));
mySplitter = new ThreeComponentsSplitter();
Project project = ProjectManager.getInstance().getDefaultProject();
myPropertiesComponent = PropertiesComponent.getInstance();
myWorkBenchManager = WorkBenchManager.getInstance();
myFloatingToolWindowManager = FloatingToolWindowManager.getInstance(project);
FileEditorManager fileEditorManager = FileEditorManager.getInstance(project);
myModel = new SideModel<>(project);
myLeftMinimizePanel = spy(new MinimizedPanel<>(Side.RIGHT, myModel));
myLeftMinimizePanel.setLayout(new BoxLayout(myLeftMinimizePanel, BoxLayout.Y_AXIS));
myRightMinimizePanel = spy(new MinimizedPanel<>(Side.RIGHT, myModel));
myRightMinimizePanel.setLayout(new BoxLayout(myRightMinimizePanel, BoxLayout.Y_AXIS));
WorkBench.InitParams<String> initParams = new WorkBench.InitParams<>(myModel, mySplitter, myLeftMinimizePanel, myRightMinimizePanel);
myWorkBench = new WorkBench<>(project, "BENCH", myFileEditor, initParams);
JRootPane rootPane = new JRootPane();
rootPane.add(myWorkBench);
List<ToolWindowDefinition<String>> definitions = ImmutableList.of(PalettePanelToolContent.getDefinition(), PalettePanelToolContent.getOtherDefinition(), PalettePanelToolContent.getThirdDefinition());
myWorkBench.init(myContent, "CONTEXT", definitions);
myToolWindow1 = myModel.getAllTools().get(0);
myToolWindow2 = myModel.getAllTools().get(1);
myToolWindow3 = myModel.getAllTools().get(2);
when(fileEditorManager.getSelectedEditors()).thenReturn(new FileEditor[] { myFileEditor, myFileEditor2 });
verify(myWorkBenchManager).register(eq(myWorkBench));
verify(myFloatingToolWindowManager).register(eq(myFileEditor), eq(myWorkBench));
reset(myWorkBenchManager, myFloatingToolWindowManager);
}
use of com.intellij.openapi.ui.ThreeComponentsSplitter in project android by JetBrains.
the class LayersManager method createContent.
@Override
protected LightToolWindow createContent(@NotNull DesignerEditorPanelFacade designer) {
if (!(designer instanceof LayeredImageEditorPanel)) {
return null;
}
LightToolWindow toolWindow = (LightToolWindow) designer.getClientProperty(getComponentName());
if (toolWindow != null) {
return toolWindow;
}
LayersPanel layersPanel = new LayersPanel();
layersPanel.setImage(getImage(designer));
PropertiesComponent propertiesComponent = PropertiesComponent.getInstance(myProject);
// When LightToolWindowManager#getEditorMode() is public (or a constructor which lets
// me not specify it) is available and upstreamed, replace the following with just
// anchor = getEditorMode() :
String value = propertiesComponent.getValue(myEditorModeKey);
ToolWindowAnchor anchor;
if (value == null) {
anchor = getAnchor();
} else {
anchor = value.equals("ToolWindow") ? null : ToolWindowAnchor.fromText(value);
}
ThreeComponentsSplitter contentSplitter = designer.getContentSplitter();
if (contentSplitter.getInnerComponent() == null) {
// This is a fix for http://b.android.com/219047
return null;
}
return new LightToolWindow(layersPanel, "Image Layers", AllIcons.Toolwindows.ToolWindowPalette, layersPanel, layersPanel, contentSplitter, anchor, this, myProject, propertiesComponent, getVisibilityKeyName(designer), 200, null);
}
Aggregations