org.eclipse.swt.dnd.TextTransfer Java Examples

The following examples show how to use org.eclipse.swt.dnd.TextTransfer. 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: TexOutlineDNDAdapter.java    From texlipse with Eclipse Public License 1.0 6 votes vote down vote up
/**
    * Set the text data into TextTransfer.
    * 
    * @see org.eclipse.swt.dnd.DragSourceListener#dragSetData(org.eclipse.swt.dnd.DragSourceEvent)
 */
   public void dragSetData(DragSourceEvent event) {

	// check that requested data type is supported
	if (!TextTransfer.getInstance().isSupportedType(event.dataType)) {
		return;
	}

       // get the source text
	int sourceOffset = this.dragSource.getPosition().getOffset();
	int sourceLength = this.dragSource.getPosition().getLength();
	
	Position sourcePosition = dragSource.getPosition();
	String sourceText = "";
	try {
		sourceText = getDocument().get(sourcePosition.getOffset(), sourcePosition.getLength());
	} catch (BadLocationException e) {
	    TexlipsePlugin.log("Could not set drag data.", e);
		return;
	}

       // set the data
       event.data = sourceText;
}
 
Example #2
Source File: TableToClipboardAdapter.java    From logbook with 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 #3
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 #4
Source File: CopyAction.java    From gama with 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 #5
Source File: TreeToClipboardAdapter.java    From logbook with 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 #6
Source File: AbapGitView.java    From ADT_Frontend with MIT License 6 votes vote down vote up
/**
 * Copies the current selection to the clipboard.
 *
 * @param table
 *            the data source
 */
protected void copy() {
	Object selection = AbapGitView.this.viewer.getStructuredSelection().getFirstElement();
	if (selection != null && selection instanceof IRepository) {
		IRepository currRepository = ((IRepository) selection);

		String repoStatusString = currRepository.getStatusText() == null ? "" : currRepository.getStatusText(); //$NON-NLS-1$
		String repoUserString = currRepository.getCreatedEmail() == null ? currRepository.getCreatedBy()
				: currRepository.getCreatedEmail();

		String lastChangedAt = currRepository.getDeserializedAt();
		if (lastChangedAt == null || lastChangedAt.equals("0.0")) { //$NON-NLS-1$
			lastChangedAt = currRepository.getCreatedAt();
		}
		String repoLastChangedString = getFormattedDate(lastChangedAt);

		final StringBuilder data = new StringBuilder();
		data.append(currRepository.getPackage() + " " + currRepository.getUrl() + " " + currRepository.getBranchName() + " " //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
				+ repoUserString + " " + repoLastChangedString + " " + repoStatusString); //$NON-NLS-1$ //$NON-NLS-2$

		final Clipboard clipboard = new Clipboard(AbapGitView.this.viewer.getControl().getDisplay());
		clipboard.setContents(new String[] { data.toString() }, new TextTransfer[] { TextTransfer.getInstance() });
		clipboard.dispose();
	}
}
 
Example #7
Source File: CellEditorTextViewer.java    From tmxeditor8 with GNU General Public License v2.0 6 votes vote down vote up
/**
 * 执行复制时对标记的处理,复制后在OS系统中不能包含标记占位符 ;
 */
private void copy() {
	super.doOperation(ITextOperationTarget.COPY);
	TextTransfer plainTextTransfer = TextTransfer.getInstance();
	HSTextTransfer hsTextTransfer = HSTextTransfer.getInstance();
	Clipboard clipboard = new Clipboard(getTextWidget().getDisplay());
	String plainText = (String) clipboard.getContents(plainTextTransfer);
	if (plainText == null || plainText.length() == 0) {
		return;
	}
	plainText = plainText.replaceAll(System.getProperty("line.separator"), "\n");
	plainText = plainText.replaceAll(TmxEditorConstanst.LINE_SEPARATOR_CHARACTER + "", "");
	plainText = plainText.replaceAll(TmxEditorConstanst.TAB_CHARACTER + "", "\t");
	plainText = plainText.replaceAll(TmxEditorConstanst.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);
	clipboard.dispose();
}
 
Example #8
Source File: ViewSelectedCellDataAction.java    From nebula with 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 #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: CopyCallHierarchyAction.java    From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 6 votes vote down vote up
@Override
public void run() {
	StringBuffer buf= new StringBuffer();
	addCalls(fViewer.getTree().getSelection()[0], 0, 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(), CallHierarchyMessages.CopyCallHierarchyAction_problem, CallHierarchyMessages.CopyCallHierarchyAction_clipboard_busy))
			run();
	}
}
 
Example #11
Source File: LocationCopyAction.java    From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 6 votes vote down vote up
@Override
public void run() {
	IStructuredSelection selection= (IStructuredSelection) fLocationViewer.getSelection();
	StringBuffer buf= new StringBuffer();
	for (Iterator<?> iterator= selection.iterator(); iterator.hasNext();) {
		CallLocation location= (CallLocation) iterator.next();
		buf.append(location.getLineNumber()).append('\t').append(location.getCallText());
		buf.append('\n');
	}
	TextTransfer plainTextTransfer = TextTransfer.getInstance();
	try {
		fClipboard.setContents(
				new String[]{ CopyCallHierarchyAction.convertLineTerminators(buf.toString()) },
				new Transfer[]{ plainTextTransfer });
	} catch (SWTError e){
		if (e.code != DND.ERROR_CANNOT_SET_CLIPBOARD)
			throw e;
		if (MessageDialog.openQuestion(fViewSite.getShell(), CallHierarchyMessages.CopyCallHierarchyAction_problem, CallHierarchyMessages.CopyCallHierarchyAction_clipboard_busy))
			run();
	}
}
 
Example #12
Source File: SegmentViewer.java    From translationstudio8 with GNU General Public License v2.0 6 votes vote down vote up
/**
 * 执行复制时对标记的处理,复制后在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 #13
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 #14
Source File: LapseView.java    From lapse-plus with GNU General Public License v3.0 6 votes vote down vote up
public void run() {
    StringBuffer buf= new StringBuffer();
    
    addCalls(fViewer.getTree().getSelection()[0], 0, buf);//we get the node selected in the tree

    TextTransfer plainTextTransfer = TextTransfer.getInstance();//for converting plain text in a String into Platform specific representation
    
    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 #15
Source File: SinkView.java    From lapse-plus with 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 #16
Source File: PasteAction.java    From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 5 votes vote down vote up
protected final String getClipboardText(TransferData[] availableDataTypes) {
	Transfer transfer= TextTransfer.getInstance();
	if (isAvailable(transfer, availableDataTypes)) {
		return (String) getContents(fClipboard2, transfer, getShell());
	}
	return null;
}
 
Example #17
Source File: CopyAction.java    From tmxeditor8 with GNU General Public License v2.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(IResource[] resources, String[] fileNames,
         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 (SWTError e) {
         if (e.code != DND.ERROR_CANNOT_SET_CLIPBOARD) {
	throw e;
}
         if (MessageDialog
                 .openQuestion(
                         shell,
                         WorkbenchNavigatorMessages.actions_CopyAction_msgTitle, // TODO ResourceNavigatorMessages.CopyToClipboardProblemDialog_title,  //$NON-NLS-1$
                         WorkbenchNavigatorMessages.actions_CopyAction_msg)) { //$NON-NLS-1$
	setClipboard(resources, fileNames, names);
}
     }
 }
 
Example #18
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 #19
Source File: CopyToClipboardAction.java    From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 5 votes vote down vote up
private static Transfer[] createDataTypeArray(IResource[] resources, IJavaElement[] javaElements, String[] fileNames, TypedSource[] typedSources) {
	List<ByteArrayTransfer> result= new ArrayList<ByteArrayTransfer>(4);
	if (resources.length != 0)
		result.add(ResourceTransfer.getInstance());
	if (javaElements.length != 0)
		result.add(JavaElementTransfer.getInstance());
	if (fileNames.length != 0)
		result.add(FileTransfer.getInstance());
	if (typedSources.length != 0)
		result.add(TypedSourceTransfer.getInstance());
	result.add(TextTransfer.getInstance());
	return result.toArray(new Transfer[result.size()]);
}
 
Example #20
Source File: CopyToClipboardAction.java    From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 5 votes vote down vote up
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);
	}
}
 
Example #21
Source File: GridCopyEnable.java    From translationstudio8 with GNU General Public License v2.0 5 votes vote down vote up
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 #22
Source File: GuiResource.java    From hop with 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
Source File: CoreSwtbotTools.java    From dsl-devkit with Eclipse Public License 1.0 5 votes vote down vote up
/**
 * Get text content from the clipboard.
 *
 * @param bot
 *          to work with, must not be {@code null}
 * @return clipboard text content, or {@code null} if no text data is available
 */
public static String getClipboardContent(final SWTWorkbenchBot bot) {
  Assert.isNotNull(bot, ARGUMENT_BOT);
  return UIThreadRunnable.syncExec(new Result<String>() {
    @Override
    public String run() {
      final Clipboard clipboard = new Clipboard(bot.getDisplay());
      return (String) clipboard.getContents(TextTransfer.getInstance());
    }
  });
}
 
Example #24
Source File: ClipboardUiTestUtil.java    From dsl-devkit with Eclipse Public License 1.0 5 votes vote down vote up
/**
 * Content from the clipboard.
 * 
 * @param bot
 *          to work with
 * @return clipboard content
 */
public static String clipboardContent(final SWTWorkbenchBot bot) {
  return UIThreadRunnable.syncExec(new Result<String>() {
    public String run() {
      Clipboard clipboard = new Clipboard(bot.getDisplay());
      return (String) clipboard.getContents(TextTransfer.getInstance());
    }
  });
}
 
Example #25
Source File: ExportWizardPage.java    From spotbugs with GNU Lesser General Public License v2.1 5 votes vote down vote up
protected void copyToClipboard(String toolTip) {
    Object[] data = new Object[] { toolTip };
    Transfer[] transfer = new Transfer[] { TextTransfer.getInstance() };
    Clipboard clipboard = new Clipboard(Display.getCurrent());
    clipboard.setContents(data, transfer);
    clipboard.dispose();
}
 
Example #26
Source File: ProcidDialog.java    From xds-ide with Eclipse Public License 1.0 5 votes vote down vote up
protected void copyProcidToClipboard() {
	Display display = Display.getCurrent();
       Clipboard clipboard = new Clipboard(display);
       clipboard.setContents(new Object[] { processId },
               new Transfer[] { TextTransfer.getInstance() });
       clipboard.dispose();
}
 
Example #27
Source File: TexOutlineDNDAdapter.java    From texlipse with Eclipse Public License 1.0 5 votes vote down vote up
/**
 * Validate the drop. Invalidation is caused if
    * 
    * - outline is not uptodate
    * - transfer type is other than text
    * - drop target is equal or children of source
    * - target is preamble
    * 
    * @param target
    * @param operation
    * @param transferType
    * 
    * @return true if drop is valid
    * 
    * @see org.eclipse.jface.viewers.ViewerDropAdapter#validateDrop(java.lang.Object, int, org.eclipse.swt.dnd.TransferData)
 */
public boolean validateDrop(Object target, int operation,
		TransferData transferType) {

	// deny if outline is dirty
	if (this.outline.isModelDirty()) {
		return false;
	}
	
	// check transfer type, only allow text
	if (!TextTransfer.getInstance().isSupportedType(transferType)) {
		return false;
	}
			
	// get the selected node, check null and type
	OutlineNode targetNode = (OutlineNode)target;
	if (targetNode == null || targetNode.getType() == OutlineNode.TYPE_PREAMBLE) {
		return false;
	}
   
	// deny dropping over oneself or over ones children
	if (targetNode.equals(this.dragSource) ||
			isAncestor(dragSource, targetNode)) {
		return false;
	}
	
	return true;
}
 
Example #28
Source File: TexOutlineActionPaste.java    From texlipse with Eclipse Public License 1.0 5 votes vote down vote up
public void run() {
	if (outline.isModelDirty()) {
		return;
	}

	String text = (String)outline.getClipboard().getContents(TextTransfer.getInstance());
	if (text == null) {
		return;
	}
	outline.paste(text);
}
 
Example #29
Source File: TexOutlineActionCopy.java    From texlipse with Eclipse Public License 1.0 5 votes vote down vote up
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 #30
Source File: TexOutlineActionCut.java    From texlipse with Eclipse Public License 1.0 5 votes vote down vote up
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();
	}
}