List of usage examples for org.eclipse.jface.viewers ComboViewer ComboViewer
public ComboViewer(Composite parent, int style)
From source file:com.nokia.cdt.internal.debug.launch.newwizard.DebugRunProcessDialog.java
License:Open Source License
/** * Allow user to enter an executable path. * @param radioGroup/* w w w . j ava 2 s . c om*/ */ private void createRemoteExecutableRadioButton(Composite radioGroup) { remoteExecutableRadioButton = new Button(radioGroup, SWT.RADIO); GridDataFactory.fillDefaults().grab(false, false).applyTo(remoteExecutableRadioButton); remoteExecutableRadioButton.setText(Messages.getString("DebugRunProcessDialog.LaunchRemoteProgLabel")); //$NON-NLS-1$ remoteExecutableRadioButton.setData(UID, "radio_remote_program"); //$NON-NLS-1$ remoteExecutableRadioButton .setToolTipText(Messages.getString("DebugRunProcessDialog.LaunchRemoteProgramRadioTooltip")); //$NON-NLS-1$ remoteProgramViewer = new ComboViewer(radioGroup, SWT.BORDER); GridDataFactory.fillDefaults().grab(true, false).applyTo(remoteProgramViewer.getControl()); projectGeneratedRemotePaths = new ArrayList<IPath>(); for (IPath launchable : debugRunProcessWizardData.getLaunchableExes()) { projectGeneratedRemotePaths.add(createSuggestedRemotePath(launchable)); } // add the entries before the user MRU entries remotePathEntries.addAll(0, projectGeneratedRemotePaths); remoteProgramViewer.setContentProvider(new ArrayContentProvider()); remoteProgramViewer.setLabelProvider(new LabelProvider() { @Override public String getText(Object element) { if (element instanceof IPath) return PathUtils.convertPathToWindows((IPath) element); return super.getText(element); } }); remoteProgramViewer.setInput(remotePathEntries); remoteProgramViewer.getCombo().setVisibleItemCount(Math.min(10, remotePathEntries.size())); remoteProgramViewer.setData(UID, "combo_remote_program"); //$NON-NLS-1$ remoteProgramViewer.getControl() .setToolTipText(Messages.getString("DebugRunProcessDialog.LaunchRemoteProgramSelectorTooltip")); //$NON-NLS-1$ remoteExecutableRadioButton.addSelectionListener(new SelectionAdapter() { @Override public void widgetSelected(SelectionEvent e) { handleRemoteExecutableRadioSelected(); } }); remoteProgramViewer.getCombo().addModifyListener(new ModifyListener() { public void modifyText(ModifyEvent e) { IPath path = PathUtils.createPath(remoteProgramViewer.getCombo().getText().trim()); if (remoteExecutableRadioButton.getSelection()) { debugRunProcessWizardData.setExeSelectionPath(path); } if (!projectExecutableRadioButton.getSelection()) { IPath projPath = getHostFileForRemoteLocation(path); if (projPath != null) { projectExecutableViewer.setSelection(new StructuredSelection(projPath)); } } validate(); } }); remoteProgramViewer.getCombo().addFocusListener(new FocusAdapter() { /* (non-Javadoc) * @see org.eclipse.swt.events.FocusAdapter#focusLost(org.eclipse.swt.events.FocusEvent) */ @Override public void focusLost(FocusEvent e) { IPath path = PathUtils.createPath(remoteProgramViewer.getCombo().getText().trim()); // MRU behavior remotePathEntries.remove(path); remotePathEntries.add(0, path); } }); }
From source file:com.nokia.cdt.internal.debug.launch.wizard.MainExecutableSelectionWizardPage.java
License:Open Source License
public void createControl(Composite parent) { Composite composite = new Composite(parent, SWT.NULL); composite.setLayout(new GridLayout(1, false)); composite.setLayoutData(new GridData()); final Label exeLabel = new Label(composite, SWT.NONE); exeLabel.setText(getAltString("MainExecutableSelectionWizardPage.ExeLabel")); //$NON-NLS-1$ exeLabel.setToolTipText(getAltString("MainExecutableSelectionWizardPage.ExeToolTip")); //$NON-NLS-1$ exeLabel.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, false, false)); exeLabel.setData(".uid", "MainExecutableSelectionWizardPage.exeLabel"); viewer = new ComboViewer(composite, SWT.READ_ONLY); Combo combo = viewer.getCombo();//w ww . ja v a2 s . c om combo.setData(".uid", "MainExecutableCombo"); //$NON-NLS-1$ //$NON-NLS-2$ combo.setToolTipText(getAltString("MainExecutableSelectionWizardPage.ExeToolTip")); //$NON-NLS-1$ combo.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false)); combo.setVisibleItemCount(20); combo.setData(".uid", "MainExecutableSelectionWizardPage.combo"); viewer.setContentProvider(new ArrayContentProvider()); viewer.setLabelProvider(new LabelProvider()); viewer.setSorter(new ViewerSorter() { public int compare(Viewer viewer, Object o1, Object o2) { if (o1.equals(EMULATOR) || o2.equals(BROWSE_ITEM)) return -1; if (o2.equals(EMULATOR) || o1.equals(BROWSE_ITEM)) return 1; if (!asProcessToLaunch) { // put .exe before any other extension, if not as process to launch boolean isEXE1 = EXE.equalsIgnoreCase(new Path(o1.toString()).getFileExtension()); boolean isEXE2 = EXE.equalsIgnoreCase(new Path(o2.toString()).getFileExtension()); if (isEXE1 != isEXE2) { // if only one is an exe return isEXE1 ? -1 : 1; // return -1 if exe path is .exe, 1 otherwise, sorting .exe paths ahead of anything else } } return o1.toString().compareToIgnoreCase(o2.toString()); } }); input = new ArrayList<String>(displayStringToExeMmpPair.keySet()); if (emulatorPath != null) { input.add(EMULATOR); //$NON-NLS-1$ input.add(BROWSE_ITEM); } if (asProcessToLaunch) { Label label = new Label(composite, SWT.NONE); label.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false)); label.setText(Messages.getString("MainExecutableSelectionWizardPage.FullPathLabel")); //$NON-NLS-1$ if (emulatorPath == null) label.setVisible(false); exePathLabel = new Text(composite, SWT.BORDER | SWT.WRAP | SWT.READ_ONLY); exePathLabel.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false)); exePathLabel.setData(".uid", "MainExecutableSelectionWizardPage.exePathLabel"); if (emulatorPath == null) { exePathLabel.setVisible(false); usePathCheck = new Button(composite, SWT.CHECK); usePathCheck.setSelection(false); usePathCheck.setText(Messages.getString("MainExecutableSelectionWizardPage.UsePathLabel.device")); //$NON-NLS-1$ usePathCheck.setToolTipText( Messages.getString("MainExecutableSelectionWizardPage.UsePathLabel.device.ToolTip")); //$NON-NLS-1$ usePathCheck.setData(".uid", "MainExecutableSelectionWizardPage.usePathCheck"); GridData gd = new GridData(SWT.FILL, SWT.CENTER, false, false); gd.verticalIndent = 30; usePathCheck.setLayoutData(gd); usePathCheck.addSelectionListener(new SelectionAdapter() { @Override public void widgetSelected(SelectionEvent e) { if (input.isEmpty()) usePathCheck.setSelection(true); enableControls(usePathCheck.getSelection()); } }); pathText = new Text(composite, SWT.BORDER); pathText.setEnabled(false); pathText.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false)); pathText.setToolTipText( Messages.getString("MainExecutableSelectionWizardPage.UsePathLabel.device.ToolTip")); //$NON-NLS-1$ pathText.addModifyListener(new ModifyListener() { public void modifyText(ModifyEvent e) { validatePage(); } }); pathText.setData(".uid", "MainExecutableSelectionWizardPage.pathText"); if (input.isEmpty()) { usePathCheck.setSelection(true); enableControls(true); } } viewer.addSelectionChangedListener(new ISelectionChangedListener() { public void selectionChanged(SelectionChangedEvent event) { IStructuredSelection selection = (IStructuredSelection) event.getSelection(); String item = (String) selection.getFirstElement(); if (item.equals(BROWSE_ITEM)) { FileDialog fileDialog = new FileDialog(getShell(), SWT.OPEN); fileDialog.setText( Messages.getString("MainExecutableSelectionWizardPage.SelectExectuableTitle")); //$NON-NLS-1$ BrowseDialogUtils.initializeFrom(fileDialog, emulatorPath); fileDialog.setFilterExtensions(FILTER_EXTS); fileDialog.setFilterNames(FILTER_EXT_NAMES); String pathstr = fileDialog.open(); if (pathstr != null) { IPath path = new Path(pathstr); String displayString = path.lastSegment(); Pair<IPath, IPath> pair = new Pair<IPath, IPath>(path, null); if (!displayStringToExeMmpPair.values().contains(pair)) { displayStringToExeMmpPair.put(displayString, pair); input.add(displayString); viewer.setInput(input); } item = displayString; } else { // just set selection to first item in combo, if user cancels browse item = viewer.getCombo().getItem(0); } viewer.setSelection(new StructuredSelection(item)); } else { Pair<IPath, IPath> pair = getSelectedExeMmpPair(item); exePathLabel.setText(pair.first.toOSString()); exePathLabel.getParent().layout(); } } }); } viewer.setInput(input); if (!input.isEmpty()) { int index = (emulatorPath != null && combo.getItemCount() > 1 && !useEmulatorByDefault) ? 1 : 0; if (index == 1 && defaultExecutable != null) { int defaultExeIndex = index = combo.indexOf(defaultExecutable.lastSegment()); if (defaultExeIndex > 0) index = defaultExeIndex; } combo.select(index); if (exePathLabel != null) { Pair<IPath, IPath> pair = getSelectedExeMmpPair(combo.getItem(index)); exePathLabel.setText(pair.first.toOSString()); } } setControl(composite); Dialog.applyDialogFont(parent); validatePage(); }
From source file:com.nokia.tools.theme.s60.ui.animation.TimingModelComposite.java
License:Open Source License
private void createTimeModelCombo(Composite root) { timeCombo = new ComboViewer(root, SWT.DROP_DOWN | SWT.READ_ONLY); timeCombo.setContentProvider(new IStructuredContentProvider() { public Object[] getElements(Object inputElement) { if (inputElement instanceof String[]) { return (String[]) inputElement; }/*w w w . j a v a2 s . c o m*/ return null; } public void inputChanged(Viewer viewer, Object oldInput, Object newInput) { } public void dispose() { } }); timeCombo.setLabelProvider(new ILabelProvider() { public Image getImage(Object element) { return null; } public String getText(Object element) { return element.toString(); } public void addListener(ILabelProviderListener listener) { } public boolean isLabelProperty(Object element, String property) { return false; } public void removeListener(ILabelProviderListener listener) { } public void dispose() { } }); timeCombo.addSelectionChangedListener(new ISelectionChangedListener() { public void selectionChanged(SelectionChangedEvent event) { timeComboSelChanged(); } }); timeCombo.setInput(timeModelInput); }
From source file:com.photon.phresco.ui.internal.controls.PhrescoConfigControl.java
License:Apache License
public PhrescoConfigControl(Composite parent, int style, IPath configFilePath, String projectCode) { super(parent, style); GridLayout layout = new GridLayout(1, false); setLayout(layout);/*from w ww .j a va2s . c o m*/ GridData data = new GridData(GridData.FILL_BOTH); setLayoutData(data); Composite envComposite = new Composite(this, SWT.NONE); envComposite.setLayout(new GridLayout(3, false)); envComposite.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false, 1, 1)); Label lblEnviroments = new Label(envComposite, SWT.NONE); lblEnviroments.setLayoutData(new GridData(SWT.RIGHT, SWT.CENTER, false, false, 1, 1)); lblEnviroments.setText("Enviroments"); configPath = configFilePath; ComboViewer comboViewer = new ComboViewer(envComposite, SWT.NONE | SWT.READ_ONLY); Combo combo = comboViewer.getCombo(); combo.setLayoutData(new GridData(SWT.DEFAULT, SWT.CENTER, false, false, 1, 1)); comboViewer.setContentProvider(new ArrayContentProvider()); comboViewer.setLabelProvider(new LabelProvider()); comboViewer.setInput(new String[] { configPath.toOSString(), "production" }); Button envManageBtn = new Button(envComposite, SWT.PUSH); envManageBtn.setText("Manage Environments"); envManageBtn.setLayoutData(new GridData(SWT.DEFAULT, SWT.CENTER, false, false, 1, 1)); final ManageEnvironmentsDialog environmentsDialog = new ManageEnvironmentsDialog(null, projectCode); envManageBtn.addListener(SWT.Selection, new Listener() { @Override public void handleEvent(Event event) { environmentsDialog.create(); environmentsDialog.open(); } }); Button addConfigBtn = new Button(envComposite, SWT.PUSH); addConfigBtn.setText("Add..."); final Composite ConfigComposite = new Composite(this, SWT.NONE); ConfigComposite.setLayout(new GridLayout(1, false)); ConfigComposite.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true, 1, 1)); final CheckboxTableViewer checkboxTableViewer = CheckboxTableViewer.newCheckList(ConfigComposite, SWT.BORDER | SWT.FULL_SELECTION); table = checkboxTableViewer.getTable(); table.setHeaderVisible(true); table.setLinesVisible(true); table.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true, 1, 1)); TableColumn tblNameColumn = new TableColumn(table, SWT.NONE); tblNameColumn.setWidth(100); tblNameColumn.setText("Name"); TableColumn tblValueColumn = new TableColumn(table, SWT.NONE); tblValueColumn.setWidth(100); tblValueColumn.setText("Description"); TableColumn tblDescColumn = new TableColumn(table, SWT.NONE); tblDescColumn.setWidth(200); tblDescColumn.setText("Environment"); TableColumn tblStatusColumn = new TableColumn(table, SWT.NONE); tblStatusColumn.setWidth(100); tblStatusColumn.setText("Status"); settingsInfoList = getConfigValues(projectCode); checkboxTableViewer.setContentProvider(new ArrayContentProvider()); checkboxTableViewer.setLabelProvider(new ITableLabelProvider() { @Override public void removeListener(ILabelProviderListener listener) { // TODO Auto-generated method stub } @Override public boolean isLabelProperty(Object element, String property) { // TODO Auto-generated method stub return false; } @Override public void dispose() { // TODO Auto-generated method stub } @Override public void addListener(ILabelProviderListener listener) { // TODO Auto-generated method stub } @Override public String getColumnText(Object element, int columnIndex) { SettingsInfo settingsInfo = (SettingsInfo) element; switch (columnIndex) { case 0: return settingsInfo.getName(); case 1: return settingsInfo.getDescription(); case 2: return settingsInfo.getType() + " [" + settingsInfo.getEnvName() + "]"; } return ""; } @Override public Image getColumnImage(Object element, int columnIndex) { return null; } }); checkboxTableViewer.setInput(settingsInfoList); final ConfigDialog dialog = new ConfigDialog(null, projectCode); addConfigBtn.addListener(SWT.Selection, new Listener() { @Override public void handleEvent(Event event) { dialog.create(); if (dialog.open() == Window.OK) { // dialog.addSave(); checkboxTableViewer.add(dialog.getSettingsInfo()); } } }); }
From source file:com.rinke.solutions.pinball.PinDmdEditor.java
/** * Create contents of the window.//from w w w.ja va 2 s. c o m */ void createContents(Shell shell) { shell.setSize(1238, 657); shell.setText("Pin2dmd - Editor"); shell.setLayout(new GridLayout(4, false)); createMenu(shell); recentProjectsMenuManager = new RecentMenuManager("recentProject", 4, menuPopRecentProjects, e -> loadProject((String) e.widget.getData())); recentProjectsMenuManager.loadRecent(); recentPalettesMenuManager = new RecentMenuManager("recentPalettes", 4, mntmRecentPalettes, e -> paletteHandler.loadPalette((String) e.widget.getData())); recentPalettesMenuManager.loadRecent(); recentAnimationsMenuManager = new RecentMenuManager("recentAnimations", 4, mntmRecentAnimations, e -> aniAction.loadAni(((String) e.widget.getData()), true, false)); recentAnimationsMenuManager.loadRecent(); resManager = new LocalResourceManager(JFaceResources.getResources(), shell); Label lblAnimations = new Label(shell, SWT.NONE); lblAnimations.setText("Animations"); Label lblKeyframes = new Label(shell, SWT.NONE); lblKeyframes.setText("KeyFrames"); Label lblPreview = new Label(shell, SWT.NONE); lblPreview.setText("Preview"); new Label(shell, SWT.NONE); aniListViewer = new TableViewer(shell, SWT.BORDER | SWT.V_SCROLL); Table aniList = aniListViewer.getTable(); GridData gd_aniList = new GridData(SWT.LEFT, SWT.FILL, false, false, 1, 1); gd_aniList.widthHint = 189; aniList.setLayoutData(gd_aniList); aniList.setLinesVisible(true); aniList.addKeyListener(new EscUnselect(aniListViewer)); aniListViewer.setContentProvider(ArrayContentProvider.getInstance()); aniListViewer.setLabelProvider(new LabelProviderAdapter(o -> ((Animation) o).getDesc())); aniListViewer.setInput(animations.values()); aniListViewer.addSelectionChangedListener(event -> { IStructuredSelection selection = (IStructuredSelection) event.getSelection(); onAnimationSelectionChanged(selection.size() > 0 ? (Animation) selection.getFirstElement() : null); }); TableViewerColumn viewerCol1 = new TableViewerColumn(aniListViewer, SWT.LEFT); viewerCol1.setEditingSupport( new GenericTextCellEditor(aniListViewer, e -> ((Animation) e).getDesc(), (e, v) -> { Animation ani = (Animation) e; updateAnimationMapKey(ani.getDesc(), v); ani.setDesc(v); frameSeqViewer.refresh(); })); viewerCol1.getColumn().setWidth(220); viewerCol1.setLabelProvider(new ColumnLabelProviderAdapter(o -> ((Animation) o).getDesc())); keyframeTableViewer = new TableViewer(shell, SWT.SINGLE | SWT.V_SCROLL); Table keyframeList = keyframeTableViewer.getTable(); GridData gd_keyframeList = new GridData(SWT.LEFT, SWT.FILL, false, false, 1, 1); gd_keyframeList.widthHint = 137; keyframeList.setLinesVisible(true); keyframeList.setLayoutData(gd_keyframeList); keyframeList.addKeyListener(new EscUnselect(keyframeTableViewer)); //keyframeTableViewer.setLabelProvider(new KeyframeLabelProvider(shell)); keyframeTableViewer.setContentProvider(ArrayContentProvider.getInstance()); keyframeTableViewer.setInput(project.palMappings); keyframeTableViewer.addSelectionChangedListener(event -> keyFrameChanged(event)); TableViewerColumn viewerColumn = new TableViewerColumn(keyframeTableViewer, SWT.LEFT); viewerColumn.setEditingSupport( new GenericTextCellEditor(keyframeTableViewer, e -> ((PalMapping) e).name, (e, v) -> { ((PalMapping) e).name = v; })); viewerColumn.getColumn().setWidth(200); viewerColumn.setLabelProvider(new KeyframeLabelProvider(shell)); dmdWidget = new DMDWidget(shell, SWT.DOUBLE_BUFFERED, this.dmd, true); // dmdWidget.setBounds(0, 0, 700, 240); GridData gd_dmdWidget = new GridData(SWT.FILL, SWT.FILL, false, false, 2, 1); gd_dmdWidget.heightHint = 231; gd_dmdWidget.widthHint = 826; dmdWidget.setLayoutData(gd_dmdWidget); dmdWidget.setPalette(activePalette); dmdWidget.addListeners(l -> frameChanged(l)); Composite composite_1 = new Composite(shell, SWT.NONE); composite_1.setLayout(new GridLayout(2, false)); GridData gd_composite_1 = new GridData(SWT.LEFT, SWT.CENTER, false, false, 1, 1); gd_composite_1.heightHint = 35; gd_composite_1.widthHint = 206; composite_1.setLayoutData(gd_composite_1); btnRemoveAni = new Button(composite_1, SWT.NONE); btnRemoveAni.setLayoutData(new GridData(SWT.LEFT, SWT.TOP, false, false, 1, 1)); btnRemoveAni.addSelectionListener(new SelectionAdapter() { @Override public void widgetSelected(SelectionEvent e) { } }); btnRemoveAni.setText("Remove"); btnRemoveAni.setEnabled(false); btnRemoveAni.addListener(SWT.Selection, e -> { if (selectedAnimation.isPresent()) { String key = selectedAnimation.get().getDesc(); animations.remove(key); playingAnis.clear(); animationHandler.setAnimations(playingAnis); animationHandler.setClockActive(true); } }); btnSortAni = new Button(composite_1, SWT.NONE); btnSortAni.setLayoutData(new GridData(SWT.LEFT, SWT.TOP, false, false, 1, 1)); btnSortAni.setText("Sort"); btnSortAni.addListener(SWT.Selection, e -> sortAnimations()); Composite composite_2 = new Composite(shell, SWT.NONE); composite_2.setLayout(new GridLayout(3, false)); GridData gd_composite_2 = new GridData(SWT.LEFT, SWT.CENTER, false, false, 1, 1); gd_composite_2.heightHint = 35; gd_composite_2.widthHint = 157; composite_2.setLayoutData(gd_composite_2); btnDeleteKeyframe = new Button(composite_2, SWT.NONE); GridData gd_btnDeleteKeyframe = new GridData(SWT.LEFT, SWT.CENTER, false, false, 1, 1); gd_btnDeleteKeyframe.widthHint = 88; btnDeleteKeyframe.setLayoutData(gd_btnDeleteKeyframe); btnDeleteKeyframe.setText("Remove"); btnDeleteKeyframe.setEnabled(false); btnDeleteKeyframe.addListener(SWT.Selection, e -> { if (selectedPalMapping != null) { project.palMappings.remove(selectedPalMapping); keyframeTableViewer.refresh(); checkReleaseMask(); } }); Button btnSortKeyFrames = new Button(composite_2, SWT.NONE); btnSortKeyFrames.setText("Sort"); btnSortKeyFrames.addListener(SWT.Selection, e -> sortKeyFrames()); new Label(composite_2, SWT.NONE); scale = new Scale(shell, SWT.NONE); scale.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, false, false, 2, 1)); scale.addListener(SWT.Selection, e -> animationHandler.setPos(scale.getSelection())); Group grpKeyframe = new Group(shell, SWT.NONE); grpKeyframe.setLayout(new GridLayout(3, false)); GridData gd_grpKeyframe = new GridData(SWT.FILL, SWT.TOP, false, false, 2, 4); gd_grpKeyframe.heightHint = 191; gd_grpKeyframe.widthHint = 350; grpKeyframe.setLayoutData(gd_grpKeyframe); grpKeyframe.setText("KeyFrames"); Composite composite_hash = new Composite(grpKeyframe, SWT.NONE); //gd_composite_hash.widthHint = 105; GridData gd_composite_hash = new GridData(SWT.LEFT, SWT.CENTER, false, false, 2, 1); gd_composite_hash.widthHint = 148; composite_hash.setLayoutData(gd_composite_hash); createHashButtons(composite_hash, 10, 0); previewDmd = new DMDWidget(grpKeyframe, SWT.DOUBLE_BUFFERED, dmd, false); GridData gd_dmdPreWidget = new GridData(SWT.CENTER, SWT.TOP, false, false, 1, 1); gd_dmdPreWidget.heightHint = 40; gd_dmdPreWidget.widthHint = 132; previewDmd.setLayoutData(gd_dmdPreWidget); previewDmd.setDrawingEnabled(false); previewDmd.setPalette(previewPalettes.get(0)); new Label(grpKeyframe, SWT.NONE); btnAddColormaskKeyFrame = new Button(grpKeyframe, SWT.NONE); btnAddColormaskKeyFrame .setToolTipText("Adds a key frame that trigger a color masking scene to be overlayed"); btnAddColormaskKeyFrame.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, false, false, 1, 1)); btnAddColormaskKeyFrame.setText("Add ColorMask"); btnAddColormaskKeyFrame.setEnabled(false); btnAddColormaskKeyFrame.addListener(SWT.Selection, e -> addFrameSeq(SwitchMode.ADD)); btnAddKeyframe = new Button(grpKeyframe, SWT.NONE); btnAddKeyframe.setToolTipText("Adds a key frame that switches palette"); btnAddKeyframe.setLayoutData(new GridData(SWT.FILL, SWT.BOTTOM, false, false, 1, 1)); btnAddKeyframe.setText("Add PalSwitch"); btnAddKeyframe.setEnabled(false); btnAddKeyframe.addListener(SWT.Selection, e -> addKeyFrame(SwitchMode.PALETTE)); Label lblDuration = new Label(grpKeyframe, SWT.NONE); lblDuration.setLayoutData(new GridData(SWT.RIGHT, SWT.CENTER, false, false, 1, 1)); lblDuration.setText("Duration:"); txtDuration = new Text(grpKeyframe, SWT.BORDER); GridData gd_txtDuration = new GridData(SWT.FILL, SWT.CENTER, false, false, 1, 1); gd_txtDuration.widthHint = 93; txtDuration.setLayoutData(gd_txtDuration); txtDuration.setText("0"); txtDuration.addListener(SWT.Verify, e -> e.doit = Pattern.matches("^[0-9]*$", e.text)); txtDuration.addListener(SWT.Modify, e -> { if (selectedPalMapping != null) { selectedPalMapping.durationInMillis = Integer.parseInt(txtDuration.getText()); selectedPalMapping.durationInFrames = (int) selectedPalMapping.durationInMillis / 40; } }); btnFetchDuration = new Button(grpKeyframe, SWT.NONE); btnFetchDuration.setToolTipText( "Fetches duration for palette switches by calculating the difference between actual timestamp and keyframe timestamp"); btnFetchDuration.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, false, false, 1, 1)); btnFetchDuration.setText("Fetch Duration"); btnFetchDuration.setEnabled(false); btnFetchDuration.addListener(SWT.Selection, e -> { if (selectedPalMapping != null) { selectedPalMapping.durationInMillis = lastTimeCode - saveTimeCode; selectedPalMapping.durationInFrames = (int) selectedPalMapping.durationInMillis / FRAME_RATE; txtDuration.setText(selectedPalMapping.durationInMillis + ""); } }); Label lblNewLabel = new Label(grpKeyframe, SWT.NONE); lblNewLabel.setLayoutData(new GridData(SWT.RIGHT, SWT.CENTER, false, false, 1, 1)); lblNewLabel.setText("FrameSeq:"); frameSeqViewer = new ComboViewer(grpKeyframe, SWT.NONE); Combo frameSeqCombo = frameSeqViewer.getCombo(); frameSeqCombo.setToolTipText("Choose frame sequence to use with key frame"); GridData gd_frameSeqCombo = new GridData(SWT.FILL, SWT.CENTER, false, false, 1, 1); gd_frameSeqCombo.widthHint = 100; frameSeqCombo.setLayoutData(gd_frameSeqCombo); frameSeqViewer.setLabelProvider(new LabelProviderAdapter(o -> ((Animation) o).getDesc())); frameSeqViewer.setContentProvider(ArrayContentProvider.getInstance()); frameSeqViewer.setInput(frameSeqList); frameSeqViewer.addSelectionChangedListener(event -> frameSeqChanged(event)); btnAddFrameSeq = new Button(grpKeyframe, SWT.NONE); btnAddFrameSeq.setToolTipText("Adds a keyframe that triggers playback of a replacement scene"); btnAddFrameSeq.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, false, false, 1, 1)); btnAddFrameSeq.setText("Add FrameSeq"); btnAddFrameSeq.addListener(SWT.Selection, e -> addFrameSeq(SwitchMode.REPLACE)); btnAddFrameSeq.setEnabled(false); Group grpDetails = new Group(shell, SWT.NONE); grpDetails.setLayout(new GridLayout(10, false)); GridData gd_grpDetails = new GridData(SWT.FILL, SWT.FILL, false, false, 2, 1); gd_grpDetails.heightHint = 21; gd_grpDetails.widthHint = 776; grpDetails.setLayoutData(gd_grpDetails); grpDetails.setText("Details"); Label lblFrame = new Label(grpDetails, SWT.NONE); lblFrame.setText("Frame:"); lblFrameNo = new Label(grpDetails, SWT.NONE); GridData gd_lblFrameNo = new GridData(SWT.LEFT, SWT.CENTER, false, false, 1, 1); gd_lblFrameNo.widthHint = 66; gd_lblFrameNo.minimumWidth = 60; lblFrameNo.setLayoutData(gd_lblFrameNo); lblFrameNo.setText("---"); Label lblTimecode = new Label(grpDetails, SWT.NONE); lblTimecode.setText("Timecode:"); lblTcval = new Label(grpDetails, SWT.NONE); GridData gd_lblTcval = new GridData(SWT.LEFT, SWT.CENTER, false, false, 1, 1); gd_lblTcval.widthHint = 62; gd_lblTcval.minimumWidth = 80; lblTcval.setLayoutData(gd_lblTcval); lblTcval.setText("---"); Label lblDelay = new Label(grpDetails, SWT.NONE); lblDelay.setText("Delay:"); lblDelayVal = new Label(grpDetails, SWT.NONE); GridData gd_lblDelayVal = new GridData(SWT.LEFT, SWT.CENTER, false, false, 1, 1); gd_lblDelayVal.widthHint = 53; lblDelayVal.setLayoutData(gd_lblDelayVal); lblDelayVal.setText("---"); Label lblPlanes = new Label(grpDetails, SWT.NONE); lblPlanes.setText("Planes:"); lblPlanesVal = new Label(grpDetails, SWT.NONE); lblPlanesVal.setText("---"); new Label(grpDetails, SWT.NONE); btnLivePreview = new Button(grpDetails, SWT.CHECK); btnLivePreview.setToolTipText("controls live preview to real display device"); btnLivePreview.setText("Live Preview"); btnLivePreview.addListener(SWT.Selection, e -> switchLivePreview(e)); Composite composite = new Composite(shell, SWT.NONE); composite.setLayout(new GridLayout(9, false)); composite.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, false, false, 2, 1)); btnStartStop = new Button(composite, SWT.NONE); btnStartStop.setText("Start"); btnStartStop.addListener(SWT.Selection, e -> startStop(animationHandler.isStopped())); btnPrev = new Button(composite, SWT.NONE); btnPrev.setText("<"); btnPrev.addListener(SWT.Selection, e -> prevFrame()); btnNext = new Button(composite, SWT.NONE); btnNext.setText(">"); btnNext.addListener(SWT.Selection, e -> nextFrame()); btnMarkStart = new Button(composite, SWT.NONE); btnMarkStart.setToolTipText("Marks start of scene for cutting"); btnMarkEnd = new Button(composite, SWT.NONE); btnCut = new Button(composite, SWT.NONE); btnCut.setToolTipText("Cuts out a new scene for editing and use a replacement or color mask"); btnMarkStart.setText("Mark Start"); btnMarkStart.addListener(SWT.Selection, e -> { cutInfo.setStart(selectedAnimation.get().actFrame); }); btnMarkEnd.setText("Mark End"); btnMarkEnd.addListener(SWT.Selection, e -> { cutInfo.setEnd(selectedAnimation.get().actFrame); }); btnCut.setText("Cut"); btnCut.addListener(SWT.Selection, e -> { // respect number of planes while cutting / copying Animation ani = cutScene(selectedAnimation.get(), cutInfo.getStart(), cutInfo.getEnd(), "Scene " + animations.size()); log.info("cutting out scene from {} to {}", cutInfo); cutInfo.reset(); // TODO mark such a scene somehow, to copy it to the // projects frames sequence for later export // alternatively introduce a dedicated flag for scenes that // should be exported // also define a way that a keyframe triggers a replacement // sequence instead of switching // the palette only // TODO NEED TO ADD a reference to the animation in the list // / map project.scenes.add(new Scene(ani.getDesc(), ani.start, ani.end, activePalette.index)); }); new Label(composite, SWT.NONE); Button btnIncPitch = new Button(composite, SWT.NONE); btnIncPitch.setText("+"); btnIncPitch.addListener(SWT.Selection, e -> dmdWidget.incPitch()); Button btnDecPitch = new Button(composite, SWT.NONE); btnDecPitch.setText("-"); btnDecPitch.addListener(SWT.Selection, e -> dmdWidget.decPitch()); Group grpPalettes = new Group(shell, SWT.NONE); grpPalettes.setLayout(new GridLayout(4, false)); GridData gd_grpPalettes = new GridData(SWT.LEFT, SWT.TOP, false, false, 1, 1); gd_grpPalettes.widthHint = 479; gd_grpPalettes.heightHint = 71; grpPalettes.setLayoutData(gd_grpPalettes); grpPalettes.setText("Palettes"); paletteComboViewer = new ComboViewer(grpPalettes, SWT.NONE); Combo combo = paletteComboViewer.getCombo(); GridData gd_combo = new GridData(SWT.FILL, SWT.CENTER, false, false, 1, 1); gd_combo.widthHint = 166; combo.setLayoutData(gd_combo); paletteComboViewer.setContentProvider(ArrayContentProvider.getInstance()); paletteComboViewer .setLabelProvider(new LabelProviderAdapter(o -> ((Palette) o).index + " - " + ((Palette) o).name)); paletteComboViewer.setInput(project.palettes); paletteComboViewer.addSelectionChangedListener(event -> { IStructuredSelection selection = (IStructuredSelection) event.getSelection(); if (selection.size() > 0) { paletteChanged((Palette) selection.getFirstElement()); } }); paletteTypeComboViewer = new ComboViewer(grpPalettes, SWT.READ_ONLY); Combo combo_1 = paletteTypeComboViewer.getCombo(); combo_1.setToolTipText( "Type of palette. Default palette is choosen at start and after timed switch is expired"); GridData gd_combo_1 = new GridData(SWT.FILL, SWT.CENTER, false, false, 1, 1); gd_combo_1.widthHint = 85; combo_1.setLayoutData(gd_combo_1); paletteTypeComboViewer.setContentProvider(ArrayContentProvider.getInstance()); paletteTypeComboViewer.setInput(PaletteType.values()); paletteTypeComboViewer.setSelection(new StructuredSelection(activePalette.type)); paletteTypeComboViewer.addSelectionChangedListener(e -> paletteTypeChanged(e)); btnNewPalette = new Button(grpPalettes, SWT.NONE); btnNewPalette.setToolTipText("Creates a new palette by copying the actual colors"); btnNewPalette.setText("New"); btnNewPalette.addListener(SWT.Selection, e -> paletteHandler.newPalette()); btnRenamePalette = new Button(grpPalettes, SWT.NONE); btnRenamePalette.setToolTipText("Confirms the new palette name"); btnRenamePalette.setText("Rename"); btnRenamePalette.addListener(SWT.Selection, e -> { String newName = paletteComboViewer.getCombo().getText(); if (newName.contains(" - ")) { activePalette.name = newName.split(" - ")[1]; paletteComboViewer.setSelection(new StructuredSelection(activePalette)); paletteComboViewer.refresh(); } else { warn("Illegal palette name", "Palette names must consist of palette index and name.\nName format therefore must be '<idx> - <name>'"); paletteComboViewer.getCombo().setText(activePalette.index + " - " + activePalette.name); } }); Composite grpPal = new Composite(grpPalettes, SWT.NONE); grpPal.setLayout(new GridLayout(1, false)); GridData gd_grpPal = new GridData(SWT.LEFT, SWT.TOP, false, false, 2, 1); gd_grpPal.widthHint = 313; gd_grpPal.heightHint = 22; grpPal.setLayoutData(gd_grpPal); // GridData gd_grpPal = new GridData(SWT.LEFT, SWT.CENTER, false, false, // 1, 1); // gd_grpPal.widthHint = 223; // gd_grpPal.heightHint = 61; // grpPal.setLayoutData(gd_grpPal); // paletteTool = new PaletteTool(shell, grpPal, SWT.FLAT | SWT.RIGHT, activePalette); paletteTool.addListener(dmdWidget); Label lblCtrlclickToEdit = new Label(grpPalettes, SWT.NONE); GridData gd_lblCtrlclickToEdit = new GridData(SWT.LEFT, SWT.CENTER, false, false, 2, 1); gd_lblCtrlclickToEdit.widthHint = 139; lblCtrlclickToEdit.setLayoutData(gd_lblCtrlclickToEdit); lblCtrlclickToEdit.setText("Ctrl-Click to edit color"); Composite composite_3 = new Composite(shell, SWT.NONE); GridLayout gl_composite_3 = new GridLayout(1, false); gl_composite_3.marginWidth = 0; gl_composite_3.marginHeight = 0; composite_3.setLayout(gl_composite_3); GridData gd_composite_3 = new GridData(SWT.LEFT, SWT.FILL, false, false, 1, 2); gd_composite_3.heightHint = 190; gd_composite_3.widthHint = 338; composite_3.setLayoutData(gd_composite_3); goDmdGroup = new GoDmdGroup(composite_3); Group grpDrawing = new Group(shell, SWT.NONE); grpDrawing.setLayout(new GridLayout(6, false)); GridData gd_grpDrawing = new GridData(SWT.LEFT, SWT.TOP, false, false, 1, 1); gd_grpDrawing.heightHint = 63; gd_grpDrawing.widthHint = 479; grpDrawing.setLayoutData(gd_grpDrawing); grpDrawing.setText("Drawing"); drawToolBar = new ToolBar(grpDrawing, SWT.FLAT | SWT.RIGHT); drawToolBar.setLayoutData(new GridData(SWT.FILL, SWT.FILL, false, false, 1, 1)); ToolItem tltmPen = new ToolItem(drawToolBar, SWT.RADIO); tltmPen.setImage( resManager.createImage(ImageDescriptor.createFromFile(PinDmdEditor.class, "/icons/pencil.png"))); tltmPen.addListener(SWT.Selection, e -> dmdWidget.setDrawTool(drawTools.get("pencil"))); ToolItem tltmFill = new ToolItem(drawToolBar, SWT.RADIO); tltmFill.setImage(resManager .createImage(ImageDescriptor.createFromFile(PinDmdEditor.class, "/icons/color-fill.png"))); tltmFill.addListener(SWT.Selection, e -> dmdWidget.setDrawTool(drawTools.get("fill"))); ToolItem tltmRect = new ToolItem(drawToolBar, SWT.RADIO); tltmRect.setImage( resManager.createImage(ImageDescriptor.createFromFile(PinDmdEditor.class, "/icons/rect.png"))); tltmRect.addListener(SWT.Selection, e -> dmdWidget.setDrawTool(drawTools.get("rect"))); ToolItem tltmLine = new ToolItem(drawToolBar, SWT.RADIO); tltmLine.setImage( resManager.createImage(ImageDescriptor.createFromFile(PinDmdEditor.class, "/icons/line.png"))); tltmLine.addListener(SWT.Selection, e -> dmdWidget.setDrawTool(drawTools.get("line"))); ToolItem tltmCircle = new ToolItem(drawToolBar, SWT.RADIO); tltmCircle.setImage( resManager.createImage(ImageDescriptor.createFromFile(PinDmdEditor.class, "/icons/oval.png"))); tltmCircle.addListener(SWT.Selection, e -> dmdWidget.setDrawTool(drawTools.get("circle"))); ToolItem tltmColorize = new ToolItem(drawToolBar, SWT.RADIO); tltmColorize.setImage( resManager.createImage(ImageDescriptor.createFromFile(PinDmdEditor.class, "/icons/colorize.png"))); tltmColorize.addListener(SWT.Selection, e -> dmdWidget.setDrawTool(drawTools.get("colorize"))); drawTools.put("pencil", new SetPixelTool(paletteTool.getSelectedColor())); drawTools.put("fill", new FloodFillTool(paletteTool.getSelectedColor())); drawTools.put("rect", new RectTool(paletteTool.getSelectedColor())); drawTools.put("line", new LineTool(paletteTool.getSelectedColor())); drawTools.put("circle", new CircleTool(paletteTool.getSelectedColor())); drawTools.put("colorize", new ColorizeTool(paletteTool.getSelectedColor())); drawTools.values().forEach(d -> paletteTool.addIndexListener(d)); paletteTool.addListener(palette -> { if (livePreviewActive) { connector.upload(activePalette, handle); } }); new Label(grpDrawing, SWT.NONE); btnColorMask = new Button(grpDrawing, SWT.CHECK); btnColorMask.setToolTipText("limits drawing to upper planes, so that this will just add coloring layers"); btnColorMask.setText("ColMask"); btnColorMask.addListener(SWT.Selection, e -> switchColorMask(btnColorMask.getSelection())); Label lblMaskNo = new Label(grpDrawing, SWT.NONE); lblMaskNo.setText("Mask No:"); maskSpinner = new Spinner(grpDrawing, SWT.BORDER); maskSpinner.setToolTipText("select the mask to use"); maskSpinner.setMinimum(0); maskSpinner.setMaximum(9); maskSpinner.addListener(SWT.Selection, e -> maskNumberChanged(e)); btnMask = new Button(grpDrawing, SWT.CHECK); btnMask.setText("Show Mask"); btnMask.addListener(SWT.Selection, e -> switchMask(btnMask.getSelection())); btnCopyToPrev = new Button(grpDrawing, SWT.NONE); btnCopyToPrev.setLayoutData(new GridData(SWT.RIGHT, SWT.CENTER, false, false, 1, 1)); btnCopyToPrev.setText("CopyToPrev"); btnCopyToPrev.addListener(SWT.Selection, e -> copyAndMoveToPrevFrame()); new Label(grpDrawing, SWT.NONE); btnCopyToNext = new Button(grpDrawing, SWT.NONE); btnCopyToNext.setToolTipText("copy the actual scene / color mask to next frame and move forward"); btnCopyToNext.setLayoutData(new GridData(SWT.LEFT, SWT.CENTER, false, false, 2, 1)); btnCopyToNext.setText("CopyToNext"); btnCopyToNext.addListener(SWT.Selection, e -> copyAndMoveToNextFrame()); btnUndo = new Button(grpDrawing, SWT.NONE); btnUndo.setText("&Undo"); btnUndo.addListener(SWT.Selection, e -> undo()); btnRedo = new Button(grpDrawing, SWT.NONE); btnRedo.setText("&Redo"); btnRedo.addListener(SWT.Selection, e -> redo()); ObserverManager.bind(maskDmdObserver, e -> btnUndo.setEnabled(e), () -> maskDmdObserver.canUndo()); ObserverManager.bind(maskDmdObserver, e -> btnRedo.setEnabled(e), () -> maskDmdObserver.canRedo()); }
From source file:com.rinke.solutions.pinball.ui.UsbConfig.java
/** * Create contents of the dialog./*from ww w . j a v a2 s . c o m*/ */ private void createContents() { shell = new Shell(getParent(), getStyle()); shell.setSize(480, 277); shell.setText("Config Device"); shell.setLayout(new GridLayout(3, false)); Label lblDeviceMode = new Label(shell, SWT.NONE); lblDeviceMode.setText("Device Mode:"); Combo deviceModeCombo = new Combo(shell, SWT.NONE); GridData gd_combo = new GridData(SWT.LEFT, SWT.CENTER, false, false, 1, 1); gd_combo.widthHint = 165; deviceModeCombo.setLayoutData(gd_combo); for (DeviceMode mode : DeviceMode.values()) { deviceModeCombo.add(mode.name(), mode.ordinal()); } Button btnSetDeviceMode = new Button(shell, SWT.NONE); btnSetDeviceMode.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, false, false, 1, 1)); btnSetDeviceMode.setText("Set Device Mode"); btnSetDeviceMode.addListener(SWT.Selection, e -> connector.switchToMode(deviceModeCombo.getSelectionIndex(), null)); Label lblPalette = new Label(shell, SWT.NONE); lblPalette.setLayoutData(new GridData(SWT.RIGHT, SWT.CENTER, false, false, 1, 1)); lblPalette.setText("Palette:"); ComboViewer comboViewerDefaultPalette = new ComboViewer(shell, SWT.NONE); Combo comboDefaultPalette = comboViewerDefaultPalette.getCombo(); GridData gd_comboDefaultPalette = new GridData(SWT.LEFT, SWT.CENTER, true, false, 1, 1); gd_comboDefaultPalette.widthHint = 161; comboDefaultPalette.setLayoutData(gd_comboDefaultPalette); comboViewerDefaultPalette.setContentProvider(ArrayContentProvider.getInstance()); comboViewerDefaultPalette.setInput(DefaultPalette.values()); comboDefaultPalette.select(0); Button btnSetPalette = new Button(shell, SWT.NONE); btnSetPalette.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, false, false, 1, 1)); btnSetPalette.setText("Set Palette"); btnSetPalette.addListener(SWT.Selection, e -> connector.switchToPal(comboDefaultPalette.getSelectionIndex(), null)); Label lblNewLabel = new Label(shell, SWT.NONE); lblNewLabel.setLayoutData(new GridData(SWT.RIGHT, SWT.TOP, false, false, 1, 1)); lblNewLabel.setText("Brightness:"); Composite grpTiming = new Composite(shell, SWT.NONE); grpTiming.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, false, false, 1, 3)); //grpTiming.setText("Timing"); grpTiming.setLayout(new GridLayout(1, false)); Scale scale = new Scale(grpTiming, SWT.NONE); GridData gd_scale = new GridData(SWT.CENTER, SWT.CENTER, false, false, 1, 1); gd_scale.widthHint = 177; scale.setLayoutData(gd_scale); Scale scale_1 = new Scale(grpTiming, SWT.NONE); scale_1.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, false, false, 1, 1)); Scale scale_2 = new Scale(grpTiming, SWT.NONE); scale_2.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, false, false, 1, 1)); Scale scale_3 = new Scale(grpTiming, SWT.NONE); scale_3.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, false, false, 1, 1)); Scale scale_4 = new Scale(grpTiming, SWT.NONE); scale_4.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, false, false, 1, 1)); Button btnResetDevice = new Button(shell, SWT.NONE); btnResetDevice.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, false, false, 1, 1)); btnResetDevice.setText("Reset Device"); btnResetDevice.addListener(SWT.Selection, e -> connector.sendCmd(UsbCmd.RESET)); new Label(shell, SWT.NONE); Button btnRemoveLicenseFrom = new Button(shell, SWT.NONE); btnRemoveLicenseFrom.setText("Remove License from device"); btnRemoveLicenseFrom.addListener(SWT.Selection, e -> removeLicenses()); new Label(shell, SWT.NONE); new Label(shell, SWT.NONE); new Label(shell, SWT.NONE); new Label(shell, SWT.NONE); new Label(shell, SWT.NONE); new Label(shell, SWT.NONE); new Label(shell, SWT.NONE); Button btnOk = new Button(shell, SWT.NONE); btnOk.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, false, false, 1, 1)); btnOk.setText("Ok"); btnOk.addListener(SWT.Selection, e -> shell.close()); }
From source file:com.runwaysdk.manager.widgets.WidgetVisitor.java
License:Open Source License
@Override public void visitEnumeration(MdAttributeEnumerationDAOIF attribute) { if (validateAttribute(attribute)) { boolean enabled = this.isEnabled(attribute); Composite composite = new Composite(parent, SWT.NONE); composite.setLayout(new FormLayout()); Label label = new Label(composite, SWT.NONE); label.setText(attribute.getDisplayLabel(Localizer.getLocale())); label.setSize(200, 20);/* w w w. ja v a 2 s . c om*/ label.setLayoutData(new FormData(200, 20)); FormData data = new FormData(); data.left = new FormAttachment(label); MdEnumerationDAOIF mdEnumeration = attribute.getMdEnumerationDAO(); List<BusinessDAOIF> items = mdEnumeration.getAllEnumItems(); List<LabelValuePair> list = new LinkedList<LabelValuePair>(); for (BusinessDAOIF item : items) { String itemLabel = item.getStructValue(EnumerationMasterInfo.DISPLAY_LABEL, Localizer.DEFAULT_LOCALE); String id = item.getId(); list.add(new LabelValuePair(itemLabel, id)); } final ComboViewer combo = new ComboViewer(composite, SWT.READ_ONLY); combo.setContentProvider(new ArrayContentProvider()); combo.setLabelProvider(new LabelProvider()); combo.setInput(list.toArray(new LabelValuePair[list.size()])); combo.getControl().setLayoutData(data); combo.getControl().setEnabled(enabled); this.controls.put(attribute.definesAttribute(), combo); } }
From source file:com.salesforce.ide.ui.editors.properysheets.widgets.ComboWidget.java
License:Open Source License
public void addTo(Composite composite) { toolkit.createLabel(composite, label); comboViewer = new ComboViewer(composite, SWT.DROP_DOWN); comboViewer.setContentProvider(new ComboBoxContentProvider()); comboViewer.setLabelProvider(new ComboBoxLabelProvider()); GridData gridData = new GridData(); gridData.horizontalAlignment = GridData.FILL; gridData.grabExcessHorizontalSpace = true; comboViewer.getControl().setLayoutData(gridData); }
From source file:com.subgraph.vega.ui.http.builder.RequestAddressEditor.java
License:Open Source License
public RequestAddressEditor(Composite parent, final IHttpRequestBuilder requestBuilder) { super(parent, SWT.NONE); this.requestBuilder = requestBuilder; final GridLayout controlLayout = new GridLayout(3, false); controlLayout.marginWidth = 0;// w w w . j a v a 2 s.c om controlLayout.marginHeight = 0; controlLayout.marginLeft = 0; controlLayout.marginTop = 0; controlLayout.marginRight = 0; controlLayout.marginBottom = 0; setLayout(controlLayout); final Composite schemeControl = new Composite(this, SWT.NONE); schemeControl.setLayout(new GridLayout(2, false)); schemeControl.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, false, false, 1, 1)); Label label = new Label(schemeControl, SWT.NONE); label.setText("Scheme:"); label.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, false, false, 1, 1)); requestScheme = new ComboViewer(schemeControl, SWT.READ_ONLY); requestScheme.setContentProvider(new ArrayContentProvider()); requestScheme.setLabelProvider(new LabelProvider() { public String getText(Object element) { return (String) element; } }); requestScheme.setInput(requestSchemes); requestScheme.setSelection(new StructuredSelection(requestSchemes[0])); requestScheme.addSelectionChangedListener(createSelectionChangedListenerRequestScheme()); final Composite hostControl = new Composite(this, SWT.NONE); hostControl.setLayout(new GridLayout(2, false)); hostControl.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false, 1, 1)); label = new Label(hostControl, SWT.NONE); label.setText("Host:"); label.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, false, false, 1, 1)); requestHost = new Text(hostControl, SWT.BORDER | SWT.SINGLE); requestHost.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false, 1, 1)); final Composite portControl = new Composite(this, SWT.NONE); portControl.setLayout(new GridLayout(2, false)); portControl.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, false, false, 1, 1)); label = new Label(portControl, SWT.NONE); label.setText("Port:"); label.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, false, false, 1, 1)); requestPort = new Text(portControl, SWT.BORDER | SWT.SINGLE); final FontMetrics requestPortFm = new GC(requestPort).getFontMetrics(); GridData requestPortGd = new GridData(SWT.FILL, SWT.CENTER, false, false, 1, 1); requestPortGd.widthHint = requestPortFm.getAverageCharWidth() * 7; requestPort.setLayoutData(requestPortGd); requestPort.addListener(SWT.Verify, new Listener() { public void handleEvent(Event e) { String string = e.text; char[] chars = new char[string.length()]; string.getChars(0, chars.length, chars, 0); for (int i = 0; i < chars.length; i++) { if (!('0' <= chars[i] && chars[i] <= '9')) { e.doit = false; return; } } } }); refresh(); }
From source file:com.subgraph.vega.ui.http.intercept.config.ConfigureInterceptionContent.java
License:Open Source License
private Composite createInterceptorOptions(Composite parent) { final Group rootControl = new Group(parent, SWT.NONE); rootControl.setText("Interceptor Options"); rootControl.setLayout(new GridLayout(2, false)); final Label label = new Label(rootControl, SWT.NONE); label.setText("Intercept for:"); comboViewerInterceptorLevel = new ComboViewer(rootControl, SWT.READ_ONLY); comboViewerInterceptorLevel.setContentProvider(new ArrayContentProvider()); comboViewerInterceptorLevel.setLabelProvider(new LabelProvider() { public String getText(Object element) { return ((HttpInterceptorLevel) element).getName(); }/* www .java 2s . co m*/ }); comboViewerInterceptorLevel.setInput(HttpInterceptorLevel.values()); comboViewerInterceptorLevel .addSelectionChangedListener(createSelectionChangedListenerComboViewerInterceptorLevel()); return rootControl; }