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

The following examples show how to use org.eclipse.swt.SWT#CURSOR_WAIT . These examples are extracted from open source projects. 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 Project: hop   File: ValidatorDialog.java    License: Apache License 2.0 6 votes vote down vote up
private void getFields() {
  Cursor busy = new Cursor( shell.getDisplay(), SWT.CURSOR_WAIT );
  shell.setCursor( busy );

  try {
    String sourceTransformName = wSourceTransform.getText();
    if ( !Utils.isEmpty( sourceTransformName ) ) {
      String fieldName = wSourceField.getText();
      IRowMeta r = pipelineMeta.getTransformFields( sourceTransformName );
      if ( r != null ) {
        wSourceField.setItems( r.getFieldNames() );
      }
      wSourceField.setText( fieldName );
    }
    shell.setCursor( null );
    busy.dispose();
  } catch ( HopException ke ) {
    shell.setCursor( null );
    busy.dispose();
    new ErrorDialog(
      shell, BaseMessages.getString( PKG, "ValidatorDialog.FailedToGetFields.DialogTitle" ), BaseMessages
      .getString( PKG, "ValidatorDialog.FailedToGetFields.DialogMessage" ), ke );
  }
}
 
Example 2
Source Project: pentaho-kettle   File: ValidatorDialog.java    License: Apache License 2.0 6 votes vote down vote up
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 );
  }
}
 
Example 3
Source Project: hop   File: ValidatorDialog.java    License: Apache License 2.0 5 votes vote down vote up
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();
}
 
Example 4
Source Project: pentaho-kettle   File: ValidatorDialog.java    License: Apache License 2.0 5 votes vote down vote up
private void getSteps() {
  Cursor busy = new Cursor( shell.getDisplay(), SWT.CURSOR_WAIT );
  shell.setCursor( busy );

  String fieldStep = wSourceStep.getText();

  wSourceStep.removeAll();
  wSourceStep.setItems( transMeta.getPrevStepNames( stepMeta ) );

  wSourceStep.setText( fieldStep );

  shell.setCursor( null );
  busy.dispose();
}
 
Example 5
private String[] getModuleFields() throws KettleException {
  if ( moduleFields != null ) {
    return moduleFields;
  } else if ( skipFetchModules() || Utils.isEmpty( wModule.getText() ) ) {
    getModulesListError = false;
    return new String[0];
  }

  getModulesListError = true;
  SalesforceUpsertMeta meta = new SalesforceUpsertMeta();
  getInfo( meta );
  String url = transMeta.environmentSubstitute( meta.getTargetURL() );
  String selectedModule = transMeta.environmentSubstitute( meta.getModule() );
  // Define a new Salesforce connection
  SalesforceConnection connection =
    new SalesforceConnection( log, url, transMeta.environmentSubstitute( meta.getUsername() ),
            Utils.resolvePassword( transMeta, meta.getPassword() ) );
  int realTimeOut = Const.toInt( transMeta.environmentSubstitute( meta.getTimeout() ), 0 );
  connection.setTimeOut( realTimeOut );
  Cursor busy = new Cursor( shell.getDisplay(), SWT.CURSOR_WAIT );
  try {
    shell.setCursor( busy );

    // connect to Salesforce
    connection.connect();
    moduleFields = connection.getFields( selectedModule, excludeNonUpdatableFields );
    getModulesListError = false;
    return moduleFields;
  } finally {
    if ( connection != null ) {
      try {
        connection.close();
      } catch ( Exception e ) { /* Ignore */
      }
    }
    shell.setCursor( null );
    busy.dispose();
  }
}
 
Example 6
Source Project: kettle-beam   File: BeamJobConfigDialog.java    License: Apache License 2.0 4 votes vote down vote up
private void buildFatJar( Event event ) {
  try {
    VariableSpace space = Variables.getADefaultVariableSpace();

    BeamJobConfig jobConfig = new BeamJobConfig();
    getInfo( jobConfig );

    FileDialog dialog = new FileDialog( shell, SWT.SAVE );
    dialog.setText( "Select the location of the Kettle+Beam+Plugins fat jar" );
    dialog.setFilterNames( new String[] { "Jar files (*.jar)", "All Files (*.*)" } );
    dialog.setFilterExtensions( new String[] { "*.jar", "*.*" } ); // Windows
    if ( StringUtils.isNotEmpty( jobConfig.getFatJar() ) ) {
      dialog.setFileName( space.environmentSubstitute( jobConfig.getFatJar() ) );
    }
    String filename = dialog.open();
    if ( StringUtils.isEmpty( filename ) ) {
      return;
    }

    List<String> files = BeamConst.findLibraryFilesToStage( null, jobConfig.getPluginsToStage(), true, true );
    files.removeIf( s -> s.contains( "commons-logging" ) || s.startsWith( "log4j" ) || s.contains( "xml-apis" ) );

    // Find the plugin classes for the specified plugins...
    //
    String stepPluginClasses = findPluginClasses( Step.class.getName() );
    if (StringUtils.isNotEmpty(jobConfig.getStepPluginClasses())) {
      if (StringUtils.isEmpty( stepPluginClasses )) {
        stepPluginClasses="";
      } else {
        stepPluginClasses+=",";
      }
      stepPluginClasses+=jobConfig.getStepPluginClasses();
    }
    String xpPluginClasses = findPluginClasses( ExtensionPoint.class.getName() );
    if (StringUtils.isNotEmpty(jobConfig.getXpPluginClasses())) {
      if (StringUtils.isEmpty( xpPluginClasses )) {
        xpPluginClasses="";
      } else {
        xpPluginClasses+=",";
      }
      xpPluginClasses+=jobConfig.getStepPluginClasses();
    }


    FatJarBuilder fatJarBuilder = new FatJarBuilder( filename, files );
    fatJarBuilder.setExtraStepPluginClasses( stepPluginClasses );
    fatJarBuilder.setExtraXpPluginClasses( xpPluginClasses );
    Cursor waitCursor = new Cursor( shell.getDisplay(), SWT.CURSOR_WAIT );
    Cursor regularCursor = shell.getCursor();

    try {
      shell.setCursor( waitCursor );
      fatJarBuilder.buildTargetJar();
    } finally {
      shell.setCursor( regularCursor );
      waitCursor.dispose();
    }

    // All went well, insert the filename...
    //
    wFatJar.setText( filename );

  } catch ( Exception e ) {
    new ErrorDialog( shell, "Error", "Error building fat jar: " + e.getMessage(), e );
  }
}
 
Example 7
public void createControl(Composite parent) {
  this.busyCursor = new Cursor(parent.getDisplay(), SWT.CURSOR_WAIT);
  this.handCursor = new Cursor(parent.getDisplay(), SWT.CURSOR_HAND);

  this.showComments = store.getBoolean(ISVNUIConstants.PREF_SHOW_COMMENTS);
  this.wrapCommentsText = store.getBoolean(ISVNUIConstants.PREF_WRAP_COMMENTS);
  this.showAffectedPaths = store.getBoolean(ISVNUIConstants.PREF_SHOW_PATHS);

  this.svnHistoryPageControl = new SashForm(parent, SWT.VERTICAL);
  this.svnHistoryPageControl.setLayoutData(new GridData(GridData.FILL_BOTH));

  this.toggleAffectedPathsModeActions = new ToggleAffectedPathsOptionAction[] {
      new ToggleAffectedPathsOptionAction(this, "HistoryView.affectedPathsTableLayout",  //$NON-NLS-1$
          ISVNUIConstants.IMG_AFFECTED_PATHS_TABLE_MODE, 
          ISVNUIConstants.PREF_AFFECTED_PATHS_MODE, 
          ISVNUIConstants.MODE_FLAT),
      new ToggleAffectedPathsOptionAction(this, "HistoryView.affectedPathsFlatLayout",  //$NON-NLS-1$
          ISVNUIConstants.IMG_AFFECTED_PATHS_FLAT_MODE, 
          ISVNUIConstants.PREF_AFFECTED_PATHS_MODE, 
          ISVNUIConstants.MODE_FLAT2),
      new ToggleAffectedPathsOptionAction(this, "HistoryView.affectedPathsCompressedLayout",  //$NON-NLS-1$
          ISVNUIConstants.IMG_AFFECTED_PATHS_COMPRESSED_MODE, 
          ISVNUIConstants.PREF_AFFECTED_PATHS_MODE, 
          ISVNUIConstants.MODE_COMPRESSED),
    };
  
  this.toggleAffectedPathsLayoutActions = new ToggleAffectedPathsOptionAction[] {
      new ToggleAffectedPathsOptionAction(this, "HistoryView.affectedPathsHorizontalLayout",  //$NON-NLS-1$
          ISVNUIConstants.IMG_AFFECTED_PATHS_HORIZONTAL_LAYOUT, 
          ISVNUIConstants.PREF_AFFECTED_PATHS_LAYOUT, 
          ISVNUIConstants.LAYOUT_HORIZONTAL),
      new ToggleAffectedPathsOptionAction(this, "HistoryView.affectedPathsVerticalLayout",  //$NON-NLS-1$
          ISVNUIConstants.IMG_AFFECTED_PATHS_VERTICAL_LAYOUT, 
          ISVNUIConstants.PREF_AFFECTED_PATHS_LAYOUT, 
          ISVNUIConstants.LAYOUT_VERTICAL),
    };
  
  createTableHistory(svnHistoryPageControl);
  createAffectedPathsViewer();
  contributeActions();

  svnHistoryPageControl.setWeights(new int[] { 70, 30});

  // set F1 help
  // PlatformUI.getWorkbench().getHelpSystem().setHelp(svnHistoryPageControl,
  // IHelpContextIds.RESOURCE_HISTORY_VIEW);
  // initDragAndDrop();

  // add listener for editor page activation - this is to support editor
  // linking
  // getSite().getPage().addPartListener(partListener);
  // getSite().getPage().addPartListener(partListener2);
}
 
Example 8
/**
 * 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
/**
 * 运行任务的准备工作
 * @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 10
/**
 * 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 11
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 );
	}

}