org.eclipse.swt.dnd.Transfer Java Examples
The following examples show how to use
org.eclipse.swt.dnd.Transfer.
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: CopyAction.java From gama with GNU General Public License v3.0 | 6 votes |
/** * 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 #2
Source File: SegmentViewer.java From translationstudio8 with GNU General Public License v2.0 | 6 votes |
/** * 执行复制时对标记的处理,复制后在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 #3
Source File: ViewSelectedCellDataAction.java From nebula with Eclipse Public License 2.0 | 6 votes |
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 #4
Source File: CallHierarchyViewPart.java From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 | 6 votes |
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 #5
Source File: SourceView.java From lapse-plus with GNU General Public License v3.0 | 6 votes |
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 #6
Source File: DetailViewEditor.java From neoscada with Eclipse Public License 1.0 | 6 votes |
/** * 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
Source File: CopyDataToClipboardSerializer.java From translationstudio8 with GNU General Public License v2.0 | 6 votes |
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: OsgiEditor.java From neoscada with Eclipse Public License 1.0 | 6 votes |
/** * 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 File: WorldEditor.java From neoscada with Eclipse Public License 1.0 | 6 votes |
/** * 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 File: TmxEditorViewer.java From tmxeditor8 with GNU General Public License v2.0 | 6 votes |
@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 File: InfrastructureEditor.java From neoscada with Eclipse Public License 1.0 | 6 votes |
/** * 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 File: GlobalizeEditor.java From neoscada with Eclipse Public License 1.0 | 6 votes |
/** * 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 File: ComponentEditor.java From neoscada with Eclipse Public License 1.0 | 6 votes |
/** * 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 #14
Source File: ItemEditor.java From neoscada with Eclipse Public License 1.0 | 6 votes |
/** * 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 #15
Source File: ConfigurationEditor.java From neoscada with Eclipse Public License 1.0 | 6 votes |
/** * 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 File: SecurityEditor.java From neoscada with Eclipse Public License 1.0 | 6 votes |
/** * 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 File: SinkView.java From lapse-plus with GNU General Public License v3.0 | 6 votes |
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 #18
Source File: TreeToClipboardAdapter.java From logbook with MIT License | 6 votes |
/** * ツリーの選択されている部分をヘッダー付きでクリップボードにコピーします * * @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 #19
Source File: TableToClipboardAdapter.java From logbook with MIT License | 6 votes |
/** * テーブルの選択されている部分をヘッダー付きでクリップボードにコピーします * * @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 File: TLCErrorView.java From tlaplus with MIT License | 6 votes |
@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 #21
Source File: GenconfEditor.java From M2Doc with Eclipse Public License 1.0 | 6 votes |
/** * 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 #22
Source File: LogViewer.java From LogViewer with Eclipse Public License 2.0 | 5 votes |
public void createPartControl(Composite parent) { //viewer this.parent = parent; documentListener = new ViewDocumentListener(); tabfolder = new TabFolder(parent,0); tabfolder.addSelectionListener(new TabSelectionListener()); viewer = new LogFileViewer(tabfolder,SWT.MULTI | SWT.H_SCROLL | SWT.V_SCROLL); // DnD DropTarget target = new DropTarget(parent, DND.DROP_MOVE | DND.DROP_COPY | DND.DROP_LINK); target.setTransfer(new Transfer[] {FileTransfer.getInstance(), TextTransfer.getInstance()}); target.addDropListener (new DropTargetAdapter() { public void dragEnter(DropTargetEvent e) { if (e.detail == DND.DROP_NONE) e.detail = DND.DROP_COPY; } public void drop(DropTargetEvent event) { if (event.data == null || ((String[])event.data).length < 1) { event.detail = DND.DROP_NONE; return; } //File file = new File(((String[])event.data)[0]); if (!checkAndOpenFile(LogFileType.LOGFILE_SYSTEM_FILE,((String[])event.data)[0], null, false)) event.detail = DND.DROP_NONE; } }); // fill the menues makeActions(); hookContextMenu(); contributeToActionBars(); openAllLastOpenFiles(); }
Example #23
Source File: BeansEditor.java From hybris-commerce-eclipse-plugin with Apache License 2.0 | 5 votes |
/** * 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 #24
Source File: CallHierarchyViewPart.java From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 | 5 votes |
private void initDragAndDrop() { addDragAdapters(fCallHierarchyViewer); addDropAdapters(fCallHierarchyViewer); addDropAdapters(fLocationViewer); //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 CallHierarchyTransferDropAdapter(this, fCallHierarchyViewer)); }
Example #25
Source File: TexOutlineActionCopy.java From texlipse with Eclipse Public License 1.0 | 5 votes |
public void run() { if (outline.isModelDirty()) { return; } String text = outline.getSelectedText(); if (text != null) { outline.getClipboard().setContents(new Object[] {text}, new Transfer[] {TextTransfer.getInstance()}); } }
Example #26
Source File: TexOutlineActionCut.java From texlipse with Eclipse Public License 1.0 | 5 votes |
public void run() { if (outline.isModelDirty()) { return; } String text = outline.getSelectedText(); if (text != null) { outline.getClipboard().setContents(new Object[] {text}, new Transfer[] {TextTransfer.getInstance()}); outline.removeSelectedText(); } }
Example #27
Source File: GuiResource.java From hop with Apache License 2.0 | 5 votes |
public void toClipboard( String cliptext ) { if ( cliptext == null ) { return; } getNewClipboard(); TextTransfer tran = TextTransfer.getInstance(); clipboard.setContents( new String[] { cliptext }, new Transfer[] { tran } ); }
Example #28
Source File: GridCopyEnable.java From tmxeditor8 with GNU General Public License v2.0 | 5 votes |
void copy() { if (focusContent == null || focusContent.equals("")) { return; } if (selection.x != selection.y) { String plainText = focusContent.substring(selection.x, selection.y); Object[] data = new Object[] { plainText }; TextTransfer plainTextTransfer = TextTransfer.getInstance(); Transfer[] types = new Transfer[] { plainTextTransfer }; clipboard.setContents(data, types); } }
Example #29
Source File: View.java From codeexamples-eclipse with Eclipse Public License 1.0 | 5 votes |
private void addDropListener(Composite parent) { LocalSelectionTransfer transfer = LocalSelectionTransfer.getTransfer(); DropTargetAdapter dragAdapter = new DropTargetAdapter() { @Override public void drop(DropTargetEvent event) { Control droppedObj = (Control) ((StructuredSelection) transfer.getSelection()).getFirstElement(); // Get the existing parent of the dragged control Composite oldParent = droppedObj.getParent(); if (oldParent == parent) { return; } if (droppedObj instanceof Label) { System.out.println("Dropped"); } // handle the drop if (droppedObj instanceof Label) { Label droppedLabel = (Label) droppedObj; droppedLabel.setParent(parent); // Change parent } if (droppedObj instanceof Button) { Button droppedButton = (Button) droppedObj; droppedButton.setParent(parent); // Change parent } // request a layout pass oldParent.requestLayout(); // If you change that to layout the layout will be correct parent.layout(); } }; DropTarget dropTarget = new DropTarget(parent, DND.DROP_MOVE | DND.DROP_COPY); dropTarget.setTransfer(new Transfer[] { transfer }); dropTarget.addDropListener(dragAdapter); }
Example #30
Source File: SlantingMatrixProjectorDesign.java From ldparteditor with MIT License | 5 votes |
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(); }); }