Java Code Examples for org.eclipse.swt.SWT#CURSOR_ARROW

The following examples show how to use org.eclipse.swt.SWT#CURSOR_ARROW . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: ShowHelpDialog.java    From hop with Apache License 2.0 5 votes vote down vote up
private void setImages() {
  imageBackEnabled = GuiResource.getInstance().getImageBackEnabled();
  imageBackDisabled = GuiResource.getInstance().getImageBackDisabled();
  imageForwardEnabled = GuiResource.getInstance().getImageForwardEnabled();
  imageForwardDisabled = GuiResource.getInstance().getImageForwardDisabled();
  imageRefreshEnabled = GuiResource.getInstance().getImageRefreshEnabled();
  imageRefreshDisabled = GuiResource.getInstance().getImageRefreshDisabled();
  imageHomeEnabled = GuiResource.getInstance().getImageHomeEnabled();
  imageHomeDisabled = GuiResource.getInstance().getImageHomeDisabled();
  imagePrintEnabled = GuiResource.getInstance().getImagePrintEnabled();
  imagePrintDisabled = GuiResource.getInstance().getImagePrintDisabled();
  cursorEnabled = new Cursor( display, SWT.CURSOR_HAND );
  cursorDisabled = new Cursor( display, SWT.CURSOR_ARROW );
}
 
Example 2
Source File: XLFEditor.java    From translationstudio8 with GNU General Public License v2.0 5 votes vote down vote up
@Override
public void init(IEditorSite site, IEditorInput input) throws PartInitException {
	if (LOGGER.isDebugEnabled()) {
		LOGGER.debug("init(IEditorSite site, IEditorInput input)");
	}
	setSite(site);
	setInput(input);

	// 设置Editor标题栏的显示名称,否则名称用plugin.xml中的name属性
	setPartName(input.getName());

	Image oldTitleImage = titleImage;
	if (input != null) {
		IEditorRegistry editorRegistry = PlatformUI.getWorkbench().getEditorRegistry();
		IEditorDescriptor editorDesc = editorRegistry.findEditor(getSite().getId());
		ImageDescriptor imageDesc = editorDesc != null ? editorDesc.getImageDescriptor() : null;
		titleImage = imageDesc != null ? imageDesc.createImage() : null;
	}

	setTitleImage(titleImage);
	if (oldTitleImage != null && !oldTitleImage.isDisposed()) {
		oldTitleImage.dispose();
	}

	getSite().setSelectionProvider(this);

	cursorIbeam = new Cursor(null, SWT.CURSOR_IBEAM);
	cursorArrow = new Cursor(null, SWT.CURSOR_ARROW);

	hookListener();
}
 
Example 3
Source File: XLFEditor.java    From tmxeditor8 with GNU General Public License v2.0 5 votes vote down vote up
@Override
public void init(IEditorSite site, IEditorInput input) throws PartInitException {
	if (LOGGER.isDebugEnabled()) {
		LOGGER.debug("init(IEditorSite site, IEditorInput input)");
	}
	setSite(site);
	setInput(input);

	// 设置Editor标题栏的显示名称,否则名称用plugin.xml中的name属性
	setPartName(input.getName());

	Image oldTitleImage = titleImage;
	if (input != null) {
		IEditorRegistry editorRegistry = PlatformUI.getWorkbench().getEditorRegistry();
		IEditorDescriptor editorDesc = editorRegistry.findEditor(getSite().getId());
		ImageDescriptor imageDesc = editorDesc != null ? editorDesc.getImageDescriptor() : null;
		titleImage = imageDesc != null ? imageDesc.createImage() : null;
	}

	setTitleImage(titleImage);
	if (oldTitleImage != null && !oldTitleImage.isDisposed()) {
		oldTitleImage.dispose();
	}

	getSite().setSelectionProvider(this);

	cursorIbeam = new Cursor(null, SWT.CURSOR_IBEAM);
	cursorArrow = new Cursor(null, SWT.CURSOR_ARROW);

	hookListener();
}
 
Example 4
Source File: IndexEditionControl.java    From bonita-studio with GNU General Public License v2.0 5 votes vote down vote up
public IndexEditionControl(Section parent, AbstractBdmFormPage formPage, DataBindingContext ctx,
        IObservableValue<Index> selectedIndexObservable, IObservableList<Field> actualsFieldsObservable) {
    super(parent, SWT.NONE);
    formPage.getToolkit().adapt(this);
    setLayoutData(GridDataFactory.fillDefaults().grab(true, true).create());
    setLayout(GridLayoutFactory.fillDefaults().margins(15, 10).create());

    this.formPage = formPage;
    this.selectedIndexObservable = selectedIndexObservable;
    this.actualsFieldsObservable = actualsFieldsObservable;
    this.indexableFieldFilter = new IndexableFieldFilter();
    this.fieldStyleStringProvider = new FieldStyleStringProvider();
    this.cursorHand = new Cursor(parent.getDisplay(), SWT.CURSOR_HAND);
    this.cursorArrow = new Cursor(parent.getDisplay(), SWT.CURSOR_ARROW);
    this.errorColor = new LocalResourceManager(JFaceResources.getResources(),
            parent).createColor(ColorConstants.ERROR_RGB);

    indexedFieldNameObservable = EMFObservables.observeDetailList(Realm.getDefault(), selectedIndexObservable,
            BusinessDataModelPackage.Literals.INDEX__FIELD_NAMES);
    indexedFieldsObservable = new WritableList<>();

    bindIndexedFieldObservableLists(ctx, actualsFieldsObservable);

    createLabels();

    Composite viewersComposite = formPage.getToolkit().createComposite(this);
    viewersComposite.setLayout(GridLayoutFactory.fillDefaults().extendedMargins(0, 0, 10, 0).numColumns(2).create());
    viewersComposite.setLayoutData(GridDataFactory.fillDefaults().grab(true, true).create());

    createAvailableAttributesTableViewer(viewersComposite);
    createIndexedAttributesTableViewer(viewersComposite);

    indexedFieldsObservable.addChangeListener(e -> availableAttributesTableViewer.refresh());
}
 
Example 5
Source File: SWTCursor.java    From tuxguitar with GNU Lesser General Public License v2.1 4 votes vote down vote up
public static Integer getCursorStyle(UICursor cursor) {
	if( CURSOR_MAP.containsKey(cursor) ) {
		return CURSOR_MAP.get(cursor);
	}
	return SWT.CURSOR_ARROW;
}
 
Example 6
Source File: TSWizardDialog.java    From translationstudio8 with GNU General Public License v2.0 4 votes vote down vote up
/**
 * About to start a long running operation triggered through the wizard.
 * Shows the progress monitor and disables the wizard's buttons and
 * controls.
 * 
 * @param enableCancelButton
 *            <code>true</code> if the Cancel button should be enabled,
 *            and <code>false</code> if it should be disabled
 * @return the saved UI state
 */
private Object aboutToStart(boolean enableCancelButton) {
	Map savedState = null;
	if (getShell() != null) {
		// Save focus control
		Control focusControl = getShell().getDisplay().getFocusControl();
		if (focusControl != null && focusControl.getShell() != getShell()) {
			focusControl = null;
		}
		boolean needsProgressMonitor = wizard.needsProgressMonitor();
		
		// Set the busy cursor to all shells.
		Display d = getShell().getDisplay();
		waitCursor = new Cursor(d, SWT.CURSOR_WAIT);
		setDisplayCursor(waitCursor);
		
		if (useCustomProgressMonitorPart) {
			cancelButton.removeSelectionListener(cancelListener);
			// Set the arrow cursor to the cancel component.
			arrowCursor = new Cursor(d, SWT.CURSOR_ARROW);
			cancelButton.setCursor(arrowCursor);
		}
		
		// Deactivate shell
		savedState = saveUIState(useCustomProgressMonitorPart && needsProgressMonitor && enableCancelButton);
		if (focusControl != null) {
			savedState.put(FOCUS_CONTROL, focusControl);
		}
		// Activate cancel behavior.
		if (needsProgressMonitor) {
			if (enableCancelButton || useCustomProgressMonitorPart) {
				progressMonitorPart.attachToCancelComponent(cancelButton);
			}
			progressMonitorPart.setVisible(true);
		}
		
		// Install traverse listener once in order to implement 'Enter' and 'Space' key blocking
		if (timeWhenLastJobFinished == -1) {
			timeWhenLastJobFinished= 0;
			getShell().addTraverseListener(new TraverseListener() {
				public void keyTraversed(TraverseEvent e) {
					if (e.detail == SWT.TRAVERSE_RETURN || (e.detail == SWT.TRAVERSE_MNEMONIC && e.keyCode == 32)) {
						// We want to ignore the keystroke when we detect that it has been received within the
						// delay period after the last operation has finished.  This prevents the user from accidentally
						// hitting "Enter" or "Space", intending to cancel an operation, but having it processed exactly
						// when the operation finished, thus traversing the wizard.  If there is another operation still
						// running, the UI is locked anyway so we are not in this code.  This listener should fire only
						// after the UI state is restored (which by definition means all jobs are done.
						// See https://bugs.eclipse.org/bugs/show_bug.cgi?id=287887
						if (timeWhenLastJobFinished != 0 && System.currentTimeMillis() - timeWhenLastJobFinished < RESTORE_ENTER_DELAY) {
							e.doit= false;
							return;
						}
						timeWhenLastJobFinished= 0;
					}}
			});
		}
	}
	return savedState;
}
 
Example 7
Source File: HsAbstractProgressDialog.java    From tmxeditor8 with GNU General Public License v2.0 4 votes vote down vote up
/**
 * 运行任务的准备工作
 * @return UI状态
 */
@SuppressWarnings("rawtypes")
private Object aboutToStart(boolean enableCancelButton) {
	Map savedState = null;
	if (getShell() != null) {
		// Save focus control
		Control focusControl = getShell().getDisplay().getFocusControl();
		if (focusControl != null && focusControl.getShell() != getShell()) {
			focusControl = null;
		}
		boolean needsProgressMonitor = needsProgressMonitor();

		// 设置Shell的鼠标状态
		Display d = getShell().getDisplay();
		waitCursor = new Cursor(d, SWT.CURSOR_WAIT);
		setDisplayCursor(waitCursor);

		if (useCustomProgressMonitorPart) {
			cancelButton.removeSelectionListener(cancelListener);
			// 设置取消按钮的鼠标状态
			arrowCursor = new Cursor(d, SWT.CURSOR_ARROW);
			cancelButton.setCursor(arrowCursor);
		}

		// Deactivate shell
		savedState = saveUIState(useCustomProgressMonitorPart && needsProgressMonitor && enableCancelButton);
		if (focusControl != null) {
			savedState.put(FOCUS_CONTROL, focusControl);
		}
		// Activate cancel behavior.
		if (needsProgressMonitor) {
			if (enableCancelButton || useCustomProgressMonitorPart) {
				progressMonitorPart.attachToCancelComponent(cancelButton);
			}
			progressMonitorPart.setVisible(true);
		}

		if (timeWhenLastJobFinished == -1) {
			timeWhenLastJobFinished = 0;
			// 忽略键盘事件( enter space)在最后一个任务完成之前
			getShell().addTraverseListener(new TraverseListener() {
				public void keyTraversed(TraverseEvent e) {
					if (e.detail == SWT.TRAVERSE_RETURN || (e.detail == SWT.TRAVERSE_MNEMONIC && e.keyCode == 32)) {
						if (timeWhenLastJobFinished != 0
								&& System.currentTimeMillis() - timeWhenLastJobFinished < RESTORE_ENTER_DELAY) {
							e.doit = false;
							return;
						}
						timeWhenLastJobFinished = 0;
					}
				}
			});
		}
	}
	return savedState;
}
 
Example 8
Source File: TSWizardDialog.java    From tmxeditor8 with GNU General Public License v2.0 4 votes vote down vote up
/**
 * About to start a long running operation triggered through the wizard.
 * Shows the progress monitor and disables the wizard's buttons and
 * controls.
 * 
 * @param enableCancelButton
 *            <code>true</code> if the Cancel button should be enabled,
 *            and <code>false</code> if it should be disabled
 * @return the saved UI state
 */
private Object aboutToStart(boolean enableCancelButton) {
	Map savedState = null;
	if (getShell() != null) {
		// Save focus control
		Control focusControl = getShell().getDisplay().getFocusControl();
		if (focusControl != null && focusControl.getShell() != getShell()) {
			focusControl = null;
		}
		boolean needsProgressMonitor = wizard.needsProgressMonitor();
		
		// Set the busy cursor to all shells.
		Display d = getShell().getDisplay();
		waitCursor = new Cursor(d, SWT.CURSOR_WAIT);
		setDisplayCursor(waitCursor);
		
		if (useCustomProgressMonitorPart) {
			cancelButton.removeSelectionListener(cancelListener);
			// Set the arrow cursor to the cancel component.
			arrowCursor = new Cursor(d, SWT.CURSOR_ARROW);
			cancelButton.setCursor(arrowCursor);
		}
		
		// Deactivate shell
		savedState = saveUIState(useCustomProgressMonitorPart && needsProgressMonitor && enableCancelButton);
		if (focusControl != null) {
			savedState.put(FOCUS_CONTROL, focusControl);
		}
		// Activate cancel behavior.
		if (needsProgressMonitor) {
			if (enableCancelButton || useCustomProgressMonitorPart) {
				progressMonitorPart.attachToCancelComponent(cancelButton);
			}
			progressMonitorPart.setVisible(true);
		}
		
		// Install traverse listener once in order to implement 'Enter' and 'Space' key blocking
		if (timeWhenLastJobFinished == -1) {
			timeWhenLastJobFinished= 0;
			getShell().addTraverseListener(new TraverseListener() {
				public void keyTraversed(TraverseEvent e) {
					if (e.detail == SWT.TRAVERSE_RETURN || (e.detail == SWT.TRAVERSE_MNEMONIC && e.keyCode == 32)) {
						// We want to ignore the keystroke when we detect that it has been received within the
						// delay period after the last operation has finished.  This prevents the user from accidentally
						// hitting "Enter" or "Space", intending to cancel an operation, but having it processed exactly
						// when the operation finished, thus traversing the wizard.  If there is another operation still
						// running, the UI is locked anyway so we are not in this code.  This listener should fire only
						// after the UI state is restored (which by definition means all jobs are done.
						// See https://bugs.eclipse.org/bugs/show_bug.cgi?id=287887
						if (timeWhenLastJobFinished != 0 && System.currentTimeMillis() - timeWhenLastJobFinished < RESTORE_ENTER_DELAY) {
							e.doit= false;
							return;
						}
						timeWhenLastJobFinished= 0;
					}}
			});
		}
	}
	return savedState;
}
 
Example 9
Source File: ExcelFileSelectionWizardPage.java    From birt with Eclipse Public License 1.0 4 votes vote down vote up
public void selectionChanged( SelectionChangedEvent event )
{

	String sheetName = (String) ( (IStructuredSelection) event.getSelection( ) ).getFirstElement( );

	String queryText = this.getInitializationDesign( ).getQueryText( );
	// When create a new data set, the quertText is an empty string, in this
	// condition
	// if the sheet name is equal, just return.
	// When edit a data set, we should check the sheet name is equal and the
	// file name
	// is in accordance with query text.
	if ( sheetName.equalsIgnoreCase( currentSheetName )
			&& ( queryText.trim( ).length( ) == 0 || isOldFile( queryText,
					getFileName( selectedFile ) ) ) )
	{
		return;
	}
	if ( currentSheetName != null
			&& !MessageDialog.openConfirm( worksheetsCombo.getControl( )
					.getShell( ),
					Messages.getString( "confirm.reselectWorksheetTitle" ), //$NON-NLS-1$
					Messages.getString( "confirm.reselectWorksheetMessage" ) ) ) //$NON-NLS-1$
	{
		worksheetsCombo.setSelection( new StructuredSelection( currentSheetName ) );

		return;
	}

	currentSheetName = sheetName;
	setPageComplete( false );
	selectedColumnsViewer.getTable( ).removeAll( );
	savedSelectedColumnsInfoList.clear( );
	availableList.removeAll( );

	if ( this.getShell( ) != null )
	{
		Cursor waitCursor = new Cursor( this.getShell( ).getDisplay( ),
				SWT.CURSOR_WAIT );
		this.getControl( ).setCursor( waitCursor );
	}

	String fileName = getFileName( selectedFile );
	String[] columnNames = getFileColumnNames( selectedFile );

	if ( columnNames != null && columnNames.length != 0 )
	{
		enableListAndViewer( );
		availableList.setItems( columnNames );
		availableList.select( 0 );
		btnAdd.setEnabled( true );
		btnRemove.setEnabled( false );
		btnMoveUp.setEnabled( false );
		btnMoveDown.setEnabled( false );
		if ( !( fileName.endsWith( ExcelODAConstants.XLS_FORMAT ) || fileName.endsWith( ExcelODAConstants.XLSX_FORMAT ) ) )
		{
			setMessage( Messages.getString( "warning.fileExtensionInvalid" ), //$NON-NLS-1$
					WARNING );
		}
		else
		{
			if ( selectedColumnsViewer.getTable( ).getItemCount( ) == 0 )
			{
				setMessage( getEmptyColumnErrMsg( ), ERROR );
			}
			else
			{
				setMessage( DEFAULT_MESSAGE );
			}
		}

	}

	// reset cursor back to normal state
	if ( this.getShell( ) != null )
	{
		Cursor normalCursor = new Cursor( this.getShell( ).getDisplay( ),
				SWT.CURSOR_ARROW );
		this.getControl( ).setCursor( normalCursor );
	}

}