List of usage examples for org.eclipse.jface.viewers ComboViewer ComboViewer
public ComboViewer(Composite parent, int style)
From source file:net.geoprism.shapefile.ui.ShapeFileAttributePage.java
License:Open Source License
public void createControl(Composite parent) { Composite composite = new Composite(parent, SWT.NULL); composite.setLayout(new GridLayout(2, false)); new Label(composite, SWT.NULL).setText(Localizer.getMessage("GEO_ENTITY") + ": "); name = new ComboViewer(composite, SWT.BORDER | SWT.READ_ONLY); name.getControl().setLayoutData(new GridData(GridData.FILL_HORIZONTAL)); name.setContentProvider(new AttributeContentProvider(true)); name.setLabelProvider(new LabelProvider()); new Label(composite, SWT.NULL).setText(Localizer.getMessage("GEO_ID") + ": "); id = new ComboViewer(composite, SWT.BORDER | SWT.READ_ONLY); id.getControl().setLayoutData(new GridData(GridData.FILL_HORIZONTAL)); id.setContentProvider(new AttributeContentProvider(false)); id.setLabelProvider(new LabelProvider()); new Label(composite, SWT.NULL).setText(Localizer.getMessage("LOCATED_IN") + ": "); locatedIn = new ComboViewer(composite, SWT.BORDER | SWT.READ_ONLY); locatedIn.getControl().setLayoutData(new GridData(GridData.FILL_HORIZONTAL)); locatedIn.setContentProvider(new AttributeContentProvider(false)); locatedIn.setLabelProvider(new LabelProvider()); new Label(composite, SWT.NULL).setText(Localizer.getMessage("LOCATED_IN_SUBTYPE") + ": "); locatedInType = new ComboViewer(composite, SWT.BORDER | SWT.READ_ONLY); locatedInType.getControl().setLayoutData(new GridData(GridData.FILL_HORIZONTAL)); locatedInType.setContentProvider(new AttributeContentProvider(false)); locatedInType.setLabelProvider(new LabelProvider()); setControl(composite);//from w w w. j av a 2 s . co m this.bind(name, "name"); this.bind(id, "id"); this.bind(locatedIn, "parent"); this.bind(locatedInType, "parentType"); }
From source file:net.geoprism.shapefile.ui.UniversalPage.java
License:Open Source License
public void createControl(Composite parent) { Composite composite = new Composite(parent, SWT.NULL); composite.setLayout(new GridLayout(2, false)); new Label(composite, SWT.NULL).setText(Localizer.getMessage("UNIVERSAL") + ": "); universal = new ComboViewer(composite, SWT.BORDER | SWT.READ_ONLY); universal.getControl().setLayoutData(new GridData(GridData.FILL_HORIZONTAL)); universal.setContentProvider(new UniversalContentProvider(universals)); universal.setLabelProvider(new LabelProvider()); universal.setInput(data);//from w w w. j a v a 2s . c om new Label(composite, SWT.NULL).setText(Localizer.getMessage("TYPE") + ": "); type = new ComboViewer(composite, SWT.BORDER | SWT.READ_ONLY); type.getControl().setLayoutData(new GridData(GridData.FILL_HORIZONTAL)); type.setContentProvider(new AttributeContentProvider(false)); type.setLabelProvider(new LabelProvider()); setControl(composite); this.bind(universal, "universal"); this.bind(type, "type"); }
From source file:net.leboxondelex.daplomb.ui.dialogs.PreferencesDialog.java
License:Open Source License
@Override protected Control createDialogArea(Composite parent) { Composite bigContainer = (Composite) super.createDialogArea(parent); GridLayoutFactory.swtDefaults().margins(0, 0).applyTo(bigContainer); bigContainer.setLayoutData(new GridData(GridData.FILL_BOTH)); Composite container = new Composite(bigContainer, SWT.NONE); GridLayoutFactory.swtDefaults().margins(10, 10).numColumns(2).applyTo(container); container.setLayoutData(new GridData(GridData.FILL_BOTH)); bigContainer.setBackground(Display.getDefault().getSystemColor(SWT.COLOR_WHITE)); container.setBackground(Display.getDefault().getSystemColor(SWT.COLOR_WHITE)); parent.setBackground(Display.getDefault().getSystemColor(SWT.COLOR_WHITE)); // Library root Label l = new Label(container, SWT.NONE); l.setText(Messages.getString("ShowPreferencesHandler.0")); //$NON-NLS-1$ l.setBackground(Display.getDefault().getSystemColor(SWT.COLOR_WHITE)); Text libraryText = createDirectoryBrowser(container, PreferencesManager.INSTANCE.getLibraryRootDirectory(), Messages.getString("ShowPreferencesHandler.1"), //$NON-NLS-1$ Messages.getString("ShowPreferencesHandler.2")); //$NON-NLS-1$ libraryText.addListener(SWT.Modify, new Listener() { @Override// w w w .j a v a 2 s . c o m public void handleEvent(Event event) { String s = ((Text) event.widget).getText(); PreferencesManager.INSTANCE.saveLibraryRootDirectory(s); } }); // Library's favorite folder l = new Label(container, SWT.NONE); l.setText(Messages.getString("ShowPreferencesHandler.3")); //$NON-NLS-1$ l.setBackground(Display.getDefault().getSystemColor(SWT.COLOR_WHITE)); Text defaultFolderText = createDirectoryBrowser(container, PreferencesManager.INSTANCE.getLibraryPreferredDirectory(), Messages.getString("ShowPreferencesHandler.4"), //$NON-NLS-1$ Messages.getString("ShowPreferencesHandler.5")); //$NON-NLS-1$ defaultFolderText.addListener(SWT.Modify, new Listener() { @Override public void handleEvent(Event event) { String s = ((Text) event.widget).getText(); PreferencesManager.INSTANCE.saveLibraryPreferredDirectory(s); } }); // FF MPEG location l = new Label(container, SWT.NONE); l.setText("FFmpeg :"); l.setBackground(Display.getDefault().getSystemColor(SWT.COLOR_WHITE)); boolean win = System.getProperty("os.name").toLowerCase().contains("win"); String s = PreferencesManager.INSTANCE.getFfMpegLocation(); File f = s != null ? new File(s) : null; Text ffMpegLocationText = createFileBrowser(container, f, "Slectionnez l'emplacement d'un excutable FFmpeg.", win ? "*.exe" : "*.*", "FFmpeg"); ffMpegLocationText.addListener(SWT.Modify, new Listener() { @Override public void handleEvent(Event event) { String s = ((Text) event.widget).getText(); PreferencesManager.INSTANCE.saveFfMpegLocation(s); } }); // Language l = new Label(container, SWT.NONE); l.setText("Langage :"); l.setBackground(Display.getDefault().getSystemColor(SWT.COLOR_WHITE)); final ComboViewer langViewer = new ComboViewer(container, SWT.READ_ONLY | SWT.BORDER | SWT.DROP_DOWN); langViewer.setContentProvider(new ArrayContentProvider()); langViewer.setLabelProvider(new LabelProvider() { @Override public String getText(Object element) { return ((Locale) element).getDisplayName(); } }); List<Locale> locales = new ArrayList<Locale>(); locales.add(Locale.FRENCH); locales.add(Locale.ENGLISH); langViewer.setInput(locales); Locale currentLocale = PreferencesManager.INSTANCE.getApplicationLanguage(); if (currentLocale == null) currentLocale = locales.get(0); langViewer.setSelection(new StructuredSelection(currentLocale)); langViewer.getCombo().addListener(SWT.Selection, new Listener() { @Override public void handleEvent(Event event) { Object o = ((IStructuredSelection) langViewer.getSelection()).getFirstElement(); PreferencesManager.INSTANCE.saveApplicationLanguage((Locale) o); Messages.switchLocale((Locale) o); PreferencesDialog.this.langHasChanged = true; } }); // Debug Button debugButton = new Button(container, SWT.CHECK); debugButton.setText("Activer les traces de DEBUG"); debugButton.setBackground(Display.getDefault().getSystemColor(SWT.COLOR_WHITE)); debugButton.setSelection(PreferencesManager.INSTANCE.isApplicationDebug()); GridDataFactory.swtDefaults().span(2, 1).indent(0, 20).applyTo(debugButton); debugButton.addListener(SWT.Selection, new Listener() { @Override public void handleEvent(Event e) { boolean selection = ((Button) e.widget).getSelection(); PreferencesManager.INSTANCE.saveApplicationDebug(selection); LogUtils.updateLogLevel(); } }); // Shell properties setTitle(Messages.getString("ShowPreferencesHandler.6")); //$NON-NLS-1$ setMessage(Messages.getString("ShowPreferencesHandler.7")); //$NON-NLS-1$ return bigContainer; }
From source file:net.leboxondelex.daplomb.ui.dialogs.VideoFiltersDialog.java
License:Open Source License
/** * Updates the options./* w w w.j a va 2 s. c om*/ * @param optionsComposite * @param index */ private void updateOptions(Composite optionsComposite, int index) { // Remove all the widgets for (Control c : optionsComposite.getChildren()) { if (!c.isDisposed()) c.dispose(); } // Add the new widgets switch (index) { case 0: Label l = new Label(optionsComposite, SWT.NONE); l.setText("Recadrer avant ajustement des proportions de l'image."); GridDataFactory.swtDefaults().span(2, 1).applyTo(l); Spinner[] spinners = VideoUtils.createCroppers(optionsComposite, this.prefs.getCrop1(), this.font); addSpinnerListener(spinners); break; case 2: l = new Label(optionsComposite, SWT.NONE); l.setText("Recadrer les aperus."); GridDataFactory.swtDefaults().span(2, 1).applyTo(l); spinners = VideoUtils.createCroppers(optionsComposite, this.prefs.getCrop2(), this.font); addSpinnerListener(spinners); break; case 1: l = new Label(optionsComposite, SWT.NONE); l.setText("Ajuster les proportions de l'image."); GridDataFactory.swtDefaults().span(2, 1).applyTo(l); ComboViewer viewer = new ComboViewer(optionsComposite, SWT.BORDER | SWT.READ_ONLY | SWT.DROP_DOWN); viewer.setLabelProvider(new LabelProvider()); viewer.setContentProvider(new ArrayContentProvider()); viewer.setInput(AspectRatio.values()); AspectRatio ar = this.prefs.getAspectRatio(); if (ar == null) ar = VideoPreferences.DEFAULT_ASPECT_RATIO; viewer.setSelection(new StructuredSelection(ar)); GridDataFactory.fillDefaults().grab(true, false).applyTo(viewer.getCombo()); viewer.addSelectionChangedListener(new ISelectionChangedListener() { @Override public void selectionChanged(SelectionChangedEvent e) { Object o = ((IStructuredSelection) e.getSelection()).getFirstElement(); VideoFiltersDialog.this.prefs.setAspectRatio((AspectRatio) o); VideoFiltersDialog.this.facet.updateModifiedImage(); } }); break; case 3: l = new Label(optionsComposite, SWT.NONE); l.setText("Configurer le nom des aperus gnrs."); GridDataFactory.swtDefaults().span(2, 1).applyTo(l); Text text2 = new Text(optionsComposite, SWT.SINGLE | SWT.BORDER); GridDataFactory.fillDefaults().grab(true, false).applyTo(text2); String s = StringUtils.isEmpty(this.prefs.getNamePattern()) ? VideoPreferences.DEFAULT_NAME_PATTERN : this.prefs.getNamePattern().trim(); text2.setText(s); text2.addModifyListener(new ModifyListener() { @Override public void modifyText(ModifyEvent e) { String s = ((Text) e.widget).getText(); VideoFiltersDialog.this.prefs.setNamePattern(s.trim()); } }); StringBuilder sb = new StringBuilder(); sb.append("Vous pouvez utilisez les symboles suivants :"); sb.append("\n\t"); //$NON-NLS-1$ sb.append("%n pour le nom de la vido"); sb.append("\n\t"); //$NON-NLS-1$ sb.append("%d pour le numro de frame"); l = new Label(optionsComposite, SWT.NONE); l.setText(sb.toString()); GridDataFactory.swtDefaults().span(2, 1).indent(0, 10).applyTo(l); break; default: break; } // Paint it white for (Control c : optionsComposite.getChildren()) { if (c instanceof Label) c.setBackground(Display.getDefault().getSystemColor(SWT.COLOR_WHITE)); } // Lay out optionsComposite.layout(); optionsComposite.getParent().layout(); }
From source file:net.leboxondelex.daplomb.ui.facets.ImageViewerFacet.java
License:Open Source License
/** * Constructor./*from www. j a v a 2 s. co m*/ * @param parent * @param appFont */ public ImageViewerFacet(Composite parent, Font appFont) { super(parent); this.appFont = appFont; this.imageCacheManager = Activator.getPlugin().getImageCache(); GridLayoutFactory.swtDefaults().margins(10, 10).spacing(20, 20).applyTo(this); setLayoutData(new GridData(GridData.FILL_BOTH)); Composite groupsComposite = new Composite(this, SWT.NONE); GridLayoutFactory.swtDefaults().numColumns(2).equalWidth(true).margins(0, 0).applyTo(groupsComposite); GridDataFactory.fillDefaults().grab(true, false).applyTo(groupsComposite); this.statsGroup = new Group(groupsComposite, SWT.SHADOW_ETCHED_IN); this.statsGroup.setFont(appFont); GridLayoutFactory.swtDefaults().margins(7, 7).numColumns(2).applyTo(this.statsGroup); this.statsGroup.setLayoutData(new GridData(GridData.FILL_BOTH)); this.statsGroup.setText(Messages.getString("ImageViewerPart.4")); //$NON-NLS-1$ updateProperties(null); final Group assemblyGroup = new Group(groupsComposite, SWT.SHADOW_ETCHED_IN); assemblyGroup.setFont(appFont); GridLayoutFactory.swtDefaults().numColumns(2).margins(7, 7).applyTo(assemblyGroup); assemblyGroup.setLayoutData(new GridData(GridData.FILL_BOTH)); assemblyGroup.setText(Messages.getString("ImageViewerPart.5")); //$NON-NLS-1$ final Button randomButton = new Button(assemblyGroup, SWT.CHECK); randomButton.setFont(appFont); randomButton.setText(Messages.getString("ImageViewerPart.6")); //$NON-NLS-1$ randomButton.setSelection(PreferencesManager.INSTANCE.isViewerRandom()); GridDataFactory.swtDefaults().span(2, 1).applyTo(randomButton); Label l = new Label(assemblyGroup, SWT.NONE); l.setText(Messages.getString("ImageViewerPart.7")); //$NON-NLS-1$ l.setFont(appFont); final Spinner assemblySpinner = new Spinner(assemblyGroup, SWT.BORDER); assemblySpinner.setFont(appFont); assemblySpinner.setValues(PreferencesManager.INSTANCE.getViewerNbPerAssembly(), 1, 10, 0, 1, 1); l = new Label(assemblyGroup, SWT.NONE); l.setText(Messages.getString("ImageViewerPart.8")); //$NON-NLS-1$ l.setFont(appFont); final ComboViewer strategyViewer = new ComboViewer(assemblyGroup, SWT.BORDER | SWT.READ_ONLY | SWT.DROP_DOWN); strategyViewer.getCombo().setFont(appFont); strategyViewer.setLabelProvider(new LabelProvider()); strategyViewer.setContentProvider(new ArrayContentProvider()); strategyViewer.setInput(AbstractImageComposer.getComposers()); this.previewCanvas = new ImageCanvas(this); GridDataFactory.fillDefaults().grab(true, true).applyTo(this.previewCanvas); Composite buttonsComposite = new Composite(this, SWT.NONE); GridLayoutFactory.swtDefaults().margins(0, 0).numColumns(2).applyTo(buttonsComposite); GridDataFactory.fillDefaults().grab(true, false).applyTo(buttonsComposite); final Button startButton = new Button(buttonsComposite, SWT.PUSH); startButton.setFont(appFont); startButton.setText(Messages.getString("ImageViewerPart.9")); //$NON-NLS-1$ startButton.setToolTipText("Regarder en plein cran"); startButton.setImage(ResourceRegistry.ICON_BROWSE_48x48); GridDataFactory.swtDefaults().align(SWT.FILL, SWT.BOTTOM).grab(true, false).hint(SWT.DEFAULT, 60) .applyTo(startButton); final Button shuffleButton = new Button(buttonsComposite, SWT.PUSH); shuffleButton.setImage(ResourceRegistry.ICON_SHUFFLE_48x48); shuffleButton.setToolTipText(Messages.getString("ImageViewerPart.10")); //$NON-NLS-1$ GridDataFactory.swtDefaults().hint(SWT.DEFAULT, 60).applyTo(shuffleButton); // Listeners final AtomicBoolean refreshIsAllowed = new AtomicBoolean(false); strategyViewer.addSelectionChangedListener(new ISelectionChangedListener() { @Override public void selectionChanged(SelectionChangedEvent event) { Object o = ((IStructuredSelection) event.getSelection()).getFirstElement(); AbstractImageComposer composer = (AbstractImageComposer) o; ImageViewerFacet.this.imageCacheManager.setImageComposer(composer); boolean needsRefresh = !composer.getName() .equals(PreferencesManager.INSTANCE.getViewerAssemblyStrategy()); if (needsRefresh) { PreferencesManager.INSTANCE.saveViewerAssemblyStrategy(composer.getName()); if (refreshIsAllowed.get()) { populateOptions(assemblyGroup, ImageViewerFacet.this.previewCanvas); ImageViewerFacet.this.imageCacheManager.paintImage(ImageViewerFacet.this.previewCanvas); } } } }); randomButton.addListener(SWT.Selection, new Listener() { @Override public void handleEvent(Event event) { PreferencesManager.INSTANCE.saveViewerRandom(randomButton.getSelection()); } }); assemblySpinner.addListener(SWT.Selection, new Listener() { @Override public void handleEvent(Event event) { PreferencesManager.INSTANCE.saveViewerNbPerAssembly(assemblySpinner.getSelection()); ImageViewerFacet.this.imageCacheManager.paintImage(ImageViewerFacet.this.previewCanvas); } }); startButton.addListener(SWT.Selection, new Listener() { @Override public void handleEvent(Event event) { new ImageViewer().open(ImageViewerFacet.this.previewCanvas); } }); shuffleButton.addListener(SWT.Selection, new Listener() { @Override public void handleEvent(Event event) { boolean shuffle = System.nanoTime() % 2 == 0 && !ImageViewerFacet.this.lastTimeWasShuffled; shuffle = shuffle && ImageViewerFacet.this.imageCacheManager.canShuffle(); ImageViewerFacet.this.lastTimeWasShuffled = shuffle; if (!shuffle) ImageViewerFacet.this.imageCacheManager.nextImage(); ImageViewerFacet.this.imageCacheManager.paintImage(ImageViewerFacet.this.previewCanvas, shuffle); } }); // Initialize everything strategyViewer.setSelection(new StructuredSelection(this.imageCacheManager.getImageComposer())); populateOptions(assemblyGroup, this.previewCanvas); refreshIsAllowed.set(true); this.imageCacheManager.paintImage(this.previewCanvas); }
From source file:net.refractions.udig.catalog.internal.wmt.ui.view.WMTZoomLevelSwitcher.java
License:Open Source License
@Override public void createPartControl(final Composite parent) { parentControl = parent;/* w w w . ja v a 2s. co m*/ Composite composite = new Composite(parent, SWT.NONE); composite.setLayout(new RowLayout(SWT.HORIZONTAL)); //region Label "Layer" Label lblLayer = new Label(composite, SWT.HORIZONTAL); lblLayer.setText(Messages.ZoomLevelSwitcher_Layer); //endregion //region Layer ComboBox cvLayers = new ComboViewer(composite, SWT.READ_ONLY); cvLayers.setContentProvider(new ArrayContentProvider()); cvLayers.setLabelProvider(new LabelProvider() { @Override public String getText(Object element) { if (element instanceof ILayer) { return ((ILayer) element).getName(); } else { return super.getText(element); } } }); cvLayers.addSelectionChangedListener(new ISelectionChangedListener() { public void selectionChanged(SelectionChangedEvent event) { updateZoomLevels(); updateGUIFromScale(); } }); //endregion //region Label "Zoom-Level" Label lblZoomLevel = new Label(composite, SWT.HORIZONTAL); lblZoomLevel.setText(Messages.ZoomLevelSwitcher_ZoomLevel); //endregion //region Zoom-Level ComboBox cvZoomLevels = new ComboViewer(composite, SWT.READ_ONLY); cvZoomLevels.setContentProvider(new ArrayContentProvider()); cvZoomLevels.setLabelProvider(new LabelProvider()); //endregion //region Zoom-In/Zoom-Out Buttons // load icons setUpImageCache(parent); btnZoomOut = new Button(composite, SWT.PUSH); btnZoomOut.setImage(imageCache.get(ICON_ZOOM_OUT)); btnZoomOut.setToolTipText(Messages.ZoomLevelSwitcher_ZoomOut); btnZoomOut.addSelectionListener(new SelectionListener() { public void widgetSelected(SelectionEvent e) { zoomOut(); } public void widgetDefaultSelected(SelectionEvent e) { } }); btnZoomIn = new Button(composite, SWT.PUSH); btnZoomIn.setImage(imageCache.get(ICON_ZOOM_IN)); btnZoomIn.setToolTipText(Messages.ZoomLevelSwitcher_ZoomIn); btnZoomIn.addSelectionListener(new SelectionListener() { public void widgetSelected(SelectionEvent e) { zoomIn(); } public void widgetDefaultSelected(SelectionEvent e) { } }); //endregion //region Setup listeners listenerZoomLevel = new ISelectionChangedListener() { public void selectionChanged(SelectionChangedEvent event) { zoomToZoomLevel(getSelectedZoomLevel()); } }; cvZoomLevels.addSelectionChangedListener(listenerZoomLevel); setUpMapListeners(ApplicationGIS.getActiveMap()); getSite().getWorkbenchWindow().getPartService().addPartListener(listenerMapEditor); //endregion }
From source file:net.refractions.udig.document.ui.DocumentDialog.java
License:Open Source License
/** * Creates the info (action type) controls. *///from www . j a v a 2 s . c o m private void createInfoGoActionControls() { infoGoActionLbl = new Label(composite, SWT.NONE); infoGoActionLbl.setText(getLabel(Messages.DocumentDialog_actionLabel)); infoGoActionLbl.setLayoutData(""); //$NON-NLS-1$ infoGoAction = new ComboViewer(composite, SWT.READ_ONLY | SWT.DROP_DOWN); infoGoAction.getControl().setLayoutData("split 2"); //$NON-NLS-1$ infoGoAction.setLabelProvider(new LabelProvider() { @Override public String getText(Object element) { final HotlinkDescriptor descriptor = (HotlinkDescriptor) element; return descriptor.getLabel(); } }); infoGoAction.setContentProvider(ArrayContentProvider.getInstance()); infoGoAction.addSelectionChangedListener(new ISelectionChangedListener() { public void selectionChanged(SelectionChangedEvent event) { final StructuredSelection selection = (StructuredSelection) event.getSelection(); final HotlinkDescriptor descriptor = (HotlinkDescriptor) selection.getFirstElement(); label.setText(descriptor.getLabel()); final String descriptionStr = descriptor.getDescription(); if (descriptionStr == null) { description.setText(""); //$NON-NLS-1$ } else { description.setText(descriptionStr); } } }); final List<HotlinkDescriptor> actions = getActions(); if (actions != null && actions.size() > 0) { infoGoAction.setInput(actions.toArray()); } infoGoActionBtn = new Button(composite, SWT.PUSH); infoGoActionBtn.setText(Messages.DocumentDialog_goBtn); infoGoActionBtn.setLayoutData(""); //$NON-NLS-1$ infoGoActionBtn.addSelectionListener(new SelectionAdapter() { @Override public void widgetSelected(SelectionEvent e) { final StructuredSelection selection = (StructuredSelection) infoGoAction.getSelection(); final HotlinkDescriptor descriptor = (HotlinkDescriptor) selection.getFirstElement(); final String action = descriptor.getConfig().replace(DocumentPropertyPage.ACTION_PARAM, info.getText()); Program.launch(action); } }); }
From source file:net.refractions.udig.document.ui.DocumentDialog.java
License:Open Source License
/** * Creates the type controls/*from w ww . j a v a 2s . c om*/ */ private void createTypeControls() { final Label typeLbl = new Label(composite, SWT.NONE); typeLbl.setText(getLabel(Messages.DocumentDialog_typeLabel, true)); typeLbl.setLayoutData(""); //$NON-NLS-1$ type = new ComboViewer(composite, SWT.READ_ONLY | SWT.DROP_DOWN); type.getControl().setLayoutData(""); //$NON-NLS-1$ type.setContentProvider(ArrayContentProvider.getInstance()); type.setLabelProvider(new LabelProvider() { @Override public String getText(Object element) { return DocUtils.toCamelCase(element.toString()); } }); type.addSelectionChangedListener(new ISelectionChangedListener() { public void selectionChanged(SelectionChangedEvent event) { final ContentType newTypeValue = getTypeComboValue(); if (typeValue != newTypeValue) { typeValue = newTypeValue; if (newTypeValue != null) { validateInfo(); refreshBtns(); configInfoControls(newTypeValue); } } } }); List<ContentType> types = getParamContentTypes(); if (types == null) { types = new ArrayList<ContentType>(); switch (getParamType()) { case LINKED: types.add(ContentType.FILE); types.add(ContentType.WEB); break; case ATTACHMENT: types.add(ContentType.FILE); break; case HOTLINK: types.add(ContentType.FILE); types.add(ContentType.WEB); types.add(ContentType.ACTION); break; default: break; } } type.setInput(types.toArray()); }
From source file:net.refractions.udig.style.sld.editor.raster.ClassifyDialog.java
License:Open Source License
@Override protected Control createDialogArea(Composite parent) { breaks = new ArrayList<Double>(); Composite main = new Composite((Composite) super.createDialogArea(parent), SWT.NONE); main.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, false)); GridLayout gl = new GridLayout(2, false); gl.marginWidth = gl.marginHeight = 20; main.setLayout(gl);//from w w w . j a va 2 s .c om Label lbl = new Label(main, SWT.NONE); lbl.setText(Messages.ClassifyDialog_ClassificationFunctionLabel); cmbClass = new ComboViewer(main, SWT.DROP_DOWN | SWT.READ_ONLY | SWT.BORDER); cmbClass.getControl().setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, false)); cmbClass.setContentProvider(ArrayContentProvider.getInstance()); cmbClass.setLabelProvider(new LabelProvider() { public String getText(Object x) { if (x instanceof ClassifyFunction) { return ((ClassifyFunction) x).guiName; } return super.getText(x); } }); cmbClass.setInput(ClassifyFunction.values()); cmbClass.getCombo().addSelectionListener(new SelectionAdapter() { @Override public void widgetSelected(SelectionEvent e) { lblOp.setText(getCurrentSelection().opName); lblOp.getParent().layout(); } }); lblOp = new Label(main, SWT.NONE); lblOp.setText(ClassifyFunction.EQUAL_INTERNAL.opName); txtOp = new Text(main, SWT.BORDER); txtOp.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, false)); txtOp.setText("10"); //$NON-NLS-1$ Label lbl4 = new Label(main, SWT.NONE); lbl4.setText(Messages.ClassifyDialog_ValuesToIgnoreLabel + "*"); //$NON-NLS-1$ txtIgnore = new Text(main, SWT.BORDER); txtIgnore.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, false)); if (defaultNoData == null) { txtIgnore.setText(String.valueOf(IColorMapTypePanel.DEFAULT_NO_DATA)); } else { StringBuilder sb = new StringBuilder(); for (double d : defaultNoData) { sb.append(d); sb.append(","); //$NON-NLS-1$ } //remove last "," if (sb.length() > 0) { sb.deleteCharAt(sb.length() - 1); } txtIgnore.setText(sb.toString()); } Label lbls = new Label(main, SWT.NONE); lbls.setText(Messages.ClassifyDialog_LimitSizeLabel); lbls.setToolTipText(Messages.ClassifyDialog_LimitSizeTooltip); Composite compSample = new Composite(main, SWT.NONE); GridLayout gla = new GridLayout(2, false); gla.marginHeight = gla.marginWidth = 0; compSample.setLayout(gla); compSample.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, false)); chSampleSize = new Button(compSample, SWT.CHECK); chSampleSize.setSelection(false); chSampleSize.addSelectionListener(new SelectionAdapter() { @Override public void widgetSelected(SelectionEvent e) { txtSampleSize.setEnabled(chSampleSize.getSelection()); } }); txtSampleSize = new Text(compSample, SWT.BORDER); txtSampleSize.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, false)); txtSampleSize.setText("100000"); //$NON-NLS-1$ txtSampleSize.setEnabled(false); btnCompute = new Button(main, SWT.PUSH); btnCompute.setText(GENERATE_LABEL); btnCompute.setLayoutData(new GridData(SWT.CENTER, SWT.FILL, true, false, 2, 1)); btnCompute.addSelectionListener(new SelectionAdapter() { @Override public void widgetSelected(SelectionEvent e) { computeValues(); } }); Label lblSep = new Label(main, SWT.SEPARATOR | SWT.HORIZONTAL); lblSep.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, false, 2, 1)); Label lblRange = new Label(main, SWT.NONE); lblRange.setText(Messages.ClassifyDialog_BreaksLabel); lblRange.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, false, 2, 1)); cmbRanges = new ListViewer(main, SWT.BORDER | SWT.V_SCROLL | SWT.H_SCROLL); GridData gd = new GridData(SWT.FILL, SWT.FILL, true, true, 2, 1); gd.widthHint = 150; gd.heightHint = 200; cmbRanges.getControl().setLayoutData(gd); cmbRanges.setLabelProvider(new LabelProvider()); cmbRanges.setContentProvider(ArrayContentProvider.getInstance()); cmbRanges.setInput(breaks); Label lbl3 = new Label(main, SWT.WRAP); lbl3.setText("*" + Messages.ClassifyDialog_IgnoreValuesInfo); //$NON-NLS-1$ lbl3.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, false, 2, 1)); cmbClass.setSelection(new StructuredSelection(ClassifyFunction.EQUAL_INTERNAL)); setMessage(Messages.ClassifyDialog_DialogMessage); setTitle(Messages.ClassifyDialog_DialogTitle); getShell().setText(Messages.ClassifyDialog_ShellTitle); return main; }
From source file:net.refractions.udig.style.sld.editor.raster.SingleBandEditorPage.java
License:Open Source License
@Override public void createPageContent(Composite parent) { Composite main = new Composite(parent, SWT.NONE); main.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true)); main.setLayout(new GridLayout(3, false)); Label lbl = new Label(main, SWT.NONE); lbl.setText(Messages.SingleBandEditorPage_ThemingStyleLabel); cmbThemingStyle = new ComboViewer(main, SWT.DROP_DOWN | SWT.READ_ONLY); cmbThemingStyle.getControl().setLayoutData(new GridData(SWT.FILL, SWT.FILL, false, false, 2, 1)); ((GridData) cmbThemingStyle.getControl().getLayoutData()).widthHint = 150; cmbThemingStyle.setContentProvider(ArrayContentProvider.getInstance()); cmbThemingStyle.setInput(stylePanels); cmbThemingStyle.setLabelProvider(new LabelProvider() { @Override/*from w w w .j av a2 s . c o m*/ public String getText(Object element) { if (element instanceof IColorMapTypePanel) { return ((IColorMapTypePanel) element).getName(); } return super.getText(element); } }); lbl = new Label(main, SWT.NONE); lbl.setText(Messages.SingleBandEditorPage_ColorPaletteLabel); cmbPalette = createPaletteViewer(main); final Button btnTest = new Button(main, SWT.PUSH); btnTest.setText(Messages.SingleBandEditorPage_ComputeBreaksButtonText); btnTest.setLayoutData(new GridData(SWT.LEFT, SWT.CENTER, false, false, 2, 1)); btnTest.addSelectionListener(new SelectionAdapter() { @Override public void widgetSelected(SelectionEvent e) { getCurrentSelection().computeValues(); } }); tableComp = new Composite(main, SWT.NONE); tableComp.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true, 3, 1)); tableComp.setLayout(new StackLayout()); final HashMap<IColorMapTypePanel, Composite> stacks = new HashMap<IColorMapTypePanel, Composite>(); for (IColorMapTypePanel pnl : stylePanels) { Composite stack = pnl.createControl(tableComp); stacks.put(pnl, stack); } Composite linkPnl = new Composite(main, SWT.NONE); linkPnl.setLayout(new GridLayout(4, false)); linkPnl.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, false, 3, 1)); Link lnk = new Link(linkPnl, SWT.NONE); lnk.setText("<a>" + Messages.SingleBandEditorPage_ReverseColorLabel + "</a>"); //$NON-NLS-1$ //$NON-NLS-2$ lnk.addSelectionListener(new SelectionAdapter() { @Override public void widgetSelected(SelectionEvent e) { reverseColors = !reverseColors; if (getCurrentSelection() != null) { Object x = ((IStructuredSelection) cmbPalette.getSelection()).getFirstElement(); if (x instanceof BrewerPalette) { BrewerPalette palette = (BrewerPalette) ((IStructuredSelection) cmbPalette.getSelection()) .getFirstElement(); getCurrentSelection().setColorPalette(palette, reverseColors); } else if (x instanceof PredefinedColorRule) { ColorMap cm = ((PredefinedColorRule) x).getColorMap(); if (cm != null && getCurrentSelection() != null) { //flip colors if (reverseColors) { ColorMap reverse = new ColorMapImpl(); for (int i = 0; i < cm.getColorMapEntries().length; i++) { ColorMapEntry entry = cm.getColorMapEntries()[i]; ColorMapEntry clone = new ColorMapEntryImpl(); clone.setColor( cm.getColorMapEntry(cm.getColorMapEntries().length - 1 - i).getColor()); clone.setLabel(entry.getLabel()); clone.setQuantity(entry.getQuantity()); clone.setOpacity(entry.getOpacity()); reverse.addColorMapEntry(clone); } cm = reverse; } getCurrentSelection().init(cm); } } } } }); Label lblSep = new Label(linkPnl, SWT.SEPARATOR | SWT.VERTICAL); GridData gd = new GridData(SWT.FILL, SWT.FILL, false, false); gd.heightHint = 10; lblSep.setLayoutData(gd); lnk = new Link(linkPnl, SWT.NONE); lnk.setText("<a>" + Messages.SingleBandEditorPage_FormatExportLink + "</a>"); //$NON-NLS-1$ //$NON-NLS-2$ lnk.addSelectionListener(new SelectionAdapter() { @Override public void widgetSelected(SelectionEvent e) { getFormat(); } }); Link lnk2 = new Link(linkPnl, SWT.NONE); lnk2.setText("<a>" + Messages.SingleBandEditorPage_OneClickExportLink + "</a>"); //$NON-NLS-1$ //$NON-NLS-2$ lnk2.setLayoutData(new GridData(SWT.RIGHT, SWT.CENTER, true, false)); lnk2.setToolTipText(Messages.SingleBandEditorPage_OneClickTooltip); lnk2.addSelectionListener(new SelectionAdapter() { @Override public void widgetSelected(SelectionEvent e) { oneClickExport(); } }); cmbThemingStyle.getCombo().addSelectionListener(new SelectionAdapter() { @Override public void widgetSelected(SelectionEvent e) { IColorMapTypePanel panel = getCurrentSelection(); if (panel != null) { ((StackLayout) tableComp.getLayout()).topControl = stacks.get(panel); tableComp.layout(); btnTest.setText(panel.getComputeValuesLabel()); btnTest.getParent().layout(); Object x = ((IStructuredSelection) cmbPalette.getSelection()).getFirstElement(); ; if (x instanceof BrewerPalette) { BrewerPalette palette = (BrewerPalette) x; getCurrentSelection().setInitialColorPalette(palette); } else if (x instanceof PredefinedColorRule) { ColorMap cm = ((PredefinedColorRule) x).getColorMap(); if (cm != null && getCurrentSelection() != null) { getCurrentSelection().init(cm); } } } } }); cmbPalette.addSelectionChangedListener(new ISelectionChangedListener() { @Override public void selectionChanged(SelectionChangedEvent event) { Object x = ((IStructuredSelection) cmbPalette.getSelection()).getFirstElement(); ; if (x instanceof BrewerPalette) { BrewerPalette palette = (BrewerPalette) x; if (getCurrentSelection() != null) { getCurrentSelection().setColorPalette(palette, reverseColors); } } else if (x instanceof PredefinedColorRule) { ColorMap cm = ((PredefinedColorRule) x).getColorMap(); if (cm != null && getCurrentSelection() != null) { getCurrentSelection().init(cm); } } } }); cmbThemingStyle.getControl().addDisposeListener(new DisposeListener() { @Override public void widgetDisposed(DisposeEvent e) { if (colorRules != null) { colorRules.dispose(); } } }); init(); }