@Override protected Control createContents(Composite parent) { isInit = true; Composite tparent = new Composite(parent, SWT.NONE); tparent.setLayout(new GridLayout()); tparent.setLayoutData(new GridData(GridData.FILL_BOTH)); Group groupCommon = new Group(tparent, SWT.NONE); groupCommon.setLayout(new GridLayout()); groupCommon.setLayoutData(new GridData(GridData.FILL_HORIZONTAL)); groupCommon.setText(Messages.getString("preferencepage.SystemPreferencePage.groupCommon")); HsImageLabel imageLabel1 = new HsImageLabel( Messages.getString("preferencepage.SystemPreferencePage.imageLabel1"), Activator.getImageDescriptor(ImageConstant.PREFERENCE_SYS_UPDATE)); Composite cmpCommon = imageLabel1.createControl(groupCommon); cmpCommon.setLayout(new GridLayout()); cmpCommon.setLayoutData(new GridData(GridData.FILL_HORIZONTAL)); btnCheckUpdateWithStartup = new Button(cmpCommon, SWT.RADIO); btnCheckUpdateWithStartup.setText( Messages.getString("preferencepage.SystemPreferencePage.btnCheckUpdateWithStartup")); GridDataFactory.fillDefaults().applyTo(btnCheckUpdateWithStartup); btnCheckUpdateWithStartup.addSelectionListener( new SelectionListener() { public void widgetSelected(SelectionEvent e) { if (btnCheckUpdateWithStartup.getSelection()) { btnCheckUpdateWithMonthly.setSelection(false); btnCheckUpdateWithWeekly.setSelection(false); btnCheckUpdateWithNever.setSelection(false); selectDateSpi.setEnabled(false); cmbSelectWeek.setEnabled(false); } } public void widgetDefaultSelected(SelectionEvent e) {} }); cmpMonthly = new Composite(cmpCommon, SWT.None); GridLayoutFactory.swtDefaults() .numColumns(3) .equalWidth(false) .margins(0, 0) .spacing(0, 0) .applyTo(cmpMonthly); cmpMonthly.setLayoutData(new GridData(GridData.FILL_HORIZONTAL)); btnCheckUpdateWithMonthly = new Button(cmpMonthly, SWT.RADIO); btnCheckUpdateWithMonthly.setText( Messages.getString("preferencepage.SystemPreferencePage.btnCheckUpdateWithMonthly1")); GridData spinnaData = new GridData(); spinnaData.widthHint = 20; selectDateSpi = new Spinner(cmpMonthly, SWT.BORDER); selectDateSpi.setMinimum(1); selectDateSpi.setMaximum(31); selectDateSpi.setTextLimit(2); selectDateSpi.setEnabled(false); selectDateSpi.setLayoutData(spinnaData); selectDateSpi.addModifyListener( new ModifyListener() { public void modifyText(ModifyEvent e) { String text = selectDateSpi.getText(); if (text != null && !text.trim().equals("")) { if (Integer.parseInt(text.trim()) > 31) { selectDateSpi.setSelection(31); } else if (Integer.parseInt(text.trim()) < 1) { selectDateSpi.setSelection(1); } } } }); new Label(cmpMonthly, SWT.None) .setText( Messages.getString("preferencepage.SystemPreferencePage.btnCheckUpdateWithMonthly2")); btnCheckUpdateWithMonthly.addSelectionListener( new SelectionListener() { public void widgetSelected(SelectionEvent e) { selectDateSpi.setEnabled(btnCheckUpdateWithMonthly.getSelection()); if (btnCheckUpdateWithMonthly.getSelection()) { btnCheckUpdateWithStartup.setSelection(false); btnCheckUpdateWithWeekly.setSelection(false); btnCheckUpdateWithNever.setSelection(false); cmbSelectWeek.setEnabled(false); } } public void widgetDefaultSelected(SelectionEvent e) {} }); cmpWeekly = new Composite(cmpCommon, SWT.None); GridLayoutFactory.swtDefaults() .numColumns(3) .equalWidth(false) .margins(0, 0) .spacing(0, 0) .applyTo(cmpWeekly); cmpWeekly.setLayoutData(new GridData(GridData.FILL_HORIZONTAL)); btnCheckUpdateWithWeekly = new Button(cmpWeekly, SWT.RADIO); btnCheckUpdateWithWeekly.setText( Messages.getString("preferencepage.SystemPreferencePage.btnCheckUpdateWithWeekly1")); cmbSelectWeek = new Combo(cmpWeekly, SWT.READ_ONLY); cmbSelectWeek.setItems(arrWeek); cmbSelectWeek.setEnabled(false); cmbSelectWeek.select(0); GridDataFactory.swtDefaults().applyTo(cmbSelectWeek); new Label(cmpWeekly, SWT.NONE) .setText( Messages.getString("preferencepage.SystemPreferencePage.btnCheckUpdateWithWeekly2")); btnCheckUpdateWithWeekly.addSelectionListener( new SelectionListener() { public void widgetSelected(SelectionEvent e) { cmbSelectWeek.setEnabled(btnCheckUpdateWithWeekly.getSelection()); if (btnCheckUpdateWithWeekly.getSelection()) { btnCheckUpdateWithStartup.setSelection(false); btnCheckUpdateWithMonthly.setSelection(false); btnCheckUpdateWithNever.setSelection(false); selectDateSpi.setEnabled(false); } } public void widgetDefaultSelected(SelectionEvent e) {} }); btnCheckUpdateWithNever = new Button(cmpCommon, SWT.RADIO); btnCheckUpdateWithNever.setText( Messages.getString("preferencepage.SystemPreferencePage.btnCheckUpdateWithNever")); btnCheckUpdateWithNever.setLayoutData(new GridData(GridData.FILL_HORIZONTAL)); GridDataFactory.fillDefaults().applyTo(btnCheckUpdateWithNever); btnCheckUpdateWithNever.addSelectionListener( new SelectionListener() { public void widgetSelected(SelectionEvent e) { if (btnCheckUpdateWithNever.getSelection()) { btnCheckUpdateWithMonthly.setSelection(false); btnCheckUpdateWithWeekly.setSelection(false); btnCheckUpdateWithStartup.setSelection(false); selectDateSpi.setEnabled(false); cmbSelectWeek.setEnabled(false); } } public void widgetDefaultSelected(SelectionEvent e) {} }); Group groupLanguage = new Group(tparent, SWT.NONE); groupLanguage.setLayout(new GridLayout()); groupLanguage.setLayoutData(new GridData(GridData.FILL_HORIZONTAL)); groupLanguage.setText(Messages.getString("preferencepage.SystemPreferencePage.groupLanguage")); HsImageLabel imageLabel2 = new HsImageLabel( Messages.getString("preferencepage.SystemPreferencePage.imageLabel3"), Activator.getImageDescriptor(ImageConstant.PREFERENCE_SYS_LANGUAGE)); Composite cmpLang = imageLabel2.createControl(groupLanguage); cmpLang.setLayout(new GridLayout()); cmpLang.setLayoutData(new GridData(GridData.FILL_HORIZONTAL)); btnLanguageWithEN = new Button(cmpLang, SWT.RADIO); btnLanguageWithEN.setText( Messages.getString("preferencepage.SystemPreferencePage.btnLanguageWithEN")); btnLanguageWithEN.setLayoutData(new GridData(GridData.FILL_HORIZONTAL)); btnLanguageWithZHCN = new Button(cmpLang, SWT.RADIO); btnLanguageWithZHCN.setText( Messages.getString("preferencepage.SystemPreferencePage.btnLanguageWithZHCN")); btnLanguageWithZHCN.setLayoutData(new GridData(GridData.FILL_HORIZONTAL)); Group groupFont = new Group(tparent, SWT.NONE); groupFont.setLayout(new GridLayout()); groupFont.setLayoutData(new GridData(GridData.FILL_HORIZONTAL)); groupFont.setText(Messages.getString("preferencepage.SystemPreferencePage.groupFont")); HsImageLabel imageLabel4 = new HsImageLabel( Messages.getString("preferencepage.SystemPreferencePage.groupFont.desc"), Activator.getImageDescriptor("images/preference/system/font.png")); Composite cmpFont = imageLabel4.createControl(groupFont); GridLayout cmpFontGl = new GridLayout(2, true); cmpFontGl.marginLeft = 0; cmpFontGl.marginRight = 0; cmpFontGl.marginTop = 0; cmpFontGl.marginBottom = 0; cmpFontGl.marginWidth = 0; cmpFontGl.marginHeight = 0; cmpFont.setLayout(cmpFontGl); GridData cmpFontGd = new GridData(SWT.FILL, SWT.FILL, true, true); cmpFont.setLayoutData(cmpFontGd); editorFontSetting = new HSFontSettingComposite( cmpFont, SWT.NONE, Messages.getString("preferencepage.fontsetting.editor.title")); GridData gd = new GridData(SWT.FILL, SWT.FILL, true, true); editorFontSetting.setLayoutData(gd); matchViewFontSetting = new HSFontSettingComposite( cmpFont, SWT.NONE, Messages.getString("preferencepage.fontsetting.matchView.title")); matchViewFontSetting.setLayoutData(gd); Group groupSystemUser = new Group(tparent, SWT.NONE); groupSystemUser.setLayout(new GridLayout()); groupSystemUser.setLayoutData(new GridData(GridData.FILL_HORIZONTAL)); groupSystemUser.setText( Messages.getString("preferencepage.SystemPreferencePage.groupSystemUser")); HsImageLabel imageLabel3 = new HsImageLabel( Messages.getString("preferencepage.SystemPreferencePage.imageLabel4"), Activator.getImageDescriptor(ImageConstant.PREFERENCE_SYS_USER)); Composite cmpUser = imageLabel3.createControl(groupSystemUser); cmpUser.setLayout(new GridLayout(2, false)); cmpUser.setLayoutData(new GridData(GridData.FILL_HORIZONTAL)); new Label(cmpUser, SWT.NONE) .setText(Messages.getString("preferencepage.SystemPreferencePage.lblUser")); txtSystemUser = new Text(cmpUser, SWT.BORDER); txtSystemUser.setLayoutData(new GridData(GridData.FILL_HORIZONTAL)); imageLabel1.computeSize(); imageLabel2.computeSize(); imageLabel3.computeSize(); imageLabel4.computeSize(); setInitValues(false); return parent; }
/** 构造函数 */ public SystemPreferencePage() { setTitle(Messages.getString("preferencepage.SystemPreferencePage.title")); setPreferenceStore(Activator.getDefault().getPreferenceStore()); preferenceStore = getPreferenceStore(); }