use of org.eclipse.swt.dnd.DropTarget in project netxms by netxms.
the class RuleEditor method dropEnable.
/**
* Enables drop functionality of the rule
*/
private void dropEnable() {
// enable each label to be a drop target
DropTarget target = new DropTarget(this, DND.DROP_MOVE);
target.setTransfer(new Transfer[] { LocalSelectionTransfer.getTransfer() });
// add a drop listener
target.addDropListener(new RuleDropTargetListener());
}
use of org.eclipse.swt.dnd.DropTarget in project pentaho-kettle by pentaho.
the class RepositoryExplorerDialog method open.
public RepositoryObjectReference open() {
debug = "opening repository explorer";
try {
debug = "open new independent shell";
Shell parent = getParent();
Display display = parent.getDisplay();
shell = new Shell(display, SWT.DIALOG_TRIM | SWT.RESIZE | SWT.MAX | SWT.MIN);
props.setLook(shell);
shell.setImage(GUIResource.getInstance().getImageFolderConnections());
shell.setText(BaseMessages.getString(PKG, "RepositoryExplorerDialog.Title") + rep.getName() + "]");
FormLayout formLayout = new FormLayout();
formLayout.marginWidth = Const.FORM_MARGIN;
formLayout.marginHeight = Const.FORM_MARGIN;
shell.setLayout(formLayout);
// Add a small toolbar to expand/collapse all items
//
ToolBar treeTb = new ToolBar(shell, SWT.HORIZONTAL | SWT.FLAT);
props.setLook(treeTb);
fdTreeTb = new FormData();
fdTreeTb.left = new FormAttachment(0, 0);
fdTreeTb.top = new FormAttachment(0, 0);
treeTb.setLayoutData(fdTreeTb);
// Add the items...
//
exportToXML = new ToolItem(treeTb, SWT.PUSH);
exportToXML.setImage(GUIResource.getInstance().getImageExport());
exportToXML.setText(BaseMessages.getString(PKG, "RepositoryExplorerDialog.ToolItem.ExportToXML.Label"));
exportToXML.setToolTipText(BaseMessages.getString(PKG, "RepositoryExplorerDialog.ToolItem.ExportToXML.Tooltip"));
importFromXML = new ToolItem(treeTb, SWT.PUSH);
importFromXML.setImage(GUIResource.getInstance().getImageImport());
importFromXML.setText(BaseMessages.getString(PKG, "RepositoryExplorerDialog.ToolItem.ImportFromXML.Label"));
importFromXML.setToolTipText(BaseMessages.getString(PKG, "RepositoryExplorerDialog.ToolItem.ImportFromXML.Tooltip"));
new ToolItem(treeTb, SWT.SEPARATOR);
showHideDeleted = new ToolItem(treeTb, SWT.PUSH);
showHideDeleted.setImage(GUIResource.getInstance().getImageShowDeleted());
showHideDeleted.setText(BaseMessages.getString(PKG, "RepositoryExplorerDialog.ToolItem.ShowDeleted.Label"));
showHideDeleted.setToolTipText(BaseMessages.getString(PKG, "RepositoryExplorerDialog.ToolItem.ShowDeleted.Tooltip"));
showHideDeleted.setEnabled(rep.getRepositoryMeta().getRepositoryCapabilities().supportsRevisions());
new ToolItem(treeTb, SWT.SEPARATOR);
expandAll = new ToolItem(treeTb, SWT.PUSH);
expandAll.setImage(GUIResource.getInstance().getImageExpandAll());
expandAll.setText(BaseMessages.getString(PKG, "RepositoryExplorerDialog.ToolItem.ExpandAll.Label"));
expandAll.setToolTipText(BaseMessages.getString(PKG, "RepositoryExplorerDialog.ToolItem.ExpandAll.Tooltip"));
collapseAll = new ToolItem(treeTb, SWT.PUSH);
collapseAll.setImage(GUIResource.getInstance().getImageCollapseAll());
collapseAll.setText(BaseMessages.getString(PKG, "RepositoryExplorerDialog.ToolItem.CollapseAll.Label"));
collapseAll.setToolTipText(BaseMessages.getString(PKG, "RepositoryExplorerDialog.ToolItem.CollapseAll.Tooltip"));
// Tree
wTree = new Tree(shell, SWT.MULTI | SWT.BORDER);
wTree.setHeaderVisible(true);
props.setLook(wTree);
// Add some columns to it as well...
nameColumn = new TreeColumn(wTree, SWT.LEFT);
nameColumn.setText(BaseMessages.getString(PKG, "RepositoryExplorerDialog.Column.Name"));
nameColumn.setWidth(350);
nameColumn.setAlignment(10);
nameColumn.addListener(SWT.Selection, new Listener() {
@Override
public void handleEvent(Event e) {
setSort(0);
}
});
// No sorting on the type column just yet.
typeColumn = new TreeColumn(wTree, SWT.LEFT);
typeColumn.setText(BaseMessages.getString(PKG, "RepositoryExplorerDialog.Column.Type"));
typeColumn.setWidth(100);
typeColumn.addListener(SWT.Selection, new Listener() {
@Override
public void handleEvent(Event e) {
setSort(1);
}
});
userColumn = new TreeColumn(wTree, SWT.LEFT);
userColumn.setText(BaseMessages.getString(PKG, "RepositoryExplorerDialog.Column.User"));
userColumn.setWidth(100);
userColumn.addListener(SWT.Selection, new Listener() {
@Override
public void handleEvent(Event e) {
setSort(2);
}
});
changedColumn = new TreeColumn(wTree, SWT.LEFT);
changedColumn.setText(BaseMessages.getString(PKG, "RepositoryExplorerDialog.Column.Changed"));
changedColumn.setWidth(120);
changedColumn.addListener(SWT.Selection, new Listener() {
@Override
public void handleEvent(Event e) {
setSort(3);
}
});
descriptionColumn = new TreeColumn(wTree, SWT.LEFT);
descriptionColumn.setText(BaseMessages.getString(PKG, "RepositoryExplorerDialog.Column.Description"));
descriptionColumn.setWidth(120);
descriptionColumn.addListener(SWT.Selection, new Listener() {
@Override
public void handleEvent(Event e) {
setSort(4);
}
});
lockColumn = new TreeColumn(wTree, SWT.LEFT);
lockColumn.setText(BaseMessages.getString(PKG, "RepositoryExplorerDialog.Column.LockMessage"));
lockColumn.setWidth(120);
lockColumn.addListener(SWT.Selection, new Listener() {
@Override
public void handleEvent(Event e) {
setSort(5);
}
});
// Add a memory to the tree.
TreeMemory.addTreeListener(wTree, STRING_REPOSITORY_EXPLORER_TREE_NAME);
// Buttons
wOK = new Button(shell, SWT.PUSH);
wOK.setText(BaseMessages.getString(PKG, "System.Button.OK"));
FormData fdTree = new FormData();
int margin = 10;
// To the right of the label
fdTree.left = new FormAttachment(0, 0);
fdTree.top = new FormAttachment(treeTb, 0);
fdTree.right = new FormAttachment(100, 0);
fdTree.bottom = new FormAttachment(100, -50);
wTree.setLayoutData(fdTree);
BaseStepDialog.positionBottomButtons(shell, new Button[] { wOK }, margin, null);
// Add listeners
wOK.addListener(SWT.Selection, new Listener() {
@Override
public void handleEvent(Event e) {
close();
}
});
wTree.addMenuDetectListener(new MenuDetectListener() {
@Override
public void menuDetected(MenuDetectEvent e) {
setTreeMenu();
}
});
wTree.addMouseListener(new MouseAdapter() {
@Override
public void mouseDoubleClick(MouseEvent e) {
if (e.button == 1) {
// left double click!
doDoubleClick();
}
}
});
wTree.addKeyListener(new KeyAdapter() {
@Override
public void keyPressed(KeyEvent e) {
// F2 --> rename...
if (e.keyCode == SWT.F2) {
if (!readonly) {
renameInTree();
}
}
// F5 --> refresh...
if (e.keyCode == SWT.F5) {
refreshTree();
}
}
});
expandAll.addSelectionListener(new SelectionAdapter() {
@Override
public void widgetSelected(SelectionEvent event) {
expandAllItems(wTree.getItems(), true);
}
});
collapseAll.addSelectionListener(new SelectionAdapter() {
@Override
public void widgetSelected(SelectionEvent event) {
expandAllItems(wTree.getItems(), false);
}
});
importFromXML.addSelectionListener(new SelectionAdapter() {
@Override
public void widgetSelected(SelectionEvent event) {
importAll();
}
});
exportToXML.addSelectionListener(new SelectionAdapter() {
@Override
public void widgetSelected(SelectionEvent event) {
exportAll(null);
}
});
showHideDeleted.addSelectionListener(new SelectionAdapter() {
@Override
public void widgetSelected(SelectionEvent event) {
includeDeleted = !includeDeleted;
if (includeDeleted) {
showHideDeleted.setText(BaseMessages.getString(PKG, "RepositoryExplorerDialog.ToolItem.HideDeleted.Label"));
showHideDeleted.setToolTipText(BaseMessages.getString(PKG, "RepositoryExplorerDialog.ToolItem.HideDeleted.Tooltip"));
} else {
showHideDeleted.setText(BaseMessages.getString(PKG, "RepositoryExplorerDialog.ToolItem.ShowDeleted.Label"));
showHideDeleted.setToolTipText(BaseMessages.getString(PKG, "RepositoryExplorerDialog.ToolItem.ShowDeleted.Tooltip"));
}
refreshTree();
}
});
// Drag & Drop
Transfer[] ttypes = new Transfer[] { TextTransfer.getInstance() };
DragSource ddSource = new DragSource(wTree, DND.DROP_MOVE);
ddSource.setTransfer(ttypes);
ddSource.addDragListener(new DragSourceListener() {
@Override
public void dragStart(DragSourceEvent event) {
debug = "drag start";
event.doit = true;
}
@Override
public void dragSetData(DragSourceEvent event) {
debug = "drag set data";
event.data = "";
event.doit = false;
TreeItem[] ti = wTree.getSelection();
if (ti.length >= 1) {
int cat = getItemCategory(ti[0]);
//
if (cat == ITEM_CATEGORY_TRANSFORMATION) {
debug = "drag set: drag around transformation";
RepositoryDirectoryInterface repdir = getDirectory(ti[0]);
if (repdir != null) {
//
// Pass info as a piece of XML
//
String xml = XMLHandler.getXMLHeader();
xml += "<dragdrop>" + Const.CR;
xml += " " + XMLHandler.addTagValue("directory", repdir.getPath());
xml += " " + XMLHandler.addTagValue("transformation", ti[0].getText());
xml += "</dragdrop>" + Const.CR;
event.data = xml;
event.doit = true;
}
} else if (cat == ITEM_CATEGORY_JOB) {
debug = "drag set: drag around job";
RepositoryDirectoryInterface repdir = getDirectory(ti[0]);
if (repdir != null) {
//
// Pass info as a piece of XML
//
String xml = XMLHandler.getXMLHeader();
xml += "<dragdrop>" + Const.CR;
xml += " " + XMLHandler.addTagValue("directory", repdir.getPath());
xml += " " + XMLHandler.addTagValue("job", ti[0].getText());
xml += "</dragdrop>" + Const.CR;
event.data = xml;
event.doit = true;
}
} else {
debug = "do nothing";
String xml = XMLHandler.getXMLHeader();
xml += "<dragdrop>" + Const.CR;
xml += "</dragdrop>" + Const.CR;
event.data = xml;
event.doit = true;
}
}
}
@Override
public void dragFinished(DragSourceEvent event) {
}
});
DropTarget ddTarget = new DropTarget(wTree, DND.DROP_MOVE);
ddTarget.setTransfer(ttypes);
ddTarget.addDropListener(new DropTargetListener() {
@Override
public void dragEnter(DropTargetEvent event) {
}
@Override
public void dragLeave(DropTargetEvent event) {
debug = "drag leave";
}
@Override
public void dragOperationChanged(DropTargetEvent event) {
}
@Override
public void dragOver(DropTargetEvent event) {
debug = "drag over";
}
@Override
public void drop(DropTargetEvent event) {
try {
debug = "Drop item in tree";
if (event.data == null) {
// no data to copy, indicate failure in event.detail
event.detail = DND.DROP_NONE;
return;
}
// event.feedback = DND.FEEDBACK_NONE;
TreeItem ti = (TreeItem) event.item;
if (ti != null) {
debug = "Get category";
int category = getItemCategory(ti);
if (category == ITEM_CATEGORY_TRANSFORMATION_DIRECTORY || category == ITEM_CATEGORY_TRANSFORMATION) {
debug = "Get directory";
RepositoryDirectoryInterface repdir = getDirectory(ti);
if (repdir != null) {
event.feedback = DND.FEEDBACK_SELECT | DND.FEEDBACK_SCROLL;
if (moveTransformation((String) event.data, repdir)) {
refreshTree();
} else {
MessageBox mb = new MessageBox(shell, SWT.ICON_INFORMATION | SWT.OK);
mb.setMessage(BaseMessages.getString(PKG, "RepositoryExplorerDialog.Trans.Move.UnableToMove.Message"));
mb.setText(BaseMessages.getString(PKG, "RepositoryExplorerDialog.Trans.Move.UnableToMove.Title"));
mb.open();
}
}
} else if (category == ITEM_CATEGORY_JOB_DIRECTORY || category == ITEM_CATEGORY_JOB) {
debug = "Get directory";
RepositoryDirectoryInterface repdir = getDirectory(ti);
if (repdir != null) {
event.feedback = DND.FEEDBACK_SELECT | DND.FEEDBACK_SCROLL;
if (moveJob((String) event.data, repdir)) {
refreshTree();
} else {
MessageBox mb = new MessageBox(shell, SWT.ICON_INFORMATION | SWT.OK);
mb.setMessage(BaseMessages.getString(PKG, "RepositoryExplorerDialog.Job.Move.UnableToMove.Message"));
mb.setText(BaseMessages.getString(PKG, "RepositoryExplorerDialog.Job.Move.UnableToMove.Title"));
mb.open();
}
}
} else {
MessageBox mb = new MessageBox(shell, SWT.ICON_INFORMATION | SWT.OK);
mb.setMessage(BaseMessages.getString(PKG, "RepositoryExplorerDialog.Trans.Move.SorryOneItemAtATime.Message"));
mb.setText(BaseMessages.getString(PKG, "RepositoryExplorerDialog.Trans.Move.SorryOneItemAtATime.Title"));
mb.open();
}
}
} catch (Throwable e) {
new ErrorDialog(shell, BaseMessages.getString(PKG, "RepositoryExplorerDialog.Drop.UnexpectedError.Title"), BaseMessages.getString(PKG, "RepositoryExplorerDialog.Drop.UnexpectedError.Message1") + debug + "]" + Const.CR + BaseMessages.getString(PKG, "RepositoryExplorerDialog.Drop.UnexpectedError.Message2"), e);
}
}
@Override
public void dropAccept(DropTargetEvent event) {
debug = "drop accept";
}
});
// Detect X or ALT-F4 or something that kills this window...
shell.addShellListener(new ShellAdapter() {
@Override
public void shellClosed(ShellEvent e) {
close();
}
});
debug = "set screen size and position";
BaseStepDialog.setSize(shell, 400, 480, true);
// refreshes too.
setSort(0);
shell.open();
while (!shell.isDisposed()) {
if (!display.readAndDispatch()) {
display.sleep();
}
}
} catch (Throwable e) {
new ErrorDialog(shell, BaseMessages.getString(PKG, "RepositoryExplorerDialog.Main.UnexpectedError.Title"), BaseMessages.getString(PKG, "RepositoryExplorerDialog.Main.UnexpectedError.Message1") + debug + "]" + Const.CR + BaseMessages.getString(PKG, "RepositoryExplorerDialog.Main.UnexpectedError.Message2") + Const.CR + BaseMessages.getString(PKG, "RepositoryExplorerDialog.Main.UnexpectedError.Message3"), e);
}
return lastOpened;
}
use of org.eclipse.swt.dnd.DropTarget in project archi by archimatetool.
the class IconSection method createControls.
@Override
protected void createControls(Composite parent) {
createLabel(parent, Messages.IconSection_9, ITabbedLayoutConstants.STANDARD_LABEL_WIDTH, SWT.NONE);
fCanvas = new Canvas(parent, SWT.BORDER);
getWidgetFactory().adapt(fCanvas);
GridData gd = new GridData(SWT.NONE, SWT.NONE, false, false);
gd.widthHint = IMAGE_SIZE;
gd.heightHint = IMAGE_SIZE;
fCanvas.setLayoutData(gd);
GridLayout layout = new GridLayout();
layout.marginWidth = 0;
layout.marginHeight = 0;
fCanvas.setLayout(layout);
fCanvas.addDisposeListener(new DisposeListener() {
@Override
public void widgetDisposed(DisposeEvent e) {
disposeImage();
}
});
fCanvas.addListener(SWT.MouseDoubleClick, new Listener() {
@Override
public void handleEvent(Event event) {
if (fImageButton.isEnabled()) {
chooseImage();
}
}
});
fCanvas.addPaintListener(new PaintListener() {
@Override
public void paintControl(PaintEvent e) {
if (fImage != null) {
e.gc.setAntialias(SWT.ON);
e.gc.setInterpolation(SWT.HIGH);
Rectangle imageBounds = fImage.getBounds();
Rectangle newSize = ImageFactory.getScaledImageSize(fImage, IMAGE_SIZE);
// Centre the image
int x = (IMAGE_SIZE - newSize.width) / 2;
int y = (IMAGE_SIZE - newSize.height) / 2;
e.gc.drawImage(fImage, 0, 0, imageBounds.width, imageBounds.height, x, y, newSize.width, newSize.height);
}
}
});
String tooltip = Messages.IconSection_10;
fCanvas.setToolTipText(tooltip);
DropTarget target = new DropTarget(fCanvas, DND.DROP_MOVE | DND.DROP_COPY | DND.DROP_DEFAULT);
target.setTransfer(new Transfer[] { FileTransfer.getInstance() });
target.addDropListener(new DropTargetAdapter() {
@Override
public void drop(DropTargetEvent event) {
if (event.data instanceof String[] && fImageButton.isEnabled()) {
File file = new File(((String[]) event.data)[0]);
setImage(file);
}
}
});
// Image Button
createImageButton(parent);
// Position
createLabel(parent, Messages.IconSection_11, ITabbedLayoutConstants.STANDARD_LABEL_WIDTH, SWT.CENTER);
fComboPosition = new Combo(parent, SWT.READ_ONLY);
fComboPosition.setItems(fComboPositionItems);
getWidgetFactory().adapt(fComboPosition, true, true);
gd = new GridData(SWT.NONE, SWT.NONE, false, false);
fComboPosition.setLayoutData(gd);
fComboPosition.addSelectionListener(new SelectionAdapter() {
@Override
public void widgetSelected(SelectionEvent e) {
CompoundCommand result = new CompoundCommand();
for (EObject iconic : getEObjects()) {
if (isAlive(iconic)) {
Command cmd = new EObjectFeatureCommand(Messages.IconSection_12, iconic, IArchimatePackage.Literals.ICONIC__IMAGE_POSITION, fComboPosition.getSelectionIndex());
if (cmd.canExecute()) {
result.add(cmd);
}
}
}
executeCommand(result.unwrap());
}
});
// Help
PlatformUI.getWorkbench().getHelpSystem().setHelp(parent, HELP_ID);
}
use of org.eclipse.swt.dnd.DropTarget in project tmdm-studio-se by Talend.
the class TransformerMainPage method createCharacteristicsContent.
@Override
protected void createCharacteristicsContent(final FormToolkit toolkit, Composite topComposite) {
try {
initTransformer();
descriptionComposite = toolkit.createComposite(topComposite, SWT.NONE);
descriptionComposite.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true, 1, 1));
descriptionComposite.setLayout(new GridLayout(3, false));
// edit by ymli; fix the bug:0012024 Make Process descriptions multilingual.
// description
/*
* Label descriptionLabel = toolkit.createLabel(descriptionComposite, "Description", SWT.NULL);
* descriptionLabel.setLayoutData( new GridData(SWT.FILL,SWT.CENTER,false,true,1,1) ); descriptionText =
* toolkit.createText(descriptionComposite, "",SWT.BORDER|SWT.MULTI); descriptionText.setLayoutData( new
* GridData(SWT.FILL,SWT.FILL,true,true,1,1) ); ((GridData)descriptionText.getLayoutData()).minimumHeight =
* 30; descriptionText.addModifyListener(new ModifyListener() { public void modifyText(ModifyEvent e) { if
* (refreshing) return; //commit as we go TransformerMainPage.this.comitting= true;
* //((WSTransformerV2)getXObject().getWsObject()) transformer.setDescription(descriptionText.getText());
* TransformerMainPage.this.comitting= false; //markDirtyWithoutCommit(); markDirtyWithoutCommit(); } });
*/
desAntionComposite = new DescAnnotationComposite(Messages.TransformerMainPage_Description, // $NON-NLS-1$
" ...", // $NON-NLS-1$
toolkit, // $NON-NLS-1$
descriptionComposite, this, false);
desAntionComposite.getTextWidget().addModifyListener(new ModifyListener() {
public void modifyText(ModifyEvent e) {
if (refreshing) {
return;
}
TransformerMainPage.this.comitting = true;
transformer.setDescription(desAntionComposite.getText());
TransformerMainPage.this.comitting = false;
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());
createOtherContent(toolkit, topComposite);
sequenceGroup = this.getNewSectionComposite(Messages.TransformerMainPage_StepsSequence);
sequenceGroup.setLayout(new GridLayout(1, false));
Composite sequenceComposite = toolkit.createComposite(sequenceGroup, SWT.NONE);
sequenceComposite.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true, 1, 1));
sequenceComposite.setLayout(new GridLayout(6, false));
Label l3 = toolkit.createLabel(sequenceComposite, Messages.TransformerMainPage_StepDesc, SWT.NULL);
l3.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, false, true, 1, 1));
// $NON-NLS-1$
stepText = toolkit.createText(sequenceComposite, "", SWT.BORDER | SWT.SINGLE);
stepText.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true, 4, 1));
stepText.addKeyListener(new KeyListener() {
public void keyPressed(KeyEvent e) {
}
public void keyReleased(KeyEvent e) {
if (e.keyCode == 13) {
// enter
performAdd();
int index = stepsList.getItemCount() - 1;
performSelect(index);
}
}
});
// $NON-NLS-1$
Button addStepButton = toolkit.createButton(sequenceComposite, "", SWT.PUSH);
addStepButton.setLayoutData(new GridData(SWT.CENTER, SWT.FILL, false, true, 1, 1));
addStepButton.setToolTipText(Messages.TransformerMainPage_Add);
addStepButton.setImage(ImageCache.getCreatedImage(EImage.ADD_OBJ.getPath()));
addStepButton.addSelectionListener(new SelectionListener() {
public void widgetDefaultSelected(org.eclipse.swt.events.SelectionEvent e) {
}
public void widgetSelected(org.eclipse.swt.events.SelectionEvent e) {
// commit as we go
performAdd();
}
});
stepsList = new List(sequenceComposite, SWT.V_SCROLL | SWT.BORDER);
stepsList.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true, 5, 1));
((GridData) stepsList.getLayoutData()).heightHint = 40;
/*
* DragSource stepsSource = new DragSource(stepsList,DND.DROP_MOVE); stepsSource.setTransfer(new
* Transfer[]{TextTransfer.getInstance()}); stepsSource.addDragListener(new DCDragSourceListener());
*/
stepsList.addSelectionListener(new SelectionListener() {
public void widgetDefaultSelected(SelectionEvent e) {
widgetSelected(e);
}
public void widgetSelected(SelectionEvent e) {
performSelect(stepsList.getSelectionIndex());
}
});
wrap.Wrap(this, stepsList);
stepsList.addFocusListener(new FocusListener() {
public void focusGained(FocusEvent e) {
if (stepsList.getSelectionIndex() >= 0) {
refreshStep(stepsList.getSelectionIndex());
section.setVisible(true);
}
}
public void focusLost(FocusEvent e) {
}
});
Composite stepUpDownComposite = toolkit.createComposite(sequenceComposite, SWT.NONE);
stepUpDownComposite.setLayoutData(new GridData(SWT.FILL, SWT.FILL, false, true, 1, 1));
stepUpDownComposite.setLayout(new GridLayout(1, false));
// $NON-NLS-1$
Button stepUpButton = toolkit.createButton(stepUpDownComposite, "", SWT.PUSH | SWT.CENTER);
stepUpButton.setLayoutData(new GridData(SWT.FILL, SWT.FILL, false, true, 1, 1));
stepUpButton.setImage(ImageCache.getCreatedImage(EImage.PREV_NAV.getPath()));
stepUpButton.setToolTipText(Messages.TransformerMainPage_MoveUpTheItem);
stepUpButton.addSelectionListener(new SelectionListener() {
public void widgetDefaultSelected(org.eclipse.swt.events.SelectionEvent e) {
}
public void widgetSelected(org.eclipse.swt.events.SelectionEvent e) {
int index = TransformerMainPage.this.stepsList.getSelectionIndex();
if (index > 0) {
// commit as we go
TransformerMainPage.this.comitting = true;
String val = TransformerMainPage.this.stepsList.getItem(index);
TransformerMainPage.this.stepsList.remove(index);
TransformerMainPage.this.stepsList.add(val, index - 1);
TransformerMainPage.this.stepsList.select(index - 1);
// (WSTransformerV2)getXObject().getWsObject();
WSTransformerV2 wsTransformer = transformer;
java.util.List<WSTransformerProcessStep> list = wsTransformer.getProcessSteps();
WSTransformerProcessStep spec = list.get(index);
list.remove(index);
list.add(index - 1, spec);
performSelect(index - 1);
TransformerMainPage.this.comitting = false;
TransformerMainPage.this.stepsList.forceFocus();
markDirtyWithoutCommit();
}
}
});
// $NON-NLS-1$
Button stepDownButton = toolkit.createButton(stepUpDownComposite, "", SWT.PUSH | SWT.CENTER);
stepDownButton.setLayoutData(new GridData(SWT.FILL, SWT.FILL, false, true, 1, 1));
stepDownButton.setImage(ImageCache.getCreatedImage(EImage.NEXT_NAV.getPath()));
stepDownButton.setToolTipText(Messages.TransformerMainPage_MoveDownTheItem);
stepDownButton.addSelectionListener(new SelectionListener() {
public void widgetDefaultSelected(org.eclipse.swt.events.SelectionEvent e) {
}
public void widgetSelected(org.eclipse.swt.events.SelectionEvent e) {
int index = TransformerMainPage.this.stepsList.getSelectionIndex();
if ((index >= 0) && (index < TransformerMainPage.this.stepsList.getItemCount() - 1)) {
// commit as we go
TransformerMainPage.this.comitting = true;
String val = TransformerMainPage.this.stepsList.getItem(index);
TransformerMainPage.this.stepsList.remove(index);
TransformerMainPage.this.stepsList.add(val, index + 1);
TransformerMainPage.this.stepsList.select(index + 1);
// (WSTransformerV2)getXObject().getWsObject();
WSTransformerV2 wsTransformer = transformer;
java.util.List<WSTransformerProcessStep> list = wsTransformer.getProcessSteps();
WSTransformerProcessStep spec = list.get(index);
list.remove(index);
list.add(index + 1, spec);
TransformerMainPage.this.comitting = false;
TransformerMainPage.this.stepsList.forceFocus();
markDirtyWithoutCommit();
}
}
});
// $NON-NLS-1$
Button deleteStepButton = toolkit.createButton(stepUpDownComposite, "", SWT.PUSH | SWT.CENTER);
deleteStepButton.setLayoutData(new GridData(SWT.FILL, SWT.FILL, false, true, 1, 1));
deleteStepButton.setImage(ImageCache.getCreatedImage(EImage.DELETE_OBJ.getPath()));
deleteStepButton.setToolTipText(Messages.TransformerMainPage_DelTheItem);
deleteStepButton.addSelectionListener(new SelectionListener() {
public void widgetDefaultSelected(org.eclipse.swt.events.SelectionEvent e) {
}
public void widgetSelected(org.eclipse.swt.events.SelectionEvent e) {
int index = TransformerMainPage.this.stepsList.getSelectionIndex();
if ((index >= 0) && (index < TransformerMainPage.this.stepsList.getItemCount())) {
removeStep(index);
}
}
});
// Plugin Specifications
// Sequence
section = this.getNewSection(Messages.TransformerMainPage_StepSpecification);
section.setVisible(false);
sequenceGroup.setLayout(new GridLayout(4, false));
disabledButton = toolkit.createButton((Composite) section.getClient(), Messages.TransformerMainPage_Disabled, SWT.CHECK);
disabledButton.setLayoutData(new GridData(SWT.LEFT, SWT.FILL, false, true, 4, 1));
specsComposite = toolkit.createComposite((Composite) section.getClient(), SWT.NULL);
specsComposite.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true, 1, 1));
specsComposite.setLayout(new GridLayout(4, false));
disabledButton.addSelectionListener(new SelectionAdapter() {
@Override
public void widgetSelected(SelectionEvent e) {
WidgetUtils.enable(specsComposite, !disabledButton.getSelection());
markDirtyWithoutCommit();
if (stepsList.getSelectionIndex() >= 0) {
transformer.getProcessSteps().get(stepsList.getSelectionIndex()).setDisabled(disabledButton.getSelection());
}
}
});
// $NON-NLS-1$
stepLabel = toolkit.createLabel(specsComposite, "", SWT.NULL);
stepLabel.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true, 4, 1));
FontData fd = stepLabel.getFont().getFontData()[0];
fd.setStyle(SWT.BOLD);
stepLabel.setFont(new Font(Display.getDefault(), fd));
stepWidget = new TransformerStepWidget(toolkit, specsComposite);
stepWidget.create();
btnAutoIndent = new Button(specsComposite, SWT.CHECK);
btnAutoIndent.setText(Messages.TransformerMainPage_AutoIndent);
btnAutoIndent.setImage(ImageCache.getCreatedImage(EImage.INTENT.getPath()));
btnAutoIndent.setLayoutData(new GridData(SWT.LEFT, SWT.CENTER, false, false, 2, 1));
// refreshAutoIndentTooltip();
btnAutoIndent.addSelectionListener(new SelectionAdapter() {
@Override
public void widgetSelected(SelectionEvent e) {
refreshAutoIndentTooltip();
}
});
btnOpenXsltEditor = new Button(specsComposite, SWT.PUSH);
btnOpenXsltEditor.setText(Messages.TransformerMainPage_open);
btnOpenXsltEditor.setToolTipText(Messages.TransformerMainPage_opentext);
btnOpenXsltEditor.setLayoutData(new GridData(SWT.LEFT, SWT.CENTER, false, false, 2, 1));
btnOpenXsltEditor.addSelectionListener(new SelectionAdapter() {
@Override
public void widgetSelected(SelectionEvent e) {
openInXSLTEditor();
}
public void openInXSLTEditor() {
refreshEnableState(false);
try {
// $NON-NLS-1$
IPreferenceStore preference = new ScopedPreferenceStore(new InstanceScope(), "org.eclipse.wst.xsl.ui");
// $NON-NLS-1$
String charSet = preference.getString("outputCodeset");
String xslcontent = parameterEditor.getContent().getContent();
IFile file = FileProvider.createdTempFile(xslcontent, getXSLTFileName(), charSet);
IWorkbenchPage page = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage();
xsltEditorInput = new XSLTFileEditorInput(file, new MainPageRefresher(), true);
page.openEditor(xsltEditorInput, XSLTEditor.ID);
} catch (PartInitException e) {
log.error(e.getMessage(), e);
}
}
});
Group parametersGroup = new Group(specsComposite, SWT.SHADOW_NONE);
parametersGroup.setText(Messages.TransformerMainPage_Parameters);
parametersGroup.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true, 4, 1));
((GridData) parametersGroup.getLayoutData()).minimumHeight = 300;
parametersGroup.setLayout(new GridLayout(1, true));
parameterEditor = new ExtensibleContentEditor(parametersGroup, SWT.NONE, EXCONTENTEDITOR_ID);
parameterEditor.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true, 4, 1));
parameterEditorListener = new ProcessPluginParameterEditorListener();
refreshParameterEditor();
refreshData();
addToolBarItem();
this.oldBackground = parameterEditor.getBackground();
} catch (Exception e) {
log.error(e.getMessage(), e);
}
}
use of org.eclipse.swt.dnd.DropTarget in project tmdm-studio-se by Talend.
the class MenuMainPage method createCharacteristicsContent.
@Override
protected void createCharacteristicsContent(FormToolkit toolkit, Composite mainComposite) {
try {
// description
Label descriptionLabel = toolkit.createLabel(mainComposite, Messages.MenuMainPage_Description, SWT.NULL);
descriptionLabel.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, false, true, 1, 1));
// $NON-NLS-1$
descriptionText = toolkit.createText(mainComposite, "", SWT.BORDER);
descriptionText.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true, 1, 1));
((GridData) descriptionText.getLayoutData()).minimumHeight = 30;
descriptionText.addModifyListener(new ModifyListener() {
public void modifyText(ModifyEvent e) {
if (refreshing) {
return;
}
markDirtyWithoutCommit();
}
});
// Util.createCompDropTarget(descriptionText);
// 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());
Composite composite = toolkit.createComposite(mainComposite, SWT.BORDER);
composite.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true, 2, 1));
composite.setLayout(new GridLayout(1, false));
menuTree = new TreeViewer(composite, SWT.MULTI | SWT.H_SCROLL | SWT.V_SCROLL);
menuTree.getControl().setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true, 1, 1));
((GridData) menuTree.getControl().getLayoutData()).heightHint = 150;
menuTree.setContentProvider(new ITreeContentProvider() {
public void dispose() {
}
public Object[] getChildren(Object parentElement) {
if (parentElement instanceof TreeEntry) {
WSMenuEntry wsEntry = ((TreeEntry) parentElement).getWSMenuEntry();
if (wsEntry.getSubMenus() != null) {
TreeEntry[] children = new TreeEntry[wsEntry.getSubMenus().size()];
for (int i = 0; i < wsEntry.getSubMenus().size(); i++) {
children[i] = new TreeEntry((TreeEntry) parentElement, wsEntry.getSubMenus().get(i));
}
return children;
}
return null;
}
if (parentElement instanceof WSMenu) {
// the root
java.util.List<WSMenuEntry> menuEntries = ((WSMenu) parentElement).getMenuEntries();
if (menuEntries != null) {
TreeEntry[] children = new TreeEntry[menuEntries.size()];
for (int i = 0; i < menuEntries.size(); i++) {
children[i] = new TreeEntry(null, menuEntries.get(i));
}
return children;
}
return null;
}
// ??!!?
return null;
}
public Object[] getElements(Object inputElement) {
return getChildren(inputElement);
}
public Object getParent(Object element) {
return null;
}
public boolean hasChildren(Object element) {
return ((getChildren(element) == null) || (getChildren(element).length > 0));
}
public void inputChanged(Viewer viewer, Object oldInput, Object newInput) {
}
});
menuTree.setLabelProvider(new LabelProvider() {
@Override
public String getText(Object element) {
WSMenuEntry wsMenuEntry = ((TreeEntry) element).getWSMenuEntry();
// $NON-NLS-1$
StringBuffer label = new StringBuffer(wsMenuEntry.getId() + " - ");
for (WSMenuMenuEntriesDescriptions description : wsMenuEntry.getDescriptions()) {
// $NON-NLS-1$//$NON-NLS-2$
label.append("[").append(description.getLanguage()).append(": ").append(description.getLabel()).append(// $NON-NLS-1$
"] ");
}
if (label.length() > 200) {
// $NON-NLS-1$
return label.substring(0, 197) + "...";
}
return label.toString();
}
@Override
public Image getImage(Object element) {
return ImageCache.getCreatedImage(EImage.MENU.getPath());
}
});
menuTreeMgr = new MenuManager();
menuTreeMgr.setRemoveAllWhenShown(true);
menuTreeMgr.addMenuListener(new IMenuListener() {
public void menuAboutToShow(IMenuManager manager) {
IStructuredSelection selection = ((IStructuredSelection) menuTree.getSelection());
if ((selection == null) || (selection.getFirstElement() == null)) {
manager.add(new Separator(IWorkbenchActionConstants.MB_ADDITIONS));
return;
}
// TreeEntry entry = (TreeEntry)selection.getFirstElement();
menuTreeMgr.add(new TreeEntryEditAction(menuTree));
menuTreeMgr.add(new TreeEntryAddAction(menuTree, LOCATION_BEFORE));
menuTreeMgr.add(new TreeEntryAddAction(menuTree, LOCATION_AFTER));
menuTreeMgr.add(new TreeEntryAddAction(menuTree, LOCATION_UNDER));
menuTreeMgr.add(new TreeEntryDeleteAction(menuTree));
menuTreeMgr.add(new Separator(IWorkbenchActionConstants.MB_ADDITIONS));
}
});
menuTree.addDoubleClickListener(new IDoubleClickListener() {
public void doubleClick(DoubleClickEvent event) {
(new TreeEntryEditAction(menuTree)).run();
}
});
Menu menu = menuTreeMgr.createContextMenu(menuTree.getControl());
menuTree.getControl().setMenu(menu);
getSite().registerContextMenu(menuTreeMgr, menuTree);
refreshData();
} catch (Exception e) {
log.error(e.getMessage(), e);
}
}
Aggregations