use of org.talend.sqlbuilder.erdiagram.ui.nodes.ErDiagram in project tdi-studio-se by Talend.
the class ErDiagramComposite method createErDiagram.
/**
* admin Comment method "createErDiagram".
*
* @return
*/
private ErDiagram createErDiagram(boolean isShowDesignerPage) {
erDiagram = new ErDiagram();
erDiagram.setErDiagramComposite(this);
if (isShowDesignerPage) {
IRunnableWithProgress progress = new IRunnableWithProgress() {
public void run(IProgressMonitor monitor) throws InvocationTargetException, InterruptedException {
//$NON-NLS-1$
monitor.beginTask("", IProgressMonitor.UNKNOWN);
try {
List<MetadataColumn> selectedColumns = new ArrayList<MetadataColumn>();
List<MetadataTable> tables = EMFRepositoryNodeManager.getInstance().getTables(getNodes(), selectedColumns);
erDiagram.setMetadataTables(tables);
List<String[]> fks = EMFRepositoryNodeManager.getInstance().getPKFromTables(tables, erDiagram.getErDiagramComposite().getDialog().getSelectedContext());
for (MetadataTable metadataTable : tables) {
Table table = new Table();
table.setMetadataTable(metadataTable, selectedColumns);
table.setErDiagram(erDiagram);
erDiagram.addTable(table);
}
erDiagram.setRelations(fks);
} finally {
monitor.done();
}
}
};
UIUtils.runWithProgress(progress, true, dialog.getProgressMonitor(), dialog.getShell());
} else {
erDiagram.setMetadataTables(new ArrayList<MetadataTable>());
erDiagram.setRelations(new ArrayList<String[]>());
}
return erDiagram;
}
use of org.talend.sqlbuilder.erdiagram.ui.nodes.ErDiagram in project tdi-studio-se by Talend.
the class ErDiagramPart method propertyChange.
/*
* (non-Javadoc)
*
* @see java.beans.PropertyChangeListener#propertyChange(java.beans.PropertyChangeEvent)
*/
public void propertyChange(PropertyChangeEvent evt) {
refreshChildren();
ErDiagram model2 = (ErDiagram) getModel();
if (evt.getPropertyName().equals(ErDiagram.PROP_ISDIRTY)) {
model2.updateSqlText();
} else {
(model2).setDirty(true);
}
}
use of org.talend.sqlbuilder.erdiagram.ui.nodes.ErDiagram in project tdi-studio-se by Talend.
the class TableEditPolicy method createDeleteCommand.
@Override
protected Command createDeleteCommand(GroupRequest deleteRequest) {
Object parent = getHost().getParent().getModel();
if (!(parent instanceof ErDiagram)) {
return null;
}
List<Table> nodeList = new ArrayList<Table>();
for (int i = 0; i < deleteRequest.getEditParts().size(); i++) {
if (deleteRequest.getEditParts().get(i) instanceof TablePart) {
nodeList.add((Table) ((TablePart) deleteRequest.getEditParts().get(i)).getModel());
}
}
DeleteTableCommand command = new DeleteTableCommand((ErDiagram) parent, nodeList);
return command;
}
use of org.talend.sqlbuilder.erdiagram.ui.nodes.ErDiagram in project tdi-studio-se by Talend.
the class ErDiagramPartFactory method createEditPart.
/*
* (non-Javadoc)
*
* @see org.eclipse.gef.EditPartFactory#createEditPart(org.eclipse.gef.EditPart, java.lang.Object)
*/
public EditPart createEditPart(EditPart context, Object model) {
EditPart part = null;
if (model instanceof ErDiagram) {
part = new ErDiagramPart();
} else if (model instanceof Column) {
part = new ColumnPart();
} else if (model instanceof Table) {
part = new TablePart();
} else if (model instanceof Relation) {
part = new RelationPart();
} else {
return null;
}
// tell the newly created part about the model object
part.setModel(model);
return part;
}
use of org.talend.sqlbuilder.erdiagram.ui.nodes.ErDiagram in project tdi-studio-se by Talend.
the class TableAddAction method run.
/*
* (non-Java)
*
* @see org.eclipse.jface.action.Action#run()
*/
//$NON-NLS-1$
@SuppressWarnings("unchecked")
@Override
public void run() {
ErdiagramDiagramEditor erdiagramDiagramEditor = (ErdiagramDiagramEditor) part;
Control control = erdiagramDiagramEditor.getGraphicalControl();
AddTablesDialog dialog = new AddTablesDialog(new Shell(control.getShell()));
if (control.getParent() instanceof ErDiagramComposite) {
if (EMFRepositoryNodeManager.getInstance().getRoot() == null) {
return;
}
dialog.setRootNode(EMFRepositoryNodeManager.getInstance().getRoot());
}
if (Window.OK == dialog.open()) {
List tables1 = dialog.getTables();
this.execute(createCreateCommand((ErDiagram) erdiagramDiagramEditor.getViewer().getContents().getModel(), tables1));
}
}
Aggregations