提交 9fc6c314 编写于 作者: S serge-rider

#6570 ERD tooltips

上级 037ebab8
......@@ -24,10 +24,12 @@ import org.eclipse.jface.resource.ColorRegistry;
import org.eclipse.swt.graphics.Color;
import org.eclipse.swt.graphics.Image;
import org.eclipse.swt.graphics.RGB;
import org.jkiss.code.NotNull;
import org.jkiss.dbeaver.ext.erd.ERDConstants;
import org.jkiss.dbeaver.ext.erd.editor.ERDViewStyle;
import org.jkiss.dbeaver.ext.erd.model.ERDEntity;
import org.jkiss.dbeaver.ext.erd.part.EntityPart;
import org.jkiss.dbeaver.model.DBPDataSourceContainer;
import org.jkiss.dbeaver.model.DBPEvaluationContext;
import org.jkiss.dbeaver.model.DBUtils;
import org.jkiss.dbeaver.model.struct.DBSEntityType;
......@@ -69,11 +71,13 @@ public class EntityFigure extends Figure {
if (!CommonUtils.isEmpty(entity.getAlias())) {
entityName += " " + entity.getAlias();
}
nameLabel = new EditableLabel(
entityName);
if (tableImage != null) {
nameLabel.setIcon(tableImage);
}
nameLabel = new EditableLabel(entityName) {
@Override
public IFigure getToolTip() {
return createToolTip();
}
};
nameLabel.setIcon(tableImage);
nameLabel.setBorder(new MarginBorder(3));
Label descLabel = null;
......@@ -105,15 +109,36 @@ public class EntityFigure extends Figure {
add(keyFigure);
add(attributeFigure);
// Tooltip doesn't make sense and just flicks around
/*
Label toolTip = new Label(DBUtils.getObjectFullName(entity.getObject(), DBPEvaluationContext.UI));
toolTip.setIcon(tableImage);
setToolTip(toolTip);
*/
refreshColors();
}
@NotNull
private IFigure createToolTip() {
ERDEntity entity = part.getEntity();
DBPDataSourceContainer dataSource = entity.getDataSource().getContainer();
Figure toolTip = new Figure();
toolTip.setOpaque(true);
//toolTip.setPreferredSize(300, 200);
toolTip.setBorder(getBorder());
toolTip.setLayoutManager(new GridLayout(1, false));
{
Label dsLabel = new Label(dataSource.getName());
dsLabel.setIcon(DBeaverIcons.getImage(dataSource.getDriver().getIcon()));
dsLabel.setBorder(new MarginBorder(2));
toolTip.add(dsLabel);
}
{
Label entityLabel = new Label(DBUtils.getObjectFullName(entity.getObject(), DBPEvaluationContext.UI));
entityLabel.setIcon(DBeaverIcons.getImage(entity.getObject().getEntityType().getIcon()));
entityLabel.setBorder(new MarginBorder(2));
toolTip.add(entityLabel);
}
return toolTip;
}
protected Color getBorderColor() {
int dsIndex = getPart().getDiagram().getDataSourceIndex(part.getEntity().getDataSource().getContainer());
RGB[] extraDsColors = ERDConstants.EXTRA_DS_COLORS;
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册