Java Code Examples for org.eclipse.swt.widgets.TreeItem#setBackground()

The following examples show how to use org.eclipse.swt.widgets.TreeItem#setBackground() . 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: StandardChartDataSheet.java    From birt with Eclipse Public License 1.0 6 votes vote down vote up
private void refreshTreeViewColor( )
{
	if ( treeViewer == null )
	{
		return;
	}

	Collection<TreeItem> items = getAllItems( treeViewer.getTree( ) );

	for ( TreeItem item : items )
	{
		String key = getBindingNameFrom( item );
		Color color = ColorPalette.getInstance( ).getColor( key );
		item.setBackground( color );
	}
	treeViewer.refresh( );
}
 
Example 2
Source File: KeysPreferencePage.java    From translationstudio8 with GNU General Public License v2.0 5 votes vote down vote up
private void changeBackground() {
	for (TreeItem item : viewer.getTree().getItems()) {
		BindingElement element = (BindingElement) item.getData();
		if (element.getConflict()) {
			item.setBackground(Display.getDefault().getSystemColor(SWT.COLOR_RED));
		} else {
			item.setBackground(null);
		}
	}
}
 
Example 3
Source File: KeysPreferencePage.java    From tmxeditor8 with GNU General Public License v2.0 5 votes vote down vote up
private void changeBackground() {
	for (TreeItem item : viewer.getTree().getItems()) {
		BindingElement element = (BindingElement) item.getData();
		if (element.getConflict()) {
			item.setBackground(Display.getDefault().getSystemColor(SWT.COLOR_RED));
		} else {
			item.setBackground(null);
		}
	}
}
 
Example 4
Source File: KeysPreferencePage.java    From tmxeditor8 with GNU General Public License v2.0 5 votes vote down vote up
private void changeBackground() {
	for (TreeItem item : viewer.getTree().getItems()) {
		BindingElement element = (BindingElement) item.getData();
		if (element.getConflict()) {
			item.setBackground(Display.getDefault().getSystemColor(SWT.COLOR_RED));
		} else {
			item.setBackground(null);
		}
	}
}
 
Example 5
Source File: BTEditor.java    From jbt with Apache License 2.0 5 votes vote down vote up
/**
 * Highlights with an error color the node <code>node</code>.
 */
private void setErrorColor(BTNode node) {
	TreeItem item = findNode(this.viewer.getTree().getTopItem(), node);
	if (item != null) {
		item.setBackground(ERROR_COLOR);
	}
}
 
Example 6
Source File: BTEditor.java    From jbt with Apache License 2.0 5 votes vote down vote up
/**
 * Clears the error color from all the nodes of the tree whose root element
 * is <code>item</code>.
 */
private void internalClearErrorColors(TreeItem item) {
	item.setBackground(null);
	for (TreeItem child : item.getItems()) {
		internalClearErrorColors(child);
	}
}
 
Example 7
Source File: TreeManager.java    From pentaho-kettle with Apache License 2.0 5 votes vote down vote up
private void populateTreeItem( TreeItem childTreeItem, TreeNode treeNode ) {
  childTreeItem.setText( treeNode.getLabel() != null ? treeNode.getLabel() : "" );
  childTreeItem.setImage( treeNode.getImage() );
  childTreeItem.setData( treeNode.getData() );
  childTreeItem.setForeground( treeNode.getForeground() );
  childTreeItem.setBackground( treeNode.getBackground() );
  childTreeItem.setFont( treeNode.getFont() );
  treeNode.getData().forEach( childTreeItem::setData );
  treeNodeItemMap.put( treeNode, childTreeItem );
}
 
Example 8
Source File: HopGuiWorkflowGridDelegate.java    From hop with Apache License 2.0 4 votes vote down vote up
private void addTrackerToTree( WorkflowTracker workflowTracker, TreeItem parentItem ) {
  try {
    if ( workflowTracker != null ) {
      TreeItem treeItem = new TreeItem( parentItem, SWT.NONE );
      if ( nrRow % 2 != 0 ) {
        treeItem.setBackground( GuiResource.getInstance().getColorBlueCustomGrid() );
      }
      nrRow++;
      if ( workflowTracker.nrWorkflowTrackers() > 0 ) {
        // This is a sub-workflow: display the name at the top of the list...
        treeItem.setText( 0, BaseMessages.getString( PKG, "WorkflowLog.Tree.WorkflowPrefix" ) + workflowTracker.getWorkflowName() );

        // then populate the sub-actions ...
        for ( int i = 0; i < workflowTracker.nrWorkflowTrackers(); i++ ) {
          addTrackerToTree( workflowTracker.getWorkflowTracker( i ), treeItem );
        }
      } else {
        ActionResult result = workflowTracker.getActionResult();
        if ( result != null ) {
          String jobEntryName = result.getActionName();
          if ( !Utils.isEmpty( jobEntryName ) ) {
            treeItem.setText( 0, jobEntryName );
            treeItem.setText( 4, Const.NVL( result.getActionFilename(), "" ) );
          } else {
            treeItem.setText( 0, BaseMessages.getString( PKG, "WorkflowLog.Tree.WorkflowPrefix2" )
              + workflowTracker.getWorkflowName() );
          }
          String comment = result.getComment();
          if ( comment != null ) {
            treeItem.setText( 1, comment );
          }
          Result res = result.getResult();
          if ( res != null ) {
            treeItem.setText( 2, res.getResult()
              ? BaseMessages.getString( PKG, "WorkflowLog.Tree.Success" ) : BaseMessages.getString(
              PKG, "WorkflowLog.Tree.Failure" ) );
            treeItem.setText( 5, Long.toString( res.getEntryNr() ) );
            if ( res.getResult() ) {
              treeItem.setForeground( GuiResource.getInstance().getColorSuccessGreen() );
            } else {
              treeItem.setForeground( GuiResource.getInstance().getColorRed() );
            }
          }
          String reason = result.getReason();
          if ( reason != null ) {
            treeItem.setText( 3, reason );
          }
          Date logDate = result.getLogDate();
          if ( logDate != null ) {
            treeItem.setText( 6, new SimpleDateFormat( "yyyy/MM/dd HH:mm:ss" ).format( logDate ) );
          }
        }
      }
      treeItem.setExpanded( true );
    }
  } catch ( Exception e ) {
    workflowGraph.getLogChannel().logError( Const.getStackTracker( e ) );
  }
}
 
Example 9
Source File: JobGridDelegate.java    From pentaho-kettle with Apache License 2.0 4 votes vote down vote up
private void addTrackerToTree( JobTracker jobTracker, TreeItem parentItem ) {
  try {
    if ( jobTracker != null ) {
      TreeItem treeItem = new TreeItem( parentItem, SWT.NONE );
      if ( nrRow % 2 != 0 ) {
        treeItem.setBackground( GUIResource.getInstance().getColorBlueCustomGrid() );
      }
      nrRow++;
      if ( jobTracker.nrJobTrackers() > 0 ) {
        // This is a sub-job: display the name at the top of the list...
        treeItem.setText( 0, BaseMessages.getString( PKG, "JobLog.Tree.JobPrefix" ) + jobTracker.getJobName() );

        // then populate the sub-job entries ...
        for ( int i = 0; i < jobTracker.nrJobTrackers(); i++ ) {
          addTrackerToTree( jobTracker.getJobTracker( i ), treeItem );
        }
      } else {
        JobEntryResult result = jobTracker.getJobEntryResult();
        if ( result != null ) {
          String jobEntryName = result.getJobEntryName();
          if ( !Utils.isEmpty( jobEntryName ) ) {
            treeItem.setText( 0, jobEntryName );
            treeItem.setText( 4, Const.NVL( result.getJobEntryFilename(), "" ) );
          } else {
            treeItem.setText( 0, BaseMessages.getString( PKG, "JobLog.Tree.JobPrefix2" )
              + jobTracker.getJobName() );
          }
          String comment = result.getComment();
          if ( comment != null ) {
            treeItem.setText( 1, comment );
          }
          Result res = result.getResult();
          if ( res != null ) {
            treeItem.setText( 2, res.getResult()
              ? BaseMessages.getString( PKG, "JobLog.Tree.Success" ) : BaseMessages.getString(
                PKG, "JobLog.Tree.Failure" ) );
            treeItem.setText( 5, Long.toString( res.getEntryNr() ) );
            if ( res.getResult() ) {
              treeItem.setForeground( GUIResource.getInstance().getColorSuccessGreen() );
            } else {
              treeItem.setForeground( GUIResource.getInstance().getColorRed() );
            }
          }
          String reason = result.getReason();
          if ( reason != null ) {
            treeItem.setText( 3, reason );
          }
          Date logDate = result.getLogDate();
          if ( logDate != null ) {
            treeItem.setText( 6, new SimpleDateFormat( "yyyy/MM/dd HH:mm:ss" ).format( logDate ) );
          }
        }
      }
      treeItem.setExpanded( true );
    }
  } catch ( Exception e ) {
    log.logError( Const.getStackTracker( e ) );
  }
}