org.eclipse.swt.widgets.TableItem Java Examples

The following examples show how to use org.eclipse.swt.widgets.TableItem. 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: OraBulkLoaderDialog.java    From pentaho-kettle with Apache License 2.0 6 votes vote down vote up
private void getUpdate() {
  try {
    RowMetaInterface r = transMeta.getPrevStepFields( stepname );
    if ( r != null ) {
      TableItemInsertListener listener = new TableItemInsertListener() {
        public boolean tableItemInserted( TableItem tableItem, ValueMetaInterface v ) {
          if ( v.getType() == ValueMetaInterface.TYPE_DATE ) {
            // The default is date mask.
            tableItem.setText( 3, BaseMessages.getString( PKG, "OraBulkLoaderDialog.DateMask.Label" ) );
          } else {
            tableItem.setText( 3, "" );
          }
          return true;
        }
      };
      BaseStepDialog.getFieldsFromPrevious( r, wReturn, 1, new int[] { 1, 2 }, new int[] {}, -1, -1, listener );
    }
  } catch ( KettleException ke ) {
    new ErrorDialog(
      shell, BaseMessages.getString( PKG, "OraBulkLoaderDialog.FailedToGetFields.DialogTitle" ), BaseMessages
        .getString( PKG, "OraBulkLoaderDialog.FailedToGetFields.DialogMessage" ), ke );
  }
}
 
Example #2
Source File: SwitchCaseDialog.java    From hop with Apache License 2.0 6 votes vote down vote up
/**
 * Copy information from the meta-data input to the dialog fields.
 */
public void getData() {
  wFieldName.setText( Const.NVL( input.getFieldname(), "" ) );
  wContains.setSelection( input.isContains() );
  wDataType.setText( ValueMetaBase.getTypeDesc( input.getCaseValueType() ) );
  wDecimalSymbol.setText( Const.NVL( input.getCaseValueDecimal(), "" ) );
  wGroupingSymbol.setText( Const.NVL( input.getCaseValueGroup(), "" ) );
  wConversionMask.setText( Const.NVL( input.getCaseValueFormat(), "" ) );

  for ( int i = 0; i < input.getCaseTargets().size(); i++ ) {
    TableItem item = wValues.table.getItem( i );
    SwitchCaseTarget target = input.getCaseTargets().get( i );
    if ( target != null ) {
      item.setText( 1, Const.NVL( target.caseValue, "" ) ); // The value
      item.setText( 2, target.caseTargetTransform == null ? "" : target.caseTargetTransform.getName() ); // The target transform name
    }
  }
  wValues.removeEmptyRows();
  wValues.setRowNums();
  wValues.optWidth( true );

  wDefaultTarget.setText( input.getDefaultTargetTransform() == null ? "" : input.getDefaultTargetTransform().getName() );

  wTransformName.selectAll();
  wTransformName.setFocus();
}
 
Example #3
Source File: TransDialog.java    From pentaho-kettle with Apache License 2.0 6 votes vote down vote up
private void getTransLogTableOptions() {

    if ( previousLogTableIndex == LOG_INDEX_TRANS ) {
      // The connection...
      //
      transLogTable.setConnectionName( wLogconnection.getText() );
      transLogTable.setSchemaName( wLogSchema.getText() );
      transLogTable.setTableName( wLogTable.getText() );
      transLogTable.setLogInterval( wLogInterval.getText() );
      transLogTable.setLogSizeLimit( wLogSizeLimit.getText() );
      transLogTable.setTimeoutInDays( wLogTimeout.getText() );

      for ( int i = 0; i < transLogTable.getFields().size(); i++ ) {
        TableItem item = wOptionFields.table.getItem( i );

        LogTableField field = transLogTable.getFields().get( i );
        field.setEnabled( item.getChecked() );
        field.setFieldName( item.getText( 1 ) );
        if ( field.isSubjectAllowed() ) {
          field.setSubject( transMeta.findStep( item.getText( 2 ) ) );
        }
      }
    }
  }
 
Example #4
Source File: RegistryManagementComposite.java    From codewind-eclipse with Eclipse Public License 2.0 6 votes vote down vote up
private void createItems() {
	// Create the items for the table.
	regTable.removeAll();
	for (RegEntry regEntry : regEntries) {
		TableItem item = new TableItem(regTable, SWT.NONE);
		item.setData(regEntry);
		
		item.setText(0, regEntry.address);
		item.setText(1, regEntry.username);
		
		if (supportsPushReg) {
			item.setText(2, regEntry.namespace == null ? "" : regEntry.namespace); //$NON-NLS-1$
			item.setForeground(2, regEntry.isPushReg ? item.getForeground() : getGray(item));
			if (regEntry.isPushReg) {
				item.setText(3, Messages.RegMgmtPushRegSet);
			}
		}
	}
}
 
Example #5
Source File: RelationByExistingColumnsDialog.java    From ermaster-b with Apache License 2.0 6 votes vote down vote up
private void column2TableItem(NormalColumn referencedColumn) {
	TableItem tableItem = new TableItem(this.comparisonTable, SWT.NONE);

	tableItem.setText(0, Format.null2blank(referencedColumn
			.getLogicalName()));

	List<NormalColumn> foreignKeyList = this.referencedMap
			.get(referencedColumn.getRootReferencedColumn());

	TableEditor tableEditor = new TableEditor(this.comparisonTable);
	tableEditor.grabHorizontal = true;

	tableEditor.setEditor(this.createForeignKeyCombo(foreignKeyList),
			tableItem, 1);
	this.tableEditorList.add(tableEditor);
	this.editorReferencedMap.put(tableEditor, foreignKeyList);
}
 
Example #6
Source File: JobDialog.java    From pentaho-kettle with Apache License 2.0 6 votes vote down vote up
private void getJobLogTableOptions( JobLogTable jobLogTable ) {

    // The connection...
    //
    jobLogTable.setConnectionName( wLogconnection.getText() );
    jobLogTable.setSchemaName( wLogSchema.getText() );
    jobLogTable.setTableName( wLogTable.getText() );
    jobLogTable.setLogInterval( wLogInterval.getText() );
    jobLogTable.setLogSizeLimit( wLogSizeLimit.getText() );
    jobLogTable.setTimeoutInDays( wLogTimeout.getText() );

    for ( int i = 0; i < jobLogTable.getFields().size(); i++ ) {
      TableItem item = wOptionFields.table.getItem( i );

      LogTableField field = jobLogTable.getFields().get( i );
      field.setEnabled( item.getChecked() );
      field.setFieldName( item.getText( 1 ) );
    }
  }
 
Example #7
Source File: FileDefinitionDialog.java    From hop with Apache License 2.0 6 votes vote down vote up
public void getData() {
  wName.setText( Const.NVL( fileDefinition.getName(), "" ) );
  wDescription.setText( Const.NVL( fileDefinition.getDescription(), "" ) );
  wSeparator.setText( Const.NVL( fileDefinition.getSeparator(), "" ) );
  wEnclosure.setText( Const.NVL( fileDefinition.getEnclosure(), "" ) );

  List<FieldDefinition> fields = fileDefinition.getFieldDefinitions();
  for (int i=0;i<fields.size();i++) {
    FieldDefinition field = fields.get( i );
    TableItem item = wFields.table.getItem( i );
    item.setText(1, Const.NVL(field.getName(), ""));
    item.setText(2, Const.NVL(field.getHopType(), ""));
    item.setText(3, Const.NVL(field.getFormatMask(), ""));
    item.setText(4, field.getLength()<0 ? "" : Integer.toString(field.getLength()));
    item.setText(5, field.getPrecision()<0 ? "" : Integer.toString(field.getPrecision()));
  }

  wName.selectAll();
  wName.setFocus();
}
 
Example #8
Source File: TransExecutionConfigurationDialog.java    From pentaho-kettle with Apache License 2.0 6 votes vote down vote up
private void getVariablesData() {
  wVariables.clearAll( false );
  List<String> variableNames = new ArrayList<String>( configuration.getVariables().keySet() );
  Collections.sort( variableNames );

  for ( int i = 0; i < variableNames.size(); i++ ) {
    String variableName = variableNames.get( i );
    String variableValue = configuration.getVariables().get( variableName );

    if ( Const.indexOfString( variableName, abstractMeta.listParameters() ) < 0 ) {

      TableItem tableItem = new TableItem( wVariables.table, SWT.NONE );
      tableItem.setText( 1, variableName );
      tableItem.setText( 2, Const.NVL( variableValue, "" ) );
    }
  }
  wVariables.removeEmptyRows();
  wVariables.setRowNums();
  wVariables.optWidth( true );
}
 
Example #9
Source File: Neo4JOutputDialog.java    From knowbi-pentaho-pdi-neo4j-output with Apache License 2.0 6 votes vote down vote up
public static boolean getPropertyNameTypePrimary( TableItem item, ValueMetaInterface valueMeta, int[] nameColumns, int[] typeColumns, int primaryColumn ) {

    for ( int nameColumn : nameColumns ) {
      // Initcap the names in there, remove spaces and weird characters, lowercase first character
      // Issue #13
      //   Text Area 1 --> textArea1
      //   My_Silly_Column --> mySillyColumn
      //
      String propertyName = Neo4jUtil.standardizePropertyName( valueMeta );

      item.setText( nameColumn, propertyName );
    }

    for ( int typeColumn : typeColumns ) {
      GraphPropertyType type = GraphPropertyType.getTypeFromKettle( valueMeta );
      item.setText( typeColumn, type.name() );
    }

    if ( primaryColumn > 0 ) {
      item.setText( primaryColumn, "N" );
    }

    return true;
  }
 
Example #10
Source File: PipelineRunConfigurationDialog.java    From hop with Apache License 2.0 6 votes vote down vote up
/**
 * Copy data from the metadata into the dialog.
 */
private void getData() {

  wName.setText( Const.NVL( workingConfiguration.getName(), "" ) );
  wDescription.setText( Const.NVL( workingConfiguration.getDescription(), "" ) );
  if ( workingConfiguration.getEngineRunConfiguration() != null ) {
    wPluginType.setText( Const.NVL( workingConfiguration.getEngineRunConfiguration().getEnginePluginName(), "" ) );
    guiCompositeWidgets.setWidgetsContents( workingConfiguration.getEngineRunConfiguration(), wPluginSpecificComp,
      PipelineRunConfiguration.GUI_PLUGIN_ELEMENT_PARENT_ID );
  } else {
    wPluginType.setText( "" );
  }

  for ( int i = 0; i < workingConfiguration.getConfigurationVariables().size(); i++ ) {
    VariableValueDescription vvd = workingConfiguration.getConfigurationVariables().get( i );
    TableItem item = wVariables.table.getItem( i );
    int col = 1;
    item.setText( col++, Const.NVL( vvd.getName(), "" ) );
    item.setText( col++, Const.NVL( vvd.getValue(), "" ) );
    item.setText( col++, Const.NVL( vvd.getDescription(), "" ) );
  }
  wVariables.setRowNums();
  wVariables.optWidth( true );
}
 
Example #11
Source File: ParameterRedefTable.java    From olca-app with Mozilla Public License 2.0 6 votes vote down vote up
public void bindActions(Section section) {
	Action add = Actions.onAdd(this::add);
	Action remove = Actions.onRemove(this::remove);
	Action copy = TableClipboard.onCopy(table);
	Action paste = TableClipboard.onPaste(table, this::onPaste);
	Action usage = Actions.create(M.Usage, Icon.LINK.descriptor(), () -> {
		ParameterRedef redef = Viewers.getFirstSelected(table);
		if (redef != null) {
			ParameterUsagePage.show(redef.name);
		}
	});
	CommentAction.bindTo(section, "parameterRedefs",
			editor.getComments(), add, remove);
	Actions.bind(table, add, remove, copy, paste, usage);
	Tables.onDeletePressed(table, (e) -> remove());
	Tables.onDoubleClick(table, (event) -> {
		TableItem item = Tables.getItem(table, event);
		if (item == null)
			add();
	});
}
 
Example #12
Source File: BeamConsumeDialog.java    From kettle-beam with Apache License 2.0 6 votes vote down vote up
private void getInfo( BeamConsumeMeta in ) {
  stepname = wStepname.getText(); // return value

  in.setBootstrapServers( wBootstrapServers.getText() );
  in.setTopics( wTopics.getText() );
  in.setKeyField( wKeyField.getText() );
  in.setMessageField( wMessageField.getText() );
  in.setGroupId( wGroupId.getText() );

  in.setUsingProcessingTime( wUseProcessingTime.getSelection() );
  in.setUsingLogAppendTime( wUseLogAppendTime.getSelection() );
  in.setUsingCreateTime( wUseCreateTime.getSelection() );
  in.setRestrictedToCommitted( wRestrictToCommitted.getSelection() );
  in.setAllowingCommitOnConsumedOffset( wAllowCommitConsumed.getSelection() );
  int nr = wConfigOptions.nrNonEmpty();
  in.getConfigOptions().clear();
  for (int i=0;i<nr;i++) {
    TableItem item = wConfigOptions.getNonEmpty( i );
    String parameter = item.getText( 1 );
    String value = item.getText( 2 );
    ConfigOption.Type type = ConfigOption.Type.getTypeFromName( item.getText( 3 ) );
    in.getConfigOptions().add(new ConfigOption(parameter, value, type));
  }

  input.setChanged();
}
 
Example #13
Source File: ActionFilesExistDialog.java    From hop with Apache License 2.0 6 votes vote down vote up
/**
 * Copy information from the meta-data input to the dialog fields.
 */
public void getData() {
  if ( action.getName() != null ) {
    wName.setText( action.getName() );
  }

  if ( action.getArguments() != null ) {
    for ( int i = 0; i < action.getArguments().length; i++ ) {
      TableItem ti = wFields.table.getItem( i );
      if ( action.getArguments()[ i ] != null ) {
        ti.setText( 1, action.getArguments()[ i ] );
      }
    }
    wFields.setRowNums();
    wFields.optWidth( true );
  }

  if ( action.getFilename() != null ) {
    wFilename.setText( action.getFilename() );
  }

  wName.selectAll();
  wName.setFocus();
}
 
Example #14
Source File: StarModelDialog.java    From pentaho-kettle with Apache License 2.0 6 votes vote down vote up
private void addLogicalColumnToFactAttributesList(LogicalColumn column) {
  TableItem item = new TableItem(wFactAttributes.table, SWT.NONE);

  //  name, description, physical column name, data type, length, precision, source db, source table, source column, conversion remarks
  //
  int col=1;
  item.setText(col++, Const.NVL(ConceptUtil.getName(column,locale), ""));
  item.setText(col++, Const.NVL(ConceptUtil.getDescription(column, locale), ""));
  item.setText(col++, ConceptUtil.getAttributeType(column).name());
  item.setText(col++, Const.NVL((String)column.getProperty(DefaultIDs.LOGICAL_COLUMN_PHYSICAL_COLUMN_NAME), ""));
  DataType dataType = (DataType) column.getProperty(DefaultPropertyID.DATA_TYPE.getId());
  item.setText(col++, dataType==null ? "" : dataType.name() );
  item.setText(col++, Const.NVL(ConceptUtil.getString(column, DefaultIDs.LOGICAL_COLUMN_DIMENSION_NAME), ""));
  item.setText(col++, Const.NVL(ConceptUtil.getString(column, DefaultIDs.LOGICAL_COLUMN_LENGTH), ""));
  item.setText(col++, Const.NVL(ConceptUtil.getString(column, DefaultIDs.LOGICAL_COLUMN_PRECISION), ""));
  item.setText(col++, Const.NVL(ConceptUtil.getString(column, DefaultIDs.LOGICAL_COLUMN_SOURCE_DB), ""));
  item.setText(col++, Const.NVL(ConceptUtil.getString(column, DefaultIDs.LOGICAL_COLUMN_SOURCE_TABLE), ""));
  item.setText(col++, Const.NVL(ConceptUtil.getString(column, DefaultIDs.LOGICAL_COLUMN_SOURCE_COLUMN), ""));
  item.setText(col++, Const.NVL(ConceptUtil.getString(column, DefaultIDs.LOGICAL_COLUMN_CONVERSION_REMARKS), ""));
}
 
Example #15
Source File: TableView.java    From hop with Apache License 2.0 6 votes vote down vote up
private void applyComboChange( TableItem row, int rownr, int colnr ) {
  String textData;
  if ( combo instanceof ComboVar ) {
    textData = ( (ComboVar) combo ).getText();
  } else {
    textData = ( (CCombo) combo ).getText();
  }
  row.setText( colnr, textData );
  combo.dispose();

  String[] afterEdit = getItemText( row );
  checkChanged( new String[][] { beforeEdit }, new String[][] { afterEdit }, new int[] { rownr } );

  selectionStart = -1;

  fireContentChangedListener( rownr, colnr, textData );
}
 
Example #16
Source File: DataSetDialog.java    From hop with Apache License 2.0 6 votes vote down vote up
/**
 * @param set The data set to load the dialog information into
 */
public void getInfo( DataSet set ) {
  set.setName( wName.getText() );
  set.setDescription( wDescription.getText() );
  set.setFolderName( wFolderName.getText() );
  set.setBaseFilename( wBaseFilename.getText() );
  set.getFields().clear();
  int nrFields = wFieldMapping.nrNonEmpty();
  for ( int i = 0; i < nrFields; i++ ) {
    TableItem item = wFieldMapping.getNonEmpty( i );
    int colnr = 1;
    String fieldName = item.getText( colnr++ );
    int type = ValueMetaFactory.getIdForValueMeta( item.getText( colnr++ ) );
    String format = item.getText( colnr++ );
    int length = Const.toInt( item.getText( colnr++ ), -1 );
    int precision = Const.toInt( item.getText( colnr++ ), -1 );
    String comment = item.getText( colnr++ );

    DataSetField field = new DataSetField( fieldName, type, length, precision, comment, format );
    set.getFields().add( field );
  }

}
 
Example #17
Source File: IfNullDialog.java    From pentaho-kettle with Apache License 2.0 6 votes vote down vote up
private void get() {
  try {
    RowMetaInterface r = transMeta.getPrevStepFields( stepname );
    if ( r != null ) {
      TableItemInsertListener insertListener = new TableItemInsertListener() {
        public boolean tableItemInserted( TableItem tableItem, ValueMetaInterface v ) {
          return true;
        }
      };

      BaseStepDialog
        .getFieldsFromPrevious( r, wFields, 1, new int[] { 1 }, new int[] {}, -1, -1, insertListener );
    }
  } catch ( KettleException ke ) {
    new ErrorDialog( shell, BaseMessages.getString( PKG, "System.Dialog.GetFieldsFailed.Title" ), BaseMessages
      .getString( PKG, "System.Dialog.GetFieldsFailed.Message" ), ke );
  }

}
 
Example #18
Source File: PrioritizeStreamsDialog.java    From hop with Apache License 2.0 6 votes vote down vote up
private void ok() {

    if ( Utils.isEmpty( wTransformName.getText() ) ) {
      return;
    }
    transformName = wTransformName.getText(); // return value

    int nrTransforms = wFields.nrNonEmpty();
    input.allocate( nrTransforms );
    for ( int i = 0; i < nrTransforms; i++ ) {
      TableItem ti = wFields.getNonEmpty( i );
      TransformMeta tm = pipelineMeta.findTransform( ti.getText( 1 ) );
      if ( tm != null ) {
        //CHECKSTYLE:Indentation:OFF
        input.getTransformName()[ i ] = tm.getName();
      }

    }
    dispose();
  }
 
Example #19
Source File: DimensionLookupDialog.java    From pentaho-kettle with Apache License 2.0 6 votes vote down vote up
/**
 * Get the fields from the previous step and use them as "update fields". Only get the the fields which are not yet in
 * use as key, or in the field table. Also ignore technical key, version, fromdate, todate.
 */
private void getUpdate() {
  try {
    RowMetaInterface r = transMeta.getPrevStepFields( stepname );
    if ( r != null && !r.isEmpty() ) {
      BaseStepDialog.getFieldsFromPrevious(
        r, wUpIns, 2, new int[] { 1, 2 }, new int[] {}, -1, -1, new TableItemInsertListener() {
          public boolean tableItemInserted( TableItem tableItem, ValueMetaInterface v ) {
            tableItem
              .setText( 3, BaseMessages.getString( PKG, "DimensionLookupDialog.TableItem.Insert.Label" ) );

            int idx = wKey.indexOfString( v.getName(), 2 );
            return idx < 0
              && !v.getName().equalsIgnoreCase( wTk.getText() )
              && !v.getName().equalsIgnoreCase( wVersion.getText() )
              && !v.getName().equalsIgnoreCase( wFromdate.getText() )
              && !v.getName().equalsIgnoreCase( wTodate.getText() );
          }
        } );
    }
  } catch ( KettleException ke ) {
    new ErrorDialog(
      shell, BaseMessages.getString( PKG, "DimensionLookupDialog.FailedToGetFields.DialogTitle" ),
      BaseMessages.getString( PKG, "DimensionLookupDialog.FailedToGetFields.DialogMessage" ), ke );
  }
}
 
Example #20
Source File: FileDefinitionDialog.java    From kettle-beam with Apache License 2.0 6 votes vote down vote up
public void getData() {
  wName.setText( Const.NVL( fileDefinition.getName(), "" ) );
  wDescription.setText( Const.NVL( fileDefinition.getDescription(), "" ) );
  wSeparator.setText( Const.NVL( fileDefinition.getSeparator(), "" ) );
  wEnclosure.setText( Const.NVL( fileDefinition.getEnclosure(), "" ) );

  List<FieldDefinition> fields = fileDefinition.getFieldDefinitions();
  for (int i=0;i<fields.size();i++) {
    FieldDefinition field = fields.get( i );
    TableItem item = wFields.table.getItem( i );
    item.setText(1, Const.NVL(field.getName(), ""));
    item.setText(2, Const.NVL(field.getKettleType(), ""));
    item.setText(3, Const.NVL(field.getFormatMask(), ""));
    item.setText(4, field.getLength()<0 ? "" : Integer.toString(field.getLength()));
    item.setText(5, field.getPrecision()<0 ? "" : Integer.toString(field.getPrecision()));
  }

  wName.selectAll();
  wName.setFocus();
}
 
Example #21
Source File: ComponentFilterTable.java    From arx with Apache License 2.0 6 votes vote down vote up
/**
 * Returns the item at the given location.
 * 
 * @param x
 * @param y
 * @return
 */
private int getItemColumnAt(int x, int y) {
    Point pt = new Point(x, y);
    int index = table.getTopIndex();
    while (index < table.getItemCount()) {
        final TableItem item = table.getItem(index);
        for (int i = 0; i < table.getColumns().length; i++) {
            final Rectangle rect = item.getBounds(i);
            if (rect.contains(pt)) {
                return i;
            }
        }
        index++;
    }
    return -1;
}
 
Example #22
Source File: GetVariableDialog.java    From pentaho-kettle with Apache License 2.0 6 votes vote down vote up
private void getInfo( GetVariableMeta input ) throws KettleException {

    stepname = wStepname.getText(); // return value
    // Table table = wFields.table;

    int count = wFields.nrNonEmpty();
    input.allocate( count );

    //CHECKSTYLE:Indentation:OFF
    for ( int i = 0; i < count; i++ ) {
      TableItem item = wFields.getNonEmpty( i );

      FieldDefinition currentField = input.getFieldDefinitions()[i];
      int index = 1;
      currentField.setFieldName( item.getText( index++ ) );
      currentField.setVariableString( item.getText( index++ ) );
      currentField.setFieldType( ValueMetaFactory.getIdForValueMeta( item.getText( index++ ) ) );
      currentField.setFieldFormat( item.getText( index++ ) );
      currentField.setFieldLength( Const.toInt( item.getText( index++ ), -1 ) );
      currentField.setFieldPrecision( Const.toInt( item.getText( index++ ), -1 ) );
      currentField.setCurrency( item.getText( index++ ) );
      currentField.setDecimal( item.getText( index++ ) );
      currentField.setGroup( item.getText( index++ ) );
      currentField.setTrimType( ValueMetaString.getTrimTypeByDesc( item.getText( index++ ) ) );
    }
  }
 
Example #23
Source File: JobEntryJobDialog.java    From pentaho-kettle with Apache License 2.0 6 votes vote down vote up
protected void getParameters( JobMeta inputJobMeta ) {
  try {
    if ( inputJobMeta == null ) {
      JobEntryJob jej = new JobEntryJob();
      getInfo( jej );
      inputJobMeta = jej.getJobMeta( rep, metaStore, jobMeta );
    }
    String[] parameters = inputJobMeta.listParameters();

    String[] existing = wParameters.getItems( 1 );

    for ( int i = 0; i < parameters.length; i++ ) {
      if ( Const.indexOfString( parameters[i], existing ) < 0 ) {
        TableItem item = new TableItem( wParameters.table, SWT.NONE );
        item.setText( 1, parameters[i] );
      }
    }
    wParameters.removeEmptyRows();
    wParameters.setRowNums();
    wParameters.optWidth( true );
  } catch ( Exception e ) {
    new ErrorDialog(
      shell, BaseMessages.getString( PKG, "JobEntryJobDialog.Exception.UnableToLoadJob.Title" ), BaseMessages
      .getString( PKG, "JobEntryJobDialog.Exception.UnableToLoadJob.Message" ), e );
  }
}
 
Example #24
Source File: DetectorConfigurationTabTestSubclass.java    From spotbugs with GNU Lesser General Public License v2.1 5 votes vote down vote up
public void enableDetector(String detectorShortName) {
    TableItem[] items = availableFactoriesTableViewer.getTable().getItems();
    for (int i = 0; i < items.length; i++) {
        DetectorFactory detectorFactory = (DetectorFactory) items[i].getData();
        boolean enable = detectorFactory.getShortName().equals(detectorShortName);
        items[i].setChecked(enable);
    }
    syncUserPreferencesWithTable();
}
 
Example #25
Source File: XMLAnalysesManagerPreferencePage.java    From tracecompass with Eclipse Public License 2.0 5 votes vote down vote up
/**
 * Apply change to items according to their checkboxes.
 */
private void handleChecks() {
    Map<@NonNull String, @NonNull File> listFiles = XmlUtils.listFiles();
    Collection<String> filesToEnable = Lists.newArrayList();
    Collection<String> filesToDisable = Lists.newArrayList();

    for (TableItem item : fAnalysesTable.getItems()) {
        String xmlName = XmlUtils.createXmlFileString(item.getText());
        // Only enable/disable if the checkbox status has changed
        if (item.getChecked() && !XmlUtils.isAnalysisEnabled(xmlName)) {
            // Do not enable an invalid file
            if (isFileValid(xmlName, listFiles)) {
                filesToEnable.add(xmlName);
            } else {
                item.setChecked(false);
            }
        } else if (!item.getChecked() && XmlUtils.isAnalysisEnabled(xmlName)) {
            filesToDisable.add(xmlName);
        }
    }

    // Apply changes
    if (!(filesToEnable.isEmpty() && filesToDisable.isEmpty())) {
        enableAndDisableAnalyses(filesToEnable, filesToDisable);
    }

    // Force update for selection handling
    handleSelection(fAnalysesTable.getSelection());
}
 
Example #26
Source File: DetectorConfigurationTab.java    From spotbugs with GNU Lesser General Public License v2.1 5 votes vote down vote up
/**
 * Disables all unchecked detector factories and enables checked factory
 * detectors, leaving those not in the table unmodified.
 */
protected void syncUserPreferencesWithTable() {
    TableItem[] itemList = availableFactoriesTableViewer.getTable().getItems();
    UserPreferences currentProps = getCurrentProps();
    for (int i = 0; i < itemList.length; i++) {
        DetectorFactory factory = (DetectorFactory) itemList[i].getData();
        // set enabled if defined in configuration
        currentProps.enableDetector(factory, itemList[i].getChecked());
    }
}
 
Example #27
Source File: TableComboSnippet1.java    From nebula with Eclipse Public License 2.0 5 votes vote down vote up
/**
 * load a list of rows with 3 columns that includes colors and fonts.
 * @return
 */
private static List<TableItem> loadThreeColumnDatasetWithColorsAndFonts(Table table) {
	List<TableItem> list = loadThreeColumnDataset(table);
	
	int total = (list == null ? 0 : list.size());
	
	for (int index=0; index < total; index++) {
		TableItem ti = ((TableItem)(list.get(index)));
		
		if (index == 0 || index == 14) {
			ti.setForeground(darkRed);
			ti.setFont(boldFont);
		}
		else if (index == 4 || index == 19) {
			ti.setForeground(darkBlue);
			ti.setFont(boldFont);
		} else if (index==6) {
			ti.setForeground(table.getDisplay().getSystemColor(SWT.COLOR_WHITE));
			ti.setBackground(table.getDisplay().getSystemColor(SWT.COLOR_BLACK));
		} else if (index == 9) {
			ti.setForeground(darkGreen);
			ti.setFont(boldFont);
		}
	}
	
	return list;
}
 
Example #28
Source File: EnhancedCheckBoxTableViewer.java    From eclipse-cs with GNU Lesser General Public License v2.1 5 votes vote down vote up
/**
 * Sets to the given value the checked state for all elements in this viewer.
 *
 * @param state
 *          <code>true</code> if the element should be checked, and <code>false</code> if it
 *          should be unchecked
 */
public void setAllChecked(boolean state) {
  TableItem[] children = getTable().getItems();
  for (int i = 0; i < children.length; i++) {
    TableItem item = children[i];
    item.setChecked(state);
  }
}
 
Example #29
Source File: TableView.java    From hop with Apache License 2.0 5 votes vote down vote up
/**
 * Get all the strings from a certain column as an array
 *
 * @param colnr The column to return
 * @return the column values as a string array.
 */
public String[] getItems( int colnr ) {
  String[] retval = new String[ table.getItemCount() ];
  for ( int i = 0; i < retval.length; i++ ) {
    TableItem item = table.getItem( i );
    retval[ i ] = item.getText( colnr + 1 );
  }
  return retval;
}
 
Example #30
Source File: JobEntryDeleteFoldersDialog.java    From pentaho-kettle with Apache License 2.0 5 votes vote down vote up
/**
 * Copy information from the meta-data input to the dialog fields.
 */
public void getData() {
  if ( jobEntry.getName() != null ) {
    wName.setText( jobEntry.getName() );
  }

  if ( jobEntry.arguments != null ) {
    for ( int i = 0; i < jobEntry.arguments.length; i++ ) {
      TableItem ti = wFields.table.getItem( i );
      if ( jobEntry.arguments[i] != null ) {
        ti.setText( 1, jobEntry.arguments[i] );
      }
    }
    wFields.setRowNums();
    wFields.optWidth( true );
  }
  wPrevious.setSelection( jobEntry.argFromPrevious );

  if ( jobEntry.getLimitFolders() != null ) {
    wLimitFolders.setText( jobEntry.getLimitFolders() );
  } else {
    wLimitFolders.setText( "10" );
  }

  if ( jobEntry.getSuccessCondition() != null ) {
    if ( jobEntry.getSuccessCondition().equals( jobEntry.SUCCESS_IF_AT_LEAST_X_FOLDERS_DELETED ) ) {
      wSuccessCondition.select( 1 );
    } else if ( jobEntry.getSuccessCondition().equals( jobEntry.SUCCESS_IF_ERRORS_LESS ) ) {
      wSuccessCondition.select( 2 );
    } else {
      wSuccessCondition.select( 0 );
    }
  } else {
    wSuccessCondition.select( 0 );
  }

  wName.selectAll();
  wName.setFocus();
}