Search in sources :

Example 21 with Transfer

use of org.eclipse.swt.dnd.Transfer in project archi by archimatetool.

the class UserPropertiesSection method addDropSupport.

private void addDropSupport() {
    int operations = DND.DROP_MOVE;
    Transfer[] transferTypes = new Transfer[] { LocalSelectionTransfer.getTransfer() };
    fTableViewer.addDropSupport(operations, transferTypes, new DropTargetListener() {

        public void dragEnter(DropTargetEvent event) {
        }

        public void dragLeave(DropTargetEvent event) {
        }

        public void dragOperationChanged(DropTargetEvent event) {
            event.detail = getEventDetail(event);
        }

        public void dragOver(DropTargetEvent event) {
            event.detail = getEventDetail(event);
            if (event.detail == DND.DROP_NONE) {
                event.feedback = DND.FEEDBACK_NONE;
            } else {
                event.feedback = getDragFeedbackType(event);
            }
            event.feedback |= DND.FEEDBACK_SCROLL;
        }

        public void drop(DropTargetEvent event) {
            doDropOperation(event);
        }

        public void dropAccept(DropTargetEvent event) {
        }

        private int getEventDetail(DropTargetEvent event) {
            return fDragSourceValid ? DND.DROP_MOVE : DND.DROP_NONE;
        }
    });
}
Also used : DropTargetListener(org.eclipse.swt.dnd.DropTargetListener) LocalSelectionTransfer(org.eclipse.jface.util.LocalSelectionTransfer) Transfer(org.eclipse.swt.dnd.Transfer) DropTargetEvent(org.eclipse.swt.dnd.DropTargetEvent) Point(org.eclipse.swt.graphics.Point)

Example 22 with Transfer

use of org.eclipse.swt.dnd.Transfer in project eclipse.platform.text by eclipse.

the class FileSearchPage method addDragAdapters.

private void addDragAdapters(StructuredViewer viewer) {
    Transfer[] transfers = new Transfer[] { ResourceTransfer.getInstance() };
    int ops = DND.DROP_COPY | DND.DROP_LINK;
    viewer.addDragSupport(ops, transfers, new NavigatorDragAdapter(viewer));
}
Also used : NavigatorDragAdapter(org.eclipse.ui.views.navigator.NavigatorDragAdapter) ResourceTransfer(org.eclipse.ui.part.ResourceTransfer) Transfer(org.eclipse.swt.dnd.Transfer)

Example 23 with Transfer

use of org.eclipse.swt.dnd.Transfer in project eclipse.platform.text by eclipse.

the class AbstractTemplatesPage method createActions.

/**
 * Create all the actions
 */
private void createActions() {
    fInsertAction = new Action(TemplatesMessages.TemplatesPage_insert) {

        @Override
        public void run() {
            TemplatePersistenceData[] selectedTemplates = getSelectedTemplates();
            insertTemplate(selectedTemplates[0].getTemplate());
        }
    };
    fInsertAction.setImageDescriptor(TemplatesPageImages.getDescriptor(TemplatesPageImages.IMG_ELCL_TEMPLATE_INSERT));
    fInsertAction.setDisabledImageDescriptor(TemplatesPageImages.getDescriptor(TemplatesPageImages.IMG_DLCL_TEMPLATE_INSERT));
    fInsertAction.setToolTipText(TemplatesMessages.TemplatesPage_insert_tooltip);
    fAddAction = new Action(TemplatesMessages.TemplatesPage_new) {

        @Override
        public void run() {
            addTemplate();
        }
    };
    fAddAction.setImageDescriptor(TemplatesPageImages.getDescriptor(TemplatesPageImages.IMG_ELCL_TEMPLATE_NEW));
    fAddAction.setToolTipText(TemplatesMessages.TemplatesPage_new_tooltip);
    fEditAction = new Action(TemplatesMessages.TemplatesPage_edit) {

        @Override
        public void run() {
            editTemplate();
        }
    };
    fEditAction.setImageDescriptor(TemplatesPageImages.getDescriptor(TemplatesPageImages.IMG_ELCL_TEMPLATE_EDIT));
    fEditAction.setDisabledImageDescriptor(TemplatesPageImages.getDescriptor(TemplatesPageImages.IMG_DLCL_TEMPLATE_EDIT));
    fEditAction.setToolTipText(TemplatesMessages.TemplatesPage_edit_tooltip);
    fRemoveAction = new Action(TemplatesMessages.TemplatesPage_remove) {

        @Override
        public void run() {
            removeTemplates();
        }
    };
    fRemoveAction.setImageDescriptor(TemplatesPageImages.getDescriptor(TemplatesPageImages.IMG_DLCL_TEMPLATE_DELETE));
    fRemoveAction.setImageDescriptor(TemplatesPageImages.getDescriptor(TemplatesPageImages.IMG_ELCL_TEMPLATE_DELETE));
    fRemoveAction.setToolTipText(TemplatesMessages.TemplatesPage_remove_tooltip);
    fLinkWithEditorAction = new Action(TemplatesMessages.TemplatesPage_link_to_editor, IAction.AS_CHECK_BOX) {

        @Override
        public void run() {
            fPreferenceStore.setValue(LINK_ACTION_PREF_ID, fLinkWithEditorAction.isChecked());
            refresh();
        }
    };
    fLinkWithEditorAction.setImageDescriptor(TemplatesPageImages.getDescriptor(TemplatesPageImages.IMG_ELCL_TEMPLATE_LINK));
    fLinkWithEditorAction.setChecked(fPreferenceStore.getBoolean(LINK_ACTION_PREF_ID));
    fLinkWithEditorAction.setToolTipText(TemplatesMessages.TemplatesPage_link_to_editor_tooltip);
    fCollapseAllAction = new Action(TemplatesMessages.TemplatesPage_collapse_all) {

        @Override
        public void run() {
            fTreeViewer.collapseAll();
        }
    };
    fCollapseAllAction.setImageDescriptor(TemplatesPageImages.getDescriptor(TemplatesPageImages.IMG_ELCL_TEMPLATE_COLLAPSE_ALL));
    fCollapseAllAction.setToolTipText(TemplatesMessages.TemplatesPage_collapse_all_tooltip);
    if (getPreferencePageId() != null) {
        fPreferencePageAction = new Action(TemplatesMessages.TemplatesPage_preference_page) {

            @Override
            public void run() {
                showPreferencePage();
            }
        };
        fPreferencePageAction.setToolTipText(TemplatesMessages.TemplatesPage_preference_page_tooltip);
    }
    fPasteAction = new Action() {

        @Override
        public void run() {
            Clipboard clipboard = new Clipboard(getShell().getDisplay());
            try {
                String pattern = ((String) clipboard.getContents(TextTransfer.getInstance()));
                if (pattern != null) {
                    // $NON-NLS-1$//$NON-NLS-2$
                    final Template template = new Template(createTemplateName(), TemplatesMessages.TemplatesPage_paste_description, getContextTypeId(), pattern.replaceAll("\\$", "\\$\\$"), true);
                    getShell().getDisplay().asyncExec(new Runnable() {

                        @Override
                        public void run() {
                            addTemplate(template);
                        }
                    });
                    return;
                }
                TemplatePersistenceData[] templates = (TemplatePersistenceData[]) clipboard.getContents(TemplatesTransfer.getInstance());
                if (templates != null)
                    copyTemplates(templates, getContextTypeId());
            } finally {
                clipboard.dispose();
            }
        }
    };
    fCopyAction = new Action() {

        @Override
        public void run() {
            Clipboard clipboard = new Clipboard(getShell().getDisplay());
            try {
                clipboard.setContents(new Object[] { getSelectedTemplates() }, new Transfer[] { TemplatesTransfer.getInstance() });
            } finally {
                clipboard.dispose();
            }
        }
    };
}
Also used : IAction(org.eclipse.jface.action.IAction) Action(org.eclipse.jface.action.Action) TemplatePersistenceData(org.eclipse.jface.text.templates.persistence.TemplatePersistenceData) Transfer(org.eclipse.swt.dnd.Transfer) TextTransfer(org.eclipse.swt.dnd.TextTransfer) Clipboard(org.eclipse.swt.dnd.Clipboard) Template(org.eclipse.jface.text.templates.Template)

Example 24 with Transfer

use of org.eclipse.swt.dnd.Transfer in project eclipse.platform.text by eclipse.

the class AbstractTemplatesPage method setupEditorDropTarget.

/**
 * Setup the editor site as a drop target.
 */
private void setupEditorDropTarget() {
    Control control = fTextEditor.getAdapter(Control.class);
    if (control == null)
        return;
    DropTarget dropTarget = (DropTarget) control.getData(DND.DROP_TARGET_KEY);
    if (dropTarget == null)
        dropTarget = new DropTarget(control, DND.DROP_COPY);
    Transfer[] currentTransfers = dropTarget.getTransfer();
    int currentLength = currentTransfers.length;
    Transfer[] newTransfers = new Transfer[currentLength + 1];
    System.arraycopy(currentTransfers, 0, newTransfers, 0, currentLength);
    newTransfers[currentLength] = TemplatesTransfer.getInstance();
    dropTarget.setTransfer(newTransfers);
    EditorDropTargetListener editorDropTarget = new EditorDropTargetListener();
    dropTarget.addDropListener(editorDropTarget);
}
Also used : Control(org.eclipse.swt.widgets.Control) Transfer(org.eclipse.swt.dnd.Transfer) TextTransfer(org.eclipse.swt.dnd.TextTransfer) DropTarget(org.eclipse.swt.dnd.DropTarget) Point(org.eclipse.swt.graphics.Point)

Example 25 with Transfer

use of org.eclipse.swt.dnd.Transfer in project eclipse.platform.swt by eclipse.

the class DNDExample method removeDropTransfer.

private void removeDropTransfer(Transfer transfer) {
    if (dropTypes.length == 1) {
        dropTypes = new Transfer[0];
    } else {
        int index = -1;
        for (int i = 0; i < dropTypes.length; i++) {
            if (dropTypes[i] == transfer) {
                index = i;
                break;
            }
        }
        if (index == -1)
            return;
        Transfer[] newTypes = new Transfer[dropTypes.length - 1];
        System.arraycopy(dropTypes, 0, newTypes, 0, index);
        System.arraycopy(dropTypes, index + 1, newTypes, index, dropTypes.length - index - 1);
        dropTypes = newTypes;
    }
    if (dropTarget != null) {
        dropTarget.setTransfer(dropTypes);
    }
}
Also used : URLTransfer(org.eclipse.swt.dnd.URLTransfer) Transfer(org.eclipse.swt.dnd.Transfer) HTMLTransfer(org.eclipse.swt.dnd.HTMLTransfer) RTFTransfer(org.eclipse.swt.dnd.RTFTransfer) TextTransfer(org.eclipse.swt.dnd.TextTransfer) FileTransfer(org.eclipse.swt.dnd.FileTransfer) Point(org.eclipse.swt.graphics.Point)

Aggregations

Transfer (org.eclipse.swt.dnd.Transfer)145 TextTransfer (org.eclipse.swt.dnd.TextTransfer)66 Point (org.eclipse.swt.graphics.Point)61 Clipboard (org.eclipse.swt.dnd.Clipboard)46 Menu (org.eclipse.swt.widgets.Menu)36 IMenuManager (org.eclipse.jface.action.IMenuManager)32 MenuManager (org.eclipse.jface.action.MenuManager)32 LocalSelectionTransfer (org.eclipse.jface.util.LocalSelectionTransfer)32 Separator (org.eclipse.jface.action.Separator)31 EditingDomainViewerDropAdapter (org.eclipse.emf.edit.ui.dnd.EditingDomainViewerDropAdapter)30 LocalTransfer (org.eclipse.emf.edit.ui.dnd.LocalTransfer)30 ViewerDragAdapter (org.eclipse.emf.edit.ui.dnd.ViewerDragAdapter)30 UnwrappingSelectionProvider (org.eclipse.emf.edit.ui.provider.UnwrappingSelectionProvider)30 FileTransfer (org.eclipse.swt.dnd.FileTransfer)30 DropTargetEvent (org.eclipse.swt.dnd.DropTargetEvent)27 DropTarget (org.eclipse.swt.dnd.DropTarget)23 GridData (org.eclipse.swt.layout.GridData)22 GridLayout (org.eclipse.swt.layout.GridLayout)21 Composite (org.eclipse.swt.widgets.Composite)21 DragSourceEvent (org.eclipse.swt.dnd.DragSourceEvent)20