Search in sources :

Example 1 with ErDiagram

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;
}
Also used : MetadataColumn(org.talend.core.model.metadata.builder.connection.MetadataColumn) IProgressMonitor(org.eclipse.core.runtime.IProgressMonitor) MetadataTable(org.talend.core.model.metadata.builder.connection.MetadataTable) Table(org.talend.sqlbuilder.erdiagram.ui.nodes.Table) ErDiagram(org.talend.sqlbuilder.erdiagram.ui.nodes.ErDiagram) ArrayList(java.util.ArrayList) MetadataTable(org.talend.core.model.metadata.builder.connection.MetadataTable) IRunnableWithProgress(org.eclipse.jface.operation.IRunnableWithProgress)

Example 2 with 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);
    }
}
Also used : ErDiagram(org.talend.sqlbuilder.erdiagram.ui.nodes.ErDiagram)

Example 3 with ErDiagram

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;
}
Also used : Table(org.talend.sqlbuilder.erdiagram.ui.nodes.Table) ErDiagram(org.talend.sqlbuilder.erdiagram.ui.nodes.ErDiagram) ArrayList(java.util.ArrayList) DeleteTableCommand(org.talend.sqlbuilder.erdiagram.ui.commands.DeleteTableCommand)

Example 4 with ErDiagram

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;
}
Also used : RelationPart(org.talend.sqlbuilder.erdiagram.ui.parts.RelationPart) Relation(org.talend.sqlbuilder.erdiagram.ui.nodes.Relation) Table(org.talend.sqlbuilder.erdiagram.ui.nodes.Table) ErDiagram(org.talend.sqlbuilder.erdiagram.ui.nodes.ErDiagram) Column(org.talend.sqlbuilder.erdiagram.ui.nodes.Column) EditPart(org.eclipse.gef.EditPart) TablePart(org.talend.sqlbuilder.erdiagram.ui.parts.TablePart) ColumnPart(org.talend.sqlbuilder.erdiagram.ui.parts.ColumnPart) ErDiagramPart(org.talend.sqlbuilder.erdiagram.ui.parts.ErDiagramPart)

Example 5 with ErDiagram

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));
    }
}
Also used : ErdiagramDiagramEditor(org.talend.sqlbuilder.erdiagram.ui.editor.ErdiagramDiagramEditor) ErDiagramComposite(org.talend.sqlbuilder.erdiagram.ui.ErDiagramComposite) Control(org.eclipse.swt.widgets.Control) Shell(org.eclipse.swt.widgets.Shell) ErDiagram(org.talend.sqlbuilder.erdiagram.ui.nodes.ErDiagram) AddTablesDialog(org.talend.sqlbuilder.erdiagram.ui.AddTablesDialog) List(java.util.List)

Aggregations

ErDiagram (org.talend.sqlbuilder.erdiagram.ui.nodes.ErDiagram)5 Table (org.talend.sqlbuilder.erdiagram.ui.nodes.Table)3 ArrayList (java.util.ArrayList)2 List (java.util.List)1 IProgressMonitor (org.eclipse.core.runtime.IProgressMonitor)1 EditPart (org.eclipse.gef.EditPart)1 IRunnableWithProgress (org.eclipse.jface.operation.IRunnableWithProgress)1 Control (org.eclipse.swt.widgets.Control)1 Shell (org.eclipse.swt.widgets.Shell)1 MetadataColumn (org.talend.core.model.metadata.builder.connection.MetadataColumn)1 MetadataTable (org.talend.core.model.metadata.builder.connection.MetadataTable)1 AddTablesDialog (org.talend.sqlbuilder.erdiagram.ui.AddTablesDialog)1 ErDiagramComposite (org.talend.sqlbuilder.erdiagram.ui.ErDiagramComposite)1 DeleteTableCommand (org.talend.sqlbuilder.erdiagram.ui.commands.DeleteTableCommand)1 ErdiagramDiagramEditor (org.talend.sqlbuilder.erdiagram.ui.editor.ErdiagramDiagramEditor)1 Column (org.talend.sqlbuilder.erdiagram.ui.nodes.Column)1 Relation (org.talend.sqlbuilder.erdiagram.ui.nodes.Relation)1 ColumnPart (org.talend.sqlbuilder.erdiagram.ui.parts.ColumnPart)1 ErDiagramPart (org.talend.sqlbuilder.erdiagram.ui.parts.ErDiagramPart)1 RelationPart (org.talend.sqlbuilder.erdiagram.ui.parts.RelationPart)1