*/
public final class ToggleTransparencyChessboardAction extends ToggleAction {
public boolean isSelected(AnActionEvent e) {
- ImageComponentDecorator decorator = (ImageComponentDecorator)e.getDataContext().getData(ImageComponentDecorator.class.getName());
+ ImageComponentDecorator decorator = ImageComponentDecorator.DATA_KEY.getData(e.getDataContext());
return decorator != null && decorator.isEnabledForActionPlace(e.getPlace()) && decorator.isTransparencyChessboardVisible();
}
public void setSelected(AnActionEvent e, boolean state) {
- ImageComponentDecorator decorator = (ImageComponentDecorator)e.getDataContext().getData(ImageComponentDecorator.class.getName());
+ ImageComponentDecorator decorator = ImageComponentDecorator.DATA_KEY.getData(e.getDataContext());
if (decorator != null && decorator.isEnabledForActionPlace(e.getPlace())) {
decorator.setTransparencyChessboardVisible(state);
}
public void update(final AnActionEvent e) {
super.update(e);
- ImageComponentDecorator decorator = (ImageComponentDecorator)e.getDataContext().getData(ImageComponentDecorator.class.getName());
+ ImageComponentDecorator decorator = ImageComponentDecorator.DATA_KEY.getData(e.getDataContext());
e.getPresentation().setEnabled(decorator != null && decorator.isEnabledForActionPlace(e.getPlace()));
e.getPresentation().setText(isSelected(e) ? "Hide Chessboard" : "Show Chessboard");
}
final PsiActionSupportFactory factory = PsiActionSupportFactory.getInstance();
copyPasteSupport = factory.createPsiBasedCopyPasteSupport(editor.getProject(), this, new PsiActionSupportFactory.PsiElementSelector() {
public PsiElement[] getSelectedElements() {
- return (PsiElement[]) getData(DataConstants.PSI_ELEMENT_ARRAY);
+ return LangDataKeys.PSI_ELEMENT_ARRAY.getData(ImageEditorUI.this);
}
});
@Nullable
public Object getData(String dataId) {
- if (DataConstants.PROJECT.equals(dataId)) {
+ if (PlatformDataKeys.PROJECT.is(dataId)) {
return editor.getProject();
- } else if (DataConstants.VIRTUAL_FILE.equals(dataId)) {
+ } else if (PlatformDataKeys.VIRTUAL_FILE.is(dataId)) {
return editor.getFile();
- } else if (DataConstants.VIRTUAL_FILE_ARRAY.equals(dataId)) {
+ } else if (PlatformDataKeys.VIRTUAL_FILE_ARRAY.is(dataId)) {
return new VirtualFile[]{editor.getFile()};
- } else if (DataConstants.PSI_FILE.equals(dataId)) {
- return getData(DataConstants.PSI_ELEMENT);
- } else if (DataConstants.PSI_ELEMENT.equals(dataId)) {
+ } else if (LangDataKeys.PSI_FILE.is(dataId)) {
+ return getData(LangDataKeys.PSI_ELEMENT.getName());
+ } else if (LangDataKeys.PSI_ELEMENT.is(dataId)) {
VirtualFile file = editor.getFile();
return file != null && file.isValid() ? PsiManager.getInstance(editor.getProject()).findFile(file) : null;
- } else if (DataConstants.PSI_ELEMENT_ARRAY.equals(dataId)) {
- return new PsiElement[]{(PsiElement) getData(DataConstants.PSI_ELEMENT)};
- } else if (DataConstants.COPY_PROVIDER.equals(dataId)) {
+ } else if (LangDataKeys.PSI_ELEMENT_ARRAY.is(dataId)) {
+ return new PsiElement[]{(PsiElement) getData(LangDataKeys.PSI_ELEMENT.getName())};
+ } else if (PlatformDataKeys.COPY_PROVIDER.is(dataId)) {
return copyPasteSupport.getCopyProvider();
- } else if (DataConstants.CUT_PROVIDER.equals(dataId)) {
+ } else if (PlatformDataKeys.CUT_PROVIDER.is(dataId)) {
return copyPasteSupport.getCutProvider();
- } else if (DataConstants.DELETE_ELEMENT_PROVIDER.equals(dataId)) {
+ } else if (PlatformDataKeys.DELETE_ELEMENT_PROVIDER.is(dataId)) {
return deleteProvider;
- } else if (ImageComponentDecorator.class.getName().equals(dataId)) {
+ } else if (ImageComponentDecorator.DATA_KEY.is(dataId)) {
return editor;
}
package org.intellij.images.thumbnail;
import com.intellij.openapi.Disposable;
+import com.intellij.openapi.actionSystem.DataKey;
import com.intellij.openapi.project.Project;
import com.intellij.openapi.vfs.VirtualFile;
import org.intellij.images.ImagesBundle;
* @author <a href="mailto:aefimov.box@gmail.com">Alexey Efimov</a>
*/
public interface ThumbnailView extends Disposable, ImageComponentDecorator {
- String TOOLWINDOW_ID = ImagesBundle.message("thumbnails.toolwindow.name");
+ DataKey<ThumbnailView> DATA_KEY = DataKey.create(ThumbnailView.class.getName());
- @NotNull
- Project getProject();
+ String TOOLWINDOW_ID = ImagesBundle.message("thumbnails.toolwindow.name");
- /**
- * Add virtual files to view
- *
- * @param root Root
- */
- void setRoot(@NotNull VirtualFile root);
+ @NotNull
+ Project getProject();
- /**
- * Return current root
- *
- * @return Current root
- */
- VirtualFile getRoot();
+ /**
+ * Add virtual files to view
+ *
+ * @param root Root
+ */
+ void setRoot(@NotNull VirtualFile root);
- boolean isRecursive();
+ /**
+ * Return current root
+ *
+ * @return Current root
+ */
+ VirtualFile getRoot();
- void setRecursive(boolean recursive);
+ boolean isRecursive();
- void setSelected(@NotNull VirtualFile file, boolean selected);
+ void setRecursive(boolean recursive);
- boolean isSelected(@NotNull VirtualFile file);
+ void setSelected(@NotNull VirtualFile file, boolean selected);
- @NotNull
- VirtualFile[] getSelection();
+ boolean isSelected(@NotNull VirtualFile file);
- /**
- * Scroll to selection. If ToolWindow is not active, then
- * it will perform activatation before scroll.
- */
- void scrollToSelection();
+ @NotNull
+ VirtualFile[] getSelection();
- void setVisible(boolean visible);
+ /**
+ * Scroll to selection. If ToolWindow is not active, then
+ * it will perform activatation before scroll.
+ */
+ void scrollToSelection();
- boolean isVisible();
+ void setVisible(boolean visible);
- void activate();
+ boolean isVisible();
+
+ void activate();
}
package org.intellij.images.thumbnail.actionSystem;
import com.intellij.openapi.actionSystem.AnActionEvent;
-import com.intellij.openapi.actionSystem.DataContext;
import com.intellij.openapi.actionSystem.Presentation;
import org.intellij.images.thumbnail.ThumbnailView;
}
public static ThumbnailView getThumbnailView(AnActionEvent e) {
- DataContext dataContext = e.getDataContext();
- return (ThumbnailView) dataContext.getData(ThumbnailView.class.getName());
+ return ThumbnailView.DATA_KEY.getData(e.getDataContext());
}
/**
final PsiActionSupportFactory factory = PsiActionSupportFactory.getInstance();
copyPasteSupport = factory.createPsiBasedCopyPasteSupport(thumbnailView.getProject(), this, new PsiActionSupportFactory.PsiElementSelector() {
public PsiElement[] getSelectedElements() {
- return (PsiElement[]) getData(DataConstants.PSI_ELEMENT_ARRAY);
+ return (PsiElement[]) getData(LangDataKeys.PSI_ELEMENT_ARRAY.getName());
}
});
@Nullable
public Object getData(String dataId) {
- if (DataConstants.PROJECT.equals(dataId)) {
+ if (PlatformDataKeys.PROJECT.is(dataId)) {
return thumbnailView.getProject();
- } else if (DataConstants.VIRTUAL_FILE.equals(dataId)) {
+ } else if (PlatformDataKeys.VIRTUAL_FILE.is(dataId)) {
VirtualFile[] selectedFiles = getSelectedFiles();
return selectedFiles.length > 0 ? selectedFiles[0] : null;
- } else if (DataConstants.VIRTUAL_FILE_ARRAY.equals(dataId)) {
+ } else if (PlatformDataKeys.VIRTUAL_FILE_ARRAY.is(dataId)) {
return getSelectedFiles();
- } else if (DataConstants.PSI_FILE.equals(dataId)) {
- return getData(DataConstants.PSI_ELEMENT);
- } else if (DataConstants.PSI_ELEMENT.equals(dataId)) {
+ } else if (LangDataKeys.PSI_FILE.is(dataId)) {
+ return getData(LangDataKeys.PSI_ELEMENT.getName());
+ } else if (LangDataKeys.PSI_ELEMENT.is(dataId)) {
VirtualFile[] selectedFiles = getSelectedFiles();
return selectedFiles.length > 0 ? PsiManager.getInstance(thumbnailView.getProject()).findFile(selectedFiles[0]) : null;
- } else if (DataConstants.PSI_ELEMENT_ARRAY.equals(dataId)) {
+ } else if (LangDataKeys.PSI_ELEMENT_ARRAY.is(dataId)) {
return getSelectedElements();
- } else if (DataConstants.NAVIGATABLE.equals(dataId)) {
+ } else if (PlatformDataKeys.NAVIGATABLE.is(dataId)) {
VirtualFile[] selectedFiles = getSelectedFiles();
return new ThumbnailNavigatable(selectedFiles.length > 0 ? selectedFiles[0] : null);
- } else if (DataConstants.COPY_PROVIDER.equals(dataId)) {
+ } else if (PlatformDataKeys.COPY_PROVIDER.is(dataId)) {
return copyPasteSupport.getCopyProvider();
- } else if (DataConstants.CUT_PROVIDER.equals(dataId)) {
+ } else if (PlatformDataKeys.CUT_PROVIDER.is(dataId)) {
return copyPasteSupport.getCutProvider();
- } else if (DataConstants.PASTE_PROVIDER.equals(dataId)) {
+ } else if (PlatformDataKeys.PASTE_PROVIDER.is(dataId)) {
return copyPasteSupport.getPasteProvider();
- } else if (DataConstants.DELETE_ELEMENT_PROVIDER.equals(dataId)) {
+ } else if (PlatformDataKeys.DELETE_ELEMENT_PROVIDER.is(dataId)) {
return deleteProvider;
- } else if (DataConstants.NAVIGATABLE_ARRAY.equals(dataId)) {
+ } else if (PlatformDataKeys.NAVIGATABLE_ARRAY.is(dataId)) {
VirtualFile[] selectedFiles = getSelectedFiles();
Set<Navigatable> navigatables = new HashSet<Navigatable>(selectedFiles.length);
for (VirtualFile selectedFile : selectedFiles) {
}
}
return navigatables.toArray(EMPTY_NAVIGATABLE_ARRAY);
- } else if (ThumbnailView.class.getName().equals(dataId)) {
+ } else if (ThumbnailView.DATA_KEY.is(dataId)) {
return thumbnailView;
- } else if (ImageComponentDecorator.class.getName().equals(dataId)) {
+ } else if (ImageComponentDecorator.DATA_KEY.is(dataId)) {
return thumbnailView;
}
psiElements.add(element);
}
}
- return psiElements.toArray(PsiElement.EMPTY_ARRAY);
+ return psiElements.toArray(new PsiElement[psiElements.size()]);
}
@NotNull
*/
package org.intellij.images.ui;
+import com.intellij.openapi.actionSystem.DataKey;
+
/**
* Image Component manager. It can toggle backround transparency, grid, etc.
*
* @author Alexey Efimov
*/
public interface ImageComponentDecorator {
- void setTransparencyChessboardVisible(boolean visible);
+ DataKey<ImageComponentDecorator> DATA_KEY = DataKey.create(ImageComponentDecorator.class.getName());
+
+ void setTransparencyChessboardVisible(boolean visible);
- boolean isTransparencyChessboardVisible();
+ boolean isTransparencyChessboardVisible();
- /**
- * Return <code>true</code> if this decorator is enabled for this action place.
- *
- * @param place Action place
- * @return <code>true</code> is decorator is enabled
- */
- boolean isEnabledForActionPlace(String place);
+ /**
+ * Return <code>true</code> if this decorator is enabled for this action place.
+ *
+ * @param place Action place
+ * @return <code>true</code> is decorator is enabled
+ */
+ boolean isEnabledForActionPlace(String place);
}
package com.intellij.compiler.actions;
import com.intellij.openapi.actionSystem.AnActionEvent;
-import com.intellij.openapi.actionSystem.DataConstants;
import com.intellij.openapi.actionSystem.DataContext;
+import com.intellij.openapi.actionSystem.PlatformDataKeys;
import com.intellij.openapi.actionSystem.Presentation;
import com.intellij.openapi.compiler.CompilerManager;
import com.intellij.openapi.project.Project;
if (!presentation.isEnabled()) {
return;
}
- presentation.setEnabled(event.getDataContext().getData(DataConstants.PROJECT) != null);
+ presentation.setEnabled(PlatformDataKeys.PROJECT.getData(event.getDataContext()) != null);
}
}
\ No newline at end of file
private static final Logger LOG = Logger.getInstance("#com.intellij.compiler.actions.MakeModuleAction");
protected void doAction(DataContext dataContext, Project project) {
- Module[] modules = (Module[])dataContext.getData(DataConstants.MODULE_CONTEXT_ARRAY);
+ Module[] modules = LangDataKeys.MODULE_CONTEXT_ARRAY.getData(dataContext);
Module module;
if (modules == null) {
module = LangDataKeys.MODULE.getData(dataContext);
}
final DataContext dataContext = event.getDataContext();
final Module module = LangDataKeys.MODULE.getData(dataContext);
- Module[] modules = (Module[])dataContext.getData(DataConstants.MODULE_CONTEXT_ARRAY);
+ Module[] modules = LangDataKeys.MODULE_CONTEXT_ARRAY.getData(dataContext);
final boolean isEnabled = module != null || modules != null;
presentation.setEnabled(isEnabled);
final String actionName = getTemplatePresentation().getTextWithMnemonic();
presentation.setText(presentationText);
presentation.setVisible(isEnabled || !ActionPlaces.PROJECT_VIEW_POPUP.equals(event.getPlace()));
}
-}
\ No newline at end of file
+}
}
}
else {
- final Editor editor = (Editor)context.getData(PlatformDataKeys.EDITOR.getName());
+ final Editor editor = e.getData(PlatformDataKeys.EDITOR);
enabled = DebuggerUtilsEx.getEditorText(editor) != null;
}
e.getPresentation().setEnabled(enabled);
addFromNodes(debuggerContext, watchPanel, selectedNodes);
}
else {
- final Editor editor = (Editor)context.getData(PlatformDataKeys.EDITOR.getName());
+ final Editor editor = e.getData(PlatformDataKeys.EDITOR);
if (editor != null) {
final TextWithImports editorText = DebuggerUtilsEx.getEditorText(editor);
if (editorText != null) {
}
}
-}
\ No newline at end of file
+}
@Nullable
public static DebuggerTree getTree(DataContext dataContext){
- return (DebuggerTree)dataContext.getData(DebuggerActions.DEBUGGER_TREE);
+ return DebuggerTree.DATA_KEY.getData(dataContext);
}
@Nullable
public static DebuggerTreePanel getPanel(DataContext dataContext){
- return (DebuggerTreePanel)dataContext.getData(DebuggerActions.DEBUGGER_TREE_PANEL);
+ return DebuggerTreePanel.DATA_KEY.getData(dataContext);
}
@Nullable
if (paths == null || paths.length == 0) {
return EMPTY_TREE_NODE_ARRAY;
}
- List<Object> nodes = new ArrayList<Object>(paths.length);
+ List<DebuggerTreeNodeImpl> nodes = new ArrayList<DebuggerTreeNodeImpl>(paths.length);
for (TreePath path : paths) {
Object component = path.getLastPathComponent();
if (component instanceof DebuggerTreeNodeImpl) {
- nodes.add(component);
+ nodes.add((DebuggerTreeNodeImpl) component);
}
}
return nodes.toArray(new DebuggerTreeNodeImpl[nodes.size()]);
*/
package com.intellij.debugger.actions;
+import com.intellij.debugger.ui.impl.DebuggerTreePanel;
+import com.intellij.debugger.ui.impl.watch.DebuggerTree;
import com.intellij.xdebugger.impl.actions.XDebuggerActions;
import org.jetbrains.annotations.NonNls;
@NonNls String INSPECT_PANEL_POPUP = "Debugger.InspectPanelPopup";
@NonNls String THREADS_PANEL_POPUP = "Debugger.ThreadsPanelPopup";
@NonNls String WATCH_PANEL_POPUP = "Debugger.WatchesPanelPopup";
- @NonNls String DEBUGGER_TREE = "DebuggerTree";
- @NonNls String DEBUGGER_TREE_PANEL = "DebuggerPanel";
+ @Deprecated @NonNls String DEBUGGER_TREE = DebuggerTree.DATA_KEY.getName();
+ @Deprecated @NonNls String DEBUGGER_TREE_PANEL = DebuggerTreePanel.DATA_KEY.getName();
@NonNls String REMOVE_WATCH = "Debugger.RemoveWatch";
@NonNls String NEW_WATCH = "Debugger.NewWatch";
@NonNls String ADD_TO_WATCH = "Debugger.AddToWatch";
@NonNls String EXPORT_THREADS = "ExportThreads";
@NonNls String DUMP_THREADS = "DumpThreads";
-}
\ No newline at end of file
+}
else if(DebuggerAction.isContextView(event)) {
presentation.setText(DebuggerBundle.message("action.add.field.watchpoint.text"));
Project project = event.getData(PlatformDataKeys.PROJECT);
- if(place != null) {
+ if(project != null && place != null) {
Document document = PsiDocumentManager.getInstance(project).getDocument(place.getFile());
if (document != null) {
final int offset = place.getOffset();
final BreakpointManager breakpointManager = (DebuggerManagerEx.getInstanceEx(project)).getBreakpointManager();
- final Breakpoint fieldBreakpoint = offset >= 0 ? (FieldBreakpoint)breakpointManager.findBreakpoint(document, offset, FieldBreakpoint.CATEGORY) : null;
+ final Breakpoint fieldBreakpoint = offset >= 0 ? breakpointManager.findBreakpoint(document, offset, FieldBreakpoint.CATEGORY) : null;
if (fieldBreakpoint != null) {
presentation.setEnabled(false);
return;
}
if(DebuggerAction.isContextView(event)) {
- DebuggerTree tree = (DebuggerTree)dataContext.getData(DebuggerActions.DEBUGGER_TREE);
+ DebuggerTree tree = DebuggerTree.DATA_KEY.getData(dataContext);
if(tree != null && tree.getSelectionPath() != null) {
DebuggerTreeNodeImpl node = ((DebuggerTreeNodeImpl)tree.getSelectionPath().getLastPathComponent());
if(node != null && node.getDescriptor() instanceof FieldDescriptorImpl) {
return null;
}
-}
\ No newline at end of file
+}
import com.intellij.debugger.impl.DebuggerStateManager;
import com.intellij.debugger.ui.impl.watch.DebuggerTree;
import com.intellij.openapi.Disposable;
-import com.intellij.openapi.actionSystem.ActionPopupMenu;
-import com.intellij.openapi.actionSystem.CustomShortcutSet;
-import com.intellij.openapi.actionSystem.DataProvider;
-import com.intellij.openapi.actionSystem.Shortcut;
+import com.intellij.openapi.actionSystem.*;
import com.intellij.openapi.keymap.KeymapManager;
import com.intellij.openapi.project.Project;
import com.intellij.openapi.util.Disposer;
import java.awt.event.KeyEvent;
public abstract class DebuggerTreePanel extends UpdatableDebuggerView implements DataProvider {
+ public static final DataKey<DebuggerTreePanel> DATA_KEY = DataKey.create("DebuggerPanel");
+
protected final DebuggerTree myTree;
public DebuggerTreePanel(Project project, DebuggerStateManager stateManager) {
}
public Object getData(String dataId) {
- if (DebuggerActions.DEBUGGER_TREE_PANEL.equals(dataId)) {
+ if (DebuggerTreePanel.DATA_KEY.is(dataId)) {
return this;
}
return null;
import com.intellij.openapi.actionSystem.ActionManager;
import com.intellij.openapi.actionSystem.ActionPopupMenu;
import com.intellij.openapi.actionSystem.DefaultActionGroup;
-import com.intellij.openapi.actionSystem.ex.DataConstantsEx;
+import com.intellij.openapi.actionSystem.PlatformDataKeys;
import com.intellij.openapi.project.Project;
import org.jetbrains.annotations.NonNls;
}
public Object getData(String dataId) {
- if (DataConstantsEx.HELP_ID.equals(dataId)) {
+ if (PlatformDataKeys.HELP_ID.is(dataId)) {
return HELP_ID;
}
return super.getData(dataId);
public ThreadsDebuggerTree getThreadsTree() {
return (ThreadsDebuggerTree) getTree();
}
-}
\ No newline at end of file
+}
}
public Object getData(String dataId) {
- if (DataConstants.HELP_ID.equals(dataId)) {
+ if (PlatformDataKeys.HELP_ID.is(dataId)) {
return HELP_ID;
}
return super.getData(dataId);
return (FrameDebuggerTree) getTree();
}
-}
\ No newline at end of file
+}
import com.intellij.debugger.ui.impl.watch.WatchItemDescriptor;
import com.intellij.openapi.Disposable;
import com.intellij.openapi.actionSystem.ActionPopupMenu;
-import com.intellij.openapi.actionSystem.DataConstants;
+import com.intellij.openapi.actionSystem.PlatformDataKeys;
import com.intellij.openapi.project.Project;
import org.jetbrains.annotations.NonNls;
}
public Object getData(String dataId) {
- if (DataConstants.HELP_ID.equals(dataId)) {
+ if (PlatformDataKeys.HELP_ID.is(dataId)) {
return HELP_ID;
}
return super.getData(dataId);
public WatchDebuggerTree getWatchTree() {
return (WatchDebuggerTree) getTree();
}
-}
\ No newline at end of file
+}
import com.intellij.debugger.DebuggerBundle;
import com.intellij.debugger.DebuggerInvocationUtil;
-import com.intellij.debugger.actions.DebuggerActions;
import com.intellij.debugger.engine.DebugProcessImpl;
import com.intellij.debugger.engine.evaluation.EvaluateException;
import com.intellij.debugger.engine.evaluation.EvaluationContextImpl;
import com.intellij.debugger.ui.tree.render.ChildrenBuilder;
import com.intellij.debugger.ui.tree.render.NodeRenderer;
import com.intellij.debugger.ui.tree.render.NodeRendererSettingsListener;
+import com.intellij.openapi.actionSystem.DataKey;
import com.intellij.openapi.actionSystem.DataProvider;
import com.intellij.openapi.application.ApplicationManager;
import com.intellij.openapi.diagnostic.Logger;
private static final Logger LOG = Logger.getInstance("#com.intellij.debugger.ui.impl.watch.DebuggerTree");
protected static final Key<Rectangle> VISIBLE_RECT = Key.create("VISIBLE_RECT");
+ public static final DataKey<DebuggerTree> DATA_KEY = DataKey.create("DebuggerTree");
+
private final Project myProject;
protected final NodeManagerImpl myNodeManager;
}
public Object getData(String dataId) {
- if (DebuggerActions.DEBUGGER_TREE.equals(dataId)) {
+ if (DebuggerTree.DATA_KEY.is(dataId)) {
return this;
}
return null;
public void hideTooltip() {
myTipManager.hideTooltip();
}
-}
\ No newline at end of file
+}
*/
package com.intellij.ide.actions;
-import com.intellij.openapi.actionSystem.AnAction;
-import com.intellij.openapi.actionSystem.AnActionEvent;
-import com.intellij.openapi.actionSystem.DataConstants;
-import com.intellij.openapi.actionSystem.DataContext;
+import com.intellij.openapi.actionSystem.*;
import com.intellij.openapi.module.Module;
import com.intellij.openapi.project.Project;
import com.intellij.openapi.roots.ui.configuration.ModulesConfigurator;
public void actionPerformed(AnActionEvent e) {
final DataContext dataContext = e.getDataContext();
- final Project project = (Project)dataContext.getData(DataConstants.PROJECT);
+ final Project project = PlatformDataKeys.PROJECT.getData(dataContext);
if (project == null) {
return;
}
- final Module module = (Module)dataContext.getData(DataConstants.MODULE_CONTEXT);
+ final Module module = LangDataKeys.MODULE_CONTEXT.getData(dataContext);
if (module == null) {
return;
}
public void update(AnActionEvent e) {
super.update(e);
final DataContext dataContext = e.getDataContext();
- final Project project = (Project)dataContext.getData(DataConstants.PROJECT);
- final Module module = (Module)dataContext.getData(DataConstants.MODULE_CONTEXT);
+ final Project project = PlatformDataKeys.PROJECT.getData(dataContext);
+ final Module module = LangDataKeys.MODULE_CONTEXT.getData(dataContext);
e.getPresentation().setVisible(project != null && module != null);
}
}
@Nullable public Object getData(String dataId) {
Object data = myPaletteWindow.getData(dataId);
if (data != null) return data;
- Project project = (Project)myPaletteWindow.getData(DataConstants.PROJECT);
+ Project project = PlatformDataKeys.PROJECT.getData(myPaletteWindow);
return myGroup.getData(project, dataId);
}
private final Project myProject;
private final ArrayList<PaletteGroupHeader> myGroupHeaders = new ArrayList<PaletteGroupHeader>();
private final PaletteItemProvider[] myProviders;
- private final PaletteWindow.MyPropertyChangeListener myPropertyChangeListener = new MyPropertyChangeListener();
+ private final MyPropertyChangeListener myPropertyChangeListener = new MyPropertyChangeListener();
private final Set<PaletteGroup> myGroups = new HashSet<PaletteGroup>();
private final JTabbedPane myTabbedPane = new JTabbedPane();
private final JScrollPane myScrollPane = new JScrollPane();
}
@Nullable public Object getData(String dataId) {
- if (dataId.equals(DataConstants.HELP_ID)) {
+ if (PlatformDataKeys.HELP_ID.is(dataId)) {
return ourHelpID;
}
- if (dataId.equals(DataConstants.PROJECT)) {
+ if (PlatformDataKeys.PROJECT.is(dataId)) {
return myProject;
}
PaletteItem item = getActiveItem();
private static FileChooserDescriptor createFileChooserDescriptor(Component parent) {
final FileChooserDescriptor descriptor = new FileChooserDescriptor(false, true, true, false, false, true);
- final Module contextModule = (Module)DataManager.getInstance().getDataContext(parent).getData(DataConstants.MODULE_CONTEXT);
+ final Module contextModule = LangDataKeys.MODULE_CONTEXT.getData(DataManager.getInstance().getDataContext(parent));
descriptor.putUserData(LangDataKeys.MODULE_CONTEXT, contextModule);
return descriptor;
}
import com.intellij.facet.impl.ProjectFacetsConfigurator;
import com.intellij.openapi.Disposable;
-import com.intellij.openapi.actionSystem.DataConstants;
import com.intellij.openapi.actionSystem.DataProvider;
+import com.intellij.openapi.actionSystem.LangDataKeys;
import com.intellij.openapi.extensions.Extensions;
import com.intellij.openapi.module.Module;
import com.intellij.openapi.module.ModuleConfigurationEditor;
}
public Object getData(String dataId) {
- if (dataId.equals(DataConstants.MODULE_CONTEXT)) {
+ if (LangDataKeys.MODULE_CONTEXT.is(dataId)) {
return getModule();
}
return null;
import com.intellij.ide.projectView.impl.ModuleGroup;
import com.intellij.openapi.actionSystem.AnActionEvent;
import com.intellij.openapi.actionSystem.DataKeys;
-import com.intellij.openapi.actionSystem.ex.DataConstantsEx;
import com.intellij.openapi.module.Module;
import com.intellij.openapi.module.impl.ModuleManagerImpl;
@Override
public void update(final AnActionEvent e) {
super.update(e);
- final ModuleGroup[] moduleGroups = (ModuleGroup[])e.getDataContext().getData(DataConstantsEx.MODULE_GROUP_ARRAY);
+ final ModuleGroup[] moduleGroups = ModuleGroup.ARRAY_DATA_KEY.getData(e.getDataContext());
final Module[] modules = e.getData(DataKeys.MODULE_CONTEXT_ARRAY);
e.getPresentation().setVisible((moduleGroups != null && moduleGroups.length > 0) ||
(modules != null && modules.length > 0));
@Override
protected Object prepareDataFromContext(final AnActionEvent e) {
- final ModuleGroup[] moduleGroups = (ModuleGroup[])e.getDataContext().getData(DataConstantsEx.MODULE_GROUP_ARRAY);
+ final ModuleGroup[] moduleGroups = ModuleGroup.ARRAY_DATA_KEY.getData(e.getDataContext());
if (moduleGroups != null && moduleGroups.length > 0) {
return moduleGroups [0];
}
import org.jetbrains.annotations.Nullable;
import javax.swing.*;
+import java.awt.*;
import java.util.*;
+import java.util.List;
/**
* @author nik
}
public String getHelpTopic() {
- final Object component = DataManager.getInstance().getDataContext().getData(DataKeys.CONTEXT_COMPONENT.getName());
+ final Component component = DataKeys.CONTEXT_COMPONENT.getData(DataManager.getInstance().getDataContext());
if (myTree.equals(component)) {
final NamedConfigurable selectedConfugurable = getSelectedConfugurable();
if (selectedConfugurable instanceof FacetTypeConfigurable) {
import com.intellij.ide.util.projectWizard.NamePathComponent;
import com.intellij.ide.util.projectWizard.ProjectWizardUtil;
import com.intellij.openapi.actionSystem.*;
-import com.intellij.openapi.actionSystem.ex.DataConstantsEx;
import com.intellij.openapi.application.ApplicationManager;
import com.intellij.openapi.components.State;
import com.intellij.openapi.components.Storage;
import com.intellij.openapi.roots.ui.configuration.ModuleEditor;
import com.intellij.openapi.roots.ui.configuration.ModulesConfigurator;
import com.intellij.openapi.roots.ui.configuration.ProjectStructureConfigurable;
-import com.intellij.openapi.roots.ui.configuration.projectRoot.daemon.*;
+import com.intellij.openapi.roots.ui.configuration.projectRoot.daemon.LibraryProjectStructureElement;
+import com.intellij.openapi.roots.ui.configuration.projectRoot.daemon.ModuleProjectStructureElement;
+import com.intellij.openapi.roots.ui.configuration.projectRoot.daemon.ProjectStructureDaemonAnalyzer;
+import com.intellij.openapi.roots.ui.configuration.projectRoot.daemon.ProjectStructureElement;
import com.intellij.openapi.ui.DialogWrapper;
import com.intellij.openapi.ui.Messages;
import com.intellij.openapi.ui.NamedConfigurable;
if (DataKeys.MODULE_CONTEXT.is(dataId)){
return getSelectedModule();
}
- if (DataConstantsEx.MODIFIABLE_MODULE_MODEL.equals(dataId)){
+ if (LangDataKeys.MODIFIABLE_MODULE_MODEL.is(dataId)){
return myContext.myModulesConfigurator.getModuleModel();
}
import com.intellij.ide.DataManager;
import com.intellij.ide.util.PackageUtil;
import com.intellij.openapi.actionSystem.DataContext;
-import com.intellij.openapi.actionSystem.ex.DataConstantsEx;
+import com.intellij.openapi.actionSystem.LangDataKeys;
import com.intellij.openapi.actionSystem.impl.SimpleDataContext;
import com.intellij.openapi.editor.Editor;
import com.intellij.openapi.module.Module;
* @author cdr
*/
public class MoveClassToModuleFix {
+ private MoveClassToModuleFix() {
+ }
+
public static void registerFixes(QuickFixActionRegistrar registrar, final PsiJavaCodeReferenceElement reference) {
final PsiElement psiElement = reference.getElement();
@NonNls final String referenceName = reference.getRangeInElement().substring(psiElement.getText());
DataManager dataManager = DataManager.getInstance();
DataContext dataContext = dataManager.getDataContext();
PsiDirectory directory = PackageUtil.findOrCreateDirectoryForPackage(currentModule, packageName, sourceRoot, true);
- DataContext context = SimpleDataContext.getSimpleContext(DataConstantsEx.TARGET_PSI_ELEMENT, directory, dataContext);
+ DataContext context = SimpleDataContext.getSimpleContext(LangDataKeys.TARGET_PSI_ELEMENT.getName(), directory, dataContext);
String qualifiedName = aClass.getQualifiedName();
+ if (qualifiedName == null) {
+ return;
+ }
moveHandler.invoke(project, new PsiElement[]{aClass}, context);
PsiReference reference = file.findReferenceAt(editor.getCaretModel().getOffset());
PsiClass newClass = JavaPsiFacade.getInstance(project).findClass(qualifiedName, GlobalSearchScope.moduleScope(currentModule));
public void update(AnActionEvent event) {
Presentation presentation = event.getPresentation();
presentation.setEnabled(
- getInspectionScope(event.getDataContext()) != null || event.getDataContext().getData(DataConstants.PSI_FILE) != null);
+ getInspectionScope(event.getDataContext()) != null || event.getData(LangDataKeys.PSI_FILE) != null);
}
public void actionPerformed(AnActionEvent e) {
}
- private AnalysisScope getInspectionScope(final DataContext dataContext) {
+ private static AnalysisScope getInspectionScope(final DataContext dataContext) {
final Project project = PlatformDataKeys.PROJECT.getData(dataContext);
if (project == null) return null;
return scope != null && scope.getScopeType() != AnalysisScope.INVALID ? scope : null;
}
- private AnalysisScope getInspectionScopeImpl(DataContext dataContext) {
+ private static AnalysisScope getInspectionScopeImpl(DataContext dataContext) {
//Possible scopes: package, project, module.
Project projectContext = PlatformDataKeys.PROJECT_CONTEXT.getData(dataContext);
if (projectContext != null) {
return new AnalysisScope(projectContext);
}
- Module moduleContext = (Module)dataContext.getData(DataConstants.MODULE_CONTEXT);
+ Module moduleContext = LangDataKeys.MODULE_CONTEXT.getData(dataContext);
if (moduleContext != null) {
return new AnalysisScope(moduleContext);
}
- Module [] modulesArray = (Module[])dataContext.getData(DataConstants.MODULE_CONTEXT_ARRAY);
+ Module [] modulesArray = LangDataKeys.MODULE_CONTEXT_ARRAY.getData(dataContext);
if (modulesArray != null) {
return new AnalysisScope(modulesArray);
}
else if (psiTarget instanceof PsiPackage) {
PsiPackage pack = (PsiPackage)psiTarget;
PsiDirectory[] dirs = pack.getDirectories(GlobalSearchScope.projectScope(pack.getProject()));
- if (dirs == null || dirs.length == 0) return null;
+ if (dirs.length == 0) return null;
return new JavaAnalysisScope(pack, LangDataKeys.MODULE.getData(dataContext));
} else if (psiTarget != null){
return null;
return getProjectScope(dataContext);
}
- private AnalysisScope getProjectScope(DataContext dataContext) {
- return new AnalysisScope(PlatformDataKeys.PROJECT.getData(dataContext));
+ private static AnalysisScope getProjectScope(DataContext dataContext) {
+ final Project data = PlatformDataKeys.PROJECT.getData(dataContext);
+ if (data == null) {
+ return null;
+ }
+ return new AnalysisScope(data);
}
- private AnalysisScope getModuleScope(DataContext dataContext) {
- return new AnalysisScope(LangDataKeys.MODULE.getData(dataContext));
+ private static AnalysisScope getModuleScope(DataContext dataContext) {
+ final Module data = LangDataKeys.MODULE.getData(dataContext);
+ if (data == null) {
+ return null;
+ }
+ return new AnalysisScope(data);
}
private class ProjectModuleOrPackageDialog extends DialogWrapper {
@Nullable
@NonNls
public Object getData(@NonNls String dataId) {
- if (dataId.equals(DataConstants.HELP_ID)) {
+ if (PlatformDataKeys.HELP_ID.is(dataId)) {
return "dependency.viewer.tool.window";
}
return null;
private static class MyTree extends Tree implements DataProvider {
public Object getData(String dataId) {
PackageDependenciesNode node = getSelectedNode();
- if (DataConstants.NAVIGATABLE.equals(dataId)) {
+ if (PlatformDataKeys.NAVIGATABLE.is(dataId)) {
return node;
}
return null;
*/
package com.intellij.ide;
-import com.intellij.psi.*;
import com.intellij.openapi.actionSystem.DataContext;
+import com.intellij.psi.JavaDirectoryService;
+import com.intellij.psi.PsiDirectory;
+import com.intellij.psi.PsiFile;
+import com.intellij.psi.PsiPackage;
public class JavaDataAccessors {
public static final DataAccessor<PsiPackage> FILE_PACKAGE = new DataAccessor<PsiPackage>() {
return JavaDirectoryService.getInstance().getPackage(containingDirectory);
}
};
- public static final DataAccessor<PsiJavaFile> PSI_JAVA_FILE = DataAccessor.SubClassDataAccessor.create(DataAccessors.PSI_FILE, PsiJavaFile.class);
private JavaDataAccessors() {
}
import com.intellij.openapi.actionSystem.DataContext;
import com.intellij.openapi.actionSystem.LangDataKeys;
import com.intellij.openapi.actionSystem.PlatformDataKeys;
-import com.intellij.openapi.actionSystem.ex.DataConstantsEx;
import com.intellij.openapi.module.Module;
import com.intellij.openapi.module.ModuleManager;
import com.intellij.openapi.project.Project;
}
}
} else {
- final Object data = context.getData(DataConstantsEx.MODULE_GROUP_ARRAY);
- if (data instanceof ModuleGroup[]) {
- for (ModuleGroup moduleGroup : ((ModuleGroup[])data)) {
+ final ModuleGroup[] data = ModuleGroup.ARRAY_DATA_KEY.getData(context);
+ if (data != null) {
+ for (ModuleGroup moduleGroup : data) {
if (currentViewId.equals(ProjectViewPane.ID)) {
result.add(new ProjectViewModuleGroupNode(project, moduleGroup, viewSettings));
}
}
return super.getPsiElement(element);
}
-}
\ No newline at end of file
+}
public final void actionPerformed(final AnActionEvent event) {
final DataContext dataContext = event.getDataContext();
- final MethodHierarchyBrowser methodHierarchyBrowser = (MethodHierarchyBrowser)dataContext.getData(MethodHierarchyBrowserBase.METHOD_HIERARCHY_BROWSER_DATA_KEY);
+ final MethodHierarchyBrowser methodHierarchyBrowser = (MethodHierarchyBrowser)MethodHierarchyBrowserBase.DATA_KEY.getData(dataContext);
if (methodHierarchyBrowser == null) return;
final Project project = PlatformDataKeys.PROJECT.getData(dataContext);
if (project == null) return;
final Presentation presentation = e.getPresentation();
final DataContext dataContext = e.getDataContext();
- final MethodHierarchyBrowser methodHierarchyBrowser = (MethodHierarchyBrowser)dataContext.getData(MethodHierarchyBrowser.METHOD_HIERARCHY_BROWSER_DATA_KEY);
+ final MethodHierarchyBrowser methodHierarchyBrowser = (MethodHierarchyBrowser)MethodHierarchyBrowserBase.DATA_KEY.getData(dataContext);
if (methodHierarchyBrowser == null) {
presentation.setEnabled(false);
presentation.setVisible(false);
*/
package com.intellij.ide.macro;
+import com.intellij.ide.IdeBundle;
import com.intellij.openapi.actionSystem.DataContext;
+import com.intellij.openapi.actionSystem.LangDataKeys;
import com.intellij.psi.PsiClass;
+import com.intellij.psi.PsiFile;
import com.intellij.psi.PsiJavaFile;
-import com.intellij.ide.IdeBundle;
-import com.intellij.ide.JavaDataAccessors;
public final class FileClassMacro extends Macro {
public String getName() {
//if (!(psiFile instanceof PsiJavaFile)) {
// return null;
//}
- final PsiJavaFile javaFile = JavaDataAccessors.PSI_JAVA_FILE.from(dataContext);
- if (javaFile == null) return null;
- PsiClass[] classes = javaFile.getClasses();
+ final PsiFile javaFile = LangDataKeys.PSI_FILE.getData(dataContext);
+ if (!(javaFile instanceof PsiJavaFile)) return null;
+ PsiClass[] classes = ((PsiJavaFile) javaFile).getClasses();
if (classes.length == 1) {
return classes[0].getQualifiedName();
}
String fileName = javaFile.getVirtualFile().getNameWithoutExtension();
- for (int i = 0; i < classes.length; i++) {
- PsiClass aClass = classes[i];
+ for (PsiClass aClass : classes) {
String name = aClass.getName();
if (fileName.equals(name)) {
return aClass.getQualifiedName();
import com.intellij.ide.util.treeView.AbstractTreeStructure;
import com.intellij.ide.util.treeView.AbstractTreeUpdater;
import com.intellij.openapi.actionSystem.*;
-import com.intellij.openapi.actionSystem.ex.DataConstantsEx;
import com.intellij.openapi.module.Module;
import com.intellij.openapi.project.Project;
import com.intellij.openapi.roots.OrderEntry;
import com.intellij.openapi.roots.ProjectRootManager;
import com.intellij.openapi.util.IconLoader;
import com.intellij.openapi.vfs.VirtualFile;
-import com.intellij.psi.*;
+import com.intellij.psi.JavaDirectoryService;
+import com.intellij.psi.PsiDirectory;
+import com.intellij.psi.PsiElement;
+import com.intellij.psi.PsiPackage;
import com.intellij.psi.search.GlobalSearchScope;
import org.jetbrains.annotations.NonNls;
import org.jetbrains.annotations.NotNull;
@Override
public Object getData(final String dataId) {
- if (DataConstantsEx.PACKAGE_ELEMENT.equals(dataId)) {
+ if (PackageElement.DATA_KEY.is(dataId)) {
final PackageElement packageElement = getSelectedPackageElement();
}
- if (DataConstants.MODULE.equals(dataId)) {
+ if (LangDataKeys.MODULE.is(dataId)) {
final PackageElement packageElement = getSelectedPackageElement();
if (packageElement != null) {
return packageElement.getModule();
return modules.toArray(new Module[modules.size()]);
}
}
-}
\ No newline at end of file
+}
*/
package com.intellij.ide.projectView.impl.nodes;
+import com.intellij.openapi.actionSystem.DataKey;
import com.intellij.openapi.module.Module;
import com.intellij.psi.PsiPackage;
* Time: 3:51:02 PM
*/
public final class PackageElement {
+ public static final DataKey<PackageElement> DATA_KEY = DataKey.create("package.element");
+
private final Module myModule;
private final PsiPackage myElement;
private final boolean myIsLibraryElement;
import com.intellij.execution.runners.ProgramRunner;
import com.intellij.execution.util.ExecutionErrorDialog;
import com.intellij.ide.DataManager;
-import com.intellij.openapi.actionSystem.DataConstants;
import com.intellij.openapi.actionSystem.DataContext;
+import com.intellij.openapi.actionSystem.PlatformDataKeys;
import com.intellij.openapi.actionSystem.impl.SimpleDataContext;
import com.intellij.openapi.components.AbstractProjectComponent;
import com.intellij.openapi.module.Module;
}
public void generateJavadoc(final PsiDirectory directory, DataContext dataContext) {
- Component component = (Component)dataContext.getData(DataConstants.CONTEXT_COMPONENT);
+ Component component = PlatformDataKeys.CONTEXT_COMPONENT.getData(dataContext);
final PsiPackage aPackage = directory != null ? JavaDirectoryService.getInstance().getPackage(directory) : null;
String packageFQName = aPackage != null ? aPackage.getQualifiedName() : null;
return myConfiguration;
}
-}
\ No newline at end of file
+}
public void update(AnActionEvent event){
final Presentation presentation = event.getPresentation();
- presentation.setEnabled(event.getDataContext().getData(DataConstants.PROJECT) != null);
+ presentation.setEnabled(PlatformDataKeys.PROJECT.getData(event.getDataContext()) != null);
}
private static PsiDirectory getDirectoryFromContext(final DataContext dataContext) {
return null;
}
-}
\ No newline at end of file
+}
*/
package com.intellij.refactoring.move.moveClassesOrPackages;
-import com.intellij.psi.*;
-import com.intellij.psi.impl.source.jsp.jspJava.JspClass;
-import com.intellij.openapi.project.Project;
+import com.intellij.codeInsight.daemon.impl.CollectHighlightsUtil;
import com.intellij.openapi.actionSystem.DataContext;
-import com.intellij.openapi.actionSystem.ex.DataConstantsEx;
+import com.intellij.openapi.actionSystem.LangDataKeys;
import com.intellij.openapi.editor.Editor;
-import com.intellij.codeInsight.daemon.impl.CollectHighlightsUtil;
+import com.intellij.openapi.project.Project;
+import com.intellij.psi.*;
+import com.intellij.psi.impl.source.jsp.jspJava.JspClass;
import org.jetbrains.annotations.Nullable;
public class MoveClassesHandler extends MoveClassesOrPackagesHandlerBase {
if (element instanceof PsiClass && !(element instanceof PsiAnonymousClass) && element.getParent() instanceof PsiFile) {
MoveClassesOrPackagesImpl.doMove(project, new PsiElement[]{element},
- (PsiElement)dataContext.getData(DataConstantsEx.TARGET_PSI_ELEMENT), null);
+ LangDataKeys.TARGET_PSI_ELEMENT.getData(dataContext), null);
return true;
}
return false;
package com.intellij.refactoring.wrapreturnvalue;
import com.intellij.ide.util.SuperMethodWarningUtil;
-import com.intellij.openapi.actionSystem.DataConstants;
import com.intellij.openapi.actionSystem.DataContext;
+import com.intellij.openapi.actionSystem.LangDataKeys;
import com.intellij.openapi.actionSystem.PlatformDataKeys;
import com.intellij.openapi.editor.CaretModel;
import com.intellij.openapi.editor.Editor;
DataContext dataContext){
final ScrollingModel scrollingModel = editor.getScrollingModel();
scrollingModel.scrollToCaret(ScrollType.MAKE_VISIBLE);
- final PsiElement element = (PsiElement) dataContext.getData(DataConstants.PSI_ELEMENT);
+ final PsiElement element = LangDataKeys.PSI_ELEMENT.getData(dataContext);
PsiMethod selectedMethod = null;
if(element instanceof PsiMethod){
selectedMethod = (PsiMethod) element;
* Returns the data for the specified data constant.
*
* @param project the project in the context of which data is requested.
- * @param dataId the data constant id (see {@link com.intellij.openapi.actionSystem.DataConstants}).
+ * @param dataId the data constant id (see {@link com.intellij.openapi.actionSystem.PlatformDataKeys}).
* @return the data item, or null if no data is available for this constant.
*/
@Nullable Object getData(Project project, String dataId);
package com.intellij.ide.palette;
+import com.intellij.ide.dnd.DnDDragStartBean;
import com.intellij.openapi.actionSystem.ActionGroup;
import com.intellij.openapi.project.Project;
import com.intellij.ui.ColoredListCellRenderer;
-import com.intellij.ide.dnd.DnDDragStartBean;
import org.jetbrains.annotations.Nullable;
-import java.awt.datatransfer.Transferable;
-
/**
* @author yole
*/
* Returns the data for the specified data constant.
*
* @param project the project in the context of which data is requested.
- * @param dataId the data constant id (see {@link com.intellij.openapi.actionSystem.DataConstants}).
+ * @param dataId the data constant id (see {@link com.intellij.openapi.actionSystem.PlatformDataKeys}).
* @return the data item, or null if no data is available for this constant.
*/
@Nullable Object getData(Project project, String dataId);
}
@Deprecated
- public static final DataKey<ChangeList[]> CHANGE_LISTS = DataKey.create(DataConstants.CHANGE_LISTS);
+ public static final DataKey<ChangeList[]> CHANGE_LISTS = DataKey.create("vcs.ChangeList");
@Deprecated
- public static final DataKey<Change[]> CHANGES = DataKey.create(DataConstants.CHANGES);
+ public static final DataKey<Change[]> CHANGES = DataKey.create("vcs.Change");
}
}
public Object getData(String dataId) {
- return dataId.equals(DataConstants.EDITOR) ? myEditor : super.getData(dataId);
+ return PlatformDataKeys.EDITOR.is(dataId) ? myEditor : super.getData(dataId);
}
protected VirtualFile getVirtualFile(@NonNls String filePath) {
*/
package com.intellij.execution;
+import com.intellij.openapi.actionSystem.DataKey;
import com.intellij.openapi.fileEditor.OpenFileDescriptor;
import com.intellij.openapi.module.Module;
import com.intellij.openapi.project.Project;
import java.util.Iterator;
public abstract class Location<E extends PsiElement> {
- @NonNls public static final String LOCATION = "Location";
+ public static final DataKey<Location<?>> DATA_KEY = DataKey.create("Location");
+ @Deprecated @NonNls public static final String LOCATION = DATA_KEY.getName();
@NotNull public abstract E getPsiElement();
@NotNull public abstract Project getProject();
package com.intellij.execution.configurations;
import com.intellij.execution.runners.ProgramRunner;
+import com.intellij.openapi.actionSystem.DataKey;
import com.intellij.openapi.module.Module;
import com.intellij.openapi.options.SettingsEditor;
import com.intellij.openapi.project.Project;
import org.jetbrains.annotations.NonNls;
import org.jetbrains.annotations.NotNull;
-import javax.swing.*;
-
public abstract class RuntimeConfiguration extends RunConfigurationBase implements LocatableConfiguration, Cloneable, ModuleRunConfiguration {
+ public static final DataKey<RuntimeConfiguration> DATA_KEY = DataKey.create("runtimeConfiguration");
+
protected RuntimeConfiguration(final String name, final Project project, final ConfigurationFactory factory) {
super(project, factory, name);
}
@NonNls public String suggestedName() {
return null;
}
-}
\ No newline at end of file
+}
import com.intellij.history.LocalHistoryConfiguration;
import com.intellij.openapi.actionSystem.AnAction;
import com.intellij.openapi.actionSystem.DataContext;
+import com.intellij.openapi.actionSystem.DataKey;
import com.intellij.openapi.actionSystem.PlatformDataKeys;
import com.intellij.openapi.application.ApplicationManager;
import com.intellij.openapi.options.SettingsEditor;
* @author spleaner
*/
public abstract class GenericProgramRunner<Settings extends JDOMExternalizable> implements ProgramRunner<Settings> {
+
/**
* @see com.intellij.execution.ui.RunContentDescriptor#myContent
*/
- @NonNls public static final String CONTENT_TO_REUSE = "contentToReuse";
+ public static final DataKey<RunContentDescriptor> CONTENT_TO_REUSE_DATA_KEY = DataKey.create("contentToReuse");
+ @Deprecated @NonNls public static final String CONTENT_TO_REUSE = CONTENT_TO_REUSE_DATA_KEY.getName();
@Nullable
public Settings createConfigurationData(final ConfigurationInfoProvider settingsProvider) {
* favorites or commander).
*
* @since 5.1
- * @see com.intellij.openapi.actionSystem.DataConstants#IDE_VIEW
+ * @see com.intellij.openapi.actionSystem.PlatformDataKeys#IDE_VIEW
*/
public interface IdeView {
/**
*
* @param selected the list of nodes currently selected in the project view.
* @param dataName the identifier of the requested data object (for example, as defined in
- * {@link com.intellij.openapi.actionSystem.DataConstants})
+ * {@link com.intellij.openapi.actionSystem.PlatformDataKeys})
* @return the data object, or null if no data object can be returned by this provider.
* @see com.intellij.openapi.actionSystem.DataProvider
*/
import com.intellij.ide.IdeView;
import com.intellij.lang.Language;
+import com.intellij.openapi.module.ModifiableModuleModel;
import com.intellij.openapi.module.Module;
import com.intellij.openapi.util.Condition;
import com.intellij.psi.PsiElement;
* @author yole
*/
public class LangDataKeys extends PlatformDataKeys {
- public static final DataKey<Module> MODULE = DataKey.create(DataConstants.MODULE);
- public static final DataKey<Module> MODULE_CONTEXT = DataKey.create(DataConstants.MODULE_CONTEXT);
- public static final DataKey<Module[]> MODULE_CONTEXT_ARRAY = DataKey.create(DataConstants.MODULE_CONTEXT_ARRAY);
- public static final DataKey<PsiElement> PSI_ELEMENT = DataKey.create(DataConstants.PSI_ELEMENT);
- public static final DataKey<PsiFile> PSI_FILE = DataKey.create(DataConstants.PSI_FILE);
- public static final DataKey<Language> LANGUAGE = DataKey.create(DataConstants.LANGUAGE);
- public static final DataKey<PsiElement[]> PSI_ELEMENT_ARRAY = DataKey.create(DataConstants.PSI_ELEMENT_ARRAY);
- public static final DataKey<IdeView> IDE_VIEW = DataKey.create(DataConstants.IDE_VIEW);
+ public static final DataKey<Module> MODULE = DataKey.create("module");
+ /**
+ * Returns module if module node is selected (in module view)
+ */
+ public static final DataKey<Module> MODULE_CONTEXT = DataKey.create("context.Module");
+ public static final DataKey<Module[]> MODULE_CONTEXT_ARRAY = DataKey.create("context.Module.Array");
+ public static final DataKey<ModifiableModuleModel> MODIFIABLE_MODULE_MODEL = DataKey.create("modifiable.module.model");
+
+ public static final DataKey<PsiElement> PSI_ELEMENT = DataKey.create("psi.Element");
+ public static final DataKey<PsiFile> PSI_FILE = DataKey.create("psi.File");
+ public static final DataKey<Language> LANGUAGE = DataKey.create("Language");
+ public static final DataKey<PsiElement[]> PSI_ELEMENT_ARRAY = DataKey.create("psi.Element.array");
+
+ /**
+ * Returns {@link com.intellij.ide.IdeView} (one of project, packages, commander or favorites view).
+ */
+ public static final DataKey<IdeView> IDE_VIEW = DataKey.create("IDEView");
public static final DataKey<Condition<AnAction>> PRESELECT_NEW_ACTION_CONDITION = DataKey.create("newElementAction.preselect.id");
+
+ public static final DataKey<PsiElement> TARGET_PSI_ELEMENT = DataKey.create("psi.TargetElement");
+ public static final DataKey<PsiElement> PASTE_TARGET_PSI_ELEMENT = DataKey.create("psi.pasteTargetElement");
}
public static void actionPerformedImpl(final DataContext dataContext) {
final Project project = PlatformDataKeys.PROJECT.getData(dataContext);
+ if (project == null) {
+ return;
+ }
PsiDocumentManager.getInstance(project).commitAllDocuments();
final Editor editor = BaseCodeInsightAction.getInjectedEditor(project, PlatformDataKeys.EDITOR.getData(dataContext));
- final VirtualFile[] files = (VirtualFile[])dataContext.getData(DataConstants.VIRTUAL_FILE_ARRAY);
+ final VirtualFile[] files = PlatformDataKeys.VIRTUAL_FILE_ARRAY.getData(dataContext);
+ if (files == null) {
+ return;
+ }
PsiFile file = null;
PsiDirectory dir;
}
else{
Project projectContext = PlatformDataKeys.PROJECT_CONTEXT.getData(dataContext);
- Module moduleContext = (Module)dataContext.getData(DataConstants.MODULE_CONTEXT);
+ Module moduleContext = LangDataKeys.MODULE_CONTEXT.getData(dataContext);
if (projectContext != null || moduleContext != null) {
final String text;
return;
}
- final VirtualFile[] files = (VirtualFile[])dataContext.getData(DataConstants.VIRTUAL_FILE_ARRAY);
+ final VirtualFile[] files = PlatformDataKeys.VIRTUAL_FILE_ARRAY.getData(dataContext);
final Editor editor = BaseCodeInsightAction.getInjectedEditor(project, PlatformDataKeys.EDITOR.getData(dataContext), false);
if (editor != null){
else if (files != null && files.length == 1) {
// skip. Both directories and single files are supported.
}
- else if (dataContext.getData(DataConstants.MODULE_CONTEXT) == null &&
- dataContext.getData(DataConstants.PROJECT_CONTEXT) == null) {
+ else if (LangDataKeys.MODULE_CONTEXT.getData(dataContext) == null &&
+ PlatformDataKeys.PROJECT_CONTEXT.getData(dataContext) == null) {
PsiElement element = LangDataKeys.PSI_ELEMENT.getData(dataContext);
if (element == null){
presentation.setEnabled(false);
import com.intellij.openapi.editor.Editor;
import com.intellij.openapi.module.Module;
import com.intellij.openapi.project.DumbAware;
-import com.intellij.openapi.project.Project;
import com.intellij.openapi.project.DumbService;
+import com.intellij.openapi.project.Project;
import com.intellij.openapi.util.TextRange;
import com.intellij.openapi.vfs.ReadonlyStatusHandler;
import com.intellij.openapi.vfs.VirtualFile;
public void actionPerformed(AnActionEvent event) {
DataContext dataContext = event.getDataContext();
final Project project = PlatformDataKeys.PROJECT.getData(dataContext);
+ if (project == null) {
+ return;
+ }
PsiDocumentManager.getInstance(project).commitAllDocuments();
final Editor editor = PlatformDataKeys.EDITOR.getData(dataContext);
- final VirtualFile[] files = (VirtualFile[])dataContext.getData(DataConstants.VIRTUAL_FILE_ARRAY);
+ final VirtualFile[] files = PlatformDataKeys.VIRTUAL_FILE_ARRAY.getData(dataContext);
+ if (files == null) {
+ return;
+ }
PsiFile file = null;
final PsiDirectory dir;
}
else{
Project projectContext = PlatformDataKeys.PROJECT_CONTEXT.getData(dataContext);
- Module moduleContext = (Module)dataContext.getData(DataConstants.MODULE_CONTEXT);
+ Module moduleContext = LangDataKeys.MODULE_CONTEXT.getData(dataContext);
if (projectContext != null || moduleContext != null) {
final String text;
Editor editor = PlatformDataKeys.EDITOR.getData(dataContext);
- final VirtualFile[] files = (VirtualFile[])dataContext.getData(DataConstants.VIRTUAL_FILE_ARRAY);
+ final VirtualFile[] files = PlatformDataKeys.VIRTUAL_FILE_ARRAY.getData(dataContext);
if (editor != null){
PsiFile file = PsiDocumentManager.getInstance(project).getPsiFile(editor.getDocument());
else if (files != null && files.length == 1) {
// skip. Both directories and single files are supported.
}
- else if (dataContext.getData(DataConstants.MODULE_CONTEXT) == null &&
- dataContext.getData(DataConstants.PROJECT_CONTEXT) == null) {
+ else if (LangDataKeys.MODULE_CONTEXT.getData(dataContext) == null &&
+ PlatformDataKeys.PROJECT_CONTEXT.getData(dataContext) == null) {
PsiElement element = LangDataKeys.PSI_ELEMENT.getData(dataContext);
if (element == null) {
presentation.setEnabled(false);
import com.intellij.openapi.command.CommandProcessor;
import com.intellij.openapi.editor.Editor;
import com.intellij.openapi.project.DumbAware;
-import com.intellij.openapi.project.Project;
-import com.intellij.openapi.project.IndexNotReadyException;
import com.intellij.openapi.project.DumbService;
+import com.intellij.openapi.project.IndexNotReadyException;
+import com.intellij.openapi.project.Project;
import com.intellij.psi.PsiDocumentManager;
import com.intellij.psi.PsiFile;
final Presentation presentation = event.getPresentation();
final DataContext dataContext = event.getDataContext();
- presentation.setEnabled(dataContext.getData(DataConstants.PROJECT) != null &&
- dataContext.getData(DataConstants.EDITOR) != null);
+ presentation.setEnabled(PlatformDataKeys.PROJECT.getData(dataContext) != null &&
+ PlatformDataKeys.EDITOR.getData(dataContext) != null);
}
public void actionPerformed(AnActionEvent e) {
null
);
}
-}
\ No newline at end of file
+}
import com.intellij.openapi.actionSystem.AnAction;
import com.intellij.openapi.actionSystem.AnActionEvent;
import com.intellij.openapi.actionSystem.CustomShortcutSet;
-import com.intellij.openapi.actionSystem.ex.DataConstantsEx;
import com.intellij.openapi.application.ApplicationManager;
import com.intellij.openapi.command.CommandProcessor;
import com.intellij.openapi.project.Project;
protected InspectionTool myTool;
public static InspectionResultsView getInvoker(AnActionEvent e) {
- return (InspectionResultsView)e.getDataContext().getData(DataConstantsEx.INSPECTION_VIEW);
+ return InspectionResultsView.DATA_KEY.getData(e.getDataContext());
}
protected QuickFixAction(String text, InspectionTool tool) {
package com.intellij.codeInspection.ui;
import com.intellij.CommonBundle;
-import com.intellij.injected.editor.VirtualFileWindow;
import com.intellij.analysis.AnalysisScope;
import com.intellij.analysis.AnalysisUIOptions;
import com.intellij.codeHighlighting.HighlightDisplayLevel;
import com.intellij.codeInspection.ui.actions.InspectionsOptionsToolbarAction;
import com.intellij.codeInspection.ui.actions.InvokeQuickFixAction;
import com.intellij.ide.*;
+import com.intellij.injected.editor.VirtualFileWindow;
import com.intellij.openapi.Disposable;
import com.intellij.openapi.actionSystem.*;
-import com.intellij.openapi.actionSystem.ex.DataConstantsEx;
import com.intellij.openapi.application.ApplicationManager;
import com.intellij.openapi.editor.Editor;
import com.intellij.openapi.editor.colors.EditorColors;
* @author max
*/
public class InspectionResultsView extends JPanel implements Disposable, OccurenceNavigator, DataProvider {
+ public static final DataKey<InspectionResultsView> DATA_KEY = DataKey.create("inspectionView");
+
private final Project myProject;
private InspectionTree myTree;
private final Browser myBrowser;
}
public Object getData(String dataId) {
- if (dataId.equals(DataConstants.HELP_ID)) return HELP_ID;
- if (dataId.equals(DataConstantsEx.INSPECTION_VIEW)) return this;
+ if (PlatformDataKeys.HELP_ID.is(dataId)) return HELP_ID;
+ if (InspectionResultsView.DATA_KEY.is(dataId)) return this;
if (myTree == null) return null;
TreePath[] paths = myTree.getSelectionPaths();
if (paths == null) return null;
if (paths.length > 1) {
- if (DataConstants.PSI_ELEMENT_ARRAY.equals(dataId)) {
+ if (LangDataKeys.PSI_ELEMENT_ARRAY.is(dataId)) {
return collectPsiElements();
}
else {
}
}
- if (DataConstants.NAVIGATABLE.equals(dataId)) {
+ if (PlatformDataKeys.NAVIGATABLE.is(dataId)) {
return getSelectedNavigatable(problem, psiElement);
}
- else if (DataConstants.PSI_ELEMENT.equals(dataId)) {
+ else if (LangDataKeys.PSI_ELEMENT.is(dataId)) {
return psiElement.isValid() ? psiElement : null;
}
}
- else if (selectedNode instanceof ProblemDescriptionNode && DataConstants.NAVIGATABLE.equals(dataId)) {
+ else if (selectedNode instanceof ProblemDescriptionNode && PlatformDataKeys.NAVIGATABLE.is(dataId)) {
return getSelectedNavigatable(((ProblemDescriptionNode)selectedNode).getDescriptor());
}
import java.util.List;
/**
- * Created by IntelliJ IDEA.
- * User: Eugene.Kudelevsky
- * Date: Sep 11, 2009
- * Time: 9:26:11 PM
- * To change this template use File | Settings | File Templates.
+ * @author Eugene.Kudelevsky
*/
public abstract class LogConsoleBase extends AdditionalTabComponent implements LogConsole, LogFilterListener {
private static final Logger LOG = Logger.getInstance("com.intellij.diagnostic.logging.LogConsoleImpl");
@Nullable
private Editor getEditor() {
- return myConsole != null ? (Editor)((DataProvider)myConsole).getData(DataConstants.EDITOR) : null;
+ return myConsole != null ? PlatformDataKeys.EDITOR.getData((DataProvider) myConsole) : null;
}
private synchronized void filterConsoleOutput(Condition<String> isApplicable) {
import com.intellij.execution.impl.RunnerAndConfigurationSettingsImpl;
import com.intellij.execution.junit.RuntimeConfigurationProducer;
import com.intellij.ide.DataManager;
-import com.intellij.openapi.actionSystem.DataConstants;
import com.intellij.openapi.actionSystem.DataContext;
import com.intellij.openapi.actionSystem.LangDataKeys;
import com.intellij.openapi.actionSystem.PlatformDataKeys;
-import com.intellij.openapi.actionSystem.ex.DataConstantsEx;
import com.intellij.openapi.diagnostic.Logger;
import com.intellij.openapi.editor.Editor;
import com.intellij.openapi.module.Module;
private final Component myContextComponent;
public ConfigurationContext(final DataContext dataContext) {
- myRuntimeConfiguration = (RuntimeConfiguration)dataContext.getData(DataConstantsEx.RUNTIME_CONFIGURATION);
- myContextComponent = (Component)dataContext.getData(DataConstants.CONTEXT_COMPONENT);
+ myRuntimeConfiguration = RuntimeConfiguration.DATA_KEY.getData(dataContext);
+ myContextComponent = PlatformDataKeys.CONTEXT_COMPONENT.getData(dataContext);
myModule = LangDataKeys.MODULE.getData(dataContext);
- final Object location = dataContext.getData(Location.LOCATION);
+ @SuppressWarnings({"unchecked"})
+ final Location<PsiElement> location = (Location<PsiElement>)Location.DATA_KEY.getData(dataContext);
if (location != null) {
- myLocation = (Location<PsiElement>)location;
+ myLocation = location;
return;
}
final Project project = PlatformDataKeys.PROJECT.getData(dataContext);
import com.intellij.execution.ui.ConsoleViewContentType;
import com.intellij.execution.ui.ObservableConsoleView;
import com.intellij.ide.CommonActionsManager;
-import com.intellij.ide.DataAccessor;
-import com.intellij.ide.DataAccessors;
import com.intellij.ide.OccurenceNavigator;
import com.intellij.openapi.Disposable;
import com.intellij.openapi.actionSystem.*;
import com.intellij.openapi.project.DumbAware;
import com.intellij.openapi.project.Project;
import com.intellij.openapi.util.Computable;
-import com.intellij.openapi.util.Condition;
import com.intellij.openapi.util.Disposer;
import com.intellij.openapi.util.Key;
import com.intellij.openapi.util.text.LineTokenizer;
import com.intellij.util.LocalTimeCounter;
import com.intellij.util.containers.HashMap;
import org.jetbrains.annotations.NotNull;
+import org.jetbrains.annotations.Nullable;
import org.jetbrains.annotations.TestOnly;
import javax.swing.*;
}
public Object getData(final String dataId) {
- if (DataConstants.NAVIGATABLE.equals(dataId)){
+ if (PlatformDataKeys.NAVIGATABLE.is(dataId)){
if (myEditor == null) {
return null;
}
return openFileDescriptor;
}
- if (DataConstants.EDITOR.equals(dataId)) {
+ if (PlatformDataKeys.EDITOR.is(dataId)) {
return myEditor;
}
- if (DataConstants.HELP_ID.equals(dataId)) {
+ if (PlatformDataKeys.HELP_ID.is(dataId)) {
return myHelpId;
}
return null;
}
}
- private static final DataAccessor<ConsoleViewImpl> CONSOLE = new DataAccessor<ConsoleViewImpl>() {
- public ConsoleViewImpl getImpl(final DataContext dataContext) throws NoDataException {
- return DataAccessors.EDITOR.getNotNull(dataContext).getUserData(CONSOLE_VIEW_IN_EDITOR_VIEW);
- }
- };
-
- private static final Condition<ConsoleViewImpl> CONSOLE_IS_RUNNING = new Condition<ConsoleViewImpl>() {
- public boolean value(final ConsoleViewImpl consoleView) {
- return consoleView.myState.isRunning();
- }
- };
-
- private static final DataAccessor<ConsoleViewImpl> RUNNINT_CONSOLE =DataAccessor.createConditionalAccessor(CONSOLE, CONSOLE_IS_RUNNING);
-
private abstract static class ConsoleAction extends AnAction implements DumbAware {
public void actionPerformed(final AnActionEvent e) {
final DataContext context = e.getDataContext();
- final ConsoleViewImpl console = RUNNINT_CONSOLE.from(context);
+ final ConsoleViewImpl console = getRunningConsole(context);
execute(console, context);
}
protected abstract void execute(ConsoleViewImpl console, final DataContext context);
public void update(final AnActionEvent e) {
- final ConsoleViewImpl console = RUNNINT_CONSOLE.from(e.getDataContext());
+ final ConsoleViewImpl console = getRunningConsole(e.getDataContext());
e.getPresentation().setEnabled(console != null);
}
+
+ @Nullable
+ private static ConsoleViewImpl getRunningConsole(final DataContext context) {
+ final Editor editor = PlatformDataKeys.EDITOR.getData(context);
+ if (editor != null) {
+ final ConsoleViewImpl console = editor.getUserData(CONSOLE_VIEW_IN_EDITOR_VIEW);
+ if (console != null && console.myState.isRunning()) {
+ return console;
+ }
+ }
+ return null;
+ }
}
private static class EnterHandler extends ConsoleAction {
final ExecutionEnvironment old = myEnvironment;
myRunner.execute(myExecutor, new ExecutionEnvironment(old.getRunProfile(), old.getRunnerSettings(), old.getConfigurationSettings(), new DataContext() {
public Object getData(final String dataId) {
- if (GenericProgramRunner.CONTENT_TO_REUSE.equals(dataId)) return myDescriptor;
+ if (GenericProgramRunner.CONTENT_TO_REUSE_DATA_KEY.is(dataId)) return myDescriptor;
return dataContext.getData(dataId);
}
}));
}
- catch (RunCanceledByUserException e1) {
+ catch (RunCanceledByUserException ignore) {
}
catch (ExecutionException e1) {
Messages.showErrorDialog(project, e1.getMessage(), ExecutionBundle.message("restart.error.message.title"));
*/
package com.intellij.execution.ui;
-import com.intellij.execution.*;
+import com.intellij.execution.ExecutionBundle;
+import com.intellij.execution.Executor;
+import com.intellij.execution.ExecutorRegistry;
+import com.intellij.execution.TerminateRemoteProcessDialog;
import com.intellij.execution.process.ProcessAdapter;
import com.intellij.execution.process.ProcessEvent;
import com.intellij.execution.process.ProcessHandler;
import com.intellij.ide.DataManager;
import com.intellij.ide.impl.ContentManagerWatcher;
import com.intellij.openapi.Disposable;
-import com.intellij.openapi.actionSystem.DataConstants;
import com.intellij.openapi.actionSystem.DataContext;
import com.intellij.openapi.actionSystem.DataProvider;
+import com.intellij.openapi.actionSystem.PlatformDataKeys;
import com.intellij.openapi.application.ApplicationManager;
import com.intellij.openapi.application.impl.LaterInvocator;
import com.intellij.openapi.diagnostic.Logger;
import com.intellij.openapi.wm.ex.ToolWindowManagerEx;
import com.intellij.ui.content.*;
import com.intellij.util.EventDispatcher;
-import com.intellij.util.IconUtil;
import com.intellij.util.concurrency.Semaphore;
import com.intellij.util.containers.HashMap;
import org.jetbrains.annotations.NotNull;
public Object getData(String dataId) {
myInsideGetData ++;
try {
- if(DataConstants.HELP_ID.equals(dataId)) {
+ if(PlatformDataKeys.HELP_ID.is(dataId)) {
return executor.getHelpId();
}
else {
if (contentManager != null && content != null) {
contentManager.setSelectedContent(content);
- if (content != null) {
- final ToolWindow toolWindow = ToolWindowManager.getInstance(myProject).getToolWindow(requestor.getToolWindowId());
- toolWindow.show(null);
- }
+ final ToolWindow toolWindow = ToolWindowManager.getInstance(myProject).getToolWindow(requestor.getToolWindowId());
+ toolWindow.show(null);
}
}
});
@Nullable
public RunContentDescriptor getReuseContent(final Executor requestor, DataContext dataContext) {
if(ApplicationManager.getApplication().isUnitTestMode()) return null;
- RunContentDescriptor runContentDescriptor = (RunContentDescriptor)dataContext.getData(GenericProgramRunner.CONTENT_TO_REUSE);
+ RunContentDescriptor runContentDescriptor = GenericProgramRunner.CONTENT_TO_REUSE_DATA_KEY.getData(dataContext);
if(runContentDescriptor != null) return runContentDescriptor;
wait(2000);
}
}
- catch (InterruptedException e) {
+ catch (InterruptedException ignore) {
}
}
}
import com.intellij.ide.ui.LafManager;
import com.intellij.ide.ui.UISettings;
import com.intellij.openapi.actionSystem.*;
-import com.intellij.openapi.application.ex.ApplicationManagerEx;
import com.intellij.openapi.editor.Editor;
import com.intellij.openapi.editor.ScrollType;
import com.intellij.openapi.editor.SelectionModel;
@Nullable
public Object getData(@NonNls final String dataId) {
- if (DataConstants.EDITOR_EVEN_IF_INACTIVE.equals(dataId)) {
+ if (PlatformDataKeys.EDITOR_EVEN_IF_INACTIVE.is(dataId)) {
return myEditor;
}
return null;
PsiDocumentManager.getInstance(project).commitAllDocuments();
Editor editor = PlatformDataKeys.EDITOR.getData(dataContext);
- UsageTarget[] usageTargets = (UsageTarget[])dataContext.getData(UsageView.USAGE_TARGETS);
+ UsageTarget[] usageTargets = UsageView.USAGE_TARGETS_KEY.getData(dataContext);
if (usageTargets != null) {
FileEditor fileEditor = PlatformDataKeys.FILE_EDITOR.getData(dataContext);
if (fileEditor != null) {
Editor editor = PlatformDataKeys.EDITOR.getData(dataContext);
if (editor == null) {
- UsageTarget[] target = (UsageTarget[])dataContext.getData(UsageView.USAGE_TARGETS);
+ UsageTarget[] target = UsageView.USAGE_TARGETS_KEY.getData(dataContext);
return target != null && target.length > 0;
}
else {
package com.intellij.ide;
import com.intellij.openapi.actionSystem.DataContext;
+import com.intellij.openapi.actionSystem.LangDataKeys;
import com.intellij.openapi.actionSystem.PlatformDataKeys;
-import com.intellij.openapi.actionSystem.ex.DataConstantsEx;
import com.intellij.openapi.extensions.ExtensionPointName;
import com.intellij.openapi.extensions.Extensions;
import com.intellij.openapi.project.Project;
final PsiElement[] elements = PsiCopyPasteManager.getInstance().getElements(isCopied);
if (elements == null) return false;
try {
- PsiElement target = (PsiElement)dataContext.getData(DataConstantsEx.PASTE_TARGET_PSI_ELEMENT);
+ PsiElement target = LangDataKeys.PASTE_TARGET_PSI_ELEMENT.getData(dataContext);
if (isCopied[0]) {
PsiDirectory targetDirectory = target instanceof PsiDirectory ? (PsiDirectory)target : null;
if (targetDirectory == null && target instanceof PsiDirectoryContainer) {
return false;
}
- Object target = dataContext.getData(DataConstantsEx.PASTE_TARGET_PSI_ELEMENT);
+ Object target = LangDataKeys.PASTE_TARGET_PSI_ELEMENT.getData(dataContext);
if (target == null) {
return false;
}
return true;
}
}
-}
\ No newline at end of file
+}
package com.intellij.ide;
-import com.intellij.openapi.actionSystem.DataConstants;
import com.intellij.openapi.actionSystem.DataContext;
-import com.intellij.openapi.editor.Editor;
-import com.intellij.openapi.fileEditor.FileEditorManager;
+import com.intellij.openapi.actionSystem.LangDataKeys;
+import com.intellij.openapi.actionSystem.PlatformDataKeys;
import com.intellij.openapi.module.Module;
import com.intellij.openapi.project.Project;
-import com.intellij.openapi.project.ex.ProjectEx;
import com.intellij.openapi.vfs.VirtualFile;
-import com.intellij.psi.*;
+import com.intellij.psi.PsiFile;
+import com.intellij.psi.PsiManager;
/**
* @author yole
*/
public class DataAccessors {
- public static final DataAccessor<Project> PROJECT = new DataAccessor.SimpleDataAccessor<Project>(DataConstants.PROJECT);
- public static final DataAccessor<Module> MODULE = new DataAccessor.SimpleDataAccessor<Module>(DataConstants.MODULE);
- public static final DataAccessor<Editor> EDITOR = new DataAccessor.SimpleDataAccessor<Editor>(DataConstants.EDITOR);
+ @Deprecated
+ public static final DataAccessor<Project> PROJECT = new DataAccessor.SimpleDataAccessor<Project>(PlatformDataKeys.PROJECT.getName());
+ @Deprecated
+ public static final DataAccessor<Module> MODULE = new DataAccessor.SimpleDataAccessor<Module>(LangDataKeys.MODULE.getName());
public static final DataAccessor<PsiManager> PSI_MANAGER = new DataAccessor<PsiManager>() {
public PsiManager getImpl(DataContext dataContext) throws NoDataException {
return PsiManager.getInstance(PROJECT.getNotNull(dataContext));
}
};
- public static final DataAccessor<FileEditorManager> FILE_EDITOR_MANAGER = new DataAccessor<FileEditorManager>() {
- public FileEditorManager getImpl(DataContext dataContext) throws NoDataException {
- return FileEditorManager.getInstance(PROJECT.getNotNull(dataContext));
- }
- };
public static final DataAccessor<PsiFile> PSI_FILE = new DataAccessor<PsiFile>() {
public PsiFile getImpl(DataContext dataContext) throws NoDataException {
return PSI_MANAGER.getNotNull(dataContext).findFile(VIRTUAL_FILE.getNotNull(dataContext));
}
};
- public static final DataAccessor<PsiElement> PSI_ELEMENT = new DataAccessor.SimpleDataAccessor<PsiElement>(DataConstants.PSI_ELEMENT);
- public static final DataAccessor<PsiElement[]> PSI_ELEMENT_ARRAY = new DataAccessor.SimpleDataAccessor<PsiElement[]>(DataConstants.PSI_ELEMENT_ARRAY);
- public static final DataAccessor<VirtualFile> VIRTUAL_FILE = new DataAccessor.SimpleDataAccessor<VirtualFile>(DataConstants.VIRTUAL_FILE);
- public static final DataAccessor<VirtualFile[]> VIRTUAL_FILE_ARRAY = new DataAccessor.SimpleDataAccessor<VirtualFile[]>(DataConstants.VIRTUAL_FILE_ARRAY);
+ public static final DataAccessor<VirtualFile> VIRTUAL_FILE = new DataAccessor.SimpleDataAccessor<VirtualFile>(PlatformDataKeys.VIRTUAL_FILE.getName());
public static final DataAccessor<VirtualFile> VIRTUAL_DIR_OR_PARENT = new DataAccessor<VirtualFile>() {
public VirtualFile getImpl(DataContext dataContext) throws NoDataException {
VirtualFile virtualFile = VIRTUAL_FILE.getNotNull(dataContext);
return virtualFile.isDirectory() ? virtualFile : virtualFile.getParent();
}
};
- /**
- * @deprecated
- */
- public static final DataAccessor<String> PROJECT_FILE_PATH = new DataAccessor<String>() {
- public String getImpl(DataContext dataContext) throws NoDataException {
- Project project = PROJECT.getNotNull(dataContext);
- return project.getProjectFilePath();
- }
- };
public static final DataAccessor<VirtualFile> PROJECT_BASE_DIR = new DataAccessor<VirtualFile>() {
public VirtualFile getImpl(DataContext dataContext) throws NoDataException {
Project project = PROJECT.getNotNull(dataContext);
return module.getModuleFilePath();
}
};
- public static final DataAccessor<ProjectEx> PROJECT_EX = new DataAccessor.SubClassDataAccessor<Project, ProjectEx>(PROJECT, ProjectEx.class);
+
+ private DataAccessors() {
+ }
}
\ No newline at end of file
package com.intellij.ide.actions;
import com.intellij.openapi.actionSystem.*;
-import com.intellij.openapi.actionSystem.ex.DataConstantsEx;
import com.intellij.openapi.command.CommandProcessor;
import com.intellij.openapi.editor.Editor;
import com.intellij.openapi.project.Project;
public void actionPerformed(AnActionEvent e) {
final DataContext dataContext = e.getDataContext();
final Project project = PlatformDataKeys.PROJECT.getData(dataContext);
+ if (project == null) {
+ return;
+ }
CommandProcessor.getInstance().executeCommand(project, new Runnable() {
public void run() {
final Editor editor = PlatformDataKeys.EDITOR.getData(dataContext);
PsiElement[] elements;
- PsiDirectory defaultTargetDirectory = null;
+ PsiDirectory defaultTargetDirectory;
if (editor != null) {
PsiElement aElement = getTargetElement(editor, project);
PsiFile file = PsiDocumentManager.getInstance(project).getPsiFile(editor.getDocument());
}
defaultTargetDirectory = file.getContainingDirectory();
} else {
- Object element = dataContext.getData(DataConstantsEx.TARGET_PSI_ELEMENT);
+ PsiElement element = LangDataKeys.TARGET_PSI_ELEMENT.getData(dataContext);
defaultTargetDirectory = element instanceof PsiDirectory ? (PsiDirectory)element : null;
elements = LangDataKeys.PSI_ELEMENT_ARRAY.getData(dataContext);
}
}
Project project = PlatformDataKeys.PROJECT.getData(dataContext);
+ if (project == null) {
+ return;
+
+ }
PsiFile file = PsiDocumentManager.getInstance(project).getPsiFile(editor.getDocument());
PsiElement element = getTargetElement(editor, project);
}
}
- private void addScheme(final DefaultActionGroup group, final CodeStyleSettingsManager manager, final CodeStyleScheme currentScheme,
- final CodeStyleScheme scheme, final boolean addScheme) {
+ private static void addScheme(final DefaultActionGroup group,
+ final CodeStyleSettingsManager manager,
+ final CodeStyleScheme currentScheme,
+ final CodeStyleScheme scheme,
+ final boolean addScheme) {
group.add(new AnAction(scheme.getName(), "",
scheme == currentScheme && !manager.USE_PER_PROJECT_SETTINGS ? ourCurrentAction : ourNotCurrentAction) {
public void actionPerformed(AnActionEvent e) {
public void update(AnActionEvent e) {
super.update(e);
- e.getPresentation().setEnabled(e.getDataContext().getData(DataConstants.PROJECT) != null);
+ e.getPresentation().setEnabled(PlatformDataKeys.PROJECT.getData(e.getDataContext()) != null);
}
}
import com.intellij.ide.FileEditorProvider;
import com.intellij.ide.SelectInContext;
-import com.intellij.openapi.actionSystem.*;
+import com.intellij.openapi.actionSystem.AnActionEvent;
+import com.intellij.openapi.actionSystem.DataContext;
+import com.intellij.openapi.actionSystem.LangDataKeys;
+import com.intellij.openapi.actionSystem.PlatformDataKeys;
import com.intellij.openapi.editor.Document;
import com.intellij.openapi.fileEditor.*;
import com.intellij.openapi.fileEditor.ex.FileEditorManagerEx;
return null;
}
- SelectInContext selectInContext = (SelectInContext)dataContext.getData(SelectInContext.DATA_CONTEXT_ID);
+ SelectInContext selectInContext = SelectInContext.DATA_KEY.getData(dataContext);
if (selectInContext == null) {
selectInContext = createPsiContext(event);
}
return (JComponent)source;
}
else {
- return safeCast(event.getDataContext().getData(DataConstants.CONTEXT_COMPONENT), JComponent.class);
+ return safeCast(PlatformDataKeys.CONTEXT_COMPONENT.getData(event.getDataContext()), JComponent.class);
}
}
public FileEditorProvider getFileEditorProvider() {
return new FileEditorProvider() {
public FileEditor openFileEditor() {
- final FileEditor[] fileEditors =
- FileEditorManager.getInstance(getProject()).openFile(myElementToSelect.getContainingFile().getVirtualFile(), false);
+ final VirtualFile file = myElementToSelect.getContainingFile().getVirtualFile();
+ if (file == null) {
+ return null;
+ }
+ final FileEditor[] fileEditors = FileEditorManager.getInstance(getProject()).openFile(file, false);
return fileEditors.length > 0 ? fileEditors[0] : null;
}
};
import com.intellij.history.LocalHistory;
import com.intellij.history.LocalHistoryAction;
-import com.intellij.ide.*;
+import com.intellij.ide.CopyPasteDelegator;
+import com.intellij.ide.DeleteProvider;
+import com.intellij.ide.IdeBundle;
+import com.intellij.ide.IdeView;
import com.intellij.ide.projectView.ProjectViewNode;
import com.intellij.ide.projectView.impl.ModuleGroup;
import com.intellij.ide.projectView.impl.ProjectAbstractTreeStructureBase;
import com.intellij.ide.util.EditSourceUtil;
import com.intellij.ide.util.EditorHelper;
import com.intellij.ide.util.treeView.AbstractTreeNode;
-import com.intellij.ide.util.treeView.smartTree.TreeElement;
import com.intellij.openapi.actionSystem.*;
-import com.intellij.openapi.actionSystem.ex.DataConstantsEx;
import com.intellij.openapi.application.ApplicationManager;
import com.intellij.openapi.application.ModalityState;
import com.intellij.openapi.diagnostic.Logger;
}
}, KeyStroke.getKeyStroke(KeyEvent.VK_BACK_SLASH, SystemInfo.isMac ? KeyEvent.META_MASK : KeyEvent.CTRL_MASK), JComponent.WHEN_FOCUSED);
- myList.getInputMap(JComponent.WHEN_FOCUSED).put(KeyStroke.getKeyStroke(KeyEvent.VK_ENTER, 0), ACTION_DRILL_DOWN);
- myList.getInputMap(JComponent.WHEN_FOCUSED)
+ myList.getInputMap(WHEN_FOCUSED).put(KeyStroke.getKeyStroke(KeyEvent.VK_ENTER, 0), ACTION_DRILL_DOWN);
+ myList.getInputMap(WHEN_FOCUSED)
.put(KeyStroke.getKeyStroke(KeyEvent.VK_PAGE_DOWN, SystemInfo.isMac ? KeyEvent.META_MASK : KeyEvent.CTRL_MASK), ACTION_DRILL_DOWN);
myList.getActionMap().put(ACTION_DRILL_DOWN, new AbstractAction() {
public void actionPerformed(final ActionEvent e) {
}
}
});
- myList.getInputMap(JComponent.WHEN_FOCUSED)
+ myList.getInputMap(WHEN_FOCUSED)
.put(KeyStroke.getKeyStroke(KeyEvent.VK_PAGE_UP, SystemInfo.isMac ? KeyEvent.META_MASK : KeyEvent.CTRL_MASK), ACTION_GO_UP);
- myList.getInputMap(JComponent.WHEN_FOCUSED).put(KeyStroke.getKeyStroke(KeyEvent.VK_BACK_SPACE, 0), ACTION_GO_UP);
+ myList.getInputMap(WHEN_FOCUSED).put(KeyStroke.getKeyStroke(KeyEvent.VK_BACK_SPACE, 0), ACTION_GO_UP);
myList.getActionMap().put(ACTION_GO_UP, new AbstractAction() {
public void actionPerformed(final ActionEvent e) {
goUp();
private static Object getValueAtIndex(AbstractTreeNode node) {
if (node == null) return null;
Object value = node.getValue();
- if (value instanceof TreeElement) {
+ if (value instanceof StructureViewTreeElement) {
return ((StructureViewTreeElement)value).getValue();
}
return value;
public final Object getDataImpl(final String dataId) {
if (myBuilder == null) return null;
final Object selectedValue = getSelectedValue();
- if (DataConstants.PSI_ELEMENT.equals(dataId)) {
+ if (LangDataKeys.PSI_ELEMENT.is(dataId)) {
final PsiElement selectedElement = getSelectedElement();
return selectedElement != null && selectedElement.isValid() ? selectedElement : null;
}
- if (DataConstants.PSI_ELEMENT_ARRAY.equals(dataId)) {
+ if (LangDataKeys.PSI_ELEMENT_ARRAY.is(dataId)) {
return filterInvalidElements(getSelectedElements());
}
- else if (DataConstantsEx.PASTE_TARGET_PSI_ELEMENT.equals(dataId)) {
+ else if (LangDataKeys.PASTE_TARGET_PSI_ELEMENT.is(dataId)) {
final AbstractTreeNode parentNode = myBuilder.getParentNode();
final Object element = parentNode != null ? parentNode.getValue() : null;
return element instanceof PsiElement && ((PsiElement)element).isValid() ? element : null;
}
- else if (DataConstants.NAVIGATABLE_ARRAY.equals(dataId)) {
+ else if (PlatformDataKeys.NAVIGATABLE_ARRAY.is(dataId)) {
return getNavigatables();
}
- else if (DataConstants.COPY_PROVIDER.equals(dataId)) {
+ else if (PlatformDataKeys.COPY_PROVIDER.is(dataId)) {
return myCopyPasteDelegator != null ? myCopyPasteDelegator.getCopyProvider() : null;
}
- else if (DataConstants.CUT_PROVIDER.equals(dataId)) {
+ else if (PlatformDataKeys.CUT_PROVIDER.is(dataId)) {
return myCopyPasteDelegator != null ? myCopyPasteDelegator.getCutProvider() : null;
}
- else if (DataConstants.PASTE_PROVIDER.equals(dataId)) {
+ else if (PlatformDataKeys.PASTE_PROVIDER.is(dataId)) {
return myCopyPasteDelegator != null ? myCopyPasteDelegator.getPasteProvider() : null;
}
- else if (DataConstants.IDE_VIEW.equals(dataId)) {
+ else if (LangDataKeys.IDE_VIEW.is(dataId)) {
return myIdeView;
}
- else if (DataConstants.DELETE_ELEMENT_PROVIDER.equals(dataId)) {
+ else if (PlatformDataKeys.DELETE_ELEMENT_PROVIDER.is(dataId)) {
return myDeleteElementProvider;
}
- else if (DataConstants.MODULE.equals(dataId)) {
+ else if (LangDataKeys.MODULE.is(dataId)) {
return selectedValue instanceof Module ? selectedValue : null;
}
- else if (DataConstantsEx.MODULE_GROUP_ARRAY.equals(dataId)) {
+ else if (ModuleGroup.ARRAY_DATA_KEY.is(dataId)) {
return selectedValue instanceof ModuleGroup ? new ModuleGroup[]{(ModuleGroup)selectedValue} : null;
}
- else if (DataConstantsEx.LIBRARY_GROUP_ARRAY.equals(dataId)) {
+ else if (LibraryGroupElement.ARRAY_DATA_KEY.is(dataId)) {
return selectedValue instanceof LibraryGroupElement ? new LibraryGroupElement[]{(LibraryGroupElement)selectedValue} : null;
}
- else if (DataConstantsEx.NAMED_LIBRARY_ARRAY.equals(dataId)) {
+ else if (NamedLibraryElement.ARRAY_DATA_KEY.is(dataId)) {
return selectedValue instanceof NamedLibraryElement ? new NamedLibraryElement[]{(NamedLibraryElement)selectedValue} : null;
}
import com.intellij.ide.util.treeView.NodeRenderer;
import com.intellij.navigation.ItemPresentation;
import com.intellij.openapi.actionSystem.*;
-import com.intellij.openapi.actionSystem.ex.DataConstantsEx;
import com.intellij.openapi.editor.Editor;
import com.intellij.openapi.extensions.Extensions;
import com.intellij.openapi.module.Module;
private FavoritesViewTreeBuilder myBuilder;
private final CopyPasteDelegator myCopyPasteDelegator;
private MouseListener myTreePopupHandler;
- @NonNls public static final String CONTEXT_FAVORITES_ROOTS = "FavoritesRoot";
- @NonNls public static final String FAVORITES_LIST_NAME = "FavoritesListName";
+
+ public static final DataKey<FavoritesTreeNodeDescriptor[]> CONTEXT_FAVORITES_ROOTS_DATA_KEY = DataKey.create("FavoritesRoot");
+ @Deprecated public static final String CONTEXT_FAVORITES_ROOTS = CONTEXT_FAVORITES_ROOTS_DATA_KEY.getName();
+
+ public static final DataKey<String> FAVORITES_LIST_NAME_DATA_KEY = DataKey.create("FavoritesListName");
+ @Deprecated public static final String FAVORITES_LIST_NAME = FAVORITES_LIST_NAME_DATA_KEY.getName();
protected Project myProject;
private final String myHelpId;
final FavoritesTreeNodeDescriptor favoritesTreeNodeDescriptor = (FavoritesTreeNodeDescriptor)userObject;
AbstractTreeNode treeNode = favoritesTreeNodeDescriptor.getElement();
final ItemPresentation presentation = treeNode.getPresentation();
- String locationString = presentation != null ? presentation.getLocationString() : null;
+ String locationString = presentation.getLocationString();
if (locationString != null && locationString.length() > 0) {
append(" (" + locationString + ")", SimpleTextAttributes.GRAY_ATTRIBUTES);
}
}
public Object getData(String dataId) {
- if (DataConstants.PROJECT.equals(dataId)) {
+ if (PlatformDataKeys.PROJECT.is(dataId)) {
return myProject;
}
- if (DataConstants.NAVIGATABLE.equals(dataId)) {
+ if (PlatformDataKeys.NAVIGATABLE.is(dataId)) {
final FavoritesTreeNodeDescriptor[] selectedNodeDescriptors = getSelectedNodeDescriptors();
return selectedNodeDescriptors.length == 1 ? selectedNodeDescriptors[0].getElement() : null;
}
- if (DataConstants.NAVIGATABLE_ARRAY.equals(dataId)) {
+ if (PlatformDataKeys.NAVIGATABLE_ARRAY.is(dataId)) {
final List<Navigatable> selectedElements = getSelectedElements(Navigatable.class);
return selectedElements.toArray(new Navigatable[selectedElements.size()]);
}
- if (DataConstants.CUT_PROVIDER.equals(dataId)) {
+ if (PlatformDataKeys.CUT_PROVIDER.is(dataId)) {
return myCopyPasteDelegator.getCutProvider();
}
- if (DataConstants.COPY_PROVIDER.equals(dataId)) {
+ if (PlatformDataKeys.COPY_PROVIDER.is(dataId)) {
return myCopyPasteDelegator.getCopyProvider();
}
- if (DataConstants.PASTE_PROVIDER.equals(dataId)) {
+ if (PlatformDataKeys.PASTE_PROVIDER.is(dataId)) {
return myCopyPasteDelegator.getPasteProvider();
}
- if (DataConstants.HELP_ID.equals(dataId)) {
+ if (PlatformDataKeys.HELP_ID.is(dataId)) {
return myHelpId;
}
- if (DataConstants.PSI_ELEMENT.equals(dataId)) {
+ if (LangDataKeys.PSI_ELEMENT.is(dataId)) {
PsiElement[] elements = getSelectedPsiElements();
if (elements.length != 1) {
return null;
}
return elements[0] != null && elements[0].isValid() ? elements[0] : null;
}
- if (DataConstants.PSI_ELEMENT_ARRAY.equals(dataId)) {
+ if (LangDataKeys.PSI_ELEMENT_ARRAY.is(dataId)) {
final PsiElement[] elements = getSelectedPsiElements();
ArrayList<PsiElement> result = new ArrayList<PsiElement>();
for (PsiElement element : elements) {
return result.isEmpty() ? null : result.toArray(new PsiElement[result.size()]);
}
- if (DataConstants.IDE_VIEW.equals(dataId)) {
+ if (LangDataKeys.IDE_VIEW.is(dataId)) {
return myIdeView;
}
- if (DataConstantsEx.TARGET_PSI_ELEMENT.equals(dataId)) {
+ if (LangDataKeys.TARGET_PSI_ELEMENT.is(dataId)) {
return null;
}
- if (DataConstants.MODULE_CONTEXT.equals(dataId)) {
+ if (LangDataKeys.MODULE_CONTEXT.is(dataId)) {
Module[] selected = getSelectedModules();
return selected != null && selected.length == 1 ? selected[0] : null;
}
- if (DataConstants.MODULE_CONTEXT_ARRAY.equals(dataId)) {
+ if (LangDataKeys.MODULE_CONTEXT_ARRAY.is(dataId)) {
return getSelectedModules();
}
- if (DataConstants.DELETE_ELEMENT_PROVIDER.equals(dataId)) {
+ if (PlatformDataKeys.DELETE_ELEMENT_PROVIDER.is(dataId)) {
final Object[] elements = getSelectedNodeElements();
return elements != null && elements.length >= 1 && elements[0] instanceof Module
? myDeleteModuleProvider
: myDeletePSIElementProvider;
}
- if (DataConstantsEx.MODULE_GROUP_ARRAY.equals(dataId)) {
+ if (ModuleGroup.ARRAY_DATA_KEY.is(dataId)) {
final List<ModuleGroup> selectedElements = getSelectedElements(ModuleGroup.class);
return selectedElements.isEmpty() ? null : selectedElements.toArray(new ModuleGroup[selectedElements.size()]);
}
- if (DataConstantsEx.LIBRARY_GROUP_ARRAY.equals(dataId)) {
+ if (LibraryGroupElement.ARRAY_DATA_KEY.is(dataId)) {
final List<LibraryGroupElement> selectedElements = getSelectedElements(LibraryGroupElement.class);
return selectedElements.isEmpty() ? null : selectedElements.toArray(new LibraryGroupElement[selectedElements.size()]);
}
- if (DataConstantsEx.NAMED_LIBRARY_ARRAY.equals(dataId)) {
+ if (NamedLibraryElement.ARRAY_DATA_KEY.is(dataId)) {
final List<NamedLibraryElement> selectedElements = getSelectedElements(NamedLibraryElement.class);
return selectedElements.isEmpty() ? null : selectedElements.toArray(new NamedLibraryElement[selectedElements.size()]);
}
- if (CONTEXT_FAVORITES_ROOTS.equals(dataId)) {
+ if (CONTEXT_FAVORITES_ROOTS_DATA_KEY.is(dataId)) {
List<FavoritesTreeNodeDescriptor> result = new ArrayList<FavoritesTreeNodeDescriptor>();
FavoritesTreeNodeDescriptor[] selectedNodeDescriptors = getSelectedNodeDescriptors();
for (FavoritesTreeNodeDescriptor selectedNodeDescriptor : selectedNodeDescriptors) {
}
return result.toArray(new FavoritesTreeNodeDescriptor[result.size()]);
}
- if (FAVORITES_LIST_NAME.equals(dataId)) {
+ if (FAVORITES_LIST_NAME_DATA_KEY.is(dataId)) {
return myListName;
}
FavoritesTreeNodeDescriptor[] descriptors = getSelectedNodeDescriptors();
import com.intellij.ide.projectView.impl.nodes.*;
import com.intellij.ide.util.treeView.AbstractTreeNode;
import com.intellij.openapi.actionSystem.*;
-import com.intellij.openapi.actionSystem.ex.DataConstantsEx;
import com.intellij.openapi.diagnostic.Logger;
import com.intellij.openapi.extensions.Extensions;
import com.intellij.openapi.module.Module;
Object elements = retrieveData(null, LangDataKeys.PSI_ELEMENT.getData(dataContext));
elements = retrieveData(elements, LangDataKeys.PSI_ELEMENT_ARRAY.getData(dataContext));
elements = retrieveData(elements, LangDataKeys.PSI_FILE.getData(dataContext));
- elements = retrieveData(elements, dataContext.getData(DataConstantsEx.MODULE_GROUP_ARRAY));
+ elements = retrieveData(elements, ModuleGroup.ARRAY_DATA_KEY.getData(dataContext));
elements = retrieveData(elements, LangDataKeys.MODULE_CONTEXT_ARRAY.getData(dataContext));
- elements = retrieveData(elements, dataContext.getData(DataConstantsEx.LIBRARY_GROUP_ARRAY));
- elements = retrieveData(elements, dataContext.getData(DataConstantsEx.NAMED_LIBRARY_ARRAY));
+ elements = retrieveData(elements, LibraryGroupElement.ARRAY_DATA_KEY.getData(dataContext));
+ elements = retrieveData(elements, NamedLibraryElement.ARRAY_DATA_KEY.getData(dataContext));
elements = retrieveData(elements, PlatformDataKeys.VIRTUAL_FILE.getData(dataContext));
elements = retrieveData(elements, PlatformDataKeys.VIRTUAL_FILE_ARRAY.getData(dataContext));
return elements;
import com.intellij.openapi.actionSystem.AnActionEvent;
import com.intellij.openapi.actionSystem.DataContext;
import com.intellij.openapi.actionSystem.PlatformDataKeys;
-import com.intellij.openapi.project.Project;
import com.intellij.openapi.project.DumbAware;
+import com.intellij.openapi.project.Project;
/**
* User: anna
return;
}
FavoritesManager favoritesManager = FavoritesManager.getInstance(project);
- String listName = (String)dataContext.getData(FavoritesTreeViewPanel.FAVORITES_LIST_NAME);
+ String listName = FavoritesTreeViewPanel.FAVORITES_LIST_NAME_DATA_KEY.getData(dataContext);
String[] lists = favoritesManager.getAvailableFavoritesLists();
for (String list : lists) {
if (!list.equals(listName)) {
e.getPresentation().setEnabled(false);
return;
}
- String listName = (String)dataContext.getData(FavoritesTreeViewPanel.FAVORITES_LIST_NAME);
+ String listName = FavoritesTreeViewPanel.FAVORITES_LIST_NAME_DATA_KEY.getData(dataContext);
e.getPresentation().setEnabled(listName != null);
if (listName != null) {
e.getPresentation().setText(IdeBundle.message("action.delete.all.favorites.lists.but.this",listName));
import com.intellij.openapi.actionSystem.AnActionEvent;
import com.intellij.openapi.actionSystem.DataContext;
import com.intellij.openapi.actionSystem.PlatformDataKeys;
-import com.intellij.openapi.project.Project;
import com.intellij.openapi.project.DumbAware;
+import com.intellij.openapi.project.Project;
/**
* User: anna
*/
public class DeleteFavoritesListAction extends AnAction implements DumbAware {
public DeleteFavoritesListAction() {
- super(IdeBundle.message("action.delete.favorites.list",""));
+ super(IdeBundle.message("action.delete.favorites.list", ""));
}
public void actionPerformed(AnActionEvent e) {
return;
}
FavoritesManager favoritesManager = FavoritesManager.getInstance(project);
- String listName = (String)dataContext.getData(FavoritesTreeViewPanel.FAVORITES_LIST_NAME);
- favoritesManager.removeFavoritesList(listName);
+ String listName = FavoritesTreeViewPanel.FAVORITES_LIST_NAME_DATA_KEY.getData(dataContext);
+ if (listName != null) {
+ favoritesManager.removeFavoritesList(listName);
+ }
}
public void update(AnActionEvent e) {
final DataContext dataContext = e.getDataContext();
Project project = PlatformDataKeys.PROJECT.getData(dataContext);
- if (project == null){
+ if (project == null) {
e.getPresentation().setEnabled(false);
return;
}
- String listName = (String)dataContext.getData(FavoritesTreeViewPanel.FAVORITES_LIST_NAME);
+ String listName = FavoritesTreeViewPanel.FAVORITES_LIST_NAME_DATA_KEY.getData(dataContext);
e.getPresentation().setEnabled(listName != null && !listName.equals(project.getName()));
if (listName != null) {
- e.getPresentation().setText(IdeBundle.message("action.delete.favorites.list",listName));
- e.getPresentation().setDescription(IdeBundle.message("action.delete.favorites.list",listName));
+ e.getPresentation().setText(IdeBundle.message("action.delete.favorites.list", listName));
+ e.getPresentation().setDescription(IdeBundle.message("action.delete.favorites.list", listName));
}
}
}
return;
}
FavoritesManager favoritesManager = FavoritesManager.getInstance(project);
- FavoritesTreeNodeDescriptor[] roots = (FavoritesTreeNodeDescriptor[])dataContext.getData(FavoritesTreeViewPanel.CONTEXT_FAVORITES_ROOTS);
- String listName = (String)dataContext.getData(FavoritesTreeViewPanel.FAVORITES_LIST_NAME);
+ FavoritesTreeNodeDescriptor[] roots = FavoritesTreeViewPanel.CONTEXT_FAVORITES_ROOTS_DATA_KEY.getData(dataContext);
+ String listName = FavoritesTreeViewPanel.FAVORITES_LIST_NAME_DATA_KEY.getData(dataContext);
assert roots != null;
assert listName != null;
for (FavoritesTreeNodeDescriptor root : roots) {
e.getPresentation().setEnabled(false);
return;
}
- final String listName = (String)dataContext.getData(FavoritesTreeViewPanel.FAVORITES_LIST_NAME);
- FavoritesTreeNodeDescriptor[] roots = (FavoritesTreeNodeDescriptor[])dataContext.getData(FavoritesTreeViewPanel.CONTEXT_FAVORITES_ROOTS);
+ final String listName = FavoritesTreeViewPanel.FAVORITES_LIST_NAME_DATA_KEY.getData(dataContext);
+ FavoritesTreeNodeDescriptor[] roots = FavoritesTreeViewPanel.CONTEXT_FAVORITES_ROOTS_DATA_KEY.getData(dataContext);
e.getPresentation().setEnabled(listName != null && roots != null && roots.length != 0);
}
}
import com.intellij.openapi.actionSystem.AnActionEvent;
import com.intellij.openapi.actionSystem.DataContext;
import com.intellij.openapi.actionSystem.PlatformDataKeys;
-import com.intellij.openapi.project.Project;
import com.intellij.openapi.project.DumbAware;
+import com.intellij.openapi.project.Project;
import com.intellij.openapi.ui.InputValidator;
import com.intellij.openapi.ui.Messages;
import com.intellij.openapi.util.IconLoader;
*/
public class RenameFavoritesListAction extends AnAction implements DumbAware {
public RenameFavoritesListAction() {
- super(IdeBundle.message("action.rename.favorites.list"),
- IdeBundle.message("action.rename.favorites.list"), IconLoader.getIcon("/actions/menu-replace.png"));
+ super(IdeBundle.message("action.rename.favorites.list"), IdeBundle.message("action.rename.favorites.list"),
+ IconLoader.getIcon("/actions/menu-replace.png"));
}
public void actionPerformed(AnActionEvent e) {
return;
}
final FavoritesManager favoritesManager = FavoritesManager.getInstance(project);
- String listName = (String)dataContext.getData(FavoritesTreeViewPanel.FAVORITES_LIST_NAME);
- final String newName = Messages.showInputDialog(project, IdeBundle.message("prompt.input.favorites.list.new.name"),
- IdeBundle.message("title.rename.favorites.list"), Messages.getInformationIcon(), listName,
- new InputValidator() {
- public boolean checkInput(String inputString) {
- return inputString != null && inputString.trim().length() > 0;
- }
+ String listName = FavoritesTreeViewPanel.FAVORITES_LIST_NAME_DATA_KEY.getData(dataContext);
+ final String newName = Messages
+ .showInputDialog(project, IdeBundle.message("prompt.input.favorites.list.new.name"), IdeBundle.message("title.rename.favorites.list"),
+ Messages.getInformationIcon(), listName, new InputValidator() {
+ public boolean checkInput(String inputString) {
+ return inputString != null && inputString.trim().length() > 0;
+ }
- public boolean canClose(String inputString) {
- String[] lists = favoritesManager.getAvailableFavoritesLists();
- final boolean isNew = ArrayUtil.find(lists, inputString.trim()) == -1;
- if (!isNew) {
- Messages.showErrorDialog(project, IdeBundle.message(
- "error.favorites.list.already.exists", inputString.trim()), IdeBundle.message(
- "title.unable.to.add.favorites.list"));
- return false;
- }
- return inputString.trim().length() > 0;
- }
- });
+ public boolean canClose(String inputString) {
+ String[] lists = favoritesManager.getAvailableFavoritesLists();
+ final boolean isNew = ArrayUtil.find(lists, inputString.trim()) == -1;
+ if (!isNew) {
+ Messages.showErrorDialog(project, IdeBundle.message("error.favorites.list.already.exists", inputString.trim()),
+ IdeBundle.message("title.unable.to.add.favorites.list"));
+ return false;
+ }
+ return inputString.trim().length() > 0;
+ }
+ });
if (listName != null && newName != null) {
favoritesManager.renameFavoritesList(listName, newName);
public void update(AnActionEvent e) {
final DataContext dataContext = e.getDataContext();
Project project = PlatformDataKeys.PROJECT.getData(dataContext);
- if (project == null){
+ if (project == null) {
e.getPresentation().setEnabled(false);
return;
}
- String listName = (String)dataContext.getData(FavoritesTreeViewPanel.FAVORITES_LIST_NAME);
+ String listName = FavoritesTreeViewPanel.FAVORITES_LIST_NAME_DATA_KEY.getData(dataContext);
e.getPresentation().setEnabled(listName != null && !listName.equals(project.getName()));
}
}
Project project = PlatformDataKeys.PROJECT.getData(dataContext);
final FavoritesManager favoritesManager = FavoritesManager.getInstance(project);
- FavoritesTreeNodeDescriptor[] roots = (FavoritesTreeNodeDescriptor[])dataContext.getData(FavoritesTreeViewPanel.CONTEXT_FAVORITES_ROOTS);
- String listName = (String)dataContext.getData(FavoritesTreeViewPanel.FAVORITES_LIST_NAME);
+ FavoritesTreeNodeDescriptor[] roots = FavoritesTreeViewPanel.CONTEXT_FAVORITES_ROOTS_DATA_KEY.getData(dataContext);
+ String listName = FavoritesTreeViewPanel.FAVORITES_LIST_NAME_DATA_KEY.getData(dataContext);
doSend(favoritesManager, roots, listName);
}
e.getPresentation().setEnabled(false);
return;
}
- FavoritesTreeNodeDescriptor[] roots = (FavoritesTreeNodeDescriptor[])dataContext.getData(FavoritesTreeViewPanel.CONTEXT_FAVORITES_ROOTS);
+ FavoritesTreeNodeDescriptor[] roots = FavoritesTreeViewPanel.CONTEXT_FAVORITES_ROOTS_DATA_KEY.getData(dataContext);
if (roots == null || roots.length == 0) {
e.getPresentation().setEnabled(false);
return;
}
- String listName = (String)dataContext.getData(FavoritesTreeViewPanel.FAVORITES_LIST_NAME);
+ String listName = FavoritesTreeViewPanel.FAVORITES_LIST_NAME_DATA_KEY.getData(dataContext);
e.getPresentation().setEnabled(listName != null);
}
}
import com.intellij.ide.favoritesTreeView.FavoritesTreeViewPanel;
import com.intellij.openapi.actionSystem.*;
import com.intellij.openapi.project.Project;
+import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
import java.util.ArrayList;
* Date: Feb 24, 2005
*/
public class SendToFavoritesGroup extends ActionGroup{
-
+ @NotNull
public AnAction[] getChildren(@Nullable AnActionEvent e) {
- if (e == null) return AnAction.EMPTY_ARRAY;
+ if (e == null) return EMPTY_ARRAY;
final Project project = PlatformDataKeys.PROJECT.getData(e.getDataContext());
if (project == null){
- return AnAction.EMPTY_ARRAY;
+ return EMPTY_ARRAY;
}
final FavoritesManager favoritesManager = FavoritesManager.getInstance(project);
final DataContext dataContext = e.getDataContext();
- FavoritesTreeNodeDescriptor[] roots = (FavoritesTreeNodeDescriptor[])dataContext.getData(FavoritesTreeViewPanel.CONTEXT_FAVORITES_ROOTS);
- String listName = (String)dataContext.getData(FavoritesTreeViewPanel.FAVORITES_LIST_NAME);
+ FavoritesTreeNodeDescriptor[] roots = FavoritesTreeViewPanel.CONTEXT_FAVORITES_ROOTS_DATA_KEY.getData(dataContext);
+ String listName = FavoritesTreeViewPanel.FAVORITES_LIST_NAME_DATA_KEY.getData(dataContext);
if (roots == null || roots.length == 0 || listName == null) {
- return AnAction.EMPTY_ARRAY;
+ return EMPTY_ARRAY;
}
final String[] allLists = favoritesManager.getAvailableFavoritesLists();
public void actionPerformed(AnActionEvent e) {
final DataContext dataContext = e.getDataContext();
Project project = PlatformDataKeys.PROJECT.getData(dataContext);
- FavoritesTreeNodeDescriptor[] roots = (FavoritesTreeNodeDescriptor[])dataContext.getData(FavoritesTreeViewPanel.CONTEXT_FAVORITES_ROOTS);
- String listName = (String)dataContext.getData(FavoritesTreeViewPanel.FAVORITES_LIST_NAME);
+ FavoritesTreeNodeDescriptor[] roots = FavoritesTreeViewPanel.CONTEXT_FAVORITES_ROOTS_DATA_KEY.getData(dataContext);
+ String listName = FavoritesTreeViewPanel.FAVORITES_LIST_NAME_DATA_KEY.getData(dataContext);
String newName = AddNewFavoritesListAction.doAddNewFavoritesList(project);
if (newName != null) {
}
protected static TypeHierarchyBrowserBase getTypeHierarchyBrowser(final DataContext context) {
- return (TypeHierarchyBrowserBase)context.getData(TypeHierarchyBrowserBase.TYPE_HIERARCHY_BROWSER_DATA_KEY);
+ return TypeHierarchyBrowserBase.DATA_KEY.getData(context);
}
}
import com.intellij.ide.actions.CloseTabToolbarAction;
import com.intellij.ide.actions.ContextHelpAction;
import com.intellij.openapi.Disposable;
-import com.intellij.openapi.project.Project;
import com.intellij.openapi.actionSystem.*;
+import com.intellij.openapi.project.Project;
import com.intellij.openapi.ui.SimpleToolWindowPanel;
import com.intellij.pom.Navigatable;
import com.intellij.psi.NavigatablePsiElement;
import com.intellij.psi.PsiElement;
-import com.intellij.ui.content.Content;
-import com.intellij.ui.content.tabs.PinToolwindowTabAction;
import com.intellij.ui.AutoScrollToSourceHandler;
import com.intellij.ui.TreeSpeedSearch;
import com.intellij.ui.TreeToolTipHandler;
+import com.intellij.ui.content.Content;
+import com.intellij.ui.content.tabs.PinToolwindowTabAction;
import com.intellij.ui.treeStructure.Tree;
import com.intellij.util.ui.UIUtil;
import com.intellij.util.ui.tree.TreeUtil;
@Nullable
public Object getData(@NonNls final String dataId) {
- if (DataConstants.PSI_ELEMENT.equals(dataId)) {
+ if (LangDataKeys.PSI_ELEMENT.is(dataId)) {
final PsiElement anElement = getSelectedElement();
return anElement != null && anElement.isValid() ? anElement : null;
}
- if (DataConstants.PSI_ELEMENT_ARRAY.equals(dataId)) {
+ if (LangDataKeys.PSI_ELEMENT_ARRAY.is(dataId)) {
return getSelectedElements();
}
- if (DataConstants.DELETE_ELEMENT_PROVIDER.equals(dataId)) {
+ if (PlatformDataKeys.DELETE_ELEMENT_PROVIDER.is(dataId)) {
return null;
}
- if (DataConstants.NAVIGATABLE.equals(dataId)) {
+ if (PlatformDataKeys.NAVIGATABLE.is(dataId)) {
final DefaultMutableTreeNode selectedNode = getSelectedNode();
if (selectedNode == null) return null;
final HierarchyNodeDescriptor descriptor = getDescriptor(selectedNode);
if (descriptor == null) return null;
return getNavigatable(descriptor);
}
- if (DataConstants.NAVIGATABLE_ARRAY.equals(dataId)) {
+ if (PlatformDataKeys.NAVIGATABLE_ARRAY.is(dataId)) {
return getNavigatables();
}
return null;
import java.awt.*;
import java.text.MessageFormat;
import java.util.*;
+import java.util.List;
public abstract class HierarchyBrowserBaseEx extends HierarchyBrowserBase implements OccurenceNavigator {
private boolean myCachedIsValidBase = false;
- private final java.util.List<Runnable> myRunOnDisposeList = new ArrayList<Runnable>();
+ private final List<Runnable> myRunOnDisposeList = new ArrayList<Runnable>();
private final HashMap<String, OccurenceNavigator> myOccurrenceNavigators = new HashMap<String, OccurenceNavigator>();
private static final OccurenceNavigator EMPTY_NAVIGATOR = new OccurenceNavigator() {
if (getBrowserDataKey().equals(dataId)) {
return this;
}
- else if (DataConstants.HELP_ID.equals(dataId)) {
+ else if (PlatformDataKeys.HELP_ID.is(dataId)) {
return HELP_ID;
}
return super.getData(dataId);
@SuppressWarnings({"UnresolvedPropertyKey"})
public static final String METHOD_TYPE = IdeBundle.message("title.hierarchy.method");
- @NonNls public static final String METHOD_HIERARCHY_BROWSER_DATA_KEY = "com.intellij.ide.hierarchy.MethodHierarchyBrowserBase";
+ public static final DataKey<MethodHierarchyBrowserBase> DATA_KEY = DataKey.create("com.intellij.ide.hierarchy.MethodHierarchyBrowserBase");
+ @Deprecated @NonNls public static final String METHOD_HIERARCHY_BROWSER_DATA_KEY = DATA_KEY.getName();
public MethodHierarchyBrowserBase(final Project project, final PsiElement method) {
super(project, method);
@NotNull
protected String getBrowserDataKey() {
- return METHOD_HIERARCHY_BROWSER_DATA_KEY;
+ return DATA_KEY.getName();
}
@NotNull
public static class BaseOnThisMethodAction extends BaseOnThisElementAction {
public BaseOnThisMethodAction() {
- super(IdeBundle.message("action.base.on.this.method"), IdeActions.ACTION_METHOD_HIERARCHY, METHOD_HIERARCHY_BROWSER_DATA_KEY);
+ super(IdeBundle.message("action.base.on.this.method"), IdeActions.ACTION_METHOD_HIERARCHY, DATA_KEY.getName());
}
}
private final MyDeleteProvider myDeleteElementProvider = new MyDeleteProvider();
- public static final String TYPE_HIERARCHY_BROWSER_DATA_KEY = "com.intellij.ide.hierarchy.TypeHierarchyBrowserBase";
+ public static final DataKey<TypeHierarchyBrowserBase> DATA_KEY = DataKey.create("com.intellij.ide.hierarchy.TypeHierarchyBrowserBase");
+ @Deprecated public static final String TYPE_HIERARCHY_BROWSER_DATA_KEY = DATA_KEY.getName();
public TypeHierarchyBrowserBase(final Project project, final PsiElement element) {
super(project, element);
@NotNull
protected String getBrowserDataKey() {
- return TYPE_HIERARCHY_BROWSER_DATA_KEY;
+ return DATA_KEY.getName();
}
@NotNull
}
public final Object getData(final String dataId) {
- if (DataConstants.DELETE_ELEMENT_PROVIDER.equals(dataId)) {
+ if (PlatformDataKeys.DELETE_ELEMENT_PROVIDER.is(dataId)) {
return myDeleteElementProvider;
}
return super.getData(dataId);
protected static class BaseOnThisTypeAction extends BaseOnThisElementAction {
public BaseOnThisTypeAction() {
- super("", IdeActions.ACTION_TYPE_HIERARCHY, TYPE_HIERARCHY_BROWSER_DATA_KEY);
+ super("", IdeActions.ACTION_TYPE_HIERARCHY, DATA_KEY.getName());
}
@Override
import com.intellij.ide.DataManager;
import com.intellij.ide.impl.DataManagerImpl;
-import com.intellij.openapi.actionSystem.DataConstants;
import com.intellij.openapi.actionSystem.DataProvider;
+import com.intellij.openapi.actionSystem.LangDataKeys;
+import com.intellij.openapi.actionSystem.PlatformDataKeys;
import com.intellij.openapi.module.ModuleUtil;
import com.intellij.openapi.project.Project;
import com.intellij.openapi.vfs.VirtualFile;
*/
public class ModuleRule implements GetDataRule {
public Object getData(DataProvider dataProvider) {
- Object moduleContext = dataProvider.getData(DataConstants.MODULE_CONTEXT);
+ Object moduleContext = LangDataKeys.MODULE_CONTEXT.getData(dataProvider);
if (moduleContext != null) {
return moduleContext;
}
- Project project = (Project)dataProvider.getData(DataConstants.PROJECT);
+ Project project = PlatformDataKeys.PROJECT.getData(dataProvider);
if (project == null) {
- PsiElement element = (PsiElement)dataProvider.getData(DataConstants.PSI_ELEMENT);
+ PsiElement element = LangDataKeys.PSI_ELEMENT.getData(dataProvider);
if (element == null || !element.isValid()) return null;
project = element.getProject();
}
- VirtualFile virtualFile = (VirtualFile)dataProvider.getData(DataConstants.VIRTUAL_FILE);
+ VirtualFile virtualFile = PlatformDataKeys.VIRTUAL_FILE.getData(dataProvider);
if (virtualFile == null) {
- GetDataRule dataRule = ((DataManagerImpl)DataManager.getInstance()).getDataRule(DataConstants.VIRTUAL_FILE);
+ GetDataRule dataRule = ((DataManagerImpl)DataManager.getInstance()).getDataRule(PlatformDataKeys.VIRTUAL_FILE.getName());
if (dataRule != null) {
virtualFile = (VirtualFile)dataRule.getData(dataProvider);
}
package com.intellij.ide.impl.dataRules;
import com.intellij.ide.util.EditSourceUtil;
-import com.intellij.openapi.actionSystem.DataConstants;
import com.intellij.openapi.actionSystem.DataProvider;
+import com.intellij.openapi.actionSystem.LangDataKeys;
+import com.intellij.openapi.actionSystem.PlatformDataKeys;
import com.intellij.openapi.fileEditor.OpenFileDescriptor;
import com.intellij.pom.Navigatable;
import com.intellij.psi.PsiElement;
public class NavigatableRule implements GetDataRule {
public Object getData(DataProvider dataProvider) {
- final OpenFileDescriptor openFileDescriptor = (OpenFileDescriptor)dataProvider.getData(DataConstants.OPEN_FILE_DESCRIPTOR);
- if (openFileDescriptor != null && openFileDescriptor.getFile().isValid()) {
- return openFileDescriptor;
+ final Navigatable navigatable = PlatformDataKeys.NAVIGATABLE.getData(dataProvider);
+ if (navigatable != null && navigatable instanceof OpenFileDescriptor) {
+ final OpenFileDescriptor openFileDescriptor = (OpenFileDescriptor)navigatable;
+
+ if (openFileDescriptor.getFile().isValid()) {
+ return openFileDescriptor;
+ }
}
- final PsiElement element = (PsiElement)dataProvider.getData(DataConstants.PSI_ELEMENT);
+ final PsiElement element = LangDataKeys.PSI_ELEMENT.getData(dataProvider);
if (element != null) {
return EditSourceUtil.getDescriptor(element);
}
- final Object selection = dataProvider.getData(DataConstants.SELECTED_ITEM);
+ final Object selection = PlatformDataKeys.SELECTED_ITEM.getData(dataProvider);
if (selection instanceof Navigatable) {
return selection;
}
package com.intellij.ide.impl.dataRules;
-import com.intellij.openapi.actionSystem.DataConstants;
import com.intellij.openapi.actionSystem.DataProvider;
+import com.intellij.openapi.actionSystem.LangDataKeys;
public class PasteTargetRule implements GetDataRule {
public Object getData(DataProvider dataProvider) {
- Object data = dataProvider.getData(DataConstants.PSI_ELEMENT);
- return data;
+ return LangDataKeys.PSI_ELEMENT.getData(dataProvider);
}
}
package com.intellij.ide.impl.dataRules;
-import com.intellij.openapi.actionSystem.DataConstants;
import com.intellij.openapi.actionSystem.DataProvider;
+import com.intellij.openapi.actionSystem.PlatformDataKeys;
import com.intellij.psi.PsiElement;
public class PsiElementFromSelectionRule implements GetDataRule {
public Object getData(DataProvider dataProvider) {
- final Object element = dataProvider.getData(DataConstants.SELECTED_ITEM);
+ final Object element = dataProvider.getData(PlatformDataKeys.SELECTED_ITEM.getName());
if (element instanceof PsiElement) {
PsiElement psiElement = (PsiElement)element;
if (psiElement.isValid()) {
return null;
}
-}
\ No newline at end of file
+}
package com.intellij.ide.impl.dataRules;
-import com.intellij.openapi.actionSystem.DataConstants;
import com.intellij.openapi.actionSystem.DataProvider;
+import com.intellij.openapi.actionSystem.LangDataKeys;
+import com.intellij.openapi.actionSystem.PlatformDataKeys;
import com.intellij.openapi.project.Project;
import com.intellij.openapi.vfs.VirtualFile;
import com.intellij.psi.PsiElement;
public class PsiFileRule implements GetDataRule {
public Object getData(DataProvider dataProvider) {
- final PsiElement element = (PsiElement)dataProvider.getData(DataConstants.PSI_ELEMENT);
- if (element != null){
+ final PsiElement element = LangDataKeys.PSI_ELEMENT.getData(dataProvider);
+ if (element != null) {
return element.getContainingFile();
}
- Project project = (Project)dataProvider.getData(DataConstants.PROJECT);
- if (project != null){
- VirtualFile vFile = (VirtualFile)dataProvider.getData(DataConstants.VIRTUAL_FILE);
- if (vFile != null){
+ Project project = PlatformDataKeys.PROJECT.getData(dataProvider);
+ if (project != null) {
+ VirtualFile vFile = PlatformDataKeys.VIRTUAL_FILE.getData(dataProvider);
+ if (vFile != null) {
return PsiManager.getInstance(project).findFile(vFile);
}
}
package com.intellij.ide.impl.dataRules;
-import com.intellij.openapi.actionSystem.DataConstants;
import com.intellij.openapi.actionSystem.DataProvider;
+import com.intellij.openapi.actionSystem.LangDataKeys;
+import com.intellij.openapi.actionSystem.PlatformDataKeys;
import com.intellij.openapi.module.Module;
import com.intellij.openapi.project.Project;
import com.intellij.openapi.roots.ModuleRootManager;
import com.intellij.openapi.roots.ProjectRootManager;
import com.intellij.openapi.vfs.VfsUtil;
import com.intellij.openapi.vfs.VirtualFile;
-import com.intellij.psi.*;
+import com.intellij.psi.PsiDirectory;
+import com.intellij.psi.PsiDirectoryContainer;
+import com.intellij.psi.PsiElement;
+import com.intellij.psi.PsiFile;
import com.intellij.usages.Usage;
import com.intellij.usages.UsageTarget;
import com.intellij.usages.UsageView;
public Object getData(final DataProvider dataProvider) {
// Try to detect multiselection.
- Project project = (Project)dataProvider.getData(DataConstants.PROJECT_CONTEXT);
+ Project project = PlatformDataKeys.PROJECT_CONTEXT.getData(dataProvider);
if (project != null && !project.isDisposed()) {
return ProjectRootManager.getInstance(project).getContentRoots();
}
- Module[] selectedModules = (Module[])dataProvider.getData(DataConstants.MODULE_CONTEXT_ARRAY);
+ Module[] selectedModules = LangDataKeys.MODULE_CONTEXT_ARRAY.getData(dataProvider);
if (selectedModules != null && selectedModules.length > 0) {
return getFilesFromModules(selectedModules);
}
- Module selectedModule = (Module)dataProvider.getData(DataConstants.MODULE_CONTEXT);
+ Module selectedModule = LangDataKeys.MODULE_CONTEXT.getData(dataProvider);
if (selectedModule != null && !selectedModule.isDisposed()) {
return ModuleRootManager.getInstance(selectedModule).getContentRoots();
}
- PsiElement[] psiElements = (PsiElement[])dataProvider.getData(DataConstants.PSI_ELEMENT_ARRAY);
+ PsiElement[] psiElements = LangDataKeys.PSI_ELEMENT_ARRAY.getData(dataProvider);
if (psiElements != null && psiElements.length != 0) {
return getFilesFromPsiElements(psiElements);
}
// VirtualFile -> VirtualFile[]
- VirtualFile vFile = (VirtualFile)dataProvider.getData(DataConstants.VIRTUAL_FILE);
+ VirtualFile vFile = PlatformDataKeys.VIRTUAL_FILE.getData(dataProvider);
if (vFile != null) {
return new VirtualFile[]{vFile};
}
//
- PsiFile psiFile = (PsiFile)dataProvider.getData(DataConstants.PSI_FILE);
+ PsiFile psiFile = LangDataKeys.PSI_FILE.getData(dataProvider);
if (psiFile != null && psiFile.getVirtualFile() != null) {
return new VirtualFile[]{psiFile.getVirtualFile()};
}
- PsiElement elem = (PsiElement)dataProvider.getData(DataConstants.PSI_ELEMENT);
+ PsiElement elem = LangDataKeys.PSI_ELEMENT.getData(dataProvider);
if (elem != null) {
return getFilesFromPsiElement(elem);
}
- Usage[] usages = (Usage[])dataProvider.getData(UsageView.USAGES);
- UsageTarget[] usageTargets = (UsageTarget[])dataProvider.getData(UsageView.USAGE_TARGETS);
+ Usage[] usages = UsageView.USAGES_KEY.getData(dataProvider);
+ UsageTarget[] usageTargets = UsageView.USAGE_TARGETS_KEY.getData(dataProvider);
if (usages != null || usageTargets != null) {
return getFilesFromUsages(usages, usageTargets);
}
package com.intellij.ide.impl.dataRules;
-import com.intellij.openapi.actionSystem.DataConstants;
import com.intellij.openapi.actionSystem.DataProvider;
+import com.intellij.openapi.actionSystem.LangDataKeys;
+import com.intellij.openapi.actionSystem.PlatformDataKeys;
import com.intellij.openapi.vfs.VirtualFile;
import com.intellij.psi.PsiElement;
import com.intellij.psi.PsiFile;
public class VirtualFileRule implements GetDataRule {
public Object getData(final DataProvider dataProvider) {
// Try to detect multiselection.
- PsiElement[] psiElements = (PsiElement[])dataProvider.getData(DataConstants.PSI_ELEMENT_ARRAY);
+ PsiElement[] psiElements = LangDataKeys.PSI_ELEMENT_ARRAY.getData(dataProvider);
if (psiElements != null) {
for (PsiElement elem : psiElements) {
VirtualFile virtualFile = PsiUtilBase.getVirtualFile(elem);
}
}
- VirtualFile[] virtualFiles = (VirtualFile[])dataProvider.getData(DataConstants.VIRTUAL_FILE_ARRAY);
+ VirtualFile[] virtualFiles = PlatformDataKeys.VIRTUAL_FILE_ARRAY.getData(dataProvider);
if (virtualFiles != null && virtualFiles.length == 1) {
return virtualFiles[0];
}
- PsiFile psiFile = (PsiFile)dataProvider.getData(DataConstants.PSI_FILE);
+ PsiFile psiFile = LangDataKeys.PSI_FILE.getData(dataProvider);
if (psiFile != null) {
return psiFile.getVirtualFile();
}
- PsiElement elem = (PsiElement)dataProvider.getData(DataConstants.PSI_ELEMENT);
+ PsiElement elem = LangDataKeys.PSI_ELEMENT.getData(dataProvider);
if (elem == null) {
return null;
}
package com.intellij.ide.macro;
import com.intellij.ide.IdeBundle;
-import com.intellij.openapi.actionSystem.DataConstants;
import com.intellij.openapi.actionSystem.DataContext;
import com.intellij.openapi.actionSystem.PlatformDataKeys;
import com.intellij.openapi.project.Project;
public String expand(final DataContext dataContext) {
final Project project = PlatformDataKeys.PROJECT.getData(dataContext);
- if (project == null) return null;
- VirtualFile file = (VirtualFile)dataContext.getData(DataConstants.VIRTUAL_FILE);
- if (file == null) return null;
+ if (project == null) {
+ return null;
+ }
+ VirtualFile file = PlatformDataKeys.VIRTUAL_FILE.getData(dataContext);
+ if (file == null) {
+ return null;
+ }
if (!file.isDirectory()) {
file = file.getParent();
- if (file == null) return null;
+ if (file == null) {
+ return null;
+ }
}
final VirtualFile contentRoot = ProjectRootManager.getInstance(project).getFileIndex().getContentRootForFile(file);
- if (contentRoot == null) return null;
+ if (contentRoot == null) {
+ return null;
+ }
return FileUtil.getRelativePath(getIOFile(contentRoot), getIOFile(file));
}
}
package com.intellij.ide.macro;
import com.intellij.ide.IdeBundle;
-import com.intellij.openapi.actionSystem.DataConstants;
import com.intellij.openapi.actionSystem.DataContext;
import com.intellij.openapi.actionSystem.PlatformDataKeys;
import com.intellij.openapi.project.Project;
public String expand(final DataContext dataContext) {
final Project project = PlatformDataKeys.PROJECT.getData(dataContext);
- if (project == null) return null;
- VirtualFile file = (VirtualFile)dataContext.getData(DataConstants.VIRTUAL_FILE);
- if (file == null) return null;
+ if (project == null) {
+ return null;
+ }
+ VirtualFile file = PlatformDataKeys.VIRTUAL_FILE.getData(dataContext);
+ if (file == null) {
+ return null;
+ }
if (!file.isDirectory()) {
file = file.getParent();
- if (file == null) return null;
+ if (file == null) {
+ return null;
+ }
}
final VirtualFile sourceRoot = ProjectRootManager.getInstance(project).getFileIndex().getSourceRootForFile(file);
if (sourceRoot == null) return null;
package com.intellij.ide.macro;
import com.intellij.ide.IdeBundle;
-import com.intellij.openapi.actionSystem.DataConstants;
import com.intellij.openapi.actionSystem.DataContext;
+import com.intellij.openapi.actionSystem.PlatformDataKeys;
import com.intellij.openapi.vfs.VirtualFile;
public final class FileExtMacro extends Macro {
}
public String expand(DataContext dataContext) {
- VirtualFile file = (VirtualFile)dataContext.getData(DataConstants.VIRTUAL_FILE);
- if (file == null ) return null;
+ VirtualFile file = PlatformDataKeys.VIRTUAL_FILE.getData(dataContext);
+ if (file == null) {
+ return null;
+ }
return file.getExtension();
}
}
package com.intellij.ide.macro;
import com.intellij.ide.IdeBundle;
-import com.intellij.openapi.actionSystem.DataConstants;
import com.intellij.openapi.actionSystem.DataContext;
+import com.intellij.openapi.actionSystem.PlatformDataKeys;
import com.intellij.openapi.vfs.VirtualFile;
}
public String expand(DataContext dataContext) {
- VirtualFile file = (VirtualFile)dataContext.getData(DataConstants.VIRTUAL_FILE);
- if (file == null) return null;
+ VirtualFile file = PlatformDataKeys.VIRTUAL_FILE.getData(dataContext);
+ if (file == null) {
+ return null;
+ }
return file.getNameWithoutExtension();
}
}
\ No newline at end of file
package com.intellij.ide.macro;
import com.intellij.ide.IdeBundle;
-import com.intellij.openapi.actionSystem.DataConstants;
import com.intellij.openapi.actionSystem.DataContext;
import com.intellij.openapi.actionSystem.PlatformDataKeys;
import com.intellij.openapi.project.Project;
public String expand(final DataContext dataContext) {
final Project project = PlatformDataKeys.PROJECT.getData(dataContext);
- if (project == null) return null;
- VirtualFile file = (VirtualFile)dataContext.getData(DataConstants.VIRTUAL_FILE);
- if (file == null) return null;
+ if (project == null) {
+ return null;
+ }
+ VirtualFile file = PlatformDataKeys.VIRTUAL_FILE.getData(dataContext);
+ if (file == null) {
+ return null;
+ }
final VirtualFile contentRoot = ProjectRootManager.getInstance(project).getFileIndex().getContentRootForFile(file);
- if (contentRoot == null) return null;
+ if (contentRoot == null) {
+ return null;
+ }
return FileUtil.getRelativePath(getIOFile(contentRoot), getIOFile(file));
}
}
package com.intellij.ide.macro;
import com.intellij.ide.IdeBundle;
-import com.intellij.openapi.actionSystem.DataConstants;
import com.intellij.openapi.actionSystem.DataContext;
import com.intellij.openapi.actionSystem.PlatformDataKeys;
import com.intellij.openapi.project.Project;
public String expand(final DataContext dataContext) {
final Project project = PlatformDataKeys.PROJECT.getData(dataContext);
- if (project == null) return null;
- VirtualFile file = (VirtualFile)dataContext.getData(DataConstants.VIRTUAL_FILE);
- if (file == null) return null;
+ if (project == null) {
+ return null;
+ }
+ VirtualFile file = PlatformDataKeys.VIRTUAL_FILE.getData(dataContext);
+ if (file == null) {
+ return null;
+ }
final VirtualFile sourceRoot = ProjectRootManager.getInstance(project).getFileIndex().getSourceRootForFile(file);
- if (sourceRoot == null) return null;
+ if (sourceRoot == null) {
+ return null;
+ }
return FileUtil.getRelativePath(getIOFile(sourceRoot), getIOFile(file));
}
}
package com.intellij.ide.macro;
-import com.intellij.ide.DataAccessors;
import com.intellij.ide.IdeBundle;
import com.intellij.openapi.actionSystem.DataContext;
+import com.intellij.openapi.actionSystem.PlatformDataKeys;
+import com.intellij.openapi.project.Project;
import com.intellij.openapi.util.io.FileUtil;
import com.intellij.openapi.vfs.VfsUtil;
import com.intellij.openapi.vfs.VirtualFile;
}
public String expand(DataContext dataContext) {
- final VirtualFile baseDir = DataAccessors.PROJECT_BASE_DIR.from(dataContext);
+ Project project = PlatformDataKeys.PROJECT.getData(dataContext);
+ final VirtualFile baseDir = project == null ? null : project.getBaseDir();
if (baseDir == null) {
return null;
}
- VirtualFile file = DataAccessors.VIRTUAL_FILE.from(dataContext);
+ VirtualFile file = PlatformDataKeys.VIRTUAL_FILE.getData(dataContext);
if (file == null) return null;
return FileUtil.getRelativePath(VfsUtil.virtualToIoFile(baseDir), VfsUtil.virtualToIoFile(file));
}
import com.intellij.ide.DataManager;
import com.intellij.ide.IdeEventQueue;
import com.intellij.ide.impl.DataManagerImpl;
-import com.intellij.openapi.actionSystem.DataConstants;
import com.intellij.openapi.actionSystem.DataContext;
import com.intellij.openapi.actionSystem.PlatformDataKeys;
import com.intellij.openapi.components.ServiceManager;
registerMacro(new JdkPathMacro());
registerMacro(new PromptMacro());
registerMacro(new SourcepathEntryMacro());
- //registerMacro(new ProjectFilePathMacro());
registerMacro(new ProjectFileDirMacro());
registerMacro(new ProjectNameMacro());
registerMacro(new ProjectPathMacro());
}
private static DataContext getCorrectContext(DataContext dataContext) {
- if (dataContext.getData(DataConstants.FILE_EDITOR) != null) return dataContext;
+ if (PlatformDataKeys.FILE_EDITOR.getData(dataContext) != null) {
+ return dataContext;
+ }
Project project = PlatformDataKeys.PROJECT.getData(dataContext);
- if (project == null) return dataContext;
+ if (project == null) {
+ return dataContext;
+ }
FileEditorManager editorManager = FileEditorManager.getInstance(project);
VirtualFile[] files = editorManager.getSelectedFiles();
- if (files.length == 0) return dataContext;
+ if (files.length == 0) {
+ return dataContext;
+ }
FileEditor fileEditor = editorManager.getSelectedEditor(files[0]);
- return fileEditor == null ? dataContext :
- DataManager.getInstance().getDataContext(fileEditor.getComponent());
+ return fileEditor == null ? dataContext : DataManager.getInstance().getDataContext(fileEditor.getComponent());
}
/**
package com.intellij.ide.macro;
-import com.intellij.ide.DataAccessors;
import com.intellij.ide.IdeBundle;
import com.intellij.openapi.actionSystem.DataContext;
+import com.intellij.openapi.actionSystem.LangDataKeys;
import com.intellij.openapi.module.Module;
import com.intellij.openapi.roots.ProjectRootsTraversing;
}
public String expand(DataContext dataContext) {
- final Module module = DataAccessors.MODULE.from(dataContext);
+ final Module module = LangDataKeys.MODULE.getData(dataContext);
if (module == null) {
return null;
}
+++ /dev/null
-/*
- * 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.ide.macro;
-
-import com.intellij.ide.DataAccessors;
-import com.intellij.ide.IdeBundle;
-import com.intellij.openapi.actionSystem.DataContext;
-
-public final class ProjectFilePathMacro extends Macro {
- public String getName() {
- return "ProjectFilePath";
- }
-
- public String getDescription() {
- return IdeBundle.message("macro.project.file.path");
- }
-
- public String expand(DataContext dataContext) {
- return DataAccessors.PROJECT_FILE_PATH.from(dataContext);
- }
-}
\ No newline at end of file
package com.intellij.ide.macro;
import com.intellij.ide.IdeBundle;
-import com.intellij.openapi.actionSystem.DataConstants;
import com.intellij.openapi.actionSystem.DataContext;
import com.intellij.openapi.actionSystem.PlatformDataKeys;
import com.intellij.openapi.project.Project;
public String expand(final DataContext dataContext) {
final Project project = PlatformDataKeys.PROJECT.getData(dataContext);
- if (project == null) return null;
- VirtualFile file = (VirtualFile)dataContext.getData(DataConstants.VIRTUAL_FILE);
- if (file == null) return null;
+ if (project == null) {
+ return null;
+ }
+ VirtualFile file = PlatformDataKeys.VIRTUAL_FILE.getData(dataContext);
+ if (file == null) {
+ return null;
+ }
final VirtualFile sourceRoot = ProjectRootManager.getInstance(project).getFileIndex().getSourceRootForFile(file);
- if (sourceRoot == null) return null;
+ if (sourceRoot == null) {
+ return null;
+ }
return getPath(sourceRoot);
}
-}
\ No newline at end of file
+}
private void updateModel() {
DataContext context = DataManager.getInstance().getDataContext();
- if (context.getData(DataConstants.IDE_VIEW) == myIdeView || context.getData(DataConstants.PROJECT) != myProject || isNodePopupShowing()) {
+ if (LangDataKeys.IDE_VIEW.getData(context) == myIdeView || PlatformDataKeys.PROJECT.getData(context) != myProject || isNodePopupShowing()) {
scheduleModelUpdate();
return;
}
@Nullable
public Object getData(String dataId) {
- if (dataId.equals(DataConstants.PROJECT)) {
+ if (PlatformDataKeys.PROJECT.is(dataId)) {
return !myProject.isDisposed() ? myProject : null;
}
- if (dataId.equals(DataConstants.MODULE)) {
+ if (LangDataKeys.MODULE.is(dataId)) {
final Module module = getSelectedElement(Module.class);
if (module != null && !module.isDisposed()) return module;
final PsiElement element = getSelectedElement(PsiElement.class);
}
return null;
}
- if (dataId.equals(DataConstants.MODULE_CONTEXT)) {
+ if (LangDataKeys.MODULE_CONTEXT.is(dataId)) {
final PsiDirectory directory = getSelectedElement(PsiDirectory.class);
if (directory != null) {
final VirtualFile dir = directory.getVirtualFile();
}
return null;
}
- if (dataId.equals(DataConstants.PSI_ELEMENT)) {
+ if (LangDataKeys.PSI_ELEMENT.is(dataId)) {
final PsiElement element = getSelectedElement(PsiElement.class);
return element != null && element.isValid() ? element : null;
}
- if (dataId.equals(DataConstants.PSI_ELEMENT_ARRAY)) {
+ if (LangDataKeys.PSI_ELEMENT_ARRAY.is(dataId)) {
final PsiElement element = getSelectedElement(PsiElement.class);
return element != null && element.isValid() ? new PsiElement[]{element} : null;
}
- if (dataId.equals(DataConstants.VIRTUAL_FILE_ARRAY)) {
- PsiElement[] psiElements = (PsiElement[])getData(DataConstants.PSI_ELEMENT_ARRAY);
+ if (PlatformDataKeys.VIRTUAL_FILE_ARRAY.is(dataId)) {
+ PsiElement[] psiElements = (PsiElement[])getData(LangDataKeys.PSI_ELEMENT_ARRAY.getName());
if (psiElements == null) return null;
Set<VirtualFile> files = new LinkedHashSet<VirtualFile>();
for (PsiElement element : psiElements) {
return files.size() > 0 ? VfsUtil.toVirtualFileArray(files) : null;
}
- if (dataId.equals(DataConstants.CONTEXT_COMPONENT)) {
+ if (PlatformDataKeys.CONTEXT_COMPONENT.is(dataId)) {
return this;
}
- if (DataConstants.CUT_PROVIDER.equals(dataId)) {
+ if (PlatformDataKeys.CUT_PROVIDER.is(dataId)) {
return myCopyPasteDelegator.getCutProvider();
}
- if (DataConstants.COPY_PROVIDER.equals(dataId)) {
+ if (PlatformDataKeys.COPY_PROVIDER.is(dataId)) {
return myCopyPasteDelegator.getCopyProvider();
}
- if (DataConstants.PASTE_PROVIDER.equals(dataId)) {
+ if (PlatformDataKeys.PASTE_PROVIDER.is(dataId)) {
return myCopyPasteDelegator.getPasteProvider();
}
- if (DataConstants.DELETE_ELEMENT_PROVIDER.equals(dataId)) {
+ if (PlatformDataKeys.DELETE_ELEMENT_PROVIDER.is(dataId)) {
return getSelectedElement(Module.class) != null ? myDeleteModuleProvider : new DeleteHandler.DefaultDeleteProvider();
}
- if (DataConstants.IDE_VIEW.equals(dataId)) {
+ if (LangDataKeys.IDE_VIEW.is(dataId)) {
return myIdeView;
}
import com.intellij.ide.IdeBundle;
import com.intellij.openapi.actionSystem.AnAction;
import com.intellij.openapi.actionSystem.AnActionEvent;
-import com.intellij.openapi.actionSystem.DataConstants;
import com.intellij.openapi.actionSystem.DataContext;
+import com.intellij.openapi.actionSystem.LangDataKeys;
import com.intellij.openapi.module.Module;
public class MoveModulesOutsideGroupAction extends AnAction {
public void actionPerformed(AnActionEvent e) {
final DataContext dataContext = e.getDataContext();
- final Module[] modules = (Module[])dataContext.getData(DataConstants.MODULE_CONTEXT_ARRAY);
+ final Module[] modules = LangDataKeys.MODULE_CONTEXT_ARRAY.getData(dataContext);
MoveModulesToGroupAction.doMove(modules, null, dataContext);
}
}
\ No newline at end of file
import com.intellij.ide.projectView.impl.AbstractProjectViewPane;
import com.intellij.ide.projectView.impl.ModuleGroup;
import com.intellij.openapi.actionSystem.*;
-import com.intellij.openapi.actionSystem.ex.DataConstantsEx;
import com.intellij.openapi.module.ModifiableModuleModel;
import com.intellij.openapi.module.Module;
import com.intellij.openapi.module.impl.ModuleManagerImpl;
public void update(AnActionEvent e) {
Presentation presentation = getTemplatePresentation();
final DataContext dataContext = e.getDataContext();
- final Module[] modules = (Module[])dataContext.getData(DataConstants.MODULE_CONTEXT_ARRAY);
+ final Module[] modules = LangDataKeys.MODULE_CONTEXT_ARRAY.getData(dataContext);
String description = IdeBundle.message("message.move.modules.to.group", whatToMove(modules), myModuleGroup.presentableText());
presentation.setDescription(description);
public void actionPerformed(AnActionEvent e) {
final DataContext dataContext = e.getDataContext();
- final Module[] modules = (Module[])dataContext.getData(DataConstants.MODULE_CONTEXT_ARRAY);
+ final Module[] modules = LangDataKeys.MODULE_CONTEXT_ARRAY.getData(dataContext);
doMove(modules, myModuleGroup, dataContext);
}
Project project = modules[0].getProject();
for (final Module module : modules) {
ModifiableModuleModel model = dataContext != null
- ? (ModifiableModuleModel)dataContext.getData(DataConstantsEx.MODIFIABLE_MODULE_MODEL)
+ ? LangDataKeys.MODIFIABLE_MODULE_MODEL.getData(dataContext)
: null;
if (model != null){
model.setModuleGroupPath(module, group == null ? null : group.getGroupPath());
}
}
}
-}
\ No newline at end of file
+}
import com.intellij.ide.IdeBundle;
import com.intellij.ide.projectView.impl.ModuleGroup;
import com.intellij.openapi.actionSystem.AnActionEvent;
-import com.intellij.openapi.actionSystem.DataConstants;
import com.intellij.openapi.actionSystem.DataContext;
+import com.intellij.openapi.actionSystem.LangDataKeys;
import com.intellij.openapi.actionSystem.Presentation;
import com.intellij.openapi.module.Module;
import com.intellij.openapi.ui.Messages;
public void actionPerformed(AnActionEvent e) {
final DataContext dataContext = e.getDataContext();
- final Module[] modules = (Module[])dataContext.getData(DataConstants.MODULE_CONTEXT_ARRAY);
+ final Module[] modules = LangDataKeys.MODULE_CONTEXT_ARRAY.getData(dataContext);
final String[] newGroup;
if (myModuleGroup != null) {
String message = IdeBundle.message("prompt.specify.name.of.module.subgroup", myModuleGroup.presentableText(), whatToMove(modules));
doMove(modules, new ModuleGroup(newGroup), dataContext);
}
-}
\ No newline at end of file
+}
import com.intellij.ide.projectView.impl.nodes.ModuleGroupNode;
import com.intellij.ide.util.treeView.*;
import com.intellij.openapi.Disposable;
-import com.intellij.openapi.actionSystem.DataConstants;
import com.intellij.openapi.actionSystem.DataContext;
import com.intellij.openapi.actionSystem.DataProvider;
import com.intellij.openapi.actionSystem.DefaultActionGroup;
+import com.intellij.openapi.actionSystem.PlatformDataKeys;
import com.intellij.openapi.application.ApplicationManager;
import com.intellij.openapi.diagnostic.Logger;
import com.intellij.openapi.extensions.ExtensionPointName;
}
public Object getData(String dataId) {
- if (DataConstants.NAVIGATABLE_ARRAY.equals(dataId)) {
+ if (PlatformDataKeys.NAVIGATABLE_ARRAY.is(dataId)) {
TreePath[] paths = getSelectionPaths();
if (paths == null) return null;
final ArrayList<Navigatable> navigatables = new ArrayList<Navigatable>();
public void dragGestureRecognized(DragGestureEvent dge) {
if ((dge.getDragAction() & DnDConstants.ACTION_COPY_OR_MOVE) == 0) return;
DataContext dataContext = DataManager.getInstance().getDataContext();
- ProjectView projectView = (ProjectView)dataContext.getData(ProjectViewImpl.PROJECT_VIEW_DATA_CONSTANT);
+ ProjectView projectView = ProjectViewImpl.DATA_KEY.getData(dataContext);
if (projectView == null) return;
final AbstractProjectViewPane currentPane = projectView.getCurrentProjectViewPane();
*/
package com.intellij.ide.projectView.impl;
-import com.intellij.openapi.actionSystem.DataConstants;
import com.intellij.openapi.actionSystem.DataContext;
-import com.intellij.openapi.actionSystem.ex.DataConstantsEx;
+import com.intellij.openapi.actionSystem.DataKey;
+import com.intellij.openapi.actionSystem.LangDataKeys;
+import com.intellij.openapi.actionSystem.PlatformDataKeys;
import com.intellij.openapi.module.ModifiableModuleModel;
import com.intellij.openapi.module.Module;
import com.intellij.openapi.module.ModuleManager;
import java.util.*;
public class ModuleGroup {
+ public static final DataKey<ModuleGroup[]> ARRAY_DATA_KEY = DataKey.create("moduleGroup.array");
+
private final String[] myGroupPath;
public ModuleGroup(@NotNull String[] groupPath) {
}
public Collection<ModuleGroup> childGroups(DataContext dataContext) {
- return childGroups((ModifiableModuleModel)dataContext.getData(DataConstantsEx.MODIFIABLE_MODULE_MODEL),
- (Project)dataContext.getData(DataConstants.PROJECT));
+ return childGroups(LangDataKeys.MODIFIABLE_MODULE_MODEL.getData(dataContext), PlatformDataKeys.PROJECT.getData(dataContext));
}
public Collection<ModuleGroup> childGroups(ModifiableModuleModel model, Project project) {
import com.intellij.ide.DataManager;
import com.intellij.ide.projectView.impl.nodes.DropTargetNode;
import com.intellij.openapi.actionSystem.DataContext;
-import com.intellij.openapi.actionSystem.ex.DataConstantsEx;
+import com.intellij.openapi.actionSystem.LangDataKeys;
import com.intellij.openapi.project.Project;
import com.intellij.openapi.vfs.LocalFileSystem;
import com.intellij.openapi.vfs.VirtualFile;
getActionHandler(dataContext).invoke(myProject, sourceElements, new DataContext() {
@Nullable
public Object getData(@NonNls String dataId) {
- if (dataId.equals(DataConstantsEx.TARGET_PSI_ELEMENT)) {
+ if (LangDataKeys.TARGET_PSI_ELEMENT.is(dataId)) {
return targetElement;
}
else {
}
private RefactoringActionHandler getActionHandler(final DataContext dataContext) {
- final MoveAction.MoveProvider moveProvider = (MoveAction.MoveProvider)dataContext.getData(MoveAction.MOVE_PROVIDER);
+ final MoveAction.MoveProvider moveProvider = MoveAction.MoveProvider.DATA_KEY.getData(dataContext);
if (moveProvider != null) {
return moveProvider.getHandler(dataContext);
}
import com.intellij.openapi.actionSystem.*;
import com.intellij.openapi.module.Module;
import com.intellij.openapi.project.Project;
+import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
import java.util.ArrayList;
public void update(AnActionEvent e){
final DataContext dataContext = e.getDataContext();
- final Project project = (Project)dataContext.getData(DataConstants.PROJECT);
- final Module[] modules = (Module[])dataContext.getData(DataConstants.MODULE_CONTEXT_ARRAY);
+ final Project project = PlatformDataKeys.PROJECT.getData(dataContext);
+ final Module[] modules = LangDataKeys.MODULE_CONTEXT_ARRAY.getData(dataContext);
boolean active = project != null && modules != null && modules.length != 0;
final Presentation presentation = e.getPresentation();
presentation.setVisible(active);
presentation.setText(myModuleGroup.presentableText());
}
+ @NotNull
public AnAction[] getChildren(@Nullable AnActionEvent e) {
- if (e == null) return AnAction.EMPTY_ARRAY;
+ if (e == null) return EMPTY_ARRAY;
List<ModuleGroup> children = new ArrayList<ModuleGroup>(myModuleGroup.childGroups(e.getDataContext()));
Collections.sort ( children, new Comparator<ModuleGroup>() {
import com.intellij.ide.projectView.actions.MoveModulesOutsideGroupAction;
import com.intellij.ide.projectView.actions.MoveModulesToSubGroupAction;
import com.intellij.openapi.actionSystem.*;
-import com.intellij.openapi.actionSystem.ex.DataConstantsEx;
import com.intellij.openapi.module.ModifiableModuleModel;
import com.intellij.openapi.module.Module;
import com.intellij.openapi.module.ModuleManager;
import com.intellij.openapi.project.Project;
+import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
import java.util.*;
public class MoveModuleToGroupTopLevel extends ActionGroup {
public void update(AnActionEvent e){
final DataContext dataContext = e.getDataContext();
- final Project project = (Project)dataContext.getData(DataConstants.PROJECT);
- final Module[] modules = (Module[])dataContext.getData(DataConstants.MODULE_CONTEXT_ARRAY);
+ final Project project = PlatformDataKeys.PROJECT.getData(dataContext);
+ final Module[] modules = LangDataKeys.MODULE_CONTEXT_ARRAY.getData(dataContext);
boolean active = project != null && modules != null && modules.length != 0;
e.getPresentation().setVisible(active);
}
+ @NotNull
public AnAction[] getChildren(@Nullable AnActionEvent e) {
- if (e == null) return AnAction.EMPTY_ARRAY;
+ if (e == null) {
+ return EMPTY_ARRAY;
+ }
List<String> topLevelGroupNames = new ArrayList<String> (getTopLevelGroupNames(e.getDataContext()));
Collections.sort ( topLevelGroupNames );
}
private static Collection<String> getTopLevelGroupNames(final DataContext dataContext) {
- final Project project = (Project)dataContext.getData(DataConstants.PROJECT);
+ final Project project =PlatformDataKeys.PROJECT.getData(dataContext);
- final ModifiableModuleModel model = (ModifiableModuleModel)dataContext.getData(DataConstantsEx.MODIFIABLE_MODULE_MODEL);
+ final ModifiableModuleModel model = LangDataKeys.MODIFIABLE_MODULE_MODEL.getData(dataContext);
Module[] allModules;
if ( model != null ) {
}
return topLevelGroupNames;
}
-}
\ No newline at end of file
+}
import com.intellij.ide.util.treeView.NodeDescriptor;
import com.intellij.openapi.Disposable;
import com.intellij.openapi.actionSystem.*;
-import com.intellij.openapi.actionSystem.ex.DataConstantsEx;
import com.intellij.openapi.application.ApplicationManager;
import com.intellij.openapi.application.ModalityState;
import com.intellij.openapi.application.ex.ApplicationInfoEx;
private final Map<String, AbstractProjectViewPane> myId2Pane = new LinkedHashMap<String, AbstractProjectViewPane>();
private final Collection<AbstractProjectViewPane> myUninitializedPanes = new THashSet<AbstractProjectViewPane>();
- static final String PROJECT_VIEW_DATA_CONSTANT = "com.intellij.ide.projectView.impl.ProjectViewImpl";
+ static final DataKey<ProjectViewImpl> DATA_KEY = DataKey.create("com.intellij.ide.projectView.impl.ProjectViewImpl");
+ @Deprecated static final String PROJECT_VIEW_DATA_CONSTANT = DATA_KEY.getName();
+
private DefaultActionGroup myActionGroup;
private final Runnable myTreeChangeListener;
private String mySavedPaneId = ProjectViewPane.ID;
}
}
if (title == null) {
- final PsiElement element = (PsiElement)myDataProvider.getData(DataConstants.PSI_ELEMENT);
+ final PsiElement element = (PsiElement)myDataProvider.getData(LangDataKeys.PSI_ELEMENT.getName());
if (element != null) {
PsiFile file = element.getContainingFile();
if (file != null) {
if (paneSpecificData != null) return paneSpecificData;
}
- if (DataConstants.PSI_ELEMENT.equals(dataId)) {
+ if (LangDataKeys.PSI_ELEMENT.is(dataId)) {
if (currentProjectViewPane == null) return null;
final PsiElement[] elements = currentProjectViewPane.getSelectedPSIElements();
return elements.length == 1 ? elements[0] : null;
}
- if (DataConstants.PSI_ELEMENT_ARRAY.equals(dataId)) {
+ if (LangDataKeys.PSI_ELEMENT_ARRAY.is(dataId)) {
if (currentProjectViewPane == null) {
return null;
}
PsiElement[] elements = currentProjectViewPane.getSelectedPSIElements();
return elements.length == 0 ? null : elements;
}
- if (DataConstants.VIRTUAL_FILE_ARRAY.equals(dataId)) {
- PsiElement[] psiElements = (PsiElement[])getData(DataConstants.PSI_ELEMENT_ARRAY);
+ if (PlatformDataKeys.VIRTUAL_FILE_ARRAY.is(dataId)) {
+ PsiElement[] psiElements = (PsiElement[])getData(LangDataKeys.PSI_ELEMENT_ARRAY.getName());
if (psiElements == null) return null;
Set<VirtualFile> files = new LinkedHashSet<VirtualFile>();
for (PsiElement element : psiElements) {
}
return files.size() > 0 ? VfsUtil.toVirtualFileArray(files) : null;
}
- if (DataConstantsEx.TARGET_PSI_ELEMENT.equals(dataId)) {
+ if (LangDataKeys.TARGET_PSI_ELEMENT.is(dataId)) {
return null;
}
- if (DataConstants.CUT_PROVIDER.equals(dataId)) {
+ if (PlatformDataKeys.CUT_PROVIDER.is(dataId)) {
return myCopyPasteDelegator.getCutProvider();
}
- if (DataConstants.COPY_PROVIDER.equals(dataId)) {
+ if (PlatformDataKeys.COPY_PROVIDER.is(dataId)) {
return myCopyPasteDelegator.getCopyProvider();
}
- if (DataConstants.PASTE_PROVIDER.equals(dataId)) {
+ if (PlatformDataKeys.PASTE_PROVIDER.is(dataId)) {
return myCopyPasteDelegator.getPasteProvider();
}
- if (DataConstants.IDE_VIEW.equals(dataId)) {
+ if (LangDataKeys.IDE_VIEW.is(dataId)) {
return myIdeView;
}
- if (DataConstants.DELETE_ELEMENT_PROVIDER.equals(dataId)) {
+ if (PlatformDataKeys.DELETE_ELEMENT_PROVIDER.is(dataId)) {
final List<Module> modules = getSelectedElements(Module.class);
if (!modules.isEmpty()) {
return myDeleteModuleProvider;
}
return myDeletePSIElementProvider;
}
- if (DataConstants.HELP_ID.equals(dataId)) {
+ if (PlatformDataKeys.HELP_ID.is(dataId)) {
return HelpID.PROJECT_VIEWS;
}
- if (PROJECT_VIEW_DATA_CONSTANT.equals(dataId)) {
+ if (ProjectViewImpl.DATA_KEY.is(dataId)) {
return ProjectViewImpl.this;
}
- if (DataConstants.PROJECT_CONTEXT.equals(dataId)) {
+ if (PlatformDataKeys.PROJECT_CONTEXT.is(dataId)) {
Object selected = getSelectedNodeElement();
return selected instanceof Project ? selected : null;
}
- if (DataConstants.MODULE_CONTEXT.equals(dataId)) {
+ if (LangDataKeys.MODULE_CONTEXT.is(dataId)) {
Object selected = getSelectedNodeElement();
if (selected instanceof Module) {
return !((Module)selected).isDisposed() ? selected : null;
}
}
- if (DataConstants.MODULE_CONTEXT_ARRAY.equals(dataId)) {
+ if (LangDataKeys.MODULE_CONTEXT_ARRAY.is(dataId)) {
return getSelectedModules();
}
- if (DataConstantsEx.MODULE_GROUP_ARRAY.equals(dataId)) {
+ if (ModuleGroup.ARRAY_DATA_KEY.is(dataId)) {
final List<ModuleGroup> selectedElements = getSelectedElements(ModuleGroup.class);
return selectedElements.isEmpty() ? null : selectedElements.toArray(new ModuleGroup[selectedElements.size()]);
}
- if (DataConstantsEx.LIBRARY_GROUP_ARRAY.equals(dataId)) {
+ if (LibraryGroupElement.ARRAY_DATA_KEY.is(dataId)) {
final List<LibraryGroupElement> selectedElements = getSelectedElements(LibraryGroupElement.class);
return selectedElements.isEmpty() ? null : selectedElements.toArray(new LibraryGroupElement[selectedElements.size()]);
}
- if (DataConstantsEx.NAMED_LIBRARY_ARRAY.equals(dataId)) {
+ if (NamedLibraryElement.ARRAY_DATA_KEY.is(dataId)) {
final List<NamedLibraryElement> selectedElements = getSelectedElements(NamedLibraryElement.class);
return selectedElements.isEmpty() ? null : selectedElements.toArray(new NamedLibraryElement[selectedElements.size()]);
}
package com.intellij.ide.projectView.impl.nodes;
+import com.intellij.openapi.actionSystem.DataKey;
import com.intellij.openapi.module.Module;
/**
* Time: 7:08:03 PM
*/
public final class LibraryGroupElement {
+ public static final DataKey<LibraryGroupElement[]> ARRAY_DATA_KEY = DataKey.create("libraryGroup.array");
+
private final Module myModule;
public LibraryGroupElement(Module module) {
package com.intellij.ide.projectView.impl.nodes;
+import com.intellij.openapi.actionSystem.DataKey;
import com.intellij.openapi.module.Module;
import com.intellij.openapi.roots.OrderEntry;
import com.intellij.openapi.util.Comparing;
* Time: 7:08:30 PM
*/
public final class NamedLibraryElement {
+ public static final DataKey<NamedLibraryElement[]> ARRAY_DATA_KEY = DataKey.create("namedLibrary.array");
+
private final Module myContextModule;
private final OrderEntry myEntry;
import com.intellij.ide.util.DirectoryChooserUtil;
import com.intellij.ide.util.EditorHelper;
import com.intellij.openapi.Disposable;
-import com.intellij.openapi.actionSystem.DataConstants;
import com.intellij.openapi.actionSystem.DataContext;
+import com.intellij.openapi.actionSystem.LangDataKeys;
+import com.intellij.openapi.actionSystem.PlatformDataKeys;
import com.intellij.openapi.diagnostic.Logger;
import com.intellij.openapi.editor.Editor;
import com.intellij.openapi.editor.colors.CodeInsightColors;