提交 d0f88bca 编写于 作者: S Serge Rider

#10 Data editors plugin extraction


Former-commit-id: 9aebc488
上级 a7181e30
......@@ -122,6 +122,7 @@ Require-Bundle: org.eclipse.core.runtime,
org.jkiss.dbeaver.model;visibility:=reexport,
org.jkiss.dbeaver.ui;visibility:=reexport,
org.jkiss.dbeaver.ui.editors.base;visibility:=reexport,
org.jkiss.dbeaver.ui.editors.data;visibility:=reexport,
org.jkiss.utils;visibility:=reexport,
org.jkiss.dbeaver.data.transfer,
org.jkiss.bundle.bouncycastle;resolution:=optional
......
......@@ -1375,9 +1375,6 @@ public class CoreMessages extends NLS {
public static String toolbar_cmd_redo_name;
//toolbar editor menu item
public static String grid_tooltip_sort_by_column;
public static String grid_tooltip_filter_by_column;
public static String CreateLinkHandler_e_create_link_message;
public static String CreateLinkHandler_e_create_link_title;
public static String CreateLinkHandler_e_create_link_validation;
......
......@@ -1329,9 +1329,6 @@ toolbar_cmd_undo_name = Undo
toolbar_cmd_redo_name = Redo
##toolbar editor menu item##
grid_tooltip_sort_by_column = Sort by column
grid_tooltip_filter_by_column = Filter by column value
CreateLinkHandler_e_create_link_message=Unable to create link
CreateLinkHandler_e_create_link_title=Create link
CreateLinkHandler_e_create_link_validation=Unable to create link inside {0}
......
......@@ -1475,10 +1475,6 @@ editors_sql_status_statement_executed_no_rows_updated = Anweisung ausgef\u00FChr
editors_sql_staus_connected_to = Verbunden mit ''
grid_tooltip_filter_by_column = Filtern mit Spaltenwert
grid_tooltip_sort_by_column = Sortieren mit Spalte
model_html_read_database_meta_data = Datenbank Metadaten lesen
model_jdbc_bad_content_value_ = Schlechter Inhaltswert:
......
......@@ -1825,6 +1825,3 @@ pref_page_error_handle_recover_retry_count_tip = Nombre de tentatives de reconne
toolbar_cmd_undo_name = Annuler
toolbar_cmd_redo_name = Refaire
##toolbar editor menu item##
grid_tooltip_sort_by_column = Trier par colonne
grid_tooltip_filter_by_column = Filtrer par la valeur de colonne
......@@ -1478,10 +1478,6 @@ editors_sql_status_statement_executed_no_rows_updated = \u8BED\u53E5\u5DF2\u6267
editors_sql_staus_connected_to = \u8FDE\u63A5\u5230 ''
grid_tooltip_filter_by_column = \u6309\u5217\u503C\u8FC7\u6EE4
grid_tooltip_sort_by_column = \u6309\u5217\u8FC7\u6EE4
model_html_read_database_meta_data = \u8BFB\u53D6\u6570\u636E\u5E93\u5143\u6570\u636E
model_jdbc_bad_content_value_ = \u65E0\u6548\u5185\u5BB9:
......
......@@ -29,8 +29,6 @@ import org.jkiss.dbeaver.model.DBPEvaluationContext;
import org.jkiss.dbeaver.model.data.DBDAttributeBinding;
import org.jkiss.dbeaver.model.sql.SQLDialect;
import org.jkiss.dbeaver.model.sql.SQLUtils;
import org.jkiss.dbeaver.model.struct.DBSDataContainer;
import org.jkiss.dbeaver.model.struct.DBSObject;
import org.jkiss.dbeaver.runtime.ui.DBUserInterface;
import org.jkiss.dbeaver.ui.controls.lightgrid.LightGrid;
import org.jkiss.dbeaver.ui.controls.resultset.IResultSetDecorator;
......
......@@ -7,6 +7,7 @@ Bundle-Version: 1.0.0.qualifier
Bundle-Release-Date: 20181224
Bundle-RequiredExecutionEnvironment: JavaSE-1.8
Bundle-ActivationPolicy: lazy
Bundle-Activator: org.jkiss.dbeaver.ui.editors.data.internal.DataEditorsActivator
Require-Bundle: org.eclipse.core.runtime,
org.eclipse.core.resources,
org.eclipse.core.expressions,
......@@ -15,4 +16,6 @@ Require-Bundle: org.eclipse.core.runtime,
org.jkiss.dbeaver.ui,
org.jkiss.dbeaver.ui.editors.base
Bundle-ClassPath: .
Export-Package: org.jkiss.dbeaver.ui.editors.data
Export-Package: org.jkiss.dbeaver.ui.controls.lightgrid,
org.jkiss.dbeaver.ui.controls.resultset,
org.jkiss.dbeaver.ui.editors.data
/*
* DBeaver - Universal Database Manager
* Copyright (C) 2010-2017 Serge Rider (serge@jkiss.org)
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.jkiss.dbeaver.ui.controls.lightgrid;
import org.eclipse.swt.widgets.Display;
/**
* Abstract grid renderer
*/
abstract class AbstractRenderer
{
protected final LightGrid grid;
protected AbstractRenderer(LightGrid grid) {
this.grid = grid;
}
/**
* Sets the display for the renderer.
*
* @return Returns the display.
*/
public Display getDisplay()
{
return grid.getDisplay();
}
}
/*
* DBeaver - Universal Database Manager
* Copyright (C) 2010-2017 Serge Rider (serge@jkiss.org)
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.jkiss.dbeaver.ui.controls.lightgrid;
import org.eclipse.swt.widgets.Display;
/**
* Abstract grid renderer
*/
abstract class AbstractRenderer
{
protected final LightGrid grid;
protected AbstractRenderer(LightGrid grid) {
this.grid = grid;
}
/**
* Sets the display for the renderer.
*
* @return Returns the display.
*/
public Display getDisplay()
{
return grid.getDisplay();
}
}
/*
* DBeaver - Universal Database Manager
* Copyright (C) 2010-2017 Serge Rider (serge@jkiss.org)
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.jkiss.dbeaver.ui.controls.lightgrid;
import org.jkiss.utils.CommonUtils;
/**
* GridCell
*/
public class GridCell
{
public Object col;
public Object row;
public GridCell(Object col, Object row)
{
this.col = col;
this.row = row;
}
public GridCell(GridCell copy)
{
this.col = copy.col;
this.row = copy.row;
}
public boolean equals(Object object)
{
return object instanceof GridCell && equalsTo((GridCell) object);
}
public boolean equalsTo(GridCell pos)
{
return CommonUtils.equalObjects(this.col, pos.col) &&
CommonUtils.equalObjects(this.row, pos.row);
}
public String toString()
{
return col + ":" + row;
}
public int hashCode()
{
return col.hashCode() ^ row.hashCode();
}
}
/*
* DBeaver - Universal Database Manager
* Copyright (C) 2010-2017 Serge Rider (serge@jkiss.org)
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.jkiss.dbeaver.ui.controls.lightgrid;
import org.jkiss.utils.CommonUtils;
/**
* GridCell
*/
public class GridCell
{
public Object col;
public Object row;
public GridCell(Object col, Object row)
{
this.col = col;
this.row = row;
}
public GridCell(GridCell copy)
{
this.col = copy.col;
this.row = copy.row;
}
public boolean equals(Object object)
{
return object instanceof GridCell && equalsTo((GridCell) object);
}
public boolean equalsTo(GridCell pos)
{
return CommonUtils.equalObjects(this.col, pos.col) &&
CommonUtils.equalObjects(this.row, pos.row);
}
public String toString()
{
return col + ":" + row;
}
public int hashCode()
{
return col.hashCode() ^ row.hashCode();
}
}
/*
* DBeaver - Universal Database Manager
* Copyright (C) 2010-2017 Serge Rider (serge@jkiss.org)
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.jkiss.dbeaver.ui.controls.lightgrid;
import org.eclipse.swt.SWT;
import org.eclipse.swt.graphics.*;
import org.jkiss.dbeaver.core.DBeaverUI;
import org.jkiss.dbeaver.model.DBPImage;
import org.jkiss.dbeaver.ui.DBeaverIcons;
import org.jkiss.dbeaver.ui.TextUtils;
import org.jkiss.dbeaver.ui.UIIcon;
import org.jkiss.dbeaver.ui.UIUtils;
/**
* Grid cell renderer
*/
class GridCellRenderer extends AbstractRenderer
{
private static final int LEFT_MARGIN = 6;
private static final int RIGHT_MARGIN = 6;
private static final int TOP_MARGIN = 0;
private static final int TEXT_TOP_MARGIN = 1;
private static final int INSIDE_MARGIN = 3;
static final Image LINK_IMAGE = DBeaverIcons.getImage(UIIcon.LINK);
static final Image LINK2_IMAGE = DBeaverIcons.getImage(UIIcon.LINK2);
static final Rectangle LINK_IMAGE_BOUNDS = new Rectangle(0, 0, 13, 13);
protected Color colorLineFocused;
public GridCellRenderer(LightGrid grid)
{
super(grid);
colorLineFocused = grid.getDisplay().getSystemColor(SWT.COLOR_LIST_FOREGROUND);
}
public void paint(GC gc, Rectangle bounds, boolean selected, boolean focus, Object col, Object row)
{
boolean drawBackground = true;
//if (grid.isEnabled()) {
Color back = grid.getCellBackground(col, row, selected);
if (back != null) {
gc.setBackground(back);
} else {
drawBackground = false;
}
/*} else {
grid.setDefaultBackground(gc);
}*/
gc.setForeground(grid.getCellForeground(col, row, selected));
if (drawBackground) {
gc.fillRectangle(bounds.x, bounds.y, bounds.width, bounds.height);
}
String text = grid.getCellText(col, row);
final int state = grid.getContentProvider().getCellState(col, row, text);
int x = LEFT_MARGIN;
Image image;
Rectangle imageBounds = null;
if (isLinkState(state)) {
image = ((state & IGridContentProvider.STATE_LINK) != 0) ? LINK_IMAGE : LINK2_IMAGE;
imageBounds = LINK_IMAGE_BOUNDS;
} else {
DBPImage cellImage = grid.getCellImage(col, row);
if (cellImage != null) {
image = DBeaverIcons.getImage(cellImage);
imageBounds = image.getBounds();
} else {
image = null;
}
}
int columnAlign = grid.getContentProvider().getColumnAlign(col);
if (image != null && columnAlign != IGridContentProvider.ALIGN_RIGHT) {
int y = bounds.y + (bounds.height - imageBounds.height) / 2;
gc.drawImage(image, bounds.x + x, y);
x += imageBounds.width + INSIDE_MARGIN;
}
int width = bounds.width - x - RIGHT_MARGIN;
// Get cell text
if (text != null && !text.isEmpty()) {
// Get shortern version of string
text = TextUtils.getShortString(grid.fontMetrics, text, width);
// Replace linefeeds with space
text = TextUtils.getSingleLineString(text);
gc.setFont(grid.normalFont);
switch (columnAlign) {
// Center
case IGridContentProvider.ALIGN_CENTER:
break;
case IGridContentProvider.ALIGN_RIGHT:
// Right (numbers, datetimes)
int imageMargin = 0;
if (image != null) {
// Reduce bounds by link image size
imageMargin = imageBounds.width + INSIDE_MARGIN;
gc.setClipping(bounds.x, bounds.y, bounds.width - imageMargin, bounds.height);
} else {
gc.setClipping(bounds);
}
Point textSize = gc.textExtent(text);
gc.drawString(
text,
bounds.x + bounds.width - (textSize.x + RIGHT_MARGIN + imageMargin),
bounds.y + TEXT_TOP_MARGIN + TOP_MARGIN,
true);
gc.setClipping((Rectangle) null);
break;
default:
gc.drawString(
text,
bounds.x + x,
bounds.y + TEXT_TOP_MARGIN + TOP_MARGIN,
true);
break;
}
}
if (image != null && columnAlign == IGridContentProvider.ALIGN_RIGHT) {
int y = bounds.y + (bounds.height - imageBounds.height) / 2;
gc.drawImage(image, bounds.x + bounds.width - imageBounds.width - RIGHT_MARGIN, y);
}
if (grid.isLinesVisible()) {
if (selected) {
gc.setForeground(grid.getLineSelectedColor());
} else {
gc.setForeground(grid.getLineColor());
}
gc.drawLine(
bounds.x,
bounds.y + bounds.height,
bounds.x + bounds.width,
bounds.y + bounds.height);
gc.drawLine(
bounds.x + bounds.width - 1,
bounds.y,
bounds.x + bounds.width - 1,
bounds.y + bounds.height);
}
if (focus) {
gc.setForeground(colorLineFocused);
gc.drawRectangle(bounds.x, bounds.y, bounds.width - 1, bounds.height);
if (grid.isFocusControl()) {
gc.drawRectangle(bounds.x + 1, bounds.y + 1, bounds.width - 3, bounds.height - 2);
}
}
}
public boolean isOverLink(GridColumn column, int row, int x, int y) {
int state = grid.getContentProvider().getCellState(column.getElement(), grid.getRowElement(row), null);
if (isLinkState(state)) {
Point origin = grid.getOrigin(column, row);
int verMargin = (grid.getItemHeight() - LINK_IMAGE_BOUNDS.height) / 2;
int columnAlign = grid.getContentProvider().getColumnAlign(column.getElement());
if (columnAlign != IGridContentProvider.ALIGN_RIGHT) {
if (x >= origin.x + LEFT_MARGIN && x <= origin.x + LEFT_MARGIN + LINK_IMAGE_BOUNDS.width &&
y >= origin.y + verMargin && y <= origin.y + verMargin + LINK_IMAGE_BOUNDS.height) {
return true;
}
} else {
int width = column.getWidth();
if (x >= origin.x + width - (LEFT_MARGIN + LINK_IMAGE_BOUNDS.width) && x <= origin.x + width - RIGHT_MARGIN &&
y >= origin.y + verMargin && y <= origin.y + verMargin + LINK_IMAGE_BOUNDS.height) {
return true;
}
}
}
return false;
}
public static boolean isLinkState(int state) {
return
(state & IGridContentProvider.STATE_LINK) != 0 ||
(state & IGridContentProvider.STATE_HYPER_LINK) != 0;
}
}
/*
* DBeaver - Universal Database Manager
* Copyright (C) 2010-2017 Serge Rider (serge@jkiss.org)
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.jkiss.dbeaver.ui.controls.lightgrid;
import org.eclipse.swt.SWT;
import org.eclipse.swt.graphics.*;
import org.jkiss.dbeaver.model.DBPImage;
import org.jkiss.dbeaver.ui.DBeaverIcons;
import org.jkiss.dbeaver.ui.TextUtils;
import org.jkiss.dbeaver.ui.UIIcon;
/**
* Grid cell renderer
*/
class GridCellRenderer extends AbstractRenderer
{
private static final int LEFT_MARGIN = 6;
private static final int RIGHT_MARGIN = 6;
private static final int TOP_MARGIN = 0;
private static final int TEXT_TOP_MARGIN = 1;
private static final int INSIDE_MARGIN = 3;
static final Image LINK_IMAGE = DBeaverIcons.getImage(UIIcon.LINK);
static final Image LINK2_IMAGE = DBeaverIcons.getImage(UIIcon.LINK2);
static final Rectangle LINK_IMAGE_BOUNDS = new Rectangle(0, 0, 13, 13);
protected Color colorLineFocused;
public GridCellRenderer(LightGrid grid)
{
super(grid);
colorLineFocused = grid.getDisplay().getSystemColor(SWT.COLOR_LIST_FOREGROUND);
}
public void paint(GC gc, Rectangle bounds, boolean selected, boolean focus, Object col, Object row)
{
boolean drawBackground = true;
//if (grid.isEnabled()) {
Color back = grid.getCellBackground(col, row, selected);
if (back != null) {
gc.setBackground(back);
} else {
drawBackground = false;
}
/*} else {
grid.setDefaultBackground(gc);
}*/
gc.setForeground(grid.getCellForeground(col, row, selected));
if (drawBackground) {
gc.fillRectangle(bounds.x, bounds.y, bounds.width, bounds.height);
}
String text = grid.getCellText(col, row);
final int state = grid.getContentProvider().getCellState(col, row, text);
int x = LEFT_MARGIN;
Image image;
Rectangle imageBounds = null;
if (isLinkState(state)) {
image = ((state & IGridContentProvider.STATE_LINK) != 0) ? LINK_IMAGE : LINK2_IMAGE;
imageBounds = LINK_IMAGE_BOUNDS;
} else {
DBPImage cellImage = grid.getCellImage(col, row);
if (cellImage != null) {
image = DBeaverIcons.getImage(cellImage);
imageBounds = image.getBounds();
} else {
image = null;
}
}
int columnAlign = grid.getContentProvider().getColumnAlign(col);
if (image != null && columnAlign != IGridContentProvider.ALIGN_RIGHT) {
int y = bounds.y + (bounds.height - imageBounds.height) / 2;
gc.drawImage(image, bounds.x + x, y);
x += imageBounds.width + INSIDE_MARGIN;
}
int width = bounds.width - x - RIGHT_MARGIN;
// Get cell text
if (text != null && !text.isEmpty()) {
// Get shortern version of string
text = TextUtils.getShortString(grid.fontMetrics, text, width);
// Replace linefeeds with space
text = TextUtils.getSingleLineString(text);
gc.setFont(grid.normalFont);
switch (columnAlign) {
// Center
case IGridContentProvider.ALIGN_CENTER:
break;
case IGridContentProvider.ALIGN_RIGHT:
// Right (numbers, datetimes)
int imageMargin = 0;
if (image != null) {
// Reduce bounds by link image size
imageMargin = imageBounds.width + INSIDE_MARGIN;
gc.setClipping(bounds.x, bounds.y, bounds.width - imageMargin, bounds.height);
} else {
gc.setClipping(bounds);
}
Point textSize = gc.textExtent(text);
gc.drawString(
text,
bounds.x + bounds.width - (textSize.x + RIGHT_MARGIN + imageMargin),
bounds.y + TEXT_TOP_MARGIN + TOP_MARGIN,
true);
gc.setClipping((Rectangle) null);
break;
default:
gc.drawString(
text,
bounds.x + x,
bounds.y + TEXT_TOP_MARGIN + TOP_MARGIN,
true);
break;
}
}
if (image != null && columnAlign == IGridContentProvider.ALIGN_RIGHT) {
int y = bounds.y + (bounds.height - imageBounds.height) / 2;
gc.drawImage(image, bounds.x + bounds.width - imageBounds.width - RIGHT_MARGIN, y);
}
if (grid.isLinesVisible()) {
if (selected) {
gc.setForeground(grid.getLineSelectedColor());
} else {
gc.setForeground(grid.getLineColor());
}
gc.drawLine(
bounds.x,
bounds.y + bounds.height,
bounds.x + bounds.width,
bounds.y + bounds.height);
gc.drawLine(
bounds.x + bounds.width - 1,
bounds.y,
bounds.x + bounds.width - 1,
bounds.y + bounds.height);
}
if (focus) {
gc.setForeground(colorLineFocused);
gc.drawRectangle(bounds.x, bounds.y, bounds.width - 1, bounds.height);
if (grid.isFocusControl()) {
gc.drawRectangle(bounds.x + 1, bounds.y + 1, bounds.width - 3, bounds.height - 2);
}
}
}
public boolean isOverLink(GridColumn column, int row, int x, int y) {
int state = grid.getContentProvider().getCellState(column.getElement(), grid.getRowElement(row), null);
if (isLinkState(state)) {
Point origin = grid.getOrigin(column, row);
int verMargin = (grid.getItemHeight() - LINK_IMAGE_BOUNDS.height) / 2;
int columnAlign = grid.getContentProvider().getColumnAlign(column.getElement());
if (columnAlign != IGridContentProvider.ALIGN_RIGHT) {
if (x >= origin.x + LEFT_MARGIN && x <= origin.x + LEFT_MARGIN + LINK_IMAGE_BOUNDS.width &&
y >= origin.y + verMargin && y <= origin.y + verMargin + LINK_IMAGE_BOUNDS.height) {
return true;
}
} else {
int width = column.getWidth();
if (x >= origin.x + width - (LEFT_MARGIN + LINK_IMAGE_BOUNDS.width) && x <= origin.x + width - RIGHT_MARGIN &&
y >= origin.y + verMargin && y <= origin.y + verMargin + LINK_IMAGE_BOUNDS.height) {
return true;
}
}
}
return false;
}
public static boolean isLinkState(int state) {
return
(state & IGridContentProvider.STATE_LINK) != 0 ||
(state & IGridContentProvider.STATE_HYPER_LINK) != 0;
}
}
/*
* DBeaver - Universal Database Manager
* Copyright (C) 2010-2017 Serge Rider (serge@jkiss.org)
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.jkiss.dbeaver.ui.controls.lightgrid;
import org.eclipse.swt.SWT;
import org.eclipse.swt.graphics.Font;
import org.eclipse.swt.graphics.GC;
import org.eclipse.swt.graphics.Image;
import org.eclipse.swt.graphics.Rectangle;
import org.jkiss.code.Nullable;
import org.jkiss.dbeaver.ui.DBeaverIcons;
import org.jkiss.dbeaver.ui.TextUtils;
import org.jkiss.dbeaver.ui.UIIcon;
import org.jkiss.utils.CommonUtils;
/**
* Grid column renderer
*/
class GridColumnRenderer extends AbstractRenderer
{
public static final int LEFT_MARGIN = 6;
public static final int RIGHT_MARGIN = 6;
public static final int BOTTOM_MARGIN = 6;
public static final int TOP_MARGIN = 6;
public static final int ARROW_MARGIN = 6;
public static final int IMAGE_SPACING = 3;
public static final Image IMAGE_ASTERISK = DBeaverIcons.getImage(UIIcon.SORT_UNKNOWN);
public static final Image IMAGE_DESC = DBeaverIcons.getImage(UIIcon.SORT_DECREASE);
public static final Image IMAGE_ASC = DBeaverIcons.getImage(UIIcon.SORT_INCREASE);
public static final Image IMAGE_FILTER = DBeaverIcons.getImage(UIIcon.FILTER_SMALL);
public static final int SORT_WIDTH = IMAGE_DESC.getBounds().width;
public static final int FILTER_WIDTH = IMAGE_FILTER.getBounds().width;
public GridColumnRenderer(LightGrid grid) {
super(grid);
}
public static Rectangle getSortControlBounds() {
return IMAGE_DESC.getBounds();
}
public static Rectangle getFilterControlBounds() {
return IMAGE_FILTER.getBounds();
}
@Nullable
protected Image getColumnImage(Object element) {
return grid.getLabelProvider().getImage(element);
}
protected String getColumnText(Object element)
{
return grid.getLabelProvider().getText(element);
}
protected String getColumnDescription(Object element)
{
return grid.getLabelProvider().getDescription(element);
}
protected Font getColumnFont(Object element) {
Font font = grid.getLabelProvider().getFont(element);
return font != null ? font : grid.normalFont;
}
public void paint(GC gc, Rectangle bounds, boolean selected, boolean hovering, Object element) {
boolean hasFilters = grid.getContentProvider().isElementSupportsFilter(element);
//GridColumn col = grid.getColumnByElement(cell.col);
//AbstractRenderer arrowRenderer = col.getSortRenderer();
int sortOrder = grid.getContentProvider().getSortOrder(element);
final Rectangle sortBounds = getSortControlBounds();
final Rectangle filterBounds = getFilterControlBounds();
// set the font to be used to display the text.
gc.setFont(getColumnFont(element));
boolean flat = true;
boolean drawSelected = false;
if (flat && (selected || hovering)) {
gc.setBackground(grid.getContentProvider().getCellHeaderSelectionBackground(element));
} else {
gc.setBackground(grid.getContentProvider().getCellHeaderBackground(element));
}
gc.setForeground(grid.getContentProvider().getCellHeaderForeground(element));
gc.fillRectangle(bounds.x, bounds.y, bounds.width, bounds.height);
int pushedDrawingOffset = 0;
if (drawSelected) {
pushedDrawingOffset = 1;
}
int x = LEFT_MARGIN;
Image columnImage = getColumnImage(element);
if (columnImage != null) {
int y = bounds.y + pushedDrawingOffset + TOP_MARGIN;
gc.drawImage(columnImage, bounds.x + x + pushedDrawingOffset, y);
x += columnImage.getBounds().width + IMAGE_SPACING;
}
int width = bounds.width - x;
if (sortOrder == SWT.NONE) {
width -= RIGHT_MARGIN;
} else {
width -= ARROW_MARGIN + sortBounds.width;
}
if (hasFilters) {
width -= filterBounds.width;
}
//gc.setForeground(getDisplay().getSystemColor(SWT.COLOR_WIDGET_FOREGROUND));
int y = bounds.y + TOP_MARGIN;
{
// Column name
String text = getColumnText(element);
text = TextUtils.getShortString(grid.fontMetrics, text, width);
gc.setFont(grid.normalFont);
gc.drawString(text, bounds.x + x + pushedDrawingOffset, y + pushedDrawingOffset, true);
}
if (sortOrder != SWT.NONE) {
if (drawSelected) {
sortBounds.x = bounds.x + bounds.width - ARROW_MARGIN - sortBounds.width + 1;
sortBounds.y = y;
} else {
sortBounds.x = bounds.x + bounds.width - ARROW_MARGIN - sortBounds.width;
sortBounds.y = y;
}
sortBounds.x += IMAGE_SPACING;
paintSort(gc, sortBounds, sortOrder);
}
if (hasFilters) {
gc.drawImage(IMAGE_FILTER,
bounds.x + bounds.width - filterBounds.width -
(sortOrder != SWT.NONE ? IMAGE_SPACING + sortBounds.width + 1 : ARROW_MARGIN),
y);
}
{
// Draw column description
String text = getColumnDescription(element);
if (!CommonUtils.isEmpty(text)) {
y += TOP_MARGIN + grid.fontMetrics.getHeight();
text = TextUtils.getShortString(grid.fontMetrics, text, width);
gc.setFont(grid.normalFont);
gc.drawString(text, bounds.x + x + pushedDrawingOffset, y + pushedDrawingOffset, true);
}
}
// Draw border
if (!flat) {
if (drawSelected) {
gc.setForeground(getDisplay().getSystemColor(SWT.COLOR_WIDGET_NORMAL_SHADOW));
} else {
gc.setForeground(getDisplay().getSystemColor(SWT.COLOR_WIDGET_HIGHLIGHT_SHADOW));
}
gc.drawLine(bounds.x, bounds.y, bounds.x + bounds.width - 1,
bounds.y);
gc.drawLine(bounds.x, bounds.y, bounds.x, bounds.y + bounds.height
- 1);
if (!drawSelected) {
gc.setForeground(getDisplay().getSystemColor(SWT.COLOR_WIDGET_LIGHT_SHADOW));
gc.drawLine(bounds.x + 1, bounds.y + 1,
bounds.x + bounds.width - 2, bounds.y + 1);
gc.drawLine(bounds.x + 1, bounds.y + 1, bounds.x + 1,
bounds.y + bounds.height - 2);
}
if (drawSelected) {
gc.setForeground(getDisplay().getSystemColor(SWT.COLOR_WIDGET_NORMAL_SHADOW));
} else {
gc.setForeground(getDisplay().getSystemColor(SWT.COLOR_WIDGET_DARK_SHADOW));
}
gc.drawLine(bounds.x + bounds.width - 1, bounds.y, bounds.x
+ bounds.width - 1,
bounds.y + bounds.height - 1);
gc.drawLine(bounds.x, bounds.y + bounds.height - 1, bounds.x
+ bounds.width - 1,
bounds.y + bounds.height - 1);
if (!drawSelected) {
gc.setForeground(getDisplay().getSystemColor(SWT.COLOR_WIDGET_NORMAL_SHADOW));
gc.drawLine(bounds.x + bounds.width - 2, bounds.y + 1,
bounds.x + bounds.width - 2, bounds.y + bounds.height
- 2);
gc.drawLine(bounds.x + 1, bounds.y + bounds.height - 2,
bounds.x + bounds.width - 2, bounds.y + bounds.height
- 2);
}
} else {
gc.setForeground(getDisplay().getSystemColor(SWT.COLOR_WIDGET_DARK_SHADOW));
gc.drawLine(bounds.x + bounds.width - 1, bounds.y, bounds.x
+ bounds.width - 1,
bounds.y + bounds.height - 1);
gc.drawLine(bounds.x, bounds.y + bounds.height - 1, bounds.x
+ bounds.width - 1,
bounds.y + bounds.height - 1);
}
gc.setFont(grid.normalFont);
}
public static void paintSort(GC gc, Rectangle bounds, int sort)
{
switch (sort) {
case SWT.DEFAULT:
gc.drawImage(IMAGE_ASTERISK, bounds.x, bounds.y);
break;
case SWT.UP:
gc.drawImage(IMAGE_ASC, bounds.x, bounds.y);
break;
case SWT.DOWN:
gc.drawImage(IMAGE_DESC, bounds.x, bounds.y);
break;
}
/*
if (isSelected()) {
gc.drawLine(bounds.x, bounds.y, bounds.x + 6, bounds.y);
gc.drawLine(bounds.x + 1, bounds.y + 1, bounds.x + 5, bounds.y + 1);
gc.drawLine(bounds.x + 2, bounds.y + 2, bounds.x + 4, bounds.y + 2);
gc.drawPoint(bounds.x + 3, bounds.y + 3);
} else {
gc.drawPoint(bounds.x + 3, bounds.y);
gc.drawLine(bounds.x + 2, bounds.y + 1, bounds.x + 4, bounds.y + 1);
gc.drawLine(bounds.x + 1, bounds.y + 2, bounds.x + 5, bounds.y + 2);
gc.drawLine(bounds.x, bounds.y + 3, bounds.x + 6, bounds.y + 3);
}
*/
}
}
/*
* DBeaver - Universal Database Manager
* Copyright (C) 2010-2017 Serge Rider (serge@jkiss.org)
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.jkiss.dbeaver.ui.controls.lightgrid;
import org.eclipse.swt.SWT;
import org.eclipse.swt.graphics.Font;
import org.eclipse.swt.graphics.GC;
import org.eclipse.swt.graphics.Image;
import org.eclipse.swt.graphics.Rectangle;
import org.jkiss.code.Nullable;
import org.jkiss.dbeaver.ui.DBeaverIcons;
import org.jkiss.dbeaver.ui.TextUtils;
import org.jkiss.dbeaver.ui.UIIcon;
import org.jkiss.utils.CommonUtils;
/**
* Grid column renderer
*/
class GridColumnRenderer extends AbstractRenderer
{
public static final int LEFT_MARGIN = 6;
public static final int RIGHT_MARGIN = 6;
public static final int BOTTOM_MARGIN = 6;
public static final int TOP_MARGIN = 6;
public static final int ARROW_MARGIN = 6;
public static final int IMAGE_SPACING = 3;
public static final Image IMAGE_ASTERISK = DBeaverIcons.getImage(UIIcon.SORT_UNKNOWN);
public static final Image IMAGE_DESC = DBeaverIcons.getImage(UIIcon.SORT_DECREASE);
public static final Image IMAGE_ASC = DBeaverIcons.getImage(UIIcon.SORT_INCREASE);
public static final Image IMAGE_FILTER = DBeaverIcons.getImage(UIIcon.FILTER_SMALL);
public static final int SORT_WIDTH = IMAGE_DESC.getBounds().width;
public static final int FILTER_WIDTH = IMAGE_FILTER.getBounds().width;
public GridColumnRenderer(LightGrid grid) {
super(grid);
}
public static Rectangle getSortControlBounds() {
return IMAGE_DESC.getBounds();
}
public static Rectangle getFilterControlBounds() {
return IMAGE_FILTER.getBounds();
}
@Nullable
protected Image getColumnImage(Object element) {
return grid.getLabelProvider().getImage(element);
}
protected String getColumnText(Object element)
{
return grid.getLabelProvider().getText(element);
}
protected String getColumnDescription(Object element)
{
return grid.getLabelProvider().getDescription(element);
}
protected Font getColumnFont(Object element) {
Font font = grid.getLabelProvider().getFont(element);
return font != null ? font : grid.normalFont;
}
public void paint(GC gc, Rectangle bounds, boolean selected, boolean hovering, Object element) {
boolean hasFilters = grid.getContentProvider().isElementSupportsFilter(element);
//GridColumn col = grid.getColumnByElement(cell.col);
//AbstractRenderer arrowRenderer = col.getSortRenderer();
int sortOrder = grid.getContentProvider().getSortOrder(element);
final Rectangle sortBounds = getSortControlBounds();
final Rectangle filterBounds = getFilterControlBounds();
// set the font to be used to display the text.
gc.setFont(getColumnFont(element));
boolean flat = true;
boolean drawSelected = false;
if (flat && (selected || hovering)) {
gc.setBackground(grid.getContentProvider().getCellHeaderSelectionBackground(element));
} else {
gc.setBackground(grid.getContentProvider().getCellHeaderBackground(element));
}
gc.setForeground(grid.getContentProvider().getCellHeaderForeground(element));
gc.fillRectangle(bounds.x, bounds.y, bounds.width, bounds.height);
int pushedDrawingOffset = 0;
if (drawSelected) {
pushedDrawingOffset = 1;
}
int x = LEFT_MARGIN;
Image columnImage = getColumnImage(element);
if (columnImage != null) {
int y = bounds.y + pushedDrawingOffset + TOP_MARGIN;
gc.drawImage(columnImage, bounds.x + x + pushedDrawingOffset, y);
x += columnImage.getBounds().width + IMAGE_SPACING;
}
int width = bounds.width - x;
if (sortOrder == SWT.NONE) {
width -= RIGHT_MARGIN;
} else {
width -= ARROW_MARGIN + sortBounds.width;
}
if (hasFilters) {
width -= filterBounds.width;
}
//gc.setForeground(getDisplay().getSystemColor(SWT.COLOR_WIDGET_FOREGROUND));
int y = bounds.y + TOP_MARGIN;
{
// Column name
String text = getColumnText(element);
text = TextUtils.getShortString(grid.fontMetrics, text, width);
gc.setFont(grid.normalFont);
gc.drawString(text, bounds.x + x + pushedDrawingOffset, y + pushedDrawingOffset, true);
}
if (sortOrder != SWT.NONE) {
if (drawSelected) {
sortBounds.x = bounds.x + bounds.width - ARROW_MARGIN - sortBounds.width + 1;
sortBounds.y = y;
} else {
sortBounds.x = bounds.x + bounds.width - ARROW_MARGIN - sortBounds.width;
sortBounds.y = y;
}
sortBounds.x += IMAGE_SPACING;
paintSort(gc, sortBounds, sortOrder);
}
if (hasFilters) {
gc.drawImage(IMAGE_FILTER,
bounds.x + bounds.width - filterBounds.width -
(sortOrder != SWT.NONE ? IMAGE_SPACING + sortBounds.width + 1 : ARROW_MARGIN),
y);
}
{
// Draw column description
String text = getColumnDescription(element);
if (!CommonUtils.isEmpty(text)) {
y += TOP_MARGIN + grid.fontMetrics.getHeight();
text = TextUtils.getShortString(grid.fontMetrics, text, width);
gc.setFont(grid.normalFont);
gc.drawString(text, bounds.x + x + pushedDrawingOffset, y + pushedDrawingOffset, true);
}
}
// Draw border
if (!flat) {
if (drawSelected) {
gc.setForeground(getDisplay().getSystemColor(SWT.COLOR_WIDGET_NORMAL_SHADOW));
} else {
gc.setForeground(getDisplay().getSystemColor(SWT.COLOR_WIDGET_HIGHLIGHT_SHADOW));
}
gc.drawLine(bounds.x, bounds.y, bounds.x + bounds.width - 1,
bounds.y);
gc.drawLine(bounds.x, bounds.y, bounds.x, bounds.y + bounds.height
- 1);
if (!drawSelected) {
gc.setForeground(getDisplay().getSystemColor(SWT.COLOR_WIDGET_LIGHT_SHADOW));
gc.drawLine(bounds.x + 1, bounds.y + 1,
bounds.x + bounds.width - 2, bounds.y + 1);
gc.drawLine(bounds.x + 1, bounds.y + 1, bounds.x + 1,
bounds.y + bounds.height - 2);
}
if (drawSelected) {
gc.setForeground(getDisplay().getSystemColor(SWT.COLOR_WIDGET_NORMAL_SHADOW));
} else {
gc.setForeground(getDisplay().getSystemColor(SWT.COLOR_WIDGET_DARK_SHADOW));
}
gc.drawLine(bounds.x + bounds.width - 1, bounds.y, bounds.x
+ bounds.width - 1,
bounds.y + bounds.height - 1);
gc.drawLine(bounds.x, bounds.y + bounds.height - 1, bounds.x
+ bounds.width - 1,
bounds.y + bounds.height - 1);
if (!drawSelected) {
gc.setForeground(getDisplay().getSystemColor(SWT.COLOR_WIDGET_NORMAL_SHADOW));
gc.drawLine(bounds.x + bounds.width - 2, bounds.y + 1,
bounds.x + bounds.width - 2, bounds.y + bounds.height
- 2);
gc.drawLine(bounds.x + 1, bounds.y + bounds.height - 2,
bounds.x + bounds.width - 2, bounds.y + bounds.height
- 2);
}
} else {
gc.setForeground(getDisplay().getSystemColor(SWT.COLOR_WIDGET_DARK_SHADOW));
gc.drawLine(bounds.x + bounds.width - 1, bounds.y, bounds.x
+ bounds.width - 1,
bounds.y + bounds.height - 1);
gc.drawLine(bounds.x, bounds.y + bounds.height - 1, bounds.x
+ bounds.width - 1,
bounds.y + bounds.height - 1);
}
gc.setFont(grid.normalFont);
}
public static void paintSort(GC gc, Rectangle bounds, int sort)
{
switch (sort) {
case SWT.DEFAULT:
gc.drawImage(IMAGE_ASTERISK, bounds.x, bounds.y);
break;
case SWT.UP:
gc.drawImage(IMAGE_ASC, bounds.x, bounds.y);
break;
case SWT.DOWN:
gc.drawImage(IMAGE_DESC, bounds.x, bounds.y);
break;
}
/*
if (isSelected()) {
gc.drawLine(bounds.x, bounds.y, bounds.x + 6, bounds.y);
gc.drawLine(bounds.x + 1, bounds.y + 1, bounds.x + 5, bounds.y + 1);
gc.drawLine(bounds.x + 2, bounds.y + 2, bounds.x + 4, bounds.y + 2);
gc.drawPoint(bounds.x + 3, bounds.y + 3);
} else {
gc.drawPoint(bounds.x + 3, bounds.y);
gc.drawLine(bounds.x + 2, bounds.y + 1, bounds.x + 4, bounds.y + 1);
gc.drawLine(bounds.x + 1, bounds.y + 2, bounds.x + 5, bounds.y + 2);
gc.drawLine(bounds.x, bounds.y + 3, bounds.x + 6, bounds.y + 3);
}
*/
}
}
/*
* DBeaver - Universal Database Manager
* Copyright (C) 2010-2017 Serge Rider (serge@jkiss.org)
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.jkiss.dbeaver.ui.controls.lightgrid;
import org.jkiss.dbeaver.model.data.DBDCellValue;
import java.util.Comparator;
/**
* Grid position. Tuple of x/y coordinates.
* Pos comparator orders positions in tree in natural order (first ordered by rows then by columns).
*/
public class GridPos implements DBDCellValue
{
public int col;
public int row;
public GridPos(int col, int row)
{
this.col = col;
this.row = row;
}
public GridPos(GridPos copy)
{
this.col = copy.col;
this.row = copy.row;
}
public boolean isValid()
{
return col >= 0 && row >= 0;
}
public boolean equals(Object object)
{
return object instanceof GridPos && equalsTo((GridPos) object);
}
public boolean equals(int col, int row)
{
return this.col == col && this.row == row;
}
public boolean equalsTo(GridPos pos)
{
return this.col == pos.col && this.row == pos.row;
}
public String toString()
{
return col + ":" + row;
}
public int hashCode()
{
return col ^ row;
}
public static class PosComparator implements Comparator<GridPos> {
@Override
public int compare(GridPos pos1, GridPos pos2)
{
int res = pos1.row - pos2.row;
return res != 0 ? res : pos1.col - pos2.col;
}
}
}
/*
* DBeaver - Universal Database Manager
* Copyright (C) 2010-2017 Serge Rider (serge@jkiss.org)
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.jkiss.dbeaver.ui.controls.lightgrid;
import org.jkiss.dbeaver.model.data.DBDCellValue;
import java.util.Comparator;
/**
* Grid position. Tuple of x/y coordinates.
* Pos comparator orders positions in tree in natural order (first ordered by rows then by columns).
*/
public class GridPos implements DBDCellValue
{
public int col;
public int row;
public GridPos(int col, int row)
{
this.col = col;
this.row = row;
}
public GridPos(GridPos copy)
{
this.col = copy.col;
this.row = copy.row;
}
public boolean isValid()
{
return col >= 0 && row >= 0;
}
public boolean equals(Object object)
{
return object instanceof GridPos && equalsTo((GridPos) object);
}
public boolean equals(int col, int row)
{
return this.col == col && this.row == row;
}
public boolean equalsTo(GridPos pos)
{
return this.col == pos.col && this.row == pos.row;
}
public String toString()
{
return col + ":" + row;
}
public int hashCode()
{
return col ^ row;
}
public static class PosComparator implements Comparator<GridPos> {
@Override
public int compare(GridPos pos1, GridPos pos2)
{
int res = pos1.row - pos2.row;
return res != 0 ? res : pos1.col - pos2.col;
}
}
}
/*
* DBeaver - Universal Database Manager
* Copyright (C) 2010-2017 Serge Rider (serge@jkiss.org)
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.jkiss.dbeaver.ui.controls.lightgrid;
import org.eclipse.swt.SWT;
import org.eclipse.swt.graphics.*;
import org.jkiss.dbeaver.ui.DBeaverIcons;
import org.jkiss.dbeaver.ui.TextUtils;
import org.jkiss.dbeaver.ui.UIIcon;
/**
* Grid row header renderer.
*/
class GridRowRenderer extends AbstractRenderer {
static final Image IMG_EXPAND = DBeaverIcons.getImage(UIIcon.TREE_EXPAND);
static final Image IMG_COLLAPSE = DBeaverIcons.getImage(UIIcon.TREE_COLLAPSE);
static final Rectangle EXPANDED_BOUNDS = IMG_EXPAND.getBounds();
public static final int LEFT_MARGIN = 4;
public static final int RIGHT_MARGIN = 4;
public static final int IMAGE_SPACING = 5;
public static final int EXPANDER_SPACING = 2;
public static final int LEVEL_SPACING = EXPANDED_BOUNDS.width;
final Color DEFAULT_BACKGROUND;
final Color DEFAULT_FOREGROUND;
final Color DEFAULT_FOREGROUND_TEXT;
public GridRowRenderer(LightGrid grid) {
super(grid);
DEFAULT_BACKGROUND = getDisplay().getSystemColor(SWT.COLOR_WIDGET_BACKGROUND);
DEFAULT_FOREGROUND = getDisplay().getSystemColor(SWT.COLOR_WIDGET_NORMAL_SHADOW);
DEFAULT_FOREGROUND_TEXT = getDisplay().getSystemColor(SWT.COLOR_WIDGET_FOREGROUND);
}
public void paint(GC gc, Rectangle bounds, boolean selected, int level, IGridContentProvider.ElementState state, Object element) {
String text = grid.getLabelProvider().getText(element);
gc.setFont(getDisplay().getSystemFont());
Color background = selected ? grid.getContentProvider().getCellHeaderSelectionBackground(element) : grid.getContentProvider().getCellHeaderBackground(element);
if (background == null) {
background = DEFAULT_BACKGROUND;
}
gc.setBackground(background);
gc.fillRectangle(bounds.x, bounds.y, bounds.width, bounds.height + 1);
{
gc.setForeground(grid.getContentProvider().getCellHeaderForeground(element));
gc.drawLine(
bounds.x + bounds.width - 1,
bounds.y,
bounds.x + bounds.width - 1,
bounds.y + bounds.height - 1);
gc.drawLine(
bounds.x,
bounds.y + bounds.height - 1,
bounds.x + bounds.width - 1,
bounds.y + bounds.height - 1);
}
int x = LEFT_MARGIN;
if (level > 0) {
x += level * LEVEL_SPACING;
}
if (state != IGridContentProvider.ElementState.NONE) {
Image expandImage = state == IGridContentProvider.ElementState.EXPANDED ? IMG_COLLAPSE : IMG_EXPAND;
gc.drawImage(expandImage, x, bounds.y + (bounds.height - EXPANDED_BOUNDS.height) / 2);
x += EXPANDED_BOUNDS.width + EXPANDER_SPACING;
} else if (grid.hasNodes()) {
x += EXPANDED_BOUNDS.width + EXPANDER_SPACING;
}
Image image = grid.getLabelProvider().getImage(element);
if (image != null) {
gc.drawImage(image, x, bounds.y + (bounds.height - image.getBounds().height) / 2);
x += image.getBounds().width + IMAGE_SPACING;
}
int width = bounds.width - x;
width -= RIGHT_MARGIN;
Color foreground = grid.getContentProvider().getCellHeaderForeground(element);
if (foreground == null) {
foreground = grid.getLabelProvider().getForeground(element);
}
gc.setForeground(foreground);
int y = bounds.y;
int selectionOffset = 0;
y += (bounds.height - gc.stringExtent(text).y) / 2;
gc.drawString(TextUtils.getShortString(grid.fontMetrics, text, width), bounds.x + x + selectionOffset, y + selectionOffset, true);
}
public int computeHeaderWidth(Object element, int level) {
int width = GridRowRenderer.LEFT_MARGIN + GridRowRenderer.RIGHT_MARGIN;
if (grid.hasNodes()) {
width += GridRowRenderer.EXPANDED_BOUNDS.width + EXPANDER_SPACING;
}
Image rowImage = grid.getLabelProvider().getImage(element);
if (rowImage != null) {
width += rowImage.getBounds().width;
width += GridRowRenderer.IMAGE_SPACING;
}
String rowText = grid.getLabelProvider().getText(element);
Point ext = grid.sizingGC.stringExtent(rowText);
width += ext.x;
width += level * GridRowRenderer.LEVEL_SPACING;
return width;
}
public static boolean isOverExpander(int x, int level)
{
int expandBegin = LEFT_MARGIN + level * LEVEL_SPACING;
int expandEnd = expandBegin + EXPANDED_BOUNDS.width;
return x >= expandBegin && x <= expandEnd;
}
}
/*
* DBeaver - Universal Database Manager
* Copyright (C) 2010-2017 Serge Rider (serge@jkiss.org)
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.jkiss.dbeaver.ui.controls.lightgrid;
import org.eclipse.swt.SWT;
import org.eclipse.swt.graphics.*;
import org.jkiss.dbeaver.ui.DBeaverIcons;
import org.jkiss.dbeaver.ui.TextUtils;
import org.jkiss.dbeaver.ui.UIIcon;
/**
* Grid row header renderer.
*/
class GridRowRenderer extends AbstractRenderer {
static final Image IMG_EXPAND = DBeaverIcons.getImage(UIIcon.TREE_EXPAND);
static final Image IMG_COLLAPSE = DBeaverIcons.getImage(UIIcon.TREE_COLLAPSE);
static final Rectangle EXPANDED_BOUNDS = IMG_EXPAND.getBounds();
public static final int LEFT_MARGIN = 4;
public static final int RIGHT_MARGIN = 4;
public static final int IMAGE_SPACING = 5;
public static final int EXPANDER_SPACING = 2;
public static final int LEVEL_SPACING = EXPANDED_BOUNDS.width;
final Color DEFAULT_BACKGROUND;
final Color DEFAULT_FOREGROUND;
final Color DEFAULT_FOREGROUND_TEXT;
public GridRowRenderer(LightGrid grid) {
super(grid);
DEFAULT_BACKGROUND = getDisplay().getSystemColor(SWT.COLOR_WIDGET_BACKGROUND);
DEFAULT_FOREGROUND = getDisplay().getSystemColor(SWT.COLOR_WIDGET_NORMAL_SHADOW);
DEFAULT_FOREGROUND_TEXT = getDisplay().getSystemColor(SWT.COLOR_WIDGET_FOREGROUND);
}
public void paint(GC gc, Rectangle bounds, boolean selected, int level, IGridContentProvider.ElementState state, Object element) {
String text = grid.getLabelProvider().getText(element);
gc.setFont(getDisplay().getSystemFont());
Color background = selected ? grid.getContentProvider().getCellHeaderSelectionBackground(element) : grid.getContentProvider().getCellHeaderBackground(element);
if (background == null) {
background = DEFAULT_BACKGROUND;
}
gc.setBackground(background);
gc.fillRectangle(bounds.x, bounds.y, bounds.width, bounds.height + 1);
{
gc.setForeground(grid.getContentProvider().getCellHeaderForeground(element));
gc.drawLine(
bounds.x + bounds.width - 1,
bounds.y,
bounds.x + bounds.width - 1,
bounds.y + bounds.height - 1);
gc.drawLine(
bounds.x,
bounds.y + bounds.height - 1,
bounds.x + bounds.width - 1,
bounds.y + bounds.height - 1);
}
int x = LEFT_MARGIN;
if (level > 0) {
x += level * LEVEL_SPACING;
}
if (state != IGridContentProvider.ElementState.NONE) {
Image expandImage = state == IGridContentProvider.ElementState.EXPANDED ? IMG_COLLAPSE : IMG_EXPAND;
gc.drawImage(expandImage, x, bounds.y + (bounds.height - EXPANDED_BOUNDS.height) / 2);
x += EXPANDED_BOUNDS.width + EXPANDER_SPACING;
} else if (grid.hasNodes()) {
x += EXPANDED_BOUNDS.width + EXPANDER_SPACING;
}
Image image = grid.getLabelProvider().getImage(element);
if (image != null) {
gc.drawImage(image, x, bounds.y + (bounds.height - image.getBounds().height) / 2);
x += image.getBounds().width + IMAGE_SPACING;
}
int width = bounds.width - x;
width -= RIGHT_MARGIN;
Color foreground = grid.getContentProvider().getCellHeaderForeground(element);
if (foreground == null) {
foreground = grid.getLabelProvider().getForeground(element);
}
gc.setForeground(foreground);
int y = bounds.y;
int selectionOffset = 0;
y += (bounds.height - gc.stringExtent(text).y) / 2;
gc.drawString(TextUtils.getShortString(grid.fontMetrics, text, width), bounds.x + x + selectionOffset, y + selectionOffset, true);
}
public int computeHeaderWidth(Object element, int level) {
int width = GridRowRenderer.LEFT_MARGIN + GridRowRenderer.RIGHT_MARGIN;
if (grid.hasNodes()) {
width += GridRowRenderer.EXPANDED_BOUNDS.width + EXPANDER_SPACING;
}
Image rowImage = grid.getLabelProvider().getImage(element);
if (rowImage != null) {
width += rowImage.getBounds().width;
width += GridRowRenderer.IMAGE_SPACING;
}
String rowText = grid.getLabelProvider().getText(element);
Point ext = grid.sizingGC.stringExtent(rowText);
width += ext.x;
width += level * GridRowRenderer.LEVEL_SPACING;
return width;
}
public static boolean isOverExpander(int x, int level)
{
int expandBegin = LEFT_MARGIN + level * LEVEL_SPACING;
int expandEnd = expandBegin + EXPANDED_BOUNDS.width;
return x >= expandBegin && x <= expandEnd;
}
}
/*
* DBeaver - Universal Database Manager
* Copyright (C) 2010-2017 Serge Rider (serge@jkiss.org)
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.jkiss.dbeaver.ui.controls.lightgrid;
import org.eclipse.jface.viewers.IContentProvider;
import org.eclipse.swt.graphics.Color;
import org.jkiss.code.NotNull;
import org.jkiss.code.Nullable;
import org.jkiss.dbeaver.model.DBPImage;
public interface IGridContentProvider extends IContentProvider {
enum ElementState {
NONE,
EXPANDED,
COLLAPSED
}
int STATE_NONE = 0;
int STATE_LINK = 1;
int STATE_HYPER_LINK = 2;
int STATE_TRANSFORMED = 4;
int ALIGN_LEFT = 0;
int ALIGN_CENTER = 1;
int ALIGN_RIGHT = 2;
@NotNull
Object[] getElements(boolean horizontal);
@Nullable
Object[] getChildren(Object element);
int getSortOrder(@Nullable Object element);
ElementState getDefaultState(@NotNull Object element);
int getColumnAlign(@Nullable Object element);
boolean isElementSupportsFilter(@Nullable Object element);
/**
*
* @param cellText pre-rendered cell text. Used for cache purposes.
*/
int getCellState(Object colElement, Object rowElement, @Nullable String cellText);
Object getCellValue(Object colElement, Object rowElement, boolean formatString);
@NotNull
String getCellText(Object colElement, Object rowElement);
@Nullable
DBPImage getCellImage(Object colElement, Object rowElement);
@Nullable
Color getCellForeground(Object colElement, Object rowElement, boolean selected);
@Nullable
Color getCellBackground(Object colElement, Object rowElement, boolean selected);
@Nullable
Color getCellHeaderForeground(Object element);
@Nullable
Color getCellHeaderBackground(Object element);
@Nullable
Color getCellHeaderSelectionBackground(Object element);
@NotNull
String getCellLinkText(Object colElement, Object rowElement);
// Resets all cached colors
void resetColors();
}
/*
* DBeaver - Universal Database Manager
* Copyright (C) 2010-2017 Serge Rider (serge@jkiss.org)
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.jkiss.dbeaver.ui.controls.lightgrid;
import org.eclipse.jface.viewers.IContentProvider;
import org.eclipse.swt.graphics.Color;
import org.jkiss.code.NotNull;
import org.jkiss.code.Nullable;
import org.jkiss.dbeaver.model.DBPImage;
public interface IGridContentProvider extends IContentProvider {
enum ElementState {
NONE,
EXPANDED,
COLLAPSED
}
int STATE_NONE = 0;
int STATE_LINK = 1;
int STATE_HYPER_LINK = 2;
int STATE_TRANSFORMED = 4;
int ALIGN_LEFT = 0;
int ALIGN_CENTER = 1;
int ALIGN_RIGHT = 2;
@NotNull
Object[] getElements(boolean horizontal);
@Nullable
Object[] getChildren(Object element);
int getSortOrder(@Nullable Object element);
ElementState getDefaultState(@NotNull Object element);
int getColumnAlign(@Nullable Object element);
boolean isElementSupportsFilter(@Nullable Object element);
/**
*
* @param cellText pre-rendered cell text. Used for cache purposes.
*/
int getCellState(Object colElement, Object rowElement, @Nullable String cellText);
Object getCellValue(Object colElement, Object rowElement, boolean formatString);
@NotNull
String getCellText(Object colElement, Object rowElement);
@Nullable
DBPImage getCellImage(Object colElement, Object rowElement);
@Nullable
Color getCellForeground(Object colElement, Object rowElement, boolean selected);
@Nullable
Color getCellBackground(Object colElement, Object rowElement, boolean selected);
@Nullable
Color getCellHeaderForeground(Object element);
@Nullable
Color getCellHeaderBackground(Object element);
@Nullable
Color getCellHeaderSelectionBackground(Object element);
@NotNull
String getCellLinkText(Object colElement, Object rowElement);
// Resets all cached colors
void resetColors();
}
/*
* DBeaver - Universal Database Manager
* Copyright (C) 2010-2017 Serge Rider (serge@jkiss.org)
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.jkiss.dbeaver.ui.controls.lightgrid;
import org.eclipse.jface.viewers.IColorProvider;
import org.eclipse.jface.viewers.IFontProvider;
import org.eclipse.jface.viewers.IToolTipProvider;
import org.eclipse.swt.graphics.Image;
import org.jkiss.code.NotNull;
import org.jkiss.code.Nullable;
public interface IGridLabelProvider extends IColorProvider, IFontProvider, IToolTipProvider {
String OPTION_EXCLUDE_COLUMN_NAME_FOR_WIDTH_CALC = "OPTION_EXCLUDE_COLUMN_NAME_FOR_WIDTH_CALC";
@NotNull
String getText(Object element);
@Nullable
String getDescription(Object element);
@Nullable
Image getImage(Object element);
Object getGridOption(String option);
}
/*
* DBeaver - Universal Database Manager
* Copyright (C) 2010-2017 Serge Rider (serge@jkiss.org)
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.jkiss.dbeaver.ui.controls.lightgrid;
import org.eclipse.jface.viewers.IColorProvider;
import org.eclipse.jface.viewers.IFontProvider;
import org.eclipse.jface.viewers.IToolTipProvider;
import org.eclipse.swt.graphics.Image;
import org.jkiss.code.NotNull;
import org.jkiss.code.Nullable;
public interface IGridLabelProvider extends IColorProvider, IFontProvider, IToolTipProvider {
String OPTION_EXCLUDE_COLUMN_NAME_FOR_WIDTH_CALC = "OPTION_EXCLUDE_COLUMN_NAME_FOR_WIDTH_CALC";
@NotNull
String getText(Object element);
@Nullable
String getDescription(Object element);
@Nullable
Image getImage(Object element);
Object getGridOption(String option);
}
/*
* DBeaver - Universal Database Manager
* Copyright (C) 2010-2017 Serge Rider (serge@jkiss.org)
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.jkiss.dbeaver.ui.controls.lightgrid;
import org.eclipse.swt.events.SelectionListener;
import org.eclipse.swt.widgets.Event;
/**
* Used by Grid to externalize the scrollbars from the table itself.
*
* @author chris.gross@us.ibm.com
* @version 1.0.0
*/
public interface IGridScrollBar
{
public int getWidth();
public boolean getVisible();
public void setVisible(boolean visible);
public int getSelection();
public void setSelection(int selection);
/**
* Sets the receiver's selection, minimum value, maximum value, thumb,
* increment and page increment all at once.
*
* @param selection selection
* @param min minimum
* @param max maximum
* @param thumb thumb
* @param increment increment
* @param pageIncrement page increment
*/
public void setValues(int selection, int min, int max, int thumb, int increment, int pageIncrement);
public void handleMouseWheel(Event e);
public void setMinimum(int min);
public int getMinimum();
public void setMaximum(int max);
public int getMaximum();
public void setThumb(int thumb);
public int getThumb();
public void setIncrement(int increment);
public int getIncrement();
public void setPageIncrement(int page);
public int getPageIncrement();
public void addSelectionListener(SelectionListener listener);
public void removeSelectionListener(SelectionListener listener);
}
/*
* DBeaver - Universal Database Manager
* Copyright (C) 2010-2017 Serge Rider (serge@jkiss.org)
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.jkiss.dbeaver.ui.controls.lightgrid;
import org.eclipse.swt.events.SelectionListener;
import org.eclipse.swt.widgets.Event;
/**
* Used by Grid to externalize the scrollbars from the table itself.
*
* @author chris.gross@us.ibm.com
* @version 1.0.0
*/
public interface IGridScrollBar
{
public int getWidth();
public boolean getVisible();
public void setVisible(boolean visible);
public int getSelection();
public void setSelection(int selection);
/**
* Sets the receiver's selection, minimum value, maximum value, thumb,
* increment and page increment all at once.
*
* @param selection selection
* @param min minimum
* @param max maximum
* @param thumb thumb
* @param increment increment
* @param pageIncrement page increment
*/
public void setValues(int selection, int min, int max, int thumb, int increment, int pageIncrement);
public void handleMouseWheel(Event e);
public void setMinimum(int min);
public int getMinimum();
public void setMaximum(int max);
public int getMaximum();
public void setThumb(int thumb);
public int getThumb();
public void setIncrement(int increment);
public int getIncrement();
public void setPageIncrement(int page);
public int getPageIncrement();
public void addSelectionListener(SelectionListener listener);
public void removeSelectionListener(SelectionListener listener);
}
/*
* DBeaver - Universal Database Manager
* Copyright (C) 2010-2017 Serge Rider (serge@jkiss.org)
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.jkiss.dbeaver.ui.controls.lightgrid;
import org.eclipse.swt.events.SelectionListener;
import org.eclipse.swt.widgets.Event;
/**
* A null-op scrollbar proxy. Used when the grid is not showing scrollbars.
*
* @author chris.gross@us.ibm.com
* @since 2.0.0
*/
class NullScrollBar implements IGridScrollBar
{
@Override
public int getWidth()
{
return 0;
}
@Override
public boolean getVisible()
{
return false;
}
@Override
public void setVisible(boolean visible)
{
}
@Override
public int getSelection()
{
return 0;
}
@Override
public void setSelection(int selection)
{
}
@Override
public void setValues(int selection, int min, int max, int thumb, int increment, int pageIncrement)
{
}
@Override
public void handleMouseWheel(Event e)
{
}
@Override
public void setMinimum(int min)
{
}
@Override
public int getMinimum()
{
return 0;
}
@Override
public void setMaximum(int max)
{
}
@Override
public int getMaximum()
{
return 0;
}
@Override
public void setThumb(int thumb)
{
}
@Override
public int getThumb()
{
return 0;
}
@Override
public void setIncrement(int increment)
{
}
@Override
public int getIncrement()
{
return 0;
}
@Override
public void setPageIncrement(int page)
{
}
@Override
public int getPageIncrement()
{
return 0;
}
@Override
public void addSelectionListener(SelectionListener listener)
{
}
@Override
public void removeSelectionListener(SelectionListener listener)
{
}
}
/*
* DBeaver - Universal Database Manager
* Copyright (C) 2010-2017 Serge Rider (serge@jkiss.org)
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.jkiss.dbeaver.ui.controls.lightgrid;
import org.eclipse.swt.events.SelectionListener;
import org.eclipse.swt.widgets.Event;
/**
* A null-op scrollbar proxy. Used when the grid is not showing scrollbars.
*
* @author chris.gross@us.ibm.com
* @since 2.0.0
*/
class NullScrollBar implements IGridScrollBar
{
@Override
public int getWidth()
{
return 0;
}
@Override
public boolean getVisible()
{
return false;
}
@Override
public void setVisible(boolean visible)
{
}
@Override
public int getSelection()
{
return 0;
}
@Override
public void setSelection(int selection)
{
}
@Override
public void setValues(int selection, int min, int max, int thumb, int increment, int pageIncrement)
{
}
@Override
public void handleMouseWheel(Event e)
{
}
@Override
public void setMinimum(int min)
{
}
@Override
public int getMinimum()
{
return 0;
}
@Override
public void setMaximum(int max)
{
}
@Override
public int getMaximum()
{
return 0;
}
@Override
public void setThumb(int thumb)
{
}
@Override
public int getThumb()
{
return 0;
}
@Override
public void setIncrement(int increment)
{
}
@Override
public int getIncrement()
{
return 0;
}
@Override
public void setPageIncrement(int page)
{
}
@Override
public int getPageIncrement()
{
return 0;
}
@Override
public void addSelectionListener(SelectionListener listener)
{
}
@Override
public void removeSelectionListener(SelectionListener listener)
{
}
}
/*
* DBeaver - Universal Database Manager
* Copyright (C) 2010-2017 Serge Rider (serge@jkiss.org)
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.jkiss.dbeaver.ui.controls.lightgrid;
import org.eclipse.swt.events.SelectionListener;
import org.eclipse.swt.widgets.Event;
import org.eclipse.swt.widgets.ScrollBar;
/**
* Adapts a normal scrollbar to the IScrollBar proxy.
*
* @author chris.gross@us.ibm.com
* @since 2.0.0
*/
class ScrollBarAdapter implements IGridScrollBar
{
/**
* Delegates to this scrollbar.
*/
private ScrollBar scrollBar;
/**
* Contructs this adapter by delegating to the given scroll bar.
*
* @param scrollBar delegate
*/
public ScrollBarAdapter(ScrollBar scrollBar)
{
super();
this.scrollBar = scrollBar;
}
@Override
public int getIncrement()
{
return scrollBar.getIncrement();
}
@Override
public int getMaximum()
{
return scrollBar.getMaximum();
}
@Override
public int getMinimum()
{
return scrollBar.getMinimum();
}
@Override
public int getPageIncrement()
{
return scrollBar.getPageIncrement();
}
@Override
public int getSelection()
{
return scrollBar.getSelection();
}
@Override
public int getThumb()
{
return scrollBar.getThumb();
}
@Override
public int getWidth()
{
return scrollBar.getSize().x;
}
@Override
public boolean getVisible()
{
return scrollBar.getVisible();
}
@Override
public void setIncrement(int value)
{
scrollBar.setIncrement(value);
}
@Override
public void setMaximum(int value)
{
scrollBar.setMaximum(value);
}
@Override
public void setMinimum(int value)
{
scrollBar.setMinimum(value);
}
@Override
public void setPageIncrement(int value)
{
scrollBar.setPageIncrement(value);
}
@Override
public void setSelection(int selection)
{
scrollBar.setSelection(selection);
}
@Override
public void setThumb(int value)
{
scrollBar.setThumb(value);
}
@Override
public void setValues(int selection, int minimum, int maximum, int thumb, int increment,
int pageIncrement)
{
scrollBar.setValues(selection, minimum, maximum, thumb, increment, pageIncrement);
}
@Override
public void setVisible(boolean visible)
{
scrollBar.setVisible(visible);
}
@Override
public void handleMouseWheel(Event e)
{
//do nothing
}
@Override
public void addSelectionListener(SelectionListener listener)
{
scrollBar.addSelectionListener(listener);
}
@Override
public void removeSelectionListener(SelectionListener listener)
{
scrollBar.removeSelectionListener(listener);
}
}
/*
* DBeaver - Universal Database Manager
* Copyright (C) 2010-2017 Serge Rider (serge@jkiss.org)
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.jkiss.dbeaver.ui.controls.lightgrid;
import org.eclipse.swt.events.SelectionListener;
import org.eclipse.swt.widgets.Event;
import org.eclipse.swt.widgets.ScrollBar;
/**
* Adapts a normal scrollbar to the IScrollBar proxy.
*
* @author chris.gross@us.ibm.com
* @since 2.0.0
*/
class ScrollBarAdapter implements IGridScrollBar
{
/**
* Delegates to this scrollbar.
*/
private ScrollBar scrollBar;
/**
* Contructs this adapter by delegating to the given scroll bar.
*
* @param scrollBar delegate
*/
public ScrollBarAdapter(ScrollBar scrollBar)
{
super();
this.scrollBar = scrollBar;
}
@Override
public int getIncrement()
{
return scrollBar.getIncrement();
}
@Override
public int getMaximum()
{
return scrollBar.getMaximum();
}
@Override
public int getMinimum()
{
return scrollBar.getMinimum();
}
@Override
public int getPageIncrement()
{
return scrollBar.getPageIncrement();
}
@Override
public int getSelection()
{
return scrollBar.getSelection();
}
@Override
public int getThumb()
{
return scrollBar.getThumb();
}
@Override
public int getWidth()
{
return scrollBar.getSize().x;
}
@Override
public boolean getVisible()
{
return scrollBar.getVisible();
}
@Override
public void setIncrement(int value)
{
scrollBar.setIncrement(value);
}
@Override
public void setMaximum(int value)
{
scrollBar.setMaximum(value);
}
@Override
public void setMinimum(int value)
{
scrollBar.setMinimum(value);
}
@Override
public void setPageIncrement(int value)
{
scrollBar.setPageIncrement(value);
}
@Override
public void setSelection(int selection)
{
scrollBar.setSelection(selection);
}
@Override
public void setThumb(int value)
{
scrollBar.setThumb(value);
}
@Override
public void setValues(int selection, int minimum, int maximum, int thumb, int increment,
int pageIncrement)
{
scrollBar.setValues(selection, minimum, maximum, thumb, increment, pageIncrement);
}
@Override
public void setVisible(boolean visible)
{
scrollBar.setVisible(visible);
}
@Override
public void handleMouseWheel(Event e)
{
//do nothing
}
@Override
public void addSelectionListener(SelectionListener listener)
{
scrollBar.addSelectionListener(listener);
}
@Override
public void removeSelectionListener(SelectionListener listener)
{
scrollBar.removeSelectionListener(listener);
}
}
/*
* DBeaver - Universal Database Manager
* Copyright (C) 2010-2017 Serge Rider (serge@jkiss.org)
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.jkiss.dbeaver.ui.editors.data.internal;
import org.eclipse.jface.resource.ImageDescriptor;
import org.eclipse.ui.plugin.AbstractUIPlugin;
import org.jkiss.dbeaver.runtime.DBeaverNotifications;
import org.jkiss.dbeaver.ui.notifications.NotificationUtils;
import org.osgi.framework.BundleContext;
public class DataEditorsActivator extends AbstractUIPlugin {
// The plug-in ID
public static final String PLUGIN_ID = "org.jkiss.dbeaver.ui.editors.data";
// The shared instance
private static DataEditorsActivator plugin;
public DataEditorsActivator() {
}
@Override
public void start(BundleContext context) throws Exception {
super.start(context);
plugin = this;
}
@Override
public void stop(BundleContext context) throws Exception {
plugin = null;
super.stop(context);
}
public static DataEditorsActivator getDefault() {
return plugin;
}
public static ImageDescriptor getImageDescriptor(String path) {
return imageDescriptorFromPlugin(PLUGIN_ID, path);
}
}
/*
* DBeaver - Universal Database Manager
* Copyright (C) 2010-2017 Serge Rider (serge@jkiss.org)
* Copyright (C) 2011-2012 Eugene Fradkin (eugene.fradkin@gmail.com)
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.jkiss.dbeaver.ui.editors.data.internal;
import org.eclipse.osgi.util.NLS;
public class DataEditorsMessages extends NLS {
static final String BUNDLE_NAME = "org.jkiss.dbeaver.ui.editors.data.internal.DataEditorsResources"; //$NON-NLS-1$
public static String grid_tooltip_sort_by_column;
public static String grid_tooltip_filter_by_column;
static {
// initialize resource bundle
NLS.initializeMessages(BUNDLE_NAME, DataEditorsMessages.class);
}
private DataEditorsMessages() {
}
}
grid_tooltip_sort_by_column = Sort by column
grid_tooltip_filter_by_column = Filter by column value
grid_tooltip_filter_by_column = Filtern mit Spaltenwert
grid_tooltip_sort_by_column = Sortieren mit Spalte
grid_tooltip_sort_by_column = Trier par colonne
grid_tooltip_filter_by_column = Filtrer par la valeur de colonne
grid_tooltip_sort_by_column = \u0421\u043E\u0440\u0442\u0438\u0440\u043E\u0432\u043A\u0430 \u043F\u043E \u043A\u043E\u043B\u043E\u043D\u043A\u0435
grid_tooltip_filter_by_column = \u0424\u0438\u043B\u044C\u0442\u0440 \u043F\u043E \u0437\u043D\u0430\u0447\u0435\u043D\u0438\u044E \u043A\u043E\u043B\u043E\u043D\u043A\u0438
grid_tooltip_filter_by_column = \u6309\u5217\u503C\u8FC7\u6EE4
grid_tooltip_sort_by_column = \u6309\u5217\u8FC7\u6EE4
......@@ -6,7 +6,7 @@ Bundle-SymbolicName: org.jkiss.dbeaver.ui;singleton:=true
Bundle-Version: 5.1.15.qualifier
Bundle-Release-Date: 20190107
Bundle-RequiredExecutionEnvironment: JavaSE-1.8
Bundle-Activator: org.jkiss.dbeaver.bundle.UIActivator
Bundle-Activator: org.jkiss.dbeaver.ui.internal.UIActivator
Bundle-ActivationPolicy: lazy
Export-Package: org.jkiss.dbeaver.runtime,
org.jkiss.dbeaver.ui,
......
......@@ -17,10 +17,7 @@
package org.jkiss.dbeaver.ui;
import org.eclipse.jface.action.Action;
import org.jkiss.dbeaver.bundle.UIMessages;
import org.jkiss.dbeaver.ui.DBeaverIcons;
import org.jkiss.dbeaver.ui.ISearchContextProvider;
import org.jkiss.dbeaver.ui.UIIcon;
import org.jkiss.dbeaver.ui.internal.UIMessages;
/**
* Context search action
......
......@@ -19,7 +19,7 @@ package org.jkiss.dbeaver.ui;
import org.eclipse.core.runtime.IStatus;
import org.eclipse.core.runtime.Status;
import org.jkiss.dbeaver.Log;
import org.jkiss.dbeaver.bundle.UIActivator;
import org.jkiss.dbeaver.ui.internal.UIActivator;
import org.jkiss.dbeaver.model.runtime.AbstractJob;
import org.jkiss.dbeaver.model.runtime.DBRProgressMonitor;
import org.jkiss.dbeaver.model.runtime.VoidProgressMonitor;
......
......@@ -63,7 +63,7 @@ import org.eclipse.ui.swt.IFocusService;
import org.jkiss.code.NotNull;
import org.jkiss.code.Nullable;
import org.jkiss.dbeaver.Log;
import org.jkiss.dbeaver.bundle.UIActivator;
import org.jkiss.dbeaver.ui.internal.UIActivator;
import org.jkiss.dbeaver.model.DBIcon;
import org.jkiss.dbeaver.model.DBPImage;
import org.jkiss.dbeaver.model.DBPNamedObject;
......
......@@ -26,7 +26,7 @@ import org.eclipse.swt.events.SelectionEvent;
import org.eclipse.swt.graphics.Point;
import org.eclipse.swt.graphics.Rectangle;
import org.eclipse.swt.widgets.*;
import org.jkiss.dbeaver.bundle.UIMessages;
import org.jkiss.dbeaver.ui.internal.UIMessages;
import org.jkiss.dbeaver.model.runtime.DBRRunnableWithProgress;
import org.jkiss.dbeaver.ui.DBeaverIcons;
import org.jkiss.dbeaver.ui.UIIcon;
......
......@@ -23,7 +23,7 @@ import org.eclipse.swt.widgets.*;
import org.jkiss.code.NotNull;
import org.jkiss.code.Nullable;
import org.jkiss.dbeaver.Log;
import org.jkiss.dbeaver.bundle.UIMessages;
import org.jkiss.dbeaver.ui.internal.UIMessages;
import org.jkiss.dbeaver.runtime.DBWorkbench;
import org.jkiss.dbeaver.runtime.ui.DBUserInterface;
import org.jkiss.dbeaver.ui.UIUtils;
......
......@@ -14,7 +14,7 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.jkiss.dbeaver.bundle;
package org.jkiss.dbeaver.ui.internal;
import org.eclipse.jface.resource.ImageDescriptor;
import org.eclipse.ui.plugin.AbstractUIPlugin;
......
......@@ -15,12 +15,12 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.jkiss.dbeaver.bundle;
package org.jkiss.dbeaver.ui.internal;
import org.eclipse.osgi.util.NLS;
public class UIMessages extends NLS {
static final String BUNDLE_NAME = "org.jkiss.dbeaver.bundle.UIMessages"; //$NON-NLS-1$
static final String BUNDLE_NAME = "org.jkiss.dbeaver.ui.internal.UIMessages"; //$NON-NLS-1$
public static String output_label_directory;
......
......@@ -36,7 +36,7 @@ import org.eclipse.swt.layout.GridLayout;
import org.eclipse.swt.widgets.*;
import org.eclipse.ui.views.properties.IPropertySource2;
import org.jkiss.code.Nullable;
import org.jkiss.dbeaver.bundle.UIMessages;
import org.jkiss.dbeaver.ui.internal.UIMessages;
import org.jkiss.dbeaver.model.DBPObject;
import org.jkiss.dbeaver.runtime.DBWorkbench;
import org.jkiss.dbeaver.model.preferences.DBPPropertyDescriptor;
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册