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;
}
});
}
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));
}
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();
}
}
};
}
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);
}
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);
}
}
Aggregations