[jboss-svn-commits] JBL Code SVN: r34615 - in labs/jbossrules/branches/5.1.x/drools-eclipse/org.drools.eclipse/src/main/java/org/drools/eclipse: wizard/dsl and 1 other directory.
jboss-svn-commits at lists.jboss.org
jboss-svn-commits at lists.jboss.org
Mon Aug 9 19:55:44 EDT 2010
Author: KrisVerlaenen
Date: 2010-08-09 19:55:44 -0400 (Mon, 09 Aug 2010)
New Revision: 34615
Added:
labs/jbossrules/branches/5.1.x/drools-eclipse/org.drools.eclipse/src/main/java/org/drools/eclipse/wizard/dsl/NewDSLFilePage2.java
Modified:
labs/jbossrules/branches/5.1.x/drools-eclipse/org.drools.eclipse/src/main/java/org/drools/eclipse/dsl/editor/DSLEditor.java
labs/jbossrules/branches/5.1.x/drools-eclipse/org.drools.eclipse/src/main/java/org/drools/eclipse/wizard/dsl/NewDSLFilePage.java
labs/jbossrules/branches/5.1.x/drools-eclipse/org.drools.eclipse/src/main/java/org/drools/eclipse/wizard/dsl/NewDSLFileWizard.java
Log:
JBDS-1261: Domain Specific Language Creation
- added wizard page to select whether you want example content or not (default = false)
- DSL editor now supports multi-line remove
Modified: labs/jbossrules/branches/5.1.x/drools-eclipse/org.drools.eclipse/src/main/java/org/drools/eclipse/dsl/editor/DSLEditor.java
===================================================================
--- labs/jbossrules/branches/5.1.x/drools-eclipse/org.drools.eclipse/src/main/java/org/drools/eclipse/dsl/editor/DSLEditor.java 2010-08-09 23:27:59 UTC (rev 34614)
+++ labs/jbossrules/branches/5.1.x/drools-eclipse/org.drools.eclipse/src/main/java/org/drools/eclipse/dsl/editor/DSLEditor.java 2010-08-09 23:55:44 UTC (rev 34615)
@@ -481,7 +481,9 @@
add.addSelectionListener( new SelectionAdapter() {
// Add a task to the ExampleTaskList and refresh the view
public void widgetSelected(SelectionEvent e) {
- model.removeEntry( getCurrentSelected() );
+ for (DSLMappingEntry entry: getAllSelected()) {
+ model.removeEntry( entry );
+ }
refreshModel();
makeDirty();
exprText.setText( "" );
@@ -518,6 +520,14 @@
return (DSLMappingEntry) ((IStructuredSelection) tableViewer.getSelection()).getFirstElement();
}
+ private List<DSLMappingEntry> getAllSelected() {
+ List<DSLMappingEntry> result = new ArrayList<DSLMappingEntry>();
+ for (Object e: ((IStructuredSelection) tableViewer.getSelection()).toList()) {
+ result.add((DSLMappingEntry) e);
+ }
+ return result;
+ }
+
private void createAddButton(Composite parent) {
// Create and configure the "Add" button
Button add = new Button( parent,
@@ -610,7 +620,7 @@
* Create the Table
*/
private void createTable(Composite parent) {
- int style = SWT.SINGLE | SWT.BORDER | SWT.H_SCROLL | SWT.V_SCROLL | SWT.FULL_SELECTION | SWT.HIDE_SELECTION;
+ int style = SWT.MULTI | SWT.BORDER | SWT.H_SCROLL | SWT.V_SCROLL | SWT.FULL_SELECTION | SWT.HIDE_SELECTION;
table = new Table( parent,
style );
Modified: labs/jbossrules/branches/5.1.x/drools-eclipse/org.drools.eclipse/src/main/java/org/drools/eclipse/wizard/dsl/NewDSLFilePage.java
===================================================================
--- labs/jbossrules/branches/5.1.x/drools-eclipse/org.drools.eclipse/src/main/java/org/drools/eclipse/wizard/dsl/NewDSLFilePage.java 2010-08-09 23:27:59 UTC (rev 34614)
+++ labs/jbossrules/branches/5.1.x/drools-eclipse/org.drools.eclipse/src/main/java/org/drools/eclipse/wizard/dsl/NewDSLFilePage.java 2010-08-09 23:55:44 UTC (rev 34615)
@@ -43,6 +43,7 @@
public class NewDSLFilePage extends WizardNewFileCreationPage {
private IWorkbench workbench;
+ private boolean exampleContent;
public NewDSLFilePage(IWorkbench workbench, IStructuredSelection selection) {
super("createDSLFilePage", selection);
@@ -56,7 +57,8 @@
setPageComplete(true);
}
- public boolean finish() {
+ public boolean finish(boolean exampleContent) {
+ this.exampleContent = exampleContent;
String fileName = getFileName();
if (!fileName.endsWith(".dsl")) {
setFileName(fileName + ".dsl");
@@ -78,8 +80,12 @@
protected InputStream getInitialContents() {
try {
- return DroolsEclipsePlugin.getDefault().getBundle().getResource(
- "org/drools/eclipse/wizard/dsl/template.dsl").openStream();
+ if (exampleContent) {
+ return DroolsEclipsePlugin.getDefault().getBundle().getResource(
+ "org/drools/eclipse/wizard/dsl/template.dsl").openStream();
+ } else {
+ return null;
+ }
} catch (IOException e) {
return null;
} catch (NullPointerException e) {
Added: labs/jbossrules/branches/5.1.x/drools-eclipse/org.drools.eclipse/src/main/java/org/drools/eclipse/wizard/dsl/NewDSLFilePage2.java
===================================================================
--- labs/jbossrules/branches/5.1.x/drools-eclipse/org.drools.eclipse/src/main/java/org/drools/eclipse/wizard/dsl/NewDSLFilePage2.java (rev 0)
+++ labs/jbossrules/branches/5.1.x/drools-eclipse/org.drools.eclipse/src/main/java/org/drools/eclipse/wizard/dsl/NewDSLFilePage2.java 2010-08-09 23:55:44 UTC (rev 34615)
@@ -0,0 +1,88 @@
+/**
+ * Copyright 2010 JBoss Inc
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.drools.eclipse.wizard.dsl;
+
+import java.util.HashMap;
+
+import org.drools.eclipse.preferences.DroolsProjectPreferencePage;
+import org.drools.eclipse.util.DroolsRuntime;
+import org.drools.eclipse.util.DroolsRuntimeManager;
+import org.eclipse.jface.wizard.WizardPage;
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.events.SelectionEvent;
+import org.eclipse.swt.events.SelectionListener;
+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 org.eclipse.swt.widgets.Link;
+import org.eclipse.ui.dialogs.PreferencesUtil;
+
+public class NewDSLFilePage2 extends WizardPage {
+
+ private Button exampleContent;
+ private boolean isExampleContent = false;
+
+ public NewDSLFilePage2() {
+ super("exampleContentPage");
+ setTitle("Content");
+ setDescription("Select the default content of the DSL file");
+ }
+
+ public void createControl(Composite parent) {
+ Composite composite = new Composite(parent, SWT.NONE);
+ GridLayout gridLayout = new GridLayout();
+ gridLayout.numColumns = 2;
+ composite.setLayout(gridLayout);
+
+ exampleContent = createCheckBox(composite,
+ "Create the DSL file with some sample DSL statements");
+ exampleContent.setSelection(false);
+ exampleContent.addSelectionListener(new SelectionListener() {
+ public void widgetDefaultSelected(SelectionEvent e) {
+ // do nothing
+ }
+ public void widgetSelected(SelectionEvent e) {
+ isExampleContent = ((Button) e.widget).getSelection();
+ }
+ });
+ GridData gridData = new GridData();
+ gridData.horizontalSpan = 2;
+ gridData.grabExcessHorizontalSpace = true;
+ gridData.horizontalAlignment = GridData.FILL;
+ exampleContent.setLayoutData(gridData);
+
+ setMessage(null);
+ setPageComplete(true);
+ setControl(composite);
+ }
+
+ private Button createCheckBox(Composite group, String label) {
+ Button button = new Button(group, SWT.CHECK | SWT.LEFT);
+ button.setText(label);
+ GridData data = new GridData();
+ button.setLayoutData(data);
+ return button;
+ }
+
+ public boolean isExampleContent() {
+ return isExampleContent;
+ }
+
+}
Modified: labs/jbossrules/branches/5.1.x/drools-eclipse/org.drools.eclipse/src/main/java/org/drools/eclipse/wizard/dsl/NewDSLFileWizard.java
===================================================================
--- labs/jbossrules/branches/5.1.x/drools-eclipse/org.drools.eclipse/src/main/java/org/drools/eclipse/wizard/dsl/NewDSLFileWizard.java 2010-08-09 23:27:59 UTC (rev 34614)
+++ labs/jbossrules/branches/5.1.x/drools-eclipse/org.drools.eclipse/src/main/java/org/drools/eclipse/wizard/dsl/NewDSLFileWizard.java 2010-08-09 23:55:44 UTC (rev 34615)
@@ -34,6 +34,7 @@
private IWorkbench workbench;
private IStructuredSelection selection;
private NewDSLFilePage mainPage;
+ private NewDSLFilePage2 extraPage;
public void init(IWorkbench workbench, IStructuredSelection selection) {
this.workbench = workbench;
@@ -46,10 +47,12 @@
public void addPages() {
mainPage = new NewDSLFilePage(workbench, selection);
addPage(mainPage);
+ extraPage = new NewDSLFilePage2();
+ addPage(extraPage);
}
public boolean performFinish() {
- return mainPage.finish();
+ return mainPage.finish(extraPage.isExampleContent());
}
More information about the jboss-svn-commits
mailing list