List of usage examples for com.intellij.openapi.actionSystem PlatformDataKeys COPY_PROVIDER
DataKey COPY_PROVIDER
To view the source code for com.intellij.openapi.actionSystem PlatformDataKeys COPY_PROVIDER.
Click Source Link
From source file:com.android.tools.idea.uibuilder.palette.NlOldPalettePanel.java
License:Apache License
@Override public Object getData(@NonNls String dataId) { if (PlatformDataKeys.DELETE_ELEMENT_PROVIDER.is(dataId) || PlatformDataKeys.CUT_PROVIDER.is(dataId) || PlatformDataKeys.COPY_PROVIDER.is(dataId) || PlatformDataKeys.PASTE_PROVIDER.is(dataId)) { return new ActionHandler(); }/*w w w.ja va 2s .c o m*/ return null; }
From source file:com.android.tools.idea.uibuilder.palette.NlPalettePanel.java
License:Apache License
@Nullable @Override public Object getData(@NonNls String dataId) { return PlatformDataKeys.COPY_PROVIDER.is(dataId) ? myCopyProvider : null; }
From source file:com.android.tools.idea.uibuilder.palette.NlPalettePanelTest.java
License:Apache License
public void testCopyIsUnavailableWhenNothingIsSelected() throws Exception { DataContext context = mock(DataContext.class); CopyProvider provider = (CopyProvider) myPanel.getData(PlatformDataKeys.COPY_PROVIDER.getName()); assertThat(provider).isNotNull();/* w w w . ja v a2s .c o m*/ assertThat(provider.isCopyVisible(context)).isTrue(); assertThat(provider.isCopyEnabled(context)).isFalse(); }
From source file:com.android.tools.idea.uibuilder.palette.NlPalettePanelTest.java
License:Apache License
public void testCopy() throws Exception { myPanel.requestFocus();/*from ww w . ja v a2 s .c o m*/ DataContext context = mock(DataContext.class); CopyProvider provider = (CopyProvider) myPanel.getData(PlatformDataKeys.COPY_PROVIDER.getName()); assertThat(provider).isNotNull(); assertThat(provider.isCopyVisible(context)).isTrue(); assertThat(provider.isCopyEnabled(context)).isTrue(); provider.performCopy(context); ArgumentCaptor<Transferable> captor = ArgumentCaptor.forClass(Transferable.class); verify(myCopyPasteManager).setContents(captor.capture()); Transferable transferable = captor.getValue(); assertThat(transferable).isNotNull(); assertThat(transferable.isDataFlavorSupported(ItemTransferable.DESIGNER_FLAVOR)).isTrue(); Object item = transferable.getTransferData(ItemTransferable.DESIGNER_FLAVOR); assertThat(item).isInstanceOf(DnDTransferItem.class); DnDTransferItem dndItem = (DnDTransferItem) item; assertThat(dndItem.getComponents().size()).isEqualTo(1); DnDTransferComponent component = dndItem.getComponents().get(0); assertThat(component.getRepresentation()).startsWith(("<TextView")); }
From source file:com.android.tools.idea.uibuilder.property.NlPropertiesPanel.java
License:Apache License
@Override public Object getData(@NonNls String dataId) { if (PlatformDataKeys.DELETE_ELEMENT_PROVIDER.is(dataId) || PlatformDataKeys.CUT_PROVIDER.is(dataId) || PlatformDataKeys.COPY_PROVIDER.is(dataId) || PlatformDataKeys.PASTE_PROVIDER.is(dataId)) { return this; }/*ww w. j av a2s . c om*/ return null; }
From source file:com.android.tools.idea.uibuilder.surface.DesignSurface.java
License:Apache License
@Override public Object getData(@NonNls String dataId) { if (PlatformDataKeys.FILE_EDITOR.is(dataId)) { return myFileEditorDelegate.get(); } else if (PlatformDataKeys.DELETE_ELEMENT_PROVIDER.is(dataId) || PlatformDataKeys.CUT_PROVIDER.is(dataId) || PlatformDataKeys.COPY_PROVIDER.is(dataId) || PlatformDataKeys.PASTE_PROVIDER.is(dataId)) { return new DesignSurfaceActionHandler(this); }//w w w.j a v a 2 s.co m return null; }
From source file:com.intellij.execution.testframework.TestTreeView.java
License:Apache License
public Object getData(final String dataId) { if (PlatformDataKeys.COPY_PROVIDER.is(dataId)) { return this; }/*from w w w.j a v a2 s .c o m*/ if (LangDataKeys.PSI_ELEMENT_ARRAY.is(dataId)) { TreePath[] paths = getSelectionPaths(); if (paths != null && paths.length > 1) { final List<PsiElement> els = new ArrayList<PsiElement>(paths.length); for (TreePath path : paths) { AbstractTestProxy test = getSelectedTest(path); if (test != null) { final PsiElement psiElement = (PsiElement) TestsUIUtil.getData(test, LangDataKeys.PSI_ELEMENT.getName(), myModel); if (psiElement != null) { els.add(psiElement); } } } return els.isEmpty() ? null : els.toArray(new PsiElement[els.size()]); } } final TreePath selectionPath = getSelectionPath(); if (selectionPath == null) return null; final AbstractTestProxy testProxy = getSelectedTest(selectionPath); if (testProxy == null) return null; return TestsUIUtil.getData(testProxy, dataId, myModel); }
From source file:com.intellij.ide.actions.CopyAction.java
License:Apache License
public void actionPerformed(AnActionEvent e) { DataContext dataContext = e.getDataContext(); CopyProvider provider = PlatformDataKeys.COPY_PROVIDER.getData(dataContext); if (provider == null) { return;/*ww w . j av a2 s . com*/ } provider.performCopy(dataContext); }
From source file:com.intellij.ide.actions.CopyAction.java
License:Apache License
public void update(AnActionEvent event) { Presentation presentation = event.getPresentation(); DataContext dataContext = event.getDataContext(); CopyProvider provider = PlatformDataKeys.COPY_PROVIDER.getData(dataContext); presentation.setEnabled(provider != null && provider.isCopyEnabled(dataContext)); if (event.getPlace().equals(ActionPlaces.EDITOR_POPUP) && provider != null) { presentation.setVisible(provider.isCopyVisible(dataContext)); } else {//from w ww. j a v a2 s .com presentation.setVisible(true); } }
From source file:com.intellij.ide.actions.SearchWebAction.java
License:Apache License
public void actionPerformed(AnActionEvent e) { DataContext dataContext = e.getDataContext(); CopyProvider provider = PlatformDataKeys.COPY_PROVIDER.getData(dataContext); if (provider == null) { return;//from w w w .ja v a 2s .co m } provider.performCopy(dataContext); Transferable contents = CopyPasteManager.getInstance().getContents(); String string; try { string = contents == null ? null : (String) contents.getTransferData(DataFlavor.stringFlavor); } catch (Exception ex) { return; } if (StringUtil.isNotEmpty(string)) { BrowserUtil.launchBrowser("http://www.google.com/search?q=" + URLEncoder.encode(string)); } }