Author: DartPeng
Date: 2008-09-18 03:48:35 -0400 (Thu, 18 Sep 2008)
New Revision: 10346
Added:
trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/ui/wizards/INewResourceConfigFactory.java
trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/ui/wizards/NewResourceConfigFactory.java
trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/ui/wizards/NewResourceConfigKey.java
trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/ui/wizards/NewResourceConfigWizard.java
trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/ui/wizards/NewResourceConfigWizardPage.java
Log:
Add some java file to display the NewResourceConfig wizard
Added:
trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/ui/wizards/INewResourceConfigFactory.java
===================================================================
---
trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/ui/wizards/INewResourceConfigFactory.java
(rev 0)
+++
trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/ui/wizards/INewResourceConfigFactory.java 2008-09-18
07:48:35 UTC (rev 10346)
@@ -0,0 +1,23 @@
+/*******************************************************************************
+ * Copyright (c) 2008 Red Hat, Inc.
+ * Distributed under license by Red Hat, Inc. All rights reserved.
+ * This program is made available under the terms of the
+ * Eclipse Public License v1.0 which accompanies this distribution,
+ * and is available at
http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Red Hat, Inc. - initial API and implementation
+ ******************************************************************************/
+package org.jboss.tools.smooks.ui.wizards;
+
+import org.jboss.tools.smooks.model.ResourceConfigType;
+
+/**
+ * @author Dart Peng<br>
+ * Date : Sep 18, 2008
+ */
+public interface INewResourceConfigFactory {
+ public ResourceConfigType createNewResourceConfig(NewResourceConfigKey key);
+
+ public NewResourceConfigKey[] getAllIDs();
+}
Property changes on:
trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/ui/wizards/INewResourceConfigFactory.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Added:
trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/ui/wizards/NewResourceConfigFactory.java
===================================================================
---
trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/ui/wizards/NewResourceConfigFactory.java
(rev 0)
+++
trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/ui/wizards/NewResourceConfigFactory.java 2008-09-18
07:48:35 UTC (rev 10346)
@@ -0,0 +1,98 @@
+/*******************************************************************************
+ * Copyright (c) 2008 Red Hat, Inc.
+ * Distributed under license by Red Hat, Inc. All rights reserved.
+ * This program is made available under the terms of the
+ * Eclipse Public License v1.0 which accompanies this distribution,
+ * and is available at
http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Red Hat, Inc. - initial API and implementation
+ ******************************************************************************/
+package org.jboss.tools.smooks.ui.wizards;
+
+import org.jboss.tools.smooks.model.ParamType;
+import org.jboss.tools.smooks.model.ResourceConfigType;
+import org.jboss.tools.smooks.model.ResourceType;
+import org.jboss.tools.smooks.model.SmooksFactory;
+import org.jboss.tools.smooks.model.util.SmooksModelConstants;
+
+/**
+ * @author Dart Peng<br>
+ * Date : Sep 18, 2008
+ */
+public class NewResourceConfigFactory implements INewResourceConfigFactory {
+
+ private static NewResourceConfigFactory instance = null;
+
+ private NewResourceConfigFactory(){
+
+ }
+
+ public static synchronized NewResourceConfigFactory getInstance() {
+ if(instance == null) instance = new NewResourceConfigFactory();
+ return instance;
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see
org.jboss.tools.smooks.ui.INewResourceConfigFactory#createNewResourceConfig(java.lang.String)
+ */
+ public ResourceConfigType createNewResourceConfig(NewResourceConfigKey key) {
+ if (SmooksModelConstants.BEAN_POPULATOR.equals(key.getId())) {
+ ResourceConfigType config = SmooksFactory.eINSTANCE
+ .createResourceConfigType();
+ ResourceType resource = SmooksFactory.eINSTANCE
+ .createResourceType();
+ config.setResource(resource);
+ resource.setValue(SmooksModelConstants.BEAN_POPULATOR);
+
+ ParamType idParmType = SmooksFactory.eINSTANCE.createParamType();
+ ParamType classParmType = SmooksFactory.eINSTANCE.createParamType();
+ ParamType bindingParmType = SmooksFactory.eINSTANCE
+ .createParamType();
+ idParmType.setName(SmooksModelConstants.BEAN_ID);
+ classParmType.setName(SmooksModelConstants.BEAN_CLASS);
+
+ config.getParam().add(idParmType);
+ config.getParam().add(classParmType);
+ config.getParam().add(bindingParmType);
+ return config;
+ }
+ if (SmooksModelConstants.DATE_DECODER.equals(key.getId())) {
+ ResourceConfigType config = SmooksFactory.eINSTANCE
+ .createResourceConfigType();
+ ResourceType resource = SmooksFactory.eINSTANCE
+ .createResourceType();
+ config.setResource(resource);
+
+ resource.setValue(SmooksModelConstants.DATE_DECODER);
+
+ ParamType formate = SmooksFactory.eINSTANCE.createParamType();
+ ParamType language = SmooksFactory.eINSTANCE.createParamType();
+ ParamType contry = SmooksFactory.eINSTANCE.createParamType();
+ formate.setName(SmooksModelConstants.FORMATE);
+ language.setName(SmooksModelConstants.LOCALE_LANGUAGE);
+ contry.setName(SmooksModelConstants.LOCALE_CONTRY);
+
+ config.getParam().add(formate);
+ config.getParam().add(language);
+ config.getParam().add(contry);
+
+ return config;
+ }
+ return null;
+ }
+
+ public NewResourceConfigKey[] getAllIDs() {
+ NewResourceConfigKey bean = new NewResourceConfigKey();
+ bean.setId(SmooksModelConstants.BEAN_POPULATOR);
+ bean.setName("BeanPopulator");
+
+ NewResourceConfigKey date = new NewResourceConfigKey();
+ date.setId(SmooksModelConstants.DATE_DECODER);
+ date.setName("Date Decoder");
+ return new NewResourceConfigKey[] { bean, date };
+ }
+
+}
Property changes on:
trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/ui/wizards/NewResourceConfigFactory.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Added:
trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/ui/wizards/NewResourceConfigKey.java
===================================================================
---
trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/ui/wizards/NewResourceConfigKey.java
(rev 0)
+++
trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/ui/wizards/NewResourceConfigKey.java 2008-09-18
07:48:35 UTC (rev 10346)
@@ -0,0 +1,48 @@
+/*******************************************************************************
+ * Copyright (c) 2008 Red Hat, Inc.
+ * Distributed under license by Red Hat, Inc. All rights reserved.
+ * This program is made available under the terms of the
+ * Eclipse Public License v1.0 which accompanies this distribution,
+ * and is available at
http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Red Hat, Inc. - initial API and implementation
+ ******************************************************************************/
+package org.jboss.tools.smooks.ui.wizards;
+
+import org.eclipse.swt.graphics.Image;
+
+/**
+ * @author Dart Peng<br>
+ * Date : Sep 18, 2008
+ */
+public class NewResourceConfigKey {
+ private String id = null;
+ private String name = null;
+
+ private Image image = null;
+
+ public String getId() {
+ return id;
+ }
+
+ public void setId(String id) {
+ this.id = id;
+ }
+
+ public String getName() {
+ return name;
+ }
+
+ public void setName(String name) {
+ this.name = name;
+ }
+
+ public Image getImage() {
+ return image;
+ }
+
+ public void setImage(Image image) {
+ this.image = image;
+ }
+}
Property changes on:
trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/ui/wizards/NewResourceConfigKey.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Added:
trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/ui/wizards/NewResourceConfigWizard.java
===================================================================
---
trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/ui/wizards/NewResourceConfigWizard.java
(rev 0)
+++
trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/ui/wizards/NewResourceConfigWizard.java 2008-09-18
07:48:35 UTC (rev 10346)
@@ -0,0 +1,57 @@
+/*******************************************************************************
+ * Copyright (c) 2008 Red Hat, Inc.
+ * Distributed under license by Red Hat, Inc. All rights reserved.
+ * This program is made available under the terms of the
+ * Eclipse Public License v1.0 which accompanies this distribution,
+ * and is available at
http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Red Hat, Inc. - initial API and implementation
+ ******************************************************************************/
+package org.jboss.tools.smooks.ui.wizards;
+
+import org.eclipse.jface.wizard.Wizard;
+
+/**
+ * @author Dart Peng<br>
+ * Date : Sep 18, 2008
+ */
+public class NewResourceConfigWizard extends Wizard {
+ protected NewResourceConfigWizardPage page = null;
+
+ private NewResourceConfigKey selectedKey = null;
+
+
+ @Override
+ public void addPages() {
+ if(page == null){
+ page = new NewResourceConfigWizardPage("New ResourceConfig");
+ }
+ this.addPage(page);
+ super.addPages();
+ }
+
+
+
+ /* (non-Javadoc)
+ * @see org.eclipse.jface.wizard.Wizard#performFinish()
+ */
+ @Override
+ public boolean performFinish() {
+ this.setSelectedKey(page.getSelectedKey());
+ return true;
+ }
+
+
+
+ public NewResourceConfigKey getSelectedKey() {
+ return selectedKey;
+ }
+
+
+
+ public void setSelectedKey(NewResourceConfigKey selectedKey) {
+ this.selectedKey = selectedKey;
+ }
+
+}
Property changes on:
trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/ui/wizards/NewResourceConfigWizard.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Added:
trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/ui/wizards/NewResourceConfigWizardPage.java
===================================================================
---
trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/ui/wizards/NewResourceConfigWizardPage.java
(rev 0)
+++
trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/ui/wizards/NewResourceConfigWizardPage.java 2008-09-18
07:48:35 UTC (rev 10346)
@@ -0,0 +1,128 @@
+/*******************************************************************************
+ * Copyright (c) 2008 Red Hat, Inc.
+ * Distributed under license by Red Hat, Inc. All rights reserved.
+ * This program is made available under the terms of the
+ * Eclipse Public License v1.0 which accompanies this distribution,
+ * and is available at
http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Red Hat, Inc. - initial API and implementation
+ ******************************************************************************/
+package org.jboss.tools.smooks.ui.wizards;
+
+import java.util.List;
+
+import org.eclipse.jface.resource.ImageDescriptor;
+import org.eclipse.jface.viewers.ISelectionChangedListener;
+import org.eclipse.jface.viewers.IStructuredContentProvider;
+import org.eclipse.jface.viewers.IStructuredSelection;
+import org.eclipse.jface.viewers.LabelProvider;
+import org.eclipse.jface.viewers.SelectionChangedEvent;
+import org.eclipse.jface.viewers.TableViewer;
+import org.eclipse.jface.viewers.Viewer;
+import org.eclipse.jface.wizard.WizardPage;
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.graphics.Image;
+import org.eclipse.swt.layout.FillLayout;
+import org.eclipse.swt.widgets.Composite;
+
+/**
+ * @author Dart Peng<br>
+ * Date : Sep 18, 2008
+ */
+public class NewResourceConfigWizardPage extends WizardPage implements
ISelectionChangedListener{
+
+ private NewResourceConfigKey selectedKey = null;
+
+ public NewResourceConfigWizardPage(String pageName, String title,
+ ImageDescriptor titleImage) {
+ super(pageName, title, titleImage);
+ // TODO Auto-generated constructor stub
+ }
+
+ public NewResourceConfigWizardPage(String pageName) {
+ super(pageName);
+ }
+
+ /* (non-Javadoc)
+ * @see
org.eclipse.jface.dialogs.IDialogPage#createControl(org.eclipse.swt.widgets.Composite)
+ */
+ public void createControl(Composite parent) {
+ Composite mainComposite = new Composite(parent,SWT.NONE);
+ FillLayout layout = new FillLayout();
+// layout.marginHeight = 350;
+ mainComposite.setLayout(layout);
+ TableViewer viewer = new TableViewer(mainComposite);
+ viewer.setContentProvider(new NewResourceConfigKeyContentProvider());
+ viewer.setLabelProvider(new NewResourceConfigKeyLabelProvider());
+ viewer.setInput(NewResourceConfigFactory.getInstance().getAllIDs());
+ viewer.addSelectionChangedListener(this);
+ setControl(mainComposite);
+
+ validatePageFinish();
+ }
+
+ protected void validatePageFinish(){
+ String error = null;
+ if(selectedKey == null){
+ error = "Please select one key";
+ }
+
+ setErrorMessage(error);
+ setPageComplete(error == null);
+ }
+
+ private class NewResourceConfigKeyContentProvider implements
IStructuredContentProvider{
+
+ public Object[] getElements(Object inputElement) {
+ if(inputElement instanceof List){
+ return ((List)inputElement).toArray();
+ }
+ if(inputElement.getClass().isArray()){
+ return (Object[])inputElement;
+ }
+ return new Object[]{};
+ }
+
+ public void dispose() {
+
+ }
+
+ public void inputChanged(Viewer viewer, Object oldInput, Object newInput) {
+
+ }
+
+ }
+
+ private class NewResourceConfigKeyLabelProvider extends LabelProvider{
+
+ public Image getImage(Object element) {
+ if(element instanceof NewResourceConfigKey){
+ return ((NewResourceConfigKey)element).getImage();
+ }
+ return super.getImage(element);
+ }
+
+ public String getText(Object element) {
+ if(element instanceof NewResourceConfigKey){
+ return ((NewResourceConfigKey)element).getName();
+ }
+ return super.getText(element);
+ }
+
+ }
+
+ public void selectionChanged(SelectionChangedEvent event) {
+ Object obj = ((IStructuredSelection)event.getSelection()).getFirstElement();
+ if(obj != null && obj instanceof NewResourceConfigKey){
+ selectedKey = (NewResourceConfigKey)obj;
+ }
+
+ validatePageFinish();
+ }
+
+ public NewResourceConfigKey getSelectedKey() {
+ return selectedKey;
+ }
+
+}
Property changes on:
trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/ui/wizards/NewResourceConfigWizardPage.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain