List of usage examples for org.eclipse.jface.viewers LabelProvider LabelProvider
public LabelProvider()
From source file:com.netxforge.netxstudio.screens.f4.NewEditJob.java
License:Open Source License
public EMFDataBindingContext initDataBindings_() { EMFDataBindingContext bindingContext = new EMFDataBindingContext(); // JOB_STATE/*from w ww . java 2s .c om*/ EMFUpdateValueStrategy jobStateModelToTargetStrategy = new EMFUpdateValueStrategy(); jobStateModelToTargetStrategy.setConverter(new IConverter() { public Object getFromType() { return JobState.class; } public Object getToType() { return Boolean.class; } public Object convert(Object fromObject) { JobState current = (JobState) fromObject; if (current.getValue() == JobState.ACTIVE_VALUE) { return Boolean.TRUE; } else { return Boolean.FALSE; } } }); EMFUpdateValueStrategy jobStateTargetToModelStrategy = new EMFUpdateValueStrategy(); jobStateTargetToModelStrategy.setConverter(new IConverter() { public Object getFromType() { return Boolean.class; } public Object getToType() { return JobState.class; } public Object convert(Object fromObject) { Boolean current = (Boolean) fromObject; if (current) { return JobState.ACTIVE; } else { return JobState.IN_ACTIVE; } } }); IObservableValue jobStateObservable = SWTObservables.observeSelection(btnActive); IEMFValueProperty jobStateProperty = EMFEditProperties.value(editingService.getEditingDomain(), SchedulingPackage.Literals.JOB__JOB_STATE); bindingContext.bindValue(jobStateObservable, jobStateProperty.observe(job), jobStateTargetToModelStrategy, jobStateModelToTargetStrategy); // JOB_NAME EMFUpdateValueStrategy nameStrategy = ValidationService.getStrategyfactory() .strategyBeforeSetStringNotEmpty("Name is required"); IObservableValue textObserveJobName = SWTObservables.observeDelayedValue(400, SWTObservables.observeText(this.txtJobName, SWT.Modify)); IEMFValueProperty textJobNameValue = EMFProperties.value(SchedulingPackage.Literals.JOB__NAME); bindingContext.bindValue(textObserveJobName, textJobNameValue.observe(job), nameStrategy, null); // //////////////////////////////////////////////////////// // WRITABLE OBSERVABLES // All these widgets, do not directly through the model and are // therefore bound // separately for each sync direction through a WritableValue // //////////////////////////////////////////////////////// comboViewerOn.setContentProvider(new ArrayContentProvider()); comboViewerOn.setLabelProvider(new LabelProvider() { @Override public String getText(Object element) { return NonModelUtils.weekDay((Integer) element); } }); comboViewerOn.setInput(NonModelUtils.weekDaysAsInteger().toArray()); comboViewerEvery.setContentProvider(new ArrayContentProvider()); comboViewerEvery.setInput(ComboStartInput); // //////////////////////////// // OBSERVABLES THROUGH AN AGGREGATOR // ////////////////////////////// comboViewerOnWritableValue = new WritableValue(); comboViewerEveryWritableValue = new WritableValue(); cdateTimeStartTimeWritableValue = new WritableValue(); dateChooserStartsOnWritableValue = new WritableValue(); dateChooserEndsOnWritableValue = new WritableValue(); btnOnWritableValue = new WritableValue(); btnAfterWritableValue = new WritableValue(); btnNeverWritableValue = new WritableValue(); txtOccurencesWritableValue = new WritableValue(); comboViewerOnObserveSingleSelection = ViewersObservables.observeSingleSelection(comboViewerOn); comboViewerEveryObserveSingleSelection = ViewersObservables.observeSingleSelection(comboViewerEvery); comboViewerEveryObserveText = SWTObservables.observeText(comboViewerEvery.getCombo()); comboObserveStartTime = new CDateTimeObservableValue(this.cdateTimeStartTime); dateChooseObserveStartDate = new DateChooserComboObservableValue(dateChooserStartsOn, SWT.Modify); dateChooseObserveEndDate = new DateChooserComboObservableValue(dateChooserEndsOn, SWT.Modify); endOnObservable = SWTObservables.observeSelection(btnOn); endOccurencesObservable = SWTObservables.observeSelection(btnAfter); endNeverObservable = SWTObservables.observeSelection(btnNever); occurenceObservable = SWTObservables.observeDelayedValue(400, SWTObservables.observeText(this.txtOccurences, SWT.Modify)); // //////////////////////////// // OPPOSITE BINDING // /////////////////////////// bindingContext.bindValue(comboViewerOnObserveSingleSelection, comboViewerOnWritableValue, null, null); bindingContext.bindValue(comboViewerEveryObserveSingleSelection, comboViewerEveryWritableValue, null, null); bindingContext.bindValue(comboObserveStartTime, cdateTimeStartTimeWritableValue, null, null); bindingContext.bindValue(dateChooseObserveStartDate, dateChooserStartsOnWritableValue, null, null); bindingContext.bindValue(dateChooseObserveEndDate, dateChooserEndsOnWritableValue, null, null); bindingContext.bindValue(endNeverObservable, btnNeverWritableValue, null, null); bindingContext.bindValue(endOccurencesObservable, btnAfterWritableValue, null, null); bindingContext.bindValue(endOnObservable, btnOnWritableValue, null, null); EMFUpdateValueStrategy occurencesModelToTargetStrategy = new EMFUpdateValueStrategy(); occurencesModelToTargetStrategy.setConverter(new IConverter() { public Object getFromType() { return Integer.class; } public Object getToType() { return String.class; } public Object convert(Object fromObject) { if (fromObject != null) { return ((Integer) fromObject).toString(); } else { return ""; } } }); EMFUpdateValueStrategy occurencesTargetToModelStrategy = new EMFUpdateValueStrategy(); occurencesTargetToModelStrategy.setConverter(new IConverter() { public Object getFromType() { return String.class; } public Object getToType() { return Integer.class; } public Object convert(Object fromObject) { try { String from = (String) fromObject; if (from.length() == 0) { return 0; } return new Integer(from); } catch (NumberFormatException nfe) { nfe.printStackTrace(); } return 0; } }); bindingContext.bindValue(occurenceObservable, this.txtOccurencesWritableValue, occurencesTargetToModelStrategy, occurencesModelToTargetStrategy); // ///////////////////////////////////////////////// // ACTUAL MODEL BINDING // //////////////////////////////////////////////// // The following binding is indirect through a series of writableValues. // / The writables, which will be deduced from various widgets by our // aggregator. IObservableValue startTimeWritableValue = new WritableValue(); IObservableValue endTimeWritableValue = new WritableValue(); IObservableValue intervalWritableValue = new WritableValue(); IObservableValue repeatWritableValue = new WritableValue(); // The aggregator. JobInfoAggregate aggregate = new JobInfoAggregate(startTimeWritableValue, endTimeWritableValue, intervalWritableValue, repeatWritableValue); IEMFValueProperty startTimeProperty = EMFEditProperties.value(editingService.getEditingDomain(), SchedulingPackage.Literals.JOB__START_TIME); IEMFValueProperty endTimeProperty = EMFEditProperties.value(editingService.getEditingDomain(), SchedulingPackage.Literals.JOB__END_TIME); IEMFValueProperty intervalProperty = EMFEditProperties.value(editingService.getEditingDomain(), SchedulingPackage.Literals.JOB__INTERVAL); IEMFValueProperty repeatProperty = EMFEditProperties.value(editingService.getEditingDomain(), SchedulingPackage.Literals.JOB__REPEAT); // TODO, add converters and validators. IObservableValue startTimeObservableValue = startTimeProperty.observe(job); IObservableValue endTimeObservableValue = endTimeProperty.observe(job); IObservableValue intervalObservableValue = intervalProperty.observe(job); IObservableValue repeatObservableValue = repeatProperty.observe(job); // ////////////////////// // BIND OUR WRITABLES. // //////////////////// EMFUpdateValueStrategy targetToModelStrategy = new EMFUpdateValueStrategy(); targetToModelStrategy.setConverter(new DateToXMLConverter()); bindingContext.bindValue(startTimeWritableValue, startTimeObservableValue, targetToModelStrategy, null); bindingContext.bindValue(endTimeWritableValue, endTimeObservableValue, targetToModelStrategy, null); bindingContext.bindValue(intervalWritableValue, intervalObservableValue, targetToModelStrategy, null); bindingContext.bindValue(repeatWritableValue, repeatObservableValue, targetToModelStrategy, null); // Set initial values of the widgets. , without having the aggregator // activated yet. this.setInitial(startTimeObservableValue.getValue(), endTimeObservableValue.getValue(), repeatObservableValue.getValue(), intervalObservableValue.getValue()); // Set the initial values of the aggregator. aggregate.setInitialValues(job); this.enableAggregate(aggregate); // bindingContext.updateTargets(); return bindingContext; }
From source file:com.netxforge.netxstudio.screens.f4.NewEditMappingColumn.java
License:Open Source License
private void initDataBindingDataMappingColumn(EMFDataBindingContext context, IEMFValueProperty dataKindProperty) { // Metric option selected. btnMetricWritableValue = new WritableValue(); metricObservable = SWTObservables.observeSelection(btnMetricValue); context.bindValue(metricObservable, btnMetricWritableValue, null, null); // We should really observe the button. metricValueObservable = SWTObservables.observeText(txtMetric, SWT.Modify); // valuePatternObservable = SWTObservables.observeText( // this.txtMetricValuePattern, SWT.Modify); EMFUpdateValueStrategy metricModelToTargetStrategy = new EMFUpdateValueStrategy(); metricModelToTargetStrategy.setConverter(new DataKindModelToTargetConverter() { public Object convert(Object fromObject) { if (fromObject instanceof ValueDataKind) { Metric metric = ((ValueDataKind) fromObject).getMetricRef(); if (metric != null) { return metric.getName(); }//w w w . j av a 2 s . c o m } return null; } }); context.bindValue(metricValueObservable, dataKindProperty.observe(mxlsColumn), null, metricModelToTargetStrategy); cmbViewrMetricKindHint.setContentProvider(new ArrayContentProvider()); cmbViewrMetricKindHint.setLabelProvider(new LabelProvider()); cmbViewrMetricKindHint.setInput(KindHintType.VALUES); metricKindHintObservable = ViewerProperties.singleSelection().observe(cmbViewrMetricKindHint); IEMFEditValueProperty KindHintProperty = EMFEditProperties.value(editingService.getEditingDomain(), FeaturePath.fromList(MetricsPackage.Literals.MAPPING_COLUMN__DATA_TYPE, MetricsPackage.Literals.VALUE_DATA_KIND__KIND_HINT)); context.bindValue(metricKindHintObservable, KindHintProperty.observe(mxlsColumn), null, null); }
From source file:com.netxforge.netxstudio.screens.nf3.Retention.java
License:Open Source License
private void addUIRule(final Composite cmpRules, final MetricRetentionRule rule, EMFDataBindingContext context, IEMFValueProperty retentionPeriodProperty, IValueProperty cmbSelectionProperty) { final Label lblMonthlyValues = toolkit.createLabel(cmpRules, rule.getName(), SWT.NONE); lblMonthlyValues.setLayoutData(new GridData(SWT.RIGHT, SWT.CENTER, false, false, 1, 1)); final ComboViewer cmbViewerTarget = new ComboViewer(cmpRules, SWT.NONE); Combo cmbMonthly = cmbViewerTarget.getCombo(); GridData gd_cmbMonthly = new GridData(SWT.FILL, SWT.CENTER, false, false, 1, 1); gd_cmbMonthly.widthHint = 150;/*from w w w . j a v a 2s . c om*/ cmbMonthly.setLayoutData(gd_cmbMonthly); toolkit.paintBordersFor(cmbMonthly); cmbMonthly.setFocus(); final ImageHyperlink mghprlnkEditRetentionExpression = toolkit.createImageHyperlink(cmpRules, SWT.NONE); mghprlnkEditRetentionExpression.setLayoutData(new GridData(SWT.LEFT, SWT.CENTER, false, false, 1, 1)); mghprlnkEditRetentionExpression.addHyperlinkListener(new HyperlinkAdapter() { public void linkActivated(HyperlinkEvent e) { launchExpressionScreen(rule); } }); toolkit.paintBordersFor(mghprlnkEditRetentionExpression); mghprlnkEditRetentionExpression.setText("Edit retention expression"); cmbViewerTarget.setContentProvider(new ArrayContentProvider()); cmbViewerTarget.setLabelProvider(new LabelProvider()); cmbViewerTarget.setInput(MetricRetentionPeriod.values()); context.bindValue(cmbSelectionProperty.observe(cmbViewerTarget), retentionPeriodProperty.observe(rule)); }
From source file:com.netxforge.netxstudio.screens.nf3.Retention.java
License:Open Source License
private void addCustomUIRule(final Composite cmpRules, final MetricRetentionRule rule, EMFDataBindingContext context, IEMFValueProperty retentionPeriodProperty, IValueProperty cmbSelectionProperty) { // Edit the name of the rule. final Text nameText = toolkit.createText(cmpRules, ""); GridData textLayoutData = new GridData(SWT.RIGHT, SWT.CENTER, false, false, 1, 1); textLayoutData.widthHint = 100;/*from w ww . j a v a2 s . co m*/ nameText.setLayoutData(textLayoutData); nameText.setFocus(); final ISWTObservableValue observeTextName = SWTObservables.observeDelayedValue(400, SWTObservables.observeText(nameText, SWT.Modify)); final IEMFEditValueProperty nameProperty = EMFEditProperties.value(editingService.getEditingDomain(), MetricsPackage.Literals.METRIC_RETENTION_RULE__NAME); context.bindValue(observeTextName, nameProperty.observe(rule)); // Edit the interval. final Text intervalText = toolkit.createText(cmpRules, ""); final GridData intervalGridData = new GridData(SWT.RIGHT, SWT.CENTER, false, false, 1, 1); intervalText.setLayoutData(intervalGridData); final ISWTObservableValue observeTextInterval = SWTObservables.observeDelayedValue(400, SWTObservables.observeText(intervalText, SWT.Modify)); final IEMFEditValueProperty intervalModelProperty = EMFEditProperties.value( editingService.getEditingDomain(), MetricsPackage.Literals.METRIC_RETENTION_RULE__INTERVAL_HINT); context.bindValue(observeTextInterval, intervalModelProperty.observe(rule)); // Edit the retention period. final ComboViewer cmbViewerTarget = new ComboViewer(cmpRules, SWT.NONE); final Combo cmbRetentionPeriod = cmbViewerTarget.getCombo(); final GridData gridDataRetentionPeriod = new GridData(SWT.FILL, SWT.CENTER, false, false, 1, 1); gridDataRetentionPeriod.widthHint = 150; cmbRetentionPeriod.setLayoutData(gridDataRetentionPeriod); toolkit.paintBordersFor(cmbRetentionPeriod); final ImageHyperlink mghprlnkEditRetentionExpression = toolkit.createImageHyperlink(cmpRules, SWT.NONE); mghprlnkEditRetentionExpression.setLayoutData(new GridData(SWT.LEFT, SWT.CENTER, false, false, 1, 1)); mghprlnkEditRetentionExpression.addHyperlinkListener(new HyperlinkAdapter() { public void linkActivated(HyperlinkEvent e) { launchExpressionScreen(rule); } }); toolkit.paintBordersFor(mghprlnkEditRetentionExpression); mghprlnkEditRetentionExpression.setText("Edit retention expression"); final ImageHyperlink removeObjectHyperLink = toolkit.createImageHyperlink(cmpRules, SWT.NONE); removeObjectHyperLink.addHyperlinkListener(new HyperlinkAdapter() { public void linkActivated(HyperlinkEvent e) { final CompoundCommand cc = new CompoundCommand(); if (rule.eIsSet(MetricsPackage.Literals.METRIC_RETENTION_RULE__RETENTION_EXPRESSION)) { final Expression retentionExpression = rule.getRetentionExpression(); final Command deleteExpressionCommand = DeleteCommand.create(editingService.getEditingDomain(), retentionExpression); cc.append(deleteExpressionCommand); } final Command deleteRuleCommand = DeleteCommand.create(editingService.getEditingDomain(), rule); cc.append(deleteRuleCommand); editingService.getEditingDomain().getCommandStack().execute(cc); } }); final GridData removeObjectGridData = new GridData(SWT.LEFT, SWT.CENTER, false, false, 1, 1); removeObjectGridData.widthHint = 18; removeObjectHyperLink.setLayoutData(removeObjectGridData); removeObjectHyperLink .setImage(ResourceManager.getPluginImage("org.eclipse.ui", "/icons/full/etool16/delete.gif")); toolkit.paintBordersFor(removeObjectHyperLink); removeObjectHyperLink.setText(""); cmbViewerTarget.setContentProvider(new ArrayContentProvider()); cmbViewerTarget.setLabelProvider(new LabelProvider()); cmbViewerTarget.setInput(MetricRetentionPeriod.values()); context.bindValue(cmbSelectionProperty.observe(cmbViewerTarget), retentionPeriodProperty.observe(rule)); }
From source file:com.netxforge.netxstudio.screens.parts.MultiChartScreenViewer.java
License:Open Source License
@Override public boolean show(final ShowInContext context) { // Overidde to reset the viewer actions. // resetToggledActions(); // As there will be multiple chart windows, show-in is not very handy as // we won't know which one is intended or a new one. // For Show-in there for we support: // For Component => Produces a new window. final ShowInContext finalContext = context; Shell shell = getSite().getShell();//from www . j a v a 2 s. c om Menu menu = new Menu(shell, SWT.POP_UP); { MenuItem item = new MenuItem(menu, SWT.RADIO); item.setText("Merge"); item.addSelectionListener(new SelectionAdapter() { @Override public void widgetSelected(SelectionEvent e) { MenuItem item = (MenuItem) e.widget; if (item.getSelection()) { if (chartList != null && !chartList.isEmpty()) { finalContext.setInput(new ChartMergeInput()); // find a chart to merge with... ElementListSelectionDialog dialog = new ElementListSelectionDialog( MultiChartScreenViewer.this.getSite().getShell(), new LabelProvider() { @Override public String getText(Object element) { if (element instanceof ChartScreen) { StringBuilder sb = new StringBuilder(); sb.append("Chart " + chartList.indexOf(element) + ": "); sb.append(element.toString()); return sb.toString(); } return super.getText(element); } }); dialog.setElements(chartList.toArray()); dialog.setTitle("Select the chart"); // user pressed cancel if (dialog.open() == Window.OK) { Object[] result = dialog.getResult(); if (result.length == 1) { ChartScreen s = (ChartScreen) result[0]; s.handleShowIn(finalContext); } } } else { ChartScreen chartScreen = addChartScreen(); chartScreen.handleShowIn(finalContext); } } } }); } { MenuItem item = new MenuItem(menu, SWT.RADIO); item.setText("Add"); item.addSelectionListener(new SelectionAdapter() { @Override public void widgetSelected(SelectionEvent e) { MenuItem item = (MenuItem) e.widget; if (item.getSelection()) { ChartScreen chartScreen = addChartScreen(); chartScreen.handleShowIn(finalContext); } } }); } menu.setEnabled(true); menu.setVisible(true); // Process merge/replace. return true; }
From source file:com.nokia.carbide.cdt.internal.api.builder.ui.MMPSelectionUI.java
License:Open Source License
/** * Create the composite/* w ww. j av a 2s . c o m*/ * @param parent * @param style */ public MMPSelectionUI(Composite parent, int style, IRunnableContext runnableContext) { super(parent, style); this.runnableContext = runnableContext; // layout self final GridLayout gridLayout = new GridLayout(); gridLayout.numColumns = 2; gridLayout.marginBottom = 5; gridLayout.marginRight = 10; gridLayout.marginLeft = 10; setLayout(gridLayout); // viewer viewer = CheckboxTableViewer.newCheckList(this, SWT.BORDER | SWT.SINGLE | SWT.FULL_SELECTION); viewer.setContentProvider(new ArrayContentProvider()); viewer.setLabelProvider(new LabelProvider()); Table table = viewer.getTable(); table.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true)); table.setData(AUTOTEST_UID, "table"); //$NON-NLS-1$ // build order column TableColumn buildOrderColumn = new TableColumn(table, SWT.NONE); // alignment ignored when checkboxes in column buildOrderColumn.setText(Messages.getString("MMPSelectionUI.BuildOrderColumnLabel")); //$NON-NLS-1$ buildOrderColumn.addSelectionListener(new SelectionAdapter() { public void widgetSelected(SelectionEvent e) { updateSortDirection(BUILD_ORDER_COLUMN); ViewerComparator comparator = getViewerComparator(BUILD_ORDER_COLUMN); viewer.setComparator(comparator); setColumnSorting((TableColumn) e.getSource(), sortDirection); } }); buildOrderColumn.setData(AUTOTEST_UID, "buildOrderColumn"); //$NON-NLS-1$ // file name column TableColumn fileNameColumn = new TableColumn(table, SWT.LEFT); fileNameColumn.setText(Messages.getString("MMPSelectionUI.FileNameColumnLabel")); //$NON-NLS-1$ fileNameColumn.addSelectionListener(new SelectionAdapter() { public void widgetSelected(SelectionEvent e) { updateSortDirection(FILENAME_COLUMN); ViewerComparator comparator = getViewerComparator(FILENAME_COLUMN); viewer.setComparator(comparator); setColumnSorting((TableColumn) e.getSource(), sortDirection); } }); fileNameColumn.setData(AUTOTEST_UID, "fileNameColumn"); //$NON-NLS-1$ // location column final TableColumn locationColumn = new TableColumn(table, SWT.LEFT); locationColumn.setText(Messages.getString("MMPSelectionUI.LocationColumnLabel")); //$NON-NLS-1$ locationColumn.addSelectionListener(new SelectionAdapter() { public void widgetSelected(SelectionEvent e) { updateSortDirection(LOCATION_COLUMN); ViewerComparator comparator = getViewerComparator(LOCATION_COLUMN); viewer.setComparator(comparator); setColumnSorting((TableColumn) e.getSource(), sortDirection); } }); locationColumn.setData(AUTOTEST_UID, "locationColumn"); //$NON-NLS-1$ setColumnSorting(buildOrderColumn, sortDirection); table.setHeaderVisible(true); // listen to checks viewer.addCheckStateListener(new ICheckStateListener() { public void checkStateChanged(CheckStateChangedEvent event) { FileInfo info = (FileInfo) event.getElement(); info.setChecked(event.getChecked()); fireSelectionChanged(); } }); // listen to double clicks viewer.addDoubleClickListener(new IDoubleClickListener() { public void doubleClick(DoubleClickEvent event) { IStructuredSelection selection = (IStructuredSelection) event.getSelection(); for (Iterator iterator = selection.iterator(); iterator.hasNext();) { FileInfo info = (FileInfo) iterator.next(); info.setChecked(!info.isChecked()); viewer.setChecked(info, info.isChecked()); fireSelectionChanged(); } } }); // select all/deselect all buttons final Composite composite = new Composite(this, SWT.NONE); composite.setLayoutData(new GridData(SWT.LEFT, SWT.FILL, false, false)); composite.setLayout(new GridLayout()); selectAllButton = new Button(composite, SWT.NONE); selectAllButton.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, false, false)); selectAllButton.setText(Messages.getString("MMPSelectionUI.SelectAllLabel")); //$NON-NLS-1$ selectAllButton.addSelectionListener(new SelectionAdapter() { @Override public void widgetSelected(SelectionEvent e) { setAllChecked(true); } }); selectAllButton.setData(AUTOTEST_UID, "selectAllButton"); //$NON-NLS-1$ deselectAllButton = new Button(composite, SWT.NONE); deselectAllButton.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, false, false)); deselectAllButton.setText(Messages.getString("MMPSelectionUI.DeselectAllLabel")); //$NON-NLS-1$ deselectAllButton.addSelectionListener(new SelectionAdapter() { @Override public void widgetSelected(SelectionEvent e) { setAllChecked(false); } }); deselectAllButton.setData(AUTOTEST_UID, "deselectAllButton"); //$NON-NLS-1$ // exclude extension makefiles check box excludeExtensionMakefilesCheckbox = new Button(this, SWT.CHECK); excludeExtensionMakefilesCheckbox.setLayoutData(new GridData(SWT.LEFT, SWT.CENTER, false, false, 2, 1)); excludeExtensionMakefilesCheckbox.setText(Messages.getString("MMPSelectionUI.ExcludeExtMakefilesLabel")); //$NON-NLS-1$ excludeExtensionMakefilesCheckbox.addSelectionListener(new SelectionAdapter() { @Override public void widgetSelected(SelectionEvent e) { boolean exclude = ((Button) e.getSource()).getSelection(); if (extMakFileFilter == null) { extMakFileFilter = new ViewerFilter() { @Override public boolean select(Viewer viewer, Object parentElement, Object element) { FileInfo info = (FileInfo) element; boolean select = info.isMMP(); if (!select) info.setChecked(false); return select; } }; } if (exclude) { viewer.addFilter(extMakFileFilter); fireSelectionChanged(); } else { viewer.removeFilter(extMakFileFilter); } updateCheckedStateFromViewer(); } }); excludeExtensionMakefilesCheckbox.setData(AUTOTEST_UID, "excludeExtensionMakefilesCheckbox"); //$NON-NLS-1$ // exclude test components checkbox excludeTestComponentsCheckbox = new Button(this, SWT.CHECK); excludeTestComponentsCheckbox.setLayoutData(new GridData(SWT.LEFT, SWT.CENTER, false, false, 2, 1)); excludeTestComponentsCheckbox.setText(Messages.getString("MMPSelectionUI.ExcludeTestCompsLabel")); //$NON-NLS-1$ excludeTestComponentsCheckbox.addSelectionListener(new SelectionAdapter() { @Override public void widgetSelected(SelectionEvent e) { boolean exclude = ((Button) e.getSource()).getSelection(); if (testFileFilter == null) { testFileFilter = new ViewerFilter() { @Override public boolean select(Viewer viewer, Object parentElement, Object element) { FileInfo info = (FileInfo) element; boolean select = !info.isTest(); if (!select) info.setChecked(false); return select; } }; } if (exclude) { viewer.addFilter(testFileFilter); fireSelectionChanged(); } else { viewer.removeFilter(testFileFilter); } updateCheckedStateFromViewer(); } }); excludeTestComponentsCheckbox.setData(AUTOTEST_UID, "excludeTestComponentsCheckbox"); //$NON-NLS-1$ }
From source file:com.nokia.carbide.cpp.internal.api.sdk.ui.SBSv2PlatformFilterComposite.java
License:Open Source License
public void createControls() { GridLayout gridLayout = new GridLayout(); gridLayout.numColumns = 2;//from ww w. j a va 2s .com setLayout(gridLayout); GridData gd = new GridData(SWT.LEFT, SWT.LEFT, true, false); gd.widthHint = 200; gd.heightHint = 350; Label aliasBoxLabel = new Label(this, SWT.NONE); aliasBoxLabel.setText(Messages.getString("SBSv2PlatformFilterComposite.PlatformsGroupText")); aliasBoxLabel.setToolTipText(Messages.getString("SBSv2PlatformFilterComposite.PlatformsGroupToolTip")); Label variantBoxLabel = new Label(this, SWT.NONE); variantBoxLabel.setText(Messages.getString("SBSv2PlatformFilterComposite.ProductsGroupText")); variantBoxLabel.setToolTipText(Messages.getString("SBSv2PlatformFilterComposite.ProductsGroupToolTip")); buildAliasTableViewer = CheckboxTableViewer.newCheckList(this, SWT.BORDER); buildAliasTableViewer.getTable().setLayoutData(gd); buildAliasTableViewer.setContentProvider(new ArrayContentProvider()); buildAliasTableViewer.setLabelProvider(new LabelProvider()); customVariantListViewer = new ListViewer(this); customVariantListViewer.getList().setLayoutData(gd); customVariantListViewer.setContentProvider(new ArrayContentProvider()); customVariantListViewer.setLabelProvider(new LabelProvider()); customVariantListViewer.addSelectionChangedListener(new ISelectionChangedListener() { public void selectionChanged(SelectionChangedEvent event) { if (customVariantListViewer.getSelection() != null && !customVariantListViewer.getSelection().isEmpty()) { removeVariantButton.setEnabled(true); } else { removeVariantButton.setEnabled(false); } } }); refreshButton = new Button(this, SWT.NONE); refreshButton.setText(Messages.getString("SBSv2PlatformFilterComposite.RefreshButtonText")); //$NON-NLS-1$ refreshButton.setToolTipText(Messages.getString("SBSv2PlatformFilterComposite.RefreshButtonToolTip")); //$NON-NLS-1$ refreshButton.addSelectionListener(new SelectionListener() { public void widgetDefaultSelected(SelectionEvent e) { widgetSelected(e); } public void widgetSelected(SelectionEvent e) { refreshButton.setEnabled(false); refreshButton.setText(Messages.getString("SBSv2PlatformFilterComposite.RefreshButtonScanningText")); //$NON-NLS-1$ // for (ISymbianSDK sdk : SDKCorePlugin.getSDKManager().getSDKList()){ // ((SBSv2BuildInfo)sdk.getBuildInfo(ISymbianBuilderID.SBSV2_BUILDER)).clearDataFromBuildCache(); // } SBSv2QueryUtils.removeAllCachedQueries(); refreshLocalSBSCacheData(); SBSv2QueryUtils.flushAllSBSv2Caches(); refreshButton.setText(Messages.getString("SBSv2PlatformFilterComposite.RefreshButtonText")); //$NON-NLS-1$ refreshButton.setEnabled(true); } }); Composite variantButtonsComposite = new Composite(this, SWT.NONE); gridLayout = new GridLayout(); gridLayout.makeColumnsEqualWidth = true; gridLayout.numColumns = 2; variantButtonsComposite.setLayout(gridLayout); GridData gridData = new GridData(SWT.LEFT, SWT.TOP, true, false); variantButtonsComposite.setLayoutData(gridData); addVariantButton = new Button(variantButtonsComposite, SWT.NONE); addVariantButton.setText(Messages.getString("SBSv2PlatformFilterComposite.AddProductButtonText")); //$NON-NLS-1$ addVariantButton.setToolTipText(Messages.getString("SBSv2PlatformFilterComposite.AddProductButtonToolTip")); //$NON-NLS-1$ addVariantButton.setLayoutData(gridData); addVariantButton.addSelectionListener(new SelectionListener() { public void widgetDefaultSelected(SelectionEvent e) { widgetSelected(e); } public void widgetSelected(SelectionEvent e) { if (aliasMap.size() == 0) { MessageDialog.openError(getShell(), "No build configurations found.", "No build configurations (aliases) were found from any SDKs. Attempted 'sbs --query=aliases' but found no results."); } else if (productVariantList.size() == 0) { MessageDialog.openError(getShell(), "No products found.", "No products were found from any SDKs. Attempted 'sbs --query=products' but found no results."); } else { String selectedAlias = ""; ISelection selectedItem = buildAliasTableViewer.getSelection(); StructuredSelection selection = (StructuredSelection) selectedItem; String stringSelection = (String) selection.getFirstElement(); if (stringSelection != null) { TableItem[] tableItems = buildAliasTableViewer.getTable().getItems(); for (TableItem item : tableItems) { if (stringSelection.equals(item.getText())) { selectedAlias = item.getText(); break; } } } AddSBSv2ProductVariant addVariantDlg = new AddSBSv2ProductVariant(getShell(), selectedAlias, aliasMap, productVariantList); if (addVariantDlg.open() == TrayDialog.OK) { if (customVariantListViewer.testFindItem(addVariantDlg.getUserCreatedVariant()) == null) { // doesn't exist, add it. if it does exist just ignore it List<String> variantList = (List<String>) customVariantListViewer.getInput(); variantList.add(addVariantDlg.getUserCreatedVariant()); customVariantListViewer.setInput(variantList); customVariantListViewer.refresh(); } } } } }); removeVariantButton = new Button(variantButtonsComposite, SWT.NONE); removeVariantButton.setText(Messages.getString("SBSv2PlatformFilterComposite.RemoveProductButtonText")); //$NON-NLS-1$ removeVariantButton .setToolTipText(Messages.getString("SBSv2PlatformFilterComposite.RemoveProductButtonToolTip")); //$NON-NLS-1$ removeVariantButton.setLayoutData(gridData); removeVariantButton.setEnabled(false); removeVariantButton.addSelectionListener(new SelectionListener() { public void widgetDefaultSelected(SelectionEvent e) { widgetSelected(e); } public void widgetSelected(SelectionEvent e) { ISelection selectedVariant = customVariantListViewer.getSelection(); if (selectedVariant != null) { StructuredSelection selection = (StructuredSelection) selectedVariant; String stringSelection = (String) selection.getFirstElement(); List<String> data = (List<String>) customVariantListViewer.getInput(); data.remove(stringSelection); customVariantListViewer.setInput(data); customVariantListViewer.refresh(true); removeVariantButton.setEnabled(false); } } }); initTable(); addListeners(); }
From source file:com.nokia.carbide.cpp.internal.project.ui.mmpEditor.dialogs.CapabilitiesDialog.java
License:Open Source License
/** * Create contents of the dialog// ww w . j a v a2s .com * @param parent */ @Override protected Control createDialogArea(Composite parent) { Composite container = (Composite) super.createDialogArea(parent); capabilitiesViewer = CheckboxTableViewer.newCheckList(container, SWT.BORDER); capabilitiesViewer.setContentProvider(new ArrayContentProvider()); capabilitiesViewer.setSorter(new ViewerSorter()); capabilitiesViewer.setLabelProvider(new LabelProvider()); capabilitiesViewer.setInput(getCapabilities()); Table table = capabilitiesViewer.getTable(); table.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true)); if (checkedCapabilities != null) { capabilitiesViewer.setCheckedElements(checkedCapabilities); } return container; }
From source file:com.nokia.carbide.cpp.internal.project.ui.mmpEditor.dialogs.ChooseDirectoryComposite.java
License:Open Source License
/** * Create contents of the dialog/*from w w w . ja v a 2 s .co m*/ * @param parent */ private void createContents() { final GridLayout gridLayout = new GridLayout(); gridLayout.numColumns = 3; setLayout(gridLayout); Label chooseAProjectLabel; chooseAProjectLabel = new Label(this, SWT.WRAP); chooseAProjectLabel.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false, 2, 1)); chooseAProjectLabel.setText(Messages.getString("IncludeDirectoryDialog.promptLabel")); //$NON-NLS-1$ Label fillerLable1; fillerLable1 = new Label(this, SWT.WRAP); fillerLable1.setLayoutData(new GridData(SWT.DEFAULT)); Label includeDirectoryLabel = new Label(this, SWT.NONE); includeDirectoryLabel.setText(Messages.getString("IncludeDirectoryDialog.includeDirectoryLabel")); //$NON-NLS-1$ pathViewer = new ComboViewer(this, SWT.NONE); pathViewer.setContentProvider(new ArrayContentProvider()); pathViewer.setLabelProvider(new LabelProvider()); pathViewer.setSorter(new ViewerSorter()); Combo combo; combo = pathViewer.getCombo(); combo.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false, 1, 1)); browseButton = new Button(this, SWT.NONE); browseButton.setText(Messages.getString("IncludeDirectoryDialog.browseButton")); //$NON-NLS-1$ browseButton.addSelectionListener(new SelectionAdapter() { @Override public void widgetSelected(SelectionEvent e) { doBrowse(); } }); populate(); }
From source file:com.nokia.carbide.cpp.internal.project.ui.mmpEditor.dialogs.ChooseFileComposite.java
License:Open Source License
private void createContents() { final GridLayout gridLayout = new GridLayout(); gridLayout.verticalSpacing = 10;//from ww w .ja v a 2 s .com gridLayout.numColumns = 3; setLayout(gridLayout); Label projectFilesLabel; final Label chooseAProjectLabel = new Label(this, SWT.WRAP); final GridData gridData_3 = new GridData(SWT.LEFT, SWT.CENTER, true, false, 3, 1); gridData_3.widthHint = 471; chooseAProjectLabel.setLayoutData(gridData_3); chooseAProjectLabel.setText(Messages.getString("ChooseFileComposite.prompt")); //$NON-NLS-1$ projectFilesLabel = new Label(this, SWT.NONE); projectFilesLabel.setLayoutData(new GridData(102, SWT.DEFAULT)); projectFilesLabel.setText(fileViewerLabel); filePathViewer = new ComboViewer(this, SWT.NONE); filePathViewer.setContentProvider(new ArrayContentProvider()); filePathViewer.setLabelProvider(new LabelProvider()); filePathViewer.setSorter(new ViewerSorter()); Combo fileCombo = filePathViewer.getCombo(); fileCombo.setLayoutData(new GridData(180, SWT.DEFAULT)); filePathViewer.setInput(new Object()); browseButton = new Button(this, SWT.NONE); final GridData gridData_5 = new GridData(); gridData_5.horizontalIndent = 10; browseButton.setLayoutData(gridData_5); browseButton.setText(Messages.getString("ResourceBlockDialog.browseButton")); //$NON-NLS-1$ browseButton.addSelectionListener(new SelectionAdapter() { @Override public void widgetSelected(SelectionEvent e) { doBrowse(); } }); }