use of org.eclipse.swt.dnd.DragSource in project webtools.sourceediting by eclipse.
the class ConfigurableContentOutlinePage method createControl.
/**
* @see ContentOutlinePage#createControl
*/
public void createControl(Composite parent) {
super.createControl(parent);
getTreeViewer().setUseHashlookup(true);
ColumnViewerToolTipSupport.enableFor(getTreeViewer());
IWorkbenchPage page = getSite().getWorkbenchWindow().getActivePage();
if (page != null) {
fEditor = page.getActiveEditor();
}
fDragAdapter = new DelegatingDragAdapter();
fDragSource = new DragSource(getControl(), DND.DROP_COPY | DND.DROP_MOVE);
fDropAdapter = new DelegatingDropAdapter();
fDropTarget = new DropTarget(getControl(), DND.DROP_COPY | DND.DROP_MOVE);
setConfiguration(getConfiguration());
/*
* ContentOutlinePage only implements ISelectionProvider while the
* tree viewer implements both ISelectionProvider and
* IPostSelectionProvider. Use an ISelectionProvider that listens to
* post selection from the tree viewer and forward only post selection
* to the selection service.
*/
getTreeViewer().addPostSelectionChangedListener(fSelectionProvider.getPostSelectionChangedListener());
getTreeViewer().addSelectionChangedListener(fSelectionProvider.getSelectionChangedListener());
if (fDoubleClickProvider == null) {
fDoubleClickProvider = new DoubleClickProvider();
}
getTreeViewer().addDoubleClickListener(fDoubleClickProvider);
getSite().setSelectionProvider(fSelectionProvider);
}
use of org.eclipse.swt.dnd.DragSource in project tdq-studio-se by Talend.
the class ExpressionEditDialog method createTemplatesTablePart.
/**
* create templates Table Part(only TAB0 use old paramaters, and others use new paramaters)
*
* @param sform
*/
public void createTemplatesTablePart(SashForm sform) {
GridData data;
final Table templatesTable = new Table(sform, SWT.MULTI | SWT.BORDER | SWT.FULL_SELECTION);
templatesTable.setLinesVisible(false);
templatesTable.setHeaderVisible(true);
data = new GridData(SWT.FILL, SWT.FILL, true, true);
data.heightHint = 200;
templatesTable.setLayoutData(data);
DragSource ds = new DragSource(templatesTable, DND.DROP_MOVE);
ds.setTransfer(new Transfer[] { TextTransfer.getInstance() });
ds.addDragListener(new DragSourceAdapter() {
@Override
public void dragSetData(DragSourceEvent event) {
event.data = templatesTable.getSelection()[0].getText();
}
});
TableColumn column = new TableColumn(templatesTable, SWT.NONE);
column.setText(TEMPLATES_TITLE);
for (String template : templates) {
TableItem item = new TableItem(templatesTable, SWT.NONE);
item.setText(0, template);
}
templatesTable.getColumn(0).pack();
}
use of org.eclipse.swt.dnd.DragSource in project tdq-studio-se by Talend.
the class ComparisonTableViewerDNDDecorate method installDragListener.
private void installDragListener(final TableViewer targetViewer, int operations) {
final Table table = targetViewer.getTable();
final DragSource source = new DragSource(table, operations);
source.setTransfer(transferTypes);
final TableItem[] dragSourceItem = new TableItem[1];
source.addDragListener(new DragSourceListener() {
public void dragStart(DragSourceEvent event) {
TableItem[] selection = table.getSelection();
if (selection.length > 0) {
event.doit = true;
dragSourceItem[0] = selection[0];
dragSelectedElement = ((IStructuredSelection) targetViewer.getSelection()).getFirstElement();
} else {
event.doit = false;
}
}
public void dragSetData(DragSourceEvent event) {
dragSelectedElement = ((IStructuredSelection) targetViewer.getSelection()).getFirstElement();
event.data = dragSourceItem[0].getText();
}
public void dragFinished(DragSourceEvent event) {
}
});
}
use of org.eclipse.swt.dnd.DragSource in project pentaho-kettle by pentaho.
the class RipDatabaseWizardPage2 method createControl.
public void createControl(Composite parent) {
shell = parent.getShell();
int margin = Const.MARGIN;
// create the composite to hold the widgets
Composite composite = new Composite(parent, SWT.NONE);
props.setLook(composite);
FormLayout compLayout = new FormLayout();
compLayout.marginHeight = Const.FORM_MARGIN;
compLayout.marginWidth = Const.FORM_MARGIN;
composite.setLayout(compLayout);
// Put it all on the composite!
// //////////////////////////////////////////////////
// Top & Bottom regions.
// //////////////////////////////////////////////////
Composite top = new Composite(composite, SWT.NONE);
FormLayout topLayout = new FormLayout();
topLayout.marginHeight = margin;
topLayout.marginWidth = margin;
top.setLayout(topLayout);
FormData fdTop = new FormData();
fdTop.left = new FormAttachment(0, 0);
fdTop.top = new FormAttachment(0, 0);
fdTop.right = new FormAttachment(100, 0);
fdTop.bottom = new FormAttachment(100, -50);
top.setLayoutData(fdTop);
props.setLook(top);
Composite bottom = new Composite(composite, SWT.NONE);
bottom.setLayout(new FormLayout());
FormData fdBottom = new FormData();
fdBottom.left = new FormAttachment(0, 0);
fdBottom.top = new FormAttachment(top, 0);
fdBottom.right = new FormAttachment(100, 0);
fdBottom.bottom = new FormAttachment(100, 0);
bottom.setLayoutData(fdBottom);
props.setLook(bottom);
// //////////////////////////////////////////////////
// Sashform
// //////////////////////////////////////////////////
SashForm sashform = new SashForm(top, SWT.HORIZONTAL);
sashform.setLayout(new FormLayout());
FormData fdSashform = new FormData();
fdSashform.left = new FormAttachment(0, 0);
fdSashform.top = new FormAttachment(0, 0);
fdSashform.right = new FormAttachment(100, 0);
fdSashform.bottom = new FormAttachment(100, 0);
sashform.setLayoutData(fdSashform);
// ////////////////////////
// / LEFT
// ////////////////////////
Composite leftsplit = new Composite(sashform, SWT.NONE);
leftsplit.setLayout(new FormLayout());
FormData fdLeftsplit = new FormData();
fdLeftsplit.left = new FormAttachment(0, 0);
fdLeftsplit.top = new FormAttachment(0, 0);
fdLeftsplit.right = new FormAttachment(100, 0);
fdLeftsplit.bottom = new FormAttachment(100, 0);
leftsplit.setLayoutData(fdLeftsplit);
props.setLook(leftsplit);
// Source list to the left...
wlListSource = new Label(leftsplit, SWT.NONE);
wlListSource.setText("Available items:");
props.setLook(wlListSource);
FormData fdlListSource = new FormData();
fdlListSource.left = new FormAttachment(0, 0);
fdlListSource.top = new FormAttachment(0, 0);
wlListSource.setLayoutData(fdlListSource);
wListSource = new List(leftsplit, SWT.BORDER | SWT.MULTI | SWT.V_SCROLL | SWT.H_SCROLL);
props.setLook(wListSource);
FormData fdListSource = new FormData();
fdListSource.left = new FormAttachment(0, 0);
fdListSource.top = new FormAttachment(wlListSource, 0);
fdListSource.right = new FormAttachment(100, 0);
fdListSource.bottom = new FormAttachment(100, 0);
wListSource.setLayoutData(fdListSource);
// /////////////////////////
// MIDDLE
// /////////////////////////
Composite compmiddle = new Composite(sashform, SWT.NONE);
compmiddle.setLayout(new FormLayout());
FormData fdCompMiddle = new FormData();
fdCompMiddle.left = new FormAttachment(0, 0);
fdCompMiddle.top = new FormAttachment(0, 0);
fdCompMiddle.right = new FormAttachment(100, 0);
fdCompMiddle.bottom = new FormAttachment(100, 0);
compmiddle.setLayoutData(fdCompMiddle);
props.setLook(compmiddle);
wAddOne = new Button(compmiddle, SWT.PUSH);
wAddOne.setText(" > ");
wAddOne.setToolTipText("Add the selected items on the left.");
wAddAll = new Button(compmiddle, SWT.PUSH);
wAddAll.setText(" >> ");
wAddAll.setToolTipText("Add all items on the left.");
wRemoveOne = new Button(compmiddle, SWT.PUSH);
wRemoveOne.setText(" < ");
wRemoveOne.setToolTipText("Remove the selected items on the right.");
wRemoveAll = new Button(compmiddle, SWT.PUSH);
wRemoveAll.setText(" << ");
wRemoveAll.setToolTipText("Add all items on the right.");
FormData fdAddOne = new FormData();
fdAddOne.left = new FormAttachment(compmiddle, 0, SWT.CENTER);
fdAddOne.top = new FormAttachment(30, 0);
wAddOne.setLayoutData(fdAddOne);
FormData fdAddAll = new FormData();
fdAddAll.left = new FormAttachment(compmiddle, 0, SWT.CENTER);
fdAddAll.top = new FormAttachment(wAddOne, margin);
wAddAll.setLayoutData(fdAddAll);
FormData fdRemoveAll = new FormData();
fdRemoveAll.left = new FormAttachment(compmiddle, 0, SWT.CENTER);
fdRemoveAll.top = new FormAttachment(wAddAll, margin);
wRemoveAll.setLayoutData(fdRemoveAll);
FormData fdRemoveOne = new FormData();
fdRemoveOne.left = new FormAttachment(compmiddle, 0, SWT.CENTER);
fdRemoveOne.top = new FormAttachment(wRemoveAll, margin);
wRemoveOne.setLayoutData(fdRemoveOne);
// ///////////////////////////////
// RIGHT
// ///////////////////////////////
Composite rightsplit = new Composite(sashform, SWT.NONE);
rightsplit.setLayout(new FormLayout());
FormData fdRightsplit = new FormData();
fdRightsplit.left = new FormAttachment(0, 0);
fdRightsplit.top = new FormAttachment(0, 0);
fdRightsplit.right = new FormAttachment(100, 0);
fdRightsplit.bottom = new FormAttachment(100, 0);
rightsplit.setLayoutData(fdRightsplit);
props.setLook(rightsplit);
wlListDest = new Label(rightsplit, SWT.NONE);
wlListDest.setText("Your selection:");
props.setLook(wlListDest);
FormData fdlListDest = new FormData();
fdlListDest.left = new FormAttachment(0, 0);
fdlListDest.top = new FormAttachment(0, 0);
wlListDest.setLayoutData(fdlListDest);
wListDest = new List(rightsplit, SWT.BORDER | SWT.MULTI | SWT.V_SCROLL | SWT.H_SCROLL);
props.setLook(wListDest);
FormData fdListDest = new FormData();
fdListDest.left = new FormAttachment(0, 0);
fdListDest.top = new FormAttachment(wlListDest, 0);
fdListDest.right = new FormAttachment(100, 0);
fdListDest.bottom = new FormAttachment(100, 0);
wListDest.setLayoutData(fdListDest);
sashform.setWeights(new int[] { 45, 10, 45 });
// Drag & Drop for steps
Transfer[] ttypes = new Transfer[] { TextTransfer.getInstance() };
DragSource ddSource = new DragSource(wListSource, DND.DROP_MOVE | DND.DROP_COPY);
ddSource.setTransfer(ttypes);
ddSource.addDragListener(new DragSourceListener() {
public void dragStart(DragSourceEvent event) {
}
public void dragSetData(DragSourceEvent event) {
String[] ti = wListSource.getSelection();
String data = new String();
for (int i = 0; i < ti.length; i++) {
data += ti[i] + Const.CR;
}
event.data = data;
}
public void dragFinished(DragSourceEvent event) {
}
});
DropTarget ddTarget = new DropTarget(wListDest, DND.DROP_MOVE | DND.DROP_COPY);
ddTarget.setTransfer(ttypes);
ddTarget.addDropListener(new DropTargetListener() {
public void dragEnter(DropTargetEvent event) {
}
public void dragLeave(DropTargetEvent event) {
}
public void dragOperationChanged(DropTargetEvent event) {
}
public void dragOver(DropTargetEvent event) {
}
public void drop(DropTargetEvent event) {
if (event.data == null) {
// no data to copy, indicate failure in event.detail
event.detail = DND.DROP_NONE;
return;
}
StringTokenizer strtok = new StringTokenizer((String) event.data, Const.CR);
while (strtok.hasMoreTokens()) {
String source = strtok.nextToken();
addToDestination(source);
}
}
public void dropAccept(DropTargetEvent event) {
}
});
wListSource.addKeyListener(new KeyAdapter() {
public void keyPressed(KeyEvent e) {
if (e.character == SWT.CR) {
addToSelection(wListSource.getSelection());
}
}
});
wListDest.addKeyListener(new KeyAdapter() {
public void keyPressed(KeyEvent e) {
if (e.character == SWT.CR) {
delFromSelection(wListDest.getSelection());
}
}
});
// Double click adds to destination.
wListSource.addSelectionListener(new SelectionAdapter() {
public void widgetDefaultSelected(SelectionEvent e) {
addToSelection(wListSource.getSelection());
}
});
// Double click adds to source
wListDest.addSelectionListener(new SelectionAdapter() {
public void widgetDefaultSelected(SelectionEvent e) {
String[] sel = wListDest.getSelection();
delFromSelection(sel);
}
});
wAddOne.addSelectionListener(new SelectionAdapter() {
public void widgetSelected(SelectionEvent e) {
addToSelection(wListSource.getSelection());
}
});
wRemoveOne.addSelectionListener(new SelectionAdapter() {
public void widgetSelected(SelectionEvent e) {
delFromSelection(wListDest.getSelection());
}
});
wAddAll.addSelectionListener(new SelectionAdapter() {
public void widgetSelected(SelectionEvent e) {
addAllToSelection();
}
});
wRemoveAll.addSelectionListener(new SelectionAdapter() {
public void widgetSelected(SelectionEvent e) {
removeAllFromSelection();
}
});
// set the composite as the control for this page
setControl(composite);
}
use of org.eclipse.swt.dnd.DragSource in project pentaho-kettle by pentaho.
the class UserDefinedJavaClassDialog method open.
public String open() {
Shell parent = getParent();
Display display = parent.getDisplay();
shell = new Shell(parent, SWT.DIALOG_TRIM | SWT.RESIZE | SWT.MAX | SWT.MIN);
props.setLook(shell);
setShellImage(shell, input);
lsMod = new ModifyListener() {
public void modifyText(ModifyEvent e) {
input.setChanged();
}
};
changed = input.hasChanged();
FormLayout formLayout = new FormLayout();
formLayout.marginWidth = Const.FORM_MARGIN;
formLayout.marginHeight = Const.FORM_MARGIN;
shell.setLayout(formLayout);
shell.setText(BaseMessages.getString(PKG, "UserDefinedJavaClassDialog.Shell.Title"));
middle = props.getMiddlePct();
margin = Const.MARGIN;
// Filename line
wlStepname = new Label(shell, SWT.RIGHT);
wlStepname.setText(BaseMessages.getString(PKG, "UserDefinedJavaClassDialog.Stepname.Label"));
props.setLook(wlStepname);
fdlStepname = new FormData();
fdlStepname.left = new FormAttachment(0, 0);
fdlStepname.right = new FormAttachment(middle, -margin);
fdlStepname.top = new FormAttachment(0, margin);
wlStepname.setLayoutData(fdlStepname);
wStepname = new Text(shell, SWT.SINGLE | SWT.LEFT | SWT.BORDER);
wStepname.setText(stepname);
props.setLook(wStepname);
wStepname.addModifyListener(lsMod);
fdStepname = new FormData();
fdStepname.left = new FormAttachment(middle, 0);
fdStepname.top = new FormAttachment(0, margin);
fdStepname.right = new FormAttachment(100, 0);
wStepname.setLayoutData(fdStepname);
wSash = new SashForm(shell, SWT.VERTICAL);
// Top sash form
//
Composite wTop = new Composite(wSash, SWT.NONE);
props.setLook(wTop);
FormLayout topLayout = new FormLayout();
topLayout.marginWidth = Const.FORM_MARGIN;
topLayout.marginHeight = Const.FORM_MARGIN;
wTop.setLayout(topLayout);
// Script line
Label wlScriptFunctions = new Label(wTop, SWT.NONE);
wlScriptFunctions.setText(BaseMessages.getString(PKG, "UserDefinedJavaClassDialog.ClassesAndSnippits.Label"));
props.setLook(wlScriptFunctions);
FormData fdlScriptFunctions = new FormData();
fdlScriptFunctions.left = new FormAttachment(0, 0);
fdlScriptFunctions.top = new FormAttachment(0, 0);
wlScriptFunctions.setLayoutData(fdlScriptFunctions);
// Tree View Test
wTree = new Tree(wTop, SWT.BORDER | SWT.H_SCROLL | SWT.V_SCROLL);
props.setLook(wTree);
FormData fdlTree = new FormData();
fdlTree.left = new FormAttachment(0, 0);
fdlTree.top = new FormAttachment(wlScriptFunctions, margin);
fdlTree.right = new FormAttachment(20, 0);
fdlTree.bottom = new FormAttachment(100, -margin);
wTree.setLayoutData(fdlTree);
// Script line
Label wlScript = new Label(wTop, SWT.NONE);
wlScript.setText(BaseMessages.getString(PKG, "UserDefinedJavaClassDialog.Class.Label"));
props.setLook(wlScript);
FormData fdlScript = new FormData();
fdlScript.left = new FormAttachment(wTree, margin);
fdlScript.top = new FormAttachment(0, 0);
wlScript.setLayoutData(fdlScript);
folder = new CTabFolder(wTop, SWT.BORDER | SWT.RESIZE);
folder.setSimple(false);
folder.setUnselectedImageVisible(true);
folder.setUnselectedCloseVisible(true);
FormData fdScript = new FormData();
fdScript.left = new FormAttachment(wTree, margin);
fdScript.top = new FormAttachment(wlScript, margin);
fdScript.right = new FormAttachment(100, -5);
fdScript.bottom = new FormAttachment(100, -50);
folder.setLayoutData(fdScript);
wlPosition = new Label(wTop, SWT.NONE);
wlPosition.setText(BaseMessages.getString(PKG, "UserDefinedJavaClassDialog.Position.Label"));
props.setLook(wlPosition);
FormData fdlPosition = new FormData();
fdlPosition.left = new FormAttachment(wTree, margin);
fdlPosition.right = new FormAttachment(30, 0);
fdlPosition.top = new FormAttachment(folder, margin);
wlPosition.setLayoutData(fdlPosition);
wlHelpLabel = new Text(wTop, SWT.V_SCROLL | SWT.LEFT);
wlHelpLabel.setEditable(false);
wlHelpLabel.setText("Hallo");
props.setLook(wlHelpLabel);
FormData fdHelpLabel = new FormData();
fdHelpLabel.left = new FormAttachment(wlPosition, margin);
fdHelpLabel.top = new FormAttachment(folder, margin);
fdHelpLabel.right = new FormAttachment(100, -5);
fdHelpLabel.bottom = new FormAttachment(100, 0);
wlHelpLabel.setLayoutData(fdHelpLabel);
wlHelpLabel.setVisible(false);
FormData fdTop = new FormData();
fdTop.left = new FormAttachment(0, 0);
fdTop.top = new FormAttachment(0, 0);
fdTop.right = new FormAttachment(100, 0);
fdTop.bottom = new FormAttachment(100, 0);
wTop.setLayoutData(fdTop);
//
// Add a tab folder for the parameters and various input and output
// streams
//
wTabFolder = new CTabFolder(wSash, SWT.BORDER);
props.setLook(wTabFolder, Props.WIDGET_STYLE_TAB);
wTabFolder.setSimple(false);
wTabFolder.setUnselectedCloseVisible(false);
FormData fdTabFolder = new FormData();
fdTabFolder.left = new FormAttachment(0, 0);
fdTabFolder.right = new FormAttachment(100, 0);
fdTabFolder.top = new FormAttachment(0, 0);
fdTabFolder.bottom = new FormAttachment(100, -75);
wTabFolder.setLayoutData(fdTabFolder);
// The Fields tab...
//
addFieldsTab();
// The parameters
//
addParametersTab();
prevStepNames = transMeta.getPrevStepNames(stepMeta);
nextStepNames = transMeta.getNextStepNames(stepMeta);
// OK, add another tab for the input settings...
//
addInfoTab();
addTargetTab();
// Select the fields tab...
//
wTabFolder.setSelection(fieldsTab);
FormData fdSash = new FormData();
fdSash.left = new FormAttachment(0, 0);
fdSash.top = new FormAttachment(wStepname, 0);
fdSash.right = new FormAttachment(100, 0);
fdSash.bottom = new FormAttachment(100, -50);
wSash.setLayoutData(fdSash);
wSash.setWeights(new int[] { 75, 25 });
wOK = new Button(shell, SWT.PUSH);
wOK.setText(BaseMessages.getString(PKG, "System.Button.OK"));
wTest = new Button(shell, SWT.PUSH);
wTest.setText(BaseMessages.getString(PKG, "UserDefinedJavaClassDialog.TestClass.Button"));
// wCreatePlugin = new Button(shell, SWT.PUSH);
// wCreatePlugin.setText("Create Plug-in");
wCancel = new Button(shell, SWT.PUSH);
wCancel.setText(BaseMessages.getString(PKG, "System.Button.Cancel"));
setButtonPositions(new Button[] { wOK, wCancel, wTest /* , wCreatePlugin */
}, margin, null);
lsCancel = new Listener() {
public void handleEvent(Event e) {
cancel();
}
};
lsTest = new Listener() {
public void handleEvent(Event e) {
test();
}
};
lsOK = new Listener() {
public void handleEvent(Event e) {
ok();
}
};
lsTree = new Listener() {
public void handleEvent(Event e) {
treeDblClick(e);
}
};
/*
* lsCreatePlugin = new Listener() { public void handleEvent(Event e) { createPlugin(); } };
*/
wCancel.addListener(SWT.Selection, lsCancel);
wTest.addListener(SWT.Selection, lsTest);
wOK.addListener(SWT.Selection, lsOK);
// wCreatePlugin.addListener(SWT.Selection, lsCreatePlugin);
wTree.addListener(SWT.MouseDoubleClick, lsTree);
lsDef = new SelectionAdapter() {
public void widgetDefaultSelected(SelectionEvent e) {
ok();
}
};
wStepname.addSelectionListener(lsDef);
// Detect X or ALT-F4 or something that kills this window...
shell.addShellListener(new ShellAdapter() {
public void shellClosed(ShellEvent e) {
if (!cancel()) {
e.doit = false;
}
}
});
folder.addCTabFolder2Listener(new CTabFolder2Adapter() {
public void close(CTabFolderEvent event) {
CTabItem cItem = (CTabItem) event.item;
event.doit = false;
if (cItem != null && folder.getItemCount() > 1) {
MessageBox messageBox = new MessageBox(shell, SWT.ICON_QUESTION | SWT.NO | SWT.YES);
messageBox.setText(BaseMessages.getString(PKG, "UserDefinedJavaClassDialog.DeleteItem.Label"));
messageBox.setMessage(BaseMessages.getString(PKG, "UserDefinedJavaClassDialog.ConfirmDeleteItem.Label", cItem.getText()));
switch(messageBox.open()) {
case SWT.YES:
modifyTabTree(cItem, TabActions.DELETE_ITEM);
event.doit = true;
break;
default:
break;
}
}
}
});
cMenu = new Menu(shell, SWT.POP_UP);
buildingFolderMenu();
tMenu = new Menu(shell, SWT.POP_UP);
buildingTreeMenu();
// Adding the Default Transform Class Item to the Tree
wTreeClassesItem = new TreeItem(wTree, SWT.NULL);
wTreeClassesItem.setImage(guiResource.getImageBol());
wTreeClassesItem.setText(BaseMessages.getString(PKG, "UserDefinedJavaClassDialog.Classes.Label"));
// Set the shell size, based upon previous time...
setSize();
getData();
// Adding the Rest (Functions, InputItems, etc.) to the Tree
buildSnippitsTree();
// Input Fields
itemInput = new TreeItem(wTree, SWT.NULL);
itemInput.setImage(imageInputFields);
itemInput.setText(BaseMessages.getString(PKG, "UserDefinedJavaClassDialog.InputFields.Label"));
itemInput.setData("Field Helpers");
// Info Fields
itemInfo = new TreeItem(wTree, SWT.NULL);
itemInfo.setImage(imageInputFields);
itemInfo.setText(BaseMessages.getString(PKG, "UserDefinedJavaClassDialog.InfoFields.Label"));
itemInfo.setData("Field Helpers");
// Output Fields
itemOutput = new TreeItem(wTree, SWT.NULL);
itemOutput.setImage(imageOutputFields);
itemOutput.setText(BaseMessages.getString(PKG, "UserDefinedJavaClassDialog.OutputFields.Label"));
itemOutput.setData("Field Helpers");
// Display waiting message for input
itemWaitFieldsIn = new TreeItem(itemInput, SWT.NULL);
itemWaitFieldsIn.setText(BaseMessages.getString(PKG, "UserDefinedJavaClassDialog.GettingFields.Label"));
itemWaitFieldsIn.setForeground(guiResource.getColorDirectory());
itemInput.setExpanded(true);
// Display waiting message for info
itemWaitFieldsInfo = new TreeItem(itemInfo, SWT.NULL);
itemWaitFieldsInfo.setText(BaseMessages.getString(PKG, "UserDefinedJavaClassDialog.GettingFields.Label"));
itemWaitFieldsInfo.setForeground(guiResource.getColorDirectory());
itemInfo.setExpanded(true);
// Display waiting message for output
itemWaitFieldsOut = new TreeItem(itemOutput, SWT.NULL);
itemWaitFieldsOut.setText(BaseMessages.getString(PKG, "UserDefinedJavaClassDialog.GettingFields.Label"));
itemWaitFieldsOut.setForeground(guiResource.getColorDirectory());
itemOutput.setExpanded(true);
//
// Search the fields in the background
//
final Runnable runnable = new Runnable() {
public void run() {
StepMeta stepMeta = transMeta.findStep(stepname);
if (stepMeta != null) {
try {
inputRowMeta = transMeta.getPrevStepFields(stepMeta);
infoRowMeta = transMeta.getPrevInfoFields(stepMeta);
outputRowMeta = transMeta.getThisStepFields(stepMeta, null, inputRowMeta.clone());
populateFieldsTree();
} catch (KettleException e) {
log.logError(BaseMessages.getString(PKG, "System.Dialog.GetFieldsFailed.Message"), e);
}
}
}
};
new Thread(runnable).start();
addRenameToTreeScriptItems();
input.setChanged(changed);
// Create the drag source on the tree
DragSource ds = new DragSource(wTree, DND.DROP_MOVE);
ds.setTransfer(new Transfer[] { TextTransfer.getInstance() });
ds.addDragListener(new DragSourceAdapter() {
public void dragStart(DragSourceEvent event) {
boolean doit = false;
TreeItem item = wTree.getSelection()[0];
// Allow dragging snippits and field helpers
if (item != null && item.getParentItem() != null) {
if ("Snippits Category".equals(item.getParentItem().getData()) && !"Snippits Category".equals(item.getData())) {
doit = true;
} else if ("Field Helpers".equals(item.getParentItem().getData())) {
doit = true;
} else if (item.getParentItem().getParentItem() != null && "Field Helpers".equals(item.getParentItem().getParentItem().getData())) {
doit = true;
}
}
event.doit = doit;
}
public void dragSetData(DragSourceEvent event) {
// Set the data to be the first selected item's data
event.data = wTree.getSelection()[0].getData();
}
});
shell.open();
while (!shell.isDisposed()) {
if (!display.readAndDispatch()) {
display.sleep();
}
}
return stepname;
}
Aggregations