Search in sources :

Example 16 with DBVEntity

use of org.jkiss.dbeaver.model.virtual.DBVEntity in project dbeaver by serge-rider.

the class ResetRowColorAction method run.

@Override
public void run() {
    final DBVEntity vEntity = getColorsVirtualEntity();
    vEntity.removeColorOverride(attribute);
    updateColors(vEntity);
}
Also used : DBVEntity(org.jkiss.dbeaver.model.virtual.DBVEntity)

Example 17 with DBVEntity

use of org.jkiss.dbeaver.model.virtual.DBVEntity in project dbeaver by serge-rider.

the class ResetAllColorAction method run.

@Override
public void run() {
    final DBVEntity vEntity = getColorsVirtualEntity();
    if (!UIUtils.confirmAction("Reset all row coloring", "Are you sure you want to reset all color settings for '" + vEntity.getName() + "'?")) {
        return;
    }
    vEntity.removeAllColorOverride();
    updateColors(vEntity);
}
Also used : DBVEntity(org.jkiss.dbeaver.model.virtual.DBVEntity)

Example 18 with DBVEntity

use of org.jkiss.dbeaver.model.virtual.DBVEntity in project dbeaver by serge-rider.

the class SetRowColorAction method run.

@Override
public void run() {
    RGB color;
    final Shell shell = UIUtils.createCenteredShell(resultSetViewer.getControl().getShell());
    try {
        ColorDialog cd = new ColorDialog(shell);
        color = cd.open();
        if (color == null) {
            return;
        }
    } finally {
        UIUtils.disposeCenteredShell(shell);
    }
    try {
        final DBVEntity vEntity = getColorsVirtualEntity();
        vEntity.setColorOverride(attribute, value, null, StringConverter.asString(color));
        updateColors(vEntity);
    } catch (IllegalStateException e) {
        DBWorkbench.getPlatformUI().showError("Row color", "Can't set row color", e);
    }
}
Also used : Shell(org.eclipse.swt.widgets.Shell) ColorDialog(org.eclipse.swt.widgets.ColorDialog) RGB(org.eclipse.swt.graphics.RGB) DBVEntity(org.jkiss.dbeaver.model.virtual.DBVEntity)

Example 19 with DBVEntity

use of org.jkiss.dbeaver.model.virtual.DBVEntity in project dbeaver by serge-rider.

the class VirtualEntityEditAction method run.

@Override
public void run() {
    DBSDataContainer dataContainer = resultSetViewer.getDataContainer();
    if (dataContainer == null) {
        return;
    }
    DBSEntity entity = resultSetViewer.getModel().isSingleSource() ? resultSetViewer.getModel().getSingleSource() : null;
    DBVEntity vEntity = resultSetViewer.getModel().getVirtualEntity(entity, true);
    EditVirtualEntityDialog dialog = new EditVirtualEntityDialog(resultSetViewer, entity, vEntity);
    dialog.setInitPage(EditVirtualEntityDialog.InitPage.ATTRIBUTES);
    if (dialog.open() == IDialogConstants.OK_ID) {
        resultSetViewer.refreshMetaData();
    }
}
Also used : DBSEntity(org.jkiss.dbeaver.model.struct.DBSEntity) DBSDataContainer(org.jkiss.dbeaver.model.struct.DBSDataContainer) DBVEntity(org.jkiss.dbeaver.model.virtual.DBVEntity)

Example 20 with DBVEntity

use of org.jkiss.dbeaver.model.virtual.DBVEntity in project dbeaver by serge-rider.

the class VirtualUniqueKeyEditAction method isEnabled.

@Override
public boolean isEnabled() {
    DBVEntity vEntity = resultSetViewer.getModel().getVirtualEntity(false);
    DBVEntityConstraint vConstraint = vEntity == null ? null : vEntity.getBestIdentifier();
    return vConstraint != null && (define != vConstraint.hasAttributes());
}
Also used : DBVEntityConstraint(org.jkiss.dbeaver.model.virtual.DBVEntityConstraint) DBVEntity(org.jkiss.dbeaver.model.virtual.DBVEntity)

Aggregations

DBVEntity (org.jkiss.dbeaver.model.virtual.DBVEntity)22 DBException (org.jkiss.dbeaver.DBException)5 DBVEntityAttribute (org.jkiss.dbeaver.model.virtual.DBVEntityAttribute)5 DBSEntity (org.jkiss.dbeaver.model.struct.DBSEntity)4 DBVEntityForeignKey (org.jkiss.dbeaver.model.virtual.DBVEntityForeignKey)4 DBSTable (org.jkiss.dbeaver.model.struct.rdb.DBSTable)3 DBSTableIndex (org.jkiss.dbeaver.model.struct.rdb.DBSTableIndex)3 DBVColorOverride (org.jkiss.dbeaver.model.virtual.DBVColorOverride)3 RGB (org.eclipse.swt.graphics.RGB)2 DBDAttributeBinding (org.jkiss.dbeaver.model.data.DBDAttributeBinding)2 DBDAttributeBindingCustom (org.jkiss.dbeaver.model.data.DBDAttributeBindingCustom)2 DBSEntityAssociation (org.jkiss.dbeaver.model.struct.DBSEntityAssociation)2 DBVEntityConstraint (org.jkiss.dbeaver.model.virtual.DBVEntityConstraint)2 InvocationTargetException (java.lang.reflect.InvocationTargetException)1 java.util (java.util)1 IStatus (org.eclipse.core.runtime.IStatus)1 Color (org.eclipse.swt.graphics.Color)1 ColorDialog (org.eclipse.swt.widgets.ColorDialog)1 Shell (org.eclipse.swt.widgets.Shell)1 NotNull (org.jkiss.code.NotNull)1