@Override public void run(ITextSelection selection) { fClipboard= new Clipboard(getShell().getDisplay()); try { copyToClipboard(selection, 0); } finally { fClipboard.dispose(); } }
public CopyToClipboardAction(IWorkbenchSite site) { super(site); setText(InfoViewMessages.CopyAction_label); setToolTipText(InfoViewMessages.CopyAction_tooltip); setDescription(InfoViewMessages.CopyAction_description); ISharedImages workbenchImages= PlatformUI.getWorkbench().getSharedImages(); setDisabledImageDescriptor(workbenchImages.getImageDescriptor(ISharedImages.IMG_TOOL_COPY_DISABLED)); setImageDescriptor(workbenchImages.getImageDescriptor(ISharedImages.IMG_TOOL_COPY)); setHoverImageDescriptor(workbenchImages.getImageDescriptor(ISharedImages.IMG_TOOL_COPY)); PlatformUI.getWorkbench().getHelpSystem().setHelp(this, IAbstractTextEditorHelpContextIds.COPY_ACTION); update(getSelection()); }
@Override public void selectionChanged(ITextSelection selection) { setEnabled(selection != null && selection.getLength() > 0); }
/** * Creates the actions and action groups for this view. */ protected void createActions() { fGotoInputAction= new GotoInputAction(this); fGotoInputAction.setEnabled(false); fCopyToClipboardAction= new CopyToClipboardAction(getViewSite()); ISelectionProvider provider= getSelectionProvider(); if (provider != null) provider.addSelectionChangedListener(fCopyToClipboardAction); }
/** * Creates the actions and action groups for this view. */ protected void createActions() { fGotoInputAction= new GotoInputAction(this); fGotoInputAction.setEnabled(false); fCopyToClipboardAction= new CopyToClipboardAction(getViewSite()); fToggleLinkAction= new LinkAction(); fToggleLinkAction.setActionDefinitionId(IWorkbenchCommandConstants.NAVIGATE_TOGGLE_LINK_WITH_EDITOR); fToggleLinkAction.updateLinkImage(false); ISelectionProvider provider= getSelectionProvider(); if (provider != null) provider.addSelectionChangedListener(fCopyToClipboardAction); }
public CopyToClipboardAction(IWorkbenchSite site) { super(site); setText(InfoViewMessages.CopyAction_label); setToolTipText(InfoViewMessages.CopyAction_tooltip); setDescription(InfoViewMessages.CopyAction_description); ISharedImages workbenchImages= PlatformUI.getWorkbench().getSharedImages(); setDisabledImageDescriptor(workbenchImages.getImageDescriptor(ISharedImages.IMG_TOOL_COPY_DISABLED)); setImageDescriptor(workbenchImages.getImageDescriptor(ISharedImages.IMG_TOOL_COPY)); setHoverImageDescriptor(workbenchImages.getImageDescriptor(ISharedImages.IMG_TOOL_COPY)); PlatformUI.getWorkbench().getHelpSystem().setHelp(this, IAbstractTextEditorHelpContextIds.COPY_ACTION); update(getSelection()); }
public void run(ITextSelection selection) { fClipboard= new Clipboard(getShell().getDisplay()); try { copyToClipboard(selection, 0); } finally { fClipboard.dispose(); } }
/** * Creates the actions and action groups for this view. */ protected void createActions() { fGotoInputAction= new GotoInputAction(this); fGotoInputAction.setEnabled(false); fCopyToClipboardAction= new CopyToClipboardAction(getViewSite()); fToggleLinkAction= new LinkAction(); fToggleLinkAction.setActionDefinitionId(IWorkbenchCommandConstants.NAVIGATE_TOGGLE_LINK_WITH_EDITOR); fToggleLinkAction.updateLinkImage(false); ISelectionProvider provider= getSelectionProvider(); if (provider != null) provider.addSelectionChangedListener(fCopyToClipboardAction); }
@Override public void selectionChanged(ITextSelection selection) { setEnabled(selection != null && selection.getLength() > 0); }
public CopyToClipboardAction(IWorkbenchSite site) { super(site); setText(InfoViewMessages.CopyAction_label); setToolTipText(InfoViewMessages.CopyAction_tooltip); setDescription(InfoViewMessages.CopyAction_description); ISharedImages workbenchImages= PlatformUI.getWorkbench().getSharedImages(); setDisabledImageDescriptor(workbenchImages.getImageDescriptor(ISharedImages.IMG_TOOL_COPY_DISABLED)); setImageDescriptor(workbenchImages.getImageDescriptor(ISharedImages.IMG_TOOL_COPY)); setHoverImageDescriptor(workbenchImages.getImageDescriptor(ISharedImages.IMG_TOOL_COPY)); PlatformUI.getWorkbench().getHelpSystem().setHelp(this, IAbstractTextEditorHelpContextIds.COPY_ACTION); update(getSelection()); }
@Override public void run(ITextSelection selection) { fClipboard= new Clipboard(getShell().getDisplay()); try { copyToClipboard(selection, 0); } finally { fClipboard.dispose(); } }
public void selectionChanged(ITextSelection selection) { setEnabled(selection != null && selection.getLength() > 0); }
private void copyToClipboard(ITextSelection selection, int repeatCount) { try{ fClipboard.setContents(new String[] { selection.getText() }, new Transfer[] { TextTransfer.getInstance() }); } catch (SWTError e) { if (e.code != DND.ERROR_CANNOT_SET_CLIPBOARD || repeatCount >= MAX_REPEAT_COUNT) throw e; if (MessageDialog.openQuestion(getShell(), InfoViewMessages.CopyToClipboard_error_title, InfoViewMessages.CopyToClipboard_error_message)) copyToClipboard(selection, repeatCount + 1); } } }
private void copyToClipboard(ITextSelection selection, int repeatCount) { try{ fClipboard.setContents(new String[] { selection.getText() }, new Transfer[] { TextTransfer.getInstance() }); } catch (SWTError e) { if (e.code != DND.ERROR_CANNOT_SET_CLIPBOARD || repeatCount >= MAX_REPEAT_COUNT) throw e; if (MessageDialog.openQuestion(getShell(), InfoViewMessages.CopyToClipboard_error_title, InfoViewMessages.CopyToClipboard_error_message)) copyToClipboard(selection, repeatCount + 1); } } }
private void copyToClipboard(ITextSelection selection, int repeatCount) { try{ fClipboard.setContents(new String[] { selection.getText() }, new Transfer[] { TextTransfer.getInstance() }); } catch (SWTError e) { if (e.code != DND.ERROR_CANNOT_SET_CLIPBOARD || repeatCount >= MAX_REPEAT_COUNT) throw e; if (MessageDialog.openQuestion(getShell(), InfoViewMessages.CopyToClipboard_error_title, InfoViewMessages.CopyToClipboard_error_message)) copyToClipboard(selection, repeatCount + 1); } } }