mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
cleanup, lambdify
This commit is contained in:
@@ -29,6 +29,7 @@ import java.util.EventListener;
|
||||
* @see UISettings#fireUISettingsChanged()
|
||||
* @see com.intellij.util.ComponentTreeEventDispatcher
|
||||
*/
|
||||
@FunctionalInterface
|
||||
public interface UISettingsListener extends EventListener {
|
||||
|
||||
Topic<UISettingsListener> TOPIC = Topic.create("UI settings", UISettingsListener.class);
|
||||
|
||||
+12
-19
@@ -84,7 +84,7 @@ public abstract class EditorComposite implements Disposable {
|
||||
* "close non modified editors first" feature.
|
||||
*/
|
||||
private final long myInitialFileTimeStamp;
|
||||
protected TabbedPaneWrapper myTabbedPaneWrapper;
|
||||
TabbedPaneWrapper myTabbedPaneWrapper;
|
||||
private final MyComponent myComponent;
|
||||
private final FocusWatcher myFocusWatcher;
|
||||
/**
|
||||
@@ -97,12 +97,12 @@ public abstract class EditorComposite implements Disposable {
|
||||
private final Map<FileEditor, String> myDisplayNames = ContainerUtil.newHashMap();
|
||||
|
||||
/**
|
||||
* @param file <code>file</code> for which composite is being constructed
|
||||
* @param file {@code file} for which composite is being constructed
|
||||
*
|
||||
* @param editors <code>edittors</code> that should be placed into the composite
|
||||
* @param editors {@code edittors} that should be placed into the composite
|
||||
*
|
||||
* @exception java.lang.IllegalArgumentException if <code>editors</code>
|
||||
* is <code>null</code> or <code>providers</code> is <code>null</code> or <code>myEditor</code> arrays is empty
|
||||
* @exception IllegalArgumentException if {@code editors}
|
||||
* is {@code null} or {@code providers} is {@code null} or {@code myEditor} arrays is empty
|
||||
*/
|
||||
EditorComposite(@NotNull final VirtualFile file,
|
||||
@NotNull final FileEditor[] editors,
|
||||
@@ -162,13 +162,8 @@ public abstract class EditorComposite implements Disposable {
|
||||
private TabbedPaneWrapper.AsJBTabs createTabbedPaneWrapper(FileEditor[] editors) {
|
||||
PrevNextActionsDescriptor descriptor = new PrevNextActionsDescriptor(IdeActions.ACTION_NEXT_EDITOR_TAB, IdeActions.ACTION_PREVIOUS_EDITOR_TAB);
|
||||
final TabbedPaneWrapper.AsJBTabs wrapper = new TabbedPaneWrapper.AsJBTabs(myFileEditorManager.getProject(), SwingConstants.BOTTOM, descriptor, this);
|
||||
wrapper.getTabs().getPresentation().setPaintBorder(0, 0, 0, 0).setTabSidePaintBorder(1).setGhostsAlwaysVisible(true).setUiDecorator(new UiDecorator() {
|
||||
@Override
|
||||
@NotNull
|
||||
public UiDecoration getDecoration() {
|
||||
return new UiDecoration(null, new Insets(0, 8, 0, 8));
|
||||
}
|
||||
});
|
||||
wrapper.getTabs().getPresentation().setPaintBorder(0, 0, 0, 0).setTabSidePaintBorder(1).setGhostsAlwaysVisible(true).setUiDecorator(
|
||||
() -> new UiDecorator.UiDecoration(null, new Insets(0, 8, 0, 8)));
|
||||
wrapper.getTabs().getComponent().setBorder(new EmptyBorder(0, 0, 1, 0));
|
||||
|
||||
boolean firstEditor = true;
|
||||
@@ -277,7 +272,7 @@ public abstract class EditorComposite implements Disposable {
|
||||
}
|
||||
|
||||
@NotNull
|
||||
public List<JComponent> getTopComponents(@NotNull FileEditor editor) {
|
||||
List<JComponent> getTopComponents(@NotNull FileEditor editor) {
|
||||
return getTopBottomComponents(editor, true);
|
||||
}
|
||||
|
||||
@@ -397,7 +392,7 @@ public abstract class EditorComposite implements Disposable {
|
||||
}
|
||||
|
||||
/**
|
||||
* @return <code>true</code> if the composite contains at least one
|
||||
* @return {@code true} if the composite contains at least one
|
||||
* modified myEditor
|
||||
*/
|
||||
public boolean isModified(){
|
||||
@@ -441,7 +436,7 @@ public abstract class EditorComposite implements Disposable {
|
||||
|
||||
@Override
|
||||
public boolean requestFocusInWindow() {
|
||||
return myFocusComponent == null ? false : myFocusComponent.requestFocusInWindow();
|
||||
return myFocusComponent != null && myFocusComponent.requestFocusInWindow();
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -453,7 +448,7 @@ public abstract class EditorComposite implements Disposable {
|
||||
|
||||
@Override
|
||||
public boolean requestDefaultFocus() {
|
||||
return myFocusComponent == null ? false : myFocusComponent.requestDefaultFocus();
|
||||
return myFocusComponent != null && myFocusComponent.requestDefaultFocus();
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -472,9 +467,7 @@ public abstract class EditorComposite implements Disposable {
|
||||
if(component instanceof DataProvider && component != this){
|
||||
return ((DataProvider)component).getData(dataId);
|
||||
}
|
||||
else{
|
||||
return null;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
-1
@@ -32,7 +32,6 @@ import com.intellij.openapi.wm.ToolWindowManager;
|
||||
import com.intellij.openapi.wm.impl.IdeFrameImpl;
|
||||
import com.intellij.ui.Gray;
|
||||
import com.intellij.ui.JBColor;
|
||||
import com.intellij.util.PairFunction;
|
||||
import com.intellij.util.ui.JBUI;
|
||||
import com.intellij.util.ui.UIUtil;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
+18
-29
@@ -65,12 +65,7 @@ public final class EditorHistoryManager implements PersistentStateComponent<Elem
|
||||
|
||||
MessageBusConnection connection = project.getMessageBus().connect();
|
||||
|
||||
connection.subscribe(UISettingsListener.TOPIC, new UISettingsListener() {
|
||||
@Override
|
||||
public void uiSettingsChanged(UISettings uiSettings) {
|
||||
trimToSize();
|
||||
}
|
||||
});
|
||||
connection.subscribe(UISettingsListener.TOPIC, uiSettings -> trimToSize());
|
||||
|
||||
connection.subscribe(FileEditorManagerListener.Before.FILE_EDITOR_MANAGER, new FileEditorManagerListener.Before.Adapter() {
|
||||
@Override
|
||||
@@ -247,11 +242,11 @@ public final class EditorHistoryManager implements PersistentStateComponent<Elem
|
||||
}
|
||||
|
||||
/**
|
||||
* Removes specified <code>file</code> from history. The method does
|
||||
* nothing if <code>file</code> is not in the history.
|
||||
* Removes specified {@code file} from history. The method does
|
||||
* nothing if {@code file} is not in the history.
|
||||
*
|
||||
* @exception IllegalArgumentException if <code>file</code>
|
||||
* is <code>null</code>
|
||||
* @exception IllegalArgumentException if {@code file}
|
||||
* is {@code null}
|
||||
*/
|
||||
public synchronized void removeFile(@NotNull final VirtualFile file){
|
||||
final HistoryEntry entry = getEntry(file);
|
||||
@@ -268,7 +263,7 @@ public final class EditorHistoryManager implements PersistentStateComponent<Elem
|
||||
/**
|
||||
* @return may be null
|
||||
*/
|
||||
public FileEditorProvider getSelectedProvider(final VirtualFile file) {
|
||||
FileEditorProvider getSelectedProvider(final VirtualFile file) {
|
||||
final HistoryEntry entry = getEntry(file);
|
||||
return entry != null ? entry.getSelectedProvider() : null;
|
||||
}
|
||||
@@ -285,7 +280,7 @@ public final class EditorHistoryManager implements PersistentStateComponent<Elem
|
||||
}
|
||||
|
||||
/**
|
||||
* If total number of files in history more then <code>UISettings.RECENT_FILES_LIMIT</code>
|
||||
* If total number of files in history more then {@code UISettings.RECENT_FILES_LIMIT}
|
||||
* then removes the oldest ones to fit the history to new size.
|
||||
*/
|
||||
private synchronized void trimToSize(){
|
||||
@@ -302,25 +297,19 @@ public final class EditorHistoryManager implements PersistentStateComponent<Elem
|
||||
// which is done via corresponding EditorProviders, those are not accessible before their
|
||||
// is initComponent() called
|
||||
final Element state = element.clone();
|
||||
StartupManager.getInstance(myProject).runWhenProjectIsInitialized(new DumbAwareRunnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
for (Element e : state.getChildren(HistoryEntry.TAG)) {
|
||||
try {
|
||||
addEntry(HistoryEntry.createHeavy(myProject, e));
|
||||
}
|
||||
catch (InvalidDataException e1) {
|
||||
// OK here
|
||||
}
|
||||
catch (ProcessCanceledException e1) {
|
||||
// OK here
|
||||
}
|
||||
catch (Exception anyException) {
|
||||
LOG.error(anyException);
|
||||
}
|
||||
StartupManager.getInstance(myProject).runWhenProjectIsInitialized((DumbAwareRunnable)() -> {
|
||||
for (Element e : state.getChildren(HistoryEntry.TAG)) {
|
||||
try {
|
||||
addEntry(HistoryEntry.createHeavy(myProject, e));
|
||||
}
|
||||
catch (InvalidDataException | ProcessCanceledException e1) {
|
||||
// OK here
|
||||
}
|
||||
catch (Exception anyException) {
|
||||
LOG.error(anyException);
|
||||
}
|
||||
trimToSize();
|
||||
}
|
||||
trimToSize();
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
+35
-48
@@ -85,9 +85,9 @@ public final class EditorTabbedContainer implements Disposable, CloseAction.Clos
|
||||
|
||||
@NonNls public static final String HELP_ID = "ideaInterface.editor";
|
||||
|
||||
private TabInfo.DragOutDelegate myDragOutDelegate = new MyDragOutDelegate();
|
||||
private final TabInfo.DragOutDelegate myDragOutDelegate = new MyDragOutDelegate();
|
||||
|
||||
EditorTabbedContainer(final EditorWindow window, Project project, final int tabPlacement) {
|
||||
EditorTabbedContainer(final EditorWindow window, Project project) {
|
||||
myWindow = window;
|
||||
myProject = project;
|
||||
final ActionManager actionManager = ActionManager.getInstance();
|
||||
@@ -96,13 +96,7 @@ public final class EditorTabbedContainer implements Disposable, CloseAction.Clos
|
||||
myTabs.setTransferHandler(new MyTransferHandler());
|
||||
myTabs.setDataProvider(new MyDataProvider()).setPopupGroup(
|
||||
() -> (ActionGroup)CustomActionsSchema.getInstance().getCorrectedAction(IdeActions.GROUP_EDITOR_TAB_POPUP), ActionPlaces.EDITOR_TAB_POPUP, false).addTabMouseListener(new TabMouseListener()).getPresentation()
|
||||
.setTabDraggingEnabled(true).setUiDecorator(new UiDecorator() {
|
||||
@Override
|
||||
@NotNull
|
||||
public UiDecoration getDecoration() {
|
||||
return new UiDecoration(null, new Insets(TabsUtil.TAB_VERTICAL_PADDING, 8, TabsUtil.TAB_VERTICAL_PADDING, 8));
|
||||
}
|
||||
}).setTabLabelActionsMouseDeadzone(TimedDeadzone.NULL).setGhostsAlwaysVisible(true).setTabLabelActionsAutoHide(false)
|
||||
.setTabDraggingEnabled(true).setUiDecorator(() -> new UiDecorator.UiDecoration(null, new Insets(TabsUtil.TAB_VERTICAL_PADDING, 8, TabsUtil.TAB_VERTICAL_PADDING, 8))).setTabLabelActionsMouseDeadzone(TimedDeadzone.NULL).setGhostsAlwaysVisible(true).setTabLabelActionsAutoHide(false)
|
||||
.setActiveTabFillIn(EditorColorsManager.getInstance().getGlobalScheme().getDefaultBackground()).setPaintFocus(false).getJBTabs()
|
||||
.addListener(new TabsListener.Adapter() {
|
||||
@Override
|
||||
@@ -124,17 +118,13 @@ public final class EditorTabbedContainer implements Disposable, CloseAction.Clos
|
||||
}
|
||||
}
|
||||
})
|
||||
.setSelectionChangeHandler(new JBTabs.SelectionChangeHandler() {
|
||||
@NotNull
|
||||
@Override
|
||||
public ActionCallback execute(TabInfo info, boolean requestFocus, @NotNull final ActiveRunnable doChangeSelection) {
|
||||
final ActionCallback result = new ActionCallback();
|
||||
CommandProcessor.getInstance().executeCommand(myProject, () -> {
|
||||
((IdeDocumentHistoryImpl)IdeDocumentHistory.getInstance(myProject)).onSelectionChanged();
|
||||
result.notify(doChangeSelection.run());
|
||||
}, "EditorChange", null);
|
||||
return result;
|
||||
}
|
||||
.setSelectionChangeHandler((info, requestFocus, doChangeSelection) -> {
|
||||
final ActionCallback result = new ActionCallback();
|
||||
CommandProcessor.getInstance().executeCommand(myProject, () -> {
|
||||
((IdeDocumentHistoryImpl)IdeDocumentHistory.getInstance(myProject)).onSelectionChanged();
|
||||
result.notify(doChangeSelection.run());
|
||||
}, "EditorChange", null);
|
||||
return result;
|
||||
}).getPresentation().setRequestFocusOnLastFocusedComponent(true);
|
||||
myTabs.addMouseListener(new MouseAdapter() {
|
||||
@Override
|
||||
@@ -163,12 +153,7 @@ public final class EditorTabbedContainer implements Disposable, CloseAction.Clos
|
||||
}
|
||||
});
|
||||
|
||||
project.getMessageBus().connect().subscribe(UISettingsListener.TOPIC, new UISettingsListener() {
|
||||
@Override
|
||||
public void uiSettingsChanged(UISettings uiSettings) {
|
||||
updateTabBorder();
|
||||
}
|
||||
});
|
||||
project.getMessageBus().connect().subscribe(UISettingsListener.TOPIC, uiSettings -> updateTabBorder());
|
||||
|
||||
Disposer.register(project, this);
|
||||
}
|
||||
@@ -177,16 +162,18 @@ public final class EditorTabbedContainer implements Disposable, CloseAction.Clos
|
||||
return myTabs.getTabCount();
|
||||
}
|
||||
|
||||
@NotNull
|
||||
public ActionCallback setSelectedIndex(final int indexToSelect) {
|
||||
return setSelectedIndex(indexToSelect, true);
|
||||
}
|
||||
|
||||
@NotNull
|
||||
public ActionCallback setSelectedIndex(final int indexToSelect, boolean focusEditor) {
|
||||
if (indexToSelect >= myTabs.getTabCount()) return ActionCallback.REJECTED;
|
||||
return myTabs.select(myTabs.getTabAt(indexToSelect), focusEditor);
|
||||
}
|
||||
|
||||
|
||||
@NotNull
|
||||
public static DockableEditor createDockableEditor(Project project, Image image, VirtualFile file, Presentation presentation, EditorWindow window) {
|
||||
return new DockableEditor(project, image, file, presentation, window.getSize(), window.isFilePinned(file));
|
||||
}
|
||||
@@ -208,10 +195,10 @@ public final class EditorTabbedContainer implements Disposable, CloseAction.Clos
|
||||
List<String> leftIds = mgr.getIdsOn(ToolWindowAnchor.LEFT);
|
||||
|
||||
if (!uiSettings.HIDE_TOOL_STRIPES && !uiSettings.PRESENTATION_MODE) {
|
||||
border.top = topIds.size() > 0 ? 1 : 0;
|
||||
border.bottom = bottom.size() > 0 ? 1 : 0;
|
||||
border.left = leftIds.size() > 0 ? 1 : 0;
|
||||
border.right = rightIds.size() > 0 ? 1 : 0;
|
||||
border.top = !topIds.isEmpty() ? 1 : 0;
|
||||
border.bottom = !bottom.isEmpty() ? 1 : 0;
|
||||
border.left = !leftIds.isEmpty() ? 1 : 0;
|
||||
border.right = !rightIds.isEmpty() ? 1 : 0;
|
||||
}
|
||||
|
||||
for (String each : ids) {
|
||||
@@ -262,17 +249,17 @@ public final class EditorTabbedContainer implements Disposable, CloseAction.Clos
|
||||
return myTabs.getIndexOf(myTabs.getSelectedInfo());
|
||||
}
|
||||
|
||||
public void setForegroundAt(final int index, final Color color) {
|
||||
void setForegroundAt(final int index, final Color color) {
|
||||
myTabs.getTabAt(index).setDefaultForeground(color);
|
||||
}
|
||||
|
||||
public void setWaveColor(final int index, @Nullable final Color color) {
|
||||
void setWaveColor(final int index, @Nullable final Color color) {
|
||||
final TabInfo tab = myTabs.getTabAt(index);
|
||||
tab.setDefaultStyle(color == null ? SimpleTextAttributes.STYLE_PLAIN : SimpleTextAttributes.STYLE_WAVED);
|
||||
tab.setDefaultWaveColor(color);
|
||||
}
|
||||
|
||||
public void setIconAt(final int index, final Icon icon) {
|
||||
void setIconAt(final int index, final Icon icon) {
|
||||
myTabs.getTabAt(index).setIcon(icon);
|
||||
}
|
||||
|
||||
@@ -280,15 +267,15 @@ public final class EditorTabbedContainer implements Disposable, CloseAction.Clos
|
||||
myTabs.getTabAt(index).setText(text);
|
||||
}
|
||||
|
||||
public void setToolTipTextAt(final int index, final String text) {
|
||||
void setToolTipTextAt(final int index, final String text) {
|
||||
myTabs.getTabAt(index).setTooltipText(text);
|
||||
}
|
||||
|
||||
public void setBackgroundColorAt(final int index, final Color color) {
|
||||
void setBackgroundColorAt(final int index, final Color color) {
|
||||
myTabs.getTabAt(index).setTabColor(color);
|
||||
}
|
||||
|
||||
public void setTabLayoutPolicy(final int policy) {
|
||||
void setTabLayoutPolicy(final int policy) {
|
||||
switch (policy) {
|
||||
case JTabbedPane.SCROLL_TAB_LAYOUT:
|
||||
myTabs.getPresentation().setSingleRow(true);
|
||||
@@ -342,7 +329,7 @@ public final class EditorTabbedContainer implements Disposable, CloseAction.Clos
|
||||
myTabs.addTabSilently(tab, indexToInsert);
|
||||
}
|
||||
|
||||
public boolean isEmptyVisible() {
|
||||
boolean isEmptyVisible() {
|
||||
return myTabs.isEmptyVisible();
|
||||
}
|
||||
|
||||
@@ -356,7 +343,7 @@ public final class EditorTabbedContainer implements Disposable, CloseAction.Clos
|
||||
}
|
||||
}
|
||||
|
||||
public void setPaintBlocked(boolean blocked) {
|
||||
void setPaintBlocked(boolean blocked) {
|
||||
myTabs.setPaintBlocked(blocked, true);
|
||||
}
|
||||
|
||||
@@ -364,7 +351,7 @@ public final class EditorTabbedContainer implements Disposable, CloseAction.Clos
|
||||
|
||||
private final TabInfo myTab;
|
||||
|
||||
public MyQueryable(TabInfo tab) {
|
||||
MyQueryable(TabInfo tab) {
|
||||
myTab = tab;
|
||||
}
|
||||
|
||||
@@ -421,7 +408,7 @@ public final class EditorTabbedContainer implements Disposable, CloseAction.Clos
|
||||
ShadowAction myShadow;
|
||||
private final TabInfo myTabInfo;
|
||||
|
||||
public CloseTab(JComponent c, TabInfo info) {
|
||||
CloseTab(JComponent c, TabInfo info) {
|
||||
myTabInfo = info;
|
||||
myShadow = new ShadowAction(this, ActionManager.getInstance().getAction(IdeActions.ACTION_CLOSE), c);
|
||||
}
|
||||
@@ -555,7 +542,7 @@ public final class EditorTabbedContainer implements Disposable, CloseAction.Clos
|
||||
|
||||
@Override
|
||||
public void mouseClicked(MouseEvent e) {
|
||||
if (UIUtil.isActionClick(e, MouseEvent.MOUSE_CLICKED) && (e.isMetaDown() || (!SystemInfo.isMac && e.isControlDown()))) {
|
||||
if (UIUtil.isActionClick(e, MouseEvent.MOUSE_CLICKED) && (e.isMetaDown() || !SystemInfo.isMac && e.isControlDown())) {
|
||||
final TabInfo info = myTabs.findInfo(e);
|
||||
if (info != null && info.getObject() != null) {
|
||||
final VirtualFile vFile = (VirtualFile)info.getObject();
|
||||
@@ -631,11 +618,11 @@ public final class EditorTabbedContainer implements Disposable, CloseAction.Clos
|
||||
|
||||
public static class DockableEditor implements DockableContent<VirtualFile> {
|
||||
final Image myImg;
|
||||
private DockableEditorTabbedContainer myContainer;
|
||||
private Presentation myPresentation;
|
||||
private Dimension myPreferredSize;
|
||||
private boolean myPinned;
|
||||
private VirtualFile myFile;
|
||||
private final DockableEditorTabbedContainer myContainer;
|
||||
private final Presentation myPresentation;
|
||||
private final Dimension myPreferredSize;
|
||||
private final boolean myPinned;
|
||||
private final VirtualFile myFile;
|
||||
|
||||
public DockableEditor(Project project, Image img, VirtualFile file, Presentation presentation, Dimension preferredSize, boolean isFilePinned) {
|
||||
myImg = img;
|
||||
@@ -707,7 +694,7 @@ public final class EditorTabbedContainer implements Disposable, CloseAction.Clos
|
||||
private static class MyShadowBorder implements Border {
|
||||
private final JBEditorTabs myTabs;
|
||||
|
||||
public MyShadowBorder(JBEditorTabs tabs) {
|
||||
MyShadowBorder(JBEditorTabs tabs) {
|
||||
myTabs = tabs;
|
||||
}
|
||||
|
||||
|
||||
@@ -101,8 +101,8 @@ public class EditorWindow {
|
||||
} : AllIcons.General.Modified;
|
||||
private static final Icon GAP_ICON = EmptyIcon.create(MODIFIED_ICON);
|
||||
|
||||
private boolean myIsDisposed = false;
|
||||
public static final Key<Integer> INITIAL_INDEX_KEY = Key.create("initial editor index");
|
||||
private boolean myIsDisposed;
|
||||
static final Key<Integer> INITIAL_INDEX_KEY = Key.create("initial editor index");
|
||||
private final Stack<Pair<String, Integer>> myRemovedTabs = new Stack<Pair<String, Integer>>() {
|
||||
@Override
|
||||
public void push(Pair<String, Integer> pair) {
|
||||
@@ -112,7 +112,7 @@ public class EditorWindow {
|
||||
super.push(pair);
|
||||
}
|
||||
};
|
||||
private AtomicBoolean myTabsHidingInProgress = new AtomicBoolean(false);
|
||||
private final AtomicBoolean myTabsHidingInProgress = new AtomicBoolean(false);
|
||||
private final Stack<Pair<String, Integer>> myHiddenTabs = new Stack<>();
|
||||
|
||||
protected EditorWindow(final EditorsSplitters owner) {
|
||||
@@ -124,7 +124,7 @@ public class EditorWindow {
|
||||
|
||||
final int tabPlacement = UISettings.getInstance().EDITOR_TAB_PLACEMENT;
|
||||
if (tabPlacement != UISettings.TABS_NONE && !UISettings.getInstance().PRESENTATION_MODE) {
|
||||
createTabs(tabPlacement);
|
||||
createTabs();
|
||||
}
|
||||
|
||||
// Tab layout policy
|
||||
@@ -140,9 +140,9 @@ public class EditorWindow {
|
||||
}
|
||||
}
|
||||
|
||||
private void createTabs(int tabPlacement) {
|
||||
private void createTabs() {
|
||||
LOG.assertTrue (myTabbedPane == null);
|
||||
myTabbedPane = new EditorTabbedContainer(this, getManager().getProject(), tabPlacement);
|
||||
myTabbedPane = new EditorTabbedContainer(this, getManager().getProject());
|
||||
myPanel.add(myTabbedPane.getComponent(), BorderLayout.CENTER);
|
||||
}
|
||||
|
||||
@@ -190,11 +190,11 @@ public class EditorWindow {
|
||||
closeFile(file, disposeIfNeeded, true);
|
||||
}
|
||||
|
||||
public boolean hasClosedTabs() {
|
||||
boolean hasClosedTabs() {
|
||||
return !myRemovedTabs.empty();
|
||||
}
|
||||
|
||||
public void restoreClosedTab() {
|
||||
void restoreClosedTab() {
|
||||
assert hasClosedTabs() : "Nothing to restore";
|
||||
|
||||
final Pair<String, Integer> info = myRemovedTabs.pop();
|
||||
@@ -219,85 +219,82 @@ public class EditorWindow {
|
||||
|
||||
public void closeFile(@NotNull final VirtualFile file, final boolean disposeIfNeeded, final boolean transferFocus) {
|
||||
final FileEditorManagerImpl editorManager = getManager();
|
||||
editorManager.runChange(new FileEditorManagerChange() {
|
||||
@Override
|
||||
public void run(EditorsSplitters splitters) {
|
||||
final List<EditorWithProviderComposite> editors = splitters.findEditorComposites(file);
|
||||
if (editors.isEmpty()) return;
|
||||
try {
|
||||
final EditorWithProviderComposite editor = findFileComposite(file);
|
||||
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);
|
||||
final FileEditorManagerListener.Before beforePublisher =
|
||||
editorManager.getProject().getMessageBus().syncPublisher(FileEditorManagerListener.Before.FILE_EDITOR_MANAGER);
|
||||
|
||||
beforePublisher.beforeFileClosed(editorManager, file);
|
||||
beforePublisher.beforeFileClosed(editorManager, file);
|
||||
|
||||
if (myTabbedPane != null && editor != null) {
|
||||
final int componentIndex = findComponentIndex(editor.getComponent());
|
||||
if (componentIndex >= 0) { // editor could close itself on decomposition
|
||||
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);
|
||||
if (myTabbedPane != null && editor != null) {
|
||||
final int componentIndex = findComponentIndex(editor.getComponent());
|
||||
if (componentIndex >= 0) { // editor could close itself on decomposition
|
||||
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 {
|
||||
}
|
||||
else {
|
||||
|
||||
if (inSplitter()) {
|
||||
Splitter splitter = (Splitter)myPanel.getParent();
|
||||
JComponent otherComponent = splitter.getOtherComponent(myPanel);
|
||||
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 (otherComponent != null) {
|
||||
IdeFocusManager.findInstance().requestFocus(otherComponent, true);
|
||||
}
|
||||
}
|
||||
|
||||
if (disposeIfNeeded && getTabCount() == 0) {
|
||||
removeFromSplitter();
|
||||
if (UISettings.getInstance().EDITOR_TAB_PLACEMENT == 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();
|
||||
}
|
||||
}
|
||||
}
|
||||
myPanel.removeAll ();
|
||||
if (editor != null) {
|
||||
editorManager.disposeComposite(editor);
|
||||
}
|
||||
else {
|
||||
myPanel.revalidate();
|
||||
if (myTabbedPane == null) {
|
||||
// in tabless mode
|
||||
myPanel.repaint();
|
||||
}
|
||||
|
||||
if (disposeIfNeeded && getTabCount() == 0) {
|
||||
removeFromSplitter();
|
||||
if (UISettings.getInstance().EDITOR_TAB_PLACEMENT == 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();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
finally {
|
||||
editorManager.removeSelectionRecord(file, EditorWindow.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);
|
||||
else {
|
||||
myPanel.revalidate();
|
||||
if (myTabbedPane == null) {
|
||||
// in tabless mode
|
||||
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);
|
||||
}
|
||||
|
||||
@@ -360,7 +357,7 @@ public class EditorWindow {
|
||||
}
|
||||
}
|
||||
} else
|
||||
if (uiSettings.ACTIVATE_RIGHT_EDITOR_ON_CLOSE && (fileIndex + 1 < myTabbedPane.getTabCount())) {
|
||||
if (uiSettings.ACTIVATE_RIGHT_EDITOR_ON_CLOSE && fileIndex + 1 < myTabbedPane.getTabCount()) {
|
||||
return fileIndex + 1;
|
||||
}
|
||||
|
||||
@@ -381,13 +378,13 @@ public class EditorWindow {
|
||||
return myPanel.getComponentCount();
|
||||
}
|
||||
|
||||
public void setForegroundAt(final int index, final Color color) {
|
||||
void setForegroundAt(final int index, final Color color) {
|
||||
if (myTabbedPane != null) {
|
||||
myTabbedPane.setForegroundAt(index, color);
|
||||
}
|
||||
}
|
||||
|
||||
public void setWaveColor(final int index, @Nullable final Color color) {
|
||||
void setWaveColor(final int index, @Nullable final Color color) {
|
||||
if (myTabbedPane != null) {
|
||||
myTabbedPane.setWaveColor(index, color);
|
||||
}
|
||||
@@ -418,18 +415,18 @@ public class EditorWindow {
|
||||
}
|
||||
|
||||
|
||||
public void setTabLayoutPolicy(final int policy) {
|
||||
void setTabLayoutPolicy(final int policy) {
|
||||
if (myTabbedPane != null) {
|
||||
myTabbedPane.setTabLayoutPolicy(policy);
|
||||
}
|
||||
}
|
||||
|
||||
public void setTabsPlacement(final int tabPlacement) {
|
||||
void setTabsPlacement(final int tabPlacement) {
|
||||
if (tabPlacement != UISettings.TABS_NONE && !UISettings.getInstance().PRESENTATION_MODE) {
|
||||
if (myTabbedPane == null) {
|
||||
final EditorWithProviderComposite editor = getSelectedEditor();
|
||||
myPanel.removeAll();
|
||||
createTabs(tabPlacement);
|
||||
createTabs();
|
||||
restoreHiddenTabs();
|
||||
setEditor (editor, true);
|
||||
}
|
||||
@@ -450,12 +447,8 @@ public class EditorWindow {
|
||||
for (VirtualFile file : files) {
|
||||
closeFile(file, false);
|
||||
}
|
||||
getManager().runChange(new FileEditorManagerChange() {//Add flag switching activity to the end of queue
|
||||
@Override
|
||||
public void run(EditorsSplitters splitters) {
|
||||
myTabsHidingInProgress.set(false);
|
||||
}
|
||||
}, myOwner);
|
||||
//Add flag switching activity to the end of queue
|
||||
getManager().runChange(splitters -> myTabsHidingInProgress.set(false), myOwner);
|
||||
disposeTabs();
|
||||
if (currentFile != null) {
|
||||
currentFile.putUserData(FileEditorManagerImpl.CLOSING_TO_REOPEN, null);
|
||||
@@ -471,7 +464,7 @@ public class EditorWindow {
|
||||
myOwner.setCurrentWindow(this, requestFocus);
|
||||
}
|
||||
|
||||
public void updateFileBackgroundColor(@NotNull VirtualFile file) {
|
||||
void updateFileBackgroundColor(@NotNull VirtualFile file) {
|
||||
final int index = findEditorIndex(findFileComposite(file));
|
||||
if (index != -1) {
|
||||
final Color color = EditorTabbedContainer.calcTabColor(getManager().getProject(), file);
|
||||
@@ -483,7 +476,7 @@ public class EditorWindow {
|
||||
return myOwner;
|
||||
}
|
||||
|
||||
public boolean isEmptyVisible() {
|
||||
boolean isEmptyVisible() {
|
||||
return myTabbedPane != null ? myTabbedPane.isEmptyVisible() : getFiles().length == 0;
|
||||
}
|
||||
|
||||
@@ -530,7 +523,7 @@ public class EditorWindow {
|
||||
@Override
|
||||
public void focusGained(FocusEvent e) {
|
||||
ApplicationManager.getApplication().invokeLater(() -> {
|
||||
if (!TComp.this.hasFocus()) return;
|
||||
if (!hasFocus()) return;
|
||||
final JComponent focus = myEditor.getSelectedEditorWithProvider().getFirst().getPreferredFocusedComponent();
|
||||
if (focus != null && !focus.hasFocus()) {
|
||||
IdeFocusManager.getGlobalInstance().requestFocus(focus, true);
|
||||
@@ -552,7 +545,7 @@ public class EditorWindow {
|
||||
final VirtualFile virtualFile = myEditor.getFile();
|
||||
return virtualFile.isValid() ? virtualFile : null;
|
||||
}
|
||||
else if (CommonDataKeys.PROJECT.is(dataId)) {
|
||||
if (CommonDataKeys.PROJECT.is(dataId)) {
|
||||
return myEditor.getFileEditorManager().getProject();
|
||||
}
|
||||
return null;
|
||||
@@ -840,7 +833,7 @@ public class EditorWindow {
|
||||
return res.toArray(new EditorWindow[res.size()]);
|
||||
}
|
||||
|
||||
public void changeOrientation() {
|
||||
void changeOrientation() {
|
||||
checkConsistency();
|
||||
final Container parent = myPanel.getParent();
|
||||
if (parent instanceof Splitter) {
|
||||
@@ -849,13 +842,13 @@ public class EditorWindow {
|
||||
}
|
||||
}
|
||||
|
||||
protected void updateFileIcon(VirtualFile file) {
|
||||
void updateFileIcon(VirtualFile file) {
|
||||
final int index = findEditorIndex(findFileComposite(file));
|
||||
LOG.assertTrue(index != -1);
|
||||
setIconAt(index, getFileIcon(file));
|
||||
}
|
||||
|
||||
protected void updateFileName(VirtualFile file) {
|
||||
void updateFileName(VirtualFile file) {
|
||||
final int index = findEditorIndex(findFileComposite(file));
|
||||
if (index != -1) {
|
||||
setTitleAt(index, EditorTabbedContainer.calcTabTitle(getManager().getProject(), file));
|
||||
@@ -971,7 +964,7 @@ public class EditorWindow {
|
||||
}
|
||||
}
|
||||
|
||||
public void unsplitAll() {
|
||||
void unsplitAll() {
|
||||
checkConsistency();
|
||||
while (inSplitter()) {
|
||||
unsplit(true);
|
||||
@@ -1001,7 +994,7 @@ public class EditorWindow {
|
||||
}
|
||||
|
||||
|
||||
public int findComponentIndex(final Component component) {
|
||||
private int findComponentIndex(final Component component) {
|
||||
for (int i = 0; i != getTabCount(); ++i) {
|
||||
final EditorWithProviderComposite editor = getEditorAt(i);
|
||||
if (editor.getComponent ().equals (component)) {
|
||||
@@ -1011,7 +1004,7 @@ public class EditorWindow {
|
||||
return -1;
|
||||
}
|
||||
|
||||
public int findEditorIndex(final EditorComposite editorToFind) {
|
||||
int findEditorIndex(final EditorComposite editorToFind) {
|
||||
for (int i = 0; i != getTabCount(); ++i) {
|
||||
final EditorWithProviderComposite editor = getEditorAt(i);
|
||||
if (editor.equals (editorToFind)) {
|
||||
@@ -1021,7 +1014,7 @@ public class EditorWindow {
|
||||
return -1;
|
||||
}
|
||||
|
||||
public int findFileIndex(final VirtualFile fileToFind) {
|
||||
int findFileIndex(final VirtualFile fileToFind) {
|
||||
for (int i = 0; i != getTabCount(); ++i) {
|
||||
final VirtualFile file = getFileAt(i);
|
||||
if (file.equals (fileToFind)) {
|
||||
@@ -1181,7 +1174,7 @@ public class EditorWindow {
|
||||
return isFileOpen (file) && !file.equals(fileToIgnore) && !isFilePinned(file);
|
||||
}
|
||||
|
||||
protected VirtualFile getFileAt(int i) {
|
||||
VirtualFile getFileAt(int i) {
|
||||
return getEditorAt(i).getFile();
|
||||
}
|
||||
|
||||
|
||||
+35
-57
@@ -25,7 +25,6 @@ import com.intellij.openapi.diagnostic.Logger;
|
||||
import com.intellij.openapi.editor.Document;
|
||||
import com.intellij.openapi.fileEditor.FileDocumentManager;
|
||||
import com.intellij.openapi.fileEditor.FileEditor;
|
||||
import com.intellij.openapi.keymap.Keymap;
|
||||
import com.intellij.openapi.keymap.KeymapManager;
|
||||
import com.intellij.openapi.keymap.KeymapManagerListener;
|
||||
import com.intellij.openapi.progress.ProgressIndicator;
|
||||
@@ -99,12 +98,9 @@ public class EditorsSplitters extends IdePanePanel implements UISettingsListener
|
||||
Disposer.register(manager.getProject(), dockable);
|
||||
dockManager.register(dockable);
|
||||
}
|
||||
KeymapManagerListener keymapListener = new KeymapManagerListener() {
|
||||
@Override
|
||||
public void activeKeymapChanged(Keymap keymap) {
|
||||
invalidate();
|
||||
repaint();
|
||||
}
|
||||
KeymapManagerListener keymapListener = keymap -> {
|
||||
invalidate();
|
||||
repaint();
|
||||
};
|
||||
KeymapManager.getInstance().addKeymapManagerListener(keymapListener, this);
|
||||
}
|
||||
@@ -233,20 +229,17 @@ public class EditorsSplitters extends IdePanePanel implements UISettingsListener
|
||||
if (mySplittersElement != null) {
|
||||
initializeProgress();
|
||||
final JPanel comp = myUIBuilder.process(mySplittersElement, getTopPanel());
|
||||
UIUtil.invokeAndWaitIfNeeded(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
if (comp != null) {
|
||||
removeAll();
|
||||
add(comp, BorderLayout.CENTER);
|
||||
mySplittersElement = null;
|
||||
}
|
||||
// clear empty splitters
|
||||
for (EditorWindow window : getWindows()) {
|
||||
if (window.getEditors().length == 0) {
|
||||
for (EditorWindow sibling : window.findSiblings()) {
|
||||
sibling.unsplit(false);
|
||||
}
|
||||
UIUtil.invokeAndWaitIfNeeded((Runnable)() -> {
|
||||
if (comp != null) {
|
||||
removeAll();
|
||||
add(comp, BorderLayout.CENTER);
|
||||
mySplittersElement = null;
|
||||
}
|
||||
// clear empty splitters
|
||||
for (EditorWindow window : getWindows()) {
|
||||
if (window.getEditors().length == 0) {
|
||||
for (EditorWindow sibling : window.findSiblings()) {
|
||||
sibling.unsplit(false);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -337,12 +330,12 @@ public class EditorsSplitters extends IdePanePanel implements UISettingsListener
|
||||
|
||||
@NotNull
|
||||
public FileEditor[] getSelectedEditors() {
|
||||
List<FileEditor> editors = new ArrayList<>();
|
||||
Set<EditorWindow> windows = new THashSet<>(myWindows);
|
||||
final EditorWindow currentWindow = getCurrentWindow();
|
||||
if (currentWindow != null) {
|
||||
windows.add(currentWindow);
|
||||
}
|
||||
List<FileEditor> editors = new ArrayList<>();
|
||||
for (final EditorWindow window : windows) {
|
||||
final EditorWithProviderComposite composite = window.getSelectedEditor();
|
||||
if (composite != null) {
|
||||
@@ -818,12 +811,7 @@ public class EditorsSplitters extends IdePanePanel implements UISettingsListener
|
||||
@Override
|
||||
protected JPanel processFiles(@NotNull List<Element> fileElements, final JPanel context) {
|
||||
final Ref<EditorWindow> windowRef = new Ref<>();
|
||||
UIUtil.invokeAndWaitIfNeeded(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
windowRef.set(context == null ? createEditorWindow() : findWindowWith(context));
|
||||
}
|
||||
});
|
||||
UIUtil.invokeAndWaitIfNeeded((Runnable)() -> windowRef.set(context == null ? createEditorWindow() : findWindowWith(context)));
|
||||
final EditorWindow window = windowRef.get();
|
||||
LOG.assertTrue(window != null);
|
||||
VirtualFile focusedFile = null;
|
||||
@@ -850,12 +838,8 @@ public class EditorsSplitters extends IdePanePanel implements UISettingsListener
|
||||
final HistoryEntry entry = HistoryEntry.createLight(fileEditorManager.getProject(), historyElement);
|
||||
final VirtualFile virtualFile = entry.getFile();
|
||||
if (virtualFile == null) throw new InvalidDataException("No file exists: " + entry.getFilePointer().getUrl());
|
||||
Document document = ApplicationManager.getApplication().runReadAction(new Computable<Document>() {
|
||||
@Override
|
||||
public Document compute() {
|
||||
return virtualFile.isValid() ? FileDocumentManager.getInstance().getDocument(virtualFile) : null;
|
||||
}
|
||||
});
|
||||
Document document = ApplicationManager.getApplication().runReadAction(
|
||||
(Computable<Document>)() -> virtualFile.isValid() ? FileDocumentManager.getInstance().getDocument(virtualFile) : null);
|
||||
final boolean isCurrentInTab = Boolean.valueOf(file.getAttributeValue(CURRENT_IN_TAB)).booleanValue();
|
||||
Boolean pin = Boolean.valueOf(file.getAttributeValue(PINNED));
|
||||
fileEditorManager.openFileImpl4(window, virtualFile, entry, isCurrentInTab, isCurrentInTab, pin, i);
|
||||
@@ -890,34 +874,28 @@ public class EditorsSplitters extends IdePanePanel implements UISettingsListener
|
||||
final JPanel firstComponent = process(firstChild, null);
|
||||
final JPanel secondComponent = process(secondChild, null);
|
||||
final Ref<JPanel> panelRef = new Ref<>();
|
||||
UIUtil.invokeAndWaitIfNeeded(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
JPanel panel = new JPanel(new BorderLayout());
|
||||
panel.setOpaque(false);
|
||||
Splitter splitter = new OnePixelSplitter(orientation, proportion, 0.1f, 0.9f);
|
||||
panel.add(splitter, BorderLayout.CENTER);
|
||||
splitter.setFirstComponent(firstComponent);
|
||||
splitter.setSecondComponent(secondComponent);
|
||||
panelRef.set(panel);
|
||||
}
|
||||
UIUtil.invokeAndWaitIfNeeded((Runnable)() -> {
|
||||
JPanel panel = new JPanel(new BorderLayout());
|
||||
panel.setOpaque(false);
|
||||
Splitter splitter = new OnePixelSplitter(orientation, proportion, 0.1f, 0.9f);
|
||||
panel.add(splitter, BorderLayout.CENTER);
|
||||
splitter.setFirstComponent(firstComponent);
|
||||
splitter.setSecondComponent(secondComponent);
|
||||
panelRef.set(panel);
|
||||
});
|
||||
return panelRef.get();
|
||||
}
|
||||
final Ref<JPanel> firstComponent = new Ref<>();
|
||||
final Ref<JPanel> secondComponent = new Ref<>();
|
||||
UIUtil.invokeAndWaitIfNeeded(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
if (context.getComponent(0) instanceof Splitter) {
|
||||
Splitter splitter = (Splitter)context.getComponent(0);
|
||||
firstComponent.set((JPanel)splitter.getFirstComponent());
|
||||
secondComponent.set((JPanel)splitter.getSecondComponent());
|
||||
}
|
||||
else {
|
||||
firstComponent.set(context);
|
||||
secondComponent.set(context);
|
||||
}
|
||||
UIUtil.invokeAndWaitIfNeeded((Runnable)() -> {
|
||||
if (context.getComponent(0) instanceof Splitter) {
|
||||
Splitter splitter = (Splitter)context.getComponent(0);
|
||||
firstComponent.set((JPanel)splitter.getFirstComponent());
|
||||
secondComponent.set((JPanel)splitter.getSecondComponent());
|
||||
}
|
||||
else {
|
||||
firstComponent.set(context);
|
||||
secondComponent.set(context);
|
||||
}
|
||||
});
|
||||
process(firstChild, firstComponent.get());
|
||||
|
||||
+1
@@ -15,6 +15,7 @@
|
||||
*/
|
||||
package com.intellij.openapi.fileEditor.impl;
|
||||
|
||||
@FunctionalInterface
|
||||
public interface FileEditorManagerChange {
|
||||
|
||||
void run(EditorsSplitters splitters);
|
||||
|
||||
+40
-75
@@ -134,12 +134,7 @@ public class FileEditorManagerImpl extends FileEditorManagerEx implements Persis
|
||||
private DockableEditorContainerFactory myContentFactory;
|
||||
private static final AtomicInteger ourOpenFilesSetModificationCount = new AtomicInteger();
|
||||
|
||||
public static final ModificationTracker OPEN_FILE_SET_MODIFICATION_COUNT = new ModificationTracker() {
|
||||
@Override
|
||||
public long getModificationCount() {
|
||||
return ourOpenFilesSetModificationCount.get();
|
||||
}
|
||||
};
|
||||
static final ModificationTracker OPEN_FILE_SET_MODIFICATION_COUNT = ourOpenFilesSetModificationCount::get;
|
||||
|
||||
|
||||
public FileEditorManagerImpl(@NotNull Project project, DockManager dockManager) {
|
||||
@@ -302,9 +297,7 @@ public class FileEditorManagerImpl extends FileEditorManagerEx implements Persis
|
||||
if (container instanceof DockableEditorTabbedContainer) {
|
||||
return ((DockableEditorTabbedContainer)container).getSplitters();
|
||||
}
|
||||
else {
|
||||
return getMainSplitters();
|
||||
}
|
||||
return getMainSplitters();
|
||||
}
|
||||
|
||||
private final Object myInitLock = new Object();
|
||||
@@ -365,7 +358,7 @@ public class FileEditorManagerImpl extends FileEditorManagerEx implements Persis
|
||||
//-------------------------------------------------------
|
||||
|
||||
/**
|
||||
* @return color of the <code>file</code> which corresponds to the
|
||||
* @return color of the {@code file} which corresponds to the
|
||||
* file's status
|
||||
*/
|
||||
public Color getFileColor(@NotNull final VirtualFile file) {
|
||||
@@ -395,7 +388,7 @@ public class FileEditorManagerImpl extends FileEditorManagerEx implements Persis
|
||||
}
|
||||
|
||||
/**
|
||||
* Updates tab color for the specified <code>file</code>. The <code>file</code>
|
||||
* Updates tab color for the specified {@code file}. The {@code file}
|
||||
* should be opened in the myEditor, otherwise the method throws an assertion.
|
||||
*/
|
||||
private void updateFileColor(@NotNull VirtualFile file) {
|
||||
@@ -413,7 +406,7 @@ public class FileEditorManagerImpl extends FileEditorManagerEx implements Persis
|
||||
}
|
||||
|
||||
/**
|
||||
* Updates tab icon for the specified <code>file</code>. The <code>file</code>
|
||||
* Updates tab icon for the specified {@code file}. The {@code file}
|
||||
* should be opened in the myEditor, otherwise the method throws an assertion.
|
||||
*/
|
||||
protected void updateFileIcon(@NotNull VirtualFile file) {
|
||||
@@ -424,7 +417,7 @@ public class FileEditorManagerImpl extends FileEditorManagerEx implements Persis
|
||||
}
|
||||
|
||||
/**
|
||||
* Updates tab title and tab tool tip for the specified <code>file</code>
|
||||
* Updates tab title and tab tool tip for the specified {@code file}
|
||||
*/
|
||||
void updateFileName(@Nullable final VirtualFile file) {
|
||||
// Queue here is to prevent title flickering when tab is being closed and two events arriving: with component==null and component==next focused tab
|
||||
@@ -597,7 +590,7 @@ public class FileEditorManagerImpl extends FileEditorManagerEx implements Persis
|
||||
@Override
|
||||
@NotNull
|
||||
public AsyncResult<EditorWindow> getActiveWindow() {
|
||||
return getActiveSplittersAsync().subResult(splitters -> splitters.getCurrentWindow());
|
||||
return getActiveSplittersAsync().subResult(EditorsSplitters::getCurrentWindow);
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -645,12 +638,7 @@ public class FileEditorManagerImpl extends FileEditorManagerEx implements Persis
|
||||
private void closeFileImpl(@NotNull final VirtualFile file, final boolean moveFocus, boolean closeAllCopies) {
|
||||
assertDispatchThread();
|
||||
ourOpenFilesSetModificationCount.incrementAndGet();
|
||||
runChange(new FileEditorManagerChange() {
|
||||
@Override
|
||||
public void run(EditorsSplitters splitters) {
|
||||
splitters.closeFile(file, moveFocus);
|
||||
}
|
||||
}, closeAllCopies ? null : getActiveSplittersSync());
|
||||
runChange(splitters -> splitters.closeFile(file, moveFocus), closeAllCopies ? null : getActiveSplittersSync());
|
||||
}
|
||||
|
||||
//-------------------------------------- Open File ----------------------------------------
|
||||
@@ -812,12 +800,7 @@ public class FileEditorManagerImpl extends FileEditorManagerEx implements Persis
|
||||
|
||||
final Ref<EditorWithProviderComposite> compositeRef = new Ref<>();
|
||||
|
||||
UIUtil.invokeAndWaitIfNeeded(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
compositeRef.set(window.findFileComposite(file));
|
||||
}
|
||||
});
|
||||
UIUtil.invokeAndWaitIfNeeded((Runnable)() -> compositeRef.set(window.findFileComposite(file)));
|
||||
|
||||
final FileEditorProvider[] newProviders;
|
||||
final AsyncFileEditorProvider.Builder[] builders;
|
||||
@@ -834,24 +817,18 @@ public class FileEditorManagerImpl extends FileEditorManagerEx implements Persis
|
||||
try {
|
||||
final FileEditorProvider provider = newProviders[i];
|
||||
LOG.assertTrue(provider != null, "Provider for file "+file+" is null. All providers: "+Arrays.asList(newProviders));
|
||||
builders[i] = ApplicationManager.getApplication().runReadAction(new Computable<AsyncFileEditorProvider.Builder>() {
|
||||
@Override
|
||||
public AsyncFileEditorProvider.Builder compute() {
|
||||
if (myProject.isDisposed() || !file.isValid()) {
|
||||
return null;
|
||||
}
|
||||
LOG.assertTrue(provider.accept(myProject, file), "Provider " + provider + " doesn't accept file " + file);
|
||||
return provider instanceof AsyncFileEditorProvider ? ((AsyncFileEditorProvider)provider).createEditorAsync(myProject, file) : null;
|
||||
builders[i] = ApplicationManager.getApplication().runReadAction((Computable<AsyncFileEditorProvider.Builder>)() -> {
|
||||
if (myProject.isDisposed() || !file.isValid()) {
|
||||
return null;
|
||||
}
|
||||
LOG.assertTrue(provider.accept(myProject, file), "Provider " + provider + " doesn't accept file " + file);
|
||||
return provider instanceof AsyncFileEditorProvider ? ((AsyncFileEditorProvider)provider).createEditorAsync(myProject, file) : null;
|
||||
});
|
||||
}
|
||||
catch (ProcessCanceledException e) {
|
||||
throw e;
|
||||
}
|
||||
catch (Exception e) {
|
||||
LOG.error(e);
|
||||
}
|
||||
catch (AssertionError e) {
|
||||
catch (Exception | AssertionError e) {
|
||||
LOG.error(e);
|
||||
}
|
||||
}
|
||||
@@ -889,10 +866,7 @@ public class FileEditorManagerImpl extends FileEditorManagerEx implements Persis
|
||||
catch (ProcessCanceledException e) {
|
||||
throw e;
|
||||
}
|
||||
catch (Exception e) {
|
||||
LOG.error(e);
|
||||
}
|
||||
catch (AssertionError e) {
|
||||
catch (Exception | AssertionError e) {
|
||||
LOG.error(e);
|
||||
}
|
||||
}
|
||||
@@ -1398,7 +1372,7 @@ public class FileEditorManagerImpl extends FileEditorManagerEx implements Persis
|
||||
@NotNull
|
||||
public List<JComponent> getTopComponents(@NotNull FileEditor editor) {
|
||||
final EditorComposite composite = getEditorComposite(editor);
|
||||
return composite != null ? composite.getTopComponents(editor) : Collections.<JComponent>emptyList();
|
||||
return composite != null ? composite.getTopComponents(editor) : Collections.emptyList();
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -1417,12 +1391,6 @@ public class FileEditorManagerImpl extends FileEditorManagerEx implements Persis
|
||||
}
|
||||
}
|
||||
|
||||
@NotNull
|
||||
public List<JComponent> getBottomComponents(@NotNull FileEditor editor) {
|
||||
final EditorComposite composite = getEditorComposite(editor);
|
||||
return composite != null ? composite.getBottomComponents(editor) : Collections.<JComponent>emptyList();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void addBottomComponent(@NotNull final FileEditor editor, @NotNull final JComponent component) {
|
||||
final EditorComposite composite = getEditorComposite(editor);
|
||||
@@ -1481,28 +1449,25 @@ public class FileEditorManagerImpl extends FileEditorManagerEx implements Persis
|
||||
*/
|
||||
connection.subscribe(UISettingsListener.TOPIC, new MyUISettingsListener());
|
||||
|
||||
StartupManager.getInstance(myProject).registerPostStartupActivity(new DumbAwareRunnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
if (myProject.isDisposed()) return;
|
||||
setTabsMode(UISettings.getInstance().EDITOR_TAB_PLACEMENT != UISettings.TABS_NONE);
|
||||
StartupManager.getInstance(myProject).registerPostStartupActivity((DumbAwareRunnable)() -> {
|
||||
if (myProject.isDisposed()) return;
|
||||
setTabsMode(UISettings.getInstance().EDITOR_TAB_PLACEMENT != UISettings.TABS_NONE);
|
||||
|
||||
ToolWindowManager.getInstance(myProject).invokeLater(() -> {
|
||||
if (!myProject.isDisposed()) {
|
||||
CommandProcessor.getInstance().executeCommand(myProject, () -> {
|
||||
ApplicationManager.getApplication().invokeLater(() -> {
|
||||
long currentTime = System.nanoTime();
|
||||
Long startTime = myProject.getUserData(ProjectImpl.CREATION_TIME);
|
||||
if (startTime != null) {
|
||||
LOG.info("Project opening took " + (currentTime - startTime.longValue()) / 1000000 + " ms");
|
||||
PluginManagerCore.dumpPluginClassStatistics();
|
||||
}
|
||||
}, myProject.getDisposed());
|
||||
// group 1
|
||||
}, "", null);
|
||||
}
|
||||
});
|
||||
}
|
||||
ToolWindowManager.getInstance(myProject).invokeLater(() -> {
|
||||
if (!myProject.isDisposed()) {
|
||||
CommandProcessor.getInstance().executeCommand(myProject, () -> {
|
||||
ApplicationManager.getApplication().invokeLater(() -> {
|
||||
long currentTime = System.nanoTime();
|
||||
Long startTime = myProject.getUserData(ProjectImpl.CREATION_TIME);
|
||||
if (startTime != null) {
|
||||
LOG.info("Project opening took " + (currentTime - startTime.longValue()) / 1000000 + " ms");
|
||||
PluginManagerCore.dumpPluginClassStatistics();
|
||||
}
|
||||
}, myProject.getDisposed());
|
||||
// group 1
|
||||
}, "", null);
|
||||
}
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
@@ -1607,7 +1572,7 @@ public class FileEditorManagerImpl extends FileEditorManagerEx implements Persis
|
||||
return status != FileStatus.UNKNOWN && status != FileStatus.NOT_CHANGED;
|
||||
}
|
||||
|
||||
public void disposeComposite(@NotNull EditorWithProviderComposite editor) {
|
||||
void disposeComposite(@NotNull EditorWithProviderComposite editor) {
|
||||
if (getAllEditors().length == 0) {
|
||||
setCurrentWindow(null);
|
||||
}
|
||||
@@ -1637,7 +1602,7 @@ public class FileEditorManagerImpl extends FileEditorManagerEx implements Persis
|
||||
}
|
||||
|
||||
@Nullable
|
||||
EditorComposite getLastSelected() {
|
||||
private EditorComposite getLastSelected() {
|
||||
final EditorWindow currentWindow = getActiveSplittersSync().getCurrentWindow();
|
||||
if (currentWindow != null) {
|
||||
return currentWindow.getSelectedEditor();
|
||||
@@ -1648,7 +1613,7 @@ public class FileEditorManagerImpl extends FileEditorManagerEx implements Persis
|
||||
/**
|
||||
* @param splitters - taken getAllSplitters() value if parameter is null
|
||||
*/
|
||||
public void runChange(@NotNull FileEditorManagerChange change, @Nullable EditorsSplitters splitters) {
|
||||
void runChange(@NotNull FileEditorManagerChange change, @Nullable EditorsSplitters splitters) {
|
||||
Set<EditorsSplitters> target = new HashSet<>();
|
||||
if (splitters == null) {
|
||||
target.addAll(getAllSplitters());
|
||||
@@ -1937,7 +1902,7 @@ public class FileEditorManagerImpl extends FileEditorManagerEx implements Persis
|
||||
return getOpenFiles();
|
||||
}
|
||||
|
||||
protected void queueUpdateFile(@NotNull final VirtualFile file) {
|
||||
void queueUpdateFile(@NotNull final VirtualFile file) {
|
||||
myQueue.queue(new Update(file) {
|
||||
@Override
|
||||
public void run() {
|
||||
@@ -1995,7 +1960,7 @@ public class FileEditorManagerImpl extends FileEditorManagerEx implements Persis
|
||||
mySelectionHistory.add(0, record);
|
||||
}
|
||||
|
||||
public void removeSelectionRecord(@NotNull VirtualFile file, @NotNull EditorWindow window) {
|
||||
void removeSelectionRecord(@NotNull VirtualFile file, @NotNull EditorWindow window) {
|
||||
mySelectionHistory.remove(Pair.create(file, window));
|
||||
updateFileName(file);
|
||||
}
|
||||
|
||||
+5
-12
@@ -31,10 +31,8 @@ import com.intellij.openapi.fileEditor.impl.text.TextEditorProvider;
|
||||
import com.intellij.openapi.project.DumbService;
|
||||
import com.intellij.openapi.project.Project;
|
||||
import com.intellij.openapi.util.Computable;
|
||||
import com.intellij.openapi.util.Condition;
|
||||
import com.intellij.openapi.util.text.StringUtil;
|
||||
import com.intellij.openapi.vfs.VirtualFile;
|
||||
import com.intellij.util.Function;
|
||||
import com.intellij.util.containers.ContainerUtil;
|
||||
import com.intellij.util.xmlb.annotations.MapAnnotation;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
@@ -85,14 +83,11 @@ public final class FileEditorProviderManagerImpl extends FileEditorProviderManag
|
||||
List<FileEditorProvider> sharedProviders = new ArrayList<>();
|
||||
boolean doNotShowTextEditor = false;
|
||||
for (final FileEditorProvider provider : myProviders) {
|
||||
if (ApplicationManager.getApplication().runReadAction(new Computable<Boolean>() {
|
||||
@Override
|
||||
public Boolean compute() {
|
||||
if (DumbService.isDumb(project) && !DumbService.isDumbAware(provider)) {
|
||||
return false;
|
||||
}
|
||||
return provider.accept(project, file);
|
||||
if (ApplicationManager.getApplication().runReadAction((Computable<Boolean>)() -> {
|
||||
if (DumbService.isDumb(project) && !DumbService.isDumbAware(provider)) {
|
||||
return false;
|
||||
}
|
||||
return provider.accept(project, file);
|
||||
})) {
|
||||
sharedProviders.add(provider);
|
||||
doNotShowTextEditor |= provider.getPolicy() == FileEditorPolicy.HIDE_DEFAULT_EDITOR;
|
||||
@@ -146,8 +141,6 @@ public final class FileEditorProviderManagerImpl extends FileEditorProviderManag
|
||||
mySelectedProviders.putAll(state.mySelectedProviders);
|
||||
}
|
||||
|
||||
private static final Function<FileEditorProvider, String> EDITOR_PROVIDER_STRING_FUNCTION = provider -> provider.getEditorTypeId();
|
||||
|
||||
private final Map<String, String> mySelectedProviders = new HashMap<>();
|
||||
|
||||
void providerSelected(EditorComposite composite) {
|
||||
@@ -159,7 +152,7 @@ public final class FileEditorProviderManagerImpl extends FileEditorProviderManag
|
||||
}
|
||||
|
||||
private static String computeKey(FileEditorProvider[] providers) {
|
||||
return StringUtil.join(ContainerUtil.map(providers, EDITOR_PROVIDER_STRING_FUNCTION), ",");
|
||||
return StringUtil.join(ContainerUtil.map(providers, FileEditorProvider::getEditorTypeId), ",");
|
||||
}
|
||||
|
||||
@Nullable
|
||||
|
||||
@@ -68,10 +68,10 @@ final class HistoryEntry {
|
||||
}
|
||||
|
||||
@NotNull
|
||||
public static HistoryEntry createLight(@NotNull VirtualFile file,
|
||||
@NotNull FileEditorProvider[] providers,
|
||||
@NotNull FileEditorState[] states,
|
||||
@NotNull FileEditorProvider selectedProvider) {
|
||||
static HistoryEntry createLight(@NotNull VirtualFile file,
|
||||
@NotNull FileEditorProvider[] providers,
|
||||
@NotNull FileEditorState[] states,
|
||||
@NotNull FileEditorProvider selectedProvider) {
|
||||
VirtualFilePointer pointer = new LightFilePointer(file);
|
||||
HistoryEntry entry = new HistoryEntry(pointer, selectedProvider, null);
|
||||
for (int i = 0; i < providers.length; i++) {
|
||||
@@ -81,7 +81,7 @@ final class HistoryEntry {
|
||||
}
|
||||
|
||||
@NotNull
|
||||
public static HistoryEntry createLight(@NotNull Project project, @NotNull Element e) throws InvalidDataException {
|
||||
static HistoryEntry createLight(@NotNull Project project, @NotNull Element e) throws InvalidDataException {
|
||||
EntryData entryData = parseEntry(project, e);
|
||||
|
||||
VirtualFilePointer pointer = new LightFilePointer(entryData.url);
|
||||
@@ -93,11 +93,11 @@ final class HistoryEntry {
|
||||
}
|
||||
|
||||
@NotNull
|
||||
public static HistoryEntry createHeavy(@NotNull Project project,
|
||||
@NotNull VirtualFile file,
|
||||
@NotNull FileEditorProvider[] providers,
|
||||
@NotNull FileEditorState[] states,
|
||||
@NotNull FileEditorProvider selectedProvider) {
|
||||
static HistoryEntry createHeavy(@NotNull Project project,
|
||||
@NotNull VirtualFile file,
|
||||
@NotNull FileEditorProvider[] providers,
|
||||
@NotNull FileEditorState[] states,
|
||||
@NotNull FileEditorProvider selectedProvider) {
|
||||
if (project.isDisposed()) return createLight(file, providers, states, selectedProvider);
|
||||
|
||||
Disposable disposable = Disposer.newDisposable();
|
||||
@@ -115,7 +115,7 @@ final class HistoryEntry {
|
||||
}
|
||||
|
||||
@NotNull
|
||||
public static HistoryEntry createHeavy(@NotNull Project project, @NotNull Element e) throws InvalidDataException {
|
||||
static HistoryEntry createHeavy(@NotNull Project project, @NotNull Element e) throws InvalidDataException {
|
||||
if (project.isDisposed()) return createLight(project, e);
|
||||
|
||||
EntryData entryData = parseEntry(project, e);
|
||||
@@ -145,16 +145,16 @@ final class HistoryEntry {
|
||||
return myProvider2State.get(provider);
|
||||
}
|
||||
|
||||
public void putState(@NotNull FileEditorProvider provider, @NotNull FileEditorState state) {
|
||||
void putState(@NotNull FileEditorProvider provider, @NotNull FileEditorState state) {
|
||||
myProvider2State.put(provider, state);
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public FileEditorProvider getSelectedProvider() {
|
||||
FileEditorProvider getSelectedProvider() {
|
||||
return mySelectedProvider;
|
||||
}
|
||||
|
||||
public void setSelectedProvider(@Nullable FileEditorProvider value) {
|
||||
void setSelectedProvider(@Nullable FileEditorProvider value) {
|
||||
mySelectedProvider = value;
|
||||
}
|
||||
|
||||
@@ -163,7 +163,7 @@ final class HistoryEntry {
|
||||
}
|
||||
|
||||
/**
|
||||
* @return element that was added to the <code>element</code>.
|
||||
* @return element that was added to the {@code element}.
|
||||
* Returned element has tag {@link #TAG}. Never null.
|
||||
*/
|
||||
public Element writeExternal(Element element, Project project) {
|
||||
@@ -226,13 +226,13 @@ final class HistoryEntry {
|
||||
}
|
||||
|
||||
private static class EntryData {
|
||||
@NotNull public final String url;
|
||||
@NotNull public final List<Pair<FileEditorProvider, FileEditorState>> providerStates;
|
||||
@Nullable public final FileEditorProvider selectedProvider;
|
||||
@NotNull private final String url;
|
||||
@NotNull private final List<Pair<FileEditorProvider, FileEditorState>> providerStates;
|
||||
@Nullable private final FileEditorProvider selectedProvider;
|
||||
|
||||
public EntryData(@NotNull String url,
|
||||
@NotNull List<Pair<FileEditorProvider, FileEditorState>> providerStates,
|
||||
@Nullable FileEditorProvider selectedProvider) {
|
||||
EntryData(@NotNull String url,
|
||||
@NotNull List<Pair<FileEditorProvider, FileEditorState>> providerStates,
|
||||
@Nullable FileEditorProvider selectedProvider) {
|
||||
this.url = url;
|
||||
this.providerStates = providerStates;
|
||||
this.selectedProvider = selectedProvider;
|
||||
|
||||
+15
-15
@@ -42,10 +42,7 @@ import org.jetbrains.annotations.TestOnly;
|
||||
import java.lang.ref.WeakReference;
|
||||
import java.util.*;
|
||||
|
||||
@State(
|
||||
name = "IdeDocumentHistory",
|
||||
storages = {@Storage(StoragePathMacros.WORKSPACE_FILE)}
|
||||
)
|
||||
@State(name = "IdeDocumentHistory", storages = @Storage(StoragePathMacros.WORKSPACE_FILE))
|
||||
public class IdeDocumentHistoryImpl extends IdeDocumentHistory implements ProjectComponent, PersistentStateComponent<IdeDocumentHistoryImpl.RecentlyChangedFilesState> {
|
||||
private static final Logger LOG = Logger.getInstance("#com.intellij.openapi.fileEditor.impl.IdeDocumentHistoryImpl");
|
||||
|
||||
@@ -63,21 +60,21 @@ public class IdeDocumentHistoryImpl extends IdeDocumentHistory implements Projec
|
||||
|
||||
private final LinkedList<PlaceInfo> myBackPlaces = new LinkedList<>(); // LinkedList of PlaceInfo's
|
||||
private final LinkedList<PlaceInfo> myForwardPlaces = new LinkedList<>(); // LinkedList of PlaceInfo's
|
||||
private boolean myBackInProgress = false;
|
||||
private boolean myForwardInProgress = false;
|
||||
private Object myLastGroupId = null;
|
||||
private boolean myBackInProgress;
|
||||
private boolean myForwardInProgress;
|
||||
private Object myLastGroupId;
|
||||
|
||||
// change's navigation
|
||||
private final LinkedList<PlaceInfo> myChangePlaces = new LinkedList<>(); // LinkedList of PlaceInfo's
|
||||
private int myStartIndex = 0;
|
||||
private int myCurrentIndex = 0;
|
||||
private PlaceInfo myCurrentChangePlace = null;
|
||||
private int myStartIndex;
|
||||
private int myCurrentIndex;
|
||||
private PlaceInfo myCurrentChangePlace;
|
||||
|
||||
private PlaceInfo myCommandStartPlace = null;
|
||||
private boolean myCurrentCommandIsNavigation = false;
|
||||
private boolean myCurrentCommandHasChanges = false;
|
||||
private PlaceInfo myCommandStartPlace;
|
||||
private boolean myCurrentCommandIsNavigation;
|
||||
private boolean myCurrentCommandHasChanges;
|
||||
private final Set<VirtualFile> myChangedFilesInCurrentCommand = new THashSet<>();
|
||||
private boolean myCurrentCommandHasMoves = false;
|
||||
private boolean myCurrentCommandHasMoves;
|
||||
|
||||
private final CommandListener myCommandListener = new CommandAdapter() {
|
||||
@Override
|
||||
@@ -513,7 +510,10 @@ public class IdeDocumentHistoryImpl extends IdeDocumentHistory implements Projec
|
||||
private final String myEditorTypeId;
|
||||
private final WeakReference<EditorWindow> myWindow;
|
||||
|
||||
public PlaceInfo(@NotNull VirtualFile file, @NotNull FileEditorState navigationState, @NotNull String editorTypeId, @Nullable EditorWindow window) {
|
||||
PlaceInfo(@NotNull VirtualFile file,
|
||||
@NotNull FileEditorState navigationState,
|
||||
@NotNull String editorTypeId,
|
||||
@Nullable EditorWindow window) {
|
||||
myNavigationState = navigationState;
|
||||
myFile = file;
|
||||
myEditorTypeId = editorTypeId;
|
||||
|
||||
@@ -15,6 +15,8 @@
|
||||
*/
|
||||
package com.intellij.openapi.util;
|
||||
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
/**
|
||||
* @author Konstantin Bulenkov
|
||||
*/
|
||||
@@ -26,11 +28,8 @@ public final class NullUtils {
|
||||
* @return <tt>true</tt> if all objects are not <tt>null</tt>,
|
||||
* otherwise <tt>false</tt>
|
||||
*/
|
||||
public static boolean notNull(Object... objects) {
|
||||
for (Object object : objects) {
|
||||
if (object == null) return false;
|
||||
}
|
||||
return true;
|
||||
public static boolean notNull(@NotNull Object... objects) {
|
||||
return !hasNull(objects);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -40,7 +39,7 @@ public final class NullUtils {
|
||||
* @return <tt>false</tt> if all objects are not <tt>null</tt>,
|
||||
* otherwise <tt>true</tt>
|
||||
*/
|
||||
public static boolean hasNull(Object... objects) {
|
||||
public static boolean hasNull(@NotNull Object... objects) {
|
||||
for (Object object : objects) {
|
||||
if (object == null) return true;
|
||||
}
|
||||
@@ -54,7 +53,7 @@ public final class NullUtils {
|
||||
* @return <tt>false</tt> if all objects are <tt>null</tt>,
|
||||
* otherwise <tt>true</tt>
|
||||
*/
|
||||
public static boolean hasNotNull(Object... objects) {
|
||||
public static boolean hasNotNull(@NotNull Object... objects) {
|
||||
for (Object object : objects) {
|
||||
if (object != null) return true;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user