private void updateEnableState() { _useDefaultRE.setEnabled(_enabled); _useProjectRE.setEnabled(_enabled); _RECombo.setEnabled(_enabled && _useProjectRE.isSelected()); if (_preferenceLink != null) { _preferenceLink.setEnabled(_enabled); } if (_group != null) { _group.setEnabled(_enabled); } }
private void setDefaultButtonState() { _useDefaultRE.setEnabled(true); _useProjectRE.setEnabled(true); boolean isBBDefaultRE = VMUtils.isBlackBerryRuntimeTheWorkspaceDefault(); // if the default JRE is non-BlackBerry, select project specific JRE if (!isBBDefaultRE) { _useProjectRE.setSelection(true); _useDefaultRE.setSelection(false); setLastSelectedJREKind(PROJECT_RE); } else { int kind = getLastSelectedJREKind(); _useProjectRE.setSelection(kind == PROJECT_RE); _useDefaultRE.setSelection(kind == DEFAULT_RE); } _RECombo.setEnabled(_useProjectRE.isSelected()); if (_preferenceLink != null) { _preferenceLink.setEnabled(true); } if (_group != null) { _group.setEnabled(true); } }
public LayoutGroup(Composite composite) { final int numColumns = 3; fStdRadio = new SelectionButtonDialogField(SWT.RADIO); fStdRadio.setLabelText(PHPUIMessages.LayoutGroup_OptionBlock_ProjectSrc); // $NON-NLS-1$ fStdRadio.setDialogFieldListener(this); fSrcBinRadio = new SelectionButtonDialogField(SWT.RADIO); fSrcBinRadio.setLabelText(PHPUIMessages.LayoutGroup_OptionBlock_SrcResources); // $NON-NLS-1$ fSrcBinRadio.setDialogFieldListener(this); // getting Preferences default choice boolean useSrcBin = PreferenceConstants.getPreferenceStore() .getBoolean(PreferenceConstants.SRCBIN_FOLDERS_IN_NEWPROJ); fSrcBinRadio.setSelection(useSrcBin); fStdRadio.setSelection(!useSrcBin); // createContent fGroup = new Group(composite, SWT.NONE); fGroup.setFont(composite.getFont()); fGroup.setLayoutData(new GridData(GridData.FILL_HORIZONTAL)); fGroup.setLayout(initGridLayout(new GridLayout(numColumns, false), true)); fGroup.setText(PHPUIMessages.LayoutGroup_OptionBlock_Title); // $NON-NLS-1$ fStdRadio.doFillIntoGrid(fGroup, 3); LayoutUtil.setHorizontalGrabbing(fStdRadio.getSelectionButton(null)); fSrcBinRadio.doFillIntoGrid(fGroup, 2); fPreferenceLink = new Link(fGroup, SWT.NONE); fPreferenceLink.setText(PHPUIMessages.ToggleLinkingAction_link_description); // $NON-NLS-1$ fPreferenceLink.setLayoutData(new GridData(SWT.END, SWT.BEGINNING, true, false)); fPreferenceLink.addSelectionListener(this); fPreferenceLink.setEnabled(true); updateEnableState(); }
/** * Update the enabled Next/Previous links + update the result label. * * @param controller */ private void refreshEnabled(PageableController controller) { resultLabel.setText(PaginationHelper.getResultsText(controller, getLocale())); nextLink.setEnabled(controller.hasNextPage()); previousLink.setEnabled(controller.hasPreviousPage()); }
private void createUI50Actions(final Composite parent) { final Composite container = _tk.createComposite(parent); GridDataFactory.fillDefaults().grab(true, true).span(3, 1).applyTo(container); GridLayoutFactory.fillDefaults().numColumns(1).applyTo(container); // container.setBackground(Display.getCurrent().getSystemColor(SWT.COLOR_YELLOW)); { /* * button: compute smoothing values for all tours */ final Button btnComputValues = _tk.createButton(container, Messages.Compute_Smoothing_Button_ForAllTours, SWT.NONE); GridDataFactory.fillDefaults() .align(SWT.BEGINNING, SWT.FILL) .indent(0, 10) .applyTo(btnComputValues); btnComputValues.setToolTipText(Messages.Compute_Smoothing_Button_ForAllTours_Tooltip); btnComputValues.addSelectionListener( new SelectionAdapter() { @Override public void widgetSelected(final SelectionEvent e) { _smoothingUI.computeSmoothingForAllTours(); } }); /* * link: restore defaults */ Link link = new Link(container, SWT.NONE); GridDataFactory.fillDefaults() // .align(SWT.FILL, SWT.END) .grab(false, true) .applyTo(link); link.setText(Messages.App_Link_RestoreDefaultValues); link.setEnabled(true); link.addSelectionListener( new SelectionAdapter() { @Override public void widgetSelected(final SelectionEvent e) { performDefaults(true); } }); _tk.adapt(link, true, true); /* * link: break time */ link = new Link(container, SWT.NONE); GridDataFactory.fillDefaults() // .align(SWT.FILL, SWT.END) .applyTo(link); link.setText(Messages.TourChart_Smoothing_Link_PrefBreakTime); link.setEnabled(true); link.addSelectionListener( new SelectionAdapter() { @Override public void widgetSelected(final SelectionEvent e) { PreferencesUtil.createPreferenceDialogOn( parent.getShell(), PrefPageComputedValues.ID, null, PrefPageComputedValues.TAB_FOLDER_BREAK_TIME) .open(); } }); _tk.adapt(link, true, true); /* * link: smoothing online documentation */ link = new Link(container, SWT.NONE); GridDataFactory.fillDefaults() // .align(SWT.FILL, SWT.END) .applyTo(link); link.setText(Messages.TourChart_Smoothing_Link_SmoothingOnlineDocumentation); link.setEnabled(true); link.addSelectionListener( new SelectionAdapter() { @Override public void widgetSelected(final SelectionEvent e) { WEB.openUrl( // // the url MUST be splitted otherwise the messages editor will truncate the url // Messages.External_Link_MyTourbook + Messages.External_Link_MyTourbook_TourChartSmoothing); } }); _tk.adapt(link, true, true); } }
/** * Create contents of the dialog. * * @param parent */ @Override protected Control createDialogArea(Composite parent) { getShell().setText("Geleistete Arbeit anlegen oder anpassen"); Composite container = (Composite) super.createDialogArea(parent); container.setLayout(new FillLayout(SWT.HORIZONTAL)); parentForm = formToolkit.createForm(container); formToolkit.paintBordersFor(parentForm); formToolkit.decorateFormHeading(parentForm); parentForm.setText("Geleistete Arbeit anlegen oder anpassen"); IToolBarManager toolbar = parentForm.getToolBarManager(); Action reuseSelectionAction = new InternalReuseEntryAction(); toolbar.add(reuseSelectionAction); toolbar.update(true); parentForm.getBody().setLayout(new GridLayout(1, false)); Composite composite = formToolkit.createComposite(parentForm.getBody(), SWT.NONE); composite.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true, 1, 1)); formToolkit.paintBordersFor(composite); composite.setLayout(new GridLayout(4, false)); Label dateLabel = new Label(composite, SWT.NONE); dateLabel.setLayoutData(new GridData(SWT.LEFT, SWT.TOP, false, false, 1, 1)); formToolkit.adapt(dateLabel, true, true); dateLabel.setText("Datum"); dateTime = new DateTime(composite, SWT.BORDER | SWT.CALENDAR); formToolkit.adapt(dateTime); formToolkit.paintBordersFor(dateTime); Label timeLabel = new Label(composite, SWT.NONE); timeLabel.setLayoutData(new GridData(SWT.RIGHT, SWT.TOP, false, false, 1, 1)); formToolkit.adapt(timeLabel, true, true); timeLabel.setText("Dauer (in h)"); timeText = new Text(composite, SWT.NONE); timeText.setLayoutData(new GridData(SWT.FILL, SWT.TOP, true, false, 1, 1)); formToolkit.adapt(timeText, true, true); Label workLabel = new Label(composite, SWT.NONE); workLabel.setLayoutData(new GridData(SWT.RIGHT, SWT.CENTER, false, false, 1, 1)); formToolkit.adapt(workLabel, true, true); workLabel.setText("Tätigkeit"); workComboViewer = new ComboViewer(composite, SWT.NONE); Combo workCombo = workComboViewer.getCombo(); workCombo.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false, 1, 1)); formToolkit.paintBordersFor(workCombo); Label personLabel = new Label(composite, SWT.NONE); personLabel.setLayoutData(new GridData(SWT.RIGHT, SWT.CENTER, false, false, 1, 1)); formToolkit.adapt(personLabel, true, true); personLabel.setText("Person"); personComboViewer = new ComboViewer(composite, SWT.NONE); Combo personCombo = personComboViewer.getCombo(); personCombo.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false, 1, 1)); formToolkit.paintBordersFor(personCombo); Label commentLabel = new Label(composite, SWT.NONE); commentLabel.setLayoutData(new GridData(SWT.RIGHT, SWT.TOP, false, false, 1, 1)); formToolkit.adapt(commentLabel, true, true); commentLabel.setText("Bemerkungen"); commentText = new Text(composite, SWT.WRAP | SWT.V_SCROLL | SWT.MULTI); GridData gd_commentText = new GridData(SWT.FILL, SWT.CENTER, true, false, 3, 1); gd_commentText.heightHint = 50; commentText.setLayoutData(gd_commentText); formToolkit.adapt(commentText, true, true); Label label = new Label(composite, SWT.SEPARATOR | SWT.HORIZONTAL); GridData gd_label = new GridData(SWT.FILL, SWT.CENTER, true, false, 4, 1); gd_label.heightHint = 10; label.setLayoutData(gd_label); formToolkit.adapt(label, true, true); bandTypeLabel = new Label(composite, SWT.NONE); bandTypeLabel.setLayoutData(new GridData(SWT.RIGHT, SWT.CENTER, false, false, 1, 1)); formToolkit.adapt(bandTypeLabel, true, true); bandTypeLabel.setText("Band Typ"); bandTypeComboViewer = new ComboViewer(composite, SWT.NONE); bandTypeCombo = bandTypeComboViewer.getCombo(); bandTypeCombo.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false, 1, 1)); formToolkit.paintBordersFor(bandTypeCombo); amountLabel = new Label(composite, SWT.NONE); amountLabel.setLayoutData(new GridData(SWT.RIGHT, SWT.CENTER, false, false, 1, 1)); formToolkit.adapt(amountLabel, true, true); amountLabel.setText("Anzahl"); amountText = new Text(composite, SWT.NONE); amountText.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false, 1, 1)); formToolkit.adapt(amountText, true, true); new Label(composite, SWT.NONE); new Label(composite, SWT.NONE); trackLink = new Link(composite, SWT.NONE); trackLink.setLayoutData(new GridData(SWT.RIGHT, SWT.CENTER, false, false, 1, 1)); formToolkit.adapt(trackLink, true, true); trackLink.setText("<a>Bahn(en)</a>"); trackText = new Text(composite, SWT.NONE); trackText.setEditable(false); trackText.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false, 1, 1)); formToolkit.adapt(trackText, true, true); bandTypeLabel.setEnabled(false); bandTypeCombo.setEnabled(false); amountLabel.setEnabled(false); amountText.setEnabled(false); trackLink.setEnabled(false); trackText.setEnabled(false); DefaultStructuredContentProvider provider = new DefaultStructuredContentProvider(); workComboViewer.setContentProvider(provider); personComboViewer.setContentProvider(provider); bandTypeComboViewer.setContentProvider(provider); InternalLabelProvider labelProvider = new InternalLabelProvider(); workComboViewer.setLabelProvider(labelProvider); personComboViewer.setLabelProvider(labelProvider); bandTypeComboViewer.setLabelProvider(labelProvider); if (root.getWorks() != null && !root.getWorks().getWork().isEmpty()) { if (bandActionOnly) { workComboViewer.addFilter(new IntenalViewerFilter()); } workComboViewer.setInput(root.getWorks().getWork()); } else { workLabel.setForeground(Display.getCurrent().getSystemColor(SWT.COLOR_RED)); } if (root.getPersons() != null && !root.getPersons().getPerson().isEmpty()) { personComboViewer.setInput(root.getPersons().getPerson()); } else { personLabel.setForeground(Display.getCurrent().getSystemColor(SWT.COLOR_RED)); } bandTypeComboViewer.setInput(BandTypes.values()); if (editMode) { if (entry.getDate() != null) { Calendar c = Calendar.getInstance(); c.setTime(entry.getDate()); dateTime.setDate(c.get(Calendar.YEAR), c.get(Calendar.MONTH), c.get(Calendar.DATE)); } if (entry.getTime() != null) { timeText.setText("" + entry.getTime()); } if (entry.getComment() != null) { commentText.setText(entry.getComment()); } if (entry.getPersonId() != null) { PersonType pt = null; if (root.getPersons() != null) { for (PersonType p : root.getPersons().getPerson()) { if (p.getId().equals(entry.getPersonId())) { pt = p; break; } } } if (pt != null) { StructuredSelection s = new StructuredSelection(pt); personComboViewer.setSelection(s); currentPersonType = pt; } personCombo.setEnabled(false); } if (entry.getWorkId() != null) { WorkType wt = null; if (root.getWorks() != null) { for (WorkType w : root.getWorks().getWork()) { if (w.getId().equals(entry.getWorkId())) { wt = w; break; } } } if (wt != null) { StructuredSelection s = new StructuredSelection(wt); workComboViewer.setSelection(s); currentWorkType = wt; } workCombo.setEnabled(false); } if (entry.getBandAction() != null) { if (entry.getBandAction().getBandType() != null) { StructuredSelection s = new StructuredSelection(entry.getBandAction().getBandType()); bandTypeComboViewer.setSelection(s); } bandTypeLabel.setEnabled(true); bandTypeCombo.setEnabled(true); if (entry.getBandAction().getAmount() != null) { amountText.setText("" + entry.getBandAction().getAmount()); } amountLabel.setEnabled(true); amountText.setEnabled(true); trackText.setText(getTrackString(entry.getBandAction())); trackLink.setEnabled(true); trackText.setEnabled(true); } } ModifyListener modifyListener = new ModifyListener() { @Override public void modifyText(ModifyEvent e) { if (e.widget == timeText) { entry.setTime(!timeText.getText().isEmpty() ? Float.valueOf(timeText.getText()) : 0); } else if (e.widget == commentText) { entry.setComment(!commentText.getText().isEmpty() ? commentText.getText() : null); } else if (e.widget == amountText) { if (entry.getBandAction() == null) entry.setBandAction(factory.createBandActionType()); if (!amountText.getText().isEmpty()) { entry.getBandAction().setAmount(Integer.parseInt(amountText.getText())); } else { entry.getBandAction().setAmount(null); } } } }; timeText.addModifyListener(modifyListener); commentText.addModifyListener(modifyListener); amountText.addModifyListener(modifyListener); SelectionAdapter selectionAdapter = new SelectionAdapter() { @Override public void widgetSelected(SelectionEvent e) { if (e.widget == dateTime) { Calendar c = Calendar.getInstance(); c.set(dateTime.getYear(), dateTime.getMonth(), dateTime.getDay()); entry.setDate(c.getTime()); } else if (e.widget == trackLink) { InternalTrackSelectionDialog dialog = new InternalTrackSelectionDialog(getShell(), entry.getBandAction()); if (InternalTrackSelectionDialog.OK == dialog.open()) { BandActionType ba = dialog.getBandAction(); if (entry.getBandAction() == null) entry.setBandAction(ba); else { entry.getBandAction().getTrack().clear(); entry.getBandAction().getTrack().addAll(ba.getTrack()); } trackText.setText(getTrackString(entry.getBandAction())); } } } }; dateTime.addSelectionListener(selectionAdapter); trackLink.addSelectionListener(selectionAdapter); ISelectionChangedListener seleChangedListener = new ISelectionChangedListener() { @Override public void selectionChanged(SelectionChangedEvent event) { if (event.getSource() == workComboViewer) { WorkType wt = (WorkType) ((IStructuredSelection) workComboViewer.getSelection()).getFirstElement(); if (wt != null) { currentWorkType = wt; entry.setWorkId(wt.getId()); if (wt.isAffectBand() != null && wt.isAffectBand()) { bandTypeLabel.setEnabled(true); bandTypeCombo.setEnabled(true); amountLabel.setEnabled(true); amountText.setEnabled(true); trackLink.setEnabled(true); trackText.setEnabled(true); } else { bandTypeLabel.setEnabled(false); bandTypeCombo.setEnabled(false); amountLabel.setEnabled(false); amountText.setEnabled(false); trackLink.setEnabled(false); trackText.setEnabled(false); } } else { currentWorkType = null; } } else if (event.getSource() == personComboViewer) { PersonType pt = (PersonType) ((IStructuredSelection) personComboViewer.getSelection()).getFirstElement(); if (pt != null) { currentPersonType = pt; entry.setPersonId(pt.getId()); } else { currentPersonType = null; } } else if (event.getSource() == bandTypeComboViewer) { BandTypes bt = (BandTypes) ((IStructuredSelection) bandTypeComboViewer.getSelection()).getFirstElement(); if (entry.getBandAction() == null) entry.setBandAction(factory.createBandActionType()); if (bt != null) { entry.getBandAction().setBandType(bt); } else { entry.getBandAction().setBandType(null); } } } }; workComboViewer.addSelectionChangedListener(seleChangedListener); personComboViewer.addSelectionChangedListener(seleChangedListener); bandTypeComboViewer.addSelectionChangedListener(seleChangedListener); return container; }