use of com.amalto.workbench.providers.TypesLabelProvider in project tmdm-studio-se by Talend.
the class SelectImportedModulesDialog method createDialogArea.
@Override
protected Control createDialogArea(Composite parent) {
parent.getShell().setText(this.title);
Composite composite = (Composite) super.createDialogArea(parent);
GridLayout layout = (GridLayout) composite.getLayout();
layout.numColumns = 2;
SashForm form = new SashForm(composite, SWT.HORIZONTAL);
GridData data = new GridData(GridData.FILL, GridData.FILL, true, true, 1, 1);
data.widthHint = 400;
data.heightHint = 300;
form.setLayoutData(data);
entityViewer = createTableViewer(form, "Entities", entityprovider, new XSDTreeLabelProvider());
typeViewer = createTableViewer(form, "Types", typeprovider, new TypesLabelProvider());
form.setWeights(new int[] { 3, 5 });
Composite compositeBtn = new Composite(composite, SWT.FILL);
compositeBtn.setLayoutData(new GridData(SWT.FILL, SWT.NONE, false, false, 1, 1));
compositeBtn.setLayout(new GridLayout(1, false));
Button addXSDFromLocal = new Button(compositeBtn, SWT.PUSH | SWT.FILL);
addXSDFromLocal.setLayoutData(new GridData(SWT.FILL, SWT.NONE, false, false, 1, 1));
addXSDFromLocal.setText(Messages.AddXsdFromlocal);
addXSDFromLocal.setToolTipText(Messages.AddXsdSchemaFromlocal);
addXSDFromLocal.addSelectionListener(new SelectionListener() {
public void widgetDefaultSelected(org.eclipse.swt.events.SelectionEvent e) {
}
public void widgetSelected(org.eclipse.swt.events.SelectionEvent e) {
FileDialog fd = new FileDialog(shell.getShell(), SWT.SAVE);
// $NON-NLS-1$
fd.setFilterExtensions(new String[] { "*.xsd" });
fd.setText(Messages.ImportXSDSchema);
String filename = fd.open();
if (filename == null) {
return;
}
URL url = getSourceURL("file:///" + filename);
addSchema(url, true);
}
});
if (exAdapter != null) {
exAdapter.createDialogArea(compositeBtn);
}
Button impXSDFromExchange = new Button(compositeBtn, SWT.PUSH | SWT.FILL);
impXSDFromExchange.setLayoutData(new GridData(SWT.FILL, SWT.NONE, false, false, 1, 1));
impXSDFromExchange.setText(Messages.ImportFromExchangeServer);
impXSDFromExchange.setToolTipText(Messages.ImportSchemaFromServer);
impXSDFromExchange.addSelectionListener(new SelectionListener() {
public void widgetDefaultSelected(SelectionEvent e) {
}
public void widgetSelected(SelectionEvent e) {
StringBuffer repository = new StringBuffer();
ImportExchangeOptionsDialog dlg = new ImportExchangeOptionsDialog(shell.getShell(), null, false, repository);
dlg.setBlockOnOpen(true);
int ret = dlg.open();
if (ret == Window.OK) {
File dir = new File(repository.toString());
File[] fs = dir.listFiles(new FileFilter() {
public boolean accept(File pathname) {
return pathname.getName().endsWith(".xsd");
}
});
if (null == fs || fs.length == 0) {
MessageDialog.openWarning(getShell(), Messages.import_schema_failed, Messages.no_schema_available);
return;
}
for (File file : fs) {
URL url = getSourceURL("file:///" + file.getPath());
addSchema(url, true);
}
}
}
});
Button addXSDFromInputDlg = new Button(compositeBtn, SWT.PUSH | SWT.FILL);
addXSDFromInputDlg.setLayoutData(new GridData(SWT.FILL, SWT.NONE, false, false, 1, 1));
addXSDFromInputDlg.setText(Messages.AddXsdFromOther);
addXSDFromInputDlg.setToolTipText(Messages.AddFromOtherSite);
addXSDFromInputDlg.addSelectionListener(new SelectionListener() {
public void widgetDefaultSelected(org.eclipse.swt.events.SelectionEvent e) {
}
public void widgetSelected(org.eclipse.swt.events.SelectionEvent e) {
InputDialog id = new InputDialog(shell.getShell(), Messages.AddXsdFromOther, Messages.EnterTextUrl, "", new // $NON-NLS-1$
IInputValidator() {
public String isValid(String newText) {
if ((newText == null) || "".equals(newText)) {
return Messages.NameNotEmpty;
}
return null;
}
});
id.setBlockOnOpen(true);
int ret = id.open();
if (ret == Window.CANCEL) {
return;
}
URL url = getSourceURL(id.getValue());
addSchema(url, true);
}
});
entityViewer.setInput(addContent);
typeViewer.setInput(addContent);
return composite;
}
use of com.amalto.workbench.providers.TypesLabelProvider in project tmdm-studio-se by Talend.
the class DataModelMainPage method createTypeTreeComp.
private void createTypeTreeComp(Composite parent) {
Composite TypeSash = new Composite(parent, SWT.NONE);
GridLayout layout = new GridLayout();
layout.verticalSpacing = 0;
TypeSash.setLayout(layout);
TypeSash.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true));
TypeSash.setBackground(sash.getDisplay().getSystemColor(SWT.COLOR_WHITE));
Composite compInfo = new Composite(TypeSash, SWT.NONE);
layout = new GridLayout();
layout.verticalSpacing = 0;
compInfo.setLayout(layout);
compInfo.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, false));
compInfo.setBackground(sash.getDisplay().getSystemColor(SWT.COLOR_WHITE));
Composite compTypeTree = new Composite(TypeSash, SWT.NONE);
GridLayout glCompTypeTree = new GridLayout();
glCompTypeTree.verticalSpacing = 0;
glCompTypeTree.marginWidth = 0;
glCompTypeTree.marginHeight = 0;
glCompTypeTree.horizontalSpacing = 0;
compTypeTree.setLayout(glCompTypeTree);
compTypeTree.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true));
compTypeTree.setBackground(sash.getDisplay().getSystemColor(SWT.COLOR_WHITE));
Label title = new Label(compInfo, SWT.VERTICAL);
title.setText(Messages.DataModelTypes);
title.setFont(FontUtils.getBoldFont(title.getFont()));
Color blue = new Color(compInfo.getDisplay(), 0, 0, 255);
title.setForeground(blue);
title.setBackground(sash.getDisplay().getSystemColor(SWT.COLOR_WHITE));
ToolBar toolBarTypeTree = createToolbarOnComposite(compTypeTree);
typesViewer = new TreeViewer(compTypeTree, SWT.MULTI | SWT.H_SCROLL | SWT.V_SCROLL | SWT.BORDER);
typesViewer.getControl().setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true));
addToolItems2TypeTreeToolBar(toolBarTypeTree);
toolBarTypeTree.pack();
typesTreeContentProvider = new TypesTreeContentProvider(this.getSite(), xsdSchema);
typesViewer.setContentProvider(typesTreeContentProvider);
typesViewer.setFilters(new ViewerFilter[] { new SchemaRoleAccessFilter(null), new TypeNameFilter() });
typesViewer.getTree().addMouseListener(new MouseAdapter() {
@Override
public void mouseDown(MouseEvent e) {
isSchemaSelected = false;
}
});
typesViewer.setLabelProvider(new TypesLabelProvider());
typesViewer.setSorter(typeTreeSorter);
// getViewSite());
typesViewer.setInput(this.getSite());
typesViewer.getTree().addKeyListener(new KeyAdapter() {
@Override
public void keyPressed(KeyEvent e) {
if (isReadOnly()) {
return;
}
IStructuredSelection selection = ((IStructuredSelection) typesViewer.getSelection());
// delete
if ((e.stateMask == 0) && (e.keyCode == SWT.DEL)) {
deleteConceptWrapAction.regisExtraClassToDel(XSDComplexTypeDefinitionImpl.class);
if (deleteConceptWrapAction.checkInDeletableType(selection.toArray())) {
deleteConceptWrapAction.prepareToDelSelectedItems(selection, viewer);
deleteConceptWrapAction.run();
} else {
deleteConceptWrapAction.clearExtraClassToDel();
deleteConceptWrapAction.regisExtraClassToDel(XSDSimpleTypeDefinitionImpl.class);
if (deleteConceptWrapAction.checkInDeletableType(selection.toArray())) {
deleteConceptWrapAction.prepareToDelSelectedItems(selection, viewer);
deleteConceptWrapAction.run();
} else {
MessageDialog.openWarning(getSite().getShell(), Messages.Warning, Messages.SelectDeletableTry);
}
}
}
}
});
}
Aggregations