下面列出了org.eclipse.ui.texteditor.ChainedPreferenceStore#org.eclipse.swt.graphics.Cursor 实例代码,或者点击链接到github查看源代码,也可以在右侧发表评论。
private void getFields() {
Cursor busy = new Cursor( shell.getDisplay(), SWT.CURSOR_WAIT );
shell.setCursor( busy );
try {
String sourceStepName = wSourceStep.getText();
if ( !Utils.isEmpty( sourceStepName ) ) {
String fieldName = wSourceField.getText();
RowMetaInterface r = transMeta.getStepFields( sourceStepName );
if ( r != null ) {
wSourceField.setItems( r.getFieldNames() );
}
wSourceField.setText( fieldName );
}
shell.setCursor( null );
busy.dispose();
} catch ( KettleException ke ) {
shell.setCursor( null );
busy.dispose();
new ErrorDialog(
shell, BaseMessages.getString( PKG, "ValidatorDialog.FailedToGetFields.DialogTitle" ), BaseMessages
.getString( PKG, "ValidatorDialog.FailedToGetFields.DialogMessage" ), ke );
}
}
/**
* Private constructor to avoid instantiation.
*/
private XYGraphMediaFactory() {
_colorRegistry = new ColorRegistry();
_imageRegistry = new ImageRegistry();
_fontRegistry = new FontRegistry();
cursorRegistry = new HashMap<String, Cursor>();
_imageCache = new HashMap<ImageDescriptor, Image>();
// dispose all images from the image cache, when the display is disposed
Display.getDefault().addListener(SWT.Dispose, new Listener() {
public void handleEvent(final Event event) {
for (Image img : _imageCache.values()) {
img.dispose();
}
disposeResources();
}
});
}
void refreshLabel () {
int colors = 0, cursors = 0, fonts = 0, gcs = 0, images = 0, regions = 0;
for (int i=0; i<objects.length; i++) {
Object object = objects [i];
if (object instanceof Color) colors++;
if (object instanceof Cursor) cursors++;
if (object instanceof Font) fonts++;
if (object instanceof GC) gcs++;
if (object instanceof Image) images++;
if (object instanceof Region) regions++;
}
String string = ""; //$NON-NLS-1$
if (colors != 0) string += colors + " Color(s)\n"; //$NON-NLS-1$
if (cursors != 0) string += cursors + " Cursor(s)\n"; //$NON-NLS-1$
if (fonts != 0) string += fonts + " Font(s)\n"; //$NON-NLS-1$
if (gcs != 0) string += gcs + " GC(s)\n"; //$NON-NLS-1$
if (images != 0) string += images + " Image(s)\n"; //$NON-NLS-1$
if (regions != 0) string += regions + " Region(s)\n"; //$NON-NLS-1$
if (string.length () != 0) {
string = string.substring (0, string.length () - 1);
}
label.setText (string);
}
protected Label createSwitchControl() {
Label switchControl = new Label(this, SWT.PUSH);
switchControl.setToolTipText(sectionExpanded ? HIDE_SECTION_TOOLTIP : SHOW_SECTION_TOOLTIP);
switchControl.setImage(sectionExpanded ? StatechartImages.COLLAPSE.image() : StatechartImages.EXPAND.image());
switchControl.setCursor(new Cursor(getDisplay(), SWT.CURSOR_HAND));
GridDataFactory.fillDefaults().align(SWT.FILL, SWT.CENTER).indent(-1, -1).hint(MIN_SIZE[0], MIN_SIZE[1])
.applyTo(switchControl);
mouseListener = new MouseAdapter() {
@Override
public void mouseUp(MouseEvent e) {
toggleExpandState();
}
};
switchControl.addMouseListener(mouseListener);
return switchControl;
}
/**
* Fills the given List with handles at each corner of a figure.
*
* @param part
* the handles' GraphicalEditPart
* @param handles
* the List to add the four corner handles to
* @param tracker
* the handles' DragTracker
* @param cursor
* the handles' Cursor
*/
public static void addCornerHandles( GraphicalEditPart part, List handles,
DragTracker tracker, Cursor cursor )
{
handles.add( createHandle( part,
PositionConstants.SOUTH_EAST,
tracker,
cursor ) );
handles.add( createHandle( part,
PositionConstants.SOUTH_WEST,
tracker,
cursor ) );
handles.add( createHandle( part,
PositionConstants.NORTH_WEST,
tracker,
cursor ) );
handles.add( createHandle( part,
PositionConstants.NORTH_EAST,
tracker,
cursor ) );
}
protected AlwStartPage() {
super("");
setTitle("Application Layout"); // $NLX-AlwStartPage.ApplicationLayout-1$
setMessage("Choose the configuration for this control.", IMessageProvider.INFORMATION); // $NLX-AlwStartPage.Choosetheconfigurationforthiscont-1$
// Setup the title font
_titleFont = JFaceResources.getBannerFont();
// Setup hand cursor
_handCursor = new Cursor(Display.getCurrent(), SWT.CURSOR_HAND);
// Load images - Do not have to be disposed later - plugin maintains a list
_defImage = ExtLibToolingPlugin.getImage("app_layout.jpg"); // $NON-NLS-1$
if (_showResponsiveIcon) {
_responsiveImage = NavigatorPlugin.getImage("navigatorIcons/navigatorChild.png"); // $NON-NLS-1$
} else {
_responsiveImage = null;
}
// Setup hyperlink color
_hyperlinkColor = new Color(Display.getCurrent(), 0, 0, 255);
}
private void showRecentlyUsedList() {
boolean existing = true;
if (contentRecent == null) {
existing = false;
Cursor oldCursor = getParent().getCursor();
getParent().setCursor(new Cursor(getParent().getDisplay(), SWT.CURSOR_WAIT));
try {
contentRecent = new DbTabContentRecent(DbTab.this, modeContent);
} finally {
getParent().getCursor().dispose();
getParent().setCursor(oldCursor);
}
}
contentStack.topControl = contentRecent;
modeContent.layout();
if (existing)
contentRecent.redisplayed();
}
private void showRel() {
boolean existing = true;
if (contentRel == null) {
existing = false;
Cursor oldCursor = getParent().getCursor();
getParent().setCursor(new Cursor(getParent().getDisplay(), SWT.CURSOR_WAIT));
try {
contentRel = new DbTabContentRel(DbTab.this, modeContent);
} finally {
getParent().getCursor().dispose();
getParent().setCursor(oldCursor);
}
}
contentStack.topControl = contentRel;
modeContent.layout();
if (existing)
contentRel.redisplayed();
contentRel.activateMenu();
}
private void showRev() {
boolean existing = true;
if (contentRev == null) {
existing = false;
Cursor oldCursor = getParent().getCursor();
getParent().setCursor(new Cursor(getParent().getDisplay(), SWT.CURSOR_WAIT));
try {
contentRev = new DbTabContentRev(DbTab.this, modeContent);
} finally {
getParent().getCursor().dispose();
getParent().setCursor(oldCursor);
}
}
contentStack.topControl = contentRev;
modeContent.layout();
if (existing)
contentRev.redisplayed();
}
private void showCmd() {
boolean existing = true;
if (contentCmd == null) {
existing = false;
Cursor oldCursor = getParent().getCursor();
getParent().setCursor(new Cursor(getParent().getDisplay(), SWT.CURSOR_WAIT));
try {
contentCmd = new DbTabContentCmd(DbTab.this, modeContent);
getParent().getCursor().dispose();
getParent().setCursor(oldCursor);
} catch (Exception e) {
getParent().getCursor().dispose();
getParent().setCursor(oldCursor);
e.printStackTrace();
MessageDialog.openError(Core.getShell(), "Unable to open local database",
wrapped("Unable to open command line due to error: " + e.toString()));
return;
}
}
contentStack.topControl = contentCmd;
modeContent.layout();
if (existing)
contentCmd.redisplayed();
}
/** Open a connection and associated panel. */
private boolean openConnection(String dbURL, boolean permanent, boolean canCreate) {
Cursor oldCursor = getParent().getCursor();
getParent().setCursor(new Cursor(getParent().getDisplay(), SWT.CURSOR_WAIT));
try {
setText(dbURL);
if (!DBrowser.hasLocalRel() && dbURL.startsWith("db:")) {
doConnectionResultFailed(new Throwable("Local Rel server is not installed."), dbURL);
return false;
}
connection = attemptConnectionOpen(dbURL, canCreate);
if (connection.client != null) {
doConnectionResultSuccess(connection.client, dbURL, permanent);
return true;
} else {
doConnectionResultFailed(connection.exception, dbURL);
return false;
}
} finally {
getParent().getCursor().dispose();
getParent().setCursor(oldCursor);
}
}
private void getTransforms() {
Cursor busy = new Cursor( shell.getDisplay(), SWT.CURSOR_WAIT );
shell.setCursor( busy );
String fieldTransform = wSourceTransform.getText();
wSourceTransform.removeAll();
wSourceTransform.setItems( pipelineMeta.getPrevTransformNames( transformMeta ) );
wSourceTransform.setText( fieldTransform );
shell.setCursor( null );
busy.dispose();
}
/**
* Returns a cursor that is also cached as to not create more handles for each time the cursor type is fetched.
*
* @param type Cursor Type to fetch
* @return Cursor
*/
public static Cursor getCursor(int type) {
if (map.get(new Integer(type)) != null) {
return map.get(new Integer(type));
} else {
Cursor c = new Cursor(Display.getDefault(), type);
map.put(new Integer(type), c);
return c;
}
}
/**
* Dispose all of the cached cursors.
*/
public static void disposeCursors() {
for (Cursor cursor : m_idToCursorMap.values()) {
cursor.dispose();
}
m_idToCursorMap.clear();
}
public void disposeResources() {
if (cursorRegistry != null) {
for (Cursor cursor : cursorRegistry.values()) {
if (cursor != null && !cursor.isDisposed())
cursor.dispose();
}
cursorRegistry.clear();
}
}
static Handle createHandle( GraphicalEditPart owner, int direction,
DragTracker tracker, Cursor cursor )
{
ReportResizeHandle handle = new ReportResizeHandle( owner, direction );
handle.setDragTracker( tracker );
handle.setCursor( cursor );
return handle;
}
@Override
protected Cursor getDefaultCursor( )
{
if (isCloneActive())
{
return Cursors.SIZEWE;
}
return super.getDefaultCursor( );
}
public static Cursor createCursor(Device device, ImageData imageData, int width, int height) {
try {
return Cursor.class.getConstructor(Device.class, ImageData.class, int.class, int.class).newInstance(device,
imageData, width, height);
} catch (Exception ne) {
return null;
}
}
/**
* Returns a cursor that is also cached as to not create more handles for each time the cursor type is fetched.
*
* @param type Cursor Type to fetch
* @return Cursor
*/
public static Cursor getCursor(final int type) {
if (_cache.get(new Integer(type)) == null) {
final Cursor cursor = new Cursor(Display.getDefault(), type);
_cache.put(new Integer(type), cursor); // NOPMD
return cursor;
} else {
return (Cursor) _cache.get(new Integer(type)); // NOPMD
}
}
/**
* if the drag is permitted, show the cursor.
*
* Else if a drag is occuring show it too, or show the
* no cursor.
*/
protected Cursor getDefaultCursor() {
if (isMoveValid()) {
return SharedCursors.SIZENS;
} else {
if (getState() == STATE_DRAG_IN_PROGRESS) {
return SharedCursors.SIZENS;
}
return SharedCursors.ARROW;
}
}
private void setActiveTab(final SWTSkinObjectTab newTab, final boolean evenIfSame) {
Utils.execSWTThread(new AERunnable() {
@Override
public void runSupport() {
Composite shell = skin.getShell();
Cursor cursor = shell.getCursor();
try {
shell.setCursor(shell.getDisplay().getSystemCursor(SWT.CURSOR_WAIT));
swtSetActiveTab(newTab, evenIfSame);
} finally {
shell.setCursor(cursor);
}
}
});
}
/**
* Dispose all of the cached cursors.
*/
public static void disposeCursors() {
for (Cursor cursor : m_idToCursorMap.values()) {
cursor.dispose();
}
m_idToCursorMap.clear();
}
/**
* Dispose all of the cached cursors.
*/
public static void disposeCursors() {
for (Cursor cursor : m_idToCursorMap.values()) {
cursor.dispose();
}
m_idToCursorMap.clear();
}
/**
* Dispose all of the cached cursors.
*/
public static void disposeCursors() {
for (Cursor cursor : m_idToCursorMap.values()) {
cursor.dispose();
}
m_idToCursorMap.clear();
}
/**
* if the drag is permitted, show the cursor.
*
* Else if a drag is occuring show it too, or show the
* no cursor.
*/
protected Cursor getDefaultCursor() {
if (isMoveValid()) {
return SharedCursors.SIZEWE;
} else {
if (getState() == STATE_DRAG_IN_PROGRESS) {
return SharedCursors.SIZEWE;
}
return SharedCursors.ARROW;
}
}
private void updateCursor(int x, int stateMask) {
// if Wait cursor not active, check for the need to change the cursor
if (getCursor() == fWaitCursor) {
return;
}
Cursor cursor = null;
if (fDragState == DRAG_SPLIT_LINE) {
} else if (fDragState == DRAG_SELECTION) {
cursor = fResizeCursor;
} else if (fDragState == DRAG_TRACE_ITEM) {
cursor = fDragCursor;
} else if (fDragState == DRAG_ZOOM) {
cursor = fZoomCursor;
} else if ((stateMask & SWT.MODIFIER_MASK) == SWT.CTRL) {
cursor = fDragCursor;
} else if ((stateMask & SWT.MODIFIER_MASK) == SWT.SHIFT) {
cursor = fResizeCursor;
} else if (!isOverSplitLine(x)) {
long selectionBegin = fTimeProvider.getSelectionBegin();
long selectionEnd = fTimeProvider.getSelectionEnd();
int xBegin = getXForTime(selectionBegin);
int xEnd = getXForTime(selectionEnd);
if (Math.abs(x - xBegin) < SNAP_WIDTH || Math.abs(x - xEnd) < SNAP_WIDTH) {
cursor = fResizeCursor;
}
}
if (getCursor() != cursor) {
setCursor(cursor);
}
}
/**
* Handles mouse moves.
*
* @param event the mouse move event
*/
protected void handleMouseMove(MouseEvent event) {
if (fTextViewer != null) {
int[] lines = toLineNumbers(event.y);
Position p = getAnnotationPosition(lines);
Cursor cursor = (p != null ? fHitDetectionCursor : null);
if (cursor != fLastCursor) {
fCanvas.setCursor(cursor);
fLastCursor = cursor;
}
}
}
@Test
public void getResources_Create4Cursors_CountEquals4() {
Map<String, Integer> counts = ResourceQuery.getAllocatedResourceCounts(display);
for (int i = 0; i < 4; i++) {
new Cursor(display, i);
}
Assert.assertEquals(4, ResourceQuery.getAllocatedResourceCounts(display).get(Cursor.class.getName()).intValue());
}
/**
* Dispose all of the cached cursors.
*/
public static void disposeCursors() {
for (Cursor cursor : m_idToCursorMap.values()) {
cursor.dispose();
}
m_idToCursorMap.clear();
}
/**
* Dispose all of the cached cursors.
*/
public static void disposeCursors() {
for (Cursor cursor : m_idToCursorMap.values()) {
cursor.dispose();
}
m_idToCursorMap.clear();
}