List of usage examples for org.eclipse.jface.fieldassist ControlDecoration setShowOnlyOnFocus
public void setShowOnlyOnFocus(boolean showOnlyOnFocus)
From source file:bndtools.editor.components.ComponentDetailsPage.java
License:Open Source License
void fillMainSection(FormToolkit toolkit, Section section) { FieldDecoration contentProposalDecoration = FieldDecorationRegistry.getDefault() .getFieldDecoration(FieldDecorationRegistry.DEC_CONTENT_PROPOSAL); ControlDecoration decor; Composite composite = toolkit.createComposite(section); section.setClient(composite);/*w ww . ja v a 2 s. c o m*/ Hyperlink lnkName = toolkit.createHyperlink(composite, "Name:", SWT.NONE); txtName = toolkit.createText(composite, "", SWT.BORDER); decor = new ControlDecoration(txtName, SWT.LEFT | SWT.TOP, composite); decor.setImage(contentProposalDecoration.getImage()); decor.setDescriptionText("Content assist available"); // TODO: keystrokes decor.setShowHover(true); decor.setShowOnlyOnFocus(true); KeyStroke assistKeyStroke = null; try { assistKeyStroke = KeyStroke.getInstance("Ctrl+Space"); } catch (ParseException x) { // Ignore } ComponentNameProposalProvider proposalProvider = new ComponentNameProposalProvider( new FormPartJavaSearchContext(this)); ContentProposalAdapter proposalAdapter = new ContentProposalAdapter(txtName, new TextContentAdapter(), proposalProvider, assistKeyStroke, UIConstants.autoActivationCharacters()); proposalAdapter.addContentProposalListener(proposalProvider); proposalAdapter.setProposalAcceptanceStyle(ContentProposalAdapter.PROPOSAL_REPLACE); proposalAdapter.setAutoActivationDelay(1500); proposalAdapter.setLabelProvider(ComponentNameProposalProvider.createLabelProvider()); toolkit.createLabel(composite, ""); // Spacer btnEnabled = toolkit.createButton(composite, "Enabled", SWT.CHECK); // Listeners lnkName.addHyperlinkListener(new HyperlinkAdapter() { @Override public void linkActivated(HyperlinkEvent e) { listPart.doOpenComponent(selected.getName()); } }); txtName.addListener(SWT.Modify, new Listener() { public void handleEvent(Event event) { if (refreshers.get() == 0) { String oldName = selected.getName(); String newName = txtName.getText(); selected.setName(newName); listPart.updateLabel(oldName, newName); markDirty(PROP_COMPONENT_NAME); updateVisibility(); } } }); btnEnabled.addListener(SWT.Modify, new MarkDirtyListener(ServiceComponent.COMPONENT_ENABLED)); // Layout GridData gd; composite.setLayout(new GridLayout(2, false)); gd = new GridData(GridData.FILL_HORIZONTAL); gd.horizontalIndent = 5; txtName.setLayoutData(gd); gd = new GridData(GridData.FILL_HORIZONTAL); gd.horizontalIndent = 5; txtName.setLayoutData(gd); }
From source file:bndtools.editor.components.ComponentSvcRefWizardPage.java
License:Open Source License
public void createControl(Composite parent) { setTitle("Edit Service Reference"); KeyStroke assistKeyStroke = null; try {/*from w ww . j a v a 2 s .c om*/ assistKeyStroke = KeyStroke.getInstance("Ctrl+Space"); } catch (ParseException x) { // Ignore } FieldDecoration assistDecor = FieldDecorationRegistry.getDefault() .getFieldDecoration(FieldDecorationRegistry.DEC_CONTENT_PROPOSAL); Composite composite = new Composite(parent, SWT.NONE); new Label(composite, SWT.NONE).setText("Name:"); txtName = new Text(composite, SWT.BORDER); new Label(composite, SWT.NONE).setText("Interface:"); txtInterface = new Text(composite, SWT.BORDER); ControlDecoration decorInterface = new ControlDecoration(txtInterface, SWT.LEFT | SWT.TOP, composite); decorInterface.setImage(assistDecor.getImage()); decorInterface.setDescriptionText("Content assist available"); decorInterface.setShowHover(true); decorInterface.setShowOnlyOnFocus(true); // Add content proposal to svc interface field SvcInterfaceProposalProvider proposalProvider = new SvcInterfaceProposalProvider(searchContext); ContentProposalAdapter interfaceProposalAdapter = new ContentProposalAdapter(txtInterface, new TextContentAdapter(), proposalProvider, assistKeyStroke, UIConstants.autoActivationCharacters()); interfaceProposalAdapter.addContentProposalListener(proposalProvider); interfaceProposalAdapter.setAutoActivationDelay(1500); interfaceProposalAdapter.setProposalAcceptanceStyle(ContentProposalAdapter.PROPOSAL_REPLACE); interfaceProposalAdapter.setLabelProvider(new JavaContentProposalLabelProvider()); new Label(composite, SWT.NONE).setText("Bind:"); txtBind = new Text(composite, SWT.BORDER); ControlDecoration decorBind = new ControlDecoration(txtBind, SWT.LEFT | SWT.TOP, composite); decorBind.setImage(assistDecor.getImage()); decorBind.setDescriptionText("Content assist available"); decorBind.setShowHover(true); decorBind.setShowOnlyOnFocus(true); MethodProposalProvider bindProposalProvider = new MethodProposalProvider(searchContext); ContentProposalAdapter bindProposalAdapter = new ContentProposalAdapter(txtBind, new TextContentAdapter(), bindProposalProvider, assistKeyStroke, UIConstants.autoActivationCharacters()); bindProposalAdapter.addContentProposalListener(bindProposalProvider); bindProposalAdapter.setAutoActivationDelay(1500); bindProposalAdapter.setProposalAcceptanceStyle(ContentProposalAdapter.PROPOSAL_REPLACE); bindProposalAdapter.setLabelProvider(new MethodProposalLabelProvider()); new Label(composite, SWT.NONE).setText("Unbind:"); txtUnbind = new Text(composite, SWT.BORDER); ControlDecoration decorUnbind = new ControlDecoration(txtUnbind, SWT.LEFT | SWT.TOP, composite); decorUnbind.setImage(assistDecor.getImage()); decorUnbind.setDescriptionText("Content assist available"); decorUnbind.setShowHover(true); decorUnbind.setShowOnlyOnFocus(true); ContentProposalAdapter unbindProposalAdapter = new ContentProposalAdapter(txtUnbind, new TextContentAdapter(), bindProposalProvider, assistKeyStroke, UIConstants.autoActivationCharacters()); unbindProposalAdapter.addContentProposalListener(bindProposalProvider); unbindProposalAdapter.setAutoActivationDelay(1500); unbindProposalAdapter.setProposalAcceptanceStyle(ContentProposalAdapter.PROPOSAL_REPLACE); unbindProposalAdapter.setLabelProvider(new MethodProposalLabelProvider()); new Label(composite, SWT.NONE); // Spacer Composite pnlButtons = new Composite(composite, SWT.NONE); btnOptional = new Button(pnlButtons, SWT.CHECK); btnOptional.setText("Optional"); btnMultiple = new Button(pnlButtons, SWT.CHECK); btnMultiple.setText("Multiple"); btnDynamic = new Button(pnlButtons, SWT.CHECK); btnDynamic.setText("Dynamic"); new Label(composite, SWT.NONE).setText("Target Filter:"); txtTargetFilter = new Text(composite, SWT.BORDER); // Initialise initialiseFields(); validate(); // Listeners ModifyListener nameAndInterfaceModifyListener = new ModifyListener() { public void modifyText(ModifyEvent e) { String name = emptyToNull(txtName.getText()); String clazz = emptyToNull(txtInterface.getText()); if (name == null) name = clazz; serviceReference.setName(name); serviceReference.setServiceClass(clazz); validate(); } }; txtName.addModifyListener(nameAndInterfaceModifyListener); txtInterface.addModifyListener(nameAndInterfaceModifyListener); txtBind.addModifyListener(new ModifyListener() { public void modifyText(ModifyEvent e) { serviceReference.setBind(emptyToNull(txtBind.getText())); validate(); } }); txtUnbind.addModifyListener(new ModifyListener() { public void modifyText(ModifyEvent e) { serviceReference.setUnbind(emptyToNull(txtUnbind.getText())); validate(); } }); btnOptional.addSelectionListener(new SelectionAdapter() { @Override public void widgetSelected(SelectionEvent e) { serviceReference.setOptional(btnOptional.getSelection()); validate(); } }); btnMultiple.addSelectionListener(new SelectionAdapter() { @Override public void widgetSelected(SelectionEvent e) { serviceReference.setMultiple(btnMultiple.getSelection()); validate(); } }); btnDynamic.addSelectionListener(new SelectionAdapter() { @Override public void widgetSelected(SelectionEvent e) { serviceReference.setDynamic(btnDynamic.getSelection()); validate(); } }); txtTargetFilter.addModifyListener(new ModifyListener() { public void modifyText(ModifyEvent e) { serviceReference.setTargetFilter(emptyToNull(txtTargetFilter.getText())); } }); // Layout GridLayout layout; layout = new GridLayout(4, false); composite.setLayout(layout); txtName.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, false, 3, 1)); txtInterface.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, false, 3, 1)); txtBind.setLayoutData(new GridData(GridData.FILL_HORIZONTAL)); txtUnbind.setLayoutData(new GridData(GridData.FILL_HORIZONTAL)); txtTargetFilter.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, false, 3, 1)); pnlButtons.setLayoutData(new GridData(SWT.LEFT, SWT.FILL, false, false, 3, 1)); layout = new GridLayout(1, true); // layout.horizontalSpacing = 0; // layout.verticalSpacing = 0; // layout.marginHeight = 0; // layout.marginWidth = 0; pnlButtons.setLayout(layout); setControl(composite); }
From source file:bndtools.editor.components.SvcInterfaceSelectionDialog.java
License:Open Source License
@Override protected Control createDialogArea(Composite parent) { Control dialogArea = super.createDialogArea(parent); FieldDecoration proposalDecoration = FieldDecorationRegistry.getDefault() .getFieldDecoration(FieldDecorationRegistry.DEC_CONTENT_PROPOSAL); KeyStroke assistKeyStroke = null; try {//from w w w. ja v a 2 s. com assistKeyStroke = KeyStroke.getInstance("Ctrl+Space"); } catch (ParseException x) { // Ignore } Text textField = getText(); ControlDecoration decor = new ControlDecoration(textField, SWT.LEFT | SWT.TOP); decor.setImage(proposalDecoration.getImage()); decor.setDescriptionText(MessageFormat.format( "Content Assist is available. Press {0} or start typing to activate", assistKeyStroke.format())); decor.setShowHover(true); decor.setShowOnlyOnFocus(true); SvcInterfaceProposalProvider proposalProvider = new SvcInterfaceProposalProvider(searchContext); ContentProposalAdapter proposalAdapter = new ContentProposalAdapter(textField, new TextContentAdapter(), proposalProvider, assistKeyStroke, UIConstants.autoActivationCharacters()); proposalAdapter.addContentProposalListener(proposalProvider); proposalAdapter.setProposalAcceptanceStyle(ContentProposalAdapter.PROPOSAL_REPLACE); proposalAdapter.setLabelProvider(new JavaContentProposalLabelProvider()); proposalAdapter.setAutoActivationDelay(1500); return dialogArea; }
From source file:bndtools.editor.contents.GeneralInfoPart.java
License:Open Source License
private void createSection(Section section, FormToolkit toolkit) { section.setText("Basic Information"); KeyStroke assistKeyStroke = null; try {//ww w.java 2 s. co m assistKeyStroke = KeyStroke.getInstance("Ctrl+Space"); } catch (ParseException x) { // Ignore } FieldDecoration contentAssistDecoration = FieldDecorationRegistry.getDefault() .getFieldDecoration(FieldDecorationRegistry.DEC_CONTENT_PROPOSAL); Composite composite = toolkit.createComposite(section); section.setClient(composite); toolkit.createLabel(composite, "Version:"); txtVersion = toolkit.createText(composite, "", SWT.BORDER); ToolTips.setupMessageAndToolTipFromSyntax(txtVersion, Constants.BUNDLE_VERSION); Hyperlink linkActivator = toolkit.createHyperlink(composite, "Activator:", SWT.NONE); txtActivator = toolkit.createText(composite, "", SWT.BORDER); ToolTips.setupMessageAndToolTipFromSyntax(txtActivator, Constants.BUNDLE_ACTIVATOR); toolkit.createLabel(composite, "Declarative Services:"); cmbComponents = new Combo(composite, SWT.READ_ONLY); // Content Proposal for the Activator field ContentProposalAdapter activatorProposalAdapter = null; ActivatorClassProposalProvider proposalProvider = new ActivatorClassProposalProvider(); activatorProposalAdapter = new ContentProposalAdapter(txtActivator, new TextContentAdapter(), proposalProvider, assistKeyStroke, UIConstants.autoActivationCharacters()); activatorProposalAdapter.addContentProposalListener(proposalProvider); activatorProposalAdapter.setProposalAcceptanceStyle(ContentProposalAdapter.PROPOSAL_REPLACE); activatorProposalAdapter.setLabelProvider(new JavaContentProposalLabelProvider()); activatorProposalAdapter.setAutoActivationDelay(1000); // Decorator for the Activator field ControlDecoration decorActivator = new ControlDecoration(txtActivator, SWT.LEFT | SWT.CENTER, composite); decorActivator.setImage(contentAssistDecoration.getImage()); decorActivator.setMarginWidth(3); if (assistKeyStroke == null) { decorActivator.setDescriptionText("Content Assist is available. Start typing to activate"); } else { decorActivator.setDescriptionText( MessageFormat.format("Content Assist is available. Press {0} or start typing to activate", assistKeyStroke.format())); } decorActivator.setShowOnlyOnFocus(true); decorActivator.setShowHover(true); // Decorator for the Components combo ControlDecoration decorComponents = new ControlDecoration(cmbComponents, SWT.LEFT | SWT.CENTER, composite); decorComponents.setImage(FieldDecorationRegistry.getDefault() .getFieldDecoration(FieldDecorationRegistry.DEC_INFORMATION).getImage()); decorComponents.setMarginWidth(3); decorComponents.setDescriptionText("Use Java annotations to detect Declarative Service Components."); decorComponents.setShowOnlyOnFocus(false); decorComponents.setShowHover(true); // Listeners txtVersion.addModifyListener(new ModifyListener() { @Override public void modifyText(ModifyEvent e) { lock.ifNotModifying(new Runnable() { @Override public void run() { addDirtyProperty(Constants.BUNDLE_VERSION); } }); } }); cmbComponents.addSelectionListener(new SelectionAdapter() { @Override public void widgetSelected(SelectionEvent e) { lock.ifNotModifying(new Runnable() { @Override public void run() { ComponentChoice old = componentChoice; int index = cmbComponents.getSelectionIndex(); if (index >= 0 && index < ComponentChoice.values().length) { componentChoice = ComponentChoice.values()[cmbComponents.getSelectionIndex()]; if (old != componentChoice) { addDirtyProperty(aQute.bnd.osgi.Constants.SERVICE_COMPONENT); addDirtyProperty(aQute.bnd.osgi.Constants.DSANNOTATIONS); if (old == null) { cmbComponents.remove(ComponentChoice.values().length); } } } } }); } }); txtActivator.addModifyListener(new ModifyListener() { @Override public void modifyText(ModifyEvent ev) { lock.ifNotModifying(new Runnable() { @Override public void run() { addDirtyProperty(Constants.BUNDLE_ACTIVATOR); } }); } }); linkActivator.addHyperlinkListener(new HyperlinkAdapter() { @Override public void linkActivated(HyperlinkEvent ev) { String activatorClassName = txtActivator.getText(); if (activatorClassName != null && activatorClassName.length() > 0) { try { IJavaProject javaProject = getJavaProject(); if (javaProject == null) return; IType activatorType = javaProject.findType(activatorClassName); if (activatorType != null) { JavaUI.openInEditor(activatorType, true, true); } } catch (PartInitException e) { ErrorDialog.openError(getManagedForm().getForm().getShell(), "Error", null, new Status(IStatus.ERROR, Plugin.PLUGIN_ID, 0, MessageFormat.format("Error opening an editor for activator class '{0}'.", activatorClassName), e)); } catch (JavaModelException e) { ErrorDialog.openError(getManagedForm().getForm().getShell(), "Error", null, new Status(IStatus.ERROR, Plugin.PLUGIN_ID, 0, MessageFormat.format( "Error searching for activator class '{0}'.", activatorClassName), e)); } } } }); activatorProposalAdapter.addContentProposalListener(new IContentProposalListener() { @Override public void proposalAccepted(IContentProposal proposal) { if (proposal instanceof JavaContentProposal) { String selectedPackageName = ((JavaContentProposal) proposal).getPackageName(); if (!model.isIncludedPackage(selectedPackageName)) { model.addPrivatePackage(selectedPackageName); } } } }); // Layout GridLayout layout = new GridLayout(2, false); layout.horizontalSpacing = 15; composite.setLayout(layout); GridData gd = new GridData(SWT.FILL, SWT.TOP, true, false); txtVersion.setLayoutData(gd); txtActivator.setLayoutData(gd); cmbComponents.setLayoutData(gd); }
From source file:bndtools.editor.pkgpatterns.PkgPatternsDetailsPage.java
License:Open Source License
public void createContents(Composite parent) { FormToolkit toolkit = getManagedForm().getToolkit(); FieldDecoration assistDecor = FieldDecorationRegistry.getDefault() .getFieldDecoration(FieldDecorationRegistry.DEC_CONTENT_PROPOSAL); KeyStroke assistKeyStroke = null; try {/*ww w . j av a2 s . co m*/ assistKeyStroke = KeyStroke.getInstance("Ctrl+Space"); } catch (ParseException x) { // Ignore } Section mainSection = toolkit.createSection(parent, Section.TITLE_BAR); mainSection.setText(title); mainComposite = toolkit.createComposite(mainSection); mainSection.setClient(mainComposite); toolkit.createLabel(mainComposite, "Pattern:"); txtName = toolkit.createText(mainComposite, "", SWT.BORDER); ControlDecoration decPattern = new ControlDecoration(txtName, SWT.LEFT | SWT.TOP, mainComposite); decPattern.setImage(assistDecor.getImage()); decPattern.setDescriptionText(MessageFormat.format( "Content assist is available. Press {0} or start typing to activate", assistKeyStroke.format())); decPattern.setShowHover(true); decPattern.setShowOnlyOnFocus(true); PkgPatternsProposalProvider proposalProvider = new PkgPatternsProposalProvider( new FormPartJavaSearchContext(this)); ContentProposalAdapter patternProposalAdapter = new ContentProposalAdapter(txtName, new TextContentAdapter(), proposalProvider, assistKeyStroke, UIConstants.autoActivationCharacters()); patternProposalAdapter.addContentProposalListener(proposalProvider); patternProposalAdapter.setProposalAcceptanceStyle(ContentProposalAdapter.PROPOSAL_IGNORE); patternProposalAdapter.setAutoActivationDelay(1000); patternProposalAdapter.setLabelProvider(new PkgPatternProposalLabelProvider()); patternProposalAdapter.addContentProposalListener(new IContentProposalListener() { public void proposalAccepted(IContentProposal proposal) { PkgPatternProposal patternProposal = (PkgPatternProposal) proposal; String toInsert = patternProposal.getContent(); int currentPos = txtName.getCaretPosition(); txtName.setSelection(patternProposal.getReplaceFromPos(), currentPos); txtName.insert(toInsert); txtName.setSelection(patternProposal.getCursorPosition()); } }); toolkit.createLabel(mainComposite, "Version:"); txtVersion = toolkit.createText(mainComposite, "", SWT.BORDER); /* * Section attribsSection = toolkit.createSection(parent, Section.TITLE_BAR | Section.TWISTIE); * attribsSection.setText("Extra Attributes"); Composite attribsComposite = * toolkit.createComposite(attribsSection); */ // Listeners txtName.addModifyListener(new ModifyListener() { public void modifyText(ModifyEvent e) { if (!modifyLock.isUnderModification()) { if (selectedClauses.size() == 1) { selectedClauses.get(0).setName(txtName.getText()); if (listPart != null) { listPart.updateLabels(selectedClauses); listPart.validate(); } markDirty(); } } } }); txtVersion.addModifyListener(new ModifyListener() { public void modifyText(ModifyEvent e) { if (!modifyLock.isUnderModification()) { String text = txtVersion.getText(); if (text.length() == 0) text = null; for (HeaderClause clause : selectedClauses) { clause.getAttribs().put(Constants.VERSION_ATTRIBUTE, text); } if (listPart != null) { listPart.updateLabels(selectedClauses); listPart.validate(); } markDirty(); } } }); // Layout GridData gd; parent.setLayout(new GridLayout()); mainSection.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, false)); mainComposite.setLayout(new GridLayout(2, false)); gd = new GridData(SWT.FILL, SWT.TOP, true, false); gd.horizontalIndent = 5; gd.widthHint = 100; txtName.setLayoutData(gd); gd = new GridData(SWT.FILL, SWT.TOP, true, false); gd.horizontalIndent = 5; gd.widthHint = 100; txtVersion.setLayoutData(gd); }
From source file:com.aptana.ruby.debug.ui.breakpoints.RubyBreakpointConditionEditor.java
License:Open Source License
/** * Creates the condition editor widgets and returns the top level control. * //from www. j ava2s . c om * @param parent * composite to embed the editor controls in * @return top level control */ public Control createControl(Composite parent) { Composite controls = SWTFactory.createComposite(parent, parent.getFont(), 2, 1, GridData.FILL_HORIZONTAL, 0, 0); fConditional = new Button(controls, SWT.CHECK); fConditional.setText(processMnemonics(PropertyPageMessages.RubyBreakpointConditionEditor_0)); fConditional.setLayoutData(new GridData(SWT.BEGINNING, SWT.CENTER, false, false)); fConditional.addSelectionListener(new SelectionAdapter() { public void widgetSelected(SelectionEvent e) { boolean checked = fConditional.getSelection(); setEnabled(checked, true); setDirty(PROP_CONDITION_ENABLED); } }); fViewer = new SourceViewer(parent, null, SWT.BORDER | SWT.V_SCROLL | SWT.H_SCROLL | SWT.LEFT_TO_RIGHT); fViewer.setEditable(false); ControlDecoration decoration = new ControlDecoration(fViewer.getControl(), SWT.TOP | SWT.LEFT); decoration.setShowOnlyOnFocus(true); FieldDecoration dec = FieldDecorationRegistry.getDefault() .getFieldDecoration(FieldDecorationRegistry.DEC_CONTENT_PROPOSAL); decoration.setImage(dec.getImage()); decoration.setDescriptionText(dec.getDescription()); GridData gd = new GridData(SWT.FILL, SWT.FILL, true, true); // set height/width hints based on font GC gc = new GC(fViewer.getTextWidget()); gc.setFont(fViewer.getTextWidget().getFont()); FontMetrics fontMetrics = gc.getFontMetrics(); // gd.heightHint = Dialog.convertHeightInCharsToPixels(fontMetrics, 10); gd.widthHint = Dialog.convertWidthInCharsToPixels(fontMetrics, 40); gc.dispose(); fViewer.getControl().setLayoutData(gd); parent.addDisposeListener(new DisposeListener() { public void widgetDisposed(DisposeEvent e) { dispose(); } }); return parent; }
From source file:com.astra.ses.spell.gui.views.controls.input.PromptField.java
License:Open Source License
/*************************************************************************** * Create decoration for the input field **************************************************************************/ private void createDecoration() { // Field decoration ControlDecoration deco = new ControlDecoration(m_contents, SWT.LEFT); deco.setDescriptionText("Use CTRL+Space to see the possible commands"); deco.setImage(FieldDecorationRegistry.getDefault() .getFieldDecoration(FieldDecorationRegistry.DEC_INFORMATION).getImage()); deco.setShowOnlyOnFocus(false); deco.setShowHover(true);// w w w . j a va 2 s. c o m KeyStroke keyStroke; ArrayList<String> possibleCommandsList = new ArrayList<String>(); for (GuiExecutorCommand cmd : GuiExecutorCommand.values()) { possibleCommandsList.add(cmd.label.toLowerCase()); } String[] possibleCommands = possibleCommandsList.toArray(new String[0]); char[] autoActivationCharacters = new char[0]; IContentProposalProvider provider = new SimpleContentProposalProvider(possibleCommands); try { keyStroke = KeyStroke.getInstance("Ctrl+Space"); new ContentProposalAdapter(m_contents, new TextContentAdapter(), provider, keyStroke, autoActivationCharacters); } catch (Exception ex) { ex.printStackTrace(); } }
From source file:com.dubture.composer.ui.editor.composer.GeneralSection.java
private void createTypeEntry(Composite client, FormToolkit toolkit) { typeEntry = new FormEntry(client, toolkit, "Type", null, false); typeEntry.setValue(composerPackage.getType(), true); ControlDecoration decoration = new ControlDecoration(typeEntry.getText(), SWT.TOP | SWT.LEFT); FieldDecoration indicator = FieldDecorationRegistry.getDefault() .getFieldDecoration(FieldDecorationRegistry.DEC_CONTENT_PROPOSAL); decoration.setImage(indicator.getImage()); decoration.setDescriptionText(indicator.getDescription() + "(Ctrl+Space)"); decoration.setShowOnlyOnFocus(true); new AutoCompleteField(typeEntry.getText(), new TextContentAdapter(), ComposerConstants.TYPES); typeEntry.addFormEntryListener(new FormEntryAdapter() { public void textValueChanged(FormEntry entry) { composerPackage.set("type", entry.getValue()); }//w w w . j av a 2s .c o m }); composerPackage.addPropertyChangeListener("type", new PropertyChangeListener() { public void propertyChange(PropertyChangeEvent e) { typeEntry.setValue(composerPackage.getType(), true); } }); }
From source file:com.dubture.composer.ui.editor.composer.GeneralSection.java
private void createLicenseEntry(Composite client, FormToolkit toolkit) { licenseEntry = new FormEntry(client, toolkit, "License", null, false); ControlDecoration decoration = new ControlDecoration(licenseEntry.getText(), SWT.TOP | SWT.LEFT); FieldDecoration indicator = FieldDecorationRegistry.getDefault() .getFieldDecoration(FieldDecorationRegistry.DEC_CONTENT_PROPOSAL); decoration.setImage(indicator.getImage()); decoration.setDescriptionText(indicator.getDescription() + "(Ctrl+Space)"); decoration.setShowOnlyOnFocus(true); new AutoCompleteField(licenseEntry.getText(), new LicenseContentAdapter(), ComposerConstants.LICENSES); final License2StringConverter converter = new License2StringConverter(); licenseEntry.setValue(converter.convert(composerPackage.getLicense()), true); licenseEntry.addFormEntryListener(new FormEntryAdapter() { String2LicenseConverter converter; public void focusGained(FormEntry entry) { converter = new String2LicenseConverter(composerPackage); }//from w w w .java 2 s. c o m public void focusLost(FormEntry entry) { converter.convert(entry.getValue()); } }); composerPackage.addPropertyChangeListener(new PropertyChangeListener() { public void propertyChange(PropertyChangeEvent e) { if (e.getPropertyName().startsWith("license")) { licenseEntry.setValue(converter.convert(composerPackage.getLicense()), true); } } }); }
From source file:com.dubture.composer.ui.wizard.project.BasicSettingsGroup.java
public void createControl(Composite composite, Shell shell) { this.shell = shell; nameComposite = new Composite(composite, SWT.NONE); nameComposite.setFont(composite.getFont()); nameComposite.setLayout(new GridLayout(2, false)); nameComposite.setLayoutData(new GridData(GridData.FILL_HORIZONTAL)); // text field for project vendor name vendorField = new StringDialogField(); vendorField.setLabelText("Vendor name"); vendorField.setDialogFieldListener(this); vendorField.doFillIntoGrid(nameComposite, 2); LayoutUtil.setHorizontalGrabbing(vendorField.getTextControl(null)); // text field for project type typeField = new StringDialogField(); typeField.setLabelText("Type"); typeField.setDialogFieldListener(this); typeField.doFillIntoGrid(nameComposite, 2); LayoutUtil.setHorizontalGrabbing(typeField.getTextControl(null)); ControlDecoration decoration = new ControlDecoration(typeField.getTextControl(), SWT.TOP | SWT.LEFT); FieldDecoration indicator = FieldDecorationRegistry.getDefault() .getFieldDecoration(FieldDecorationRegistry.DEC_CONTENT_PROPOSAL); decoration.setImage(indicator.getImage()); decoration.setDescriptionText(indicator.getDescription() + "(Ctrl+Space)"); decoration.setShowOnlyOnFocus(true); new AutoCompleteField(typeField.getTextControl(), new TextContentAdapter(), ComposerConstants.TYPES); // text field for project description descriptionField = new StringDialogField(); descriptionField.setLabelText("Description"); descriptionField.setDialogFieldListener(this); descriptionField.doFillIntoGrid(nameComposite, 2); LayoutUtil.setHorizontalGrabbing(descriptionField.getTextControl(null)); // text field for project description keywordField = new StringDialogField(); keywordField.setLabelText("Keywords"); keywordField.setDialogFieldListener(this); keywordField.doFillIntoGrid(nameComposite, 2); LayoutUtil.setHorizontalGrabbing(keywordField.getTextControl(null)); // text field for project description licenseField = new StringDialogField(); licenseField.setLabelText("License"); licenseField.setDialogFieldListener(this); licenseField.doFillIntoGrid(nameComposite, 2); LayoutUtil.setHorizontalGrabbing(licenseField.getTextControl(null)); ControlDecoration licenseDecoration = new ControlDecoration(licenseField.getTextControl(), SWT.TOP | SWT.LEFT);//w w w.j ava2 s .c o m licenseDecoration.setImage(indicator.getImage()); licenseDecoration.setDescriptionText(indicator.getDescription() + "(Ctrl+Space)"); licenseDecoration.setShowOnlyOnFocus(true); new AutoCompleteField(licenseField.getTextControl(), new LicenseContentAdapter(), ComposerConstants.LICENSES); }