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));
}
}
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"));
}
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);
}
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);
}
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);
}
}
Aggregations