Java Code Examples for org.eclipse.swt.widgets.Combo#getText()

The following examples show how to use org.eclipse.swt.widgets.Combo#getText() . 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: TestingGuiPlugin.java    From hop with Apache License 2.0 6 votes vote down vote up
@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 );
  }
}
 
Example 2
Source File: TermBaseSearchDialog.java    From tmxeditor8 with GNU General Public License v2.0 5 votes vote down vote up
/**
 * 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);
	}
}
 
Example 3
Source File: WizardUtils.java    From XPagesExtensionLibrary with Apache License 2.0 5 votes vote down vote up
public static String getComboText(final Combo combo, final String defVal) {
    if ((combo == null) || (combo.isDisposed())) {
        return defVal;
    }

    return (combo.getText());
}
 
Example 4
Source File: SWTUtils.java    From APICloud-Studio with GNU General Public License v3.0 5 votes vote down vote up
/**
 * 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;
}
 
Example 5
Source File: TermBaseSearchDialog.java    From translationstudio8 with GNU General Public License v2.0 5 votes vote down vote up
/**
 * 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);
	}
}
 
Example 6
Source File: TimeGraphFindDialog.java    From tracecompass with Eclipse Public License 2.0 5 votes vote down vote up
/**
 * 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);
    }
}
 
Example 7
Source File: OptionsConfigurationBlock.java    From typescript.java with MIT License 5 votes vote down vote up
protected void textChanged(Combo comboControl) {
	Key key = (Key) comboControl.getData();
	String number = comboControl.getText();
	String oldValue = setValue(key, number);
	reconcileControls();
	validateSettings(key, oldValue, number);
}
 
Example 8
Source File: WizardNewXtextProjectCreationPage.java    From xtext-eclipse with Eclipse Public License 2.0 5 votes vote down vote up
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);
}
 
Example 9
Source File: HopGuiPipelineGraph.java    From hop with Apache License 2.0 5 votes vote down vote up
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 ) + "%" );
  }
}
 
Example 10
Source File: ProjectsGuiPlugin.java    From hop with Apache License 2.0 5 votes vote down vote up
@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 );
  }
}
 
Example 11
Source File: SWTAtdl4jInputAndFilterDataPanel.java    From atdl4j with MIT License 5 votes vote down vote up
public static String getDropDownItemSelected( Combo aDropDown )
{
	String tempText = aDropDown.getText();
	if ( "".equals( tempText ) )
	{
		return null;
	}
	else
	{
		return tempText;
	}
}
 
Example 12
Source File: ProjectsGuiPlugin.java    From hop with Apache License 2.0 5 votes vote down vote up
@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 );
  }
}
 
Example 13
Source File: FindReplaceDialog.java    From tmxeditor8 with GNU General Public License v2.0 5 votes vote down vote up
/**
 * 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);
	}
}
 
Example 14
Source File: AbstractDominoWizardPanel.java    From XPagesExtensionLibrary with Apache License 2.0 5 votes vote down vote up
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);
    }
}
 
Example 15
Source File: HopGuiWorkflowGraph.java    From hop with Apache License 2.0 5 votes vote down vote up
/**
 * 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();
}
 
Example 16
Source File: ConcordanceSearchDialog.java    From tmxeditor8 with GNU General Public License v2.0 5 votes vote down vote up
/**
 * 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);
	}
}
 
Example 17
Source File: ProjectsGuiPlugin.java    From hop with Apache License 2.0 4 votes vote down vote up
@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 );
    }
  }
}
 
Example 18
Source File: ProjectsGuiPlugin.java    From hop with Apache License 2.0 4 votes vote down vote up
@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 );
    }
  }
}
 
Example 19
Source File: TestingGuiPlugin.java    From hop with Apache License 2.0 4 votes vote down vote up
@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 );
  }
}
 
Example 20
Source File: GuiCompositeWidgets.java    From hop with Apache License 2.0 4 votes vote down vote up
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 );
    }
  }
}