Skip to content

Commit

Permalink
Merge pull request #4652 from nadment/4651
Browse files Browse the repository at this point in the history
Add a property to the ColumnInfo class to define an image #4651
  • Loading branch information
hansva authored Dec 10, 2024
2 parents b9f2bde + 991ad7d commit 689528c
Show file tree
Hide file tree
Showing 4 changed files with 26 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -287,10 +287,12 @@ private boolean addFields() {

ColumnInfo[] columns = new ColumnInfo[rowMeta.size()];
for (int i = 0; i < rowMeta.size(); i++) {
IValueMeta v = rowMeta.getValueMeta(i);
columns[i] = new ColumnInfo(v.getName(), ColumnInfo.COLUMN_TYPE_TEXT, v.isNumeric());
columns[i].setToolTip(v.toStringMeta());
columns[i].setValueMeta(v);
IValueMeta valueMeta = rowMeta.getValueMeta(i);
columns[i] =
new ColumnInfo(valueMeta.getName(), ColumnInfo.COLUMN_TYPE_TEXT, valueMeta.isNumeric());
columns[i].setToolTip(valueMeta.toStringMeta());
columns[i].setValueMeta(valueMeta);
columns[i].setImage(GuiResource.getInstance().getImage(valueMeta));
}

wFields =
Expand Down
15 changes: 15 additions & 0 deletions ui/src/main/java/org/apache/hop/ui/core/widget/ColumnInfo.java
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
import org.apache.hop.core.row.value.ValueMetaString;
import org.eclipse.swt.SWT;
import org.eclipse.swt.events.SelectionListener;
import org.eclipse.swt.graphics.Image;

/** Used to define the behaviour and the content of a Table column in a TableView object. */
public class ColumnInfo {
Expand All @@ -41,6 +42,7 @@ public class ColumnInfo {
private Supplier<String[]> comboValueSupplier = () -> comboValues;
private boolean numeric;
private String tooltip;
private Image image;
private int alignment;
private boolean readonly;
private String buttonText;
Expand Down Expand Up @@ -241,6 +243,19 @@ public String getToolTip() {
return tooltip;
}

public Image getImage() {
return image;
}

/**
* Sets the column's image to be displayed.
*
* @param image the image to display on the receiver (may be null)
*/
public void setImage(Image image) {
this.image = image;
}

public int getAlignment() {
return alignment;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -394,7 +394,10 @@ public TableView(
tableColumn[i + 1].setText(columnName);
}
if (columns[i].getToolTip() != null) {
tableColumn[i + 1].setToolTipText((columns[i].getToolTip()));
tableColumn[i + 1].setToolTipText(columns[i].getToolTip());
}
if (columns[i].getImage() != null) {
tableColumn[i + 1].setImage(columns[i].getImage());
}
IValueMeta valueMeta = columns[i].getValueMeta();
if (valueMeta != null && valueMeta.isNumeric()) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -544,6 +544,7 @@ private void showDataRows() {
valueMeta.getName(), ColumnInfo.COLUMN_TYPE_TEXT, valueMeta.isNumeric());
columnInfo.setValueMeta(valueMeta);
columnInfo.setToolTip(valueMeta.toStringMeta());
columnInfo.setImage(GuiResource.getInstance().getImage(valueMeta));
columns.add(columnInfo);
}

Expand Down

0 comments on commit 689528c

Please sign in to comment.