use of org.eclipse.swt.dnd.DropTarget in project mylyn.docs by eclipse.
the class DndConfigurationStrategy method configure.
public void configure(CommandManager commandManager, Control control, ISelectionProvider provider) {
dragAdapter = new DelegatingDragAdapter();
dragSource = new DragSource(control, DND.DROP_COPY | DND.DROP_MOVE);
dragAdapter.addDragSourceListener(new OutlineDragSourceListener(provider));
dragSource.addDragListener(dragAdapter);
dragSource.setTransfer(dragAdapter.getTransfers());
dropAdapter = new DelegatingDropAdapter();
dropTarget = new DropTarget(control, DND.DROP_COPY | DND.DROP_MOVE);
dropAdapter.addDropTargetListener(new OutlineDropTargetListener(commandManager));
dropTarget.addDropListener(dropAdapter);
dropTarget.setTransfer(dropAdapter.getTransfers());
}
use of org.eclipse.swt.dnd.DropTarget in project core by jcryptool.
the class JCTTextEditor method createPartControl.
/**
* override to grab the parent object for drag&drop
*/
public void createPartControl(Composite parent) {
super.createPartControl(parent);
DropTarget target = new DropTarget(parent, DND.DROP_MOVE);
target.setTransfer(new Transfer[] { TextTransfer.getInstance(), FileTransfer.getInstance() });
target.addDropListener(new DropTargetAdapter() {
public void drop(DropTargetEvent event) {
if (FileTransfer.getInstance().isSupportedType(event.currentDataType)) {
String[] filenames = (String[]) event.data;
for (String filename : filenames) {
FileOpener.open(filename);
}
} else {
// call the algorithm action
AlgorithmView.doAction((String) event.data);
}
}
});
PlatformUI.getWorkbench().getHelpSystem().setHelp(parent, // $NON-NLS-1$
"org.jcryptool.editor.text.textEditor");
}
use of org.eclipse.swt.dnd.DropTarget in project tmdm-studio-se by Talend.
the class ViewMainPage method createCharacteristicsContent.
@Override
protected void createCharacteristicsContent(FormToolkit toolkit, Composite charComposite) {
try {
Composite descriptionComposite = toolkit.createComposite(charComposite, SWT.NONE);
descriptionComposite.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true, 1, 1));
descriptionComposite.setLayout(new GridLayout());
desAntionComposite = new DescAnnotationComposite(Messages.ViewMainPage_Description, // $NON-NLS-1$
" ...", // $NON-NLS-1$
toolkit, // $NON-NLS-1$
descriptionComposite, // $NON-NLS-1$
this, false);
Composite comp = toolkit.createComposite(descriptionComposite);
GridLayout layout = new GridLayout(2, false);
layout.marginWidth = 0;
layout.marginLeft = 0;
layout.marginTop = 0;
layout.marginHeight = 0;
layout.marginBottom = 0;
comp.setLayout(layout);
comp.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true, 1, 1));
btnRunProcess = toolkit.createButton(comp, Messages.ViewMainPage_RunResultThroughProcess, SWT.CHECK);
btnRunProcess.setLayoutData(new GridData(SWT.LEFT, SWT.CENTER, false, true, 1, 1));
cboProcessList = new Combo(comp, SWT.READ_ONLY | SWT.DROP_DOWN | SWT.SINGLE);
cboProcessList.setLayoutData(new GridData(SWT.LEFT, SWT.TOP, false, true, 1, 1));
initProcessCombo();
createSortPart(toolkit, comp);
if (adapter != null) {
adapter.createComposite(this, toolkit, comp);
}
// add listener
btnRunProcess.addSelectionListener(new SelectionListener() {
@Override
public void widgetSelected(SelectionEvent e) {
cboProcessList.setEnabled(btnRunProcess.getSelection());
markDirtyWithoutCommit();
}
@Override
public void widgetDefaultSelected(SelectionEvent e) {
cboProcessList.setEnabled(btnRunProcess.getSelection());
markDirtyWithoutCommit();
}
});
cboProcessList.addModifyListener(new ModifyListener() {
@Override
public void modifyText(ModifyEvent e) {
markDirtyWithoutCommit();
}
});
// make the Page window a DropTarget - we need to dispose it
windowTarget = new DropTarget(this.getPartControl(), DND.DROP_MOVE);
windowTarget.setTransfer(new Transfer[] { TextTransfer.getInstance() });
windowTarget.addDropListener(new DCDropTargetListener());
/**
**
* /viewable Business Elements
***
*/
TreeParent treeParent = (TreeParent) getAdapter(TreeParent.class);
Composite viewablehGroup = this.getNewSectionComposite(Messages.ViewMainPage_ViewableBusinessElements);
viewablehGroup.setLayout(new GridLayout(2, false));
viewableElementColumns[0].setColumnWidth(220);
viewableViewer = getNewTisTableViewer(viewablehGroup, toolkit, Arrays.asList(viewableElementColumns));
viewableViewer.setTreeParent(treeParent);
viewableViewer.setXpath(true);
if (viewName.startsWith("Browse_items_")) {
// $NON-NLS-1$//$NON-NLS-2$//$NON-NLS-3$//$NON-NLS-4$
concept = viewName.replaceAll("Browse_items_", "").replaceAll("#.*", "");
}
viewableViewer.setConceptName(concept);
viewableViewer.setMainPage(this);
viewableViewer.setAddMulti(true);
viewableViewer.create();
viewableViewer.setHeight(110);
// wrap.Wrap(this, viewableViewer);
Composite searchGroup = this.getNewSectionComposite(Messages.ViewMainPage_SearchableBusinessElements);
searchGroup.setLayout(new GridLayout(2, false));
searchableElementColumns[0].setColumnWidth(220);
searchableViewer = getNewTisTableViewer(searchGroup, toolkit, Arrays.asList(searchableElementColumns));
searchableViewer.setTreeParent(treeParent);
searchableViewer.setXpath(true);
searchableViewer.setConceptName(concept);
searchableViewer.setMainPage(this);
searchableViewer.setAddMulti(true);
searchableViewer.create();
searchableViewer.setHeight(110);
// wrap.Wrap(this, searchableViewer);
// Where Conditions
// if(viewName.startsWith("Browse_items_"))
// setCompositeView(false);
// else
setCompositeView(true);
initCoditionsColumns();
Composite wcGroup = this.getNewSectionComposite(Messages.ViewMainPage_WhereConditions);
wcGroup.setLayout(new GridLayout(2, false));
conditionsColumns[0].setColumnWidth(250);
conditionsColumns[1].setColumnWidth(150);
conditionsColumns[2].setColumnWidth(250);
conditionsColumns[3].setColumnWidth(120);
conditionViewer = getNewTisTableViewer(wcGroup, toolkit, Arrays.asList(conditionsColumns));
conditionViewer.setTreeParent(treeParent);
conditionViewer.setXpath(true);
conditionViewer.setConceptName(concept);
conditionViewer.setMainPage(this);
conditionViewer.setAddMulti(true);
conditionViewer.create();
conditionViewer.setHeight(110);
// wrap.Wrap(this, conditionViewer);
addToolBarItem();
refreshData();
} catch (Exception e) {
log.error(e.getMessage(), e);
}
}
use of org.eclipse.swt.dnd.DropTarget in project tmdm-studio-se by Talend.
the class Util method createCompDropTarget.
// add this method for the text drop action of all the texts available.
public static void createCompDropTarget(final Text text) {
DropTarget dropTarget = new DropTarget(text, DND.DROP_MOVE | DND.DROP_LINK);
dropTarget.setTransfer(new TreeObjectTransfer[] { TreeObjectTransfer.getInstance() });
dropTarget.addDropListener(new DropTargetAdapter() {
@Override
public void dragEnter(DropTargetEvent event) {
}
@Override
public void dragLeave(DropTargetEvent event) {
}
@Override
public void dragOver(DropTargetEvent event) {
event.feedback |= DND.FEEDBACK_EXPAND | DND.FEEDBACK_SCROLL;
}
@Override
public void drop(DropTargetEvent event) {
if (event.data instanceof TreeObject[]) {
text.setText(text.getText() + ((TreeObject[]) event.data)[0].getDisplayName());
}
}
});
}
use of org.eclipse.swt.dnd.DropTarget in project tmdm-studio-se by Talend.
the class RoutingRuleMainPage method createCharacteristicsContent.
@Override
protected void createCharacteristicsContent(FormToolkit toolkit, Composite charComposite) {
try {
// description
Label descriptionLabel = toolkit.createLabel(charComposite, Messages.descriptionLabel, SWT.NULL);
descriptionLabel.setLayoutData(new GridData(SWT.FILL, SWT.FILL, false, true, 1, 1));
// $NON-NLS-1$
descriptionText = toolkit.createText(charComposite, "", SWT.BORDER);
descriptionText.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true, 1, 1));
descriptionText.addModifyListener(new ModifyListener() {
public void modifyText(ModifyEvent e) {
if (refreshing) {
return;
}
markDirtyWithoutCommit();
}
});
// Util.createCompDropTarget(descriptionText);
// objectType
Label objectTypeLabel = toolkit.createLabel(charComposite, Messages.entityLabel, SWT.NULL);
objectTypeLabel.setLayoutData(new GridData(SWT.BEGINNING, SWT.CENTER, false, true, 1, 1));
Composite typeComposite = toolkit.createComposite(charComposite);
typeComposite.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true, 1, 1));
GridLayout layout = new GridLayout(2, false);
layout.marginLeft = 0;
layout.marginWidth = 0;
typeComposite.setLayout(layout);
// $NON-NLS-1$
objectTypeText = toolkit.createText(typeComposite, "", SWT.BORDER);
objectTypeText.setLayoutData(new GridData(GridData.HORIZONTAL_ALIGN_BEGINNING, SWT.CENTER, false, false, 1, 1));
((GridData) objectTypeText.getLayoutData()).widthHint = 300;
// objectTypeText.setLocation(descriptionText.getLocation().x,descriptionText.getLocation().y+10);
objectTypeText.addModifyListener(new ModifyListener() {
public void modifyText(ModifyEvent e) {
if (refreshing) {
return;
}
markDirtyWithoutCommit();
}
});
// $NON-NLS-1$
xpathButton = toolkit.createButton(typeComposite, "", SWT.PUSH);
xpathButton.setImage(ImageCache.getCreatedImage(EImage.DOTS_BUTTON.getPath()));
xpathButton.setToolTipText(Messages.entitySelectLabel);
xpathButton.addSelectionListener(new SelectionListener() {
public void widgetDefaultSelected(SelectionEvent e) {
}
public void widgetSelected(SelectionEvent e) {
XpathSelectDialog xpathDialog;
xpathDialog = getNewXpathDlg();
xpathDialog.setBlockOnOpen(true);
xpathDialog.open();
if (xpathDialog.getReturnCode() == Window.OK) {
String xpath = xpathDialog.getXpath();
// $NON-NLS-1$
int index = xpathDialog.getXpath().indexOf("/");
if (index > 0) {
xpath = xpathDialog.getXpath().substring(0, index);
}
objectTypeText.setText(xpath);
}
}
});
// xpathWidget1 = new XpathWidget("...",treeParent, toolkit,
// charComposite,(AMainPageV2)RoutingRuleMainPage.this,false,false,dataModelName);
Composite paramComposite = toolkit.createComposite(charComposite);
GridLayout pcLayout = new GridLayout(4, false);
pcLayout.marginLeft = 0;
pcLayout.horizontalSpacing = 0;
paramComposite.setLayout(pcLayout);
GridData pcLayoutData = new GridData(SWT.FILL, SWT.FILL, true, false);
pcLayoutData.horizontalSpan = 2;
pcLayoutData.horizontalIndent = 0;
paramComposite.setLayoutData(pcLayoutData);
// issynchronous Button
isSynchronousButton = toolkit.createButton(paramComposite, Messages.executesynLabel, SWT.CHECK);
GridData synBtnLayoutData = new GridData(SWT.FILL, SWT.FILL, false, true, 1, 1);
synBtnLayoutData.horizontalIndent = 0;
isSynchronousButton.setLayoutData(synBtnLayoutData);
isSynchronousButton.addMouseListener(new MouseListener() {
public void mouseUp(MouseEvent e) {
orderLabel.setEnabled(isSynchronousButton.getSelection());
orderText.setEnabled(isSynchronousButton.getSelection());
if (isSynchronousButton.getSelection()) {
// $NON-NLS-1$
orderText.setText("0");
} else {
// $NON-NLS-1$
orderText.setText("");
}
// mark for need to save
markDirtyWithoutCommit();
}
public void mouseDoubleClick(MouseEvent e) {
}
public void mouseDown(MouseEvent e) {
}
});
orderLabel = toolkit.createLabel(paramComposite, Messages.RoutingRuleMainPage_executeOrder);
GridData olLayoutData = new GridData();
olLayoutData.horizontalIndent = 10;
orderLabel.setLayoutData(olLayoutData);
orderLabel.setEnabled(false);
// $NON-NLS-1$
orderText = toolkit.createText(paramComposite, "", SWT.BORDER | SWT.SINGLE);
GridData otLayoutData = new GridData(SWT.FILL, SWT.CENTER, false, false);
otLayoutData.widthHint = 50;
otLayoutData.horizontalIndent = 10;
orderText.setLayoutData(otLayoutData);
orderText.setEnabled(false);
orderText.addModifyListener(new ModifyListener() {
public void modifyText(ModifyEvent e) {
markDirtyWithoutCommit();
}
});
deactiveButton = toolkit.createButton(paramComposite, Messages.deactivateLabel, SWT.CHECK);
GridData dbLayoutData = new GridData(SWT.BEGINNING, SWT.FILL, false, true, 1, 1);
dbLayoutData.horizontalIndent = 25;
deactiveButton.setLayoutData(dbLayoutData);
deactiveButton.addMouseListener(new MouseListener() {
public void mouseUp(MouseEvent e) {
// mark for need to save
markDirtyWithoutCommit();
}
public void mouseDoubleClick(MouseEvent e) {
}
public void mouseDown(MouseEvent e) {
}
});
// Routing Expressions
Composite serviceGroup = this.getNewSectionComposite(Messages.serviceLabel);
serviceGroup.setLayout(new GridLayout(2, false));
// Service Name
Label serviceNameLabel = toolkit.createLabel(serviceGroup, Messages.serviceJndiLabel, SWT.NULL);
serviceNameLabel.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, false, true, 1, 1));
Composite subPanel = toolkit.createComposite(serviceGroup);
subPanel.setLayoutData(new GridData(SWT.LEFT, SWT.CENTER, false, true, 1, 1));
subPanel.setLayout(new GridLayout(2, false));
serviceNameCombo = new Combo(subPanel, SWT.DROP_DOWN | SWT.SINGLE | SWT.READ_ONLY);
serviceNameCombo.setLayoutData(new GridData(SWT.LEFT, SWT.CENTER, false, true, 1, 1));
((GridData) serviceNameCombo.getLayoutData()).widthHint = 300;
serviceNameCombo.addModifyListener(new ModifyListener() {
public void modifyText(ModifyEvent e) {
if (refreshing) {
return;
}
String serviceName = serviceNameCombo.getText();
// $NON-NLS-1$
String helpPara = "";
if (!"".equals(serviceName) && !serviceName.equals(null)) {
// $NON-NLS-1$
if (EInputTemplate.getXtentisObjexts().get(serviceName) != null) {
helpPara = EInputTemplate.getXtentisObjexts().get(serviceName).getContent();
} else {
// $NON-NLS-1$
helpPara = "";
}
}
// serviceParametersText.setText(XmlUtil.formatXmlSource(helpPara));
refreshParameterEditor(serviceName);
serviceParametersEditor.setContent(XmlUtil.formatXmlSource(helpPara));
markDirtyWithoutCommit();
initParamterProposal(serviceNameCombo.getText());
}
});
initServiceNameCombo();
// default parameters button
// $NON-NLS-1$
defultParameterBtn = toolkit.createButton(subPanel, "", SWT.PUSH);
defultParameterBtn.setImage(ImageCache.getCreatedImage(EImage.HELP_CONTENTS.getPath()));
defultParameterBtn.setToolTipText(Messages.helpLabel);
defultParameterBtn.setLayoutData(new GridData(SWT.FILL, SWT.FILL, false, true, 1, 1));
defultParameterBtn.addSelectionListener(new SelectionListener() {
public void widgetDefaultSelected(org.eclipse.swt.events.SelectionEvent e) {
}
public void widgetSelected(org.eclipse.swt.events.SelectionEvent e) {
if (serviceNameCombo.getText().trim().length() == 0) {
return;
}
// $NON-NLS-1$
String doc = "";
// $NON-NLS-1$
String desc = "";
// WSRoutingRule wsObject = (WSRoutingRule) (getXObject().getWSObject());
try {
WSServiceGetDocument document = getServiceDocument(serviceNameCombo.getText().trim());
doc = document.getDocument();
desc = document.getDescription();
} catch (Exception e1) {
// $NON-NLS-1$
doc = "N/A";
} finally {
showUpDialog(desc, doc);
}
}
private void showUpDialog(String desc, String doc) {
final PluginDetailsDialog dialog = new PluginDetailsDialog(getSite().getShell(), desc, doc, null, Messages.documentionLabel);
dialog.addListener(new Listener() {
public void handleEvent(Event event) {
dialog.close();
}
});
dialog.create();
dialog.getShell().setText(serviceNameCombo.getText() + Messages.serviceDetailLabel);
dialog.setBlockOnOpen(true);
dialog.open();
}
});
// Service Parameters
Label serviceParametersLabel = toolkit.createLabel(serviceGroup, Messages.serviceParamLabel, SWT.NULL);
serviceParametersLabel.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, false, true, 2, 1));
serviceParametersEditor = new ExtensibleContentEditor(serviceGroup, SWT.MULTI | SWT.WRAP, EXCONTENTEDITOR_ID);
GridData gdServiceParameter = new GridData(SWT.FILL, SWT.FILL, true, true, 2, 1);
// gdServiceParameter.widthHint = 200;
gdServiceParameter.heightHint = 200;
serviceParametersEditor.setLayoutData(gdServiceParameter);
parameterEditorListener = new ParameterEditorListener();
// serviceParametersText = toolkit.createText(serviceGroup, "",SWT.BORDER|SWT.MULTI|SWT.V_SCROLL|SWT.WRAP);
// serviceParametersText.setLayoutData(
// new GridData(SWT.FILL,SWT.FILL,true,false,2,1)
// );
// ((GridData) serviceParametersText.getLayoutData()).widthHint = 200;
// ((GridData) serviceParametersText.getLayoutData()).heightHint = 120;
// serviceParametersText.addModifyListener(new ModifyListener() {
//
// public void modifyText(ModifyEvent e) {
// if (refreshing)
// return;
// markDirtyWithoutCommit();
// }
// });
// // add by ymli.fix the bug:0011830. We can reuse the same ctrl+space in trigger configs.
// serviceParametersText.addKeyListener(new KeyListener() {
//
// public void keyReleased(KeyEvent event) {
//
// // System.out.println("SWT.CTRL:"+SWT.CTRL);
// int start = serviceParametersText.getSelection().x;
// int end = serviceParametersText.getSelection().y;
// if (event.stateMask == SWT.CTRL && event.keyCode == 17) {
// // if(event.keyCode == SWT.F2){
// ResourceSelectDialog dialog = new ResourceSelectDialog(getSite().getShell(), treeParent.getParent(),
// "Select a resource node", ServerView.show().getSite());
// dialog.setBlockOnOpen(true);
// dialog.open();
// if (dialog.getReturnCode() == Window.OK) {
// String xpath = dialog.getXpath();
// String textHead = serviceParametersText.getText(0, start - 1);
// String textEnd = serviceParametersText.getText(end, serviceParametersText.getText().length());
// serviceParametersText.setText(textHead + xpath + textEnd);
// serviceParametersText.setSelection(start, start + xpath.length());
// markDirtyWithoutCommit();
// }
// }
// }
//
// public void keyPressed(KeyEvent e) {
// }
// });
// Routing Expressions
Composite routingExpressionsGroup = this.getNewSectionComposite(Messages.triggerExpressionLabel);
routingExpressionsGroup.setLayout(new GridLayout(1, true));
conditionsColumns[0].setColumnWidth(250);
conditionsColumns[1].setColumnWidth(150);
conditionsColumns[2].setColumnWidth(250);
conditionsColumns[3].setColumnWidth(120);
conditionViewer = getNewTisTableViewer(toolkit, routingExpressionsGroup);
TreeParent treeParent = (TreeParent) getAdapter(TreeParent.class);
conditionViewer.setTreeParent(treeParent);
// $NON-NLS-1$
conditionViewer.setDatamodelName("UpdateReport");
conditionViewer.setXpath(true);
conditionViewer.setMainPage(this);
conditionViewer.setAddMulti(true);
conditionViewer.create();
conditionViewer.setHeight(110);
// and or not condition
ConditionWidget conditionWidget = new ConditionWidget(routingExpressionsGroup, toolkit, this);
conditionText = conditionWidget.getConditionText();
conditionText.addModifyListener(new ModifyListener() {
public void modifyText(ModifyEvent e) {
if (!refreshing) {
markDirtyWithoutCommit();
}
}
});
wrap.Wrap(this, conditionViewer);
// make the Page window a DropTarget - we need to dispose it
windowTarget = new DropTarget(this.getPartControl(), DND.DROP_MOVE);
windowTarget.setTransfer(new Transfer[] { TextTransfer.getInstance() });
windowTarget.addDropListener(new DCDropTargetListener());
refreshData();
conditionText.addFocusListener(new FocusListener() {
public void focusLost(FocusEvent e) {
// adapter.resetPosition();
}
public void focusGained(FocusEvent e) {
initConditionProposal();
}
});
} catch (Exception e) {
log.error(e.getMessage(), e);
}
}
Aggregations