public DateControl(Composite parent) { super(parent, SWT.NONE); setBackground(parent.getBackground()); GridLayout layout = UIUtil.gridLayout(this, 2, 0, 0); layout.horizontalSpacing = 1; text = UIUtil.newText(this, "", new TextChanged()); UIControlUtil.increaseFontSize(text, -2); GridData gd = new GridData(); gd.widthHint = 50; text.setLayoutData(gd); button = UIUtil.newImageButton( this, SharedImages.getImage(SharedImages.icons.x16.basic.CALENDAR_POPUP), new ButtonListener(), null); }
public static void setFontStyle(Control ctrl, int style) { Font font = UIUtil.setFontStyle(ctrl.getFont(), style); ctrl.setFont(font); ctrl.addDisposeListener( new DisposeListenerWithData<Font>(font) { public void widgetDisposed(DisposeEvent e) { data().dispose(); } }); }
public static void increaseFontSize(Control ctrl, int inc) { Font font = UIUtil.increaseFontSize(ctrl.getFont(), inc); ctrl.setFont(font); ctrl.addDisposeListener( new DisposeListenerWithData<Font>(font) { public void widgetDisposed(DisposeEvent e) { data().dispose(); } }); }
@Override protected Composite createControl(Composite container) { container.setBackground(ColorUtil.getWhite()); Composite panel = UIUtil.newGridComposite(container, 0, 0, 1); int lang = recent.get(0).getValue2(); Composite header = UIUtil.newGridComposite(panel, 2, 2, 2); UIUtil.gridDataHorizFill(header); UIUtil.newImage(header, EclipseImages.getImage(EclipsePlugin.ID, "cd-dvd.jpg")); text = new LCMLText(header, false, false); text.setText(_text[lang]); GridData gd = new GridData(); gd.widthHint = 350; text.setLayoutData(gd); Composite body = UIUtil.newGridComposite(panel, 2, 2, 3); UIUtil.gridDataHorizFill(body); labelDataBase = UIUtil.newLabel(body, _database[lang]); comboDataBase = new Combo(body, SWT.DROP_DOWN); for (Pair<String, Integer> p : recent) comboDataBase.add(p.getValue1()); comboDataBase.select(0); comboDataBase.addSelectionListener( new SelectionListener() { public void widgetDefaultSelected(SelectionEvent e) {} public void widgetSelected(SelectionEvent e) { refresh(true); } }); comboDataBase.addModifyListener( new ModifyListener() { public void modifyText(ModifyEvent e) { refresh(true); } }); comboDataBase.setLayoutData(UIUtil.gridDataHoriz(1, true)); buttonBrowse = UIUtil.newButton( body, _browse[lang], new Listener<Object>() { public void fire(Object event) { DirectoryDialog dlg = new DirectoryDialog(getShell()); String result = dlg.open(); if (result != null) { comboDataBase.setText(result); refresh(true); } } }, null); labelLanguage = UIUtil.newLabel(body, _language[lang]); comboLanguage = new Combo(body, SWT.DROP_DOWN | SWT.READ_ONLY); comboLanguage.add("English"); comboLanguage.add("Français"); comboLanguage.select(lang); comboLanguage.addSelectionListener( new SelectionListener() { public void widgetDefaultSelected(SelectionEvent e) {} public void widgetSelected(SelectionEvent e) { refresh(false); } }); UIUtil.newSeparator(panel, true, true); Composite footer = UIUtil.newGridComposite(panel, 2, 2, 2, 40, 0); gd = new GridData(); gd.horizontalAlignment = SWT.CENTER; footer.setLayoutData(gd); buttonOk = new Button(footer, SWT.PUSH); buttonOk.setText(_ok[lang]); buttonCancel = new Button(footer, SWT.PUSH); buttonCancel.setText(_cancel[lang]); buttonOk.addSelectionListener( new SelectionListener() { public void widgetDefaultSelected(SelectionEvent e) {} public void widgetSelected(SelectionEvent e) { selectedDir = comboDataBase.getText(); if (selectedDir.length() == 0) return; selectedLang = comboLanguage.getSelectionIndex(); if (selectedLang < 0) return; ok = true; close(); } }); buttonCancel.addSelectionListener( new SelectionListener() { public void widgetDefaultSelected(SelectionEvent e) {} public void widgetSelected(SelectionEvent e) { ok = false; close(); } }); return panel; }