org.eclipse.swt.widgets.Combo#getText ( )源码实例Demo

下面列出了org.eclipse.swt.widgets.Combo#getText ( ) 实例代码,或者点击链接到github查看源代码,也可以在右侧发表评论。

源代码1 项目: hop   文件: TestingGuiPlugin.java
@GuiToolbarElement(
  root = HopGuiPipelineGraph.GUI_PLUGIN_TOOLBAR_PARENT_ID,
  id = ID_TOOLBAR_UNIT_TESTS_LABEL,
  type = GuiToolbarElementType.LABEL,
  label = "  Unit test :",
  toolTip = "Click here to edit the active unit test",
  separator = true
)
public void editPipelineUnitTest() {
  HopGui hopGui = HopGui.getInstance();
  Combo combo = getUnitTestsCombo();
  if ( combo == null ) {
    return;
  }
  String unitTestName = combo.getText();
  try {
    MetadataManager<PipelineUnitTest> manager = new MetadataManager<>( hopGui.getVariables(), hopGui.getMetadataProvider(), PipelineUnitTest.class );
    if ( manager.editMetadata( unitTestName ) ) {
      refreshUnitTestsList();
      selectUnitTestInList( unitTestName );
    }
  } catch ( Exception e ) {
    new ErrorDialog( hopGui.getShell(), "Error", "Error editing active unit test '" + unitTestName, e );
  }
}
 
源代码2 项目: hop   文件: HopGuiPipelineGraph.java
public void setZoomLabel() {
  Combo combo = (Combo) toolBarWidgets.getWidgetsMap().get( TOOLBAR_ITEM_ZOOM_LEVEL );
  if ( combo == null ) {
    return;
  }
  String newString = Math.round( magnification * 100 ) + "%";
  String oldString = combo.getText();
  if ( !newString.equals( oldString ) ) {
    combo.setText( Math.round( magnification * 100 ) + "%" );
  }
}
 
源代码3 项目: tmxeditor8   文件: ConcordanceSearchDialog.java
/**
 * Updates the combo with the history.
 * @param combo
 *            to be updated
 * @param history
 *            to be put into the combo
 */
private void updateHistory(Combo combo, List<String> history) {
	String findString = combo.getText();
	int index = history.indexOf(findString);
	if (index != 0) {
		if (index != -1) {
			history.remove(index);
		}
		history.add(0, findString);
		Point selection = combo.getSelection();
		updateCombo(combo, history);
		combo.setText(findString);
		combo.setSelection(selection);
	}
}
 
源代码4 项目: hop   文件: HopGuiWorkflowGraph.java
/**
 * Allows for magnifying to any percentage entered by the user...
 */
private void readMagnification() {
  float oldMagnification = magnification;
  Combo zoomLabel = (Combo) toolBarWidgets.getWidgetsMap().get( TOOLBAR_ITEM_ZOOM_LEVEL );
  if ( zoomLabel == null ) {
    return;
  }
  String possibleText = zoomLabel.getText();
  possibleText = possibleText.replace( "%", "" );

  float possibleFloatMagnification;
  try {
    possibleFloatMagnification = Float.parseFloat( possibleText ) / 100;
    magnification = possibleFloatMagnification;
    if ( zoomLabel.getText().indexOf( '%' ) < 0 ) {
      zoomLabel.setText( zoomLabel.getText().concat( "%" ) );
    }
  } catch ( Exception e ) {
    MessageBox mb = new MessageBox( hopShell(), SWT.YES | SWT.ICON_ERROR );
    mb.setMessage( BaseMessages.getString( PKG, "PipelineGraph.Dialog.InvalidZoomMeasurement.Message", zoomLabel
      .getText() ) );
    mb.setText( BaseMessages.getString( PKG, "PipelineGraph.Dialog.InvalidZoomMeasurement.Title" ) );
    mb.open();
  }

  // When zooming out we want to correct the scroll bars.
  //
  float factor = magnification / oldMagnification;
  int newHThumb = Math.min( (int) ( horizontalScrollBar.getThumb() / factor ), 100 );
  horizontalScrollBar.setThumb( newHThumb );
  horizontalScrollBar.setSelection( (int) ( horizontalScrollBar.getSelection() * factor ) );
  int newVThumb = Math.min( (int) ( verticalScrollBar.getThumb() / factor ), 100 );
  verticalScrollBar.setThumb( newVThumb );
  verticalScrollBar.setSelection( (int) ( verticalScrollBar.getSelection() * factor ) );

  redraw();
}
 
protected void createDSNameArea(){
    createLabel("Da&ta source name:", createSpanGD(getNumRightColumns() - 2)); // $NLX-AbstractDominoWizardPanel.Datasourcename-1$

    _nameText = createDCTextComputed(XSPAttributeNames.XSP_ATTR_VAR, createControlGDBigWidth(getNumRightColumns() - 2));
    _nameText.setIsComputable(false);
    _nameText.setValidator(new UniqueXmlNameValidator(_data.getNode(), XSPAttributeNames.XSP_ATTR_VAR, "Data source name", !isPropsPanel() && !isNewDesignElementDialog()));  // $NLX-AbstractDominoWizardPanel.Datasourcename.1-1$
    final Combo viewCombo = getDesignElementPicker();
    if (viewCombo != null) {
        _lastViewName = viewCombo.getText();
        viewCombo.addModifyListener(new ModifyListener() {
            public void modifyText(ModifyEvent e) {
                // delay a second before setting input to make sure the user
                // is done typing.
                _currentTime = System.currentTimeMillis();
                Display.getCurrent().timerExec(1500, new Runnable() {
                    public void run() {
                        if (!isDisposed() && (System.currentTimeMillis() - _currentTime >= 1400)) { // more robust with -100ms from delay
                            if (_lastViewName != null && !_lastViewName.equals(viewCombo.getText())) {
                                _lastViewName = viewCombo.getText();
                                if (!ComputedValueUtils.isStringComputed(_lastViewName)) {
                                    // _responsesViewer.setInput(getViewAttrInput());
                                }
                            }
                        }
                    }
                });
            }
        });
    }
    String tip = "Use the data source name when referring to this data source\nprogrammatically. Use caution when changing this name.";   // $NLX-AbstractDominoWizardPanel.Usethedatasourcenamewhenreferring-1$
    _nameText.setToolTipText(tip); 
    _nameText.getEditorControl().setToolTipText(tip);
    if(isPropsPanel()) {
        Label separator = new Label(getCurrentParent(), SWT.SEPARATOR | SWT.HORIZONTAL);
        GridData sep = SWTLayoutUtils.createGDFillHorizontal();
        sep.horizontalSpan = 2;
        sep.verticalIndent = 7;
        separator.setLayoutData(sep);
    }
}
 
源代码6 项目: tmxeditor8   文件: FindReplaceDialog.java
/**
 * Updates the combo with the history.
 * @param combo
 *            to be updated
 * @param history
 *            to be put into the combo
 */
private void updateHistory(Combo combo, List<String> history) {
	String findString = combo.getText();
	int index = history.indexOf(findString);
	if (index != 0) {
		if (index != -1) {
			history.remove(index);
		}
		history.add(0, findString);
		Point selection = combo.getSelection();
		updateCombo(combo, history);
		combo.setText(findString);
		combo.setSelection(selection);
	}
}
 
源代码7 项目: hop   文件: ProjectsGuiPlugin.java
@GuiToolbarElement(
  root = HopGui.ID_MAIN_TOOLBAR,
  id = ID_TOOLBAR_PROJECT_LABEL,
  type = GuiToolbarElementType.LABEL,
  label = "  Project : ",
  toolTip = "Click here to edit the active project",
  separator = true
)
public void editProject() {
  HopGui hopGui = HopGui.getInstance();
  Combo combo = getProjectsCombo();
  if ( combo == null ) {
    return;
  }
  ProjectsConfig config = ProjectsConfigSingleton.getConfig();

  String projectName = combo.getText();

  ProjectConfig projectConfig = config.findProjectConfig( projectName );
  if ( projectConfig == null ) {
    return;
  }

  try {
    Project project = projectConfig.loadProject( hopGui.getVariables() );
    ProjectDialog projectDialog = new ProjectDialog( hopGui.getShell(), project, projectConfig, hopGui.getVariables() );
    if ( projectDialog.open() != null ) {
      config.addProjectConfig( projectConfig );
      project.saveToFile();

      refreshProjectsList();
      selectProjectInList( projectName );
    }
  } catch ( Exception e ) {
    new ErrorDialog( hopGui.getShell(), "Error", "Error editing project '" + projectName, e );
  }
}
 
源代码8 项目: atdl4j   文件: SWTAtdl4jInputAndFilterDataPanel.java
public static String getDropDownItemSelected( Combo aDropDown )
{
	String tempText = aDropDown.getText();
	if ( "".equals( tempText ) )
	{
		return null;
	}
	else
	{
		return tempText;
	}
}
 
源代码9 项目: hop   文件: ProjectsGuiPlugin.java
@GuiToolbarElement(
  root = HopGui.ID_MAIN_TOOLBAR,
  id = ID_TOOLBAR_ENVIRONMENT_LABEL,
  type = GuiToolbarElementType.LABEL,
  label = "  Environment : ",
  toolTip = "Click here to edit the active environment",
  separator = true
)
public void editEnvironment() {
  HopGui hopGui = HopGui.getInstance();
  Combo combo = getEnvironmentsCombo();
  if ( combo == null ) {
    return;
  }
  ProjectsConfig config = ProjectsConfigSingleton.getConfig();

  String environmentName = combo.getText();
  if ( StringUtils.isEmpty( environmentName ) ) {
    return;
  }
  LifecycleEnvironment environment = config.findEnvironment( environmentName );
  if ( environment == null ) {
    return;
  }

  try {
    LifecycleEnvironmentDialog dialog = new LifecycleEnvironmentDialog( hopGui.getShell(), environment, hopGui.getVariables() );
    if ( dialog.open() != null ) {
      config.addEnvironment( environment );
      ProjectsConfigSingleton.saveConfig();

      refreshEnvironmentsList(); ;
      selectEnvironmentInList( environmentName );
    }
  } catch ( Exception e ) {
    new ErrorDialog( hopGui.getShell(), "Error", "Error editing environment '" + environmentName, e );
  }
}
 
源代码10 项目: tmxeditor8   文件: TermBaseSearchDialog.java
/**
 * Updates the combo with the history.
 * @param combo
 *            to be updated
 * @param history
 *            to be put into the combo
 */
private void updateHistory(Combo combo, List<String> history) {
	String findString = combo.getText();
	int index = history.indexOf(findString);
	if (index != 0) {
		if (index != -1) {
			history.remove(index);
		}
		history.add(0, findString);
		Point selection = combo.getSelection();
		updateCombo(combo, history);
		combo.setText(findString);
		combo.setSelection(selection);
	}
}
 
protected void fillBreeCombo(Combo comboToFill) {
	Set<String> brees = Sets.newLinkedHashSet();
	Set<String> availableBrees = Sets.newHashSet();
	for (IExecutionEnvironment ee : JavaRuntime.getExecutionEnvironmentsManager().getExecutionEnvironments()) {
		availableBrees.add(ee.getId());
	}
	for (JavaVersion supportedVersion : JavaVersion.values()) {
		if (supportedVersion.isAtLeast(JavaVersion.JAVA6)) {
			String bree = supportedVersion.getBree();
			if (availableBrees.contains(bree))
				brees.add(bree);
		}
	}
	String[] array = brees.toArray(new String[] {});
	String selectionMemento = comboToFill.getText();
	comboToFill.setItems(array);
	int index = comboToFill.indexOf(selectionMemento);
	String defaultBree = JREContainerProvider.getDefaultBREE();
	if (index < 0) {
		if (brees.contains(defaultBree)) {
			comboToFill.select(comboToFill.indexOf(defaultBree));
		} else {
			comboToFill.select(array.length - 1);
		}
	}
	comboToFill.select(index);
}
 
protected void textChanged(Combo comboControl) {
	Key key = (Key) comboControl.getData();
	String number = comboControl.getText();
	String oldValue = setValue(key, number);
	reconcileControls();
	validateSettings(key, oldValue, number);
}
 
源代码13 项目: tracecompass   文件: TimeGraphFindDialog.java
/**
 * Updates the combo with the history.
 *
 * @param combo
 *            to be updated
 * @param history
 *            to be put into the combo
 */
private static void updateHistory(Combo combo, List<String> history) {
    String findString = combo.getText();
    int index = history.indexOf(findString);
    if (index != 0) {
        if (index != -1) {
            history.remove(index);
        }
        history.add(0, findString);
        Point selection = combo.getSelection();
        updateCombo(combo, history);
        combo.setText(findString);
        combo.setSelection(selection);
    }
}
 
源代码14 项目: translationstudio8   文件: TermBaseSearchDialog.java
/**
 * Updates the combo with the history.
 * @param combo
 *            to be updated
 * @param history
 *            to be put into the combo
 */
private void updateHistory(Combo combo, List<String> history) {
	String findString = combo.getText();
	int index = history.indexOf(findString);
	if (index != 0) {
		if (index != -1) {
			history.remove(index);
		}
		history.add(0, findString);
		Point selection = combo.getSelection();
		updateCombo(combo, history);
		combo.setText(findString);
		combo.setSelection(selection);
	}
}
 
源代码15 项目: APICloud-Studio   文件: SWTUtils.java
/**
 * Tests if the Combo value is empty. If so, it adds an error color to the background of the cell.
 * 
 * @param combo
 *            the combo to validate
 * @param validSelectionIndex
 *            the first item that is a "valid" selection
 * @return boolean
 */
public static boolean validateCombo(Combo combo, int validSelectionIndex)
{
	int selectionIndex = Math.max(validSelectionIndex, 0);
	String text = combo.getText();
	if (text == null || text.length() == 0 || combo.getSelectionIndex() < selectionIndex)
	{
		combo.setBackground(backgroundErrorColor);
		return false;
	}
	combo.setBackground(null);
	return true;
}
 
源代码16 项目: XPagesExtensionLibrary   文件: WizardUtils.java
public static String getComboText(final Combo combo, final String defVal) {
    if ((combo == null) || (combo.isDisposed())) {
        return defVal;
    }

    return (combo.getText());
}
 
源代码17 项目: hop   文件: GuiCompositeWidgets.java
private void getWidgetsData( Object sourceData, GuiElements guiElements ) {
  if ( guiElements.isIgnored() ) {
    return;
  }

  // Do we add the element or the children?
  //
  if ( guiElements.getId() != null ) {

    Control control = widgetsMap.get( guiElements.getId() );
    if ( control != null ) {

      // What's the value?
      //
      Object value = null;

      switch ( guiElements.getType() ) {
        case TEXT:
          if ( guiElements.isVariablesEnabled() ) {
            TextVar textVar = (TextVar) control;
            value = textVar.getText();
          } else {
            Text text = (Text) control;
            value = text.getText();
          }
          break;
        case CHECKBOX:
          Button button = (Button) control;
          value = button.getSelection();
          break;
        case COMBO:
          if ( guiElements.isVariablesEnabled() ) {
            ComboVar comboVar = (ComboVar) control;
            value = comboVar.getText();
          } else {
            Combo combo = (Combo) control;
            value = combo.getText();
          }
          break;
        default:
          System.err.println( "WARNING: getting data from widget with ID " + guiElements.getId() + " : not implemented type " + guiElements.getType() + " yet." );
          break;
      }

      // Set the value on the source data object
      //
      try {
        new PropertyDescriptor( guiElements.getFieldName(), sourceData.getClass() )
          .getWriteMethod()
          .invoke( sourceData, value )
        ;
      } catch ( Exception e ) {
        System.err.println( "Unable to set value '" + value + "'on field: '" + guiElements.getFieldName() + "' : " + e.getMessage() );
        e.printStackTrace();
      }

    } else {
      System.err.println( "Widget not found to set value on for id: " + guiElements.getId()+", label: "+guiElements.getLabel() );
    }
  } else {

    // Add the children
    //
    for ( GuiElements child : guiElements.getChildren() ) {
      getWidgetsData( sourceData, child );
    }
  }
}
 
源代码18 项目: hop   文件: ProjectsGuiPlugin.java
@GuiToolbarElement(
  root = HopGui.ID_MAIN_TOOLBAR,
  id = ID_TOOLBAR_PROJECT_DELETE,
  toolTip = "Deleted the selected project",
  image = "project-delete.svg",
  separator = true
)
public void deleteSelectedProject() {
  Combo combo = getProjectsCombo();
  if ( combo == null ) {
    return;
  }
  String projectName = combo.getText();
  if ( StringUtils.isEmpty( projectName ) ) {
    return;
  }

  ProjectsConfig config = ProjectsConfigSingleton.getConfig();

  ProjectConfig projectConfig = config.findProjectConfig( projectName );
  if ( projectConfig == null ) {
    return;
  }
  String projectHome = projectConfig.getProjectHome();
  String configFilename = projectConfig.getConfigFilename();

  MessageBox box = new MessageBox( HopGui.getInstance().getShell(), SWT.YES | SWT.NO | SWT.ICON_QUESTION );
  box.setText( "Delete?" );
  box.setMessage( "Do you want to delete project '" + projectName + "' from the Hop configuration?" + Const.CR + "Please note that folder '" + projectHome
    + "' or the project configuration file " + configFilename + " in it are NOT removed or otherwise altered in any way." );
  int anwser = box.open();
  if ( ( anwser & SWT.YES ) != 0 ) {
    try {
      config.removeProjectConfig( projectName );
      ProjectsConfigSingleton.saveConfig();

      refreshProjectsList();
      selectProjectInList( null );
    } catch ( Exception e ) {
      new ErrorDialog( HopGui.getInstance().getShell(), "Error", "Error removing project '" + projectName + "'", e );
    }
  }
}
 
源代码19 项目: hop   文件: ProjectsGuiPlugin.java
@GuiToolbarElement(
  root = HopGui.ID_MAIN_TOOLBAR,
  id = ID_TOOLBAR_ENVIRONMENT_DELETE,
  toolTip = "Deleted the selected environment",
  image = "environment-delete.svg",
  separator = true
)
public void deleteSelectedEnvironment() {
  Combo combo = getEnvironmentsCombo();
  if ( combo == null ) {
    return;
  }
  String environmentName = combo.getText();
  if ( StringUtils.isEmpty( environmentName ) ) {
    return;
  }

  ProjectsConfig config = ProjectsConfigSingleton.getConfig();

  LifecycleEnvironment environment = config.findEnvironment( environmentName );
  if ( environment == null ) {
    return;
  }

  MessageBox box = new MessageBox( HopGui.getInstance().getShell(), SWT.YES | SWT.NO | SWT.ICON_QUESTION );
  box.setText( "Delete?" );
  box.setMessage( "Do you want to delete environment '" + environmentName + "' from the Hop configuration?" + Const.CR + "Please note that project '" + environment.getProjectName()
    + "' or any file or folder are NOT removed or otherwise altered in any way." );
  int anwser = box.open();
  if ( ( anwser & SWT.YES ) != 0 ) {
    try {
      config.removeEnvironment( environmentName );
      ProjectsConfigSingleton.saveConfig();

      refreshEnvironmentsList();
      selectEnvironmentInList( null );
    } catch ( Exception e ) {
      new ErrorDialog( HopGui.getInstance().getShell(), "Error", "Error removing environment " + environmentName + "'", e );
    }
  }
}
 
源代码20 项目: hop   文件: TestingGuiPlugin.java
@GuiToolbarElement(
  root = HopGuiPipelineGraph.GUI_PLUGIN_TOOLBAR_PARENT_ID,
  id = ID_TOOLBAR_UNIT_TESTS_COMBO,
  type = GuiToolbarElementType.COMBO,
  comboValuesMethod = "getUnitTestsList",
  extraWidth = 200,
  toolTip = "Select the active environment"
)
public void selectUnitTest() {

  HopGui hopGui = HopGui.getInstance();
  try {
    PipelineMeta pipelineMeta = getActivePipelineMeta();
    if ( pipelineMeta == null ) {
      return;
    }
    IHopMetadataProvider metadataProvider = hopGui.getMetadataProvider();

    Combo combo = getUnitTestsCombo();
    if ( combo == null ) {
      return;
    }

    IHopMetadataSerializer<PipelineUnitTest> testSerializer = metadataProvider.getSerializer( PipelineUnitTest.class );

    String testName = combo.getText();
    if ( testName != null ) {
      PipelineUnitTest unitTest = testSerializer.load( testName );
      if ( unitTest == null ) {
        throw new HopException( "Unit test '" + testName + "' could not be found (deleted)?" );
      }
      unitTest.initializeVariablesFrom( pipelineMeta );

      selectUnitTest( pipelineMeta, unitTest );

      // Update the pipeline graph
      //
      hopGui.getActiveFileTypeHandler().updateGui();
    }
  } catch ( Exception e ) {
    new ErrorDialog( hopGui.getShell(), "Error", "Error selecting a new pipeline unit test", e );
  }
}