[jbosstools-commits] JBoss Tools SVN: r6841 - in trunk/seam/plugins/org.jboss.tools.seam.ui/src/org/jboss/tools/seam/ui: widget/editor and 1 other directories.

jbosstools-commits at lists.jboss.org jbosstools-commits at lists.jboss.org
Tue Mar 11 10:12:34 EDT 2008


Author: scabanovich
Date: 2008-03-11 10:12:34 -0400 (Tue, 11 Mar 2008)
New Revision: 6841

Added:
   trunk/seam/plugins/org.jboss.tools.seam.ui/src/org/jboss/tools/seam/ui/wizard/ShowProjectSettingsAction.java
Modified:
   trunk/seam/plugins/org.jboss.tools.seam.ui/src/org/jboss/tools/seam/ui/SeamUIMessages.java
   trunk/seam/plugins/org.jboss.tools.seam.ui/src/org/jboss/tools/seam/ui/messages.properties
   trunk/seam/plugins/org.jboss.tools.seam.ui/src/org/jboss/tools/seam/ui/widget/editor/IFieldEditorFactory.java
   trunk/seam/plugins/org.jboss.tools.seam.ui/src/org/jboss/tools/seam/ui/widget/editor/SwtFieldEditorFactory.java
   trunk/seam/plugins/org.jboss.tools.seam.ui/src/org/jboss/tools/seam/ui/wizard/SeamProjectSelectionDialog.java
   trunk/seam/plugins/org.jboss.tools.seam.ui/src/org/jboss/tools/seam/ui/wizard/SeamWizardFactory.java
Log:
JBIDE-1322

Modified: trunk/seam/plugins/org.jboss.tools.seam.ui/src/org/jboss/tools/seam/ui/SeamUIMessages.java
===================================================================
--- trunk/seam/plugins/org.jboss.tools.seam.ui/src/org/jboss/tools/seam/ui/SeamUIMessages.java	2008-03-11 14:04:58 UTC (rev 6840)
+++ trunk/seam/plugins/org.jboss.tools.seam.ui/src/org/jboss/tools/seam/ui/SeamUIMessages.java	2008-03-11 14:12:34 UTC (rev 6841)
@@ -180,6 +180,8 @@
 	public static String SEAM_PROJECT_LABEL_PROVIDER_SEAM_COMPONENTS;
 
 	public static String SEAM_PROJECT_SELECTION_DIALOG_SEAM_WEB_PROJECT;
+	
+	public static String SEAM_PROJECT_SELECTION_DIALOG_SHOW_ALL_PROJECTS;
 
 	public static String SEAM_PROJECT_SELECTION_DIALOG_SELECT_SEAM_WEB_PROJECT;
 
@@ -306,6 +308,8 @@
 	public static String SEAM_WIZARD_FACTORY_SEAM_PROJECT;
 
 	public static String SELECT_SEAM_PROJECT_ACTION_BROWSE;
+	
+	public static String SHOW_PROJECT_SETTINGS_ACTION;
 
 	public static String SWT_FIELD_EDITOR_FACTORY_BROWS;
 

Modified: trunk/seam/plugins/org.jboss.tools.seam.ui/src/org/jboss/tools/seam/ui/messages.properties
===================================================================
--- trunk/seam/plugins/org.jboss.tools.seam.ui/src/org/jboss/tools/seam/ui/messages.properties	2008-03-11 14:04:58 UTC (rev 6840)
+++ trunk/seam/plugins/org.jboss.tools.seam.ui/src/org/jboss/tools/seam/ui/messages.properties	2008-03-11 14:12:34 UTC (rev 6841)
@@ -35,6 +35,7 @@
 SEAM_INSTALL_WIZARD_PAGE_DATABASE_CATALOG_NAME=Database Catalog Name:
 SEAM_PROJECT_WIZARD_PAGE1_MULTIPAGE_EDITOR_FILE=Multi-page Editor File
 SEAM_PROJECT_SELECTION_DIALOG_SEAM_WEB_PROJECT=Seam Web Projects
+SEAM_PROJECT_SELECTION_DIALOG_SHOW_ALL_PROJECTS=Show all projects
 SEAM_PROJECT_LABEL_PROVIDER_SEAM_COMPONENTS=Seam Components
 SEAM_ENTITY_WIZARD_PAGE1_ENTITY_MASTER_PAGE=Entity master page
 SEAM_ENTITY_WIZARD_ENTITY_CREATING_OPERATION=Entity creating operation
@@ -87,6 +88,7 @@
 SEAM_WIZARD_FACTORY_SEAM_PROJECT=Seam Project:
 SEAM_INSTALL_WIZARD_PAGE_DATABASE=Database
 SELECT_SEAM_PROJECT_ACTION_BROWSE=Browse...
+SHOW_PROJECT_SETTINGS_ACTION=Settings...
 SEAM_INSTALL_WIZARD_PAGE_CODE_GENERATION=Code Generation
 SEAM_FORM_WIZARD_FORM_CREATING_OPERATION=Form creating operation
 SEAM_WIZARD_FACTORY_LOCAL_INTERFACE_NAME=Local interface name:

Modified: trunk/seam/plugins/org.jboss.tools.seam.ui/src/org/jboss/tools/seam/ui/widget/editor/IFieldEditorFactory.java
===================================================================
--- trunk/seam/plugins/org.jboss.tools.seam.ui/src/org/jboss/tools/seam/ui/widget/editor/IFieldEditorFactory.java	2008-03-11 14:04:58 UTC (rev 6840)
+++ trunk/seam/plugins/org.jboss.tools.seam.ui/src/org/jboss/tools/seam/ui/widget/editor/IFieldEditorFactory.java	2008-03-11 14:12:34 UTC (rev 6841)
@@ -159,6 +159,19 @@
 	 * 
 	 * @param name
 	 * @param label
+	 * @param defaultValue
+	 * @param actions
+	 * @param validator
+	 * @return
+	 */
+	public IFieldEditor createButtonFieldEditor(String name, String label,
+			String defaultValue, ButtonFieldEditor.ButtonPressedAction[] actions, 
+			IValidator validator);
+
+	/**
+	 * 
+	 * @param name
+	 * @param label
 	 * @param values
 	 * @param defaultValue
 	 * @param editable

Modified: trunk/seam/plugins/org.jboss.tools.seam.ui/src/org/jboss/tools/seam/ui/widget/editor/SwtFieldEditorFactory.java
===================================================================
--- trunk/seam/plugins/org.jboss.tools.seam.ui/src/org/jboss/tools/seam/ui/widget/editor/SwtFieldEditorFactory.java	2008-03-11 14:04:58 UTC (rev 6840)
+++ trunk/seam/plugins/org.jboss.tools.seam.ui/src/org/jboss/tools/seam/ui/widget/editor/SwtFieldEditorFactory.java	2008-03-11 14:12:34 UTC (rev 6841)
@@ -348,6 +348,18 @@
 		return editor;
 	}
 
+	public IFieldEditor createButtonFieldEditor(String name, String label, String defaultValue, ButtonFieldEditor.ButtonPressedAction[] actions, IValidator validator ) {
+		CompositeEditor editor = new CompositeEditor(name,label, defaultValue);
+		List<IFieldEditor> editors = new ArrayList<IFieldEditor>();
+		editors.add(new LabelFieldEditor(name,label));
+		editors.add(new TextFieldEditor(name,label, defaultValue));
+		for (int i = 0; i < actions.length; i++) {
+			editors.add(new ButtonFieldEditor(name,actions[i],defaultValue));
+		}
+		editor.addFieldEditors(editors.toArray(new IFieldEditor[0]));
+		return editor;
+	}
+
 	/**
 	 * @param buttonName
 	 * @return

Modified: trunk/seam/plugins/org.jboss.tools.seam.ui/src/org/jboss/tools/seam/ui/wizard/SeamProjectSelectionDialog.java
===================================================================
--- trunk/seam/plugins/org.jboss.tools.seam.ui/src/org/jboss/tools/seam/ui/wizard/SeamProjectSelectionDialog.java	2008-03-11 14:04:58 UTC (rev 6840)
+++ trunk/seam/plugins/org.jboss.tools.seam.ui/src/org/jboss/tools/seam/ui/wizard/SeamProjectSelectionDialog.java	2008-03-11 14:12:34 UTC (rev 6841)
@@ -19,8 +19,14 @@
 import org.eclipse.jface.viewers.ISelectionChangedListener;
 import org.eclipse.jface.viewers.IStructuredContentProvider;
 import org.eclipse.jface.viewers.SelectionChangedEvent;
+import org.eclipse.jface.viewers.TableViewer;
 import org.eclipse.jface.viewers.Viewer;
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.events.SelectionEvent;
+import org.eclipse.swt.events.SelectionListener;
+import org.eclipse.swt.widgets.Button;
 import org.eclipse.swt.widgets.Composite;
+import org.eclipse.swt.widgets.Control;
 import org.eclipse.swt.widgets.Shell;
 import org.eclipse.ui.dialogs.ListDialog;
 import org.eclipse.ui.model.WorkbenchLabelProvider;
@@ -36,6 +42,8 @@
  *
  */
 public class SeamProjectSelectionDialog extends ListDialog implements ISelectionChangedListener {
+	Button check;
+	boolean allowAllProjects = false;
 
 	/**
 	 * @param parent
@@ -43,6 +51,7 @@
 	 */
 	public SeamProjectSelectionDialog(Shell parent, final boolean allowAllProjects) {
 		super(parent);
+		this.allowAllProjects = allowAllProjects;
 		setTitle(SeamUIMessages.SEAM_PROJECT_SELECTION_DIALOG_SEAM_WEB_PROJECT);
 		setMessage(SeamUIMessages.SEAM_PROJECT_SELECTION_DIALOG_SELECT_SEAM_WEB_PROJECT);
 		setLabelProvider(new WorkbenchLabelProvider());
@@ -52,7 +61,8 @@
 				ArrayList<IProject> seamProjects = new ArrayList<IProject>();
 				for (IProject project : ResourcesPlugin.getWorkspace().getRoot().getProjects()) {
 					try {
-						if(allowAllProjects || (project.hasNature(ISeamProject.NATURE_ID) 
+						if((allowAllProjects || (check != null && check.getSelection())) 
+							|| (project.hasNature(ISeamProject.NATURE_ID) 
 								&& SeamCorePlugin.getSeamPreferences(project)!=null
 								&& project.getAdapter(IFacetedProject.class)!=null
 								&& ((IFacetedProject)project.getAdapter(IFacetedProject.class)).hasProjectFacet(ProjectFacetsManager.getProjectFacet("jst.web"))
@@ -96,4 +106,23 @@
 	public void selectionChanged(SelectionChangedEvent event) {
 		getOkButton().setEnabled(!event.getSelection().isEmpty());
 	}
+
+    protected Control createDialogArea(Composite container) {
+    	Composite parent = (Composite) super.createDialogArea(container);
+    	if(!allowAllProjects) {
+    		check = new Button(parent, SWT.CHECK);
+    		check.setText(SeamUIMessages.SEAM_PROJECT_SELECTION_DIALOG_SHOW_ALL_PROJECTS);
+    		check.setSelection(false);
+    		check.addSelectionListener(new SelectionListener() {
+				public void widgetDefaultSelected(SelectionEvent e) {
+					widgetSelected(e);
+				}
+				public void widgetSelected(SelectionEvent e) {
+					TableViewer v = getTableViewer();
+					v.refresh();
+				}    			
+    		});
+    	}
+    	return parent;
+    }
 }
\ No newline at end of file

Modified: trunk/seam/plugins/org.jboss.tools.seam.ui/src/org/jboss/tools/seam/ui/wizard/SeamWizardFactory.java
===================================================================
--- trunk/seam/plugins/org.jboss.tools.seam.ui/src/org/jboss/tools/seam/ui/wizard/SeamWizardFactory.java	2008-03-11 14:04:58 UTC (rev 6840)
+++ trunk/seam/plugins/org.jboss.tools.seam.ui/src/org/jboss/tools/seam/ui/wizard/SeamWizardFactory.java	2008-03-11 14:12:34 UTC (rev 6841)
@@ -56,9 +56,22 @@
 	 * @return
 	 */
 	public static IFieldEditor createSeamProjectSelectionFieldEditor(String name, String label, String defaultSelection, boolean allowAllProjects) {
-		return IFieldEditorFactory.INSTANCE.createButtonFieldEditor(
+		if(allowAllProjects) {
+			return IFieldEditorFactory.INSTANCE.createButtonFieldEditor(
+					name, label, defaultSelection, 
+					 new SelectSeamProjectAction(allowAllProjects), ValidatorFactory.NO_ERRORS_VALIDATOR);
+		}
+		ShowProjectSettingsAction settingsAction = new ShowProjectSettingsAction();
+		ButtonFieldEditor.ButtonPressedAction[] actions = new ButtonFieldEditor.ButtonPressedAction[]{
+			new SelectSeamProjectAction(allowAllProjects),
+			settingsAction
+		};
+		IFieldEditor editor = IFieldEditorFactory.INSTANCE.createButtonFieldEditor(
 				name, label, defaultSelection, 
-				 new SelectSeamProjectAction(allowAllProjects), ValidatorFactory.NO_ERRORS_VALIDATOR);
+				actions, ValidatorFactory.NO_ERRORS_VALIDATOR);
+		settingsAction.setEnabled(false);
+		settingsAction.setEditor(editor);
+		return editor;
 	}
 
 	/**

Added: trunk/seam/plugins/org.jboss.tools.seam.ui/src/org/jboss/tools/seam/ui/wizard/ShowProjectSettingsAction.java
===================================================================
--- trunk/seam/plugins/org.jboss.tools.seam.ui/src/org/jboss/tools/seam/ui/wizard/ShowProjectSettingsAction.java	                        (rev 0)
+++ trunk/seam/plugins/org.jboss.tools.seam.ui/src/org/jboss/tools/seam/ui/wizard/ShowProjectSettingsAction.java	2008-03-11 14:12:34 UTC (rev 6841)
@@ -0,0 +1,65 @@
+package org.jboss.tools.seam.ui.wizard;
+
+import java.beans.PropertyChangeEvent;
+import java.beans.PropertyChangeListener;
+import java.util.List;
+
+import org.eclipse.core.resources.IProject;
+import org.eclipse.core.resources.ResourcesPlugin;
+import org.eclipse.jface.preference.PreferenceDialog;
+import org.eclipse.ui.PlatformUI;
+import org.eclipse.ui.dialogs.PreferencesUtil;
+import org.jboss.tools.seam.ui.SeamUIMessages;
+import org.jboss.tools.seam.ui.widget.editor.ButtonFieldEditor;
+import org.jboss.tools.seam.ui.widget.editor.CompositeEditor;
+import org.jboss.tools.seam.ui.widget.editor.IFieldEditor;
+
+public class ShowProjectSettingsAction extends ButtonFieldEditor.ButtonPressedAction implements PropertyChangeListener {
+	IFieldEditor editor;
+	IFieldEditor button;
+
+	public ShowProjectSettingsAction() {
+		super(SeamUIMessages.SHOW_PROJECT_SETTINGS_ACTION);
+	}
+	
+	public void setEditor(IFieldEditor editor) {
+		this.editor = editor;
+		editor.addPropertyChangeListener(this);
+		CompositeEditor c = (CompositeEditor)editor;
+		List<IFieldEditor> es = c.getEditors();
+		button = es.get(es.size() - 1);
+	}
+
+	@Override
+	public void run() {
+		if(editor == null) return;
+		IProject p = getSelectedProject();
+		if(p == null) return;
+		PreferenceDialog prefsdlg = PreferencesUtil.createPropertyDialogOn(
+			PlatformUI.getWorkbench().getDisplay().getActiveShell(),
+			p,
+			"org.jboss.tools.seam.ui.propertyPages.SeamSettingsPreferencePage", 
+			new String[]{"org.jboss.tools.seam.ui.propertyPages.SeamSettingsPreferencePage"},
+			null);
+
+        prefsdlg.open();
+	}
+
+	public void propertyChange(PropertyChangeEvent evt) {
+		IProject p = getSelectedProject();
+		boolean enabled = p != null;
+		if(isEnabled() != enabled) {
+			setEnabled(enabled);
+			button.setEnabled(enabled);
+		}		
+	}
+	
+	IProject getSelectedProject() {
+		String s = editor.getValueAsString();
+		if(s == null || s.length() == 0) return null;
+		IProject p = ResourcesPlugin.getWorkspace().getRoot().getProject(s);
+		if(p == null || !p.isAccessible()) return null;
+		return p;
+	}
+
+}




More information about the jbosstools-commits mailing list