Search in sources :

Example 1 with CopyProvider

use of com.intellij.ide.CopyProvider in project intellij-community by JetBrains.

the class SearchWebAction method actionPerformed.

public void actionPerformed(AnActionEvent e) {
    DataContext dataContext = e.getDataContext();
    CopyProvider provider = PlatformDataKeys.COPY_PROVIDER.getData(dataContext);
    if (provider == null) {
        return;
    }
    provider.performCopy(dataContext);
    String string = CopyPasteManager.getInstance().getContents(DataFlavor.stringFlavor);
    if (StringUtil.isNotEmpty(string)) {
        BrowserUtil.browse("http://www.google.com/search?q=" + URLEncoder.encode(string));
    }
}
Also used : CopyProvider(com.intellij.ide.CopyProvider)

Example 2 with CopyProvider

use of com.intellij.ide.CopyProvider in project android by JetBrains.

the class NlPalettePanelTest method testCopy.

public void testCopy() throws Exception {
    myPanel.requestFocus();
    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"));
}
Also used : DnDTransferComponent(com.android.tools.idea.uibuilder.model.DnDTransferComponent) DataContext(com.intellij.openapi.actionSystem.DataContext) CopyProvider(com.intellij.ide.CopyProvider) Transferable(java.awt.datatransfer.Transferable) ItemTransferable(com.android.tools.idea.uibuilder.model.ItemTransferable) DnDTransferItem(com.android.tools.idea.uibuilder.model.DnDTransferItem)

Example 3 with CopyProvider

use of com.intellij.ide.CopyProvider in project intellij-community by JetBrains.

the class SearchWebAction method update.

public void update(AnActionEvent event) {
    Presentation presentation = event.getPresentation();
    DataContext dataContext = event.getDataContext();
    CopyProvider provider = PlatformDataKeys.COPY_PROVIDER.getData(dataContext);
    boolean available = provider != null && provider.isCopyEnabled(dataContext) && provider.isCopyVisible(dataContext);
    presentation.setEnabled(available);
    presentation.setVisible(available);
}
Also used : CopyProvider(com.intellij.ide.CopyProvider)

Example 4 with CopyProvider

use of com.intellij.ide.CopyProvider in project intellij-community by JetBrains.

the class CopyAction method actionPerformed.

public void actionPerformed(AnActionEvent e) {
    DataContext dataContext = e.getDataContext();
    CopyProvider provider = PlatformDataKeys.COPY_PROVIDER.getData(dataContext);
    if (provider == null) {
        return;
    }
    provider.performCopy(dataContext);
}
Also used : CopyProvider(com.intellij.ide.CopyProvider)

Example 5 with CopyProvider

use of com.intellij.ide.CopyProvider in project intellij-community by JetBrains.

the class CopyAction method update.

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 {
        presentation.setVisible(true);
    }
}
Also used : CopyProvider(com.intellij.ide.CopyProvider)

Aggregations

CopyProvider (com.intellij.ide.CopyProvider)7 DataContext (com.intellij.openapi.actionSystem.DataContext)2 DnDTransferComponent (com.android.tools.idea.uibuilder.model.DnDTransferComponent)1 DnDTransferItem (com.android.tools.idea.uibuilder.model.DnDTransferItem)1 ItemTransferable (com.android.tools.idea.uibuilder.model.ItemTransferable)1 PsiElement2UsageTargetAdapter (com.intellij.find.findUsages.PsiElement2UsageTargetAdapter)1 DeleteProvider (com.intellij.ide.DeleteProvider)1 ContextHelpAction (com.intellij.ide.actions.ContextHelpAction)1 IProperty (com.intellij.lang.properties.IProperty)1 ResourceBundle (com.intellij.lang.properties.ResourceBundle)1 ResourceBundleEditorRenderer (com.intellij.lang.properties.editor.inspections.ResourceBundleEditorRenderer)1 ResourceBundleDeleteProvider (com.intellij.lang.properties.projectView.ResourceBundleDeleteProvider)1 PropertiesFile (com.intellij.lang.properties.psi.PropertiesFile)1 com.intellij.openapi.actionSystem (com.intellij.openapi.actionSystem)1 Logger (com.intellij.openapi.diagnostic.Logger)1 CopyPasteManager (com.intellij.openapi.ide.CopyPasteManager)1 Project (com.intellij.openapi.project.Project)1 StringUtil (com.intellij.openapi.util.text.StringUtil)1 PsiElement (com.intellij.psi.PsiElement)1 PsiFile (com.intellij.psi.PsiFile)1