@Override

This commit is contained in:
Alexey Kudravtsev
2013-08-20 12:24:09 +04:00
parent e47e0e9681
commit 72974c0ba4
18 changed files with 276 additions and 13 deletions
@@ -117,6 +117,7 @@ public abstract class EditorComposite implements Disposable {
PrevNextActionsDescriptor descriptor = new PrevNextActionsDescriptor(IdeActions.ACTION_NEXT_EDITOR_TAB, IdeActions.ACTION_PREVIOUS_EDITOR_TAB);
final TabbedPaneWrapper.AsJBTabs wrapper = new TabbedPaneWrapper.AsJBTabs(fileEditorManager.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));
@@ -126,14 +127,17 @@ public abstract class EditorComposite implements Disposable {
myTabbedPaneWrapper=wrapper;
myComponent=new MyComponent(wrapper.getComponent()){
@Override
public boolean requestFocusInWindow() {
return wrapper.getComponent().requestFocusInWindow();
}
@Override
public void requestFocus() {
wrapper.getComponent().requestFocus();
}
@Override
public boolean requestDefaultFocus() {
return wrapper.getComponent().requestDefaultFocus();
}
@@ -146,6 +150,7 @@ public abstract class EditorComposite implements Disposable {
else if(editors.length==1){
myTabbedPaneWrapper=null;
myComponent = new MyComponent(createEditorComponent(editors[0])){
@Override
public void requestFocus() {
JComponent component = editors[0].getPreferredFocusedComponent();
if (component != null) {
@@ -153,6 +158,7 @@ public abstract class EditorComposite implements Disposable {
}
}
@Override
public boolean requestFocusInWindow() {
JComponent component = editors[0].getPreferredFocusedComponent();
if (component != null) {
@@ -162,6 +168,7 @@ public abstract class EditorComposite implements Disposable {
return false;
}
@Override
public boolean requestDefaultFocus() {
JComponent component = editors[0].getPreferredFocusedComponent();
if (component != null) {
@@ -383,6 +390,7 @@ public abstract class EditorComposite implements Disposable {
* Handles changes of selected myEditor
*/
private final class MyChangeListener implements ChangeListener{
@Override
public void stateChanged(ChangeEvent e) {
FileEditor oldSelectedEditor = mySelectedEditor;
LOG.assertTrue(oldSelectedEditor != null);
@@ -399,6 +407,7 @@ public abstract class EditorComposite implements Disposable {
add(realComponent, BorderLayout.CENTER);
}
@Override
public final Object getData(String dataId){
if (PlatformDataKeys.FILE_EDITOR.is(dataId)) {
return getSelectedEditor();
@@ -421,6 +430,7 @@ public abstract class EditorComposite implements Disposable {
}
}
@Override
public void dispose() {
for (FileEditor editor : myEditors) {
if (!Disposer.isDisposed(editor)) {
@@ -60,6 +60,7 @@ public final class EditorHistoryManager extends AbstractProjectComponent impleme
uiSettings.addUISettingsListener(new MyUISettingsListener(), project);
}
@Override
public void projectOpened(){
MessageBusConnection connection = myProject.getMessageBus().connect();
@@ -68,6 +69,7 @@ public final class EditorHistoryManager extends AbstractProjectComponent impleme
StartupManager.getInstance(myProject).runWhenProjectIsInitialized(
new DumbAwareRunnable() {
@Override
public void run() {
// myElement may be null if node that corresponds to this manager does not exist
if (myElement != null) {
@@ -95,6 +97,7 @@ public final class EditorHistoryManager extends AbstractProjectComponent impleme
);
}
@Override
@NotNull
public String getComponentName(){
return "editorHistoryManager";
@@ -305,6 +308,7 @@ public final class EditorHistoryManager extends AbstractProjectComponent impleme
}
}
@Override
public void readExternal(final Element element) {
// we have to delay xml processing because history entries require EditorStates to be created
// which is done via corresponding EditorProviders, those are not accessible before their
@@ -312,6 +316,7 @@ public final class EditorHistoryManager extends AbstractProjectComponent impleme
myElement = element.clone();
}
@Override
public void writeExternal(final Element element){
// update history before saving
final VirtualFile[] openFiles = FileEditorManager.getInstance(myProject).getOpenFiles();
@@ -331,10 +336,12 @@ public final class EditorHistoryManager extends AbstractProjectComponent impleme
* Updates history
*/
private final class MyEditorManagerListener extends FileEditorManagerAdapter{
@Override
public void fileOpened(@NotNull final FileEditorManager source, @NotNull final VirtualFile file){
fileOpenedImpl(file);
}
@Override
public void selectionChanged(@NotNull final FileEditorManagerEvent event){
updateHistoryEntry(event.getOldFile(), event.getOldEditor(), event.getOldProvider(), false);
updateHistoryEntry(event.getNewFile(), true);
@@ -352,6 +359,7 @@ public final class EditorHistoryManager extends AbstractProjectComponent impleme
* Cuts/extends history length
*/
private final class MyUISettingsListener implements UISettingsListener{
@Override
public void uiSettingsChanged(final UISettings source) {
trimToSize();
}
@@ -86,11 +86,13 @@ public final class EditorTabbedContainer implements Disposable, CloseAction.Clos
final ActionManager actionManager = ActionManager.getInstance();
myTabs = new JBEditorTabs(project, actionManager, IdeFocusManager.getInstance(project), this);
myTabs.setDataProvider(new MyDataProvider()).setPopupGroup(new Getter<ActionGroup>() {
@Override
public ActionGroup get() {
return (ActionGroup)CustomActionsSchema.getInstance().getCorrectedAction(IdeActions.GROUP_EDITOR_TAB_POPUP);
}
}, ActionPlaces.EDITOR_TAB_POPUP, false).setNavigationActionsEnabled(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, 10, TabsUtil.TAB_VERTICAL_PADDING, 10));
@@ -98,6 +100,7 @@ public final class EditorTabbedContainer implements Disposable, CloseAction.Clos
}).setTabLabelActionsMouseDeadzone(TimedDeadzone.NULL).setGhostsAlwaysVisible(true).setTabLabelActionsAutoHide(false)
.setActiveTabFillIn(EditorColorsManager.getInstance().getGlobalScheme().getDefaultBackground()).setPaintFocus(false).getJBTabs()
.addListener(new TabsListener.Adapter() {
@Override
public void selectionChanged(final TabInfo oldSelection, final TabInfo newSelection) {
final FileEditorManager editorManager = FileEditorManager.getInstance(myProject);
final FileEditor oldEditor = oldSelection != null ? editorManager.getSelectedEditor((VirtualFile)oldSelection.getObject()) : null;
@@ -142,16 +145,19 @@ public final class EditorTabbedContainer implements Disposable, CloseAction.Clos
updateTabBorder();
((ToolWindowManagerEx)ToolWindowManager.getInstance(myProject)).addToolWindowManagerListener(new ToolWindowManagerAdapter() {
@Override
public void stateChanged() {
updateTabBorder();
}
@Override
public void toolWindowRegistered(@NotNull final String id) {
updateTabBorder();
}
});
UISettings.getInstance().addUISettingsListener(new UISettingsListener() {
@Override
public void uiSettingsChanged(UISettings source) {
updateTabBorder();
}
@@ -354,6 +360,7 @@ public final class EditorTabbedContainer implements Disposable, CloseAction.Clos
myTab = tab;
}
@Override
public void putInfo(@NotNull Map<String, String> info) {
info.put("editorTab", myTab.getText());
}
@@ -387,6 +394,7 @@ public final class EditorTabbedContainer implements Disposable, CloseAction.Clos
return tab.getComponent();
}
@Override
public void dispose() {
}
@@ -409,6 +417,7 @@ public final class EditorTabbedContainer implements Disposable, CloseAction.Clos
e.getPresentation().setText("Close. Alt-click to close others.");
}
@Override
public void actionPerformed(final AnActionEvent e) {
final FileEditorManagerEx mgr = FileEditorManagerEx.getInstanceEx(myProject);
EditorWindow window;
@@ -434,6 +443,7 @@ public final class EditorTabbedContainer implements Disposable, CloseAction.Clos
}
private class MyDataProvider implements DataProvider {
@Override
public Object getData(@NonNls final String dataId) {
if (PlatformDataKeys.PROJECT.is(dataId)) {
return myProject;
@@ -464,6 +474,7 @@ public final class EditorTabbedContainer implements Disposable, CloseAction.Clos
}
}
@Override
public void close() {
TabInfo selected = myTabs.getTargetInfo();
if (selected == null) return;
@@ -533,6 +544,7 @@ public final class EditorTabbedContainer implements Disposable, CloseAction.Clos
}
private class MySwitchProvider implements SwitchProvider {
@Override
public List<SwitchTarget> getTargets(final boolean onlyVisible, boolean originalProvider) {
final ArrayList<SwitchTarget> result = new ArrayList<SwitchTarget>();
TabInfo selected = myTabs.getSelectedInfo();
@@ -552,6 +564,7 @@ public final class EditorTabbedContainer implements Disposable, CloseAction.Clos
return result;
}
@Override
public SwitchTarget getCurrentTarget() {
TabInfo selected = myTabs.getSelectedInfo();
final Ref<SwitchTarget> targetRef = new Ref<SwitchTarget>();
@@ -572,10 +585,12 @@ public final class EditorTabbedContainer implements Disposable, CloseAction.Clos
return targetRef.get();
}
@Override
public JComponent getComponent() {
return null;
}
@Override
public boolean isCycleRoot() {
return false;
}
@@ -589,7 +604,7 @@ public final class EditorTabbedContainer implements Disposable, CloseAction.Clos
@Override
public void dragOutStarted(MouseEvent mouseEvent, TabInfo info) {
final TabInfo previousSelection = info.getPreviousSelection();
final Image img = myTabs.getComponentImage(info);
final Image img = JBTabsImpl.getComponentImage(info);
info.setHidden(true);
if (previousSelection != null) {
myTabs.select(previousSelection, true);
@@ -161,7 +161,7 @@ public class EditorWindow {
boolean editorToTheDown = false;
Splitter splitter = (Splitter)parent;
boolean vertical = splitter.getOrientation();
if (vertical && splitter.getFirstComponent() == c) {
editorToTheDown = true;
@@ -172,7 +172,7 @@ public class EditorWindow {
if (splitter.getSecondComponent() == c) editorToTheLeft = true;
}
//Frame frame = (Frame) SwingUtilities.getAncestorOfClass(Frame.class, c);
//if (frame instanceof IdeFrame) {
// Project project = ((IdeFrame)frame).getProject();
@@ -218,10 +218,10 @@ public class EditorWindow {
int bottom = editorToTheDown ? 1 : 0;
return new Insets(0, left, bottom, right);
}
return new Insets(0, 0, 0, 0);
}
@Nullable
private static Splitter nextOuterSplitter(Component c) {
Container parent = c.getParent();
@@ -290,6 +290,7 @@ public class EditorWindow {
public void closeFile(final VirtualFile file, final boolean unsplit, 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;
@@ -308,6 +309,7 @@ public class EditorWindow {
myRemovedTabs.push(Pair.create(file.getUrl(), componentIndex));
final ActionCallback removeTab = myTabbedPane.removeTabAt(componentIndex, indexToSelect, transferFocus);
final Runnable disposer = new Runnable() {
@Override
public void run() {
editorManager.disposeComposite(editor);
}
@@ -378,11 +380,11 @@ public class EditorWindow {
return histFileIndex;
}
}
} else
} else
if (uiSettings.ACTIVATE_RIGHT_EDITOR_ON_CLOSE && (fileIndex + 1 < myTabbedPane.getTabCount())) {
return fileIndex + 1;
}
// by default select previous neighbour
if (fileIndex > 0) {
return fileIndex - 1;
@@ -553,6 +555,7 @@ public class EditorWindow {
return myWindow;
}
@Override
public Object getData(String dataId) {
if (PlatformDataKeys.VIRTUAL_FILE.is(dataId)){
final VirtualFile virtualFile = myEditor.getFile();
@@ -570,6 +573,7 @@ public class EditorWindow {
super(window, editor);
}
@Override
public Object getData(String dataId) {
// this is essential for ability to close opened file
if (DATA_KEY.is(dataId)){
@@ -636,6 +640,7 @@ public class EditorWindow {
final int index = findFileIndex(editor.getFile());
if (index != -1) {
UIUtil.invokeLaterIfNeeded(new Runnable() {
@Override
public void run() {
myTabbedPane.setSelectedIndex(index, focusEditor);
}
@@ -663,12 +668,12 @@ public class EditorWindow {
if (initialIndex == null) {
int selectedIndex = myTabbedPane.getSelectedIndex();
if (selectedIndex >= 0) {
indexToInsert = UISettings.getInstance().ACTIVATE_RIGHT_EDITOR_ON_CLOSE ? selectedIndex : selectedIndex + 1;
indexToInsert = UISettings.getInstance().ACTIVATE_RIGHT_EDITOR_ON_CLOSE ? selectedIndex : selectedIndex + 1;
}
} else {
indexToInsert = initialIndex;
}
final VirtualFile file = editor.getFile();
final Icon template = AllIcons.FileTypes.Text;
myTabbedPane.insertTab(file, new EmptyIcon(template.getIconWidth(), template.getIconHeight()), new TComp(this, editor), null, indexToInsert);
@@ -709,7 +714,7 @@ public class EditorWindow {
myPanel.setOpaque(false);
myPanel.setBorder(new AdaptiveBorder());
myPanel.setOpaque(false);
final Splitter splitter = new Splitter(orientation == JSplitPane.VERTICAL_SPLIT, 0.5f, 0.1f, 0.9f);
final EditorWindow res = new EditorWindow(myOwner);
if (myTabbedPane != null) {
@@ -772,7 +777,7 @@ public class EditorWindow {
/**
* Tries to setup caret and viewport for the given editor from the selected one.
*
*
* @param toSync editor to setup caret and viewport for
*/
private void syncCaretIfPossible(@Nullable FileEditor[] toSync) {
@@ -809,6 +814,7 @@ public class EditorWindow {
scrollingModel.scrollVertically(scrollOffset);
SwingUtilities.invokeLater(new Runnable() {
@Override
public void run() {
if (!editor.isDisposed()) {
scrollingModel.scrollToCaret(ScrollType.MAKE_VISIBLE);
@@ -47,6 +47,7 @@ public class EditorWithProviderComposite extends EditorComposite {
return myProviders;
}
@Override
public boolean isModified() {
final FileEditor [] editors = getEditors ();
for (FileEditor editor : editors) {
@@ -57,6 +58,7 @@ public class EditorWithProviderComposite extends EditorComposite {
return false;
}
@Override
@NotNull
public Pair<FileEditor, FileEditorProvider> getSelectedEditorWithProvider() {
LOG.assertTrue(myEditors.length > 0, myEditors.length);
@@ -479,6 +479,7 @@ public class EditorsSplitters extends JBPanel {
myFilesToUpdateIconsFor.add(file);
myIconUpdaterAlarm.cancelAllRequests();
myIconUpdaterAlarm.addRequest(new Runnable() {
@Override
public void run() {
if (myManager.getProject().isDisposed()) return;
for (VirtualFile file : myFilesToUpdateIconsFor) {
@@ -650,6 +651,7 @@ public class EditorsSplitters extends JBPanel {
}
private final class MyFocusTraversalPolicy extends IdeFocusTraversalPolicy {
@Override
public final Component getDefaultComponentImpl(final Container focusCycleRoot) {
if (myCurrentWindow != null) {
final EditorWithProviderComposite selectedEditor = myCurrentWindow.getSelectedEditor();
@@ -708,6 +710,7 @@ public class EditorsSplitters extends JBPanel {
final EditorWithProviderComposite newEditor = window != null? window.getSelectedEditor() : null;
Runnable fireRunnable = new Runnable() {
@Override
public void run() {
getManager().fireSelectionChanged(newEditor);
}
@@ -824,6 +827,7 @@ public class EditorsSplitters extends JBPanel {
}
private final class MyFocusWatcher extends FocusWatcher {
@Override
protected void focusedComponentChanged(final Component component, final AWTEvent cause) {
EditorWindow newWindow = null;
@@ -159,6 +159,7 @@ public class FileEditorManagerImpl extends FileEditorManagerEx implements Projec
//-------------------------------------------------------------------------------
@Override
public JComponent getComponent() {
initUI();
return myPanels;
@@ -279,6 +280,7 @@ public class FileEditorManagerImpl extends FileEditorManagerEx implements Projec
}
}
@Override
public JComponent getPreferredFocusedComponent() {
assertReadAccess();
final EditorWindow window = getSplitters().getCurrentWindow();
@@ -312,6 +314,7 @@ public class FileEditorManagerImpl extends FileEditorManagerEx implements Projec
return FileUtil.getLocationRelativeToUserHome(file.getPresentableUrl());
}
@Override
public void updateFilePresentation(@NotNull VirtualFile file) {
if (!isFileOpen(file)) return;
@@ -357,10 +360,12 @@ public class FileEditorManagerImpl extends FileEditorManagerEx implements Projec
// Queue here is to prevent title flickering when tab is being closed and two events arriving: with component==null and component==next focused tab
// only the last event makes sense to handle
myQueue.queue(new Update("UpdateFileName " + (file == null ? "" : file.getPath())) {
@Override
public boolean isExpired() {
return myProject.isDisposed() || !myProject.isOpen() || (file == null ? super.isExpired() : !file.isValid());
}
@Override
public void run() {
Set<EditorsSplitters> all = getAllSplitters();
for (EditorsSplitters each : all) {
@@ -373,6 +378,7 @@ public class FileEditorManagerImpl extends FileEditorManagerEx implements Projec
//-------------------------------------------------------
@Override
public VirtualFile getFile(@NotNull final FileEditor editor) {
final EditorComposite editorComposite = getEditorComposite(editor);
if (editorComposite != null) {
@@ -381,6 +387,7 @@ public class FileEditorManagerImpl extends FileEditorManagerEx implements Projec
return null;
}
@Override
public void unsplitWindow() {
final EditorWindow currentWindow = getActiveSplitters(true).getResult().getCurrentWindow();
if (currentWindow != null) {
@@ -388,6 +395,7 @@ public class FileEditorManagerImpl extends FileEditorManagerEx implements Projec
}
}
@Override
public void unsplitAllWindow() {
final EditorWindow currentWindow = getActiveSplitters(true).getResult().getCurrentWindow();
if (currentWindow != null) {
@@ -407,6 +415,7 @@ public class FileEditorManagerImpl extends FileEditorManagerEx implements Projec
return getWindowSplitCount() > 1;
}
@Override
@NotNull
public EditorWindow[] getWindows() {
ArrayList<EditorWindow> windows = new ArrayList<EditorWindow>();
@@ -419,6 +428,7 @@ public class FileEditorManagerImpl extends FileEditorManagerEx implements Projec
return windows.toArray(new EditorWindow[windows.size()]);
}
@Override
public EditorWindow getNextWindow(@NotNull final EditorWindow window) {
final EditorWindow[] windows = getSplitters().getOrderedWindows();
for (int i = 0; i != windows.length; ++i) {
@@ -430,6 +440,7 @@ public class FileEditorManagerImpl extends FileEditorManagerEx implements Projec
return null;
}
@Override
public EditorWindow getPrevWindow(@NotNull final EditorWindow window) {
final EditorWindow[] windows = getSplitters().getOrderedWindows();
for (int i = 0; i != windows.length; ++i) {
@@ -441,6 +452,7 @@ public class FileEditorManagerImpl extends FileEditorManagerEx implements Projec
return null;
}
@Override
public void createSplitter(final int orientation, @Nullable final EditorWindow window) {
// window was available from action event, for example when invoked from the tab menu of an editor that is not the 'current'
if (window != null) {
@@ -455,6 +467,7 @@ public class FileEditorManagerImpl extends FileEditorManagerEx implements Projec
}
}
@Override
public void changeSplitterOrientation() {
final EditorWindow currentWindow = getSplitters().getCurrentWindow();
if (currentWindow != null) {
@@ -463,6 +476,7 @@ public class FileEditorManagerImpl extends FileEditorManagerEx implements Projec
}
@Override
public void flipTabs() {
/*
if (myTabs == null) {
@@ -480,6 +494,7 @@ public class FileEditorManagerImpl extends FileEditorManagerEx implements Projec
myPanels.revalidate();
}
@Override
public boolean tabsMode() {
return false;
}
@@ -492,20 +507,24 @@ public class FileEditorManagerImpl extends FileEditorManagerEx implements Projec
}
@Override
public boolean isInSplitter() {
final EditorWindow currentWindow = getSplitters().getCurrentWindow();
return currentWindow != null && currentWindow.inSplitter();
}
@Override
public boolean hasOpenedFile() {
final EditorWindow currentWindow = getSplitters().getCurrentWindow();
return currentWindow != null && currentWindow.getSelectedEditor() != null;
}
@Override
public VirtualFile getCurrentFile() {
return getActiveSplitters(true).getResult().getCurrentFile();
}
@Override
@NotNull
public AsyncResult<EditorWindow> getActiveWindow() {
return _getActiveWindow(false);
@@ -524,10 +543,12 @@ public class FileEditorManagerImpl extends FileEditorManagerEx implements Projec
return result;
}
@Override
public EditorWindow getCurrentWindow() {
return _getActiveWindow(true).getResult();
}
@Override
public void setCurrentWindow(final EditorWindow window) {
getActiveSplitters(true).getResult().setCurrentWindow(window, true);
}
@@ -536,6 +557,7 @@ public class FileEditorManagerImpl extends FileEditorManagerEx implements Projec
assertDispatchThread();
CommandProcessor.getInstance().executeCommand(myProject, new Runnable() {
@Override
public void run() {
if (window.isFileOpen(file)) {
window.closeFile(file, true, transferFocus);
@@ -552,12 +574,14 @@ public class FileEditorManagerImpl extends FileEditorManagerEx implements Projec
removeSelectionRecord(file, window);
}
@Override
public void closeFile(@NotNull final VirtualFile file, @NotNull final EditorWindow window) {
closeFile(file, window, true);
}
//============================= EditorManager methods ================================
@Override
public void closeFile(@NotNull final VirtualFile file) {
closeFile(file, true, false);
}
@@ -571,6 +595,7 @@ public class FileEditorManagerImpl extends FileEditorManagerEx implements Projec
}
CommandProcessor.getInstance().executeCommand(myProject, new Runnable() {
@Override
public void run() {
closeFileImpl(file, moveFocus, closeAllCopies);
}
@@ -582,6 +607,7 @@ public class FileEditorManagerImpl extends FileEditorManagerEx implements Projec
private void closeFileImpl(@NotNull final VirtualFile file, final boolean moveFocus, boolean closeAllCopies) {
assertDispatchThread();
runChange(new FileEditorManagerChange() {
@Override
public void run(EditorsSplitters splitters) {
splitters.closeFile(file, moveFocus);
}
@@ -590,6 +616,7 @@ public class FileEditorManagerImpl extends FileEditorManagerEx implements Projec
//-------------------------------------- Open File ----------------------------------------
@Override
@NotNull
public Pair<FileEditor[], FileEditorProvider[]> openFileWithProviders(@NotNull final VirtualFile file,
final boolean focusEditor,
@@ -697,6 +724,7 @@ public class FileEditorManagerImpl extends FileEditorManagerEx implements Projec
final boolean focusEditor) {
final Ref<Pair<FileEditor[], FileEditorProvider[]>> result = new Ref<Pair<FileEditor[], FileEditorProvider[]>>();
CommandProcessor.getInstance().executeCommand(myProject, new Runnable() {
@Override
public void run() {
result.set(openFileImpl3(window, file, focusEditor, null, true));
}
@@ -711,7 +739,6 @@ public class FileEditorManagerImpl extends FileEditorManagerEx implements Projec
* invalid file become selected. That's why we do not require that
* passed file is valid.
* @param entry map between FileEditorProvider and FileEditorState. If this parameter
* @param current
*/
@NotNull
Pair<FileEditor[], FileEditorProvider[]> openFileImpl3(@NotNull final EditorWindow window,
@@ -757,6 +784,7 @@ public class FileEditorManagerImpl extends FileEditorManagerEx implements Projec
providers = editorProviderManager.getProviders(myProject, file);
if (DumbService.getInstance(myProject).isDumb()) {
final List<FileEditorProvider> dumbAware = ContainerUtil.findAll(providers, new Condition<FileEditorProvider>() {
@Override
public boolean value(FileEditorProvider fileEditorProvider) {
return DumbService.isDumbAware(fileEditorProvider);
}
@@ -873,6 +901,7 @@ public class FileEditorManagerImpl extends FileEditorManagerEx implements Projec
window.getOwner().afterFileOpen(file);
UIUtil.invokeLaterIfNeeded(new Runnable() {
@Override
public void run() {
newSelectedComposite.getSelectedEditor().selectNotify();
}
@@ -1008,6 +1037,7 @@ public class FileEditorManagerImpl extends FileEditorManagerEx implements Projec
return newComposite;
}
@Override
@NotNull
public List<FileEditor> openEditor(@NotNull final OpenFileDescriptor descriptor, final boolean focusEditor) {
assertDispatchThread();
@@ -1021,6 +1051,7 @@ public class FileEditorManagerImpl extends FileEditorManagerEx implements Projec
final List<FileEditor> result = new ArrayList<FileEditor>();
CommandProcessor.getInstance().executeCommand(myProject, new Runnable() {
@Override
public void run() {
VirtualFile file = descriptor.getFile();
final FileEditor[] editors = openFile(file, focusEditor, !descriptor.isUseCurrentWindow());
@@ -1075,11 +1106,13 @@ public class FileEditorManagerImpl extends FileEditorManagerEx implements Projec
}
}
@Override
@NotNull
public Project getProject() {
return myProject;
}
@Override
@Nullable
public Editor openTextEditor(@NotNull final OpenFileDescriptor descriptor, final boolean focusEditor) {
final Collection<FileEditor> fileEditors = openEditor(descriptor, focusEditor);
@@ -1098,6 +1131,7 @@ public class FileEditorManagerImpl extends FileEditorManagerEx implements Projec
return editor;
}
@Override
public Editor getSelectedTextEditor() {
assertReadAccess();
@@ -1113,10 +1147,12 @@ public class FileEditorManagerImpl extends FileEditorManagerEx implements Projec
}
@Override
public boolean isFileOpen(@NotNull final VirtualFile file) {
return !getEditorComposites(file).isEmpty();
}
@Override
@NotNull
public VirtualFile[] getOpenFiles() {
HashSet<VirtualFile> openFiles = new HashSet<VirtualFile>();
@@ -1127,6 +1163,7 @@ public class FileEditorManagerImpl extends FileEditorManagerEx implements Projec
return VfsUtilCore.toVirtualFileArray(openFiles);
}
@Override
@NotNull
public VirtualFile[] getSelectedFiles() {
HashSet<VirtualFile> selectedFiles = new HashSet<VirtualFile>();
@@ -1137,6 +1174,7 @@ public class FileEditorManagerImpl extends FileEditorManagerEx implements Projec
return VfsUtilCore.toVirtualFileArray(selectedFiles);
}
@Override
@NotNull
public FileEditor[] getSelectedEditors() {
HashSet<FileEditor> selectedEditors = new HashSet<FileEditor>();
@@ -1147,12 +1185,14 @@ public class FileEditorManagerImpl extends FileEditorManagerEx implements Projec
return selectedEditors.toArray(new FileEditor[selectedEditors.size()]);
}
@Override
@NotNull
public EditorsSplitters getSplitters() {
EditorsSplitters active = getActiveSplitters(true).getResult();
return active == null ? getMainSplitters() : active;
}
@Override
@Nullable
public FileEditor getSelectedEditor(@NotNull final VirtualFile file) {
final Pair<FileEditor, FileEditorProvider> selectedEditorWithProvider = getSelectedEditorWithProvider(file);
@@ -1160,6 +1200,7 @@ public class FileEditorManagerImpl extends FileEditorManagerEx implements Projec
}
@Override
@Nullable
public Pair<FileEditor, FileEditorProvider> getSelectedEditorWithProvider(@NotNull VirtualFile file) {
if (file instanceof VirtualFileWindow) file = ((VirtualFileWindow)file).getDelegate();
@@ -1172,6 +1213,7 @@ public class FileEditorManagerImpl extends FileEditorManagerEx implements Projec
return composites.isEmpty() ? null : composites.get(0).getSelectedEditorWithProvider();
}
@Override
@NotNull
public Pair<FileEditor[], FileEditorProvider[]> getEditorsWithProviders(@NotNull final VirtualFile file) {
assertReadAccess();
@@ -1190,6 +1232,7 @@ public class FileEditorManagerImpl extends FileEditorManagerEx implements Projec
}
}
@Override
@NotNull
public FileEditor[] getEditors(@NotNull VirtualFile file) {
assertReadAccess();
@@ -1240,6 +1283,7 @@ public class FileEditorManagerImpl extends FileEditorManagerEx implements Projec
return result;
}
@Override
@NotNull
public FileEditor[] getAllEditors() {
assertReadAccess();
@@ -1255,14 +1299,17 @@ public class FileEditorManagerImpl extends FileEditorManagerEx implements Projec
return result.toArray(new FileEditor[result.size()]);
}
@Override
public void showEditorAnnotation(@NotNull FileEditor editor, @NotNull JComponent annotationComponent) {
addTopComponent(editor, annotationComponent);
}
@Override
public void removeEditorAnnotation(@NotNull FileEditor editor, @NotNull JComponent annotationComponent) {
removeTopComponent(editor, annotationComponent);
}
@Override
public void addTopComponent(@NotNull final FileEditor editor, @NotNull final JComponent component) {
final EditorComposite composite = getEditorComposite(editor);
if (composite != null) {
@@ -1270,6 +1317,7 @@ public class FileEditorManagerImpl extends FileEditorManagerEx implements Projec
}
}
@Override
public void removeTopComponent(@NotNull final FileEditor editor, @NotNull final JComponent component) {
final EditorComposite composite = getEditorComposite(editor);
if (composite != null) {
@@ -1277,6 +1325,7 @@ public class FileEditorManagerImpl extends FileEditorManagerEx implements Projec
}
}
@Override
public void addBottomComponent(@NotNull final FileEditor editor, @NotNull final JComponent component) {
final EditorComposite composite = getEditorComposite(editor);
if (composite != null) {
@@ -1284,6 +1333,7 @@ public class FileEditorManagerImpl extends FileEditorManagerEx implements Projec
}
}
@Override
public void removeBottomComponent(@NotNull final FileEditor editor, @NotNull final JComponent component) {
final EditorComposite composite = getEditorComposite(editor);
if (composite != null) {
@@ -1293,20 +1343,24 @@ public class FileEditorManagerImpl extends FileEditorManagerEx implements Projec
private final MessageListenerList<FileEditorManagerListener> myListenerList;
@Override
public void addFileEditorManagerListener(@NotNull final FileEditorManagerListener listener) {
myListenerList.add(listener);
}
@Override
public void addFileEditorManagerListener(@NotNull final FileEditorManagerListener listener, @NotNull final Disposable parentDisposable) {
myListenerList.add(listener, parentDisposable);
}
@Override
public void removeFileEditorManagerListener(@NotNull final FileEditorManagerListener listener) {
myListenerList.remove(listener);
}
// ProjectComponent methods
@Override
public void projectOpened() {
//myFocusWatcher.install(myWindows.getComponent ());
getMainSplitters().startListeningFocus();
@@ -1336,16 +1390,20 @@ public class FileEditorManagerImpl extends FileEditorManagerEx implements Projec
UISettings.getInstance().addUISettingsListener(myUISettingsListener, myProject);
StartupManager.getInstance(myProject).registerPostStartupActivity(new DumbAwareRunnable() {
@Override
public void run() {
setTabsMode(UISettings.getInstance().EDITOR_TAB_PLACEMENT != UISettings.TABS_NONE);
ToolWindowManager.getInstance(myProject).invokeLater(new Runnable() {
@Override
public void run() {
CommandProcessor.getInstance().executeCommand(myProject, new Runnable() {
@Override
public void run() {
LaterInvocator.invokeLater(new Runnable() {
@Override
public void run() {
long currentTime = System.nanoTime();
Long startTime = myProject.getUserData(ProjectImpl.CREATION_TIME);
@@ -1364,6 +1422,7 @@ public class FileEditorManagerImpl extends FileEditorManagerEx implements Projec
});
}
@Override
public void projectClosed() {
//myFocusWatcher.deinstall(myWindows.getComponent ());
getMainSplitters().dispose();
@@ -1375,23 +1434,28 @@ public class FileEditorManagerImpl extends FileEditorManagerEx implements Projec
// BaseCompomemnt methods
@Override
@NotNull
public String getComponentName() {
return FILE_EDITOR_MANAGER;
}
@Override
public void initComponent() {
}
@Override
public void disposeComponent() { /* really do nothing */ }
//JDOMExternalizable methods
@Override
public void writeExternal(final Element element) {
getMainSplitters().writeExternal(element);
}
@Override
public void readExternal(final Element element) {
getMainSplitters().readExternal(element);
}
@@ -1481,6 +1545,7 @@ public class FileEditorManagerImpl extends FileEditorManagerEx implements Projec
return new Trinity<VirtualFile, FileEditor, FileEditorProvider>(file, editor, provider);
}
@Override
public boolean isChanged(@NotNull final EditorComposite editor) {
final FileStatusManager fileStatusManager = FileStatusManager.getInstance(myProject);
if (fileStatusManager != null) {
@@ -1559,6 +1624,7 @@ public class FileEditorManagerImpl extends FileEditorManagerEx implements Projec
* Closes deleted files. Closes file which are in the deleted directories.
*/
private final class MyVirtualFileListener extends VirtualFileAdapter {
@Override
public void beforeFileDeletion(VirtualFileEvent e) {
assertDispatchThread();
@@ -1573,6 +1639,7 @@ public class FileEditorManagerImpl extends FileEditorManagerEx implements Projec
}
}
@Override
public void propertyChanged(VirtualFilePropertyEvent e) {
if (VirtualFile.PROP_NAME.equals(e.getPropertyName())) {
assertDispatchThread();
@@ -1602,6 +1669,7 @@ public class FileEditorManagerImpl extends FileEditorManagerEx implements Projec
}
}
@Override
public void fileMoved(VirtualFileMoveEvent e) {
final VirtualFile file = e.getFile();
final VirtualFile[] openFiles = getOpenFiles();
@@ -1626,11 +1694,13 @@ public class FileEditorManagerImpl extends FileEditorManagerEx implements Projec
return true;
}
@Override
public boolean isInsideChange() {
return getSplitters().isInsideChange();
}
private final class MyEditorPropertyChangeListener implements PropertyChangeListener {
@Override
public void propertyChange(final PropertyChangeEvent e) {
assertDispatchThread();
@@ -1662,6 +1732,7 @@ public class FileEditorManagerImpl extends FileEditorManagerEx implements Projec
* Gets events from VCS and updates color of myEditor tabs
*/
private final class MyFileStatusListener implements FileStatusListener {
@Override
public void fileStatusesChanged() { // update color of all open files
assertDispatchThread();
LOG.debug("FileEditorManagerImpl.MyFileStatusListener.fileStatusesChanged()");
@@ -1670,6 +1741,7 @@ public class FileEditorManagerImpl extends FileEditorManagerEx implements Projec
final VirtualFile file = openFiles[i];
LOG.assertTrue(file != null);
ApplicationManager.getApplication().invokeLater(new Runnable() {
@Override
public void run() {
if (LOG.isDebugEnabled()) {
LOG.debug("updating file status in tab for " + file.getPath());
@@ -1680,6 +1752,7 @@ public class FileEditorManagerImpl extends FileEditorManagerEx implements Projec
}
}
@Override
public void fileStatusChanged(@NotNull final VirtualFile file) { // update color of the file (if necessary)
assertDispatchThread();
if (isFileOpen(file)) {
@@ -1710,6 +1783,7 @@ public class FileEditorManagerImpl extends FileEditorManagerEx implements Projec
}
private class MyRootsListener extends ModuleRootAdapter {
@Override
public void rootsChanged(ModuleRootEvent event) {
EditorFileSwapper[] swappers = Extensions.getExtensions(EditorFileSwapper.EP_NAME);
@@ -1762,6 +1836,7 @@ public class FileEditorManagerImpl extends FileEditorManagerEx implements Projec
* and EDITOR_TAB_LIMIT, etc values.
*/
private final class MyUISettingsListener implements UISettingsListener {
@Override
public void uiSettingsChanged(final UISettings source) {
assertDispatchThread();
setTabsMode(source.EDITOR_TAB_PLACEMENT != UISettings.TABS_NONE && !UISettings.getInstance().PRESENTATION_MODE);
@@ -1790,6 +1865,7 @@ public class FileEditorManagerImpl extends FileEditorManagerEx implements Projec
}
}
@Override
public void closeAllFiles() {
final VirtualFile[] openFiles = getSplitters().getOpenFiles();
for (VirtualFile openFile : openFiles) {
@@ -1797,6 +1873,7 @@ public class FileEditorManagerImpl extends FileEditorManagerEx implements Projec
}
}
@Override
@NotNull
public VirtualFile[] getSiblings(@NotNull VirtualFile file) {
return getOpenFiles();
@@ -1804,6 +1881,7 @@ public class FileEditorManagerImpl extends FileEditorManagerEx implements Projec
protected void queueUpdateFile(final VirtualFile file) {
myQueue.queue(new Update(file) {
@Override
public void run() {
if (isFileOpen(file)) {
updateFileIcon(file);
@@ -1815,6 +1893,7 @@ public class FileEditorManagerImpl extends FileEditorManagerEx implements Projec
});
}
@Override
public EditorsSplitters getSplittersFor(Component c) {
EditorsSplitters splitters = null;
DockContainer dockContainer = myDockManager.getContainerFor(c);
@@ -57,10 +57,12 @@ public final class FileEditorProviderManagerImpl extends FileEditorProviderManag
public FileEditorProviderManagerImpl(FileEditorProvider[] providers) {
Extensions.getRootArea().getExtensionPoint(FileEditorProvider.EP_FILE_EDITOR_PROVIDER).addExtensionPointListener(
new ExtensionPointListener<FileEditorProvider>() {
@Override
public void extensionAdded(@NotNull final FileEditorProvider extension, @Nullable final PluginDescriptor pluginDescriptor) {
registerProvider(extension);
}
@Override
public void extensionRemoved(@NotNull final FileEditorProvider extension, @Nullable final PluginDescriptor pluginDescriptor) {
unregisterProvider(extension);
}
@@ -74,6 +76,7 @@ public final class FileEditorProviderManagerImpl extends FileEditorProviderManag
public FileEditorProviderManagerImpl() {
}
@Override
@NotNull
public synchronized FileEditorProvider[] getProviders(@NotNull final Project project, @NotNull final VirtualFile file){
// Collect all possible editors
@@ -113,6 +116,7 @@ public final class FileEditorProviderManagerImpl extends FileEditorProviderManag
}
}
@Override
@Nullable
public synchronized FileEditorProvider getProvider(@NotNull String editorTypeId){
for(int i=myProviders.size()-1;i>=0;i--){
@@ -211,6 +215,7 @@ public final class FileEditorProviderManagerImpl extends FileEditorProviderManag
: Double.MAX_VALUE;
}
@Override
public int compare(FileEditorProvider provider1, FileEditorProvider provider2) {
final int i1 = provider1.getPolicy().ordinal();
final int i2 = provider2.getPolicy().ordinal();
@@ -27,6 +27,7 @@ import com.intellij.openapi.vfs.VirtualFile;
*/
public class MoveEditorToOppositeTabGroupAction extends AnAction implements DumbAware {
@Override
public void actionPerformed(final AnActionEvent event) {
final DataContext dataContext = event.getDataContext();
final VirtualFile vFile = PlatformDataKeys.VIRTUAL_FILE.getData(dataContext);
@@ -46,6 +47,7 @@ public class MoveEditorToOppositeTabGroupAction extends AnAction implements Dumb
}
}
@Override
public void update(AnActionEvent e) {
final Presentation presentation = e.getPresentation();
final DataContext dataContext = e.getDataContext();
@@ -26,6 +26,7 @@ import com.intellij.openapi.project.DumbAware;
// The only purpose of this action is to serve as placeholder for assigning keyboard shortcuts.
// For actual tab switching code, see EditorComposite constructor.
public class SelectNextEditorTabAction extends AnAction implements DumbAware {
@Override
public void actionPerformed(final AnActionEvent e) {
}
@@ -26,6 +26,7 @@ import com.intellij.openapi.project.DumbAware;
// The only purpose of this action is to serve as placeholder for assigning keyboard shortcuts.
// For actual tab switching code, see EditorComposite constructor.
public class SelectPreviousEditorTabAction extends AnAction implements DumbAware {
@Override
public void actionPerformed(final AnActionEvent e) {
}
@@ -88,6 +88,7 @@ public final class TrailingSpacesStripper extends FileDocumentManagerAdapter {
@Override
public void run() {
CommandProcessor.getInstance().runUndoTransparentAction(new Runnable() {
@Override
public void run() {
if (CharArrayUtil.containsOnlyWhiteSpaces(content.subSequence(start, end)) && doStrip) {
document.deleteString(start, end);
@@ -57,275 +57,342 @@ public class WaverGraphicsDecorator extends Graphics2D {
}
}
@Override
public void draw(final Shape s) {
myOriginal.draw(s);
}
@Override
public boolean drawImage(final Image img, final AffineTransform xform, final ImageObserver obs) {
return myOriginal.drawImage(img, xform, obs);
}
@Override
public void drawImage(final BufferedImage img, final BufferedImageOp op, final int x, final int y) {
myOriginal.drawImage(img, op, x, y);
}
@Override
public void drawRenderedImage(final RenderedImage img, final AffineTransform xform) {
myOriginal.drawRenderedImage(img, xform);
}
@Override
public void drawRenderableImage(final RenderableImage img, final AffineTransform xform) {
myOriginal.drawRenderableImage(img, xform);
}
@Override
public void drawString(final String str, final int x, final int y) {
myOriginal.drawString(str, x, y);
drawWave(str, x, y);
}
@Override
public void drawString(final String s, final float x, final float y) {
myOriginal.drawString(s, x, y);
drawWave(s, (int)x, (int)y);
}
@Override
public void drawString(final AttributedCharacterIterator iterator, final int x, final int y) {
myOriginal.drawString(iterator, x, y);
//TODO: drawWave
}
@Override
public void drawString(final AttributedCharacterIterator iterator, final float x, final float y) {
myOriginal.drawString(iterator, x, y);
//TODO: drawWave
}
@Override
public void drawGlyphVector(final GlyphVector g, final float x, final float y) {
myOriginal.drawGlyphVector(g, x, y);
//TODO: drawWave
}
@Override
public void fill(final Shape s) {
myOriginal.fill(s);
}
@Override
public boolean hit(final Rectangle rect, final Shape s, final boolean onStroke) {
return myOriginal.hit(rect, s, onStroke);
}
@Override
public GraphicsConfiguration getDeviceConfiguration() {
return myOriginal.getDeviceConfiguration();
}
@Override
public void setComposite(final Composite comp) {
myOriginal.setComposite(comp);
}
@Override
public void setPaint(final Paint paint) {
myOriginal.setPaint(paint);
}
@Override
public void setStroke(final Stroke s) {
myOriginal.setStroke(s);
}
@Override
public void setRenderingHint(final RenderingHints.Key hintKey, final Object hintValue) {
myOriginal.setRenderingHint(hintKey, hintValue);
}
@Override
public Object getRenderingHint(final RenderingHints.Key hintKey) {
return myOriginal.getRenderingHint(hintKey);
}
@Override
public void setRenderingHints(final Map<?, ?> hints) {
myOriginal.setRenderingHints(hints);
}
@Override
public void addRenderingHints(final Map<?, ?> hints) {
myOriginal.addRenderingHints(hints);
}
@Override
public RenderingHints getRenderingHints() {
return myOriginal.getRenderingHints();
}
@Override
public void translate(final int x, final int y) {
myOriginal.translate(x, y);
}
@Override
public void translate(final double tx, final double ty) {
myOriginal.translate(tx, ty);
}
@Override
public void rotate(final double theta) {
myOriginal.rotate(theta);
}
@Override
public void rotate(final double theta, final double x, final double y) {
myOriginal.rotate(theta, x, y);
}
@Override
public void scale(final double sx, final double sy) {
myOriginal.scale(sx, sy);
}
@Override
public void shear(final double shx, final double shy) {
myOriginal.shear(shx, shy);
}
@Override
public void transform(final AffineTransform Tx) {
myOriginal.transform(Tx);
}
@Override
public void setTransform(final AffineTransform Tx) {
myOriginal.setTransform(Tx);
}
@Override
public AffineTransform getTransform() {
return myOriginal.getTransform();
}
@Override
public Paint getPaint() {
return myOriginal.getPaint();
}
@Override
public Composite getComposite() {
return myOriginal.getComposite();
}
@Override
public void setBackground(final Color color) {
myOriginal.setBackground(color);
}
@Override
public Color getBackground() {
return myOriginal.getBackground();
}
@Override
public Stroke getStroke() {
return myOriginal.getStroke();
}
@Override
public void clip(final Shape s) {
myOriginal.clip(s);
}
@Override
public FontRenderContext getFontRenderContext() {
return myOriginal.getFontRenderContext();
}
@Override
public Graphics create() {
return new WaverGraphicsDecorator((Graphics2D)myOriginal.create(), myWaveColor);
}
@Override
public Color getColor() {
return myOriginal.getColor();
}
@Override
public void setColor(final Color c) {
myOriginal.setColor(c);
}
@Override
public void setPaintMode() {
myOriginal.setPaintMode();
}
@Override
public void setXORMode(final Color c1) {
myOriginal.setXORMode(c1);
}
@Override
public Font getFont() {
return myOriginal.getFont();
}
@Override
public void setFont(final Font font) {
myOriginal.setFont(font);
}
@Override
public FontMetrics getFontMetrics(final Font f) {
return myOriginal.getFontMetrics(f);
}
@Override
public Rectangle getClipBounds() {
return myOriginal.getClipBounds();
}
@Override
public void clipRect(final int x, final int y, final int width, final int height) {
myOriginal.clipRect(x, y, width, height);
}
@Override
public void setClip(final int x, final int y, final int width, final int height) {
myOriginal.setClip(x, y, width, height);
}
@Override
public Shape getClip() {
return myOriginal.getClip();
}
@Override
public void setClip(final Shape clip) {
myOriginal.setClip(clip);
}
@Override
public void copyArea(final int x, final int y, final int width, final int height, final int dx, final int dy) {
myOriginal.copyArea(x, y, width, height, dx, dy);
}
@Override
public void drawLine(final int x1, final int y1, final int x2, final int y2) {
myOriginal.drawLine(x1, y1, x2, y2);
}
@Override
public void fillRect(final int x, final int y, final int width, final int height) {
myOriginal.fillRect(x, y, width, height);
}
@Override
public void clearRect(final int x, final int y, final int width, final int height) {
myOriginal.clearRect(x, y, width, height);
}
@Override
public void drawRoundRect(final int x, final int y, final int width, final int height, final int arcWidth, final int arcHeight) {
myOriginal.drawRoundRect(x, y, width, height, arcWidth, arcHeight);
}
@Override
public void fillRoundRect(final int x, final int y, final int width, final int height, final int arcWidth, final int arcHeight) {
myOriginal.fillRoundRect(x, y, width, height, arcWidth, arcHeight);
}
@Override
public void drawOval(final int x, final int y, final int width, final int height) {
myOriginal.drawOval(x, y, width, height);
}
@Override
public void fillOval(final int x, final int y, final int width, final int height) {
myOriginal.fillOval(x, y, width, height);
}
@Override
public void drawArc(final int x, final int y, final int width, final int height, final int startAngle, final int arcAngle) {
myOriginal.drawArc(x, y, width, height, startAngle, arcAngle);
}
@Override
public void fillArc(final int x, final int y, final int width, final int height, final int startAngle, final int arcAngle) {
myOriginal.fillArc(x, y, width, height, startAngle, arcAngle);
}
@Override
public void drawPolyline(final int[] xPoints, final int[] yPoints, final int nPoints) {
myOriginal.drawPolyline(xPoints, yPoints, nPoints);
}
@Override
public void drawPolygon(final int[] xPoints, final int[] yPoints, final int nPoints) {
myOriginal.drawPolygon(xPoints, yPoints, nPoints);
}
@Override
public void fillPolygon(final int[] xPoints, final int[] yPoints, final int nPoints) {
myOriginal.fillPolygon(xPoints, yPoints, nPoints);
}
@Override
public boolean drawImage(final Image img, final int x, final int y, final ImageObserver observer) {
return myOriginal.drawImage(img, x, y, observer);
}
@Override
public boolean drawImage(final Image img, final int x, final int y, final int width, final int height, final ImageObserver observer) {
return myOriginal.drawImage(img, x, y, width, height, observer);
}
@Override
public boolean drawImage(final Image img, final int x, final int y, final Color bgcolor, final ImageObserver observer) {
return myOriginal.drawImage(img, x, y, bgcolor, observer);
}
@Override
public boolean drawImage(final Image img,
final int x,
final int y,
@@ -336,6 +403,7 @@ public class WaverGraphicsDecorator extends Graphics2D {
return myOriginal.drawImage(img, x, y, width, height, bgcolor, observer);
}
@Override
public boolean drawImage(final Image img,
final int dx1,
final int dy1,
@@ -349,6 +417,7 @@ public class WaverGraphicsDecorator extends Graphics2D {
return myOriginal.drawImage(img, dx1, dy1, dx2, dy2, sx1, sy1, sx2, sy2, observer);
}
@Override
public boolean drawImage(final Image img,
final int dx1,
final int dy1,
@@ -363,47 +432,58 @@ public class WaverGraphicsDecorator extends Graphics2D {
return myOriginal.drawImage(img, dx1, dy1, dx2, dy2, sx1, sy1, sx2, sy2, bgcolor, observer);
}
@Override
public void dispose() {
//myOriginal.dispose();
}
@Override
public Rectangle getClipRect() {
return myOriginal.getClipRect();
}
@Override
public boolean hitClip(final int x, final int y, final int width, final int height) {
return myOriginal.hitClip(x, y, width, height);
}
@Override
public Rectangle getClipBounds(final Rectangle r) {
return myOriginal.getClipBounds(r);
}
@Override
public void fill3DRect(final int x, final int y, final int width, final int height, final boolean raised) {
myOriginal.fill3DRect(x, y, width, height, raised);
}
@Override
public void draw3DRect(final int x, final int y, final int width, final int height, final boolean raised) {
myOriginal.draw3DRect(x, y, width, height, raised);
}
@Override
public Graphics create(final int x, final int y, final int width, final int height) {
return new WaverGraphicsDecorator((Graphics2D)myOriginal.create(x, y, width, height), myWaveColor);
}
@Override
public void drawRect(final int x, final int y, final int width, final int height) {
myOriginal.drawRect(x, y, width, height);
}
@Override
public void drawPolygon(final Polygon p) {
myOriginal.drawPolygon(p);
}
@Override
public void fillPolygon(final Polygon p) {
myOriginal.fillPolygon(p);
}
@Override
public FontMetrics getFontMetrics() {
return myOriginal.getFontMetrics();
}
@@ -47,11 +47,13 @@ public class HttpFileEditor implements TextEditor {
myPanel = new RemoteFilePanel(project, virtualFile);
}
@Override
@NotNull
public JComponent getComponent() {
return myPanel.getMainPanel();
}
@Override
public JComponent getPreferredFocusedComponent() {
final TextEditor textEditor = myPanel.getFileEditor();
if (textEditor != null) {
@@ -60,11 +62,13 @@ public class HttpFileEditor implements TextEditor {
return myPanel.getMainPanel();
}
@Override
@NotNull
public String getName() {
return "Http";
}
@Override
@NotNull
public Editor getEditor() {
final TextEditor fileEditor = myPanel.getFileEditor();
@@ -77,6 +81,7 @@ public class HttpFileEditor implements TextEditor {
return myMockTextEditor;
}
@Override
@NotNull
public FileEditorState getState(@NotNull final FileEditorStateLevel level) {
final TextEditor textEditor = myPanel.getFileEditor();
@@ -86,6 +91,7 @@ public class HttpFileEditor implements TextEditor {
return new TextEditorState();
}
@Override
public void setState(@NotNull final FileEditorState state) {
final TextEditor textEditor = myPanel.getFileEditor();
if (textEditor != null) {
@@ -93,30 +99,37 @@ public class HttpFileEditor implements TextEditor {
}
}
@Override
public boolean isModified() {
return false;
}
@Override
public boolean isValid() {
return true;
}
@Override
public void selectNotify() {
myPanel.selectNotify();
}
@Override
public void deselectNotify() {
myPanel.deselectNotify();
}
@Override
public void addPropertyChangeListener(@NotNull final PropertyChangeListener listener) {
myPanel.addPropertyChangeListener(listener);
}
@Override
public void removePropertyChangeListener(@NotNull final PropertyChangeListener listener) {
myPanel.removePropertyChangeListener(listener);
}
@Override
public BackgroundEditorHighlighter getBackgroundHighlighter() {
final TextEditor textEditor = myPanel.getFileEditor();
if (textEditor != null) {
@@ -125,6 +138,7 @@ public class HttpFileEditor implements TextEditor {
return null;
}
@Override
public boolean canNavigateTo(@NotNull Navigatable navigatable) {
final TextEditor textEditor = myPanel.getFileEditor();
if (textEditor != null) {
@@ -133,6 +147,7 @@ public class HttpFileEditor implements TextEditor {
return false;
}
@Override
public void navigateTo(@NotNull Navigatable navigatable) {
final TextEditor textEditor = myPanel.getFileEditor();
if (textEditor != null) {
@@ -140,6 +155,7 @@ public class HttpFileEditor implements TextEditor {
}
}
@Override
public <T> T getUserData(@NotNull Key<T> key) {
final TextEditor textEditor = myPanel.getFileEditor();
if (textEditor != null) {
@@ -148,6 +164,7 @@ public class HttpFileEditor implements TextEditor {
return myUserDataHolder.getUserData(key);
}
@Override
public <T> void putUserData(@NotNull Key<T> key, @Nullable T value) {
final TextEditor textEditor = myPanel.getFileEditor();
if (textEditor != null) {
@@ -158,6 +175,7 @@ public class HttpFileEditor implements TextEditor {
}
}
@Override
public FileEditorLocation getCurrentLocation() {
final TextEditor textEditor = myPanel.getFileEditor();
if (textEditor != null) {
@@ -166,6 +184,7 @@ public class HttpFileEditor implements TextEditor {
return null;
}
@Override
public StructureViewBuilder getStructureViewBuilder() {
final TextEditor textEditor = myPanel.getFileEditor();
if (textEditor != null) {
@@ -174,6 +193,7 @@ public class HttpFileEditor implements TextEditor {
return null;
}
@Override
public void dispose() {
if (myMockTextEditor != null) {
EditorFactory.getInstance().releaseEditor(myMockTextEditor);
@@ -32,32 +32,39 @@ import org.jetbrains.annotations.NotNull;
* @author nik
*/
public class HttpFileEditorProvider implements FileEditorProvider, DumbAware {
@Override
public boolean accept(@NotNull final Project project, @NotNull final VirtualFile file) {
return file instanceof HttpVirtualFile && !file.isDirectory();
}
@Override
@NotNull
public FileEditor createEditor(@NotNull final Project project, @NotNull final VirtualFile file) {
return new HttpFileEditor(project, (HttpVirtualFile)file);
return new HttpFileEditor(project, (HttpVirtualFile)file);
}
@Override
public void disposeEditor(@NotNull final FileEditor editor) {
Disposer.dispose(editor);
}
@Override
@NotNull
public FileEditorState readState(@NotNull final Element sourceElement, @NotNull final Project project, @NotNull final VirtualFile file) {
return new TextEditorState();
}
@Override
public void writeState(@NotNull final FileEditorState state, @NotNull final Project project, @NotNull final Element targetElement) {
}
@Override
@NotNull
public String getEditorTypeId() {
return "httpFileEditor";
}
@Override
@NotNull
public FileEditorPolicy getPolicy() {
return FileEditorPolicy.HIDE_DEFAULT_EDITOR;
@@ -45,10 +45,12 @@ public class FileDropHandler implements EditorDropHandler {
}
@Override
public boolean canHandleDrop(final DataFlavor[] transferFlavors) {
return transferFlavors != null && FileCopyPasteUtil.isFileListFlavorSupported(transferFlavors);
}
@Override
public void handleDrop(@NotNull final Transferable t, @Nullable final Project project, EditorWindow editorWindow) {
if (project == null || !FileCopyPasteUtil.isFileListFlavorSupported(t)) {
return;
@@ -36,6 +36,7 @@ import java.beans.PropertyChangeListener;
*/
public class LargeFileEditorProvider implements FileEditorProvider, DumbAware {
@Override
public boolean accept(@NotNull Project project, @NotNull VirtualFile file) {
if (file.isDirectory() || !file.isValid()) {
return false;
@@ -43,28 +44,34 @@ public class LargeFileEditorProvider implements FileEditorProvider, DumbAware {
return SingleRootFileViewProvider.isTooLargeForContentLoading(file);
}
@Override
@NotNull
public FileEditor createEditor(@NotNull Project project, @NotNull final VirtualFile file) {
return new LargeFileEditor(file);
}
@Override
public void disposeEditor(@NotNull FileEditor editor) {
Disposer.dispose(editor);
}
@Override
@NotNull
public FileEditorState readState(@NotNull Element element, @NotNull Project project, @NotNull VirtualFile file) {
return FileEditorState.INSTANCE;
}
@Override
public void writeState(@NotNull FileEditorState _state, @NotNull Project project, @NotNull Element element) {
}
@Override
@NotNull
public String getEditorTypeId() {
return "LargeFileEditor";
}
@Override
@NotNull
public FileEditorPolicy getPolicy() {
return FileEditorPolicy.NONE;
@@ -121,6 +121,7 @@ public abstract class AbstractFileProcessor {
final Runnable[] resultRunnable = new Runnable[1];
execute(new Runnable() {
@Override
public void run() {
try {
resultRunnable[0] = preprocessFile(file);
@@ -130,6 +131,7 @@ public abstract class AbstractFileProcessor {
}
}
}, new Runnable() {
@Override
public void run() {
if (resultRunnable[0] != null) {
resultRunnable[0].run();
@@ -182,6 +184,7 @@ public abstract class AbstractFileProcessor {
}
return new Runnable() {
@Override
public void run() {
ProgressIndicator indicator = ProgressManager.getInstance().getProgressIndicator();
String msg = null;
@@ -219,10 +222,12 @@ public abstract class AbstractFileProcessor {
private void process(final PsiFile[] files) {
final Runnable[] resultRunnable = new Runnable[1];
execute(new Runnable() {
@Override
public void run() {
resultRunnable[0] = prepareFiles(new ArrayList<PsiFile>(Arrays.asList(files)));
}
}, new Runnable() {
@Override
public void run() {
if (resultRunnable[0] != null) {
resultRunnable[0].run();
@@ -234,6 +239,7 @@ public abstract class AbstractFileProcessor {
private void process(final PsiDirectory dir, final boolean subdirs) {
final List<PsiFile> pfiles = new ArrayList<PsiFile>();
ProgressManager.getInstance().runProcessWithProgressSynchronously(new Runnable() {
@Override
public void run() {
findFiles(pfiles, dir, subdirs);
}
@@ -244,6 +250,7 @@ public abstract class AbstractFileProcessor {
private void process(final Project project) {
final List<PsiFile> pfiles = new ArrayList<PsiFile>();
ProgressManager.getInstance().runProcessWithProgressSynchronously(new Runnable() {
@Override
public void run() {
findFiles(project, pfiles);
}
@@ -254,6 +261,7 @@ public abstract class AbstractFileProcessor {
private void process(final Module module) {
final List<PsiFile> pfiles = new ArrayList<PsiFile>();
ProgressManager.getInstance().runProcessWithProgressSynchronously(new Runnable() {
@Override
public void run() {
findFiles(module, pfiles);
}
@@ -276,6 +284,7 @@ public abstract class AbstractFileProcessor {
for (VirtualFile root : roots) {
idx.iterateContentUnderDirectory(root, new ContentIterator() {
@Override
public boolean processFile(final VirtualFile dir) {
if (dir.isDirectory()) {
final PsiDirectory psiDir = PsiManager.getInstance(module.getProject()).findDirectory(dir);
@@ -299,10 +308,12 @@ public abstract class AbstractFileProcessor {
if (!files.isEmpty()) {
final Runnable[] resultRunnable = new Runnable[1];
execute(new Runnable() {
@Override
public void run() {
resultRunnable[0] = prepareFiles(files);
}
}, new Runnable() {
@Override
public void run() {
if (resultRunnable[0] != null) {
resultRunnable[0].run();
@@ -335,11 +346,13 @@ public abstract class AbstractFileProcessor {
private void execute(final Runnable readAction, final Runnable writeAction) {
ProgressManager.getInstance().runProcessWithProgressSynchronously(new Runnable() {
@Override
public void run() {
readAction.run();
}
}, title, true, myProject);
new WriteCommandAction(myProject, title) {
@Override
protected void run(Result result) throws Throwable {
writeAction.run();
}