import org.eclipse.swt.events.SelectionEvent;
import org.eclipse.swt.events.SelectionListener;
import org.eclipse.swt.graphics.Color;
+import org.eclipse.swt.graphics.GC;
import org.eclipse.swt.graphics.Image;
+import org.eclipse.swt.graphics.Point;
import org.eclipse.swt.layout.FormAttachment;
import org.eclipse.swt.layout.FormData;
import org.eclipse.swt.widgets.Composite;
+import org.eclipse.swt.widgets.Display;
import org.eclipse.swt.widgets.Event;
import org.eclipse.swt.widgets.Listener;
import org.eclipse.swt.widgets.Menu;
private ImageButton modifyButton;
private ImageButton deleteButton;
+ private int maxItemHeight = 0;
+
public BaseImageTableViewer(Shell shell, String key) {
super(shell, key);
}
settingSortingPair();
setTableItemMenu();
+
+ //
+ maxItemHeight = table.getItemHeight();
+ //
}
private void settingSortingPair() {
setTableItemProperty(item, image);
}
+ private int getTextHeight(String text) {
+ GC gc = new GC(Display.getCurrent());
+ Point p = gc.textExtent(text);
+ gc.dispose();
+ return p.y;
+ }
+
private Color backupTableItemForeground;
private Color backupTableItemSelectedForeground;
private void setTableItemProperty(TableItem item, BaseImage image) {
item.setText(4, image.getPathName());
// TODO set description
item.setText(5, image.getDescription());
+ if (!image.getDescription().isEmpty()) {
+ int height = getTextHeight(image.getDescription());
+ if (maxItemHeight < height) {
+ maxItemHeight = height;
+ table.setItemHeight(maxItemHeight);
+ table.setSelectedItemHeight(maxItemHeight);
+ table.redraw();
+ }
+ }
+
item.setData(image);
settingToolTip(item, image);
String pathToolTip = "Path: " + image.getPath();
item.setToolTipText(4, pathToolTip);
+
+ item.setToolTipText(5, image.getDescription());
}
private Menu menu;