private void createXhtmlTree() { sourcePicker.createXhtmlTree(treesSashForm); // DND support int ops = DND.DROP_COPY | DND.DROP_MOVE; Transfer[] transfers = new Transfer[] {StepSourceTransfer.getInstance()}; DragSource source = new DragSource(sourcePicker.getTwsDomTree().getTree(), ops); source.setTransfer(transfers); source.addDragListener(new DragSourceAdapter() { @Override public void dragStart(DragSourceEvent event) { event.doit = true; StepSourceTransfer.getInstance().setStepSource(sourcePicker.getDragData()); } }); }
private void addDragSupport(final List sourcePackageList, final Combo comboJarList) { DragSource dragSource = ExpressionEditorUtil.INSTANCE.getDragSource(sourcePackageList); dragSource.addDragListener(new DragSourceAdapter() { public void dragSetData(DragSourceEvent event) { event.data = formatDataToTransfer(sourcePackageList.getSelection()); } private Object formatDataToTransfer(String[] selection) { StringBuffer buffer = new StringBuffer(); for (String field : selection) { buffer.append(field + Constants.DOT + Constants.ASTERISK + SWT.SPACE + Constants.DASH + SWT.SPACE + comboJarList.getItem(comboJarList.getSelectionIndex()) + Constants.FIELD_SEPRATOR_FOR_DRAG_DROP); } return buffer.toString(); } }); }
public void applyDragFromTableViewer(Control sourceControl, int index) { Transfer[] types = new Transfer[] { TextTransfer.getInstance() }; final String portLabel = "in" + index + "."; int operations = DND.DROP_MOVE | DND.DROP_COPY | DND.DROP_LINK; final Table table = (Table) sourceControl; DragSource source = new DragSource(table, operations); source.setTransfer(types); final String[] columnData = new String[1]; source.addDragListener(new DragSourceAdapter() { public void dragSetData(DragSourceEvent event) { // Set the data to be the first selected item's text event.data = addDelimeter(portLabel, table.getSelection()); } }); }
void initDragAndDrop() { int operations = DND.DROP_MOVE; Transfer[] transferTypes = new Transfer[]{ LocalSelectionTransfer.getTransfer() }; treeViewer.addDragSupport(operations, transferTypes, new DragSourceAdapter() { @Override public void dragStart(DragSourceEvent event) { LocalSelectionTransfer.getTransfer().setSelection(treeViewer.getSelection()); // not really needed since we can get selection from member variable } // @Override public void dragSetData(DragSourceEvent event) { // } // @Override public void dragFinished(DragSourceEvent event) { // } }); treeViewer.addDropSupport(operations, transferTypes, new StructureTreeDropAdapter(treeViewer)); }
protected DragSourceListener getDragSourceAdapter( final TableViewer inViewer) { return new DragSourceAdapter() { @Override public void dragSetData(final DragSourceEvent inEvent) { final IStructuredSelection lSelected = (IStructuredSelection) inViewer .getSelection(); if (!lSelected.isEmpty()) { final Object[] lItems = lSelected.toArray(); final UniqueID[] lIDs = new UniqueID[lItems.length]; for (int i = 0; i < lItems.length; i++) { final ILightWeightItem lItem = (ILightWeightItem) lItems[i]; lIDs[i] = new UniqueID(lItem.getItemType(), lItem.getID()); } inEvent.data = lIDs; } } }; }
private void addDragSupport() { ExpressionEditorUtil.INSTANCE.getDragSource(methodList).addDragListener(new DragSourceAdapter() { public void dragSetData(DragSourceEvent event) { if (methodList.getItemCount() != 0 && !StringUtils.startsWith(methodList.getItem(0),Messages.CANNOT_SEARCH_INPUT_STRING)) { MethodDetails methodDetails = (MethodDetails) methodList.getData(String.valueOf(methodList .getSelectionIndex())); event.data = methodDetails.getPlaceHolder(); }else event.data=StringUtils.EMPTY+"#"+StringUtils.EMPTY; } }); }
public void addDragSupport(final Control widget) { DragSource dragSource = getDragSource(widget); dragSource.addDragListener(new DragSourceAdapter() { public void dragSetData(DragSourceEvent event) { if (widget instanceof Table) { event.data = formatDataToTransfer(((Table) widget).getSelection()); } if (widget instanceof List) { event.data = formatDataToTransfer(((List) widget).getSelection()); } } }); }
private void attachDragListener() { dragSource = new DragSource(table_1, DND.DROP_MOVE); dragSource.setTransfer(new Transfer[] { TextTransfer.getInstance() }); dragSource.addDragListener(new DragSourceAdapter() { public void dragSetData(DragSourceEvent event) { // Set the data to be the first selected item's text event.data = formatDataToTransfer(table_1.getSelection()); } }); }
private void createSourceTable(Composite composite_2) { sourceTable = new Table(composite_2, SWT.BORDER | SWT.MULTI | SWT.FULL_SELECTION); sourceTable.addMouseListener(new MouseAdapter() { @Override public void mouseDoubleClick(MouseEvent e) { if(sourceTable.getSelection().length==1){ addNewProperty(targetTableViewer, sourceTable.getSelection()[0].getText()); enableControlButtons(); } } }); GridData gd_table = new GridData(SWT.FILL, SWT.FILL, true, true, 1, 2); gd_table.widthHint = 221; gd_table.heightHint = 407; sourceTable.setLayoutData(gd_table); sourceTable.setHeaderVisible(true); sourceTable.setLinesVisible(true); TableColumn sourceTableColumnFieldName = new TableColumn(sourceTable, SWT.LEFT); if(OSValidator.isMac()){ sourceTableColumnFieldName.setWidth(212); }else{ sourceTableColumnFieldName.setWidth(202); } sourceTableColumnFieldName.setText(Messages.AVAILABLE_FIELDS_HEADER); getSourceFieldsFromPropagatedSchema(sourceTable); dragSource = new DragSource(sourceTable, DND.DROP_MOVE); dragSource.setTransfer(new Transfer[] { TextTransfer.getInstance() }); dragSource.addDragListener(new DragSourceAdapter() { public void dragSetData(DragSourceEvent event) { // Set the data to be the first selected item's text event.data = formatDataToTransfer(sourceTable.getSelection()); } }); }
private void addDoubleClickListener(TableViewer availableFieldtableViewer) { DragSource dragSource = new DragSource(availableFieldsTable, DND.DROP_COPY); dragSource.setTransfer(new Transfer[] { ObjectTransfer.getInstance() }); dragSource.addDragListener(new DragSourceAdapter() { public void dragSetData(DragSourceEvent event) { // Set the data to be the first selected item's text List<Object> list=new ArrayList<Object>(); for(TableItem tableItem:availableFieldsTable.getSelection()){ list.add(tableItem.getData()); } event.data=list.toArray(new Object[list.size()]); } }); }
private void addDragListener(Control control) { LocalSelectionTransfer transfer = LocalSelectionTransfer.getTransfer(); DragSourceAdapter dragAdapter = new DragSourceAdapter() { @Override public void dragSetData(DragSourceEvent event) { transfer.setSelection(new StructuredSelection(control)); } }; DragSource dragSource = new DragSource(control, DND.DROP_MOVE | DND.DROP_COPY); dragSource.setTransfer(new Transfer[] { transfer }); dragSource.addDragListener(dragAdapter); }
private void setupAsDragSource() { DragSource source = new DragSource(_table, DND.DROP_MOVE); source.setTransfer(new Transfer[] {TextTransfer.getInstance()}); source.addDragListener(new DragSourceAdapter() { @Override public void dragSetData(DragSourceEvent evt) { if (TextTransfer.getInstance().isSupportedType(evt.dataType)) evt.data = "drag"; } }); }
private void setupAsDragSource() { DragSource source = new DragSource(table, DND.DROP_MOVE); source.setTransfer(new Transfer[] {TextTransfer.getInstance()}); source.addDragListener(new DragSourceAdapter() { @Override public void dragSetData(DragSourceEvent evt) { if (TextTransfer.getInstance().isSupportedType(evt.dataType)) evt.data = "drag"; } }); }
private void addIn0InputFields(Composite inputComposite2) { List<FilterProperties> inputIn0PortFieldList = null; if (lookupMappingGrid != null) { if (lookupMappingGrid.getLookupInputProperties() != null && !lookupMappingGrid.getLookupInputProperties() .isEmpty()) { inputIn0PortFieldList = lookupMappingGrid .getLookupInputProperties().get(0); } else { inputIn0PortFieldList = new ArrayList<>(); } } if (inputPorts != null) { inputPorts.add(inputIn0PortFieldList); if (inputIn0PortFieldList != null) { for (FilterProperties inputField : inputIn0PortFieldList) { allInputFields.add(IN0_PREFIX + inputField.getPropertyname()); } } } TableViewer in0TableViewer = new TableViewer(inputComposite2, SWT.BORDER | SWT.FULL_SELECTION | SWT.MULTI); in0Table = in0TableViewer.getTable(); in0Table.setLinesVisible(true); in0Table.setHeaderVisible(true); in0Table.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true, 1, 1)); in0TableViewer.setContentProvider(new ArrayContentProvider()); TableViewerColumn in0TableViewerColumn = new TableViewerColumn( in0TableViewer, SWT.NONE); TableColumn in0TblclmnInputFields = in0TableViewerColumn.getColumn(); in0TblclmnInputFields.setWidth(230); in0TblclmnInputFields.setText(IN0_HEADER); in0TableViewerColumn.setLabelProvider(new ColumnLabelProvider() { @Override public String getText(Object element) { FilterProperties tableField = (FilterProperties) element; return tableField.getPropertyname(); } }); in0TableViewer.setInput(inputIn0PortFieldList); Transfer[] in0Types = new Transfer[] { TextTransfer.getInstance() }; final String in0PortLabel = IN0_PREFIX; int in0Operations = DND.DROP_MOVE | DND.DROP_COPY | DND.DROP_LINK; // final Table table = (Table) sourceControl; DragSource in0Source = new DragSource(in0Table, in0Operations); in0Source.setTransfer(in0Types); in0Source.addDragListener(new DragSourceAdapter() { public void dragSetData(DragSourceEvent event) { // Set the data to be the first selected item's text event.data = addDelimeter(in0PortLabel, in0Table.getSelection()); } }); }
private void addIn1InputFields(Composite inputComposite2) { List<FilterProperties> inputIn1PortFieldList = null; if (lookupMappingGrid != null) { if (lookupMappingGrid.getLookupInputProperties() != null && !lookupMappingGrid.getLookupInputProperties() .isEmpty()) { inputIn1PortFieldList = lookupMappingGrid .getLookupInputProperties().get(1); } else { inputIn1PortFieldList = new ArrayList<>(); } } if (inputPorts != null) { inputPorts.add(inputIn1PortFieldList); for (FilterProperties inputField : inputIn1PortFieldList) { allInputFields.add(IN1_PREFIX + inputField.getPropertyname()); } } TableViewer in1TableViewer = new TableViewer(inputComposite2, SWT.BORDER | SWT.FULL_SELECTION | SWT.MULTI); in1Table = in1TableViewer.getTable(); in1Table.setHeaderVisible(true); in1Table.setLinesVisible(true); in1Table.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true, 1, 1)); in1TableViewer.setContentProvider(new ArrayContentProvider()); TableViewerColumn in1TableViewerColumn = new TableViewerColumn( in1TableViewer, SWT.NONE); TableColumn in1TblclmnInputFields = in1TableViewerColumn.getColumn(); in1TblclmnInputFields.setWidth(225); in1TblclmnInputFields.setText(IN1_HEADER); in1TableViewerColumn.setLabelProvider(new ColumnLabelProvider() { @Override public String getText(Object element) { FilterProperties tableField = (FilterProperties) element; return tableField.getPropertyname(); } }); in1TableViewer.setInput(inputIn1PortFieldList); Transfer[] in1Types = new Transfer[] { TextTransfer.getInstance() }; final String in1PortLabel = IN1_PREFIX; int in1Operations = DND.DROP_MOVE | DND.DROP_COPY | DND.DROP_LINK; // final Table table = (Table) sourceControl; DragSource in1Source = new DragSource(in1Table, in1Operations); in1Source.setTransfer(in1Types); in1Source.addDragListener(new DragSourceAdapter() { public void dragSetData(DragSourceEvent event) { // Set the data to be the first selected item's text event.data = addDelimeter(in1PortLabel, in1Table.getSelection()); } }); }
private void createButton(final Table table, final TableItem tableItem, final int index, final RGBa color) { TableEditor editor = new TableEditor(table); Button button = new Button(table, SWT.PUSH | SWT.FLAT); Image image = createColorImage(table, color); button.setImage(image); button.pack(); editor.minimumWidth = button.getSize().x - 4; editor.horizontalAlignment = SWT.CENTER; editor.setEditor(button, tableItem, index); fTableEditors.add(editor); button.setData("color", color); //$NON-NLS-1$ button.addSelectionListener(new SelectionAdapter() { @Override public void widgetSelected(SelectionEvent e) { ColorDialog colorDialog = new ColorDialog(table.getShell()); Button self = ((Button) e.widget); RGBa theColor = (RGBa) self.getData("color"); //$NON-NLS-1$ if (theColor == null) { theColor = color; } colorDialog.setRGB(theColor.toRGB()); RGB newRGB = colorDialog.open(); if (newRGB == null) { return; } ThemeRule token = (ThemeRule) tableItem.getData(); RGBa newColor = new RGBa(newRGB); if (index == 1) { getTheme().updateRule(table.indexOf(tableItem), token.updateFG(newColor)); } else { getTheme().updateRule(table.indexOf(tableItem), token.updateBG(newColor)); } // Update the image for this button! self.setImage(createColorImage(table, newColor)); self.setData("color", newColor); //$NON-NLS-1$ tableViewer.refresh(); } }); // Allow dragging the button out of it's location to remove the fg/bg for the rule! Transfer[] types = new Transfer[] { TextTransfer.getInstance() }; final DragSource source = new DragSource(button, DND.DROP_MOVE); source.setTransfer(types); source.addDragListener(new DragSourceAdapter() { public void dragSetData(DragSourceEvent event) { event.data = "button:" + table.indexOf(tableItem) + ":" + index; //$NON-NLS-1$ //$NON-NLS-2$ } }); }