protected Control createControl() { m_Combo = new CCombo(m_Table, SWT.READ_ONLY); m_Combo.setBackground(Display.getCurrent().getSystemColor( SWT.COLOR_LIST_BACKGROUND)); if (m_Items != null) m_Combo.setItems(m_Items); m_Combo.addKeyListener(new KeyAdapter() { public void keyPressed(KeyEvent e) { try { onKeyPressed(e); } catch (Exception ex) { } } }); /* * m_Combo.addTraverseListener(new TraverseListener() { public void * keyTraversed(TraverseEvent arg0) { onTraverse(arg0); } }); */ return m_Combo; }
public static void setCompressionTooltips(CCombo wCompression, Class dialogClass) { switch (ConnectionCompression.fromString(wCompression.getText())) { case NONE: wCompression.setToolTipText(BaseMessages.getString(dialogClass, "CompressionNone.TipText")); break; case SNAPPY: wCompression.setToolTipText(BaseMessages.getString(dialogClass, "CompressionSnappy.TipText")); break; case PIEDPIPER: wCompression.setToolTipText(BaseMessages.getString(dialogClass, "CompressionPiedPiper.TipText")); break; default: wCompression.setToolTipText(BaseMessages.getString(dialogClass, "CompressionNotAvailable.TipText")); } }
private CCombo addComboInTable(TableViewer tableViewer, TableItem tableItem, String comboName, String comboPaneName, String editorName, int columnIndex, String[] relationalOperators, SelectionListener dropDownSelectionListener, ModifyListener modifyListener,FocusListener focusListener) { final Composite buttonPane = new Composite(tableViewer.getTable(), SWT.NONE); buttonPane.setLayout(new FillLayout()); final CCombo combo = new CCombo(buttonPane, SWT.NONE); combo.setItems(relationalOperators); combo.setData(FilterConstants.ROW_INDEX, tableViewer.getTable().indexOf(tableItem)); tableItem.setData(comboName, combo); tableItem.setData(comboPaneName, buttonPane); combo.addSelectionListener(dropDownSelectionListener); combo.addModifyListener(modifyListener); combo.addFocusListener(focusListener); new AutoCompleteField(combo, new CComboContentAdapter(), combo.getItems()); final TableEditor editor = new TableEditor(tableViewer.getTable()); editor.grabHorizontal = true; editor.grabVertical = true; editor.setEditor(buttonPane, tableItem, columnIndex); editor.layout(); combo.setData(editorName, editor); return combo; }
/** * Gets the conditional operator modify listener. * * @param conditionsList * the conditions list * @param fieldsAndTypes * the fields and types * @param fieldNames * the field names * @param saveButton * the save button * @param displayButton * the display button * @return the conditional operator modify listener */ public ModifyListener getConditionalOperatorModifyListener(final List<Condition> conditionsList, final Map<String, String> fieldsAndTypes, final String[] fieldNames, final Button saveButton, final Button displayButton) { ModifyListener listener = new ModifyListener() { @Override public void modifyText(ModifyEvent e) { CCombo source = (CCombo) e.getSource(); TableItem tableItem = getTableItem(source); Condition condition = (Condition) tableItem.getData(); if (tableItem.getData(FilterConstants.VALUE2TEXTBOX) != null) { Text text = (Text) tableItem.getData(FilterConstants.VALUE2TEXTBOX); enableAndDisableValue2TextBox(condition.getConditionalOperator(), text); } processConditionalOperator(source, conditionsList, fieldsAndTypes, fieldNames, saveButton, displayButton); } }; return listener; }
public void insertControlContents(Control control, String text, int cursorPosition) { CCombo combo = (CCombo) control; String contents = combo.getText(); Point selection = combo.getSelection(); StringBuffer sb = new StringBuffer(); sb.append(contents.substring(0, selection.x)); sb.append(text); if (selection.y < contents.length()) { sb.append(contents.substring(selection.y, contents.length())); } combo.setText(sb.toString()); selection.x = selection.x + cursorPosition; selection.y = selection.x; combo.setSelection(selection); }
public Rectangle getInsertionBounds(Control control) { // This doesn't take horizontal scrolling into affect. // see https://bugs.eclipse.org/bugs/show_bug.cgi?id=204599 CCombo combo = (CCombo) control; int position = combo.getSelection().y; String contents = combo.getText(); GC gc = new GC(combo); gc.setFont(combo.getFont()); Point extent = gc.textExtent(contents.substring(0, Math.min(position, contents.length()))); gc.dispose(); if (COMPUTE_TEXT_USING_CLIENTAREA) { return new Rectangle(combo.getClientArea().x + extent.x, combo .getClientArea().y, 1, combo.getClientArea().height); } return new Rectangle(extent.x, 0, 1, combo.getSize().y); }
private void initServerCombo(Composite container) { Label serverLabel = new Label(container, SWT.FLAT); serverLabel.setLayoutData(new GridData(SWT.LEFT, SWT.CENTER, true, true, 1, 1)); serverLabel.setText("Server: "); serverCombo = new CCombo(container, SWT.DROP_DOWN); serverCombo.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, true, 1, 1)); for (String s : serverProposals) serverCombo.add(s); if (serverProposals.length > 0) serverCombo.select(0); if (defaultUriIndex >= 0 && defaultUriIndex < serverProposals.length) serverCombo.select(defaultUriIndex); // serverCombo.pack(); }
protected CCombo createCombo(Composite parent, String label, IJSONPath path, String[] values, String defaultValue) { FormToolkit toolkit = getToolkit(); Composite composite = toolkit.createComposite(parent, SWT.NONE); composite.setLayoutData(new GridData(GridData.FILL_HORIZONTAL)); GridLayout layout = new GridLayout(2, false); layout.marginWidth = 0; layout.marginBottom = 0; layout.marginTop = 0; layout.marginHeight = 0; layout.verticalSpacing = 0; composite.setLayout(layout); toolkit.createLabel(composite, label); CCombo combo = new CCombo(composite, SWT.DROP_DOWN | SWT.READ_ONLY | SWT.BORDER); combo.setLayoutData(new GridData(GridData.FILL_HORIZONTAL)); combo.setItems(values); toolkit.adapt(combo, true, false); bind(combo, path, defaultValue); return combo; }
public void keyPressed(KeyEvent e) { if (e.keyCode == UICoreConstant.UMLSECTION_CONSTANTS__KEYCODE_ENTER || e.keyCode == UICoreConstant.UMLSECTION_CONSTANTS__KEYCODE_ENTER_SECOND) { CCombo combo = (CCombo) e.getSource(); String text = combo.getText(); try { final int value = new Integer(text).intValue(); final Property property = this.property; if (value > 0) { DomainUtil.run(new TransactionalAction() { @Override public void doExecute() { property.setLower(value); property.setUpper(value); } }); } } catch (Exception e2) { // TODO: handle exception } } }
public void focusLost(FocusEvent e) { CCombo combo = (CCombo) e.getSource(); String text = combo.getText(); try { final int value = new Integer(text).intValue(); final Property property = this.property; if (value > 0) { DomainUtil.run(new TransactionalAction() { @Override public void doExecute() { property.setLower(value); property.setUpper(value); } }); } } catch (Exception e2) { // TODO: handle exception } }
/** * @see org.eclipse.swt.events.SelectionListener#widgetSelected(org.eclipse.swt.events.SelectionEvent) */ public void widgetSelected(final SelectionEvent e) { DomainUtil.run(new TransactionalAction() { /** * @see nexcore.tool.uml.manager.transaction.TransactionalAction#doExecute() */ @Override public void doExecute() { CCombo combo = (CCombo) e.getSource(); String comboValue = combo.getText(); if (comboValue.equals(MultiplicityType.SINGLE_STAR.toString())) { property.setLower(0); property.setUpper(LiteralUnlimitedNatural.UNLIMITED); } else if (comboValue.equals(MultiplicityType.ZERO_TO_UNIQUE.toString())) { property.setLower(0); property.setUpper(1); } else if (comboValue.equals(MultiplicityType.UNIQUE_TO_SINGLE_STAR.toString())) { property.setLower(1); property.setUpper(LiteralUnlimitedNatural.UNLIMITED); } else { property.setLower(1); property.setUpper(1); } } }); }
/** * 속성 모델에 다중성 값을 세팅 * * @param combo * void */ private void setMultiplicityOfPropertyToModel(CCombo combo) { if ((combo.getText()).equals(MultiplicityType.SINGLE_STAR.toString())) { // * this.getData().setLower(0); this.getData().setUpper(LiteralUnlimitedNatural.UNLIMITED); } else if ((combo.getText()).equals(MultiplicityType.ZERO_TO_UNIQUE.toString())) { // 0.. 1 this.getData().setLower(0); this.getData().setUpper(1); } else if ((combo.getText()).equals(MultiplicityType.UNIQUE.toString())) { // 1 this.getData().setLower(1); this.getData().setUpper(1); } else if ((combo.getText()).equals(MultiplicityType.UNIQUE_TO_SINGLE_STAR.toString())) { // 1.. * this.getData().setLower(1); this.getData().setUpper(LiteralUnlimitedNatural.UNLIMITED); } else if ((combo.getText()).equals(MultiplicityType.NONE.toString())) { // 1 this.getData().setLower(1); this.getData().setUpper(1); } else { return; } }
private void createMatchModeCombo(Composite parent) { // draw label Label comboLabel = new Label(parent,SWT.LEFT); comboLabel.setLayoutData(new GridData(GridData.HORIZONTAL_ALIGN_END)); comboLabel.setText(LogViewerPlugin.getResourceString("preferences.ruleseditor.dialog.matchmode.label")); //$NON-NLS-1$ // draw combo matchModeCombo = new CCombo(parent,SWT.BORDER); matchModeCombo.setLayoutData(new GridData(GridData.FILL_HORIZONTAL)); matchModeCombo.setEditable(false); String[] matchModes = {LogViewerPlugin.getResourceString("preferences.ruleseditor.dialog.matchmode.entry.find"), LogViewerPlugin.getResourceString("preferences.ruleseditor.dialog.matchmode.entry.match")}; matchModeCombo.setItems(matchModes); if(edit) { String[] items = matchModeCombo.getItems(); for(int i = 0 ; i < items.length ; i++) { if(items[i].toLowerCase().indexOf(this.data.getMatchMode())!=-1) { matchModeCombo.select(i); return; } } } }
private void handleAddExceptionForControl(final Control control, final ValidationException e) { if (control instanceof Text) { Text text = (Text) control; text.setBackground(new Color(control.getDisplay(), ERROR_COLOR)); text.setToolTipText(e.getMessage()); } else if (control instanceof CCombo) { CCombo combo = (CCombo) control; combo.setBackground(new Color(control.getDisplay(), ERROR_COLOR)); combo.setToolTipText(e.getMessage()); } else if (control instanceof Composite) { Composite composite = (Composite) control; composite.setBackground(new Color(control.getDisplay(), ERROR_COLOR)); for (final Control childControl : composite.getChildren()) { childControl.setBackground(new Color(control.getDisplay(), ERROR_COLOR)); } composite.setToolTipText(e.getMessage()); } }
private void handleRemoveExceptionForControl(final Control control) { if (control instanceof Text) { Text text = (Text) control; text.setBackground(null); text.setToolTipText(null); } else if (control instanceof CCombo) { CCombo combo = (CCombo) control; combo.setBackground(null); combo.setToolTipText(null); } else if (control instanceof Composite) { Composite composite = (Composite) control; composite.setBackground(null); for (final Control childControl : composite.getChildren()) { childControl.setBackground(null); } composite.setToolTipText(null); } }
private void PopulateFields( CCombo cc ) { if ( cc.isDisposed() ) { return; } try { String initValue = cc.getText(); cc.removeAll(); RowMetaInterface r = transMeta.getPrevStepFields( stepname ); if ( r != null ) { cc.setItems( r.getFieldNames() ); } if ( !Const.isEmpty( initValue ) ) { cc.setText( initValue ); } } catch ( KettleException ke ) { new ErrorDialog( shell, BaseMessages.getString( PKG, "XsltDialog.FailedToGetFields.DialogTitle" ), BaseMessages .getString( PKG, "XsltDialog.FailedToGetFields.DialogMessage" ), ke ); } }
@Override public void doSetFocus() { final CCombo combo = (CCombo)getControl(); if (!combo.isDisposed()) { String text = combo.getText(); if (text.length() == 0 && CommonUtils.isWSCocoa()) { combo.getDisplay().timerExec(1000, new Runnable() { @Override public void run() { focusIt(combo); } }); } else { focusIt(combo); } } }
/** * DOC nrousseau Comment method "createComboCommand". * * @param source * @return */ private PropertyChangeCommand createComboCommand(CCombo combo) { String paramName = (String) combo.getData(PARAMETER_NAME); IElementParameter param = elem.getElementParameter(paramName); String value = combo.getText(); // for (int j = 0; j < param.getListItemsValue().length; j++) { // if (combo.getText().equals(param.getListItemsDisplayName()[j])) { // value = (String) param.getListItemsValue()[j]; // } // } if (value.equals(param.getValue())) { return null; } return new PropertyChangeCommand(elem, paramName, value); }
private void clearAll(IElementParameter param, IElementParameter processTypeParameter) { Text jobName = (Text) hashCurControls.get(param.getName() + ":" + processTypeParameter.getName()); //$NON-NLS-1$ CCombo contextCombo = (CCombo) hashCurControls.get(param.getChildParameters().get(EParameterName.PROCESS_TYPE_CONTEXT.getName()).getName()); CCombo versionCombo = (CCombo) hashCurControls.get(param.getChildParameters().get(EParameterName.PROCESS_TYPE_VERSION.getName()).getName()); jobName.setText(""); contextCombo.removeAll(); versionCombo.removeAll(); param.setValue(""); Map<String, IElementParameter> childParameters = param.getChildParameters(); Iterator<String> iterator = childParameters.keySet().iterator(); while(iterator.hasNext()){ String next = iterator.next(); IElementParameter nextPara = childParameters.get(next); nextPara.setValue(""); } }
/** * Remove the UI to enter method arguments * The current values are stored and returned. */ private List<String> removeArgumentsUI(){ Control [] controls = metadataComposite.getChildren(); List<String> currentValues = new ArrayList<String>(); for (Control control : controls) { if ( control == alwaysPassInputRowLabel || control == alwaysPassInputRowButton || control == methodLabel || control == methodCombo || control == argumentSourceLabel || control == argumentSourceFields || control == removeArgumentFieldsLabel || control == removeArgumentFieldsButton ) continue; if (control instanceof CCombo) { currentValues.add(((CCombo)control).getText()); } control.dispose(); } return currentValues; }
private void getFieldsInto( CCombo fieldCombo ) { try { if ( !gotPreviousFields ) { previousFields = transMeta.getPrevStepFields( stepname ); } String field = fieldCombo.getText(); if ( previousFields != null ) { fieldCombo.setItems( previousFields.getFieldNames() ); } if ( field != null ) { fieldCombo.setText( field ); } gotPreviousFields = true; } catch ( KettleException ke ) { new ErrorDialog( shell, BaseMessages.getString( PKG, "HazelcastInputDialog.FailedToGetFields.DialogTitle" ), BaseMessages.getString( PKG, "HazelcastInputDialog.FailedToGetFields.DialogMessage" ), ke ); } }
private void getFieldsInto( CCombo fieldCombo ) { try { if ( !gotPreviousFields ) { previousFields = transMeta.getPrevStepFields( stepname ); } String field = fieldCombo.getText(); if ( previousFields != null ) { fieldCombo.setItems( previousFields.getFieldNames() ); } if ( field != null ) fieldCombo.setText( field ); gotPreviousFields = true; } catch ( KettleException ke ) { new ErrorDialog( shell, BaseMessages.getString( PKG, "MemcachedInputDialog.FailedToGetFields.DialogTitle" ), BaseMessages.getString( PKG, "MemcachedInputDialog.FailedToGetFields.DialogMessage" ), ke ); } }
private void getFieldsInto( CCombo fieldCombo ) { try { if ( !gotPreviousFields ) { previousFields = transMeta.getPrevStepFields( stepname ); } String field = fieldCombo.getText(); if ( previousFields != null ) { fieldCombo.setItems( previousFields.getFieldNames() ); } if ( field != null ) fieldCombo.setText( field ); gotPreviousFields = true; } catch ( KettleException ke ) { new ErrorDialog( shell, BaseMessages.getString( PKG, "MemcachedOutputDialog.FailedToGetFields.DialogTitle" ), BaseMessages.getString( PKG, "MemcachedOutputDialog.FailedToGetFields.DialogMessage" ), ke ); } }
private void PopulateFields(CCombo cc) { try{ cc.removeAll(); RowMetaInterface r = transMeta.getPrevStepFields(stepname); if (r!=null) { r.getFieldNames(); for (int i=0;i<r.getFieldNames().length;i++) { cc.add(r.getFieldNames()[i]); } } }catch(KettleException ke){ new ErrorDialog(shell, Messages.getString("XsltDialog.FailedToGetFields.DialogTitle"), Messages.getString("XsltDialog.FailedToGetFields.DialogMessage"), ke); //$NON-NLS-1$ //$NON-NLS-2$ } }
public static IExpressionButton createExpressionButton( Composite parent, Control control, ExtendedItemHandle eih, IExpressionProvider ep ) { boolean isCube = ChartReportItemHelper.instance( ) .getBindingCubeHandle( eih ) != null; boolean isCombo = control instanceof Combo || control instanceof CCombo; ChartExpressionHelper eHelper = isCombo ? new ChartExpressionComboHelper( isCube ) : new ChartExpressionHelper( isCube ); return new ChartExpressionButton( parent, control, eih, ep, eHelper ); }
public void insertControlContents( Control control, String text, int cursorPosition ) { CCombo combo = (CCombo) control; String contents = ChartUIUtil.getText( combo ); Point selection = combo.getSelection( ); StringBuffer sb = new StringBuffer( ); sb.append( contents.substring( 0, selection.x ) ); sb.append( text ); if ( selection.y < contents.length( ) ) { sb.append( contents.substring( selection.y, contents.length( ) ) ); } ChartUIUtil.setText( combo, sb.toString( ) ); selection.x = selection.x + cursorPosition; selection.y = selection.x; combo.setSelection( selection ); }
public Rectangle getInsertionBounds( Control control ) { // This doesn't take horizontal scrolling into affect. // see https://bugs.eclipse.org/bugs/show_bug.cgi?id=204599 CCombo combo = (CCombo) control; int position = combo.getSelection( ).y; String contents = ChartUIUtil.getText( combo ); GC gc = new GC( combo ); gc.setFont( combo.getFont( ) ); Point extent = gc.textExtent( contents.substring( 0, Math.min( position, contents.length( ) ) ) ); gc.dispose( ); if ( COMPUTE_TEXT_USING_CLIENTAREA ) { return new Rectangle( combo.getClientArea( ).x + extent.x, combo.getClientArea( ).y, 1, combo.getClientArea( ).height ); } return new Rectangle( extent.x, 0, 1, combo.getSize( ).y ); }
public static void setText( Control control, String text ) { if ( control instanceof Text ) { ( (Text) control ).setText( text ); } else if ( control instanceof CCombo ) { if ( text.trim( ).length( ) > 0 ) { // Fix a CCombo bug. If the text is too long and CCombo is // shorter than it, CCombo will only display the tail. text += " "; //$NON-NLS-1$ } ( (CCombo) control ).setText( text ); } else if ( control instanceof Combo ) { ( (Combo) control ).setText( text ); } }
public static ComboProxy getInstance( Control control ) { if ( control != null && !control.isDisposed( ) ) { if ( control instanceof Combo ) { return new ProxyOfCombo( (Combo) control ); } else if ( control instanceof CCombo ) { return new ProxyOfCCombo( (CCombo) control ); } } return null; }
protected void handleFormatSelectionEvent( final CCombo combo ) { int index = combo.getSelectionIndex( ); combo.select( -1 ); switch ( index ) { case 0 : String result = " format=\"HTML\""; //$NON-NLS-1$ textEditor.insert( result ); break; case 1 : insertFormat( FormatBuilder.NUMBER ); break; case 2 : insertFormat( FormatBuilder.STRING ); break; case 3 : insertFormat( FormatBuilder.DATETIME ); break; default : } textEditor.setFocus( ); }
public boolean modify( Object data, String property, Object value ) throws NameException, SemanticException { int index = Arrays.asList( columnNames ).indexOf( property ); String key = columnKeys[index]; String strValue; if ( value instanceof Integer ) { int intValue = ( (Integer) value ).intValue( ); if ( intValue == -1 ) { CCombo combo = (CCombo) editors[index].getControl( ); strValue = combo.getText( ); } else { String[] choices = modelAdapter.getChoiceSet( input.get( 0 ), columnKeys[index] ); strValue = choices[intValue]; } } else strValue = (String) value; return modelAdapter.setStringValue( input.get( 0 ), data, key, strValue ); }
public String getExpression( ) { if ( control.isDisposed( ) ) { return ""; //$NON-NLS-1$ } if ( control instanceof Text ) { return ( (Text) control ).getText( ); } else if ( control instanceof Combo ) { return ( (Combo) control ).getText( ); } else if ( control instanceof CCombo ) { return ( (CCombo) control ).getText( ); } return ""; //$NON-NLS-1$ }
@Override protected void okPressed() { GridComposite gridComposite = getGridComposite(); CCombo typeCombo = (CCombo) gridComposite.getControl(CONTROL_NAME_TYPE_COMBO); Text schemeText = (Text) gridComposite.getControl(CONTROL_NAME_SCHEME_TEXT); Text authStringText = (Text) gridComposite.getControl(CONTROL_NAME_AUTH_STRING_TEXT); AuthInfo.Type type = AuthInfo.Type.valueOf(typeCombo.getText()); String scheme = schemeText.getText(); String authString = authStringText.getText(); _AuthInfo = new AuthInfo(type, scheme, authString); super.okPressed(); }
@Override public Object doGetValue () { final int sel = ( (CCombo)getControl () ).getSelectionIndex (); if ( sel < 0 ) { return ( (CCombo)getControl () ).getText (); } else { return toString ( this.list.get ( sel ) ); } }
@Override public void doSetValue ( Object value ) { if ( value == null ) { // clear selection ( (CCombo)getControl () ).select ( -1 ); ( (CCombo)getControl () ).setText ( "" ); return; } if ( value instanceof String ) { value = fromString ( (String)value ); } final int idx = this.list.indexOf ( value ); if ( idx < 0 ) { // not found ( (CCombo)getControl () ).setText ( value.toString () ); } else { ( (CCombo)getControl () ).select ( idx ); } }
@Override public void activate(ColumnViewerEditorActivationEvent activationEvent) { super.activate(activationEvent); boolean dropDown = true; if (dropDown) { getControl().getDisplay().asyncExec(new Runnable() { public void run() { ((CCombo) getControl()).setListVisible(true); } }); } }
@Override protected Control createControl(Composite parent) { CCombo combo = (CCombo)super.createControl(parent); if (cmode.isDirectlyConnected()) { combo.addSelectionListener(new SelectionAdapter() { @Override public void widgetSelected(SelectionEvent e) { setValue(); } }); } return combo; }
protected void setValue() { try { CCombo combo = (CCombo)getControl(); if (controlNode!=null && cservice.getScannable(controlNode.getName())!=null) { String value = combo.getText(); job.setPosition(cservice.getScannable(controlNode.getName()), value); } } catch (Exception ne) { logger.error("Cannot send value to scannable "+controlNode.getName(), ne); } }
private CCombo createLabelledCombo(Composite content, String slabel) { Label label = new Label(content, SWT.NONE); label.setBackground(content.getDisplay().getSystemColor(SWT.COLOR_WHITE)); label.setText(" "+slabel+" "); label.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, false, true)); CCombo ret = new CCombo(content, SWT.READ_ONLY|SWT.BORDER); ret.setItems(getNames()); GridData fill = new GridData(SWT.FILL, SWT.CENTER, true, true); fill.widthHint=100; ret.setLayoutData(fill); return ret; }