use of org.talend.designer.xmlmap.ui.tabs.TabFolderEditors in project tdi-studio-se by Talend.
the class RenameTreeNodeAction method run.
@Override
public void run() {
if (selectedNode != null) {
// validataor
IInputValidator validataor = new IInputValidator() {
public String isValid(String newText) {
String xpath = XmlMapUtil.getXPath(((TreeNode) selectedNode.eContainer()).getXpath(), newText, selectedNode.getNodeType());
EList<TreeNode> children = ((TreeNode) selectedNode.eContainer()).getChildren();
boolean exist = false;
for (TreeNode child : children) {
if (child.getNodeType().equals(selectedNode.getNodeType())) {
if (child.getXpath() != null && child.getXpath().equals(xpath) && !child.equals(selectedNode)) {
exist = true;
break;
}
}
}
if (exist) {
if (selectedNode.getNodeType().equals(NodeType.ATTRIBUT)) {
return "Atribute '" + newText + "' already exist !";
} else if (selectedNode.getNodeType().equals(NodeType.ELEMENT)) {
return "Element '" + newText + "' already exist !";
}
}
return null;
}
};
String name = selectedNode.getName();
if (selectedNode.isSubstitution()) {
name = name.substring(0, name.lastIndexOf(XSDPopulationUtil2.SUBS));
}
InputDialog dialog = new InputDialog(null, "Rename Tree Node", "", name, validataor);
if (dialog.open() == Window.OK) {
if (selectedNode.isSubstitution()) {
selectedNode.setName(dialog.getValue() + XSDPopulationUtil2.SUBS);
} else {
selectedNode.setName(dialog.getValue());
}
// refresh
if (selectedNode.isSubstitution()) {
TreeNode realParent = XmlMapUtil.getRealParentNode(selectedNode);
if (realParent != null) {
selectedNode.setXpath(XmlMapUtil.getXPath(realParent.getXpath(), selectedNode.getName(), selectedNode.getNodeType()));
}
} else {
XmlMapData externalEmfData = (XmlMapData) mapperManager.getExternalData();
XmlMapUtil.updateXPathAndExpression(externalEmfData, mapperManager.getMapperComponent().getExpressionManager(), selectedNode, dialog.getValue(), XmlMapUtil.getXPathLength(selectedNode.getXpath()), true);
}
TabFolderEditors tabFolderEditors = mapperManager.getMapperUI().getTabFolderEditors();
if (tabFolderEditors != null) {
if (selectedNode instanceof OutputTreeNode) {
tabFolderEditors.getOutputTreeSchemaEditor().refresh();
} else if (selectedNode instanceof TreeNode) {
tabFolderEditors.getInputTreeSchemaEditor().refresh();
}
}
}
}
}
use of org.talend.designer.xmlmap.ui.tabs.TabFolderEditors in project tdi-studio-se by Talend.
the class MapperUI method createWindow.
public Shell createWindow(final Display display) {
Shell activeShell = display.getActiveShell();
int style = SWT.DIALOG_TRIM | SWT.MIN | SWT.MAX | SWT.APPLICATION_MODAL | SWT.RESIZE;
if (activeShell == null) {
mapperShell = new Shell(mapperShell, style);
} else {
mapperShell = new Shell(activeShell, style);
}
mapperShell.addShellListener(new ShellListener() {
@Override
public void shellActivated(ShellEvent e) {
}
@Override
public void shellClosed(ShellEvent e) {
if (editor != null && editor.isDirty() && !closeWithoutPrompt) {
boolean closeWindow = MessageDialog.openConfirm(mapperShell, "Close without save", Messages.getString("MapperUI.CloseWindow.Message"));
if (!closeWindow) {
e.doit = false;
} else {
prepareClosing(SWT.CANCEL);
}
}
}
@Override
public void shellDeactivated(ShellEvent e) {
}
@Override
public void shellDeiconified(ShellEvent e) {
}
@Override
public void shellIconified(ShellEvent e) {
}
});
mapperShell.setMaximized(true);
mapperShell.setImage(CoreImageProvider.getComponentIcon(mapperComponent.getComponent(), ICON_SIZE.ICON_32));
IBrandingService brandingService = (IBrandingService) GlobalServiceRegister.getDefault().getService(IBrandingService.class);
String productName = brandingService.getFullProductName();
mapperShell.setText(productName + " - " + mapperComponent.getComponent().getName() + " - " + //$NON-NLS-1$
mapperComponent.getUniqueName());
GridLayout parentLayout = new GridLayout(1, true);
mapperShell.setLayout(parentLayout);
// Composite composite = new Composite(mapperShell, SWT.NONE);
// composite.setBackground(display.getSystemColor(SWT.COLOR_YELLOW));
mainSashForm = new SashForm(mapperShell, SWT.SMOOTH | SWT.VERTICAL);
GridData mainSashFormGridData = new GridData(GridData.FILL_BOTH);
mainSashForm.setLayoutData(mainSashFormGridData);
datasViewSashForm = new SashForm(mainSashForm, SWT.SMOOTH | SWT.HORIZONTAL | SWT.BORDER);
editor = new XmlMapEditor(mapperManager);
editor.createPartControl(datasViewSashForm);
if (copyOfMapData.getVarTables().isEmpty()) {
VarTable varTable1 = XmlmapFactory.eINSTANCE.createVarTable();
varTable1.setName("Var");
varTable1.setMinimized(true);
copyOfMapData.getVarTables().add(varTable1);
}
editor.setContent(copyOfMapData);
tabFolderEditors = new TabFolderEditors(mainSashForm, mapperManager, SWT.BORDER);
// selectFirstInOutTree();
mainSashForm.setWeights(new int[] { 70, 30 });
footerComposite = new FooterComposite(mapperShell, this);
footerComposite.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
mapperShell.addDisposeListener(new DisposeListener() {
@Override
public void widgetDisposed(DisposeEvent e) {
ColorProviderMapper.releaseColors();
FontProviderMapper.releaseFonts();
ImageProviderMapper.releaseImages();
}
});
editor.makeDefaultSelection();
mapperShell.open();
return mapperShell;
}
Aggregations