001: package org.drools.eclipse.wizard.project;
002:
003: import org.eclipse.jface.wizard.WizardPage;
004: import org.eclipse.swt.SWT;
005: import org.eclipse.swt.events.SelectionEvent;
006: import org.eclipse.swt.events.SelectionListener;
007: import org.eclipse.swt.layout.GridData;
008: import org.eclipse.swt.layout.GridLayout;
009: import org.eclipse.swt.widgets.Button;
010: import org.eclipse.swt.widgets.Composite;
011:
012: public class NewDroolsProjectWizardPage extends WizardPage {
013:
014: private Button addSampleJavaRuleCodeButton;
015: private Button addSampleRuleButton;
016: private Button addSampleJavaDecisionTableCodeButton;
017: private Button addSampleDecisionTableCodeButton;
018: private Button addSampleRuleFlowButton;
019: private Button addSampleJavaRuleFlowCodeButton;
020: private boolean addSampleJavaRuleCode = true;
021: private boolean addSampleRule = true;
022: private boolean addSampleJavaDecisionTableCode = false;
023: private boolean addSampleDecisionTableCode = false;
024: private boolean addSampleJavaRuleFlowCode = false;
025: private boolean addSampleRuleFlow = false;
026:
027: public NewDroolsProjectWizardPage() {
028: super ("extendedNewProjectPage");
029: setTitle("New Drools Project");
030: setDescription("Create a new Drools Project");
031: }
032:
033: public void createControl(Composite parent) {
034: Composite composite = new Composite(parent, SWT.NULL);
035: composite.setFont(parent.getFont());
036: composite.setLayout(new GridLayout());
037: composite.setLayoutData(new GridData(GridData.FILL_BOTH));
038: createControls(composite);
039: setPageComplete(true);
040: // Show description on opening
041: setErrorMessage(null);
042: setMessage(null);
043: setControl(composite);
044: }
045:
046: private void createControls(Composite parent) {
047: addSampleRuleButton = createCheckBox(parent,
048: "Add a sample HelloWorld rule file to this project.");
049: addSampleRuleButton.setSelection(addSampleRule);
050: addSampleRuleButton
051: .addSelectionListener(new SelectionListener() {
052: public void widgetDefaultSelected(SelectionEvent e) {
053: // do nothing
054: }
055:
056: public void widgetSelected(SelectionEvent e) {
057: addSampleRule = ((Button) e.widget)
058: .getSelection();
059: }
060: });
061: addSampleJavaRuleCodeButton = createCheckBox(parent,
062: "Add a sample Java class for loading and executing the HelloWorld rules.");
063: addSampleJavaRuleCodeButton.setSelection(addSampleJavaRuleCode);
064: addSampleJavaRuleCodeButton
065: .addSelectionListener(new SelectionListener() {
066: public void widgetDefaultSelected(SelectionEvent e) {
067: // do nothing
068: }
069:
070: public void widgetSelected(SelectionEvent e) {
071: addSampleJavaRuleCode = ((Button) e.widget)
072: .getSelection();
073: }
074: });
075: addSampleDecisionTableCodeButton = createCheckBox(parent,
076: "Add a sample HelloWorld decision table file to this project.");
077: addSampleDecisionTableCodeButton
078: .setSelection(addSampleDecisionTableCode);
079: addSampleDecisionTableCodeButton
080: .addSelectionListener(new SelectionListener() {
081: public void widgetDefaultSelected(SelectionEvent e) {
082: // do nothing
083: }
084:
085: public void widgetSelected(SelectionEvent e) {
086: addSampleDecisionTableCode = ((Button) e.widget)
087: .getSelection();
088: }
089: });
090: addSampleJavaDecisionTableCodeButton = createCheckBox(
091: parent,
092: "Add a sample Java class for loading and executing the HelloWorld decision table.");
093: addSampleJavaDecisionTableCodeButton
094: .setSelection(addSampleDecisionTableCode);
095: addSampleJavaDecisionTableCodeButton
096: .addSelectionListener(new SelectionListener() {
097: public void widgetDefaultSelected(SelectionEvent e) {
098: // do nothing
099: }
100:
101: public void widgetSelected(SelectionEvent e) {
102: addSampleJavaDecisionTableCode = ((Button) e.widget)
103: .getSelection();
104: }
105: });
106: addSampleRuleFlowButton = createCheckBox(parent,
107: "Add a sample RuleFlow file to this project.");
108: addSampleRuleFlowButton.setSelection(addSampleRuleFlow);
109: addSampleRuleFlowButton
110: .addSelectionListener(new SelectionListener() {
111: public void widgetDefaultSelected(SelectionEvent e) {
112: // do nothing
113: }
114:
115: public void widgetSelected(SelectionEvent e) {
116: addSampleRuleFlow = ((Button) e.widget)
117: .getSelection();
118: }
119: });
120: addSampleJavaRuleFlowCodeButton = createCheckBox(parent,
121: "Add a sample Java class for loading and executing the RuleFlow.");
122: addSampleJavaRuleFlowCodeButton
123: .setSelection(addSampleJavaRuleFlowCode);
124: addSampleJavaRuleFlowCodeButton
125: .addSelectionListener(new SelectionListener() {
126: public void widgetDefaultSelected(SelectionEvent e) {
127: // do nothing
128: }
129:
130: public void widgetSelected(SelectionEvent e) {
131: addSampleJavaRuleFlowCode = ((Button) e.widget)
132: .getSelection();
133: }
134: });
135:
136: }
137:
138: private Button createCheckBox(Composite group, String label) {
139: Button button = new Button(group, SWT.CHECK | SWT.LEFT);
140: button.setText(label);
141: GridData data = new GridData();
142: button.setLayoutData(data);
143: return button;
144: }
145:
146: public boolean createRuleFile() {
147: return addSampleRule;
148: }
149:
150: public boolean createJavaRuleFile() {
151: return addSampleJavaRuleCode;
152: }
153:
154: public boolean createDecisionTableFile() {
155: return addSampleDecisionTableCode;
156: }
157:
158: public boolean createJavaDecisionTableFile() {
159: return addSampleJavaDecisionTableCode;
160: }
161:
162: public boolean createRuleFlowFile() {
163: return addSampleRuleFlow;
164: }
165:
166: public boolean createJavaRuleFlowFile() {
167: return addSampleJavaRuleFlowCode;
168: }
169: }
|