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));
}
}
Aggregations