private void openLink() { PreferencesUtil.createPreferenceDialogOn( getShell(), DroolsProjectPreferencePage.PREF_ID, new String[] {DroolsProjectPreferencePage.PROP_ID}, new HashMap()) .open(); droolsRuntimeCombo.removeAll(); DroolsRuntime[] runtimes = DroolsRuntimeManager.getDroolsRuntimes(); if (runtimes.length == 0) { setPageComplete(false); setErrorMessage("No Drools Runtimes have been defined, please do this first"); } else { setPageComplete(true); setErrorMessage(null); for (int i = 0; i < runtimes.length; i++) { droolsRuntimeCombo.add(runtimes[i].getName()); } droolsRuntimeCombo.select(0); selectedRuntime = droolsRuntimeCombo.getText(); } }
public void createControl(Composite parent) { Composite composite = new Composite(parent, SWT.NONE); GridLayout gridLayout = new GridLayout(); gridLayout.numColumns = 2; composite.setLayout(gridLayout); DroolsRuntime defaultRuntime = DroolsRuntimeManager.getDefaultDroolsRuntime(); projectSpecificRuntime = createCheckBox( composite, "Use default Drools Runtime (currently " + (defaultRuntime == null ? "undefined)" : defaultRuntime.getName() + ")")); projectSpecificRuntime.setSelection(true); projectSpecificRuntime.addSelectionListener( new SelectionListener() { public void widgetDefaultSelected(SelectionEvent e) { // do nothing } public void widgetSelected(SelectionEvent e) { isDefaultRuntime = ((Button) e.widget).getSelection(); droolsRuntimeCombo.setEnabled(!isDefaultRuntime); } }); GridData gridData = new GridData(); gridData.horizontalSpan = 2; gridData.grabExcessHorizontalSpace = true; gridData.horizontalAlignment = GridData.FILL; projectSpecificRuntime.setLayoutData(gridData); Label nameLabel = new Label(composite, SWT.NONE); nameLabel.setText("Drools Runtime: "); droolsRuntimeCombo = new Combo(composite, SWT.LEFT); droolsRuntimeCombo.setEnabled(false); droolsRuntimeCombo.addSelectionListener( new SelectionListener() { public void widgetDefaultSelected(SelectionEvent e) { selectedRuntime = droolsRuntimeCombo.getText(); } public void widgetSelected(SelectionEvent e) { selectedRuntime = droolsRuntimeCombo.getText(); } }); DroolsRuntime[] runtimes = DroolsRuntimeManager.getDroolsRuntimes(); if (runtimes.length == 0) { setErrorMessage("No Drools Runtimes have been defined, configure workspace settings first"); } else { setErrorMessage(null); for (int i = 0; i < runtimes.length; i++) { droolsRuntimeCombo.add(runtimes[i].getName()); } droolsRuntimeCombo.select(0); selectedRuntime = droolsRuntimeCombo.getText(); } gridData = new GridData(); gridData.grabExcessHorizontalSpace = true; gridData.horizontalAlignment = GridData.FILL; droolsRuntimeCombo.setLayoutData(gridData); Link changeWorkspaceSettingsLink = createLink(composite, "Configure Workspace Settings..."); changeWorkspaceSettingsLink.setLayoutData(new GridData(SWT.END, SWT.CENTER, false, false)); setMessage(null); setPageComplete(runtimes.length > 0); setControl(composite); }
public DroolsRuntime getDroolsRuntime() { if (isDefaultRuntime) { return null; } return DroolsRuntimeManager.getDroolsRuntime(selectedRuntime); }