org.eclipse.swt.dnd.Clipboard Java Examples

The following examples show how to use org.eclipse.swt.dnd.Clipboard. 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: TLCErrorView.java    From tlaplus with MIT License 6 votes vote down vote up
@Override
public void runWithKey(final boolean excludeActionHeader) {
	// it seems impossible this could ever be null since we treat it as non-null in the constructor.
	if (errorTraceTreeViewer == null) {
		return;
	}
	final TLCError trace = errorTraceTreeViewer.getCurrentTrace();
	if (!trace.hasTrace()) {
		// safeguard in addition to isEnabled 
		return;
	}

	final Clipboard clipboard = new Clipboard(display);
	clipboard.setContents(new Object[] { trace.toSequenceOfRecords(!excludeActionHeader) },
			new Transfer[] { TextTransfer.getInstance() });
	clipboard.dispose();
}
 
Example #2
Source File: PasteResourceAction.java    From birt with Eclipse Public License 1.0 6 votes vote down vote up
/**
 * Constructs an action for pasting resource.
 * 
 * @param page
 *            the resource explorer page
 * @param clipboard
 *            the clipboard for pasting resource
 */
public PasteResourceAction( LibraryExplorerTreeViewPage page,
		Clipboard clipboard )
{
	super( Messages.getString( "PasteLibraryAction.Text" ), page ); //$NON-NLS-1$
	this.clipboard = clipboard;
	setId( ActionFactory.PASTE.getId( ) );
	setAccelerator( SWT.CTRL | 'V' );

	setImageDescriptor( PlatformUI.getWorkbench( )
			.getSharedImages( )
			.getImageDescriptor( ISharedImages.IMG_TOOL_PASTE ) );

	setDisabledImageDescriptor( PlatformUI.getWorkbench( )
			.getSharedImages( )
			.getImageDescriptor( ISharedImages.IMG_TOOL_PASTE_DISABLED ) );
}
 
Example #3
Source File: EditActionProvider.java    From gama with GNU General Public License v3.0 6 votes vote down vote up
protected void makeActions() {
	clipboard = new Clipboard(shell.getDisplay());

	pasteAction = new PasteAction(shell, clipboard);
	pasteAction.setImageDescriptor(GamaIcons.create("menu.paste2").descriptor());
	pasteAction.setActionDefinitionId(IWorkbenchCommandConstants.EDIT_PASTE);

	copyAction = new CopyAction(shell, clipboard, pasteAction);
	copyAction.setImageDescriptor(GamaIcons.create("menu.copy2").descriptor());
	copyAction.setActionDefinitionId(IWorkbenchCommandConstants.EDIT_COPY);

	final IShellProvider sp = () -> shell;

	deleteAction = new DeleteResourceAction(sp);
	deleteAction.setImageDescriptor(GamaIcons.create("menu.delete2").descriptor());
	deleteAction.setActionDefinitionId(IWorkbenchCommandConstants.EDIT_DELETE);

}
 
Example #4
Source File: CopyToClipboardAction.java    From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 6 votes vote down vote up
private void copyToClipboard(IResource[] resources, String[] fileNames, String names, IJavaElement[] javaElements, TypedSource[] typedSources, int repeat, Clipboard clipboard) {
	final int repeat_max_count= 10;
	try{
		clipboard.setContents(createDataArray(resources, javaElements, fileNames, names, typedSources),
								createDataTypeArray(resources, javaElements, fileNames, typedSources));
	} catch (SWTError e) {
		if (e.code != DND.ERROR_CANNOT_SET_CLIPBOARD || repeat >= repeat_max_count)
			throw e;
		if (fAutoRepeatOnFailure) {
			try {
				Thread.sleep(500);
			} catch (InterruptedException e1) {
				// do nothing.
			}
		}
		if (fAutoRepeatOnFailure || MessageDialog.openQuestion(fShell, ReorgMessages.CopyToClipboardAction_4, ReorgMessages.CopyToClipboardAction_5))
			copyToClipboard(resources, fileNames, names, javaElements, typedSources, repeat + 1, clipboard);
	}
}
 
Example #5
Source File: ClipboardUtil.java    From xtext-eclipse with Eclipse Public License 2.0 6 votes vote down vote up
/**
 * Retrieves Java import information from the clipboard.
 *
 * @return {@link JavaImportData} containing imports information
 */
public static JavaImportData getJavaImportsContent() {
	return clipboardOperation(new Function<Clipboard, JavaImportData>() {

		@Override
		public JavaImportData apply(Clipboard clipboard) {
			for (int i = 0; i < clipboard.getAvailableTypeNames().length; i++) {
				final String formatName = clipboard.getAvailableTypeNames()[i];
				if (formatName.startsWith("source-with-imports-transfer-format")) {
					final TransferData transferData = clipboard.getAvailableTypes()[i];
					Object content = clipboard.getContents(new DynamicByteArrayTransfer(formatName, transferData));
					if (content instanceof JavaImportData) {
						return (JavaImportData) content;
					}
					return null;
				}
			}
			return null;
		}
	});
}
 
Example #6
Source File: TexOutlinePage.java    From texlipse with Eclipse Public License 1.0 6 votes vote down vote up
/**
 * Initialize copy paste by getting the clipboard and hooking 
 * the actions to global edit menu.
 * 
 * @param viewer
 */
private void initCopyPaste(TreeViewer viewer) {
    this.clipboard = new Clipboard(getSite().getShell().getDisplay());
    
    IActionBars bars = getSite().getActionBars();
    bars.setGlobalActionHandler(
            ActionFactory.CUT.getId(), 
            (Action)outlineActions.get(ACTION_CUT));
    
    bars.setGlobalActionHandler(
            ActionFactory.COPY.getId(),
            (Action)outlineActions.get(ACTION_COPY));
    
    bars.setGlobalActionHandler(
            ActionFactory.PASTE.getId(),
            (Action)outlineActions.get(ACTION_PASTE));
    
    bars.setGlobalActionHandler(
            ActionFactory.DELETE.getId(),
            (Action)outlineActions.get(ACTION_DELETE));
}
 
Example #7
Source File: CopyDataToClipboardSerializer.java    From translationstudio8 with GNU General Public License v2.0 6 votes vote down vote up
public void serialize() {
	final Clipboard clipboard = command.getClipboard();
	final String cellDelimeter = command.getCellDelimeter();
	final String rowDelimeter = command.getRowDelimeter();
	
	final TextTransfer textTransfer = TextTransfer.getInstance();
	final StringBuilder textData = new StringBuilder();
	int currentRow = 0;
	for (LayerCell[] cells : copiedCells) {
		int currentCell = 0;
		for (LayerCell cell : cells) {
			final String delimeter = ++currentCell < cells.length ? cellDelimeter : "";
			if (cell != null) {
				textData.append(cell.getDataValue() + delimeter);
			} else {
				textData.append(delimeter);
			} 
		}
		if (++currentRow < copiedCells.length) {
			textData.append(rowDelimeter);
		}
	}
	clipboard.setContents(new Object[]{textData.toString()}, new Transfer[]{textTransfer});
}
 
Example #8
Source File: ImportsAwareClipboardAction.java    From xtext-eclipse with Eclipse Public License 2.0 6 votes vote down vote up
private void doPasteWithImportsOperation() {
	XbaseClipboardData xbaseClipboardData = ClipboardUtil
			.clipboardOperation(new Function<Clipboard, XbaseClipboardData>() {
				@Override
				public XbaseClipboardData apply(Clipboard input) {
					Object content = input.getContents(TRANSFER_INSTANCE);
					if (content instanceof XbaseClipboardData) {
						return (XbaseClipboardData) content;
					}
					return null;
				}
			});
	JavaImportData javaImportsContent = ClipboardUtil.getJavaImportsContent();
	String textFromClipboard = ClipboardUtil.getTextFromClipboard();
	XtextEditor xtextEditor = EditorUtils.getXtextEditor(getTextEditor());
	boolean addImports = shouldAddImports(xtextEditor.getDocument(), caretOffset(xtextEditor));
	if (xbaseClipboardData != null && !sameTarget(xbaseClipboardData)) {
		doPasteXbaseCode(xbaseClipboardData, addImports);
	} else if (javaImportsContent != null) {
		doPasteJavaCode(textFromClipboard, javaImportsContent, addImports);
	} else {
		textOperationTarget.doOperation(operationCode);
	}
}
 
Example #9
Source File: CopyDataToClipboardSerializer.java    From tmxeditor8 with GNU General Public License v2.0 6 votes vote down vote up
public void serialize() {
	final Clipboard clipboard = command.getClipboard();
	final String cellDelimeter = command.getCellDelimeter();
	final String rowDelimeter = command.getRowDelimeter();
	
	final TextTransfer textTransfer = TextTransfer.getInstance();
	final StringBuilder textData = new StringBuilder();
	int currentRow = 0;
	for (LayerCell[] cells : copiedCells) {
		int currentCell = 0;
		for (LayerCell cell : cells) {
			final String delimeter = ++currentCell < cells.length ? cellDelimeter : "";
			if (cell != null) {
				textData.append(cell.getDataValue() + delimeter);
			} else {
				textData.append(delimeter);
			} 
		}
		if (++currentRow < copiedCells.length) {
			textData.append(rowDelimeter);
		}
	}
	clipboard.setContents(new Object[]{textData.toString()}, new Transfer[]{textTransfer});
}
 
Example #10
Source File: SlantingMatrixProjectorDesign.java    From ldparteditor with MIT License 5 votes vote down vote up
private void insertMatrix(Composite cmp_container) {

        final Matrix M = vm.getSlantingMatrix(mps.isMovingOriginToAxisCenter());

        insertMatrixCell(cmp_container, M.M00, M00);
        insertMatrixCell(cmp_container, M.M10, M10);
        insertMatrixCell(cmp_container, M.M20, M20);
        insertMatrixCell(cmp_container, M.M30, M30);
        insertMatrixCell(cmp_container, M.M01, M01);
        insertMatrixCell(cmp_container, M.M11, M11);
        insertMatrixCell(cmp_container, M.M21, M21);
        insertMatrixCell(cmp_container, M.M31, M31);
        insertMatrixCell(cmp_container, M.M02, M02);
        insertMatrixCell(cmp_container, M.M12, M12);
        insertMatrixCell(cmp_container, M.M22, M22);
        insertMatrixCell(cmp_container, M.M32, M32);
        insertMatrixCell(cmp_container, BigDecimal.ZERO, M03);
        insertMatrixCell(cmp_container, BigDecimal.ZERO, M13);
        insertMatrixCell(cmp_container, BigDecimal.ZERO, M23);
        insertMatrixCell(cmp_container, BigDecimal.ONE, M33);

        NButton btn_CopyMatrixToClipboard = new NButton(cmp_container, SWT.NONE);
        btn_CopyMatrixToClipboard.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, false, false, 4, 1));
        btn_CopyMatrixToClipboard.setText(I18n.SLANT_CopyToClipboard);

        WidgetUtil(btn_CopyMatrixToClipboard).addSelectionListener(e -> {
            final Matrix M1 = vm.getSlantingMatrix(mps.isMovingOriginToAxisCenter());
            final StringBuilder cbString = new StringBuilder();
            cbString.append("1 16 "); //$NON-NLS-1$
            cbString.append(M1.toLDrawString());
            cbString.append(" "); //$NON-NLS-1$
            final String cbs = cbString.toString();
            Display display = Display.getCurrent();
            Clipboard clipboard = new Clipboard(display);
            clipboard.setContents(new Object[] { cbs }, new Transfer[] { TextTransfer.getInstance() });
            clipboard.dispose();
        });
    }
 
Example #11
Source File: VM99Clipboard.java    From ldparteditor with MIT License 5 votes vote down vote up
public String getClipboardText() {
    final String result;
    Display display = Display.getCurrent();
    Clipboard clipboard = new Clipboard(display);
    result = (String) clipboard.getContents(TextTransfer.getInstance());
    clipboard.dispose();
    return result == null ? "" : result; //$NON-NLS-1$
}
 
Example #12
Source File: EditActionGroup.java    From tmxeditor8 with GNU General Public License v2.0 5 votes vote down vote up
protected void makeActions() {
	clipboard = new Clipboard(shell.getDisplay());

	pasteAction = new PasteAction(shell, clipboard);
	pasteAction.setText(WorkbenchNavigatorMessages.actions_EditActionGroup_pasteAction);
	ISharedImages images = PlatformUI.getWorkbench().getSharedImages();
	pasteAction.setDisabledImageDescriptor(images.getImageDescriptor(ISharedImages.IMG_TOOL_PASTE_DISABLED));
	pasteAction.setImageDescriptor(images.getImageDescriptor(ISharedImages.IMG_TOOL_PASTE));
	pasteAction.setActionDefinitionId(IWorkbenchCommandConstants.EDIT_PASTE);

	copyAction = new CopyAction(shell, clipboard, pasteAction);
	copyAction.setText(WorkbenchNavigatorMessages.actions_EditActionGroup_copyAction);
	copyAction.setDisabledImageDescriptor(images.getImageDescriptor(ISharedImages.IMG_TOOL_COPY_DISABLED));
	copyAction.setImageDescriptor(images.getImageDescriptor(ISharedImages.IMG_TOOL_COPY));
	copyAction.setActionDefinitionId(IWorkbenchCommandConstants.EDIT_COPY);

	IShellProvider sp = new IShellProvider() {
		public Shell getShell() {
			return shell;
		}
	};

	deleteAction = new DeleteResourceAndCloseEditorAction(sp);
	deleteAction.setText(WorkbenchNavigatorMessages.actions_EditActionGroup_deleteAction);
	deleteAction.setDisabledImageDescriptor(images.getImageDescriptor(ISharedImages.IMG_TOOL_DELETE_DISABLED));
	deleteAction.setImageDescriptor(images.getImageDescriptor(ISharedImages.IMG_TOOL_DELETE));
	deleteAction.setActionDefinitionId(IWorkbenchCommandConstants.EDIT_DELETE);
}
 
Example #13
Source File: CopyAction.java    From gama with GNU General Public License v3.0 5 votes vote down vote up
/**
 * Creates a new action.
 *
 * @param shell
 *            the shell for any dialogs
 * @param clipboard
 *            a platform clipboard
 */
public CopyAction(final Shell shell, final Clipboard clipboard) {
	super("Copy");
	Assert.isNotNull(shell);
	Assert.isNotNull(clipboard);
	this.shell = shell;
	this.clipboard = clipboard;
	setToolTipText("Copy selected resource(s)");
	setId(CopyAction.ID);
	PlatformUI.getWorkbench().getHelpSystem().setHelp(this, "CopyHelpId"); //$NON-NLS-1$
	// TODO INavigatorHelpContextIds.COPY_ACTION);
}
 
Example #14
Source File: TreeClipboard.java    From olca-app with Mozilla Public License 2.0 5 votes vote down vote up
private static void copy(Tree tree, ClipboardLabelProvider label) {
	if (tree == null)
		return;
	StringBuilder text = new StringBuilder();
	copyHeaders(tree, label, text);
	copyItems(tree, label, text);
	Clipboard clipboard = new Clipboard(UI.shell().getDisplay());
	clipboard.setContents(new String[] { text.toString() }, new Transfer[] { TextTransfer.getInstance() });
	clipboard.dispose();
}
 
Example #15
Source File: ImportStatusDialog.java    From bonita-studio with GNU General Public License v2.0 5 votes vote down vote up
@Override
protected Button createButton(final Composite parent, final int id, final String label, final boolean defaultButton) {
    if (org.bonitasoft.studio.ui.i18n.Messages.seeDetails.equals(label)) {
        return super.createButton(parent, IDialogConstants.OPEN_ID, label, defaultButton);
    }
    if (Messages.deploy.equals(label)) {
        return super.createButton(parent, IDialogConstants.PROCEED_ID, label, defaultButton);
    }
    if (Messages.copyToClipboard.equals(label)) {
        final Button copyButton = super.createButton(parent, IDialogConstants.NO_ID, label, defaultButton);
        copyButton.addSelectionListener(new SelectionAdapter() {

            /*
             * (non-Javadoc)
             * @see org.eclipse.swt.events.SelectionAdapter#widgetSelected(org.eclipse.swt.events.SelectionEvent)
             */
            @Override
            public void widgetSelected(SelectionEvent e) {
                final Clipboard cb = new Clipboard(Display.getDefault());
                final TextTransfer textTransfer = TextTransfer.getInstance();
                cb.setContents(new Object[] { statusMessages() },
                        new Transfer[] { textTransfer });
            }
        });
        return copyButton;
    }
    return super.createButton(parent, id, label, defaultButton);
}
 
Example #16
Source File: CopyRemoteResourceAction.java    From APICloud-Studio with GNU General Public License v3.0 5 votes vote down vote up
protected void execute(IAction action) {
	ISVNRemoteResource remoteResources[] = getSelectedRemoteResources();
	Clipboard clipboard = new Clipboard(getShell().getDisplay());
	clipboard.setContents(new Object[]{remoteResources[0]},
			new Transfer[]{RemoteResourceTransfer.getInstance()});
	clipboard.dispose();
}
 
Example #17
Source File: CopyUrlToClipboardAction.java    From APICloud-Studio with GNU General Public License v3.0 5 votes vote down vote up
protected void execute(IAction action) throws InvocationTargetException, InterruptedException {
	Clipboard clipboard = new Clipboard(Display.getCurrent());
	Transfer transfer = TextTransfer.getInstance();
	ISVNRemoteResource[] selectedResources = getSelectedRemoteResources();
	clipboard.setContents(
			new String[]{selectedResources[0].getUrl().toString()}, 
			new Transfer[]{transfer});	
	clipboard.dispose();
}
 
Example #18
Source File: PasteRemoteResourceAction.java    From APICloud-Studio with GNU General Public License v3.0 5 votes vote down vote up
protected boolean isEnabled() {
       if (getSelectedRemoteResources().length != 1)
           return false;
       
       boolean result;
       Clipboard clipboard = new Clipboard(getShell().getDisplay());
       result = clipboard.getContents(RemoteResourceTransfer.getInstance()) != null;
       clipboard.dispose();
	return result;
}
 
Example #19
Source File: PasteAction.java    From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 5 votes vote down vote up
public PasteAction(IWorkbenchSite site, Clipboard clipboard) {
	super(site);
	fClipboard= clipboard;

	setId(ID);
	setText(ReorgMessages.PasteAction_4);
	setDescription(ReorgMessages.PasteAction_5);

	ISharedImages workbenchImages= JavaPlugin.getDefault().getWorkbench().getSharedImages();
	setDisabledImageDescriptor(workbenchImages.getImageDescriptor(ISharedImages.IMG_TOOL_PASTE_DISABLED));
	setImageDescriptor(workbenchImages.getImageDescriptor(ISharedImages.IMG_TOOL_PASTE));
	setHoverImageDescriptor(workbenchImages.getImageDescriptor(ISharedImages.IMG_TOOL_PASTE));

	PlatformUI.getWorkbench().getHelpSystem().setHelp(this, IJavaHelpContextIds.PASTE_ACTION);
}
 
Example #20
Source File: file_to_clipboard.java    From ldparteditor with MIT License 5 votes vote down vote up
/**
 * Copy a file into the clipboard
 * Assumes the file exists -> no additional check
 * @param fileName - includes the path
 */

public static void copytoClipboard(String fileName) {
    Display display = Display.getCurrent();
    Clipboard clipboard = new Clipboard(display);
    String[] data = { fileName };
    clipboard.setContents(new Object[] { data },
            new Transfer[] { FileTransfer.getInstance() });
    clipboard.dispose();
}
 
Example #21
Source File: RenderClipboardAction.java    From eclipsegraphviz with Eclipse Public License 1.0 5 votes vote down vote up
public void run(IAction action) {
    Clipboard clipboard = new Clipboard(Display.getCurrent());
    String contents = (String) clipboard.getContents(TextTransfer.getInstance());
    if (contents != null) {
        view.setAutoSync(false);
        view.setContents(contents.getBytes(), new DOTGraphicalContentProvider());
    }
}
 
Example #22
Source File: ClipboardHandlerTable.java    From arx with Apache License 2.0 5 votes vote down vote up
/**
 * Copies the table's contents to the clipboard.
 */
public void copy(){
    if (table != null && table.getItemCount()>0) {
        Clipboard clipboard = new Clipboard(table.getDisplay());
        TextTransfer textTransfer = TextTransfer.getInstance();
        clipboard.setContents(new String[]{getText(table)}, new Transfer[]{textTransfer});
        clipboard.dispose();
    }
}
 
Example #23
Source File: CopyToClipboardOperation.java    From tracecompass with Eclipse Public License 2.0 5 votes vote down vote up
@Override
public void run(IProgressMonitor monitor) {
    final StringBuilder sb = new StringBuilder();
    monitor.beginTask(Messages.CopyToClipboardOperation_TaskName, (int) (fEndRank - fStartRank + 1));

    boolean needTab = false;
    for (TmfEventTableColumn column : fColumns) {
        if (needTab) {
            sb.append('\t');
        }
        sb.append(column.getHeaderName());
        needTab = true;
    }
    sb.append(LINE_SEPARATOR);

    copy(sb, monitor);

    Display.getDefault().syncExec(() -> {
        if (sb.length() == 0) {
            return;
        }
        Clipboard clipboard = new Clipboard(Display.getDefault());
        try {
            clipboard.setContents(new Object[] { sb.toString() },
                    new Transfer[] { TextTransfer.getInstance() });
        } catch (OutOfMemoryError e) {
            sb.setLength(0);
            sb.trimToSize();
            showErrorDialog();
        } finally {
            clipboard.dispose();
        }
    });

    monitor.done();
}
 
Example #24
Source File: Clipboards.java    From offspring with MIT License 5 votes vote down vote up
public static void copy(Display display, String contents) {
  Clipboard clipboard = new Clipboard(display);
  TextTransfer textTransfer = TextTransfer.getInstance();
  clipboard.setContents(new String[] {
      contents
  }, new Transfer[] {
    textTransfer
  });
  clipboard.dispose();
}
 
Example #25
Source File: RemoteProfilesPreferencePage.java    From tracecompass with Eclipse Public License 2.0 5 votes vote down vote up
private static void setClipboardContents(IStructuredSelection data) {
    LocalSelectionTransfer transfer = LocalSelectionTransfer.getTransfer();
    transfer.setSelection(data);
    Clipboard clipboard = new Clipboard(PlatformUI.getWorkbench().getDisplay());
    clipboard.setContents(new Object[] { new Object() }, new Transfer[] { transfer });
    clipboard.dispose();
}
 
Example #26
Source File: GridCopyEnable.java    From tmxeditor8 with GNU General Public License v2.0 5 votes vote down vote up
/**
 * @param gridTable
 */
public GridCopyEnable(Grid gridTable) {
	Assert.isNotNull(gridTable);
	this.gridTable = gridTable;
	defaultCaret = new Caret(gridTable, SWT.NONE);
	clipboard = new Clipboard(gridTable.getDisplay());
	this.gridTable.setCaret(defaultCaret);
	this.gridTable.setCursor(Display.getDefault().getSystemCursor(SWT.CURSOR_IBEAM));
	initListener();
}
 
Example #27
Source File: TextEditor.java    From birt with Eclipse Public License 1.0 5 votes vote down vote up
private void pasteClipboard( )
{
	Clipboard cb = new Clipboard( Display.getCurrent( ) );
	// TransferData[] types = cb.getAvailableTypes( );
	RTFTransfer rtfTransfer = RTFTransfer.getInstance( );
	Object contents = cb.getContents( rtfTransfer );
	// textEditor.paste( );
	if ( contents != null )
	{
		RTFHTMLHandler handler = new RTFHTMLHandler( );
		try
		{
			RTFParser.parse( contents.toString( ), handler );
			textEditor.insert( handler.toHTML( ) );
			return;
		}
		catch ( Exception e1 )
		{
		}
	}
	else
	{
		HTMLTransfer htmlTransfer = HTMLTransfer.getInstance( );
		contents = cb.getContents( htmlTransfer );
		if ( contents != null )
		{
			textEditor.insert( contents.toString( ) );
			return;
		}
	}

	TextTransfer plainTextTransfer = TextTransfer.getInstance( );
	String text = (String) cb.getContents( plainTextTransfer, DND.CLIPBOARD );
	textEditor.insert( text );
}
 
Example #28
Source File: CopyAction.java    From Pydev with Eclipse Public License 1.0 5 votes vote down vote up
/**
 * Creates a new action.
 *
 * @param shell the shell for any dialogs
 * @param clipboard a platform clipboard
 */
public CopyAction(Shell shell, Clipboard clipboard) {
    super("Copy"); // TODO ResourceNavigatorMessages.CopyAction_title); //$NON-NLS-1$
    Assert.isNotNull(shell);
    Assert.isNotNull(clipboard);
    this.shell = shell;
    this.clipboard = clipboard;
    setToolTipText("Copy Tooltip"); // TODO ResourceNavigatorMessages.CopyAction_toolTip); //$NON-NLS-1$
    setId(CopyAction.ID);
    PlatformUI.getWorkbench().getHelpSystem().setHelp(this, "CopyHelpId"); //$NON-NLS-1$
    // TODO INavigatorHelpContextIds.COPY_ACTION);
}
 
Example #29
Source File: ResultSetPreviewPage.java    From birt with Eclipse Public License 1.0 5 votes vote down vote up
public void run( )
{
	StringBuffer textData = new StringBuffer( );

	for ( int i = 0; i < resultSetTable.getColumnCount( ); i++ )
	{
		textData.append( resultSetTable.getColumn( i ).getText( ) + "\t" ); //$NON-NLS-1$
	}
	textData.append( "\n" ); //$NON-NLS-1$

	TableItem[] tableItems = resultSetTable.getSelection( );
	for ( int i = 0; i < tableItems.length; i++ )
	{
		for ( int j = 0; j < resultSetTable.getColumnCount( ); j++ )
		{
			textData.append( tableItems[i].getText( j ) + "\t" ); //$NON-NLS-1$
		}
		textData.append( "\n" ); //$NON-NLS-1$
	}

	Clipboard clipboard = new Clipboard( resultSetTable.getDisplay( ) );
	clipboard.setContents( new Object[]{
		textData.toString( )
	}, new Transfer[]{
		TextTransfer.getInstance( )
	} );
	clipboard.dispose( );
}
 
Example #30
Source File: ListDisplay.java    From elexis-3-core with Eclipse Public License 1.0 5 votes vote down vote up
public void toClipBoard(boolean bAsString){
	Clipboard clip = new Clipboard(UiDesk.getDisplay());
	StringBuilder sb = new StringBuilder();
	for (String s : list.getItems()) {
		sb.append(s).append("\n");
	}
	clip.setContents(new Object[] {
		sb.toString()
	}, new Transfer[] {
		myTransfer
	});
}