Search in sources :

Example 66 with Clipboard

use of org.eclipse.swt.dnd.Clipboard in project linuxtools by eclipse.

the class BasePropertySection method createControls.

@Override
public void createControls(final Composite parent, final TabbedPropertySheetPage propertySheetPage) {
    GridLayoutFactory.fillDefaults().numColumns(1).applyTo(parent);
    GridDataFactory.fillDefaults().align(SWT.FILL, SWT.FILL).grab(true, true).applyTo(parent);
    final Composite container = new Composite(parent, SWT.NONE);
    container.setBackground(Display.getDefault().getSystemColor(SWT.COLOR_LIST_BACKGROUND));
    GridLayoutFactory.fillDefaults().numColumns(1).margins(5, 5).applyTo(container);
    GridDataFactory.fillDefaults().align(SWT.FILL, SWT.FILL).grab(true, true).hint(400, 180).applyTo(container);
    this.treeViewer = createTableTreeViewer(container);
    if (this.clipboard != null)
        this.clipboard.dispose();
    this.clipboard = new Clipboard(Display.getCurrent());
    this.pageSite = propertySheetPage.getSite();
    initContextMenu(pageSite, clipboard);
    GridDataFactory.fillDefaults().align(SWT.FILL, SWT.FILL).grab(true, true).applyTo(treeViewer.getControl());
}
Also used : Composite(org.eclipse.swt.widgets.Composite) Clipboard(org.eclipse.swt.dnd.Clipboard)

Example 67 with Clipboard

use of org.eclipse.swt.dnd.Clipboard in project linuxtools by eclipse.

the class NewDockerConnectionPage method createControl.

@Override
public void createControl(final Composite parent) {
    final ScrolledComposite scrollTop = new ScrolledComposite(parent, SWT.H_SCROLL | SWT.V_SCROLL);
    scrollTop.setExpandVertical(true);
    scrollTop.setExpandHorizontal(true);
    final Composite container = new Composite(scrollTop, SWT.NONE);
    GridLayoutFactory.fillDefaults().numColumns(1).applyTo(container);
    GridDataFactory.fillDefaults().align(SWT.FILL, SWT.FILL).applyTo(container);
    createConnectionSettingsContainer(container);
    // attach the Databinding context status to this wizard page.
    WizardPageSupport.create(this, this.dbc);
    Clipboard clip = new Clipboard(Display.getCurrent());
    String content = (String) clip.getContents(TextTransfer.getInstance(), DND.SELECTION_CLIPBOARD);
    // DOCKER_HOST is the minimal property needed
    if (content != null && content.contains(DefaultDockerConnectionSettingsFinder.DOCKER_HOST)) {
        retrieveConnectionSettings(content);
    } else {
        content = (String) clip.getContents(TextTransfer.getInstance(), DND.CLIPBOARD);
        if (content != null && content.contains(DefaultDockerConnectionSettingsFinder.DOCKER_HOST)) {
            retrieveConnectionSettings(content);
        } else {
            retrieveDefaultConnectionSettings();
        }
    }
    scrollTop.setContent(container);
    Point point = container.computeSize(SWT.DEFAULT, SWT.DEFAULT);
    scrollTop.setSize(point);
    scrollTop.setMinSize(point);
    setControl(container);
}
Also used : Composite(org.eclipse.swt.widgets.Composite) ScrolledComposite(org.eclipse.swt.custom.ScrolledComposite) ScrolledComposite(org.eclipse.swt.custom.ScrolledComposite) Clipboard(org.eclipse.swt.dnd.Clipboard) Point(org.eclipse.swt.graphics.Point)

Example 68 with Clipboard

use of org.eclipse.swt.dnd.Clipboard in project linuxtools by eclipse.

the class PrepareCommitHandler method populateClipboardBuffer.

private void populateClipboardBuffer(String input) {
    TextTransfer plainTextTransfer = TextTransfer.getInstance();
    Clipboard clipboard = new Clipboard(PlatformUI.getWorkbench().getDisplay());
    clipboard.setContents(new String[] { input }, new Transfer[] { plainTextTransfer });
    clipboard.dispose();
}
Also used : Clipboard(org.eclipse.swt.dnd.Clipboard) TextTransfer(org.eclipse.swt.dnd.TextTransfer)

Example 69 with Clipboard

use of org.eclipse.swt.dnd.Clipboard in project linuxtools by eclipse.

the class NewDockerConnectionSWTBotTest method clearClipboards.

@Before
public void clearClipboards() {
    // Clear all clipboards
    Display.getDefault().syncExec(() -> {
        Clipboard clip = new Clipboard(Display.getCurrent());
        clip.clearContents(DND.CLIPBOARD);
        clip.clearContents(DND.SELECTION_CLIPBOARD);
    });
}
Also used : Clipboard(org.eclipse.swt.dnd.Clipboard) Before(org.junit.Before)

Example 70 with Clipboard

use of org.eclipse.swt.dnd.Clipboard in project yamcs-studio by yamcs.

the class CloneCommand method execute.

/**
 * {@inheritDoc}
 */
@Override
public void execute() {
    Clipboard clipboard = new Clipboard(Display.getCurrent());
    DisplayModel tempModel = new DisplayModel();
    for (AbstractWidgetModel widget : _models) {
        tempModel.addChild(widget, false);
    }
    String xml = XMLUtil.widgetToXMLString(tempModel, false);
    clipboard.setContents(new Object[] { xml }, new Transfer[] { OPIWidgetsTransfer.getInstance() });
    _clonedWidgets = getWidgetsFromClipboard();
    _compoundCommand = new CompoundCommand();
    int i = 0;
    for (AbstractWidgetModel widgetModel : _clonedWidgets) {
        if (_difference != null) {
            widgetModel.setLocation((widgetModel.getLocation().x + _difference.width), (widgetModel.getLocation().y + _difference.height));
        } else {
            widgetModel.setLocation((widgetModel.getLocation().x + 10), (widgetModel.getLocation().y + 10));
        }
        _compoundCommand.add(new WidgetCreateCommand(widgetModel, _parent, new Rectangle(widgetModel.getLocation(), widgetModel.getSize()), (i++ == 0 ? false : true)));
        if (_hGuide != null) {
            ChangeGuideCommand hGuideCommand = new ChangeGuideCommand(widgetModel, true);
            hGuideCommand.setNewGuide(_hGuide, _hAlignment);
            _compoundCommand.add(hGuideCommand);
        }
        if (_vGuide != null) {
            ChangeGuideCommand vGuideCommand = new ChangeGuideCommand(widgetModel, false);
            vGuideCommand.setNewGuide(_vGuide, _vAlignment);
            _compoundCommand.add(vGuideCommand);
        }
    }
    _compoundCommand.execute();
}
Also used : AbstractWidgetModel(org.csstudio.opibuilder.model.AbstractWidgetModel) DisplayModel(org.csstudio.opibuilder.model.DisplayModel) Rectangle(org.eclipse.draw2d.geometry.Rectangle) Clipboard(org.eclipse.swt.dnd.Clipboard) CompoundCommand(org.eclipse.gef.commands.CompoundCommand)

Aggregations

Clipboard (org.eclipse.swt.dnd.Clipboard)73 TextTransfer (org.eclipse.swt.dnd.TextTransfer)50 Transfer (org.eclipse.swt.dnd.Transfer)19 Point (org.eclipse.swt.graphics.Point)12 StyledText (org.eclipse.swt.custom.StyledText)8 Composite (org.eclipse.swt.widgets.Composite)7 Display (org.eclipse.swt.widgets.Display)7 IAction (org.eclipse.jface.action.IAction)6 ISelection (org.eclipse.jface.viewers.ISelection)6 GridLayout (org.eclipse.swt.layout.GridLayout)6 Control (org.eclipse.swt.widgets.Control)6 TableItem (org.eclipse.swt.widgets.TableItem)6 ArrayList (java.util.ArrayList)5 IStructuredSelection (org.eclipse.jface.viewers.IStructuredSelection)5 SelectionAdapter (org.eclipse.swt.events.SelectionAdapter)5 SelectionEvent (org.eclipse.swt.events.SelectionEvent)5 GridData (org.eclipse.swt.layout.GridData)5 Event (org.eclipse.swt.widgets.Event)4 Shell (org.eclipse.swt.widgets.Shell)4 Rectangle (org.eclipse.swt.graphics.Rectangle)3