📄 faketablecell.java
字号:
} else
{
composite.setForeground(Colors.colorError);
return true;
}
}
public boolean setGraphic(Graphic img)
{
Image imgSWT = null;
if (img instanceof UISWTGraphic)
imgSWT = ((UISWTGraphic)img).getImage();
if (imgSWT != null && imgSWT.isDisposed())
return false;
if (image == imgSWT)
return false;
image = imgSWT;
if (image != null)
imageBounds = image.getBounds();
if (composite != null && !composite.isDisposed())
redraw();
graphic = img;
return true;
}
public void setMarginHeight(int i)
{
}
public void setMarginWidth(int i)
{
}
public boolean setSortValue(Comparable valueToSort)
{
return false;
}
public boolean setSortValue(float valueToSort)
{
return false;
}
public boolean setText(String text)
{
if (text != null && text.equals(this.text))
{
return false;
} else
{
this.text = text;
Utils.execSWTThread(new AERunnable() {
final FakeTableCell this$0;
public void runSupport()
{
if (!isDisposed())
composite.redraw();
}
{
this$0 = FakeTableCell.this;
super();
}
});
return true;
}
}
public void setToolTip(Object tooltip)
{
this.tooltip = tooltip;
if (!isDisposed())
composite.setToolTipText(tooltip != null ? tooltip.toString() : null);
}
private boolean _setSortValue(Comparable valueToSort)
{
if (sortValue == valueToSort)
return false;
if ((valueToSort instanceof String) && (sortValue instanceof String) && sortValue.equals(valueToSort))
return false;
if ((valueToSort instanceof Number) && (sortValue instanceof Number) && sortValue.equals(valueToSort))
{
return false;
} else
{
sortValue = valueToSort;
return true;
}
}
public boolean setSortValue(long valueToSort)
{
if ((sortValue instanceof Long) && ((Long)sortValue).longValue() == valueToSort)
return false;
else
return _setSortValue(new Long(valueToSort));
}
public void doPaint(GC gc, Rectangle bounds)
{
if (isDisposed())
return;
if (bounds == null)
return;
if (image != null && !image.isDisposed())
{
Point size = new Point(bounds.width, bounds.height);
int y = marginHeight;
y += (size.y - imageBounds.height) / 2;
int x;
if (orientation == 0x1000000)
{
x = marginWidth;
x += (size.x - marginWidth * 2 - imageBounds.width) / 2;
} else
if (orientation == 0x20000)
x = bounds.width - marginWidth - imageBounds.width;
else
x = marginWidth;
int width = Math.min(bounds.width - x - marginWidth, imageBounds.width);
int height = Math.min(bounds.height - y - marginHeight, imageBounds.height);
if (width >= 0 && height >= 0)
gc.drawImage(image, 0, 0, width, height, bounds.x + x, bounds.y + y, width, height);
}
if (text != null && text.length() > 0)
{
GCStringPrinter sp = new GCStringPrinter(gc, text, bounds, true, false, orientation | 0x40);
sp.printString();
hadMore = sp.isCutoff();
}
invokeSWTPaintListeners(gc);
}
public boolean refresh()
{
Utils.execSWTThread(new AERunnable() {
final FakeTableCell this$0;
public void runSupport()
{
boolean wasValid = valid;
try
{
tableColumn.invokeCellRefreshListeners(FakeTableCell.this, false);
}
catch (Throwable e) { }
if (refreshListeners != null)
{
for (int i = 0; i < refreshListeners.size(); i++)
((TableCellRefreshListener)(TableCellRefreshListener)refreshListeners.get(i)).refresh(FakeTableCell.this);
}
if (!wasValid)
valid = true;
}
{
this$0 = FakeTableCell.this;
super();
}
});
return true;
}
public void setDataSource(Object datasource)
{
coreDataSource = datasource;
if (datasource != null && !isDisposed())
invokeVisibilityListeners(0, true);
}
public void setControl(Composite composite)
{
setControl(composite, null);
}
public void setControl(Composite composite, Rectangle cellArea)
{
if (composite == null)
{
dispose();
this.composite = null;
return;
}
this.composite = composite;
this.cellArea = cellArea;
composite.addPaintListener(this);
composite.addMouseListener(this);
composite.addMouseMoveListener(this);
composite.addMouseTrackListener(this);
setForeground(-1, -1, -1);
setText(null);
setToolTip(null);
composite.addDisposeListener(new DisposeListener() {
final FakeTableCell this$0;
public void widgetDisposed(DisposeEvent e)
{
dispose();
}
{
this$0 = FakeTableCell.this;
super();
}
});
if (coreDataSource != null && !isDisposed())
invokeVisibilityListeners(0, true);
}
public void paintControl(PaintEvent e)
{
doPaint(e.gc, cellArea != null ? cellArea : composite.getClientArea());
}
public void mouseUp(MouseEvent e)
{
invokeMouseListeners(buildMouseEvent(e, 1));
}
public void mouseDown(MouseEvent e)
{
if (composite == null || composite.getMenu() != null || cellMouseListeners != null && cellMouseListeners.size() > 0 || text == null || text.length() == 0)
{
invokeMouseListeners(buildMouseEvent(e, 0));
return;
}
if (e.button != 3 && (e.button != 1 || e.stateMask != 0x40000))
{
invokeMouseListeners(buildMouseEvent(e, 0));
return;
}
Menu menu = new Menu(composite.getShell(), 8);
MenuItem item = new MenuItem(menu, 0);
item.setText(MessageText.getString("ConfigView.copy.to.clipboard.tooltip"));
item.addSelectionListener(new SelectionAdapter() {
final FakeTableCell this$0;
public void widgetSelected(SelectionEvent arg0)
{
if (!composite.isDisposed() && text != null && text.length() > 0)
(new Clipboard(composite.getDisplay())).setContents(new Object[] {
text
}, new Transfer[] {
TextTransfer.getInstance()
});
}
{
this$0 = FakeTableCell.this;
super();
}
});
composite.setMenu(menu);
menu.addMenuListener(new MenuAdapter() {
final FakeTableCell this$0;
public void menuHidden(MenuEvent arg0)
{
if (!composite.isDisposed())
composite.setMenu(null);
}
{
this$0 = FakeTableCell.this;
super();
}
});
menu.setVisible(true);
invokeMouseListeners(buildMouseEvent(e, 0));
break MISSING_BLOCK_LABEL_199;
Exception exception;
exception;
invokeMouseListeners(buildMouseEvent(e, 0));
throw exception;
}
public void mouseDoubleClick(MouseEvent e)
{
invokeMouseListeners(buildMouseEvent(e, 2));
}
public void mouseMove(MouseEvent e)
{
invokeMouseListeners(buildMouseEvent(e, 3));
}
public void mouseHover(MouseEvent e)
{
invokeToolTipListeners(0);
}
public void mouseExit(MouseEvent e)
{
invokeMouseListeners(buildMouseEvent(e, 5));
}
public void mouseEnter(MouseEvent e)
{
invokeMouseListeners(buildMouseEvent(e, 4));
}
protected TableCellMouseEvent buildMouseEvent(MouseEvent e, int eventType)
{
if (isDisposed())
return null;
TableCellMouseEvent event = new TableCellMouseEvent();
event.cell = this;
event.button = e.button;
event.keyboardState = e.stateMask;
event.eventType = eventType;
Rectangle r = composite.getBounds();
if (cellArea != null)
r = new Rectangle(r.x + cellArea.x, r.y + cellArea.y, cellArea.width, cellArea.height);
event.x = e.x - r.x;
event.y = e.y - r.y;
return event;
}
private void setOrientationViaColumn()
{
orientation = TableColumnSWTUtils.convertColumnAlignmentToSWT(tableColumn.getAlignment());
}
public void dispose()
{
if (composite != null && !composite.isDisposed())
{
composite.removePaintListener(this);
composite.removeMouseListener(this);
composite.removeMouseMoveListener(this);
composite.removeMouseTrackListener(this);
}
if (disposeListeners != null)
{
for (Iterator iter = disposeListeners.iterator(); iter.hasNext();)
{
TableCellDisposeListener listener = (TableCellDisposeListener)iter.next();
try
{
listener.dispose(this);
}
catch (Throwable e)
{
Debug.out(e);
}
}
disposeListeners = null;
}
tableColumn.invokeCellDisposeListeners(this);
tableColumn.invalidateCells();
}
public int getCursorID()
{
return 0;
}
public String getObfusticatedText()
{
return text;
}
public TableRowCore getTableRowCore()
{
return null;
}
public boolean getVisuallyChangedSinceRefresh()
{
return true;
}
public void invalidate(boolean mustRefresh)
{
valid = false;
}
public void invokeToolTipListeners(int type)
{
if (tableColumn == null)
return;
tableColumn.invokeCellToolTipListeners(this, type);
if (tooltipListeners == null)
return;
try
{
if (type == 0)
{
for (int i = 0; i < tooltipListeners.size(); i++)
((TableCellToolTipListener)(TableCellToolTipListener)tooltipListeners.get(i)).cellHover(this);
} else
{
for (int i = 0; i < tooltipListeners.size(); i++)
((TableCellToolTipListener)(TableCellToolTipListener)tooltipListeners.get(i)).cellHoverComplete(this);
}
}
catch (Throwable e)
{
Debug.out(e);
}
}
public void invokeVisibilityListeners(int visibility, boolean invokeColumnListeners)
{
if (invokeColumnListeners)
tableColumn.invokeCellVisibilityListeners(this, visibility);
if (cellVisibilityListeners == null)
return;
for (int i = 0; i < cellVisibilityListeners.size(); i++)
try
{
TableCellVisibilityListener l = (TableCellVisibilityListener)(TableCellVisibilityListener)cellVisibilityListeners.get(i);
l.cellVisibilityChanged(this, visibility);
}
catch (Throwable e)
{
Debug.printStackTrace(e);
}
}
public boolean isMouseOver()
{
if (isDisposed())
return false;
Rectangle r = composite.getBounds();
if (cellArea != null)
r = new Rectangle(r.x + cellArea.x, r.y + cellArea.y, cellArea.width, cellArea.height);
Point ptStart = composite.toDisplay(r.x, r.y);
r.x = ptStart.x;
r.y = ptStart.y;
Point ptCursor = composite.getDisplay().getCursorLocation();
return r.contains(ptCursor);
}
public boolean isUpToDate()
{
return false;
}
public void locationChanged()
{
}
public boolean needsPainting()
{
return true;
}
public boolean refresh(boolean doGraphics)
{
return refresh();
}
public boolean refresh(boolean doGraphics, boolean rowVisible, boolean cellVisible)
{
return refresh();
}
public boolean refresh(boolean doGraphics, boolean rowVisible)
{
return refresh();
}
public void setCursorID(int i)
{
}
public void setUpToDate(boolean flag)
{
}
public int compareTo(Object arg0)
{
return 0;
}
public void setOrentation(int o)
{
orientation = o;
}
public Rectangle getCellArea()
{
return cellArea;
}
public void setCellArea(Rectangle cellArea)
{
this.cellArea = cellArea;
}
public int[] getMouseOffset()
{
if (isDisposed())
return null;
Rectangle r = composite.getBounds();
if (cellArea != null)
r = new Rectangle(r.x + cellArea.x, r.y + cellArea.y, cellArea.width, cellArea.height);
Point ptStart = composite.toDisplay(r.x, r.y);
r.x = ptStart.x;
r.y = ptStart.y;
Point ptCursor = composite.getDisplay().getCursorLocation();
if (!r.contains(ptCursor))
return null;
else
return (new int[] {
ptCursor.x - r.x, ptCursor.y - r.y
});
}
public int getMarginHeight()
{
return marginHeight;
}
public int getMarginWidth()
{
return marginWidth;
}
public void refreshAsync()
{
refresh();
}
public void redraw()
{
Utils.execSWTThread(new AERunnable() {
final FakeTableCell this$0;
public void runSupport()
{
if (!isDisposed())
composite.redraw();
}
{
this$0 = FakeTableCell.this;
super();
}
});
}
public void doPaint(GC gc)
{
doPaint(gc, cellArea != null ? cellArea : composite.getClientArea());
}
public Image getBackgroundImage()
{
return null;
}
public Color getBackgroundSWT()
{
return composite.getBackground();
}
public Rectangle getBounds()
{
return cellArea != null ? new Rectangle(cellArea.x, cellArea.y, cellArea.width, cellArea.height) : composite.getClientArea();
}
public BufferedTableItem getBufferedTableItem()
{
return null;
}
public Color getForegroundSWT()
{
return composite.getForeground();
}
public Image getGraphicSWT()
{
return null;
}
public Image getIcon()
{
return null;
}
public Point getSize()
{
Rectangle bounds = getBounds();
if (bounds == null)
return null;
else
return new Point(bounds.width, bounds.height);
}
public TableRowSWT getTableRowSWT()
{
return null;
}
public int getTextAlpha()
{
return 0;
}
public boolean setForeground(Color color)
{
return false;
}
public boolean setGraphic(Image img)
{
graphic = null;
image = img;
if (image != null)
imageBounds = image.getBounds();
if (composite != null && !composite.isDisposed())
redraw();
return true;
}
public boolean setIcon(Image img)
{
return false;
}
public void setTextAlpha(int i)
{
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -