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