diff options
Diffstat (limited to 'platform/platform-api/src/com/intellij/openapi')
16 files changed, 295 insertions, 52 deletions
diff --git a/platform/platform-api/src/com/intellij/openapi/actionSystem/AbbreviationManager.java b/platform/platform-api/src/com/intellij/openapi/actionSystem/AbbreviationManager.java index 78db7cf0ed5c..1e03a3482ad4 100644 --- a/platform/platform-api/src/com/intellij/openapi/actionSystem/AbbreviationManager.java +++ b/platform/platform-api/src/com/intellij/openapi/actionSystem/AbbreviationManager.java @@ -15,7 +15,7 @@ */ package com.intellij.openapi.actionSystem; -import com.intellij.openapi.application.ApplicationManager; +import com.intellij.openapi.components.ServiceManager; import java.util.List; import java.util.Set; @@ -26,11 +26,16 @@ import java.util.Set; */ public abstract class AbbreviationManager { public static AbbreviationManager getInstance() { - return ApplicationManager.getApplication().getComponent(AbbreviationManager.class); + return ServiceManager.getService(AbbreviationManager.class); } + public abstract Set<String> getAbbreviations(); + public abstract Set<String> getAbbreviations(String actionId); + public abstract List<String> findActions(String abbreviation); + public abstract void register(String abbreviation, String actionId); + public abstract void remove(String abbreviation, String actionId); } diff --git a/platform/platform-api/src/com/intellij/openapi/editor/actionSystem/CaretSpecificDataContext.java b/platform/platform-api/src/com/intellij/openapi/editor/actionSystem/CaretSpecificDataContext.java new file mode 100644 index 000000000000..e53cc48e4d5a --- /dev/null +++ b/platform/platform-api/src/com/intellij/openapi/editor/actionSystem/CaretSpecificDataContext.java @@ -0,0 +1,47 @@ +/* + * Copyright 2000-2014 JetBrains s.r.o. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package com.intellij.openapi.editor.actionSystem; + +import com.intellij.openapi.actionSystem.CommonDataKeys; +import com.intellij.openapi.actionSystem.DataContext; +import com.intellij.openapi.actionSystem.DataContextWrapper; +import com.intellij.openapi.editor.Caret; +import com.intellij.openapi.fileEditor.FileEditorManager; +import com.intellij.openapi.project.Project; +import org.jetbrains.annotations.NonNls; +import org.jetbrains.annotations.NotNull; +import org.jetbrains.annotations.Nullable; + +public class CaretSpecificDataContext extends DataContextWrapper { + private final Caret myCaret; + + public CaretSpecificDataContext(@NotNull DataContext delegate, @NotNull Caret caret) { + super(delegate); + myCaret = caret; + } + + @Nullable + @Override + public Object getData(@NonNls String dataId) { + Project project = (Project)super.getData(CommonDataKeys.PROJECT.getName()); + if (project == null) { + return null; + } + FileEditorManager fm = FileEditorManager.getInstance(project); + Object data = fm == null ? null : fm.getData(dataId, myCaret.getEditor(), myCaret); + return data == null ? super.getData(dataId) : data; + } +} diff --git a/platform/platform-api/src/com/intellij/openapi/editor/actionSystem/EditorAction.java b/platform/platform-api/src/com/intellij/openapi/editor/actionSystem/EditorAction.java index 945c52022984..d93a508f97bd 100644 --- a/platform/platform-api/src/com/intellij/openapi/editor/actionSystem/EditorAction.java +++ b/platform/platform-api/src/com/intellij/openapi/editor/actionSystem/EditorAction.java @@ -26,13 +26,14 @@ import org.jetbrains.annotations.Nullable; import java.awt.event.KeyEvent; +import static com.intellij.openapi.actionSystem.CommonDataKeys.EDITOR; import static com.intellij.openapi.actionSystem.CommonDataKeys.PROJECT; public abstract class EditorAction extends AnAction implements DumbAware { private EditorActionHandler myHandler; private boolean myHandlersLoaded; - public EditorActionHandler getHandler() { + public final EditorActionHandler getHandler() { ensureHandlersLoaded(); return myHandler; } @@ -46,6 +47,7 @@ public abstract class EditorAction extends AnAction implements DumbAware { ensureHandlersLoaded(); EditorActionHandler tmp = myHandler; myHandler = newHandler; + myHandler.setWorksInInjected(isInInjectedContext()); return tmp; } @@ -58,12 +60,22 @@ public abstract class EditorAction extends AnAction implements DumbAware { final EditorActionHandlerBean handlerBean = extensions[i]; if (handlerBean.action.equals(id)) { myHandler = handlerBean.getHandler(myHandler); + myHandler.setWorksInInjected(isInInjectedContext()); } } } } @Override + public void setInjectedContext(boolean worksInInjected) { + super.setInjectedContext(worksInInjected); + // we assume that this method is called in constructor at the point + // where the chain of handlers is not initialized yet + // and it's enough to pass the flag to the default handler only + myHandler.setWorksInInjected(isInInjectedContext()); + } + + @Override public final void actionPerformed(AnActionEvent e) { DataContext dataContext = e.getDataContext(); Editor editor = getEditor(dataContext); @@ -72,7 +84,7 @@ public abstract class EditorAction extends AnAction implements DumbAware { @Nullable protected Editor getEditor(@NotNull DataContext dataContext) { - return CommonDataKeys.EDITOR.getData(dataContext); + return EDITOR.getData(dataContext); } public final void actionPerformed(final Editor editor, @NotNull final DataContext dataContext) { @@ -102,7 +114,7 @@ public abstract class EditorAction extends AnAction implements DumbAware { } public void update(Editor editor, Presentation presentation, DataContext dataContext) { - presentation.setEnabled(getHandler().isEnabled(editor, dataContext)); + presentation.setEnabled(getHandler().isEnabled(editor, null, dataContext)); } public void updateForKeyboardAccess(Editor editor, Presentation presentation, DataContext dataContext) { diff --git a/platform/platform-api/src/com/intellij/openapi/editor/actionSystem/EditorActionHandler.java b/platform/platform-api/src/com/intellij/openapi/editor/actionSystem/EditorActionHandler.java index c43fd13d8bef..294622ce1916 100644 --- a/platform/platform-api/src/com/intellij/openapi/editor/actionSystem/EditorActionHandler.java +++ b/platform/platform-api/src/com/intellij/openapi/editor/actionSystem/EditorActionHandler.java @@ -15,7 +15,7 @@ */ package com.intellij.openapi.editor.actionSystem; -import com.intellij.openapi.actionSystem.DataContext; +import com.intellij.openapi.actionSystem.*; import com.intellij.openapi.editor.Caret; import com.intellij.openapi.editor.CaretAction; import com.intellij.openapi.editor.Editor; @@ -35,7 +35,9 @@ import org.jetbrains.annotations.Nullable; */ public abstract class EditorActionHandler { private final boolean myRunForEachCaret; + private boolean myWorksInInjected; private boolean inExecution; + private boolean inCheck; protected EditorActionHandler() { this(false); @@ -46,17 +48,92 @@ public abstract class EditorActionHandler { } /** - * Checks if the action handler is currently enabled. - * - * @param editor the editor in which the action is invoked. - * @param dataContext the data context for the action. - * @return true if the action is enabled, false otherwise + * @deprecated Implementations should override + * {@link #isEnabledForCaret(com.intellij.openapi.editor.Editor, com.intellij.openapi.editor.Caret, com.intellij.openapi.actionSystem.DataContext)} + * instead, + * client code should invoke + * {@link #isEnabled(com.intellij.openapi.editor.Editor, com.intellij.openapi.editor.Caret, com.intellij.openapi.actionSystem.DataContext)} + * instead. */ - public boolean isEnabled(Editor editor, DataContext dataContext) { - return true; + public boolean isEnabled(Editor editor, final DataContext dataContext) { + if (inCheck) { + return true; + } + inCheck = true; + try { + if (editor == null) { + return false; + } + Editor hostEditor = dataContext == null ? null : CommonDataKeys.HOST_EDITOR.getData(dataContext); + if (hostEditor == null) { + hostEditor = editor; + } + final boolean[] result = new boolean[1]; + final CaretTask check = new CaretTask() { + @Override + public void perform(@NotNull Caret caret, @Nullable DataContext dataContext) { + result[0] = true; + } + }; + if (myRunForEachCaret) { + hostEditor.getCaretModel().runForEachCaret(new CaretAction() { + @Override + public void perform(Caret caret) { + doIfEnabled(caret, dataContext, check); + } + }); + } + else { + doIfEnabled(hostEditor.getCaretModel().getCurrentCaret(), dataContext, check); + } + return result[0]; + } + finally { + inCheck = false; + } + } + + private void doIfEnabled(@NotNull Caret hostCaret, @Nullable DataContext context, @NotNull CaretTask task) { + DataContext caretContext = context == null ? null : new CaretSpecificDataContext(context, hostCaret); + if (myWorksInInjected && caretContext != null) { + DataContext injectedCaretContext = AnActionEvent.getInjectedDataContext(caretContext); + Caret injectedCaret = CommonDataKeys.CARET.getData(injectedCaretContext); + if (injectedCaret != null && injectedCaret != hostCaret && isEnabledForCaret(injectedCaret.getEditor(), injectedCaret, injectedCaretContext)) { + task.perform(injectedCaret, injectedCaretContext); + return; + } + } + if (isEnabledForCaret(hostCaret.getEditor(), hostCaret, caretContext)) { + task.perform(hostCaret, caretContext); + } } /** + * Implementations can override this method to define whether handler is enabled for a specific caret in a given editor. + */ + protected boolean isEnabledForCaret(@NotNull Editor editor, @NotNull Caret caret, DataContext dataContext) { + if (inCheck) { + return true; + } + inCheck = true; + try { + //noinspection deprecation + return isEnabled(editor, dataContext); + } + finally { + inCheck = false; + } + } + + /** + * If <code>caret</code> is <code>null</code>, checks whether handler is enabled in general (i.e. enabled for at least one caret in editor), + * if <code>caret</code> is not <code>null</code>, checks whether it's enabled for specified caret. + */ + public final boolean isEnabled(@NotNull Editor editor, @Nullable Caret caret, DataContext dataContext) { + //noinspection deprecation + return caret == null ? isEnabled(editor, dataContext) : isEnabledForCaret(editor, caret, dataContext); + } + /** * @deprecated To implement action logic, override * {@link #doExecute(com.intellij.openapi.editor.Editor, com.intellij.openapi.editor.Caret, com.intellij.openapi.actionSystem.DataContext)}, * to invoke the handler, call @@ -112,22 +189,49 @@ public abstract class EditorActionHandler { * @param editor the editor in which the action is invoked. * @param dataContext the data context for the action. */ - public final void execute(@NotNull final Editor editor, @Nullable Caret contextCaret, final DataContext dataContext) { + public final void execute(@NotNull Editor editor, @Nullable final Caret contextCaret, final DataContext dataContext) { + Editor hostEditor = dataContext == null ? null : CommonDataKeys.HOST_EDITOR.getData(dataContext); + if (hostEditor == null) { + hostEditor = editor; + } if (contextCaret == null && runForAllCarets()) { - editor.getCaretModel().runForEachCaret(new CaretAction() { + hostEditor.getCaretModel().runForEachCaret(new CaretAction() { @Override public void perform(Caret caret) { - doExecute(editor, caret, dataContext); + doIfEnabled(caret, dataContext, new CaretTask() { + @Override + public void perform(@NotNull Caret caret, @Nullable DataContext dataContext) { + doExecute(caret.getEditor(), caret, dataContext); + } + }); } }, true); } else { - doExecute(editor, contextCaret, dataContext); + if (contextCaret == null) { + doIfEnabled(hostEditor.getCaretModel().getCurrentCaret(), dataContext, new CaretTask() { + @Override + public void perform(@NotNull Caret caret, @Nullable DataContext dataContext) { + doExecute(caret.getEditor(), null, dataContext); + } + }); + } + else { + doExecute(editor, contextCaret, dataContext); + } } } + void setWorksInInjected(boolean worksInInjected) { + myWorksInInjected = worksInInjected; + } + public DocCommandGroupId getCommandGroupId(Editor editor) { // by default avoid merging two consequential commands, and, in the same time, pass along the Document return DocCommandGroupId.noneGroupId(editor.getDocument()); } + + private interface CaretTask { + void perform(@NotNull Caret caret, @Nullable DataContext dataContext); + } } diff --git a/platform/platform-api/src/com/intellij/openapi/fileEditor/EditorDataProvider.java b/platform/platform-api/src/com/intellij/openapi/fileEditor/EditorDataProvider.java index 7dfec0240c1f..90d05360be0e 100644 --- a/platform/platform-api/src/com/intellij/openapi/fileEditor/EditorDataProvider.java +++ b/platform/platform-api/src/com/intellij/openapi/fileEditor/EditorDataProvider.java @@ -1,5 +1,5 @@ /* - * Copyright 2000-2009 JetBrains s.r.o. + * Copyright 2000-2014 JetBrains s.r.o. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -15,14 +15,14 @@ */ package com.intellij.openapi.fileEditor; +import com.intellij.openapi.editor.Caret; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; import com.intellij.openapi.editor.Editor; -import com.intellij.openapi.vfs.VirtualFile; /** * @author peter */ public interface EditorDataProvider { - @Nullable Object getData(@NotNull String dataId, @NotNull Editor e, @NotNull VirtualFile file); + @Nullable Object getData(@NotNull String dataId, @NotNull Editor e, @NotNull Caret caret); } diff --git a/platform/platform-api/src/com/intellij/openapi/fileEditor/FileEditorManager.java b/platform/platform-api/src/com/intellij/openapi/fileEditor/FileEditorManager.java index b9589574059d..86e719eef48d 100644 --- a/platform/platform-api/src/com/intellij/openapi/fileEditor/FileEditorManager.java +++ b/platform/platform-api/src/com/intellij/openapi/fileEditor/FileEditorManager.java @@ -1,5 +1,5 @@ /* - * Copyright 2000-2009 JetBrains s.r.o. + * Copyright 2000-2014 JetBrains s.r.o. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -16,6 +16,7 @@ package com.intellij.openapi.fileEditor; import com.intellij.openapi.Disposable; +import com.intellij.openapi.editor.Caret; import com.intellij.openapi.editor.Editor; import com.intellij.openapi.project.Project; import com.intellij.openapi.util.Key; @@ -184,6 +185,13 @@ public abstract class FileEditorManager { public abstract void registerExtraEditorDataProvider(@NotNull EditorDataProvider provider, Disposable parentDisposable); /** + * Returns data associated with given editor/caret context. Data providers are registered via + * {@link #registerExtraEditorDataProvider(EditorDataProvider, com.intellij.openapi.Disposable)} method. + */ + @Nullable + public abstract Object getData(@NotNull String dataId, @NotNull Editor editor, @NotNull Caret caret); + + /** * Selects a specified file editor tab for the specified editor. * @param file a file to switch the file editor tab for. The function does nothing if the file is not currently open in the editor. * @param fileEditorProviderId the ID of the file editor to open; matches the return value of diff --git a/platform/platform-api/src/com/intellij/openapi/ui/ComboBoxTableRenderer.java b/platform/platform-api/src/com/intellij/openapi/ui/ComboBoxTableRenderer.java index c02f27af5d4b..f35d76fff51c 100644 --- a/platform/platform-api/src/com/intellij/openapi/ui/ComboBoxTableRenderer.java +++ b/platform/platform-api/src/com/intellij/openapi/ui/ComboBoxTableRenderer.java @@ -117,7 +117,7 @@ public class ComboBoxTableRenderer<T> extends JLabel implements TableCellRendere public Component getTableCellEditorComponent(JTable table, final Object value, boolean isSelected, final int row, final int column) { @SuppressWarnings("unchecked") final T t = (T)value; myValue = t; - customizeComponent(t, table, isSelected); + customizeComponent(t, table, true); //noinspection SSBasedInspection SwingUtilities.invokeLater(new Runnable() { diff --git a/platform/platform-api/src/com/intellij/openapi/ui/ComponentWithActions.java b/platform/platform-api/src/com/intellij/openapi/ui/ComponentWithActions.java index d6310f508ed0..889fb2786188 100644 --- a/platform/platform-api/src/com/intellij/openapi/ui/ComponentWithActions.java +++ b/platform/platform-api/src/com/intellij/openapi/ui/ComponentWithActions.java @@ -1,5 +1,5 @@ /* - * Copyright 2000-2009 JetBrains s.r.o. + * Copyright 2000-2014 JetBrains s.r.o. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -41,11 +41,11 @@ public interface ComponentWithActions { boolean isContentBuiltIn(); class Impl implements ComponentWithActions { - private ActionGroup myToolbar; - private String myToolbarPlace; - private JComponent myToolbarContext; - private JComponent mySearchComponent; - private JComponent myComponent; + private final ActionGroup myToolbar; + private final String myToolbarPlace; + private final JComponent myToolbarContext; + private final JComponent mySearchComponent; + private final JComponent myComponent; public Impl(final ActionGroup toolbar, final String toolbarPlace, final JComponent toolbarContext, final JComponent searchComponent, @@ -57,6 +57,7 @@ public interface ComponentWithActions { myComponent = component; } + @Override public boolean isContentBuiltIn() { return false; } @@ -65,22 +66,27 @@ public interface ComponentWithActions { this(null, null, null, null, component); } + @Override public ActionGroup getToolbarActions() { return myToolbar; } + @Override public JComponent getSearchComponent() { return mySearchComponent; } + @Override public String getToolbarPlace() { return myToolbarPlace; } + @Override public JComponent getToolbarContextComponent() { return myToolbarContext; } + @Override @NotNull public JComponent getComponent() { return myComponent; diff --git a/platform/platform-api/src/com/intellij/openapi/ui/MasterDetailsComponent.java b/platform/platform-api/src/com/intellij/openapi/ui/MasterDetailsComponent.java index 6c13964d5789..a262ea0a3b85 100644 --- a/platform/platform-api/src/com/intellij/openapi/ui/MasterDetailsComponent.java +++ b/platform/platform-api/src/com/intellij/openapi/ui/MasterDetailsComponent.java @@ -122,7 +122,7 @@ public abstract class MasterDetailsComponent implements Configurable, DetailsCom private boolean myHasDeletedItems; protected AutoScrollToSourceHandler myAutoScrollHandler; - private boolean myToReInitWholePanel = true; + protected boolean myToReInitWholePanel = true; protected MasterDetailsComponent() { this(new MasterDetailsState()); @@ -139,7 +139,7 @@ public abstract class MasterDetailsComponent implements Configurable, DetailsCom reInitWholePanelIfNeeded(); } - private void reInitWholePanelIfNeeded() { + protected void reInitWholePanelIfNeeded() { if (!myToReInitWholePanel) return; myWholePanel = new JPanel(new BorderLayout()) { @@ -177,7 +177,8 @@ public abstract class MasterDetailsComponent implements Configurable, DetailsCom decorator.setActionGroup(group); } //left.add(myNorthPanel, BorderLayout.NORTH); - myMaster = decorator.setPanelBorder(new EmptyBorder(0, 0, 0, 0)).createPanel(); + myMaster = decorator.setAsUsualTopToolbar().setPanelBorder(new EmptyBorder(0, 0, 0, 0)).createPanel(); + myNorthPanel.setVisible(false); } else { left.add(myNorthPanel, BorderLayout.NORTH); myMaster = ScrollPaneFactory.createScrollPane(myTree); @@ -280,6 +281,7 @@ public abstract class MasterDetailsComponent implements Configurable, DetailsCom } private void initToolbar() { + if (Registry.is("ide.new.project.settings")) return; DefaultActionGroup group = createToolbarActionGroup(); if (group != null) { final JComponent component = ActionManager.getInstance().createActionToolbar(ActionPlaces.UNKNOWN, group, true).getComponent(); diff --git a/platform/platform-api/src/com/intellij/openapi/ui/PanelWithText.java b/platform/platform-api/src/com/intellij/openapi/ui/PanelWithText.java index 172772139ccf..fc6c3c6686cd 100644 --- a/platform/platform-api/src/com/intellij/openapi/ui/PanelWithText.java +++ b/platform/platform-api/src/com/intellij/openapi/ui/PanelWithText.java @@ -1,5 +1,5 @@ /* - * Copyright 2000-2009 JetBrains s.r.o. + * Copyright 2000-2014 JetBrains s.r.o. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -36,7 +36,7 @@ public class PanelWithText extends JPanel { public PanelWithText(String text) { super(new GridBagLayout()); - setBorder(BorderFactory.createEtchedBorder()); + //setBorder(BorderFactory.createEtchedBorder()); myLabel.setText(XmlStringUtil.wrapInHtml(text)); add(myLabel, new GridBagConstraints(0, 0, 1, 1, 1, 1, GridBagConstraints.NORTH, GridBagConstraints.HORIZONTAL, new Insets(8,8,8,8), 0, 0)); } diff --git a/platform/platform-api/src/com/intellij/openapi/ui/popup/ListItemDescriptorAdapter.java b/platform/platform-api/src/com/intellij/openapi/ui/popup/ListItemDescriptorAdapter.java new file mode 100644 index 000000000000..e11e70c74b98 --- /dev/null +++ b/platform/platform-api/src/com/intellij/openapi/ui/popup/ListItemDescriptorAdapter.java @@ -0,0 +1,44 @@ +/* + * Copyright 2000-2009 JetBrains s.r.o. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package com.intellij.openapi.ui.popup; + +import org.jetbrains.annotations.Nullable; + +import javax.swing.*; + +public abstract class ListItemDescriptorAdapter<T> implements ListItemDescriptor<T> { + @Nullable + @Override + public String getCaptionAboveOf(T value) { + return null; + } + + @Nullable + @Override + public String getTooltipFor(T value) { + return null; + } + + @Override + public Icon getIconFor(T value) { + return null; + } + + @Override + public boolean hasSeparatorAboveOf(T value) { + return false; + } +}
\ No newline at end of file diff --git a/platform/platform-api/src/com/intellij/openapi/vfs/VfsUtil.java b/platform/platform-api/src/com/intellij/openapi/vfs/VfsUtil.java index 3cd467048e98..254f7749fb25 100644 --- a/platform/platform-api/src/com/intellij/openapi/vfs/VfsUtil.java +++ b/platform/platform-api/src/com/intellij/openapi/vfs/VfsUtil.java @@ -51,7 +51,9 @@ import java.util.*; public class VfsUtil extends VfsUtilCore { private static final Logger LOG = Logger.getInstance("#com.intellij.openapi.vfs.VfsUtil"); - public static final char VFS_PATH_SEPARATOR = '/'; + + /** @deprecated incorrect name, use {@link #VFS_SEPARATOR_CHAR} (to be removed in IDEA 15) */ + public static final char VFS_PATH_SEPARATOR = VFS_SEPARATOR_CHAR; public static void saveText(@NotNull VirtualFile file, @NotNull String text) throws IOException { Charset charset = file.getCharset(); @@ -585,7 +587,7 @@ public class VfsUtil extends VfsUtilCore { if (url == null) { return null; } - final int index = url.lastIndexOf(VFS_PATH_SEPARATOR); + final int index = url.lastIndexOf(VfsUtil.VFS_SEPARATOR_CHAR); return index < 0 ? null : url.substring(0, index); } @@ -598,12 +600,12 @@ public class VfsUtil extends VfsUtilCore { if (urlOrPath == null) { return null; } - final int index = urlOrPath.lastIndexOf(VFS_PATH_SEPARATOR); + final int index = urlOrPath.lastIndexOf(VfsUtil.VFS_SEPARATOR_CHAR); return index < 0 ? null : urlOrPath.substring(index+1); } @NotNull - public static List<VirtualFile> markDirty(boolean recursive, boolean reloadChildren, VirtualFile... files) { + public static List<VirtualFile> markDirty(boolean recursive, boolean reloadChildren, @NotNull VirtualFile... files) { List<VirtualFile> list = ContainerUtil.filter(Condition.NOT_NULL, files); if (list.isEmpty()) { return Collections.emptyList(); @@ -626,7 +628,7 @@ public class VfsUtil extends VfsUtilCore { return list; } - public static void markDirtyAndRefresh(boolean async, boolean recursive, boolean reloadChildren, VirtualFile... files) { + public static void markDirtyAndRefresh(boolean async, boolean recursive, boolean reloadChildren, @NotNull VirtualFile... files) { List<VirtualFile> list = markDirty(recursive, reloadChildren, files); if (list.isEmpty()) return; LocalFileSystem.getInstance().refreshFiles(list, async, recursive, null); diff --git a/platform/platform-api/src/com/intellij/openapi/wm/FocusCommand.java b/platform/platform-api/src/com/intellij/openapi/wm/FocusCommand.java index 6c40a04f5831..38dcb877e030 100644 --- a/platform/platform-api/src/com/intellij/openapi/wm/FocusCommand.java +++ b/platform/platform-api/src/com/intellij/openapi/wm/FocusCommand.java @@ -192,7 +192,7 @@ public abstract class FocusCommand extends ActiveRunnable implements Expirable { LOG.info("We could not request focus in window on " + myToFocus.getClass().getName()); LOG.info(myAllocation); } - if (!SystemInfo.isMac || isForced() ) { + if (isForced()) { myToFocus.requestFocus(); if (shouldLogFocuses) { LOG.info("Force request focus on " + myToFocus.getClass().getName()); @@ -217,10 +217,6 @@ public abstract class FocusCommand extends ActiveRunnable implements Expirable { if (myToFocus == null) { return true; } - if (SwingUtilities.getWindowAncestor(myToFocus) == null) { - clear(); - return true; - } return false; } diff --git a/platform/platform-api/src/com/intellij/openapi/wm/IdeFocusManager.java b/platform/platform-api/src/com/intellij/openapi/wm/IdeFocusManager.java index d8f7e86d4b9e..6b4852319899 100644 --- a/platform/platform-api/src/com/intellij/openapi/wm/IdeFocusManager.java +++ b/platform/platform-api/src/com/intellij/openapi/wm/IdeFocusManager.java @@ -1,5 +1,5 @@ /* - * Copyright 2000-2013 JetBrains s.r.o. + * Copyright 2000-2014 JetBrains s.r.o. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -163,9 +163,8 @@ public abstract class IdeFocusManager implements FocusRequestor { public abstract void toFront(JComponent c); public static IdeFocusManager getInstance(@Nullable Project project) { - if (project == null) return getGlobalInstance(); + if (project == null || project.isDisposed() || !project.isInitialized()) return getGlobalInstance(); - if (project.isDisposed() || !project.isInitialized()) return getGlobalInstance(); return project.getComponent(IdeFocusManager.class); } diff --git a/platform/platform-api/src/com/intellij/openapi/wm/ToolWindowFactory.java b/platform/platform-api/src/com/intellij/openapi/wm/ToolWindowFactory.java index 477ff28baef6..cc198e18a140 100644 --- a/platform/platform-api/src/com/intellij/openapi/wm/ToolWindowFactory.java +++ b/platform/platform-api/src/com/intellij/openapi/wm/ToolWindowFactory.java @@ -1,5 +1,5 @@ /* - * Copyright 2000-2009 JetBrains s.r.o. + * Copyright 2000-2014 JetBrains s.r.o. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -17,6 +17,7 @@ package com.intellij.openapi.wm; import com.intellij.openapi.project.Project; +import org.jetbrains.annotations.NotNull; /** * Performs lazy initialization of a toolwindow registered in plugin.xml. @@ -25,5 +26,5 @@ import com.intellij.openapi.project.Project; * @see ToolWindowEP */ public interface ToolWindowFactory { - void createToolWindowContent(Project project, ToolWindow toolWindow); + void createToolWindowContent(@NotNull Project project, @NotNull ToolWindow toolWindow); } diff --git a/platform/platform-api/src/com/intellij/openapi/wm/ToolWindowManager.java b/platform/platform-api/src/com/intellij/openapi/wm/ToolWindowManager.java index 0e7ddb332151..b616429a11c8 100644 --- a/platform/platform-api/src/com/intellij/openapi/wm/ToolWindowManager.java +++ b/platform/platform-api/src/com/intellij/openapi/wm/ToolWindowManager.java @@ -1,5 +1,5 @@ /* - * Copyright 2000-2009 JetBrains s.r.o. + * Copyright 2000-2014 JetBrains s.r.o. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -47,16 +47,25 @@ public abstract class ToolWindowManager { * @return tool window * @deprecated {@link com.intellij.openapi.wm.ToolWindowManager#registerToolWindow(String, boolean, ToolWindowAnchor)} */ - public abstract ToolWindow registerToolWindow(@NotNull String id,@NotNull JComponent component,@NotNull ToolWindowAnchor anchor); + @Deprecated + @NotNull + public abstract ToolWindow registerToolWindow(@NotNull String id, @NotNull JComponent component, @NotNull ToolWindowAnchor anchor); /** * @deprecated {@link com.intellij.openapi.wm.ToolWindowManager#registerToolWindow(String, boolean, ToolWindowAnchor)} */ - public abstract ToolWindow registerToolWindow(@NotNull String id,@NotNull JComponent component,@NotNull ToolWindowAnchor anchor, Disposable parentDisposable); + @Deprecated + @NotNull + public abstract ToolWindow registerToolWindow(@NotNull String id, + @NotNull JComponent component, + @NotNull ToolWindowAnchor anchor, + @NotNull Disposable parentDisposable); /** * @deprecated {@link com.intellij.openapi.wm.ToolWindowManager#registerToolWindow(String, boolean, ToolWindowAnchor)} */ + @Deprecated + @NotNull public abstract ToolWindow registerToolWindow(@NotNull String id, @NotNull JComponent component, @NotNull ToolWindowAnchor anchor, @@ -65,6 +74,8 @@ public abstract class ToolWindowManager { /** * @deprecated {@link com.intellij.openapi.wm.ToolWindowManager#registerToolWindow(String, boolean, ToolWindowAnchor)} */ + @Deprecated + @NotNull public abstract ToolWindow registerToolWindow(@NotNull String id, @NotNull JComponent component, @NotNull ToolWindowAnchor anchor, @@ -72,12 +83,16 @@ public abstract class ToolWindowManager { boolean canWorkInDumbMode, boolean canCloseContents); + @NotNull public abstract ToolWindow registerToolWindow(@NotNull String id, boolean canCloseContent, @NotNull ToolWindowAnchor anchor); + @NotNull public abstract ToolWindow registerToolWindow(@NotNull String id, boolean canCloseContent, @NotNull ToolWindowAnchor anchor, boolean secondary); + @NotNull public abstract ToolWindow registerToolWindow(@NotNull String id, boolean canCloseContent, @NotNull ToolWindowAnchor anchor, Disposable parentDisposable, boolean canWorkInDumbMode); + @NotNull public ToolWindow registerToolWindow(@NotNull final String id, final boolean canCloseContent, @NotNull final ToolWindowAnchor anchor, @@ -102,6 +117,7 @@ public abstract class ToolWindowManager { /** * @return array of <code>id</code>s of all registered tool windows. */ + @NotNull public abstract String[] getToolWindowIds(); /** @@ -120,11 +136,12 @@ public abstract class ToolWindowManager { /** * Puts specified runnable to the tail of current command queue. */ - public abstract void invokeLater(Runnable runnable); + public abstract void invokeLater(@NotNull Runnable runnable); /** * Utility method for quick access to the focus manager */ + @NotNull public abstract IdeFocusManager getFocusManager(); public abstract void notifyByBalloon(@NotNull final String toolWindowId, @NotNull final MessageType type, @NotNull final String htmlBody); |