List of usage examples for org.eclipse.jface.viewers ComboViewer setLabelProvider
@Override public void setLabelProvider(IBaseLabelProvider labelProvider)
Viewer
framework method ensures that the given label provider is an instance of ILabelProvider
. From source file:org.svenk.redmine.ui.wizard.querypage.RedmineQueryPage.java
License:Open Source License
private void createListGroup(final Composite parent) { LabelProvider labelProvider = new RedmineLabelProvider(); Collection<SearchField> searchFields = new ArrayList<SearchField>(); for (SearchField searchField : SearchField.values()) { if (!searchField.isListType() || searchField.isGeneric()) { continue; }//w ww . j a va 2 s . c o m searchFields.add(searchField); ListViewer list = new ListViewer(parent, SWT.BORDER | SWT.MULTI | SWT.V_SCROLL); list.setLabelProvider(labelProvider); list.setContentProvider(new RedmineContentProvider()); list.getControl().setEnabled(false); lstSearchValues.put(searchField, list); ComboViewer combo = new ComboViewer(parent, SWT.READ_ONLY | SWT.DROP_DOWN); String defaultValue = searchField.isRequired() ? null : OPERATOR_TITLE; combo.setContentProvider(new RedmineContentProvider(defaultValue)); combo.setLabelProvider(labelProvider); searchOperators.put(searchField, combo); combo.setInput(searchField.getCompareOperators()); combo.setSelection(new StructuredSelection(combo.getElementAt(0))); combo.addSelectionChangedListener( new RedmineCompareOperatorSelectionListener(lstSearchValues.get(searchField).getControl())); } RedmineGuiHelper.placeListElements(parent, 4, searchFields, lstSearchValues, searchOperators); }
From source file:org.svenk.redmine.ui.wizard.querypage.RedmineQueryPage.java
License:Open Source License
private void updateCustomFieldFilter(String listDataKey) { LabelProvider labelProvider = new RedmineLabelProvider(); List<RedmineCustomField> customFields = listData.get(listDataKey).getCustomTicketFields(); List<IRedmineQueryField> lstKeys = new ArrayList<IRedmineQueryField>(lstCustomSearchValues.keySet()); List<IRedmineQueryField> txtKeys = new ArrayList<IRedmineQueryField>(txtCustomSearchValues.keySet()); Collection<Composite> oldComposites = new ArrayList<Composite>(2); for (Control child : customComposite.getChildren()) { if (child instanceof Composite) { oldComposites.add((Composite) child); }/* w w w . j av a2s.c o m*/ } if (customFields != null) { for (RedmineCustomField customField : customFields) { if (!customField.isSupportFilter()) { continue; } Control control = null; ComboViewer combo = null; SearchField searchfield = null; switch (customField.getType()) { case LIST: { ListViewer list = null; if (lstKeys.remove(customField)) { list = lstCustomSearchValues.get(customField); control = list.getControl(); } else { list = new ListViewer(customComposite, SWT.BORDER | SWT.MULTI | SWT.V_SCROLL); list.setLabelProvider(labelProvider); list.setContentProvider(new RedmineContentProvider()); control = list.getControl(); lstCustomSearchValues.put(customField, list); searchfield = SearchField.fromCustomTicketField(customField); } list.setInput(customField.getListValues()); break; } case BOOL: { if (txtKeys.remove(customField)) { control = txtCustomSearchValues.get(customField); } else { txtKeys.remove(customField); Text text = new Text(customComposite, SWT.NONE); text.setText(OPERATOR_BOOLEAN_TRUE); text.setEditable(false); txtCustomSearchValues.put(customField, text); control = text; searchfield = SearchField.fromCustomTicketField(customField); } break; } case STRING: case TEXT: case INT: case DATE: case FLOAT: { if (txtKeys.remove(customField)) { control = txtCustomSearchValues.get(customField); } else { txtKeys.remove(customField); Text text = new Text(customComposite, SWT.BORDER); txtCustomSearchValues.put(customField, text); control = text; searchfield = SearchField.fromCustomTicketField(customField); } break; } } if (searchfield == null) { combo = customSearchOperators.get(customField); combo.getControl().setParent(customComposite); control.setParent(customComposite); } else { control.setEnabled(false); if (customSearchOperators.containsKey(customField)) { customSearchOperators.remove(customField).getControl().dispose(); } combo = new ComboViewer(customComposite, SWT.READ_ONLY | SWT.DROP_DOWN); combo.setContentProvider(new RedmineContentProvider(OPERATOR_TITLE)); combo.setLabelProvider(labelProvider); combo.setInput(searchfield.getCompareOperators()); combo.setSelection(new StructuredSelection(combo.getElementAt(0))); combo.addSelectionChangedListener(new RedmineCompareOperatorSelectionListener(control)); customSearchOperators.put(customField, combo); } } } for (Composite old : oldComposites) { old.dispose(); } for (IRedmineQueryField field : lstKeys) { lstCustomSearchValues.remove(field); customSearchOperators.remove(field); } for (IRedmineQueryField field : txtKeys) { txtCustomSearchValues.remove(field); customSearchOperators.remove(field); } RedmineGuiHelper.placeListElements(customComposite, 4, lstCustomSearchValues.keySet(), lstCustomSearchValues, customSearchOperators); RedmineGuiHelper.placeTextElements(customComposite, txtCustomSearchValues.keySet(), txtCustomSearchValues, customSearchOperators); }
From source file:org.svenk.redmine.ui.wizard.RedmineRepositorySettingsPage.java
License:Open Source License
@Override protected void createAdditionalControls(Composite parent) { new Label(parent, SWT.NONE).setText(Messages.RedmineRepositorySettingsPage_CLIENT_IMPL_TITLE); ComboViewer clientImplViewer = new ComboViewer(parent, SWT.READ_ONLY); clientImplViewer.setLabelProvider(new LabelProvider() { @Override/*from w ww . j a v a2s. c o m*/ public String getText(Object element) { if (element instanceof IExtension) { return ((IExtension) element).getLabel(); } return super.getText(element); } }); clientImplViewer.addSelectionChangedListener(new ISelectionChangedListener() { public void selectionChanged(SelectionChangedEvent event) { clientImplClassName = null; if (getWizard() != null) { getWizard().getContainer().updateButtons(); } ISelection selection = event.getSelection(); if (selection instanceof IStructuredSelection) { Object obj = ((IStructuredSelection) event.getSelection()).getFirstElement(); if (obj != null && obj instanceof IExtension) { IExtension extension = (IExtension) obj; Class<? extends IRedmineClient> clazz = implementationFromExtension(extension); if (clazz != null) { clientImplClassName = clazz.getName(); } requiredVersion = versionFromExtension(extension); } } } }); IExtensionPoint extPoint = Platform.getExtensionRegistry().getExtensionPoint(EXTENSION_POINT_CLIENT); clientImplViewer.add(Messages.RedmineRepositorySettingsPage_CLIENT_IMPL_DO_SELECT); clientImplViewer.add(extPoint.getExtensions()); clientImplViewer.getCombo().select(0); //reselect old setting if (clientImplClassName != null) { for (int i = extPoint.getExtensions().length - 1; i >= 0; i--) { IExtension extension = extPoint.getExtensions()[i]; Class<? extends IRedmineClient> clazz = implementationFromExtension(extension); if (clazz != null && clazz.getName().equals(clientImplClassName)) { clientImplViewer.getCombo().select(i + 1); requiredVersion = versionFromExtension(extension); break; } } if (clientImplViewer.getCombo().getSelectionIndex() == 0) { clientImplClassName = null; } } else if (extPoint.getExtensions().length == 1) { //select first implementation, if only this one exists IExtension extension = extPoint.getExtensions()[0]; Class<? extends IRedmineClient> clazz = implementationFromExtension(extension); if (clazz != null) { clientImplClassName = clazz.getName(); clientImplViewer.getCombo().select(1); requiredVersion = versionFromExtension(extension); } } }
From source file:org.symbian.tools.tmw.internal.ui.wizard.NewApplicationDetailsWizardPage.java
License:Open Source License
public void createControl(Composite parent) { Composite root = new Composite(parent, SWT.NONE); initializeDialogUnits(parent);//from w w w . j a v a2s. co m PlatformUI.getWorkbench().getHelpSystem().setHelp(root, IIDEHelpContextIds.NEW_PROJECT_WIZARD_PAGE); WizardPageSupport.create(this, bindingContext); root.setLayout(new GridLayout(2, false)); createProjectNameGroup(root); createLabel(root, ""); createLabel(root, ""); createLabel(root, "Mobile Runtime:"); ComboViewer viewer = new ComboViewer(root); viewer.setContentProvider(new ArrayContentProvider()); viewer.setLabelProvider(new LabelProvider() { @Override public String getText(Object element) { return ((IMobileWebRuntime) element).getName(); } }); viewer.setInput(TMWCore.getRuntimesManager().getAllRuntimes()); final IViewerObservableValue observeSelection = ViewersObservables.observeSingleSelection(viewer); final IObservableValue observableValue = BeansObservables.observeValue(context, WizardContext.RUNTIME); bindingContext.bindValue(observeSelection, observableValue); createLabel(root, ""); createLabel(root, ""); createLabel(root, "Application identifier:"); context.createText(root, WizardContext.WIDGET_ID, "applicatoin identifier", bindingContext, null, new RegexpValidator("[\\w]*(\\.\\w[\\w]*)*", "{0} is not a valid applicatoin ID", true)); createLabel(root, ""); createLabel(root, "This id should be unique for successful installation of application on the device"); createLabel(root, ""); createLabel(root, ""); createLabel(root, "Application name:"); context.createText(root, WizardContext.WIDGET_NAME, "application name", bindingContext, null, new RegexpValidator("[^\\w\\. ]", "Application name cannot contain {0} character", false)); createLabel(root, ""); createLabel(root, "This will be the application display name on the device"); Composite composite = new Composite(root, SWT.NONE); GridLayout gridLayout = new GridLayout(1, false); gridLayout.marginWidth = 0; composite.setLayout(gridLayout); composite.setLayoutData(new GridData(GridData.FILL, GridData.BEGINNING, true, true, 2, 1)); locationArea = new ProjectContentsLocationArea(getErrorReporter(), composite); if (context.getProjectName() != null && context.getProjectName().trim().length() > 0) { locationArea.updateProjectName(context.getProjectName()); } // Scale the button based on the rest of the dialog setButtonLayoutData(locationArea.getBrowseButton()); setPageComplete(validatePage()); // Show description on opening setErrorMessage(null); setMessage(null); setControl(root); Dialog.applyDialogFont(root); }
From source file:org.xwiki.eclipse.ui.dialogs.RenameAttachmentDialog.java
License:Open Source License
@Override protected Control createDialogArea(Composite parent) { Composite mainComposite = (Composite) super.createDialogArea(parent); GridLayoutFactory.fillDefaults().applyTo(mainComposite); Composite composite = new Composite(mainComposite, SWT.NONE); GridLayoutFactory.fillDefaults().numColumns(2).margins(10, 10).applyTo(composite); GridDataFactory.fillDefaults().align(SWT.FILL, SWT.FILL).grab(true, true).applyTo(composite); Label label = new Label(composite, SWT.NONE); label.setText("New space:"); final ComboViewer comboViewer = new ComboViewer(composite, SWT.BORDER); GridDataFactory.fillDefaults().align(SWT.FILL, SWT.CENTER).grab(true, false) .applyTo(comboViewer.getControl()); comboViewer.setContentProvider(new IStructuredContentProvider() { public Object[] getElements(Object inputElement) { XWikiEclipseSafeRunnableWithResult<List<XWikiEclipseSpaceSummary>> runnable = new XWikiEclipseSafeRunnableWithResult<List<XWikiEclipseSpaceSummary>>() { public void run() throws Exception { setResult(attachmentSummary.getDataManager().getSpaces()); }/*from www . ja v a2 s . co m*/ }; SafeRunner.run(runnable); if (runnable.getResult() != null) { String[] elements = new String[runnable.getResult().size()]; int i = 0; for (XWikiEclipseSpaceSummary spaceSummary : runnable.getResult()) { elements[i] = spaceSummary.getData().getKey(); i++; } return elements; } return new Object[0]; } public void dispose() { } public void inputChanged(Viewer viewer, Object oldInput, Object newInput) { } }); comboViewer.setLabelProvider(new LabelProvider()); comboViewer.addSelectionChangedListener(new ISelectionChangedListener() { public void selectionChanged(SelectionChangedEvent event) { IStructuredSelection selection = (IStructuredSelection) event.getSelection(); if (selection != null) { toSpace = (String) selection.getFirstElement(); } } }); comboViewer.getCombo().addModifyListener(new ModifyListener() { public void modifyText(ModifyEvent e) { toSpace = comboViewer.getCombo().getText(); } }); comboViewer.setInput(new Object()); try { comboViewer.setSelection(new StructuredSelection(attachmentSummary.getDataManager() .getPage(attachmentSummary.getData().getPageId()).getData().getSpace())); } catch (XWikiEclipseException e1) { e1.printStackTrace(); } label = new Label(composite, SWT.NONE); label.setText("New Page:"); final ComboViewer comboViewer2 = new ComboViewer(composite, SWT.BORDER); GridDataFactory.fillDefaults().align(SWT.FILL, SWT.CENTER).grab(true, false) .applyTo(comboViewer2.getControl()); comboViewer2.setContentProvider(new IStructuredContentProvider() { public Object[] getElements(Object inputElement) { XWikiEclipseSafeRunnableWithResult<List<XWikiEclipsePageSummary>> runnable = new XWikiEclipseSafeRunnableWithResult<List<XWikiEclipsePageSummary>>() { public void run() throws Exception { setResult(attachmentSummary.getDataManager().getPages(toSpace)); } }; SafeRunner.run(runnable); if (runnable.getResult() != null) { String[] elements = new String[runnable.getResult().size()]; int i = 0; for (XWikiEclipsePageSummary pageSummary : runnable.getResult()) { elements[i] = pageSummary.getData().getId().split("\\.")[1]; i++; } return elements; } return new Object[0]; } public void dispose() { } public void inputChanged(Viewer viewer, Object oldInput, Object newInput) { } }); comboViewer2.setLabelProvider(new LabelProvider()); comboViewer2.addSelectionChangedListener(new ISelectionChangedListener() { public void selectionChanged(SelectionChangedEvent event) { IStructuredSelection selection = (IStructuredSelection) event.getSelection(); if (selection != null) { toPageName = (String) selection.getFirstElement(); } } }); comboViewer2.getCombo().addModifyListener(new ModifyListener() { public void modifyText(ModifyEvent e) { toPageName = comboViewer2.getCombo().getText(); } }); comboViewer2.setInput(new Object()); comboViewer2 .setSelection(new StructuredSelection(attachmentSummary.getPageSummary().getId().split("\\.")[1])); comboViewer.addSelectionChangedListener(new ISelectionChangedListener() { public void selectionChanged(SelectionChangedEvent event) { IStructuredSelection selection = (IStructuredSelection) event.getSelection(); if (selection != null) { toSpace = (String) selection.getFirstElement(); } comboViewer2.refresh(); } }); label = new Label(composite, SWT.NONE); label.setText("New Attachment Name:"); final Text name = new Text(composite, SWT.BORDER); GridDataFactory.fillDefaults().align(SWT.FILL, SWT.CENTER).grab(true, false).applyTo(name); name.setText(attachmentSummary.getData().getFileName()); name.addModifyListener(new ModifyListener() { public void modifyText(ModifyEvent e) { tofileName = name.getText(); } }); return composite; }
From source file:org.xwiki.eclipse.ui.dialogs.RenamePageDialog.java
License:Open Source License
@Override protected Control createDialogArea(Composite parent) { Composite mainComposite = (Composite) super.createDialogArea(parent); GridLayoutFactory.fillDefaults().applyTo(mainComposite); Composite composite = new Composite(mainComposite, SWT.NONE); GridLayoutFactory.fillDefaults().numColumns(2).margins(10, 10).applyTo(composite); GridDataFactory.fillDefaults().align(SWT.FILL, SWT.FILL).grab(true, true).applyTo(composite); Label label = new Label(composite, SWT.NONE); label.setText("Wiki:"); final Combo combo = new Combo(composite, SWT.READ_ONLY | SWT.DROP_DOWN); List<XWikiEclipseWikiSummary> wikis = new ArrayList<XWikiEclipseWikiSummary>(); try {// w w w . ja v a 2s . c o m wikis = pageSummary.getDataManager().getWikis(); } catch (XWikiEclipseStorageException e) { CoreLog.logError(String.format("Error getting wikis in rename page dialog"), e); } final String[] items = new String[wikis.size()]; for (int i = 0; i < items.length; i++) { String wiki = wikis.get(i).getName(); items[i] = wiki; if (wiki.equals(pageSummary.getWiki())) { combo.select(i); } } combo.setItems(items); for (int i = 0; i < items.length; i++) { String wiki = wikis.get(i).getName(); if (wiki.equals(pageSummary.getWiki())) { combo.select(i); newWiki = pageSummary.getWiki(); } } combo.addSelectionListener(new SelectionListener() { @Override public void widgetSelected(SelectionEvent e) { newWiki = items[((Combo) e.getSource()).getSelectionIndex()]; } @Override public void widgetDefaultSelected(SelectionEvent e) { // TODO Auto-generated method stub } }); label = new Label(composite, SWT.NONE); label.setText("New space:"); final ComboViewer comboViewer = new ComboViewer(composite, SWT.BORDER); GridDataFactory.fillDefaults().align(SWT.FILL, SWT.CENTER).grab(true, false) .applyTo(comboViewer.getControl()); comboViewer.setContentProvider(new IStructuredContentProvider() { public Object[] getElements(Object inputElement) { XWikiEclipseSafeRunnableWithResult<List<XWikiEclipseSpaceSummary>> runnable = new XWikiEclipseSafeRunnableWithResult<List<XWikiEclipseSpaceSummary>>() { public void run() throws Exception { setResult(pageSummary.getDataManager().getSpaces(pageSummary.getWiki())); } }; SafeRunner.run(runnable); if (runnable.getResult() != null) { String[] elements = new String[runnable.getResult().size()]; int i = 0; for (XWikiEclipseSpaceSummary spaceSummary : runnable.getResult()) { elements[i] = spaceSummary.getName(); i++; } return elements; } return new Object[0]; } public void dispose() { // TODO Auto-generated method stub } public void inputChanged(Viewer viewer, Object oldInput, Object newInput) { // TODO Auto-generated method stub } }); comboViewer.setLabelProvider(new LabelProvider()); comboViewer.addSelectionChangedListener(new ISelectionChangedListener() { public void selectionChanged(SelectionChangedEvent event) { IStructuredSelection selection = (IStructuredSelection) event.getSelection(); if (selection != null) { newSpace = (String) selection.getFirstElement(); } } }); comboViewer.getCombo().addModifyListener(new ModifyListener() { public void modifyText(ModifyEvent e) { newSpace = comboViewer.getCombo().getText(); } }); comboViewer.setInput(new Object()); comboViewer.setSelection(new StructuredSelection(pageSummary.getSpace())); label = new Label(composite, SWT.NONE); label.setText("New name:"); final Text name = new Text(composite, SWT.BORDER); GridDataFactory.fillDefaults().align(SWT.FILL, SWT.CENTER).grab(true, false).applyTo(name); if (pageSummary.getId().indexOf('.') != -1) { String[] components = pageSummary.getId().split("\\."); name.setText(components[1]); } else { name.setText(pageSummary.getTitle()); } name.addModifyListener(new ModifyListener() { public void modifyText(ModifyEvent e) { newPageName = name.getText(); } }); return composite; }
From source file:skillpro.dialogs.AddInputOutputDialog.java
License:Open Source License
private void createButtonsComposite(Composite container) { GridDataFactory gdf = GridDataFactory.swtDefaults().align(SWT.FILL, SWT.FILL).grab(true, false).span(2, 1); final Label productLabel = new Label(container, SWT.NONE); productLabel.setText("Product: "); productLabel.setLayoutData(gdf.span(1, 2).create()); Set<Product> products = new HashSet<>(); products.addAll(SkillproService.getSkillproProvider().getProductRepo().getEntities()); for (ProductQuantity prodQuantity : existingProductQuantities) { products.remove(prodQuantity.getProduct()); }/*from ww w . j a v a2 s . c om*/ final ComboViewer productComboViewer = new ComboViewer(container); productComboViewer.getControl().setLayoutData(gdf.span(1, 2).create()); productComboViewer.setContentProvider(new ArrayContentProvider()); productComboViewer.setLabelProvider(new LabelProvider() { @Override public String getText(Object element) { return ((Product) element).getName(); } }); productComboViewer.addSelectionChangedListener(new ISelectionChangedListener() { @Override public void selectionChanged(SelectionChangedEvent event) { product = (Product) ((IStructuredSelection) productComboViewer.getSelection()).getFirstElement(); validate(); } }); productComboViewer.setInput(products); final Label quantityLabel = new Label(container, SWT.NONE); quantityLabel.setText("Quantity: "); quantityLabel.setLayoutData(gdf.span(1, 1).create()); final Text quantityText = new Text(container, SWT.BORDER); quantityText.setText(String.valueOf(quantity)); quantityText.setLayoutData(gdf.span(1, 1).create()); final Label errorLabel = new Label(container, SWT.NONE); errorLabel.setText(getMessage()); errorLabel.setForeground(getShell().getDisplay().getSystemColor(SWT.COLOR_RED)); errorLabel.setLayoutData(GridDataFactory.fillDefaults().span(2, 1).create()); quantityText.addModifyListener(new ModifyListener() { @Override public void modifyText(ModifyEvent e) { quantity = -1; try { quantity = Integer.parseInt(quantityText.getText()); } catch (NumberFormatException ex) { } if (quantity <= 0) { setMessage("Quantity has to be a positive integer"); } else { setMessage(""); } errorLabel.setText(getMessage()); validate(); } }); }
From source file:skillpro.dialogs.AddRequirementPairDialog.java
License:Open Source License
private void createResourceSkillComposite(Composite parent) { GridDataFactory gdGrab = GridDataFactory.fillDefaults().align(SWT.FILL, SWT.CENTER).copy().grab(true, false);//w w w . j a v a 2s .c om Composite resourceSkillComposite = new Composite(parent, SWT.NONE); resourceSkillComposite .setLayout(GridLayoutFactory.fillDefaults().equalWidth(false).numColumns(2).margins(3, 4).create()); resourceSkillComposite.setLayoutData(GridDataFactory.fillDefaults().grab(true, true).create()); Label resourceLabel = new Label(resourceSkillComposite, SWT.NONE); resourceLabel.setText("Resource"); resourceLabel.setLayoutData( GridDataFactory.fillDefaults().align(SWT.LEFT, SWT.CENTER).grab(false, false).create()); final ComboViewer resourceCV = new ComboViewer(resourceSkillComposite); resourceCV.getControl().setLayoutData(gdGrab.create()); resourceCV.setContentProvider(new ArrayContentProvider()); resourceCV.setLabelProvider(new LabelProvider() { @Override public String getText(Object element) { return ((Resource) element).getName(); } }); List<Resource> resourceInput = new ArrayList<>( SkillproService.getSkillproProvider().getAssetRepo().getAllAssignedResources()); for (PrePostRequirement pair : mainResourceSkill.getPrePostRequirements()) { //FIXME assuming that every pairs have a resource skill Resource existingResource = pair.getPreRequirement().getRequiredResourceSkill().getResource(); if (selectedResource == null || !selectedResource.equals(existingResource)) { resourceInput.remove(existingResource); } } resourceCV.setInput(resourceInput); if (requiredResourceSkill != null) { resourceCV.setSelection(new StructuredSelection(selectedResource)); } else if (resourceInput.size() > 0) { resourceCV.setSelection(new StructuredSelection(resourceInput.get(0))); selectedResource = resourceInput.get(0); } resourceCV.getControl().setEnabled(isRequiredRSkillEditable); Label resourceSkillLabel = new Label(resourceSkillComposite, SWT.NONE); resourceSkillLabel.setText("ResourceSkill"); resourceSkillLabel.setLayoutData( GridDataFactory.fillDefaults().align(SWT.LEFT, SWT.CENTER).grab(false, false).create()); final ComboViewer resourceSkillCV = new ComboViewer(resourceSkillComposite); resourceSkillCV.getControl().setLayoutData(gdGrab.create()); resourceSkillCV.setContentProvider(new ArrayContentProvider()); resourceSkillCV.setLabelProvider(new LabelProvider() { @Override public String getText(Object element) { return ((ResourceSkill) element).getName(); } }); final List<ResourceSkill> input = new ArrayList<>(); for (Setup setup : selectedResource.getSetups()) { input.addAll(setup.getResourceSkills()); } if (requiredResourceSkill != null) { resourceSkillCV.setSelection(new StructuredSelection(requiredResourceSkill)); } else { resourceSkillCV.setSelection(new StructuredSelection(input.get(0))); requiredResourceSkill = input.get(0); } resourceSkillCV.setInput(input); if (requiredResourceSkill != null) { resourceSkillCV.setSelection(new StructuredSelection(requiredResourceSkill)); } else if (input.size() > 0) { resourceSkillCV.setSelection(new StructuredSelection(input.get(0))); requiredResourceSkill = input.get(0); } resourceSkillCV.getControl().setEnabled(isRequiredRSkillEditable); resourceSkillCV.addSelectionChangedListener(new ISelectionChangedListener() { @Override public void selectionChanged(SelectionChangedEvent event) { requiredResourceSkill = (ResourceSkill) ((IStructuredSelection) resourceSkillCV.getSelection()) .getFirstElement(); validate(); } }); resourceCV.addSelectionChangedListener(new ISelectionChangedListener() { @Override public void selectionChanged(SelectionChangedEvent event) { selectedResource = (Resource) ((IStructuredSelection) resourceCV.getSelection()).getFirstElement(); List<ResourceConfiguration> resourceConfigInput = selectedResource != null ? new ArrayList<>(selectedResource.getResourceConfigurations()) : new ArrayList<ResourceConfiguration>(); preResourceConfigCV.setInput(resourceConfigInput); if (resourceConfigInput.size() > 0) { preResourceConfigCV.setSelection(new StructuredSelection(resourceConfigInput.get(0))); preResourceConfiguration = resourceConfigInput.get(0); } postResourceConfigCV.setInput(resourceConfigInput); if (resourceConfigInput.size() > 0) { postResourceConfigCV.setSelection(new StructuredSelection(resourceConfigInput.get(0))); postResourceConfiguration = resourceConfigInput.get(0); } input.clear(); if (selectedResource != null) { for (Setup setup : selectedResource.getSetups()) { input.addAll(setup.getResourceSkills()); } } resourceSkillCV.refresh(); resourceSkillCV.setSelection(new StructuredSelection(input.get(0))); requiredResourceSkill = input.get(0); validate(); } }); }
From source file:skillpro.dialogs.AddRequirementPairDialog.java
License:Open Source License
private void createSkillSyncComposite(Composite parent) { GridDataFactory gdGrab = GridDataFactory.fillDefaults().align(SWT.FILL, SWT.CENTER).copy().grab(true, false);//from w w w . j ava 2s . co m Composite skillSyncComposite = new Composite(parent, SWT.NONE); skillSyncComposite .setLayout(GridLayoutFactory.fillDefaults().equalWidth(false).numColumns(2).margins(3, 4).create()); skillSyncComposite.setLayoutData(GridDataFactory.fillDefaults().grab(true, true).create()); Label skillSyncLabel = new Label(skillSyncComposite, SWT.NONE); skillSyncLabel.setText("Skill Sync Type"); skillSyncLabel.setLayoutData( GridDataFactory.fillDefaults().align(SWT.LEFT, SWT.CENTER).grab(false, false).create()); final ComboViewer skillSyncCV = new ComboViewer(skillSyncComposite); skillSyncCV.getControl().setLayoutData(gdGrab.create()); skillSyncCV.setContentProvider(new ArrayContentProvider()); skillSyncCV.setLabelProvider(new LabelProvider() { @Override public String getText(Object element) { return ((SkillSynchronizationType) element).getName(); } }); final List<SkillSynchronizationType> input = new ArrayList<>(); for (SkillSynchronizationType type : SkillSynchronizationType.values()) { input.add(type); } skillSyncCV.setInput(input); if (syncType != null) { skillSyncCV.setSelection(new StructuredSelection(syncType)); } else { skillSyncCV.setSelection(new StructuredSelection(SkillSynchronizationType.NONE)); syncType = SkillSynchronizationType.NONE; } skillSyncCV.refresh(); skillSyncCV.addSelectionChangedListener(new ISelectionChangedListener() { @Override public void selectionChanged(SelectionChangedEvent event) { syncType = (SkillSynchronizationType) ((IStructuredSelection) skillSyncCV.getSelection()) .getFirstElement(); validate(); } }); }
From source file:skillpro.dialogs.AddRequirementPairDialog.java
License:Open Source License
private void createPreRequirementComposite(Composite parent) { GridDataFactory gdGrab = GridDataFactory.fillDefaults().align(SWT.FILL, SWT.CENTER).copy().grab(true, false);/*from w ww .j a va 2 s . c o m*/ Composite preRequirementComposite = new Composite(parent, SWT.NONE); preRequirementComposite.setLayout(GridLayoutFactory.fillDefaults().numColumns(2).margins(1, 1).create()); preRequirementComposite.setLayoutData(GridDataFactory.fillDefaults().grab(true, true).create()); //center label Label preRequirementLabel = new Label(preRequirementComposite, SWT.NONE); preRequirementLabel.setText("Pre-Requirement"); preRequirementLabel.setLayoutData( GridDataFactory.fillDefaults().span(2, 1).align(SWT.CENTER, SWT.CENTER).grab(true, false).create()); //ResourceConfigurationType Label resourceConfigTypeLabel = new Label(preRequirementComposite, SWT.NONE); resourceConfigTypeLabel.setText("Resource Config Type"); resourceConfigTypeLabel.setLayoutData(GridDataFactory.fillDefaults().grab(true, false).create()); final ComboViewer resourceConfigTypeCV = new ComboViewer(preRequirementComposite); resourceConfigTypeCV.getControl().setLayoutData(gdGrab.create()); resourceConfigTypeCV.setContentProvider(new ArrayContentProvider()); resourceConfigTypeCV.setLabelProvider(new LabelProvider() { @Override public String getText(Object element) { return ((RequirementResourceConfigType) element).toString(); } }); List<RequirementResourceConfigType> resourceConfigurationTypeInput = Arrays .asList(RequirementResourceConfigType.values()); resourceConfigurationTypeInput = new ArrayList<>(resourceConfigurationTypeInput); for (Iterator<RequirementResourceConfigType> iter = resourceConfigurationTypeInput.iterator(); iter .hasNext();) { RequirementResourceConfigType type = iter.next(); if (type.toString().equalsIgnoreCase("different_any") || type.toString().equalsIgnoreCase("same")) { iter.remove(); } } resourceConfigTypeCV.setInput(resourceConfigurationTypeInput); if (preResourceConfigType != null) { resourceConfigTypeCV.setSelection(new StructuredSelection(preResourceConfigType)); } else if (resourceConfigurationTypeInput.size() > 0) { resourceConfigTypeCV.setSelection(new StructuredSelection(resourceConfigurationTypeInput.get(0))); preResourceConfigType = resourceConfigurationTypeInput.get(0); } //ResourceConfiguration Label resourceConfigurationLabel = new Label(preRequirementComposite, SWT.NONE); resourceConfigurationLabel.setText("Resource Configuration"); resourceConfigurationLabel.setLayoutData(GridDataFactory.fillDefaults().grab(true, false).create()); preResourceConfigCV = new ComboViewer(preRequirementComposite); preResourceConfigCV.getControl().setLayoutData(gdGrab.create()); preResourceConfigCV.setContentProvider(new ArrayContentProvider()); preResourceConfigCV.setLabelProvider(new LabelProvider() { @Override public String getText(Object element) { return ((ResourceConfiguration) element).getName(); } }); List<ResourceConfiguration> resourceConfigInput = requiredResourceSkill != null ? new ArrayList<>(requiredResourceSkill.getResource().getResourceConfigurations()) : new ArrayList<ResourceConfiguration>(); preResourceConfigCV.setInput(resourceConfigInput); if (preResourceConfiguration != null) { preResourceConfigCV.setSelection(new StructuredSelection(preResourceConfiguration)); } else if (resourceConfigInput.size() > 0) { preResourceConfigCV.setSelection(new StructuredSelection(resourceConfigInput.get(0))); preResourceConfiguration = resourceConfigInput.get(0); } if (preResourceConfigType != RequirementResourceConfigType.SPECIFIC) { preResourceConfigCV.getControl().setEnabled(false); } //ProductConfigurationType Label productConfigurationTypeLabel = new Label(preRequirementComposite, SWT.NONE); productConfigurationTypeLabel.setText("Product Config Type"); productConfigurationTypeLabel.setLayoutData(GridDataFactory.fillDefaults().grab(true, false).create()); final ComboViewer productConfigTypeCV = new ComboViewer(preRequirementComposite); productConfigTypeCV.getControl().setLayoutData(gdGrab.create()); productConfigTypeCV.setContentProvider(new ArrayContentProvider()); productConfigTypeCV.setLabelProvider(new LabelProvider() { @Override public String getText(Object element) { return ((RequirementProductConfigType) element).toString(); } }); List<RequirementProductConfigType> productConfigTypeInput = Arrays .asList(RequirementProductConfigType.values()); productConfigTypeInput = new ArrayList<>(productConfigTypeInput); for (Iterator<RequirementProductConfigType> iter = productConfigTypeInput.iterator(); iter.hasNext();) { RequirementProductConfigType type = iter.next(); if (type.toString().equalsIgnoreCase("same")) { iter.remove(); } } productConfigTypeCV.setInput(productConfigTypeInput); if (preProductConfigType != null) { productConfigTypeCV.setSelection(new StructuredSelection(preProductConfigType)); } else if (productConfigTypeInput.size() > 0) { productConfigTypeCV.setSelection(new StructuredSelection(productConfigTypeInput.get(0))); preProductConfigType = productConfigTypeInput.get(0); } //ProductConfiguration Label ProductConfigurationLabel = new Label(preRequirementComposite, SWT.NONE); ProductConfigurationLabel.setText("Product Configuration"); ProductConfigurationLabel .setLayoutData(GridDataFactory.fillDefaults().span(2, 1).grab(true, false).create()); String[] headers = { "Name", "Quantity" }; int[] bounds = { 100, 100 }; // input if (preProductConfiguration != null) { preProductQuantities.addAll(preProductConfiguration.getProductQuantities()); } final TableViewer preProductQuantitiesTableViewer = createTableViewer(preRequirementComposite, headers, bounds); preProductQuantitiesTableViewer.setInput(preProductQuantities); preProductQuantitiesTableViewer.getControl() .setLayoutData(GridDataFactory.fillDefaults().span(2, 1).grab(true, true).hint(0, 200).create()); // ADD Buttons Composite inputButtonsArea = new Composite(preRequirementComposite, SWT.NONE); inputButtonsArea.setLayout(GridLayoutFactory.fillDefaults().numColumns(2).create()); Button addPreProductQuantityButton = new Button(inputButtonsArea, SWT.PUSH); addPreProductQuantityButton.setText("Add"); Button deleteProductQuantityButton = new Button(inputButtonsArea, SWT.PUSH); deleteProductQuantityButton.setText("Delete"); if (preProductConfigType != RequirementProductConfigType.SPECIFIC) { preProductQuantitiesTableViewer.getControl().setEnabled(false); } //Listeners!! resourceConfigTypeCV.addSelectionChangedListener(new ISelectionChangedListener() { @Override public void selectionChanged(SelectionChangedEvent event) { preResourceConfigType = (RequirementResourceConfigType) ((IStructuredSelection) resourceConfigTypeCV .getSelection()).getFirstElement(); if (preResourceConfigType == RequirementResourceConfigType.SPECIFIC) { preResourceConfigCV.getControl().setEnabled(true); preResourceConfiguration = (ResourceConfiguration) ((IStructuredSelection) preResourceConfigCV .getSelection()).getFirstElement(); } else { preResourceConfigCV.getControl().setEnabled(false); preResourceConfiguration = null; } validate(); } }); preResourceConfigCV.addSelectionChangedListener(new ISelectionChangedListener() { @Override public void selectionChanged(SelectionChangedEvent event) { preResourceConfiguration = (ResourceConfiguration) ((IStructuredSelection) preResourceConfigCV .getSelection()).getFirstElement(); validate(); } }); productConfigTypeCV.addSelectionChangedListener(new ISelectionChangedListener() { @Override public void selectionChanged(SelectionChangedEvent event) { preProductConfigType = (RequirementProductConfigType) ((IStructuredSelection) productConfigTypeCV .getSelection()).getFirstElement(); if (preProductConfigType == RequirementProductConfigType.SPECIFIC) { preProductQuantitiesTableViewer.getControl().setEnabled(true); } else { preProductQuantitiesTableViewer.getControl().setEnabled(false); } validate(); } }); addPreProductQuantityButton.addSelectionListener(new SelectionAdapter() { @Override public void widgetSelected(SelectionEvent e) { AddInputOutputDialog dialog = new AddInputOutputDialog(getShell(), ProductDialogType.INPUT_DIALOG, preProductQuantities); if (dialog.open() == Window.OK) { for (ProductQuantity pq : dialog.getResult()) { preProductQuantities.add(pq); } preProductQuantitiesTableViewer.refresh(); validate(); } } }); deleteProductQuantityButton.addSelectionListener(new SelectionAdapter() { @Override public void widgetSelected(SelectionEvent e) { deleteSelected(preProductQuantitiesTableViewer); preProductQuantitiesTableViewer.refresh(); validate(); } }); }