本文整理汇总了Java中org.eclipse.swt.dnd.DropTargetAdapter类的典型用法代码示例。如果您正苦于以下问题:Java DropTargetAdapter类的具体用法?Java DropTargetAdapter怎么用?Java DropTargetAdapter使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
DropTargetAdapter类属于org.eclipse.swt.dnd包,在下文中一共展示了DropTargetAdapter类的12个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: attachDropListener
import org.eclipse.swt.dnd.DropTargetAdapter; //导入依赖的package包/类
private void attachDropListener() {
dropTarget = new DropTarget(targetTable, DND.DROP_MOVE);
dropTarget.setTransfer(new Transfer[] { TextTransfer.getInstance() });
dropTarget.addDropListener(new DropTargetAdapter() {
public void drop(DropTargetEvent event) {
for (String fieldName : getformatedData((String) event.data)) {
if(isPropertyAlreadyExists(fieldName)){
return;
}else{
ExcelConfigurationDataStructure excelConfigurationDataStructure = new ExcelConfigurationDataStructure();
excelConfigurationDataStructure.setFieldName(fieldName);
listOfExcelConfiguration.add(excelConfigurationDataStructure);
targetTableViewer.refresh();
draggedFields.add(fieldName);
enableDeleteButton();
}
}
combo.setItems(convertToArray(draggedFields));
combo.select(0);
top_composite.layout();
top_composite.getParent().layout();
highlightDropFields();
}
});
}
示例2: createPartControl
import org.eclipse.swt.dnd.DropTargetAdapter; //导入依赖的package包/类
@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);
}
}
}
});
}
示例3: setupFileDrop
import org.eclipse.swt.dnd.DropTargetAdapter; //导入依赖的package包/类
public static void setupFileDrop(Control ctrl)
{
DropTarget dt = new DropTarget(ctrl, DND.DROP_DEFAULT | DND.DROP_MOVE);
dt.setTransfer(new Transfer[] {FileTransfer.getInstance()});
dt.addDropListener(new DropTargetAdapter() {
public void drop(DropTargetEvent event)
{
FileTransfer ft = FileTransfer.getInstance();
if (ft.isSupportedType(event.currentDataType))
{
String[] files = (String[]) event.data;
for (String file : files)
{
if (file.toLowerCase().endsWith(".eml"))
ImportExportUtilities.importFromEmailFile(file);
else if (file.toLowerCase().endsWith(".mbx"))
ImportExportUtilities.importFromMbox(file);
}
}
}
});
}
示例4: addDropSupport
import org.eclipse.swt.dnd.DropTargetAdapter; //导入依赖的package包/类
public static void addDropSupport(TreeViewer tree,
final IModelDropHandler handler) {
final Transfer transfer = ModelTransfer.getInstance();
DropTarget dropTarget = new DropTarget(tree.getTree(), DND.DROP_COPY
| DND.DROP_MOVE | DND.DROP_DEFAULT);
dropTarget.setTransfer(new Transfer[] { transfer });
dropTarget.addDropListener(new DropTargetAdapter() {
@Override
public void drop(DropTargetEvent event) {
if (!transfer.isSupportedType(event.currentDataType))
return;
List<BaseDescriptor> list = ModelTransfer
.getBaseDescriptors(event.data);
handler.handleDrop(list);
}
});
}
示例5: addDropSupport
import org.eclipse.swt.dnd.DropTargetAdapter; //导入依赖的package包/类
private void addDropSupport() {
DropTarget dropTarget = new DropTarget(targetList, DND.DROP_MOVE);
dropTarget.setTransfer(new Transfer[] { TextTransfer.getInstance() });
dropTarget.addDropListener(new DropTargetAdapter() {
public void drop(DropTargetEvent event) {
for (String formattedPackageName : ExpressionEditorUtil.INSTANCE.getformatedData((String) event.data)) {
if (isFieldAvailable(formattedPackageName)){
targetList.add(formattedPackageName);
removeAddedPackageNameFromSourceList(formattedPackageName);
categoriesDialogSourceComposite.enableOrDisableAddLabelsOnComboSelection();
}
}
}
});
}
示例6: addDropSupport
import org.eclipse.swt.dnd.DropTargetAdapter; //导入依赖的package包/类
private void addDropSupport() {
DropTarget dropTarget = new DropTarget(expressionEditor, DND.DROP_MOVE);
dropTarget.setTransfer(new Transfer[] { TextTransfer.getInstance() });
dropTarget.addDropListener(new DropTargetAdapter() {
public void drop(DropTargetEvent event) {
for (String fieldName :ExpressionEditorUtil.INSTANCE.getformatedData((String) event.data)){
expressionEditor.insert(SWT.SPACE+fieldName+SWT.SPACE);
}
}
});
}
示例7: createPartControl
import org.eclipse.swt.dnd.DropTargetAdapter; //导入依赖的package包/类
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], false))
event.detail = DND.DROP_NONE;
}
});
// fill the menues
makeActions();
hookContextMenu();
contributeToActionBars();
openAllLastOpenFiles();
}
示例8: initDragAndDrop
import org.eclipse.swt.dnd.DropTargetAdapter; //导入依赖的package包/类
private void initDragAndDrop() {
for (int i= 0; i < fAllViewers.length; i++) {
addDragAdapters(fAllViewers[i]);
addDropAdapters(fAllViewers[i]);
}
addDragAdapters(fMethodsViewer);
fMethodsViewer.addDropSupport(DND.DROP_NONE, new Transfer[0], new DropTargetAdapter());
//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 TypeHierarchyTransferDropAdapter(this, fAllViewers[0]));
}
示例9: addDropListener
import org.eclipse.swt.dnd.DropTargetAdapter; //导入依赖的package包/类
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);
}
示例10: addDropSupport
import org.eclipse.swt.dnd.DropTargetAdapter; //导入依赖的package包/类
public static void addDropSupport(TableViewer table, IModelDropHandler handler) {
final Transfer transfer = ModelTransfer.getInstance();
DropTarget dropTarget = new DropTarget(table.getTable(), DND.DROP_COPY | DND.DROP_MOVE | DND.DROP_DEFAULT);
dropTarget.setTransfer(new Transfer[] { transfer });
dropTarget.addDropListener(new DropTargetAdapter() {
@Override
public void drop(DropTargetEvent event) {
if (!transfer.isSupportedType(event.currentDataType))
return;
List<BaseDescriptor> list = ModelTransfer
.getBaseDescriptors(event.data);
handler.handleDrop(list);
}
});
}
示例11: createTargetTable
import org.eclipse.swt.dnd.DropTargetAdapter; //导入依赖的package包/类
private void createTargetTable(Composite container) {
targetTableViewer = new TableViewer(container, SWT.BORDER | SWT.MULTI | SWT.FULL_SELECTION);
targetTable = targetTableViewer.getTable();
GridData gd_table_1 = new GridData(SWT.FILL, SWT.FILL, true, true, 1, 2);
gd_table_1.heightHint = 401;
if(OSValidator.isMac()){
gd_table_1.widthHint = 363;
}else{
gd_table_1.widthHint = 352;
}
targetTable.setLayoutData(gd_table_1);
attachTargetTableListeners();
targetTableViewer.setContentProvider(new SecondaryColumnKeysContentProvider());
targetTableViewer.setLabelProvider(new SecondaryColumnKeysLabelProvider());
targetTableViewer.setInput(propertyList);
TableColumn targetTableColumnFieldName = new TableColumn(targetTable, SWT.LEFT);
targetTableColumnFieldName.setText(COLUMNNAME); //$NON-NLS-1$
TableColumn targetTableColumnSortOrder = new TableColumn(targetTable, SWT.LEFT_TO_RIGHT);
targetTableColumnSortOrder.setText(SORTORDER); //$NON-NLS-1$
for (int i = 0, n = targetTable.getColumnCount(); i < n; i++) {
targetTable.getColumn(i).pack();
}
targetTableColumnFieldName.setWidth(175);
if(OSValidator.isMac()){
targetTableColumnSortOrder.setWidth(128);
}else{
targetTableColumnSortOrder.setWidth(116);
}
targetTable.setHeaderVisible(true);
targetTable.setLinesVisible(true);
// enables the tab functionality
TableViewerEditor.create(targetTableViewer, new ColumnViewerEditorActivationStrategy(targetTableViewer),
ColumnViewerEditor.KEYBOARD_ACTIVATION | ColumnViewerEditor.TABBING_HORIZONTAL
| ColumnViewerEditor.TABBING_MOVE_TO_ROW_NEIGHBOR | ColumnViewerEditor.TABBING_VERTICAL);
final CellEditor propertyNameeditor = new TextCellEditor(targetTable);
ComboBoxViewerCellEditor propertyValueeditor = new ComboBoxViewerCellEditor(targetTable, SWT.READ_ONLY);
propertyValueeditor.setContentProvider(new ArrayContentProvider());
propertyValueeditor.setLabelProvider(new LabelProvider());
propertyValueeditor.setInput(new String[] { Constants.ASCENDING_SORT_ORDER, Constants.DESCENDING_SORT_ORDER, Constants.NONE_SORT_ORDER });
CellEditor[] editors = new CellEditor[] { propertyNameeditor, propertyValueeditor };
propertyNameeditor.setValidator(createNameEditorValidator(Messages.EmptyColumnNotification));
propertyValueeditor.setValidator(createValueEditorValidator(Messages.EmptySortOrderNotification));
targetTableViewer.setColumnProperties(PROPS);
targetTableViewer.setCellModifier(new SecondaryColumnKeysWidgetCellModifier(targetTableViewer));
targetTableViewer.setCellEditors(editors);
loadProperties(targetTableViewer);
if (propertyList.size() != 0) {
deleteButton.setEnabled(true);
}
if (propertyList.size() >= 2) {
upButton.setEnabled(true);
downButton.setEnabled(true);
}
dropTarget = new DropTarget(targetTable, DND.DROP_MOVE);
dropTarget.setTransfer(new Transfer[] { TextTransfer.getInstance() });
dropTarget.addDropListener(new DropTargetAdapter() {
public void drop(DropTargetEvent event) {
for (String fieldName : getformatedData((String) event.data))
addNewProperty(targetTableViewer, fieldName);
enableControlButtons();
}
});
}
示例12: getDropTargetListener
import org.eclipse.swt.dnd.DropTargetAdapter; //导入依赖的package包/类
protected DropTargetAdapter getDropTargetListener() {
return new ExampleDropTargetListener();
}