Search in sources :

Example 1 with ColumnPart

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

the class ColumnDirectEditPolicy method showCurrentEditValue.

@Override
protected void showCurrentEditValue(DirectEditRequest request) {
    String value = (String) request.getCellEditor().getValue();
    ColumnPart columnPart = (ColumnPart) getHost();
    columnPart.handleNameChange(value);
}
Also used : ColumnPart(com.cubrid.common.ui.er.part.ColumnPart)

Example 2 with ColumnPart

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

the class ColumnDirectEditPolicy method revertOldEditValue.

@Override
protected void revertOldEditValue(DirectEditRequest request) {
    CellEditor cellEditor = request.getCellEditor();
    cellEditor.setValue(oldValue);
    ColumnPart columnPart = (ColumnPart) getHost();
    columnPart.revertNameChange(oldValue);
}
Also used : CellEditor(org.eclipse.jface.viewers.CellEditor) ColumnPart(com.cubrid.common.ui.er.part.ColumnPart)

Example 3 with ColumnPart

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

the class SchemaContextMenuProvider method buildContextMenu.

@Override
public void buildContextMenu(IMenuManager menu) {
    if (!(menu instanceof SchemaContextMenuProvider)) {
        return;
    }
    SchemaContextMenuProvider menuProvider = (SchemaContextMenuProvider) menu;
    EditPartViewer viewer = menuProvider.getViewer();
    if (viewer == null) {
        return;
    }
    buildPublicMenuItems(menu);
    List selectParts = viewer.getSelectedEditParts();
    // blank right-click
    if (selectParts == null || selectParts.size() == 0) {
        return;
    }
    // multi-objects right-click
    if (selectParts.size() > 1) {
        buildMultiFiguresMenuItems(menu);
        return;
    }
    // one object right-click
    Object object = selectParts.get(0);
    if (object instanceof TablePart) {
        buildTableMenuItems(menu);
    } else if (object instanceof ColumnPart) {
        buildColumnMenuItems(menu);
    } else if (object instanceof RelationshipPart) {
        buildRelationshipLineMenuItems(menu);
    }
}
Also used : RelationshipPart(com.cubrid.common.ui.er.part.RelationshipPart) TablePart(com.cubrid.common.ui.er.part.TablePart) EditPartViewer(org.eclipse.gef.EditPartViewer) ColumnPart(com.cubrid.common.ui.er.part.ColumnPart) List(java.util.List)

Example 4 with ColumnPart

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

the class TableLayoutEditPolicy method createAddCommand.

@Override
protected Command createAddCommand(EditPart child, EditPart after) {
    if (!(child instanceof ColumnPart) || !(after instanceof ColumnPart)) {
        return null;
    }
    ERTableColumn toMove = (ERTableColumn) child.getModel();
    ERTableColumn afterModel = (ERTableColumn) after.getModel();
    TablePart originalTablePart = (TablePart) child.getParent();
    ERTable originalTable = (ERTable) originalTablePart.getModel();
    TablePart newTablePart = (TablePart) after.getParent();
    ERTable newTable = newTablePart.getTable();
    int oldIndex = originalTablePart.getChildren().indexOf(child);
    int newIndex = newTablePart.getChildren().indexOf(after);
    return new TransferColumnCommand(toMove, afterModel, originalTable, newTable, oldIndex, newIndex);
}
Also used : ERTableColumn(com.cubrid.common.ui.er.model.ERTableColumn) TablePart(com.cubrid.common.ui.er.part.TablePart) TransferColumnCommand(com.cubrid.common.ui.er.commands.TransferColumnCommand) ColumnPart(com.cubrid.common.ui.er.part.ColumnPart) ERTable(com.cubrid.common.ui.er.model.ERTable)

Example 5 with ColumnPart

use of com.cubrid.common.ui.er.part.ColumnPart 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

ColumnPart (com.cubrid.common.ui.er.part.ColumnPart)5 TablePart (com.cubrid.common.ui.er.part.TablePart)3 RelationshipPart (com.cubrid.common.ui.er.part.RelationshipPart)2 List (java.util.List)2 TransferColumnCommand (com.cubrid.common.ui.er.commands.TransferColumnCommand)1 ERTable (com.cubrid.common.ui.er.model.ERTable)1 ERTableColumn (com.cubrid.common.ui.er.model.ERTableColumn)1 HashSet (java.util.HashSet)1 LinkedList (java.util.LinkedList)1 EditPart (org.eclipse.gef.EditPart)1 EditPartViewer (org.eclipse.gef.EditPartViewer)1 CellEditor (org.eclipse.jface.viewers.CellEditor)1