Search in sources :

Example 21 with TablePart

use of com.cubrid.common.ui.er.part.TablePart in project cubrid-manager by CUBRID.

the class DeleteAction method run.

/**
	 * 1. First, delete relationship connection line; <br>
	 * 2. Then, delete column; <br>
	 * 3. Delete table at last.
	 */
public void run() {
    List objects = getSelectedObjects();
    if (objects.isEmpty()) {
        return;
    }
    List<EditPart> lineParts = new LinkedList<EditPart>();
    List<EditPart> columnParts = new LinkedList<EditPart>();
    List<EditPart> tableParts = new LinkedList<EditPart>();
    List<String> tableNames = new LinkedList<String>();
    Set<String> columnNames = new HashSet<String>();
    int lineCount = 0;
    for (Object obj : objects) {
        if (obj == null) {
            continue;
        }
        if (obj instanceof RelationshipPart) {
            lineParts.add((RelationshipPart) obj);
            lineCount++;
        } else if (obj instanceof ColumnPart) {
            columnParts.add((ColumnPart) obj);
            columnNames.add(((ColumnPart) obj).getName());
        } else if (obj instanceof TablePart) {
            tableParts.add((TablePart) obj);
            tableNames.add(((TablePart) obj).getName());
        }
    }
    List<EditPart> allParts = new LinkedList<EditPart>(lineParts);
    allParts.addAll(columnParts);
    allParts.addAll(tableParts);
    StringBuilder msg = new StringBuilder(Messages.msgConfirmDelete);
    if (!tableNames.isEmpty()) {
        msg.append(StringUtil.NEWLINE).append(Messages.msgConfirmDeleteTableList).append(tableNames.toString());
    }
    if (!columnNames.isEmpty()) {
        msg.append(StringUtil.NEWLINE).append(Messages.msgConfirmDeleteColumnList).append(columnNames.toString());
    }
    if (lineCount != 0) {
        msg.append(StringUtil.NEWLINE).append(Messages.msgConfirmDeleteLineCount).append(lineCount);
    }
    boolean delete = CommonUITool.openConfirmBox(getWorkbenchPart().getSite().getShell(), msg.toString());
    if (delete) {
        execute(buildDeleteCommands(allParts));
    }
}
Also used : EditPart(org.eclipse.gef.EditPart) TablePart(com.cubrid.common.ui.er.part.TablePart) LinkedList(java.util.LinkedList) RelationshipPart(com.cubrid.common.ui.er.part.RelationshipPart) ColumnPart(com.cubrid.common.ui.er.part.ColumnPart) List(java.util.List) LinkedList(java.util.LinkedList) HashSet(java.util.HashSet)

Aggregations

TablePart (com.cubrid.common.ui.er.part.TablePart)21 List (java.util.List)7 ERTable (com.cubrid.common.ui.er.model.ERTable)5 RelationshipPart (com.cubrid.common.ui.er.part.RelationshipPart)4 ColumnPart (com.cubrid.common.ui.er.part.ColumnPart)3 SchemaDiagramPart (com.cubrid.common.ui.er.part.SchemaDiagramPart)3 ArrayList (java.util.ArrayList)3 EventObject (java.util.EventObject)3 Iterator (java.util.Iterator)3 Rectangle (org.eclipse.draw2d.geometry.Rectangle)3 CreateRelationshipCommand (com.cubrid.common.ui.er.commands.CreateRelationshipCommand)2 TableFigure (com.cubrid.common.ui.er.figures.TableFigure)2 ERTableColumn (com.cubrid.common.ui.er.model.ERTableColumn)2 Edge (org.eclipse.draw2d.graph.Edge)2 CreateColumnCommand (com.cubrid.common.ui.er.commands.CreateColumnCommand)1 DeleteTableCommand (com.cubrid.common.ui.er.commands.DeleteTableCommand)1 MoveTableCommand (com.cubrid.common.ui.er.commands.MoveTableCommand)1 ReconnectForeignKeyCommand (com.cubrid.common.ui.er.commands.ReconnectForeignKeyCommand)1 ReconnectPrimaryKeyCommand (com.cubrid.common.ui.er.commands.ReconnectPrimaryKeyCommand)1 TransferColumnCommand (com.cubrid.common.ui.er.commands.TransferColumnCommand)1