com.intellij.ide.CopyProvider Java Examples

The following examples show how to use com.intellij.ide.CopyProvider. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: CopyRouteActionBase.java    From railways with MIT License 5 votes vote down vote up
@Override
public void actionPerformed(AnActionEvent anActionEvent) {
    DataContext ctx = anActionEvent.getDataContext();

    Route[] routes = (Route[])PlatformDataKeys.SELECTED_ITEMS.getData(ctx);

    CopyProvider provider = new RoutesCopyProvider(routes) {
        @Override
        public String getCopyValue(Route route) {
            return getRouteValue(route);
        }
    };

    provider.performCopy(ctx);
}
 
Example #2
Source File: SearchWebAction.java    From consulo with Apache License 2.0 5 votes vote down vote up
@RequiredUIAccess
@Override
public void actionPerformed(@Nonnull AnActionEvent e) {
  DataContext dataContext = e.getDataContext();
  CopyProvider provider = dataContext.getData(PlatformDataKeys.COPY_PROVIDER);
  if (provider == null) {
    return;
  }
  provider.performCopy(dataContext);
  String content = CopyPasteManager.getInstance().getContents(DataFlavor.stringFlavor);
  if (StringUtil.isNotEmpty(content)) {
    WebSearchEngine engine = myWebSearchOptions.getEngine();
    BrowserUtil.browse(BundleBase.format(engine.getUrlTemplate(), URLUtil.encodeURIComponent(content)));
  }
}
 
Example #3
Source File: SearchWebAction.java    From consulo with Apache License 2.0 5 votes vote down vote up
@RequiredUIAccess
@Override
public void update(@Nonnull AnActionEvent e) {
  Presentation presentation = e.getPresentation();
  DataContext dataContext = e.getDataContext();
  CopyProvider provider = e.getData(PlatformDataKeys.COPY_PROVIDER);
  boolean available = provider != null && provider.isCopyEnabled(dataContext) && provider.isCopyVisible(dataContext);
  presentation.setEnabled(available);
  presentation.setVisible(available);

  WebSearchEngine engine = myWebSearchOptions.getEngine();

  presentation.setText(BundleBase.format(ActionsBundle.message("action.$SearchWeb.0.text", engine.getPresentableName())));
  presentation.setDescription(BundleBase.format(ActionsBundle.message("action.$SearchWeb.0.description", engine.getPresentableName())));
}
 
Example #4
Source File: CopyAction.java    From consulo with Apache License 2.0 5 votes vote down vote up
public void actionPerformed(AnActionEvent e) {
  DataContext dataContext = e.getDataContext();
  CopyProvider provider = e.getData(PlatformDataKeys.COPY_PROVIDER);
  if (provider == null) {
    return;
  }
  provider.performCopy(dataContext);
}
 
Example #5
Source File: CopyAction.java    From consulo with Apache License 2.0 5 votes vote down vote up
public void update(AnActionEvent event) {
  Presentation presentation = event.getPresentation();
  DataContext dataContext = event.getDataContext();
  CopyProvider provider = event.getData(PlatformDataKeys.COPY_PROVIDER);
  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);
  }
}
 
Example #6
Source File: CopyProviderRule.java    From consulo with Apache License 2.0 5 votes vote down vote up
@Override
public CopyProvider getData(@Nonnull DataProvider dataProvider) {
  final Editor editor = dataProvider.getDataUnchecked(PlatformDataKeys.EDITOR);
  if (editor instanceof EditorEx) {
    return ((EditorEx) editor).getCopyProvider();
  }
  return null;
}
 
Example #7
Source File: CopyProviderRule.java    From consulo with Apache License 2.0 4 votes vote down vote up
@Nonnull
@Override
public Key<CopyProvider> getKey() {
  return PlatformDataKeys.COPY_PROVIDER;
}
 
Example #8
Source File: EditorWindowImpl.java    From consulo with Apache License 2.0 4 votes vote down vote up
@Override
public CopyProvider getCopyProvider() {
  return myDelegate.getCopyProvider();
}
 
Example #9
Source File: WebEditorImpl.java    From consulo with Apache License 2.0 4 votes vote down vote up
@Override
public CopyProvider getCopyProvider() {
  return null;
}
 
Example #10
Source File: CopyPasteSupport.java    From consulo with Apache License 2.0 votes vote down vote up
CopyProvider getCopyProvider(); 
Example #11
Source File: EditorEx.java    From consulo with Apache License 2.0 votes vote down vote up
CopyProvider getCopyProvider();