Java Code Examples for org.eclipse.swt.dnd.Transfer

The following examples show how to use org.eclipse.swt.dnd.Transfer. These examples are extracted from open source projects. 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 Project: lapse-plus   Source File: SinkView.java    License: GNU General Public License v3.0 6 votes vote down vote up
public void run() {
    StringBuffer buf = new StringBuffer();
    addCalls(viewer.getTable().getSelection(), buf);
    TextTransfer plainTextTransfer = TextTransfer.getInstance();
    try {
        fClipboard.setContents(new String[]{convertLineTerminators(buf.toString())},
            new Transfer[]{plainTextTransfer});
    } catch (SWTError e) {
        if (e.code != DND.ERROR_CANNOT_SET_CLIPBOARD) throw e;
        if (MessageDialog
            .openQuestion(fView.getViewSite().getShell(),
                ("CopyCallHierarchyAction.problem"),
                ("CopyCallHierarchyAction.clipboard_busy"))) {
            run();
        }
    }
}
 
Example 2
Source Project: lapse-plus   Source File: SourceView.java    License: GNU General Public License v3.0 6 votes vote down vote up
public void run() {
       StringBuffer buf = new StringBuffer();
       addCalls(viewer.getTable().getSelection(), buf);

	TextTransfer plainTextTransfer = TextTransfer.getInstance();
	try{
		fClipboard.setContents(
			new String[]{ convertLineTerminators(buf.toString()) }, 
			new Transfer[]{ plainTextTransfer });
	}  catch (SWTError e){
		if (e.code != DND.ERROR_CANNOT_SET_CLIPBOARD) 
			throw e;
		if (MessageDialog.openQuestion(fView.getViewSite().getShell(), 
				("CopyCallHierarchyAction.problem"), ("CopyCallHierarchyAction.clipboard_busy"))
		) 
		{
			run();
		}
	}
}
 
Example 3
private void addDragAdapters(StructuredViewer viewer) {
	int ops= DND.DROP_COPY | DND.DROP_LINK;

	Transfer[] transfers= new Transfer[] { LocalSelectionTransfer.getInstance(), ResourceTransfer.getInstance(), FileTransfer.getInstance()};

	DelegatingDragAdapter dragAdapter= new DelegatingDragAdapter() {
		@Override
		public void dragStart(DragSourceEvent event) {
			IStructuredSelection selection= (IStructuredSelection) fSelectionProviderMediator.getSelection();
			if (selection.isEmpty()) {
				event.doit= false;
				return;
			}
			super.dragStart(event);
		}
	};
	dragAdapter.addDragSourceListener(new SelectionTransferDragAdapter(fSelectionProviderMediator));
	dragAdapter.addDragSourceListener(new EditorInputTransferDragAdapter(fSelectionProviderMediator));
	dragAdapter.addDragSourceListener(new ResourceTransferDragAdapter(fSelectionProviderMediator));
	dragAdapter.addDragSourceListener(new FileTransferDragAdapter(fSelectionProviderMediator));

	viewer.addDragSupport(ops, transfers, dragAdapter);
}
 
Example 4
Source Project: nebula   Source File: ViewSelectedCellDataAction.java    License: Eclipse Public License 2.0 6 votes vote down vote up
public void run(TreeColumn treeCol, TreeItem treeItem, int columnNum) throws XViewerException, Exception {
   if (treeCol != null) {
      XViewerColumn xCol = (XViewerColumn) treeCol.getData();
      String data = null;

      if (xCol instanceof IXViewerValueColumn) {
         data = ((IXViewerValueColumn) xCol).getColumnText(treeItem.getData(), xCol, columnNum);
      } else {
         data =
            ((IXViewerLabelProvider) xViewer.getLabelProvider()).getColumnText(treeItem.getData(), xCol, columnNum);
      }
      if (data != null && !data.equals("")) { //$NON-NLS-1$
         if (option == Option.View) {
            String html = HtmlUtil.simplePage(HtmlUtil.getPreData(data));
            new HtmlDialog(treeCol.getText() + " " + XViewerText.get("data"), //$NON-NLS-1$//$NON-NLS-2$
               treeCol.getText() + " " + XViewerText.get("data"), html).open(); //$NON-NLS-1$ //$NON-NLS-2$
         } else {
            clipboard.setContents(new Object[] {data}, new Transfer[] {TextTransfer.getInstance()});
         }
      }
   }
}
 
Example 5
/**
 * 执行复制时对标记的处理,复制后在OS系统中不能包含标记占位符 ;
 */
private void copy() {
	super.doOperation(ITextOperationTarget.COPY);
	TextTransfer plainTextTransfer = TextTransfer.getInstance();
	XLiffTextTransfer hsTextTransfer = XLiffTextTransfer.getInstance();
	Clipboard clipboard = new Clipboard(getTextWidget().getDisplay());
	String plainText = (String) clipboard.getContents(plainTextTransfer);
	if (plainText == null || plainText.length() == 0) {
		return;
	}
	plainText = plainText.replaceAll(Utils.getLineSeparator(), "\n");
	plainText = plainText.replaceAll(Constants.LINE_SEPARATOR_CHARACTER + "", "");
	plainText = plainText.replaceAll(Constants.TAB_CHARACTER + "", "\t");
	plainText = plainText.replaceAll(Constants.SPACE_CHARACTER + "", " ");
	plainText = plainText.replaceAll("\u200B", "");
	clipboard.clearContents();
	Object[] data = new Object[] { PATTERN.matcher(plainText).replaceAll(""), plainText };
	Transfer[] types = new Transfer[] { plainTextTransfer, hsTextTransfer };

	clipboard.setContents(data, types, DND.CLIPBOARD);
	clipboard.dispose();
}
 
Example 6
Source Project: neoscada   Source File: DetailViewEditor.java    License: Eclipse Public License 1.0 6 votes vote down vote up
/**
 * This creates a context menu for the viewer and adds a listener as well registering the menu for extension.
 * <!-- begin-user-doc -->
 * <!-- end-user-doc -->
 * @generated
 */
protected void createContextMenuFor ( StructuredViewer viewer )
{
    MenuManager contextMenu = new MenuManager ( "#PopUp" ); //$NON-NLS-1$
    contextMenu.add ( new Separator ( "additions" ) ); //$NON-NLS-1$
    contextMenu.setRemoveAllWhenShown ( true );
    contextMenu.addMenuListener ( this );
    Menu menu = contextMenu.createContextMenu ( viewer.getControl () );
    viewer.getControl ().setMenu ( menu );
    getSite ().registerContextMenu ( contextMenu, new UnwrappingSelectionProvider ( viewer ) );

    int dndOperations = DND.DROP_COPY | DND.DROP_MOVE | DND.DROP_LINK;
    Transfer[] transfers = new Transfer[] { LocalTransfer.getInstance (), LocalSelectionTransfer.getTransfer (), FileTransfer.getInstance () };
    viewer.addDragSupport ( dndOperations, transfers, new ViewerDragAdapter ( viewer ) );
    viewer.addDropSupport ( dndOperations, transfers, new EditingDomainViewerDropAdapter ( editingDomain, viewer ) );
}
 
Example 7
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 Project: neoscada   Source File: OsgiEditor.java    License: Eclipse Public License 1.0 6 votes vote down vote up
/**
 * This creates a context menu for the viewer and adds a listener as well registering the menu for extension.
 * <!-- begin-user-doc -->
 * <!-- end-user-doc -->
 * @generated
 */
protected void createContextMenuFor ( StructuredViewer viewer )
{
    MenuManager contextMenu = new MenuManager ( "#PopUp" ); //$NON-NLS-1$
    contextMenu.add ( new Separator ( "additions" ) ); //$NON-NLS-1$
    contextMenu.setRemoveAllWhenShown ( true );
    contextMenu.addMenuListener ( this );
    Menu menu = contextMenu.createContextMenu ( viewer.getControl () );
    viewer.getControl ().setMenu ( menu );
    getSite ().registerContextMenu ( contextMenu, new UnwrappingSelectionProvider ( viewer ) );

    int dndOperations = DND.DROP_COPY | DND.DROP_MOVE | DND.DROP_LINK;
    Transfer[] transfers = new Transfer[] { LocalTransfer.getInstance (), LocalSelectionTransfer.getTransfer (), FileTransfer.getInstance () };
    viewer.addDragSupport ( dndOperations, transfers, new ViewerDragAdapter ( viewer ) );
    viewer.addDropSupport ( dndOperations, transfers, new EditingDomainViewerDropAdapter ( editingDomain, viewer ) );
}
 
Example 9
Source Project: neoscada   Source File: WorldEditor.java    License: Eclipse Public License 1.0 6 votes vote down vote up
/**
 * This creates a context menu for the viewer and adds a listener as well registering the menu for extension.
 * <!-- begin-user-doc -->
 * <!-- end-user-doc -->
 * @generated
 */
protected void createContextMenuFor ( StructuredViewer viewer )
{
    MenuManager contextMenu = new MenuManager ( "#PopUp" ); //$NON-NLS-1$
    contextMenu.add ( new Separator ( "additions" ) ); //$NON-NLS-1$
    contextMenu.setRemoveAllWhenShown ( true );
    contextMenu.addMenuListener ( this );
    Menu menu = contextMenu.createContextMenu ( viewer.getControl () );
    viewer.getControl ().setMenu ( menu );
    getSite ().registerContextMenu ( contextMenu, new UnwrappingSelectionProvider ( viewer ) );

    int dndOperations = DND.DROP_COPY | DND.DROP_MOVE | DND.DROP_LINK;
    Transfer[] transfers = new Transfer[] { LocalTransfer.getInstance (), LocalSelectionTransfer.getTransfer (), FileTransfer.getInstance () };
    viewer.addDragSupport ( dndOperations, transfers, new ViewerDragAdapter ( viewer ) );
    viewer.addDropSupport ( dndOperations, transfers, new EditingDomainViewerDropAdapter ( editingDomain, viewer ) );
}
 
Example 10
Source Project: tmxeditor8   Source File: TmxEditorViewer.java    License: GNU General Public License v2.0 6 votes vote down vote up
@Override
public void createPartControl(Composite parent) {
	parent.setLayout(new FillLayout());
	this.container = parent;
	CellEditorGlobalActionHanlder.getInstance().setIActionBars(getViewSite().getActionBars());
	DropTarget target = new DropTarget(parent, DND.DROP_MOVE | DND.DROP_COPY);
	Transfer[] tfs = new Transfer[] { FileTransfer.getInstance() };
	target.setTransfer(tfs);
	target.addDropListener(new DropTargetAdapter() {
		@Override
		public void drop(DropTargetEvent event) {
			Object o = event.data;
			if (o instanceof String[]) {
				String[] s = (String[]) o;
				if (s.length == 0 && s[0] == null || s[0].length() == 0) {
					return;
				}
				File f = new File(s[0]);
				if (f.exists() && f.isFile()) {
					open(f);
				}
			}
		}
	});
}
 
Example 11
Source Project: neoscada   Source File: InfrastructureEditor.java    License: Eclipse Public License 1.0 6 votes vote down vote up
/**
 * This creates a context menu for the viewer and adds a listener as well registering the menu for extension.
 * <!-- begin-user-doc -->
 * <!-- end-user-doc -->
 * @generated
 */
protected void createContextMenuFor ( StructuredViewer viewer )
{
    MenuManager contextMenu = new MenuManager ( "#PopUp" ); //$NON-NLS-1$
    contextMenu.add ( new Separator ( "additions" ) ); //$NON-NLS-1$
    contextMenu.setRemoveAllWhenShown ( true );
    contextMenu.addMenuListener ( this );
    Menu menu = contextMenu.createContextMenu ( viewer.getControl () );
    viewer.getControl ().setMenu ( menu );
    getSite ().registerContextMenu ( contextMenu, new UnwrappingSelectionProvider ( viewer ) );

    int dndOperations = DND.DROP_COPY | DND.DROP_MOVE | DND.DROP_LINK;
    Transfer[] transfers = new Transfer[] { LocalTransfer.getInstance (), LocalSelectionTransfer.getTransfer (), FileTransfer.getInstance () };
    viewer.addDragSupport ( dndOperations, transfers, new ViewerDragAdapter ( viewer ) );
    viewer.addDropSupport ( dndOperations, transfers, new EditingDomainViewerDropAdapter ( editingDomain, viewer ) );
}
 
Example 12
Source Project: neoscada   Source File: SecurityEditor.java    License: Eclipse Public License 1.0 6 votes vote down vote up
/**
 * This creates a context menu for the viewer and adds a listener as well registering the menu for extension.
 * <!-- begin-user-doc -->
 * <!-- end-user-doc -->
 * @generated
 */
protected void createContextMenuFor ( StructuredViewer viewer )
{
    MenuManager contextMenu = new MenuManager ( "#PopUp" ); //$NON-NLS-1$
    contextMenu.add ( new Separator ( "additions" ) ); //$NON-NLS-1$
    contextMenu.setRemoveAllWhenShown ( true );
    contextMenu.addMenuListener ( this );
    Menu menu = contextMenu.createContextMenu ( viewer.getControl () );
    viewer.getControl ().setMenu ( menu );
    getSite ().registerContextMenu ( contextMenu, new UnwrappingSelectionProvider ( viewer ) );

    int dndOperations = DND.DROP_COPY | DND.DROP_MOVE | DND.DROP_LINK;
    Transfer[] transfers = new Transfer[] { LocalTransfer.getInstance (), LocalSelectionTransfer.getTransfer (), FileTransfer.getInstance () };
    viewer.addDragSupport ( dndOperations, transfers, new ViewerDragAdapter ( viewer ) );
    viewer.addDropSupport ( dndOperations, transfers, new EditingDomainViewerDropAdapter ( editingDomain, viewer ) );
}
 
Example 13
Source Project: neoscada   Source File: GlobalizeEditor.java    License: Eclipse Public License 1.0 6 votes vote down vote up
/**
 * This creates a context menu for the viewer and adds a listener as well registering the menu for extension.
 * <!-- begin-user-doc -->
 * <!-- end-user-doc -->
 * @generated
 */
protected void createContextMenuFor ( StructuredViewer viewer )
{
    MenuManager contextMenu = new MenuManager ( "#PopUp" ); //$NON-NLS-1$
    contextMenu.add ( new Separator ( "additions" ) ); //$NON-NLS-1$
    contextMenu.setRemoveAllWhenShown ( true );
    contextMenu.addMenuListener ( this );
    Menu menu = contextMenu.createContextMenu ( viewer.getControl () );
    viewer.getControl ().setMenu ( menu );
    getSite ().registerContextMenu ( contextMenu, new UnwrappingSelectionProvider ( viewer ) );

    int dndOperations = DND.DROP_COPY | DND.DROP_MOVE | DND.DROP_LINK;
    Transfer[] transfers = new Transfer[] { LocalTransfer.getInstance (), LocalSelectionTransfer.getTransfer (), FileTransfer.getInstance () };
    viewer.addDragSupport ( dndOperations, transfers, new ViewerDragAdapter ( viewer ) );
    viewer.addDropSupport ( dndOperations, transfers, new EditingDomainViewerDropAdapter ( editingDomain, viewer ) );
}
 
Example 14
Source Project: neoscada   Source File: ComponentEditor.java    License: Eclipse Public License 1.0 6 votes vote down vote up
/**
 * This creates a context menu for the viewer and adds a listener as well
 * registering the menu for extension.
 * <!-- begin-user-doc -->
 * <!-- end-user-doc -->
 *
 * @generated NOT
 */
protected void createContextMenuFor ( final StructuredViewer viewer )
{
    final MenuManager contextMenu = new MenuManager ( "#PopUp" ); //$NON-NLS-1$
    contextMenu.add ( new Separator ( "additions" ) ); //$NON-NLS-1$
    contextMenu.setRemoveAllWhenShown ( true );
    contextMenu.addMenuListener ( this );
    final Menu menu = contextMenu.createContextMenu ( viewer.getControl () );
    viewer.getControl ().setMenu ( menu );
    getSite ().registerContextMenu ( contextMenu, new UnwrappingSelectionProvider ( viewer ) );

    final int dndOperations = DND.DROP_COPY | DND.DROP_MOVE | DND.DROP_LINK;
    final Transfer[] transfers = new Transfer[] { LocalTransfer.getInstance (), LocalSelectionTransfer.getTransfer (), FileTransfer.getInstance (), ItemTransfer.getInstance () };
    viewer.addDragSupport ( dndOperations, transfers, new ViewerDragAdapter ( viewer ) );
    viewer.addDropSupport ( dndOperations, transfers, new DropAdapterExtension ( this.editingDomain, viewer ) );
}
 
Example 15
Source Project: neoscada   Source File: ItemEditor.java    License: Eclipse Public License 1.0 6 votes vote down vote up
/**
 * This creates a context menu for the viewer and adds a listener as well registering the menu for extension.
 * <!-- begin-user-doc -->
 * <!-- end-user-doc -->
 * @generated
 */
protected void createContextMenuFor ( StructuredViewer viewer )
{
    MenuManager contextMenu = new MenuManager ( "#PopUp" ); //$NON-NLS-1$
    contextMenu.add ( new Separator ( "additions" ) ); //$NON-NLS-1$
    contextMenu.setRemoveAllWhenShown ( true );
    contextMenu.addMenuListener ( this );
    Menu menu = contextMenu.createContextMenu ( viewer.getControl () );
    viewer.getControl ().setMenu ( menu );
    getSite ().registerContextMenu ( contextMenu, new UnwrappingSelectionProvider ( viewer ) );

    int dndOperations = DND.DROP_COPY | DND.DROP_MOVE | DND.DROP_LINK;
    Transfer[] transfers = new Transfer[] { LocalTransfer.getInstance (), LocalSelectionTransfer.getTransfer (), FileTransfer.getInstance () };
    viewer.addDragSupport ( dndOperations, transfers, new ViewerDragAdapter ( viewer ) );
    viewer.addDropSupport ( dndOperations, transfers, new EditingDomainViewerDropAdapter ( editingDomain, viewer ) );
}
 
Example 16
Source Project: neoscada   Source File: ConfigurationEditor.java    License: Eclipse Public License 1.0 6 votes vote down vote up
/**
 * This creates a context menu for the viewer and adds a listener as well registering the menu for extension.
 * <!-- begin-user-doc -->
 * <!-- end-user-doc -->
 * @generated
 */
protected void createContextMenuFor ( StructuredViewer viewer )
{
    MenuManager contextMenu = new MenuManager ( "#PopUp" ); //$NON-NLS-1$
    contextMenu.add ( new Separator ( "additions" ) ); //$NON-NLS-1$
    contextMenu.setRemoveAllWhenShown ( true );
    contextMenu.addMenuListener ( this );
    Menu menu = contextMenu.createContextMenu ( viewer.getControl () );
    viewer.getControl ().setMenu ( menu );
    getSite ().registerContextMenu ( contextMenu, new UnwrappingSelectionProvider ( viewer ) );

    int dndOperations = DND.DROP_COPY | DND.DROP_MOVE | DND.DROP_LINK;
    Transfer[] transfers = new Transfer[] { LocalTransfer.getInstance (), LocalSelectionTransfer.getTransfer (), FileTransfer.getInstance () };
    viewer.addDragSupport ( dndOperations, transfers, new ViewerDragAdapter ( viewer ) );
    viewer.addDropSupport ( dndOperations, transfers, new EditingDomainViewerDropAdapter ( editingDomain, viewer ) );
}
 
Example 17
Source Project: M2Doc   Source File: GenconfEditor.java    License: Eclipse Public License 1.0 6 votes vote down vote up
/**
 * This creates a context menu for the viewer and adds a listener as well registering the menu for extension.
 * <!-- begin-user-doc -->
 * <!-- end-user-doc -->
 * 
 * @generated
 */
protected void createContextMenuFor(StructuredViewer viewer) {
    MenuManager contextMenu = new MenuManager("#PopUp");
    contextMenu.add(new Separator("additions"));
    contextMenu.setRemoveAllWhenShown(true);
    contextMenu.addMenuListener(this);
    Menu menu = contextMenu.createContextMenu(viewer.getControl());
    viewer.getControl().setMenu(menu);
    getSite().registerContextMenu(contextMenu, new UnwrappingSelectionProvider(viewer));

    int dndOperations = DND.DROP_COPY | DND.DROP_MOVE | DND.DROP_LINK;
    Transfer[] transfers = new Transfer[] {LocalTransfer.getInstance(), LocalSelectionTransfer.getTransfer(),
        FileTransfer.getInstance()};
    viewer.addDragSupport(dndOperations, transfers, new ViewerDragAdapter(viewer));
    viewer.addDropSupport(dndOperations, transfers, new EditingDomainViewerDropAdapter(editingDomain, viewer));
}
 
Example 18
Source Project: tlaplus   Source File: TLCErrorView.java    License: 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 19
Source Project: logbook   Source File: TableToClipboardAdapter.java    License: MIT License 6 votes vote down vote up
/**
 * テーブルの選択されている部分をヘッダー付きでクリップボードにコピーします
 *
 * @param header ヘッダー
 * @param table テーブル
 */
public static void copyTable(String[] header, Table table) {
    TableItem[] tableItems = table.getSelection();
    StringBuilder sb = new StringBuilder();
    sb.append(StringUtils.join(header, "\t"));
    sb.append("\r\n");
    for (TableItem column : tableItems) {
        String[] columns = new String[header.length];
        for (int i = 0; i < header.length; i++) {
            columns[i] = column.getText(i);
        }
        sb.append(StringUtils.join(columns, "\t"));
        sb.append("\r\n");
    }
    Clipboard clipboard = new Clipboard(Display.getDefault());
    clipboard.setContents(new Object[] { sb.toString() }, new Transfer[] { TextTransfer.getInstance() });
}
 
Example 20
Source Project: logbook   Source File: TreeToClipboardAdapter.java    License: MIT License 6 votes vote down vote up
/**
 * ツリーの選択されている部分をヘッダー付きでクリップボードにコピーします
 * 
 * @param header ヘッダー
 * @param tree ツリー
 */
public static void copyTree(String[] header, Tree tree) {
    TreeItem[] treeItems = tree.getSelection();
    StringBuilder sb = new StringBuilder();
    sb.append(StringUtils.join(header, "\t"));
    sb.append("\r\n");
    for (TreeItem column : treeItems) {
        String[] columns = new String[header.length];
        for (int i = 0; i < header.length; i++) {
            columns[i] = column.getText(i);
        }
        sb.append(StringUtils.join(columns, "\t"));
        sb.append("\r\n");
    }
    Clipboard clipboard = new Clipboard(Display.getDefault());
    clipboard.setContents(new Object[] { sb.toString() }, new Transfer[] { TextTransfer.getInstance() });
}
 
Example 21
Source Project: gama   Source File: CopyAction.java    License: GNU General Public License v3.0 6 votes vote down vote up
/**
 * Set the clipboard contents. Prompt to retry if clipboard is busy.
 *
 * @param resources
 *            the resources to copy to the clipboard
 * @param fileNames
 *            file names of the resources to copy to the clipboard
 * @param names
 *            string representation of all names
 */
private void setClipboard(final IResource[] resources, final String[] fileNames, final String names) {
	try {
		// set the clipboard contents
		if (fileNames.length > 0) {
			clipboard.setContents(new Object[] { resources, fileNames, names }, new Transfer[] {
					ResourceTransfer.getInstance(), FileTransfer.getInstance(), TextTransfer.getInstance() });
		} else {
			clipboard.setContents(new Object[] { resources, names },
					new Transfer[] { ResourceTransfer.getInstance(), TextTransfer.getInstance() });
		}
	} catch (final SWTError e) {
		if (e.code != DND.ERROR_CANNOT_SET_CLIPBOARD) { throw e; }
		if (MessageDialog.openQuestion(shell, "Problem with copy title", // TODO //$NON-NLS-1$
																			// ResourceNavigatorMessages.CopyToClipboardProblemDialog_title,
				"Problem with copy.")) { //$NON-NLS-1$
			setClipboard(resources, fileNames, names);
		}
	}
}
 
Example 22
Source Project: hop   Source File: GuiResource.java    License: Apache License 2.0 5 votes vote down vote up
public void toClipboard( String cliptext ) {
  if ( cliptext == null ) {
    return;
  }

  getNewClipboard();
  TextTransfer tran = TextTransfer.getInstance();
  clipboard.setContents( new String[] { cliptext }, new Transfer[] { tran } );
}
 
Example 23
private void addDropAdapters(AbstractTreeViewer viewer) {
	Transfer[] transfers= new Transfer[] { LocalSelectionTransfer.getInstance(), PluginTransfer.getInstance() };
	int ops= DND.DROP_MOVE | DND.DROP_COPY | DND.DROP_LINK | DND.DROP_DEFAULT;

	DelegatingDropAdapter delegatingDropAdapter= new DelegatingDropAdapter();
	delegatingDropAdapter.addDropTargetListener(new TypeHierarchyTransferDropAdapter(this, viewer));
	delegatingDropAdapter.addDropTargetListener(new PluginTransferDropAdapter(viewer));

	viewer.addDropSupport(ops, transfers, delegatingDropAdapter);
}
 
Example 24
Source Project: nebula   Source File: XViewerCustomizeDialog.java    License: Eclipse Public License 2.0 5 votes vote down vote up
private void createVisibleButtonsComposition(Composite parent) {
   final Composite visibleTableComp = new Composite(parent, SWT.NONE);
   visibleTableComp.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true));
   final GridLayout gridLayout_6 = new GridLayout();
   gridLayout_6.marginWidth = 0;
   gridLayout_6.marginHeight = 0;
   visibleTableComp.setLayout(gridLayout_6);

   final Label visibleColumnsLabel = new Label(visibleTableComp, SWT.NONE);
   visibleColumnsLabel.setLayoutData(new GridData(SWT.CENTER, SWT.CENTER, false, false));
   visibleColumnsLabel.setText(XViewerText.get("heading.visible")); //$NON-NLS-1$

   // Visible Column Table
   visibleColTable = new XViewerFilteredTree(visibleTableComp);
   final Tree table = visibleColTable.getViewer().getTree();
   final GridData gd_table = new GridData(SWT.FILL, SWT.FILL, true, true);
   gd_table.widthHint = 300;
   table.setLayoutData(gd_table);
   visibleColTable.getViewer().setLabelProvider(new XViewerColumnLabelProvider());
   visibleColTable.getViewer().setContentProvider(new ArrayTreeContentProvider());
   visibleColTable.getViewer().addSelectionChangedListener(event ->updateButtonEnablements());

   visibleColTable.getViewer().addDragSupport(DND.DROP_MOVE, new Transfer[] {TextTransfer.getInstance()},
      visibleTableDragListener);
   visibleColTable.getViewer().addDropSupport(DND.DROP_MOVE, new Transfer[] {TextTransfer.getInstance()},
      visibleTableDropListener);
   hiddenColTable.getViewer().addDragSupport(DND.DROP_MOVE, new Transfer[] {TextTransfer.getInstance()},
      hiddenTableDragListener);
   hiddenColTable.getViewer().addDropSupport(DND.DROP_MOVE, new Transfer[] {TextTransfer.getInstance()},
      hiddenTableDropListener);

}
 
Example 25
Source Project: nebula   Source File: XViewerCustDialogDragDrop.java    License: Eclipse Public License 2.0 5 votes vote down vote up
public XViewerCustDialogDragDrop(XViewerCustomizeDialog xViewerCustomizeDialog) {
   this.xViewerCustomizeDialog = xViewerCustomizeDialog;

   xViewerCustomizeDialog.visibleColTable.getViewer().addDragSupport(DND.DROP_MOVE,
      new Transfer[] {TextTransfer.getInstance()}, visibleTableDragListener);
   xViewerCustomizeDialog.visibleColTable.getViewer().addDropSupport(DND.DROP_MOVE,
      new Transfer[] {TextTransfer.getInstance()}, visibleTableDropListener);
   xViewerCustomizeDialog.hiddenColTable.getViewer().addDragSupport(DND.DROP_MOVE,
      new Transfer[] {TextTransfer.getInstance()}, hiddenTableDragListener);
   xViewerCustomizeDialog.hiddenColTable.getViewer().addDropSupport(DND.DROP_MOVE,
      new Transfer[] {TextTransfer.getInstance()}, hiddenTableDropListener);

}
 
Example 26
Source Project: neoscada   Source File: ChartManager.java    License: Eclipse Public License 1.0 5 votes vote down vote up
public DropTarget createDropTarget ( final Transfer[] transfers, final DropTargetListener dropTargetListener )
{
    checkWidget ();

    final DropTarget target = new DropTarget ( this.chartArea, DND.DROP_DEFAULT | DND.DROP_COPY | DND.DROP_LINK );
    target.setTransfer ( transfers );
    target.addDropListener ( dropTargetListener );
    return target;
}
 
Example 27
private void addDropAdapters(StructuredViewer viewer) {
	Transfer[] transfers= new Transfer[] { LocalSelectionTransfer.getInstance(), PluginTransfer.getInstance() };
	int ops= DND.DROP_MOVE | DND.DROP_COPY | DND.DROP_LINK | DND.DROP_DEFAULT;

	DelegatingDropAdapter delegatingDropAdapter= new DelegatingDropAdapter();
	delegatingDropAdapter.addDropTargetListener(new CallHierarchyTransferDropAdapter(this, viewer));
	delegatingDropAdapter.addDropTargetListener(new PluginTransferDropAdapter(viewer));

	viewer.addDropSupport(ops, transfers, delegatingDropAdapter);
}
 
Example 28
private void initDragAndDrop() {
	for (int i= 0; i < fAllViewers.length; i++) {
		addDragAdapters(fAllViewers[i]);
		addDropAdapters(fAllViewers[i]);
	}
	addDragAdapters(fMethodsViewer);
	fMethodsViewer.addDropSupport(DND.DROP_NONE, new Transfer[0], new DropTargetAdapter());

	//DND on empty hierarchy
	DropTarget dropTarget = new DropTarget(fPagebook, DND.DROP_MOVE | DND.DROP_COPY | DND.DROP_LINK | DND.DROP_DEFAULT);
	dropTarget.setTransfer(new Transfer[] { LocalSelectionTransfer.getInstance() });
	dropTarget.addDropListener(new TypeHierarchyTransferDropAdapter(this, fAllViewers[0]));
}
 
Example 29
Source Project: birt   Source File: CopyResourceAction.java    License: Eclipse Public License 1.0 5 votes vote down vote up
/**
 * Set the clipboard contents. Prompt to retry if clipboard is busy.
 * 
 * @param resources
 *            the resources to copy to the clipboard
 * @param fileNames
 *            file names of the resources to copy to the clipboard
 * @param names
 *            string representation of all names
 */
private void setClipboard( String[] fileNames )
{
	// set the clipboard contents
	if ( fileNames.length > 0 )
	{
		clipboard.setContents( new Object[]{
			fileNames
		}, new Transfer[]{
			FileTransfer.getInstance( )
		} );
	}
}
 
Example 30
protected final String getClipboardText(TransferData[] availableDataTypes) {
	Transfer transfer= TextTransfer.getInstance();
	if (isAvailable(transfer, availableDataTypes)) {
		return (String) getContents(fClipboard2, transfer, getShell());
	}
	return null;
}