use of org.jkiss.dbeaver.erd.ui.part.EntityPart in project dbeaver by dbeaver.
the class ERDGraphicalViewer method setContents.
@Override
public void setContents(EditPart editpart) {
loadContents = true;
try {
super.setContents(editpart);
// Reset palette contents
if (editpart instanceof DiagramPart) {
List<DBSEntity> tables = new ArrayList<>();
for (Object child : editpart.getChildren()) {
if (child instanceof EntityPart) {
tables.add(((EntityPart) child).getEntity().getObject());
}
}
tables.sort(DBUtils.nameComparator());
Map<PaletteDrawer, List<ToolEntryTable>> toolMap = new LinkedHashMap<>();
for (DBSEntity table : tables) {
DBPDataSourceContainer container = table.getDataSource().getContainer();
PaletteDrawer drawer = getContainerPaletteDrawer(container);
if (drawer != null) {
List<ToolEntryTable> tools = toolMap.get(drawer);
if (tools == null) {
tools = new ArrayList<>(tables.size());
toolMap.put(drawer, tools);
}
tools.add(new ToolEntryTable(table));
}
}
for (Map.Entry<PaletteDrawer, List<ToolEntryTable>> entry : toolMap.entrySet()) {
entry.getKey().setChildren(entry.getValue());
}
// editor.getPaletteContents().setChildren(tools);
}
} finally {
loadContents = false;
}
}
use of org.jkiss.dbeaver.erd.ui.part.EntityPart in project dbeaver by dbeaver.
the class EntityDirectEditPolicy method revertOldEditValue.
@Override
protected void revertOldEditValue(DirectEditRequest request) {
CellEditor cellEditor = request.getCellEditor();
cellEditor.setValue(oldValue);
EntityPart entityPart = (EntityPart) getHost();
entityPart.revertNameChange();
}
use of org.jkiss.dbeaver.erd.ui.part.EntityPart in project dbeaver by dbeaver.
the class EntityDirectEditPolicy method showCurrentEditValue.
@Override
protected void showCurrentEditValue(DirectEditRequest request) {
String value = (String) request.getCellEditor().getValue();
EntityPart entityPart = (EntityPart) getHost();
entityPart.handleNameChange(value);
}
use of org.jkiss.dbeaver.erd.ui.part.EntityPart in project dbeaver by serge-rider.
the class ERDEditorPart method fillAttributeVisibilityMenu.
public void fillAttributeVisibilityMenu(IMenuManager menu) {
MenuManager asMenu = new MenuManager(ERDUIMessages.menu_view_style);
asMenu.add(new ChangeAttributePresentationAction(ERDViewStyle.ICONS));
asMenu.add(new ChangeAttributePresentationAction(ERDViewStyle.TYPES));
asMenu.add(new ChangeAttributePresentationAction(ERDViewStyle.NULLABILITY));
asMenu.add(new ChangeAttributePresentationAction(ERDViewStyle.COMMENTS));
asMenu.add(new ChangeAttributePresentationAction(ERDViewStyle.ENTITY_FQN));
menu.add(asMenu);
if (getDiagram().getDecorator().supportsAttributeVisibility()) {
MenuManager avMenu = new MenuManager(ERDUIMessages.menu_attribute_visibility);
avMenu.add(new EmptyAction(ERDUIMessages.menu_attribute_visibility_default));
avMenu.add(new ChangeAttributeVisibilityAction(true, ERDAttributeVisibility.ALL));
avMenu.add(new ChangeAttributeVisibilityAction(true, ERDAttributeVisibility.KEYS));
avMenu.add(new ChangeAttributeVisibilityAction(true, ERDAttributeVisibility.PRIMARY));
avMenu.add(new ChangeAttributeVisibilityAction(true, ERDAttributeVisibility.NONE));
ISelection selection = getGraphicalViewer().getSelection();
if (selection instanceof IStructuredSelection && !selection.isEmpty()) {
int totalEntities = 0;
for (Object item : ((IStructuredSelection) selection).toArray()) {
if (item instanceof EntityPart) {
totalEntities++;
}
}
if (totalEntities > 0) {
avMenu.add(new Separator());
String avaTitle = ERDUIMessages.menu_attribute_visibility_entity;
if (((IStructuredSelection) selection).size() == 1) {
avaTitle += " (" + ((IStructuredSelection) selection).getFirstElement() + ")";
} else {
avaTitle += " (" + totalEntities + ")";
}
avMenu.add(new EmptyAction(avaTitle));
avMenu.add(new ChangeAttributeVisibilityAction(false, ERDAttributeVisibility.ALL));
avMenu.add(new ChangeAttributeVisibilityAction(false, ERDAttributeVisibility.KEYS));
avMenu.add(new ChangeAttributeVisibilityAction(false, ERDAttributeVisibility.PRIMARY));
avMenu.add(new ChangeAttributeVisibilityAction(false, ERDAttributeVisibility.NONE));
}
}
menu.add(avMenu);
}
}
use of org.jkiss.dbeaver.erd.ui.part.EntityPart in project dbeaver by serge-rider.
the class ERDEditorPart method restoreVisualSettings.
private boolean restoreVisualSettings(DiagramPart oldDiagram, EntityDiagram newDiagram) {
boolean hasChanges = false;
// Collect visual settings from old diagram and apply them to the new one
for (ERDEntity newEntity : newDiagram.getEntities()) {
NodePart oldEntity = oldDiagram.getChildByObject(newEntity.getObject());
if (oldEntity instanceof EntityPart) {
EntityDiagram.NodeVisualInfo vi = new EntityDiagram.NodeVisualInfo(oldEntity);
newDiagram.addVisualInfo(newEntity.getObject(), vi);
hasChanges = true;
}
}
for (ERDNote newNote : newDiagram.getNotes()) {
NodePart oldNotePart = oldDiagram.getChildByObject(newNote.getObject());
if (oldNotePart instanceof NotePart) {
EntityDiagram.NodeVisualInfo vi = new EntityDiagram.NodeVisualInfo(oldNotePart);
vi.initBounds = oldNotePart.getBounds();
newDiagram.addVisualInfo(newNote, vi);
hasChanges = true;
}
}
return hasChanges;
}
Aggregations