Search in sources :

Example 6 with PropertyChangeProvider

use of com.cubrid.common.ui.er.model.PropertyChangeProvider in project cubrid-manager by CUBRID.

the class AbstractBasicPart method handleChildChange.

protected void handleChildChange(PropertyChangeEvent evt) {
    Object newValue = evt.getNewValue();
    Object oldValue = evt.getOldValue();
    if ((oldValue == null) && (newValue == null)) {
        throw new IllegalStateException(Messages.errOldNewValueBothNull);
    }
    if (oldValue != null) {
        List children = getChildren();
        EditPart partToRemove = null;
        for (Iterator iter = children.iterator(); iter.hasNext(); ) {
            EditPart part = (EditPart) iter.next();
            if (part.getModel() instanceof PropertyChangeProvider && oldValue instanceof PropertyChangeProvider) {
                PropertyChangeProvider model = (PropertyChangeProvider) part.getModel();
                PropertyChangeProvider old = (PropertyChangeProvider) oldValue;
                PropertyChangeProvider newV = (PropertyChangeProvider) newValue;
                if (newV != null && model.getName().equals(newV.getName())) {
                    return;
                }
                if (model.getName().equals(old.getName())) {
                    partToRemove = part;
                    break;
                }
            } else if (part.getModel().equals(oldValue)) {
                partToRemove = part;
                break;
            }
        }
        if (partToRemove != null) {
            removeChild(partToRemove);
        }
    }
    if (newValue != null) {
        EditPart editPart = createChild(newValue);
        int modelIndex = getModelChildren().indexOf(newValue);
        addChild(editPart, modelIndex);
    }
}
Also used : PropertyChangeProvider(com.cubrid.common.ui.er.model.PropertyChangeProvider) AbstractGraphicalEditPart(org.eclipse.gef.editparts.AbstractGraphicalEditPart) GraphicalEditPart(org.eclipse.gef.GraphicalEditPart) EditPart(org.eclipse.gef.EditPart) ConnectionEditPart(org.eclipse.gef.ConnectionEditPart) Iterator(java.util.Iterator) List(java.util.List)

Example 7 with PropertyChangeProvider

use of com.cubrid.common.ui.er.model.PropertyChangeProvider in project cubrid-manager by CUBRID.

the class AbstractBasicPart method activate.

public void activate() {
    super.activate();
    PropertyChangeProvider propertyChangeProvider = (PropertyChangeProvider) getModel();
    if (propertyChangeProvider != null) {
        propertyChangeProvider.addPropertyChangeListener(this);
    }
}
Also used : PropertyChangeProvider(com.cubrid.common.ui.er.model.PropertyChangeProvider)

Example 8 with PropertyChangeProvider

use of com.cubrid.common.ui.er.model.PropertyChangeProvider in project cubrid-manager by CUBRID.

the class AbstractSelectionAction method getSelectedNode.

/**
	 * Get the first selected node.
	 * 
	 * @return
	 */
protected PropertyChangeProvider getSelectedNode() {
    List objects = getSelectedObjects();
    if (objects.isEmpty()) {
        return null;
    }
    if (!(objects.get(0) instanceof EditPart)) {
        return null;
    }
    EditPart part = (EditPart) objects.get(0);
    return (PropertyChangeProvider) part.getModel();
}
Also used : PropertyChangeProvider(com.cubrid.common.ui.er.model.PropertyChangeProvider) EditPart(org.eclipse.gef.EditPart) List(java.util.List)

Example 9 with PropertyChangeProvider

use of com.cubrid.common.ui.er.model.PropertyChangeProvider in project cubrid-manager by CUBRID.

the class AbstractSelectionAction method getERTable.

protected ERTable getERTable() {
    ERTable table = null;
    PropertyChangeProvider node = getSelectedNode();
    if (node instanceof ERTable) {
        table = (ERTable) node;
    } else if (node instanceof ERTableColumn) {
        ERTableColumn col = (ERTableColumn) node;
        table = col.getTable();
    }
    return table;
}
Also used : PropertyChangeProvider(com.cubrid.common.ui.er.model.PropertyChangeProvider) ERTableColumn(com.cubrid.common.ui.er.model.ERTableColumn) ERTable(com.cubrid.common.ui.er.model.ERTable)

Example 10 with PropertyChangeProvider

use of com.cubrid.common.ui.er.model.PropertyChangeProvider in project cubrid-manager by CUBRID.

the class ModifyTableNameAction method run.

@Override
public void run() {
    PropertyChangeProvider node = getSelectedNode();
    boolean isPhysicModel = getERSchema().isPhysicModel();
    String oldName = ((ERTable) node).getShownName();
    Set<String> names = getERSchema().getAllShownTableNames();
    names.remove(oldName);
    RenameTableDialog dlg = new RenameTableDialog(PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell(), oldName, true, new ArrayList<String>(names), isPhysicModel);
    int ret = dlg.open();
    if (ret == IDialogConstants.OK_ID) {
        String newName = dlg.getNewName();
        if (StringUtil.isEqual(oldName, newName)) {
            return;
        }
        getERSchema().modifyTableNameAndFire(oldName, newName, isPhysicModel);
    }
}
Also used : PropertyChangeProvider(com.cubrid.common.ui.er.model.PropertyChangeProvider) RenameTableDialog(com.cubrid.common.ui.cubrid.table.dialog.RenameTableDialog) ERTable(com.cubrid.common.ui.er.model.ERTable)

Aggregations

PropertyChangeProvider (com.cubrid.common.ui.er.model.PropertyChangeProvider)10 EditPart (org.eclipse.gef.EditPart)3 ERTable (com.cubrid.common.ui.er.model.ERTable)2 List (java.util.List)2 RenameTableDialog (com.cubrid.common.ui.cubrid.table.dialog.RenameTableDialog)1 ERTableColumn (com.cubrid.common.ui.er.model.ERTableColumn)1 Iterator (java.util.Iterator)1 ConnectionEditPart (org.eclipse.gef.ConnectionEditPart)1 GraphicalEditPart (org.eclipse.gef.GraphicalEditPart)1 AbstractGraphicalEditPart (org.eclipse.gef.editparts.AbstractGraphicalEditPart)1