use of com.amalto.workbench.webservices.WSMenuMenuEntriesDescriptions 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);
}
}
use of com.amalto.workbench.webservices.WSMenuMenuEntriesDescriptions in project tmdm-studio-se by Talend.
the class Bean2EObjUtilTest method initBean.
private void initBean(WSMenu menu) {
// $NON-NLS-1$
menu.setDescription("this is a description");
// $NON-NLS-1$
menu.setName("menuA");
//
List<WSMenuEntry> menuEntries = new ArrayList<WSMenuEntry>();
WSMenuEntry menuEntry = new WSMenuEntry();
// $NON-NLS-1$
menuEntry.setApplication("application A");
// $NON-NLS-1$
menuEntry.setContext("contextA");
// $NON-NLS-1$
menuEntry.setIcon("icon A");
// $NON-NLS-1$
menuEntry.setId("id A");
WSMenuMenuEntriesDescriptions ds = new WSMenuMenuEntriesDescriptions();
// $NON-NLS-1$
ds.setLabel("label A");
// $NON-NLS-1$
ds.setLanguage("En");
menuEntry.getDescriptions().add(ds);
menuEntries.add(menuEntry);
//
menuEntry = new WSMenuEntry();
// $NON-NLS-1$
menuEntry.setApplication("application B");
// $NON-NLS-1$
menuEntry.setContext("contextB");
// $NON-NLS-1$
menuEntry.setIcon("icon B");
// $NON-NLS-1$
menuEntry.setId("id B");
menuEntries.add(menuEntry);
//
menu.getMenuEntries().add(menuEntry);
}
Aggregations