gfmprojectcreationwizard.java

来自「BPO作业管理系统DMP的插件」· Java 代码 · 共 90 行

JAVA
90
字号
package com.cmspad.dmp.bundles.gfm.widget;import java.util.Map;import org.eclipse.swt.SWT;import org.eclipse.swt.events.KeyAdapter;import org.eclipse.swt.events.KeyEvent;import org.eclipse.swt.events.SelectionAdapter;import org.eclipse.swt.events.SelectionEvent;import org.eclipse.swt.layout.GridData;import org.eclipse.swt.layout.GridLayout;import org.eclipse.swt.widgets.Button;import org.eclipse.swt.widgets.Combo;import org.eclipse.swt.widgets.Composite;import org.eclipse.swt.widgets.Label;import com.cmspad.dmp.bundles.gfm.GFMProgDictionary;public class GFMProjectCreationWizard extends Composite {	private Combo cCombo;		public GFMProjectCreationWizard(Composite parent, final Map<String, Object> attributes) {		super(parent, SWT.NONE);				final GridLayout gridLayout = new GridLayout();		gridLayout.numColumns = 3;		setLayout(gridLayout);		final Label label = new Label(this, SWT.NONE);		label.setText("使用程序");		cCombo = new Combo(this, SWT.READ_ONLY);		cCombo.addKeyListener(new KeyAdapter() {			public void keyPressed(final KeyEvent e) {				switch(e.keyCode){					case SWT.F5:						refresh(attributes);						break;				}			}		});		cCombo.addSelectionListener(new SelectionAdapter() {			public void widgetSelected(final SelectionEvent e) {				attributes.put("prog", cCombo.getData(cCombo.getText()));			}		});		cCombo.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false));		//				refresh(attributes);		final Button button = new Button(this, SWT.NONE);		button.addSelectionListener(new SelectionAdapter() {			public void widgetSelected(final SelectionEvent e) {				refresh(attributes);			}		});		final GridData gd_button = new GridData(SWT.FILL, SWT.CENTER, false, false);		gd_button.widthHint = 50;		button.setLayoutData(gd_button);		button.setText("刷新");	}	@Override	protected void checkSubclass() {}	private void refresh(Map<String, Object> attributes){		// 初始化选择项		cCombo.removeAll();		int index = 0;		for(String key:GFMProgDictionary.keys()){			String newProg = GFMProgDictionary.value(key);			String oldProg = attributes.containsKey("prog")?(String)attributes.get("prog"):null;			if(newProg.equals(oldProg)){				cCombo.select(index);			}			cCombo.add(key);			cCombo.setData(key, newProg);		}				int selection = cCombo.getSelectionIndex();		if(selection < 0){			cCombo.select(0);		}		attributes.put("prog", cCombo.getData(cCombo.getItem(index)));	}}

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?