JBoss Tools SVN: r15000 - in trunk/hibernatetools: plugins/org.hibernate.eclipse.jdt.ui and 10 other directories.
by jbosstools-commits@lists.jboss.org
Author: dgeraskov
Date: 2009-05-04 08:08:45 -0400 (Mon, 04 May 2009)
New Revision: 15000
Added:
trunk/hibernatetools/plugins/org.hibernate.eclipse.jdt.ui/icons/hibernate_small_icon.gif
trunk/hibernatetools/plugins/org.hibernate.eclipse.jdt.ui/src/org/hibernate/eclipse/jdt/ui/wizards/
trunk/hibernatetools/plugins/org.hibernate.eclipse.jdt.ui/src/org/hibernate/eclipse/jdt/ui/wizards/ConfigurationActor.java
trunk/hibernatetools/plugins/org.hibernate.eclipse.jdt.ui/src/org/hibernate/eclipse/jdt/ui/wizards/NewHibernateMappingFilePage.java
trunk/hibernatetools/plugins/org.hibernate.eclipse.jdt.ui/src/org/hibernate/eclipse/jdt/ui/wizards/NewHibernateMappingFileWizard.java
trunk/hibernatetools/tests/org.hibernate.eclipse.console.test/src/org/hibernate/eclipse/console/test/mappingproject/HbmExportExceptionTest.java
trunk/hibernatetools/tests/org.hibernate.eclipse.jdt.ui.test/res/hbm/
trunk/hibernatetools/tests/org.hibernate.eclipse.jdt.ui.test/res/hbm/pack/
trunk/hibernatetools/tests/org.hibernate.eclipse.jdt.ui.test/res/hbm/pack/A.java
trunk/hibernatetools/tests/org.hibernate.eclipse.jdt.ui.test/res/hbm/pack/B.java
trunk/hibernatetools/tests/org.hibernate.eclipse.jdt.ui.test/src/org/hibernate/eclipse/jdt/ui/test/hbmexporter/
trunk/hibernatetools/tests/org.hibernate.eclipse.jdt.ui.test/src/org/hibernate/eclipse/jdt/ui/test/hbmexporter/HbmExporterTest.java
Removed:
trunk/hibernatetools/plugins/org.hibernate.eclipse.console/src/org/hibernate/eclipse/console/wizards/NewHibernateMappingFilePage.java
trunk/hibernatetools/plugins/org.hibernate.eclipse.console/src/org/hibernate/eclipse/console/wizards/NewHibernateMappingFileWizard.java
Modified:
trunk/hibernatetools/plugins/org.hibernate.eclipse.jdt.ui/META-INF/MANIFEST.MF
trunk/hibernatetools/plugins/org.hibernate.eclipse.jdt.ui/plugin.properties
trunk/hibernatetools/plugins/org.hibernate.eclipse.jdt.ui/plugin.xml
trunk/hibernatetools/tests/org.hibernate.eclipse.console.test/src/org/hibernate/eclipse/console/test/mappingproject/Customization.java
trunk/hibernatetools/tests/org.hibernate.eclipse.console.test/src/org/hibernate/eclipse/console/test/mappingproject/TestSet.java
Log:
https://jira.jboss.org/jira/browse/JBIDE-3457
Deleted: trunk/hibernatetools/plugins/org.hibernate.eclipse.console/src/org/hibernate/eclipse/console/wizards/NewHibernateMappingFilePage.java
===================================================================
--- trunk/hibernatetools/plugins/org.hibernate.eclipse.console/src/org/hibernate/eclipse/console/wizards/NewHibernateMappingFilePage.java 2009-05-04 10:06:51 UTC (rev 14999)
+++ trunk/hibernatetools/plugins/org.hibernate.eclipse.console/src/org/hibernate/eclipse/console/wizards/NewHibernateMappingFilePage.java 2009-05-04 12:08:45 UTC (rev 15000)
@@ -1,285 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source
- * Copyright 2005, JBoss Inc., and individual contributors as indicated
- * by the @authors tag. See the copyright.txt in the distribution for a
- * full listing of individual contributors.
- *
- * This is free software; you can redistribute it and/or modify it
- * under the terms of the GNU Lesser General Public License as
- * published by the Free Software Foundation; either version 2.1 of
- * the License, or (at your option) any later version.
- *
- * This software is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this software; if not, write to the Free
- * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
- * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
- */
-package org.hibernate.eclipse.console.wizards;
-
-import org.eclipse.core.resources.IResource;
-import org.eclipse.core.resources.ResourcesPlugin;
-import org.eclipse.core.runtime.Path;
-import org.eclipse.jdt.core.IJavaElement;
-import org.eclipse.jdt.core.IJavaProject;
-import org.eclipse.jdt.core.IType;
-import org.eclipse.jdt.core.JavaCore;
-import org.eclipse.jdt.core.JavaModelException;
-import org.eclipse.jdt.core.search.IJavaSearchScope;
-import org.eclipse.jdt.core.search.SearchEngine;
-import org.eclipse.jdt.ui.IJavaElementSearchConstants;
-import org.eclipse.jdt.ui.JavaUI;
-import org.eclipse.jface.dialogs.IDialogPage;
-import org.eclipse.jface.viewers.ISelection;
-import org.eclipse.jface.window.Window;
-import org.eclipse.jface.wizard.WizardPage;
-import org.eclipse.swt.SWT;
-import org.eclipse.swt.custom.ScrolledComposite;
-import org.eclipse.swt.events.ModifyEvent;
-import org.eclipse.swt.events.ModifyListener;
-import org.eclipse.swt.events.SelectionAdapter;
-import org.eclipse.swt.events.SelectionEvent;
-import org.eclipse.swt.layout.GridData;
-import org.eclipse.swt.layout.GridLayout;
-import org.eclipse.swt.widgets.Button;
-import org.eclipse.swt.widgets.Composite;
-import org.eclipse.swt.widgets.Label;
-import org.eclipse.swt.widgets.Text;
-import org.eclipse.ui.dialogs.ContainerSelectionDialog;
-import org.eclipse.ui.dialogs.SelectionDialog;
-import org.eclipse.ui.dialogs.WizardNewFileCreationPage;
-import org.hibernate.eclipse.console.HibernateConsoleMessages;
-import org.hibernate.eclipse.console.HibernateConsolePlugin;
-import org.hibernate.eclipse.console.utils.xpl.SelectionHelper;
-
-/**
- * The "New" wizard page allows setting the container for the new file as well
- * as the file name. The page will only accept file name without the extension
- * OR with the extension that matches the expected one (hbm.xml).
- */
-
-public class NewHibernateMappingFilePage extends WizardPage {
- private Label containerText;
-
- private Label fileText;
-
- private ISelection selection;
-
- private Text classToMap;
-
- private WizardNewFileCreationPage fileCreation;
-
- private boolean beenShown;
-
- /**
- * Constructor for SampleNewWizardPage.
- * @param page
- *
- * @param pageName
- */
- public NewHibernateMappingFilePage(ISelection selection, WizardNewFileCreationPage page) {
- super("wizardPage"); //$NON-NLS-1$
- this.fileCreation = page;
- setTitle(HibernateConsoleMessages.NewHibernateMappingFilePage_hibernate_xml_mapping_file);
- setDescription(HibernateConsoleMessages.NewHibernateMappingFilePage_this_wizard_creates);
- this.selection = selection;
- }
-
- public void setVisible(boolean visible) {
- containerText.setText(fileCreation.getContainerFullPath().toPortableString() );
- fileText.setText(fileCreation.getFileName() );
- super.setVisible(visible);
- if(visible) {
- classToMap.setFocus();
- }
- beenShown = true;
- dialogChanged();
- }
-
- /**
- * @see IDialogPage#createControl(Composite)
- */
- public void createControl(Composite parent) {
- final ScrolledComposite sc = new ScrolledComposite(parent, SWT.H_SCROLL | SWT.V_SCROLL);
- sc.setExpandHorizontal(true);
- sc.setExpandVertical(true);
-
- Composite container = new Composite(sc, SWT.NULL);
- sc.setContent(container);
- GridLayout layout = new GridLayout();
- container.setLayout(layout);
- layout.numColumns = 3;
- layout.verticalSpacing = 9;
-
- Label label = new Label(container, SWT.NULL);
- label.setText(HibernateConsoleMessages.NewHibernateMappingFilePage_container);
-
- containerText = new Label(container, SWT.BORDER | SWT.SINGLE);
- GridData gd = new GridData(GridData.FILL_HORIZONTAL);
- containerText.setLayoutData(gd);
-
- label = new Label(container, SWT.NULL);
- label.setText(""); //$NON-NLS-1$
-
- label = new Label(container, SWT.NULL);
- label.setText(HibernateConsoleMessages.NewHibernateMappingFilePage_file_name);
-
- fileText = new Label(container, SWT.BORDER | SWT.SINGLE);
- gd = new GridData(GridData.FILL_HORIZONTAL);
- fileText.setLayoutData(gd);
-
- label = new Label(container, SWT.NULL);
- label.setText(""); //$NON-NLS-1$
-
- label = new Label(container, SWT.NULL);
- label.setText(HibernateConsoleMessages.NewHibernateMappingFilePage_class_to_map);
-
- classToMap = new Text(container, SWT.BORDER | SWT.SINGLE);
- gd = new GridData(GridData.FILL_HORIZONTAL);
- classToMap.setLayoutData(gd);
- classToMap.addModifyListener(new ModifyListener() {
- public void modifyText(ModifyEvent e) {
- dialogChanged();
- }
- });
- //TODO (internal api!): ControlContentAssistHelper.createTextContentAssistant(classToMap, aCompletionProcessor);
-
- Button button = new Button(container, SWT.PUSH);
- button.setText(HibernateConsoleMessages.NewHibernateMappingFilePage_browse);
- button.addSelectionListener(new SelectionAdapter() {
- public void widgetSelected(SelectionEvent e) {
- handleClassToMapBrowse();
- }
- });
-
- sc.setMinSize(container.computeSize(SWT.DEFAULT, SWT.DEFAULT));
-
- initialize();
- dialogChanged();
- setControl(sc);
- }
-
- /**
- * Tests if the current workbench selection is a suitable container to use.
- */
-
- private void initialize() {
- IType initialJavaElement = SelectionHelper.getClassFromElement(SelectionHelper.getInitialJavaElement(selection));
- if(initialJavaElement!=null) {
- classToMap.setText(initialJavaElement.getFullyQualifiedName('.'));
- }
- }
-
- /**
- * Uses the standard container selection dialog to choose the new value for
- * the container field.
- */
-
- private void handleBrowse() {
- ContainerSelectionDialog dialog = new ContainerSelectionDialog(
- getShell(), ResourcesPlugin.getWorkspace().getRoot(), false,
- HibernateConsoleMessages.NewHibernateMappingFilePage_select_new_file_container);
- if (dialog.open() == ContainerSelectionDialog.OK) {
- Object[] result = dialog.getResult();
- if (result.length == 1) {
- containerText.setText(((Path) result[0]).toString());
- }
- }
- }
-
- private void handleClassToMapBrowse() {
- IType type = findClassToMap();
- if(type!=null) {
- classToMap.setText(type.getFullyQualifiedName('.'));
- }
- }
-
- IType findClassToMap() {
- IJavaProject root= getRootJavaProject();
- if (root == null)
- return null;
-
- IJavaElement[] elements= new IJavaElement[] { root };
- IJavaSearchScope scope= SearchEngine.createJavaSearchScope(elements);
-
- try {
- SelectionDialog dialog= JavaUI.createTypeDialog(getShell(), getWizard().getContainer(), scope, IJavaElementSearchConstants.CONSIDER_CLASSES, false, getClassToMapText());
- dialog.setTitle(HibernateConsoleMessages.NewHibernateMappingFilePage_select_class_to_map);
- dialog.setMessage(HibernateConsoleMessages.NewHibernateMappingFilePage_the_class_will_be_used_when);
- if (dialog.open() == Window.OK) {
- Object[] resultArray= dialog.getResult();
- if (resultArray != null && resultArray.length > 0)
- return (IType) resultArray[0];
- }
- } catch (JavaModelException e) {
- HibernateConsolePlugin.getDefault().log(e);
- }
- return null;
- }
-
- private IJavaProject getRootJavaProject() {
- IResource resource = ResourcesPlugin.getWorkspace().getRoot().findMember(containerText.getText());
- if(resource!=null) {
- if(resource.getProject()!=null) {
- IJavaProject project = JavaCore.create(resource.getProject());
- return project;
- }
- }
- return null;
- }
-
- String getClassToMapText() {
- return classToMap.getText();
- }
-
- /**
- * Ensures that both text fields are set.
- */
-
- private void dialogChanged() {
- IResource container = ResourcesPlugin.getWorkspace().getRoot()
- .findMember(new Path(getContainerName()));
- String fileName = getFileName();
-
- if (getContainerName().length() == 0) {
- updateStatus(HibernateConsoleMessages.NewHibernateMappingFilePage_file_container_must_be_specified);
- return;
- }
- if (container == null
- || (container.getType() & (IResource.PROJECT | IResource.FOLDER)) == 0) {
- updateStatus(HibernateConsoleMessages.NewHibernateMappingFilePage_file_container_must_exist);
- return;
- }
- if (!container.isAccessible()) {
- updateStatus(HibernateConsoleMessages.NewHibernateMappingFilePage_project_must_be_writable);
- return;
- }
- if (fileName.length() == 0) {
- updateStatus(HibernateConsoleMessages.NewHibernateMappingFilePage_file_name_must_be_specified);
- return;
- }
- if (fileName.replace('\\', '/').indexOf('/', 1) > 0) {
- updateStatus(HibernateConsoleMessages.NewHibernateMappingFilePage_file_name_must_be_valid);
- return;
- }
-
- updateStatus(null);
- }
-
- private void updateStatus(String message) {
- setErrorMessage(message);
- setPageComplete(message == null);
- }
-
- public String getContainerName() {
- return containerText.getText();
- }
-
- public String getFileName() {
- return fileText.getText();
- }
-}
\ No newline at end of file
Deleted: trunk/hibernatetools/plugins/org.hibernate.eclipse.console/src/org/hibernate/eclipse/console/wizards/NewHibernateMappingFileWizard.java
===================================================================
--- trunk/hibernatetools/plugins/org.hibernate.eclipse.console/src/org/hibernate/eclipse/console/wizards/NewHibernateMappingFileWizard.java 2009-05-04 10:06:51 UTC (rev 14999)
+++ trunk/hibernatetools/plugins/org.hibernate.eclipse.console/src/org/hibernate/eclipse/console/wizards/NewHibernateMappingFileWizard.java 2009-05-04 12:08:45 UTC (rev 15000)
@@ -1,225 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source
- * Copyright 2005, JBoss Inc., and individual contributors as indicated
- * by the @authors tag. See the copyright.txt in the distribution for a
- * full listing of individual contributors.
- *
- * This is free software; you can redistribute it and/or modify it
- * under the terms of the GNU Lesser General Public License as
- * published by the Free Software Foundation; either version 2.1 of
- * the License, or (at your option) any later version.
- *
- * This software is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this software; if not, write to the Free
- * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
- * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
- */
-package org.hibernate.eclipse.console.wizards;
-
-import java.io.ByteArrayInputStream;
-import java.io.IOException;
-import java.io.InputStream;
-import java.lang.reflect.InvocationTargetException;
-
-import org.eclipse.core.resources.IFile;
-import org.eclipse.core.runtime.CoreException;
-import org.eclipse.core.runtime.IProgressMonitor;
-import org.eclipse.jdt.core.IType;
-import org.eclipse.jface.operation.IRunnableWithProgress;
-import org.eclipse.jface.viewers.ISelection;
-import org.eclipse.jface.viewers.IStructuredSelection;
-import org.eclipse.jface.wizard.Wizard;
-import org.eclipse.ui.INewWizard;
-import org.eclipse.ui.IWorkbench;
-import org.eclipse.ui.IWorkbenchPage;
-import org.eclipse.ui.IWorkbenchWizard;
-import org.eclipse.ui.PartInitException;
-import org.eclipse.ui.PlatformUI;
-import org.eclipse.ui.dialogs.WizardNewFileCreationPage;
-import org.eclipse.ui.ide.IDE;
-import org.hibernate.console.ImageConstants;
-import org.hibernate.eclipse.console.HibernateConsoleMessages;
-import org.hibernate.eclipse.console.HibernateConsolePlugin;
-import org.hibernate.eclipse.console.utils.EclipseImages;
-import org.hibernate.eclipse.console.utils.xpl.SelectionHelper;
-import org.hibernate.util.StringHelper;
-
-public class NewHibernateMappingFileWizard extends Wizard implements INewWizard {
- private NewHibernateMappingFilePage mappingFileInfoPage;
- private ISelection selection;
- private WizardNewFileCreationPage cPage;
-
-
- /**
- * Constructor for NewConfigurationWizard.
- */
- public NewHibernateMappingFileWizard() {
- super();
- setDefaultPageImageDescriptor(EclipseImages.getImageDescriptor(ImageConstants.NEW_WIZARD) );
- setNeedsProgressMonitor(true);
- }
-
- /** extended to update status messages on first show **/
- static class ExtendedWizardNewFileCreationPage extends WizardNewFileCreationPage {
-
- public ExtendedWizardNewFileCreationPage(String pageName, IStructuredSelection selection) {
- super(pageName, selection);
- }
-
- boolean firstTime = true;
- public void setVisible(boolean visible) {
- super.setVisible(visible);
- if(firstTime) {
- validatePage();
- firstTime = false;
- }
- }
- }
- /**
- * Adding the page to the wizard.
- */
-
- public void addPages() {
- cPage =
- new ExtendedWizardNewFileCreationPage( "Chbmxml", (IStructuredSelection) selection ); //$NON-NLS-1$
- cPage.setTitle( HibernateConsoleMessages.NewHibernateMappingFileWizard_create_hibernate_xml_mapping_file );
- cPage.setDescription( HibernateConsoleMessages.NewHibernateMappingFileWizard_create_new_xml_mapping_file );
- IType initialJavaElement = SelectionHelper.getClassFromElement(SelectionHelper.getInitialJavaElement(selection));
- if(initialJavaElement!=null) {
- cPage.setFileName(initialJavaElement.getElementName() + ".hbm.xml"); //$NON-NLS-1$
- } else {
- cPage.setFileName("NewMapping.hbm.xml"); //$NON-NLS-1$
- }
- addPage( cPage );
-
-
- mappingFileInfoPage = new NewHibernateMappingFilePage(selection, cPage);
- addPage(mappingFileInfoPage);
-
- }
-
-
-
- /**
- * This method is called when 'Finish' button is pressed in
- * the wizard. We will create an operation and run it
- * using wizard as execution context.
- */
- public boolean performFinish() {
- final IFile file = cPage.createNewFile();
- final String classToMapText = mappingFileInfoPage.getClassToMapText();
-
- IRunnableWithProgress op = new IRunnableWithProgress() {
- public void run(IProgressMonitor monitor) throws InvocationTargetException {
- try {
- createFile(file, classToMapText, monitor);
- } catch (CoreException e) {
- throw new InvocationTargetException(e);
- } finally {
- monitor.done();
- }
- }
- };
- try {
- getContainer().run(true, false, op);
- } catch (InterruptedException e) {
- return false;
- } catch (InvocationTargetException e) {
- Throwable realException = e.getTargetException();
- HibernateConsolePlugin.getDefault().log(realException);
- return false;
- }
- return true;
- }
-
-
- /**
- * The worker method. It will find the container, create the
- * file if missing or just replace its contents, and open
- * the editor on the newly created file.
- * @param file
- * @param props
- */
-
- private void createFile(
- final IFile file, String classToMapText, IProgressMonitor monitor)
- throws CoreException {
- // create a sample file
- monitor.beginTask(HibernateConsoleMessages.NewHibernateMappingFileWizard_creating + file.getName(), 2);
- try {
- InputStream stream = openContentStream(classToMapText);
- if (file.exists() ) {
- file.setContents(stream, true, true, monitor);
- } else {
- file.create(stream, true, monitor);
- }
- stream.close();
- } catch (IOException e) {
- }
- monitor.worked(1);
- monitor.setTaskName(HibernateConsoleMessages.NewHibernateMappingFileWizard_opening_file_for_editing);
- getShell().getDisplay().asyncExec(new Runnable() {
- public void run() {
- IWorkbenchPage page =
- PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage();
- try {
- IDE.openEditor(page, file, true);
- } catch (PartInitException e) {
- }
- }
- });
- monitor.worked(1);
- }
-
- /**
- * We will initialize file contents with a sample text.
- */
-
- private InputStream openContentStream(String classToMapText) {
-
- String classname = null;
- String packagename = null;
-
- if(StringHelper.isNotEmpty(classToMapText)) {
- classname = StringHelper.unqualify(classToMapText);
- packagename = StringHelper.qualifier(classToMapText);
- }
- String contents =
- "<?xml version=\"1.0\"?>\n" + //$NON-NLS-1$
- "<!DOCTYPE hibernate-mapping PUBLIC\n" + //$NON-NLS-1$
- " \"-//Hibernate/Hibernate Mapping DTD 3.0//EN\"\n" + //$NON-NLS-1$
- " \"http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd\">\n" + //$NON-NLS-1$
- "<hibernate-mapping"; //$NON-NLS-1$
-
- if(StringHelper.isNotEmpty(packagename)) {
- contents +=" package=\"" + packagename + "\">"; //$NON-NLS-1$//$NON-NLS-2$
- } else {
- contents +=">\n"; //$NON-NLS-1$
- }
-
- if(StringHelper.isNotEmpty(classname)) {
- contents +="\n <class name=\"" + classname + "\">\n" + //$NON-NLS-1$ //$NON-NLS-2$
- " </class>"; //$NON-NLS-1$
- }
-
- contents += "\n</hibernate-mapping>"; //$NON-NLS-1$
-
- return new ByteArrayInputStream(contents.getBytes());
- }
-
- /**
- * We will accept the selection in the workbench to see if
- * we can initialize from it.
- * @see IWorkbenchWizard#init(IWorkbench, IStructuredSelection)
- */
- public void init(IWorkbench workbench, IStructuredSelection selection) {
- this.selection = selection;
- }
-
-
-}
\ No newline at end of file
Modified: trunk/hibernatetools/plugins/org.hibernate.eclipse.jdt.ui/META-INF/MANIFEST.MF
===================================================================
--- trunk/hibernatetools/plugins/org.hibernate.eclipse.jdt.ui/META-INF/MANIFEST.MF 2009-05-04 10:06:51 UTC (rev 14999)
+++ trunk/hibernatetools/plugins/org.hibernate.eclipse.jdt.ui/META-INF/MANIFEST.MF 2009-05-04 12:08:45 UTC (rev 15000)
@@ -26,4 +26,5 @@
org.hibernate.eclipse.jdt.ui.internal.jpa.actions,
org.hibernate.eclipse.jdt.ui.internal.jpa.collect,
org.hibernate.eclipse.jdt.ui.internal.jpa.common,
- org.hibernate.eclipse.jdt.ui.internal.jpa.process
+ org.hibernate.eclipse.jdt.ui.internal.jpa.process,
+ org.hibernate.eclipse.jdt.ui.wizards
Added: trunk/hibernatetools/plugins/org.hibernate.eclipse.jdt.ui/icons/hibernate_small_icon.gif
===================================================================
(Binary files differ)
Property changes on: trunk/hibernatetools/plugins/org.hibernate.eclipse.jdt.ui/icons/hibernate_small_icon.gif
___________________________________________________________________
Name: svn:mime-type
+ image/gif
Modified: trunk/hibernatetools/plugins/org.hibernate.eclipse.jdt.ui/plugin.properties
===================================================================
--- trunk/hibernatetools/plugins/org.hibernate.eclipse.jdt.ui/plugin.properties 2009-05-04 10:06:51 UTC (rev 14999)
+++ trunk/hibernatetools/plugins/org.hibernate.eclipse.jdt.ui/plugin.properties 2009-05-04 12:08:45 UTC (rev 15000)
@@ -6,3 +6,4 @@
JavaEditorMenu_GenerateHibernateAnnotations=Generate &Hibernate/JPA annotations...
JavaElementMenu_GenerateHibernateAnnotations=Generate &Hibernate/JPA annotations
Menu_Source=&Source
+New_wizard_menu_New_mapping_file=Hibernate XML Mapping file (hbm.xml)
\ No newline at end of file
Modified: trunk/hibernatetools/plugins/org.hibernate.eclipse.jdt.ui/plugin.xml
===================================================================
--- trunk/hibernatetools/plugins/org.hibernate.eclipse.jdt.ui/plugin.xml 2009-05-04 10:06:51 UTC (rev 14999)
+++ trunk/hibernatetools/plugins/org.hibernate.eclipse.jdt.ui/plugin.xml 2009-05-04 12:08:45 UTC (rev 15000)
@@ -142,5 +142,13 @@
</action>
</objectContribution>
</extension>
-
+ <extension
+ point="org.eclipse.ui.newWizards">
+ <wizard
+ category="hibernatewizards"
+ class="org.hibernate.eclipse.jdt.ui.wizards.NewHibernateMappingFileWizard"
+ icon="icons/hibernate_small_icon.gif"
+ id="org.hibernate.eclipse.console.wizards.NewHibernateMappingFileWizard"
+ name="%New_wizard_menu_New_mapping_file"/>
+ </extension>
</plugin>
Added: trunk/hibernatetools/plugins/org.hibernate.eclipse.jdt.ui/src/org/hibernate/eclipse/jdt/ui/wizards/ConfigurationActor.java
===================================================================
--- trunk/hibernatetools/plugins/org.hibernate.eclipse.jdt.ui/src/org/hibernate/eclipse/jdt/ui/wizards/ConfigurationActor.java (rev 0)
+++ trunk/hibernatetools/plugins/org.hibernate.eclipse.jdt.ui/src/org/hibernate/eclipse/jdt/ui/wizards/ConfigurationActor.java 2009-05-04 12:08:45 UTC (rev 15000)
@@ -0,0 +1,574 @@
+/*******************************************************************************
+ * Copyright (c) 2007-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
+ *
+ * Contributor:
+ * Red Hat, Inc. - initial API and implementation
+ ******************************************************************************/
+package org.hibernate.eclipse.jdt.ui.wizards;
+
+import java.util.Collection;
+import java.util.HashMap;
+import java.util.HashSet;
+import java.util.Iterator;
+import java.util.Map;
+import java.util.Set;
+import java.util.Map.Entry;
+
+import org.eclipse.core.runtime.Assert;
+import org.eclipse.jdt.core.ICompilationUnit;
+import org.eclipse.jdt.core.IJavaProject;
+import org.eclipse.jdt.core.IType;
+import org.eclipse.jdt.core.JavaModelException;
+import org.eclipse.jdt.core.dom.ASTVisitor;
+import org.eclipse.jdt.core.dom.ArrayType;
+import org.eclipse.jdt.core.dom.CompilationUnit;
+import org.eclipse.jdt.core.dom.FieldDeclaration;
+import org.eclipse.jdt.core.dom.ITypeBinding;
+import org.eclipse.jdt.core.dom.MethodDeclaration;
+import org.eclipse.jdt.core.dom.ParameterizedType;
+import org.eclipse.jdt.core.dom.PrimitiveType;
+import org.eclipse.jdt.core.dom.QualifiedType;
+import org.eclipse.jdt.core.dom.SimpleType;
+import org.eclipse.jdt.core.dom.Type;
+import org.eclipse.jdt.core.dom.VariableDeclarationFragment;
+import org.eclipse.jdt.core.dom.WildcardType;
+import org.hibernate.FetchMode;
+import org.hibernate.cfg.Configuration;
+import org.hibernate.cfg.Mappings;
+import org.hibernate.eclipse.jdt.ui.internal.jpa.collect.AllEntitiesInfoCollector;
+import org.hibernate.eclipse.jdt.ui.internal.jpa.common.EntityInfo;
+import org.hibernate.eclipse.jdt.ui.internal.jpa.common.RefEntityInfo;
+import org.hibernate.eclipse.jdt.ui.internal.jpa.common.RefType;
+import org.hibernate.eclipse.jdt.ui.internal.jpa.common.Utils;
+import org.hibernate.mapping.Array;
+import org.hibernate.mapping.Column;
+import org.hibernate.mapping.IndexedCollection;
+import org.hibernate.mapping.JoinedSubclass;
+import org.hibernate.mapping.List;
+import org.hibernate.mapping.ManyToOne;
+import org.hibernate.mapping.OneToMany;
+import org.hibernate.mapping.OneToOne;
+import org.hibernate.mapping.PersistentClass;
+import org.hibernate.mapping.PrimitiveArray;
+import org.hibernate.mapping.Property;
+import org.hibernate.mapping.RootClass;
+import org.hibernate.mapping.SimpleValue;
+import org.hibernate.mapping.SingleTableSubclass;
+import org.hibernate.mapping.Subclass;
+import org.hibernate.mapping.Table;
+import org.hibernate.mapping.ToOne;
+import org.hibernate.mapping.Value;
+import org.hibernate.util.StringHelper;
+
+/**
+ * @author Dmitry Geraskov
+ *
+ */
+public class ConfigurationActor {
+
+ /**
+ * selected compilation units for startup processing,
+ * result of processing selection
+ */
+ protected Set<ICompilationUnit> selectionCU;
+
+ public ConfigurationActor(Set<ICompilationUnit> selectionCU){
+ this.selectionCU = selectionCU;
+ }
+
+ /**
+ *
+ * @return different configuration for different projects
+ */
+ public Map<IJavaProject, Configuration> createConfigurations(){
+ Map<IJavaProject, Configuration> configs = new HashMap<IJavaProject, Configuration>();
+ if (selectionCU.size() == 0) {
+ return configs;
+ }
+
+ AllEntitiesInfoCollector collector = new AllEntitiesInfoCollector();
+ Iterator<ICompilationUnit> it = selectionCU.iterator();
+
+ Map<IJavaProject, Set<ICompilationUnit>> mapJP_CUSet =
+ new HashMap<IJavaProject, Set<ICompilationUnit>>();
+ //separate by parent project
+ while (it.hasNext()) {
+ ICompilationUnit cu = it.next();
+ Set<ICompilationUnit> set = mapJP_CUSet.get(cu.getJavaProject());
+ if (set == null) {
+ set = new HashSet<ICompilationUnit>();
+ mapJP_CUSet.put(cu.getJavaProject(), set);
+ }
+ set.add(cu);
+ }
+ Iterator<Map.Entry<IJavaProject, Set<ICompilationUnit>>>
+ mapIt = mapJP_CUSet.entrySet().iterator();
+ while (mapIt.hasNext()) {
+ Map.Entry<IJavaProject, Set<ICompilationUnit>>
+ entry = mapIt.next();
+ IJavaProject javaProject = entry.getKey();
+ Iterator<ICompilationUnit> setIt = entry.getValue().iterator();
+ collector.initCollector(javaProject);
+ while (setIt.hasNext()) {
+ ICompilationUnit icu = setIt.next();
+ collector.collect(icu);
+ }
+ collector.resolveRelations();
+ //I don't check here if any non abstract class selected
+ configs.put(javaProject, createConfiguration(javaProject, collector.getMapCUs_Info()));
+
+ }
+ return configs;
+ }
+
+ protected Configuration createConfiguration(IJavaProject project, Map<String, EntityInfo> entities) {
+ Configuration config = new Configuration();
+
+ ProcessEntityInfo processor = new ProcessEntityInfo();
+ processor.setEntities(entities);
+
+ for (Entry<String, EntityInfo> entry : entities.entrySet()) {
+ String fullyQualifiedName = entry.getKey();
+ ICompilationUnit icu = Utils.findCompilationUnit(project, fullyQualifiedName);
+ CompilationUnit cu = Utils.getCompilationUnit(icu, true);
+
+ processor.setEntityInfo(entry.getValue());
+ cu.accept(processor);
+ }
+
+ Mappings mappings = config.createMappings();
+ Collection<PersistentClass> classesCollection = createHierarhyStructure(project, processor.getRootClasses());
+ for (PersistentClass persistentClass : classesCollection) {
+ mappings.addClass(persistentClass);
+ }
+ return config;
+ }
+
+ /**
+ * Replace <class> element on <joined-subclass> or <subclass>.
+ * @param project
+ * @param rootClasses
+ * @return
+ */
+ private Collection<PersistentClass> createHierarhyStructure(IJavaProject project, Map<String, RootClass> rootClasses){
+ Map<String, PersistentClass> pcCopy = new HashMap<String, PersistentClass>();
+ for (Map.Entry<String, RootClass> entry : rootClasses.entrySet()) {
+ pcCopy.put(entry.getKey(), entry.getValue());
+ }
+ for (Map.Entry<String, PersistentClass> entry : pcCopy.entrySet()) {
+ PersistentClass pc = null;
+ try {
+ pc = getMappedSuperclass(project, pcCopy, (RootClass) entry.getValue());
+ Subclass subclass = null;
+ if (pc != null){
+ subclass = new JoinedSubclass(pc);
+ } else {
+ pc = getMappedImplementedInterface(project, pcCopy, (RootClass) entry.getValue());
+ if (pc != null){
+ subclass = new SingleTableSubclass(pc);
+ }
+ }
+ if (subclass != null){
+ PersistentClass pastClass = pcCopy.get(entry.getKey());
+ subclass.setClassName(pastClass.getClassName());
+ subclass.setEntityName(pastClass.getEntityName());
+ subclass.setDiscriminatorValue(StringHelper.unqualify(pastClass.getClassName()));
+ subclass.setAbstract(pastClass.isAbstract());
+ entry.setValue(subclass);
+ }
+ } catch (JavaModelException e) {
+ // TODO Auto-generated catch block
+ e.printStackTrace();
+ }
+ }
+ return pcCopy.values();
+ }
+
+ private PersistentClass getMappedSuperclass(IJavaProject project, Map<String, PersistentClass> persistentClasses, RootClass rootClass) throws JavaModelException{
+ IType type = Utils.findType(project, rootClass.getClassName());
+ //TODO not direct superclass?
+ if (type.getSuperclassName() != null
+ && persistentClasses.get(type.getSuperclassName()) != null){
+ return persistentClasses.get(type.getSuperclassName());
+ }
+ return null;
+ }
+
+ private PersistentClass getMappedImplementedInterface(IJavaProject project, Map<String, PersistentClass> persistentClasses, RootClass rootClass) throws JavaModelException{
+ IType type = Utils.findType(project, rootClass.getClassName());
+ //TODO not direct interfaces?
+ String[] interfaces = type.getSuperInterfaceNames();
+ for (String interfaze : interfaces) {
+ String[][] fullInterfaces = type.resolveType(interfaze);
+ for (String[] fullInterface : fullInterfaces) {
+ String inrefaceName = fullInterface[0] + '.' + fullInterface[1];
+ if (persistentClasses.get(inrefaceName) != null){
+ return persistentClasses.get(inrefaceName);
+ }
+ }
+ }
+ return null;
+ }
+
+}
+
+class ProcessEntityInfo extends ASTVisitor {
+
+ private Map<String, RootClass> rootClasses = new HashMap<String, RootClass>();
+
+ /**
+ * current rootClass
+ */
+ private RootClass rootClass;
+
+ /**
+ * information about entity
+ */
+ protected EntityInfo entityInfo;
+
+ TypeVisitor typeVisitor;
+
+ /**
+ * information about all entities
+ */
+ protected Map<String, EntityInfo> entities;
+
+ public void setEntities(Map<String, EntityInfo> entities) {
+ this.entities = entities;
+ rootClasses.clear();
+ Iterator<Map.Entry<String, EntityInfo>> it = entities.entrySet().iterator();
+ while (it.hasNext()) {
+ Map.Entry<String, EntityInfo> entry = it.next();
+ EntityInfo entryInfo = entry.getValue();
+ String className = entryInfo.getName();
+ Table table = new Table(className.toUpperCase());
+ RootClass rootClass = new RootClass();
+ rootClass.setEntityName( className );
+ rootClass.setClassName( entryInfo.getFullyQualifiedName() );
+ rootClass.setProxyInterfaceName( className );
+ rootClass.setLazy(true);
+ rootClass.setTable(table);
+ rootClass.setAbstract(entryInfo.isAbstractFlag());//abstract or interface
+ rootClasses.put(entry.getKey(), rootClass);
+ }
+ typeVisitor = new TypeVisitor(rootClasses);
+ }
+
+
+ public void setEntityInfo(EntityInfo entityInfo) {
+ this.entityInfo = entityInfo;
+ rootClass = rootClasses.get(entityInfo.getFullyQualifiedName());
+ }
+
+ @Override
+ public boolean visit(CompilationUnit node) {
+ Assert.isNotNull(rootClass);
+ return true;
+ }
+
+ public boolean visit(FieldDeclaration node) {
+ Type type = node.getType();
+ if (type == null) {
+ return true;
+ }
+
+ String primaryIdName = entityInfo.getPrimaryIdName();
+ Iterator itVarNames = node.fragments().iterator();
+ while (itVarNames.hasNext()) {
+ VariableDeclarationFragment var = (VariableDeclarationFragment)itVarNames.next();
+ Property prop = createProperty(var);
+ if (prop == null) {
+ continue;
+ }
+
+ String name = var.getName().getIdentifier();
+ if (name.equals(primaryIdName)) {
+ rootClass.setIdentifierProperty(prop);
+ } else {
+ rootClass.addProperty(prop);
+ }
+ }
+
+ return true;
+ }
+
+ @Override
+ public boolean visit(MethodDeclaration node) {
+ if (!entityInfo.isInterfaceFlag()) return super.visit(node);
+ org.eclipse.jdt.core.dom.TypeDeclaration type = (org.eclipse.jdt.core.dom.TypeDeclaration) node.getParent();
+ //TODO check Abstract methods
+ if (type.isInterface()){
+ String varName = Utils.getFieldNameByGetter(node);
+ if (varName != null){
+ String primaryIdName = entityInfo.getPrimaryIdName();
+ Type methodType = node.getReturnType2();
+ if (varName.toLowerCase().equals(primaryIdName.toLowerCase()))
+ varName = primaryIdName;
+ Property prop = createProperty(varName, methodType);
+ if (varName.equals(primaryIdName)) {
+ rootClass.setIdentifierProperty(prop);
+ } else {
+ rootClass.addProperty(prop);
+ }
+ //System.out.println("From method->" + varName);
+ }
+ }
+ return super.visit(node);
+ }
+
+
+ /**
+ * @return the rootClass
+ */
+ public PersistentClass getPersistentClass() {
+ return rootClass;
+ }
+
+ protected Property createProperty(VariableDeclarationFragment var) {
+ return createProperty(var.getName().getIdentifier(), ((FieldDeclaration)var.getParent()).getType());
+ }
+
+ protected Property createProperty(String varName, Type varType) {
+ typeVisitor.init(varName, entityInfo);
+ varType.accept(typeVisitor);
+ Property p = typeVisitor.getProperty();
+ return p;
+ }
+
+ /**
+ * @return the rootClasses
+ */
+ public Map<String, RootClass> getRootClasses() {
+ return rootClasses;
+ }
+
+}
+
+class TypeVisitor extends ASTVisitor{
+
+ private String varName;
+
+ private Map<String, RootClass> rootClasses;
+
+ private RootClass rootClass;
+
+ private EntityInfo entityInfo;
+
+ private RefEntityInfo ref;
+
+ private Property prop;
+
+ TypeVisitor(Map<String, RootClass> rootClasses){
+ this.rootClasses = rootClasses;
+ }
+
+ public void init(String varName, EntityInfo entityInfo){
+ this.varName = varName;
+ this.entityInfo = entityInfo;
+ Map<String, RefEntityInfo> refs = entityInfo.getReferences();
+ ref = refs.get(varName);
+ prop = null;
+ rootClass = rootClasses.get(entityInfo.getFullyQualifiedName());
+ }
+
+ @Override
+ public boolean visit(ArrayType type) {
+ Array array = null;
+ Type componentType = type.getComponentType();
+ ITypeBinding tb = componentType.resolveBinding();
+ if (tb.isPrimitive()){
+ array = new PrimitiveArray(rootClass);
+
+ SimpleValue value = buildSimpleValue(tb.getName());
+ value.setTable(rootClass.getTable());
+ array.setElement(value);
+ array.setCollectionTable(rootClass.getTable());//TODO what to set?
+ } else {
+ RootClass associatedClass = rootClasses.get(tb.getBinaryName());
+ array = new Array(rootClass);
+ array.setElementClassName(tb.getBinaryName());
+ array.setCollectionTable(associatedClass.getTable());
+
+ OneToMany oValue = new OneToMany(rootClass);
+ oValue.setAssociatedClass(associatedClass);
+ oValue.setReferencedEntityName(tb.getBinaryName());
+
+ array.setElement(oValue);
+ }
+ if (array == null) return true;
+
+ SimpleValue key = new SimpleValue();
+ if (StringHelper.isNotEmpty(entityInfo.getPrimaryIdName())) {
+ key.addColumn(new Column(entityInfo.getPrimaryIdName().toUpperCase()));
+ }
+ array.setKey(key);
+ array.setFetchMode(FetchMode.SELECT);
+ SimpleValue index = new SimpleValue();
+
+ //add default index
+ //index.addColumn(new Column(varName.toUpperCase()+"_POSITION"));
+
+ array.setIndex(index);
+ buildProperty(array);
+ prop.setCascade("none");//$NON-NLS-1$
+ return false;//do not visit children
+ }
+
+ @Override
+ public boolean visit(ParameterizedType type) {
+ Assert.isNotNull(type, "Type object cannot be null");
+ Assert.isNotNull(entityInfo, "EntityInfo object cannot be null");
+ ITypeBinding tb = type.resolveBinding();
+ Assert.isNotNull(tb, "Type binding not resolved.");
+ rootClass = rootClasses.get(entityInfo.getFullyQualifiedName());
+ Assert.isNotNull(rootClass, "RootClass not found.");
+
+ Value value = null;
+ if (ref != null && rootClasses.get(ref.fullyQualifiedName) != null){
+ RootClass associatedClass = rootClasses.get(ref.fullyQualifiedName);
+ ITypeBinding[] interfaces = Utils.getAllInterfaces(tb);
+ value = buildCollectionValue(interfaces);
+ if (value != null) {
+ org.hibernate.mapping.Collection cValue = (org.hibernate.mapping.Collection)value;
+ OneToMany oValue = new OneToMany(rootClass);
+ oValue.setAssociatedClass(associatedClass);
+ oValue.setReferencedEntityName(ref.fullyQualifiedName);
+ //Set another table
+ cValue.setCollectionTable(associatedClass.getTable());
+
+ cValue.setElement(oValue);
+
+ if (value instanceof List){
+ ((IndexedCollection)cValue).setIndex(new SimpleValue());
+ } else if (value instanceof org.hibernate.mapping.Map){
+ SimpleValue map_key = new SimpleValue();
+ //FIXME: is it possible to map Map<SourceType, String>?
+ //Or only Map<String, SourceType>
+ map_key.setTypeName(tb.getTypeArguments()[0].getBinaryName());
+ ((IndexedCollection)cValue).setIndex(map_key);
+ }
+ }
+ }
+
+ if (value == null) {
+ value = buildSimpleValue(tb.getBinaryName());
+ }
+
+ buildProperty(value);
+ if (!(value instanceof SimpleValue)){
+ prop.setCascade("none");//$NON-NLS-1$
+ }
+ return false;//do not visit children
+ }
+
+ @Override
+ public boolean visit(PrimitiveType type) {
+ buildProperty(buildSimpleValue(type.getPrimitiveTypeCode().toString()));
+ return false;
+ }
+
+ @Override
+ public boolean visit(QualifiedType type) {
+ return super.visit(type);
+ }
+
+ @Override
+ public boolean visit(SimpleType type) {
+ ITypeBinding tb = type.resolveBinding();
+ Assert.isNotNull(tb);
+ ITypeBinding[] interfaces = Utils.getAllInterfaces(tb);
+ Value value = buildCollectionValue(interfaces);
+ if (value != null){
+ SimpleValue element = buildSimpleValue("string");//$NON-NLS-1$
+ ((org.hibernate.mapping.Collection) value).setElement(element);
+ buildProperty(value);
+ if (value instanceof List){
+ ((IndexedCollection)value).setIndex(new SimpleValue());
+ } else if (value instanceof org.hibernate.mapping.Map){
+ SimpleValue map_key = new SimpleValue();
+ //FIXME: how to detect key-type here
+ map_key.setTypeName("String");
+ ((IndexedCollection)value).setIndex(map_key);
+ }
+ prop.setCascade("none");//$NON-NLS-1$
+ } else if (ref != null){
+ ToOne sValue = null;
+ if (ref.refType == RefType.MANY2ONE){
+ sValue = new ManyToOne(rootClass.getTable());
+ } else if (ref.refType == RefType.ONE2ONE){
+ sValue = new OneToOne(rootClass.getTable(), rootClass);
+ } else if (ref.refType == RefType.UNDEF){
+ sValue = new OneToOne(rootClass.getTable(), rootClass);
+ } else {
+ //OneToMany and ManyToMany must be a collection
+ throw new IllegalStateException(ref.refType.toString());
+ }
+
+ Column column = new Column(varName.toUpperCase());
+ sValue.addColumn(column);
+ sValue.setTypeName(tb.getBinaryName());
+ sValue.setFetchMode(FetchMode.SELECT);
+ sValue.setReferencedEntityName(ref.fullyQualifiedName);
+ buildProperty(sValue);
+ prop.setCascade("none");//$NON-NLS-1$
+ } else {
+ value = buildSimpleValue(tb.getBinaryName());
+ buildProperty(value);
+ }
+ return super.visit(type);
+ }
+
+ @Override
+ public boolean visit(WildcardType type) {
+ return super.visit(type);
+ }
+
+ public Property getProperty(){
+ return prop;
+ }
+
+ protected void buildProperty(Value value){
+ prop = new Property();
+ prop.setName(varName);
+ prop.setValue(value);
+ }
+
+ private SimpleValue buildSimpleValue(String typeName){
+ SimpleValue sValue = new SimpleValue();
+ sValue.addColumn(new Column(varName.toUpperCase()));
+ sValue.setTypeName(typeName);
+ return sValue;
+ }
+
+ private org.hibernate.mapping.Collection buildCollectionValue(ITypeBinding[] interfaces){
+ org.hibernate.mapping.Collection cValue = null;
+ if (Utils.isImplementInterface(interfaces, "java.util.Set")){//$NON-NLS-1$
+ cValue = new org.hibernate.mapping.Set(rootClass);
+ } else if (Utils.isImplementInterface(interfaces, "java.util.List")){//$NON-NLS-1$
+ cValue = new org.hibernate.mapping.List(rootClass);
+ } else if (Utils.isImplementInterface(interfaces, "java.util.Map")){//$NON-NLS-1$
+ cValue = new org.hibernate.mapping.Map(rootClass);
+ } else if (Utils.isImplementInterface(interfaces, "java.util.Collection")){//$NON-NLS-1$
+ cValue = new org.hibernate.mapping.Bag(rootClass);
+ }
+
+ if (cValue == null) return null;
+
+ //By default set the same table, but for one-to many should change it to associated class's table
+ cValue.setCollectionTable(rootClass.getTable());
+
+ SimpleValue key = new SimpleValue();
+ key.setTypeName("string");//$NON-NLS-1$
+ if (StringHelper.isNotEmpty(entityInfo.getPrimaryIdName())){
+ key.addColumn(new Column(entityInfo.getPrimaryIdName().toUpperCase()));
+ }
+ cValue.setKey(key);
+ cValue.setLazy(true);
+ cValue.setRole(StringHelper.qualify(rootClass.getEntityName(), varName));
+ return cValue;
+ }
+}
Property changes on: trunk/hibernatetools/plugins/org.hibernate.eclipse.jdt.ui/src/org/hibernate/eclipse/jdt/ui/wizards/ConfigurationActor.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Name: svn:keywords
+ Author Id Revision Date
Name: svn:eol-style
+ native
Added: trunk/hibernatetools/plugins/org.hibernate.eclipse.jdt.ui/src/org/hibernate/eclipse/jdt/ui/wizards/NewHibernateMappingFilePage.java
===================================================================
--- trunk/hibernatetools/plugins/org.hibernate.eclipse.jdt.ui/src/org/hibernate/eclipse/jdt/ui/wizards/NewHibernateMappingFilePage.java (rev 0)
+++ trunk/hibernatetools/plugins/org.hibernate.eclipse.jdt.ui/src/org/hibernate/eclipse/jdt/ui/wizards/NewHibernateMappingFilePage.java 2009-05-04 12:08:45 UTC (rev 15000)
@@ -0,0 +1,260 @@
+/*******************************************************************************
+ * Copyright (c) 2007-2009 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
+ *
+ * Contributor:
+ * Red Hat, Inc. - initial API and implementation
+ ******************************************************************************/
+package org.hibernate.eclipse.jdt.ui.wizards;
+
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.Iterator;
+import java.util.List;
+import java.util.Map;
+import java.util.Map.Entry;
+
+import org.eclipse.jdt.core.IJavaProject;
+import org.eclipse.jface.viewers.CellEditor;
+import org.eclipse.jface.viewers.CheckboxCellEditor;
+import org.eclipse.jface.viewers.ICellModifier;
+import org.eclipse.jface.viewers.IStructuredContentProvider;
+import org.eclipse.jface.viewers.ITableLabelProvider;
+import org.eclipse.jface.viewers.LabelProvider;
+import org.eclipse.jface.viewers.TableViewer;
+import org.eclipse.jface.viewers.TextCellEditor;
+import org.eclipse.jface.viewers.Viewer;
+import org.eclipse.jface.wizard.WizardPage;
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.custom.ScrolledComposite;
+import org.eclipse.swt.graphics.Image;
+import org.eclipse.swt.layout.FillLayout;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.swt.widgets.Table;
+import org.eclipse.swt.widgets.TableColumn;
+import org.eclipse.swt.widgets.TableItem;
+import org.hibernate.console.ImageConstants;
+import org.hibernate.eclipse.console.HibernateConsoleMessages;
+import org.hibernate.eclipse.console.utils.EclipseImages;
+import org.hibernate.eclipse.jdt.ui.internal.jpa.common.EntityInfo;
+
+/**
+ * @author Dmitry Geraskov
+ *
+ */
+public class NewHibernateMappingFilePage extends WizardPage {
+
+ private TableViewer viewer;
+
+ private Map<IJavaProject, Collection<EntityInfo>> project_infos;
+
+ /**
+ * @param pageName
+ */
+ protected NewHibernateMappingFilePage(Map<IJavaProject, Collection<EntityInfo>> project_infos) {
+ super("");
+ setTitle(HibernateConsoleMessages.NewHibernateMappingFilePage_hibernate_xml_mapping_file);
+ setDescription(HibernateConsoleMessages.NewHibernateMappingFilePage_this_wizard_creates);
+ this.project_infos = project_infos;
+ }
+
+ public void createControl(Composite parent) {
+
+ final ScrolledComposite sc = new ScrolledComposite(parent, SWT.H_SCROLL | SWT.V_SCROLL);
+ sc.setExpandHorizontal(true);
+ sc.setExpandVertical(true);
+ sc.pack(false);
+
+ Composite container = new Composite(sc, SWT.NULL);
+ sc.setContent(container);
+
+ FillLayout layout = new FillLayout();
+ container.setLayout(layout);
+
+ Table table = new Table(container, SWT.SINGLE | SWT.BORDER | SWT.H_SCROLL | SWT.V_SCROLL | SWT.FULL_SELECTION );
+ table.setHeaderVisible(true);
+ table.setLinesVisible(true);
+ table.pack(false);
+ createTableColumns(table);
+ viewer = createTableFilterViewer(table);
+ viewer.setInput(project_infos);
+
+ sc.setMinSize(container.computeSize(SWT.DEFAULT, SWT.DEFAULT));
+ setControl(sc);
+ }
+
+ private void createTableColumns(Table table){
+ int coulmnIndex = 0;
+ TableColumn column = new TableColumn(table, SWT.CENTER, coulmnIndex++);
+ column.setText("!");
+ column.setWidth(20);
+ column.setResizable(false);
+
+ if (project_infos.keySet().size() > 1){
+ column = new TableColumn(table, SWT.LEFT, coulmnIndex++);
+ column.setText("Project name");
+ column.setWidth(120);
+ }
+
+ column = new TableColumn(table, SWT.LEFT, coulmnIndex++);
+ column.setText("Class name");
+ column.setWidth(150);
+
+ column = new TableColumn(table, SWT.LEFT, coulmnIndex++);
+ column.setText("File name");
+ column.setWidth(150);
+ }
+
+ private TableViewer createTableFilterViewer(Table table) {
+ TableViewer result = new TableViewer( table );
+ result.setUseHashlookup( true );
+ if (project_infos.keySet().size() > 1){
+ result.setColumnProperties( new String[] {"create", "project", //$NON-NLS-1$//$NON-NLS-2$
+ "class", "file",} ); //$NON-NLS-1$ //$NON-NLS-2$
+ } else {
+ result.setColumnProperties( new String[] {"create", //$NON-NLS-1$
+ "class", "file",} ); //$NON-NLS-1$ //$NON-NLS-2$
+ }
+
+
+ CellEditor[] editors = new CellEditor[result.getColumnProperties().length];
+ editors[0] = new CheckboxCellEditor( result.getTable() );
+ editors[1] = new TextCellEditor( result.getTable() );
+ editors[2] = new TextCellEditor( result.getTable() );
+ if (project_infos.keySet().size() > 1){
+ editors[3] = new TextCellEditor( result.getTable() );
+ }
+
+ result.setCellEditors( editors );
+ result.setCellModifier( new TableCellModifier(result) );
+ result.setLabelProvider(new TableLableProvider(result));
+ result.setContentProvider( new TableContentProvider() );
+ return result;
+ }
+
+ private class TableLine {
+
+ public String projectName;
+
+ public String className;
+
+ public String fileName;
+
+ public Boolean isCreate = true;
+
+ public TableLine(String projectName, String className){
+ this(projectName, className, className + ".hbm.xml",true);
+ }
+
+ public TableLine(String projectName, String className, String fileName, boolean isCreate){
+ this.projectName = projectName;
+ this.className = className;
+ this.fileName = fileName;
+ this.isCreate = isCreate;
+ }
+
+ }
+
+ private class TableContentProvider implements IStructuredContentProvider {
+
+ public Object[] getElements(Object inputElement) {
+ if (inputElement instanceof Map) {
+ List<TableLine> result = new ArrayList<TableLine>();
+ Map<IJavaProject, Collection<EntityInfo>> configs = (Map<IJavaProject, Collection<EntityInfo>>)inputElement;
+ for (Entry<IJavaProject, Collection<EntityInfo>> entry : configs.entrySet()) {
+ Iterator<EntityInfo> iter = entry.getValue().iterator();
+ while (iter.hasNext()) {
+ EntityInfo ei = iter.next();
+ result.add(new TableLine(entry.getKey().getProject().getName(), ei.getName()));
+ }
+ }
+ return result.toArray();
+ }
+ return new Object[0];
+ }
+
+ public void dispose() { }
+
+ public void inputChanged(Viewer viewer, Object oldInput, Object newInput) {
+ // TODO Auto-generated method stub
+
+ }
+
+ }
+
+ private class TableLableProvider extends LabelProvider implements ITableLabelProvider {
+
+ private final TableViewer tv;
+
+ public TableLableProvider(TableViewer tv) {
+ this.tv = tv;
+ }
+
+ public Image getColumnImage(Object element, int columnIndex) {
+ String property = (String) tv.getColumnProperties()[columnIndex];
+ if("create".equals(property)) {
+ TableLine tl = (TableLine) element;
+ String key = tl.isCreate ? null : ImageConstants.CLOSE ; // TODO: find a better image
+ return EclipseImages.getImage(key);
+ }
+ return null;
+ }
+
+ public String getColumnText(Object element, int columnIndex) {
+ String property = (String) tv.getColumnProperties()[columnIndex];
+ TableLine tl = (TableLine) element;
+
+ if ("class".equals(property)){
+ return tl.className;
+ } else if ("project".equals(property)){
+ return tl.projectName;
+ } else if ("file".equals(property)){
+ return tl.fileName;
+ } else return "";
+ }
+ }
+
+ private class TableCellModifier implements ICellModifier {
+
+ private final TableViewer tv;
+
+ public TableCellModifier(TableViewer tv) {
+ this.tv = tv;
+ }
+
+ public boolean canModify(Object element, String property) {
+ return false/*TODO "file".equals(property) || "create".equals(property)*/;
+ }
+
+ public Object getValue(Object element, String property) {
+ if ("class".equals(property)){
+ return ((TableLine)element).className;
+ } else if ("project".equals(property)){
+ return ((TableLine)element).projectName;
+ } else if ("file".equals(property)){
+ return ((TableLine)element).fileName;
+ } else if ("create".equals(property)){
+ return ((TableLine)element).isCreate;
+ }
+ return null;
+ }
+
+ public void modify(Object element, String property, Object value) {
+ TableLine tl = (TableLine)((TableItem)element).getData();
+ if ("class".equals(property)){
+ tl.className = (String)value;
+ } else if ("project".equals(property)){
+ tl.projectName = (String)value;
+ } else if ("file".equals(property)){
+ tl.fileName = (String)value;
+ } else if ("create".equals(property)){
+ tl.isCreate = (Boolean)value;
+ }
+
+ tv.update(new Object[] { tl }, new String[] { property });
+ }
+ }
+}
Property changes on: trunk/hibernatetools/plugins/org.hibernate.eclipse.jdt.ui/src/org/hibernate/eclipse/jdt/ui/wizards/NewHibernateMappingFilePage.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Name: svn:keywords
+ Author Id Revision Date
Name: svn:eol-style
+ native
Added: trunk/hibernatetools/plugins/org.hibernate.eclipse.jdt.ui/src/org/hibernate/eclipse/jdt/ui/wizards/NewHibernateMappingFileWizard.java
===================================================================
--- trunk/hibernatetools/plugins/org.hibernate.eclipse.jdt.ui/src/org/hibernate/eclipse/jdt/ui/wizards/NewHibernateMappingFileWizard.java (rev 0)
+++ trunk/hibernatetools/plugins/org.hibernate.eclipse.jdt.ui/src/org/hibernate/eclipse/jdt/ui/wizards/NewHibernateMappingFileWizard.java 2009-05-04 12:08:45 UTC (rev 15000)
@@ -0,0 +1,302 @@
+/*******************************************************************************
+ * Copyright (c) 2007-2009 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
+ *
+ * Contributor:
+ * Red Hat, Inc. - initial API and implementation
+ ******************************************************************************/
+package org.hibernate.eclipse.jdt.ui.wizards;
+
+import java.lang.reflect.Field;
+import java.util.Collection;
+import java.util.HashMap;
+import java.util.HashSet;
+import java.util.Iterator;
+import java.util.Map;
+import java.util.Set;
+import java.util.Map.Entry;
+
+import org.eclipse.core.internal.filebuffers.SynchronizableDocument;
+import org.eclipse.core.internal.resources.File;
+import org.eclipse.core.resources.IResource;
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.jdt.core.ICompilationUnit;
+import org.eclipse.jdt.core.IJavaElement;
+import org.eclipse.jdt.core.IJavaProject;
+import org.eclipse.jdt.core.IPackageFragmentRoot;
+import org.eclipse.jdt.core.JavaCore;
+import org.eclipse.jdt.core.JavaModelException;
+import org.eclipse.jdt.core.dom.AST;
+import org.eclipse.jdt.core.dom.ASTParser;
+import org.eclipse.jdt.core.dom.AbstractTypeDeclaration;
+import org.eclipse.jdt.core.dom.TypeDeclaration;
+import org.eclipse.jdt.internal.core.JavaElement;
+import org.eclipse.jdt.internal.core.JavaElementInfo;
+import org.eclipse.jdt.internal.core.JavaProject;
+import org.eclipse.jdt.internal.core.PackageFragment;
+import org.eclipse.jdt.internal.core.PackageFragmentRoot;
+import org.eclipse.jface.text.IDocument;
+import org.eclipse.jface.text.TextSelection;
+import org.eclipse.jface.viewers.ISelection;
+import org.eclipse.jface.viewers.IStructuredSelection;
+import org.eclipse.jface.viewers.TreeSelection;
+import org.eclipse.jface.wizard.Wizard;
+import org.eclipse.ui.INewWizard;
+import org.eclipse.ui.IWorkbench;
+import org.hibernate.cfg.Configuration;
+import org.hibernate.console.ImageConstants;
+import org.hibernate.eclipse.console.HibernateConsolePlugin;
+import org.hibernate.eclipse.console.utils.EclipseImages;
+import org.hibernate.eclipse.jdt.ui.internal.jpa.collect.AllEntitiesInfoCollector;
+import org.hibernate.eclipse.jdt.ui.internal.jpa.common.EntityInfo;
+import org.hibernate.eclipse.jdt.ui.internal.jpa.common.Utils;
+import org.hibernate.tool.hbm2x.HibernateMappingExporter;
+import org.hibernate.tool.hbm2x.HibernateMappingGlobalSettings;
+
+/**
+ * @author Dmitry Geraskov
+ *
+ */
+public class NewHibernateMappingFileWizard extends Wizard implements INewWizard {
+
+ /**
+ * Selected compilation units for startup processing,
+ * result of processing selection
+ */
+ private Set<ICompilationUnit> selectionCU = new HashSet<ICompilationUnit>();
+
+ private Map<IJavaProject, Collection<EntityInfo>> project_infos = new HashMap<IJavaProject, Collection<EntityInfo>>();
+
+
+ public NewHibernateMappingFileWizard(){
+ setDefaultPageImageDescriptor(EclipseImages.getImageDescriptor(ImageConstants.NEW_WIZARD) );
+ }
+
+ @Override
+ public void addPages() {
+ super.addPages();
+ addPage(new NewHibernateMappingFilePage(project_infos));
+ }
+
+ public void init(IWorkbench workbench, IStructuredSelection selection) {
+ updateSelectedItems(selection);
+ initEntitiesInfo();
+ }
+
+ @Override
+ public boolean performFinish() {
+ Map<IJavaProject, Configuration> configs = createConfigurations();
+ for (Entry<IJavaProject, Configuration> entry : configs.entrySet()) {
+ Configuration config = entry.getValue();
+ HibernateMappingGlobalSettings hmgs = new HibernateMappingGlobalSettings();
+
+ IResource container;
+ try {
+ container = entry.getKey().getPackageFragmentRoots().length > 0
+ ? entry.getKey().getPackageFragmentRoots()[0].getResource()
+ : entry.getKey().getResource();
+
+ HibernateMappingExporter hce = new HibernateMappingExporter(config,
+ container.getLocation().toFile());
+
+ hce.setGlobalSettings(hmgs);
+ //hce.setForEach("entity");
+ //hce.setFilePattern(file.getName());
+ try {
+ hce.start();
+ } catch (Exception e){
+ e.getCause().printStackTrace();
+ }
+ container.refreshLocal(IResource.DEPTH_INFINITE, null);
+ } catch (JavaModelException e1) {
+ HibernateConsolePlugin.getDefault().log(e1);
+ } catch (CoreException e) {
+ HibernateConsolePlugin.getDefault().log(e);
+ }
+ }
+ return true;
+ }
+
+ protected void initEntitiesInfo(){
+ if (selectionCU.size() == 0) return;
+ AllEntitiesInfoCollector collector = new AllEntitiesInfoCollector();
+ Iterator<ICompilationUnit> it = selectionCU.iterator();
+
+ Map<IJavaProject, Set<ICompilationUnit>> mapJP_CUSet =
+ new HashMap<IJavaProject, Set<ICompilationUnit>>();
+ //separate by parent project
+ while (it.hasNext()) {
+ ICompilationUnit cu = it.next();
+ Set<ICompilationUnit> set = mapJP_CUSet.get(cu.getJavaProject());
+ if (set == null) {
+ set = new HashSet<ICompilationUnit>();
+ mapJP_CUSet.put(cu.getJavaProject(), set);
+ }
+ set.add(cu);
+ }
+ Iterator<Map.Entry<IJavaProject, Set<ICompilationUnit>>>
+ mapIt = mapJP_CUSet.entrySet().iterator();
+ while (mapIt.hasNext()) {
+ Map.Entry<IJavaProject, Set<ICompilationUnit>>
+ entry = mapIt.next();
+ IJavaProject javaProject = entry.getKey();
+ Iterator<ICompilationUnit> setIt = entry.getValue().iterator();
+ collector.initCollector(javaProject);
+ while (setIt.hasNext()) {
+ ICompilationUnit icu = setIt.next();
+ collector.collect(icu);
+ }
+ collector.resolveRelations();
+ //I don't check here if any non abstract class selected
+ project_infos.put(javaProject, collector.getMapCUs_Info().values());
+
+ }
+ }
+
+ private Map<IJavaProject, Configuration> createConfigurations() {
+ ConfigurationActor actor = new ConfigurationActor(selectionCU);
+ Map<IJavaProject, Configuration> configs = actor.createConfigurations();
+ return configs;
+ }
+
+ protected void updateSelectedItems(ISelection sel) {
+ if (sel instanceof TextSelection) {
+ String fullyQualifiedName = ""; //$NON-NLS-1$
+ IDocument fDocument = null;
+ SynchronizableDocument sDocument = null;
+ org.eclipse.jdt.core.dom.CompilationUnit resultCU = null;
+ Class clazz = sel.getClass();
+ Field fd = null;
+ try {
+ fd = clazz.getDeclaredField("fDocument"); //$NON-NLS-1$
+ } catch (NoSuchFieldException e) {
+ // just ignore it!
+ }
+ if (fd != null) {
+ try {
+ fd.setAccessible(true);
+ fDocument = (IDocument)fd.get(sel);
+ if (fDocument instanceof SynchronizableDocument) {
+ sDocument = (SynchronizableDocument)fDocument;
+ }
+ if (sDocument != null) {
+ ASTParser parser = ASTParser.newParser(AST.JLS3);
+ parser.setSource(sDocument.get().toCharArray());
+ parser.setResolveBindings(false);
+ resultCU = (org.eclipse.jdt.core.dom.CompilationUnit) parser.createAST(null);
+ }
+ if (resultCU != null && resultCU.types().size() > 0 ) {
+ if (resultCU.getPackage() != null) {
+ fullyQualifiedName = resultCU.getPackage().getName().getFullyQualifiedName() + "."; //$NON-NLS-1$
+ }
+ else {
+ fullyQualifiedName = ""; //$NON-NLS-1$
+ }
+ Object tmp = resultCU.types().get(0);
+ if (tmp instanceof AbstractTypeDeclaration) {
+ fullyQualifiedName += ((AbstractTypeDeclaration)tmp).getName();
+ }
+ if (!(tmp instanceof TypeDeclaration)) {
+ // ignore EnumDeclaration & AnnotationTypeDeclaration
+ fullyQualifiedName = ""; //$NON-NLS-1$
+ }
+ }
+ } catch (IllegalArgumentException e) {
+ HibernateConsolePlugin.getDefault().logErrorMessage("IllegalArgumentException: ", e); //$NON-NLS-1$
+ } catch (IllegalAccessException e) {
+ HibernateConsolePlugin.getDefault().logErrorMessage("IllegalAccessException: ", e); //$NON-NLS-1$
+ } catch (SecurityException e) {
+ HibernateConsolePlugin.getDefault().logErrorMessage("SecurityException: ", e); //$NON-NLS-1$
+ }
+ }
+ if (fullyQualifiedName.length() > 0) {
+ ICompilationUnit cu = Utils.findCompilationUnit(fullyQualifiedName);
+ selectionCU.add(cu);
+ }
+ }
+ else if (sel instanceof TreeSelection) {
+ TreeSelection treeSelection = (TreeSelection)sel;
+ Iterator it = treeSelection.iterator();
+ while (it.hasNext()) {
+ Object obj = it.next();
+ processJavaElements(obj);
+ }
+ }
+ }
+
+ protected void processJavaElements(Object obj) {
+ if (obj instanceof ICompilationUnit) {
+ ICompilationUnit cu = (ICompilationUnit)obj;
+ selectionCU.add(cu);
+ }
+ else if (obj instanceof File) {
+ File file = (File)obj;
+ if (file != null && file.getProject() != null) {
+ IJavaProject javaProject = JavaCore.create(file.getProject());
+ ICompilationUnit[] cus = Utils.findCompilationUnits(javaProject,
+ file.getFullPath());
+ if (cus != null) {
+ for (int i = 0; i < cus.length; i++) {
+ selectionCU.add(cus[i]);
+ }
+ }
+ }
+ }
+ else if (obj instanceof JavaProject) {
+ JavaProject javaProject = (JavaProject)obj;
+ IPackageFragmentRoot[] pfr = null;
+ try {
+ pfr = javaProject.getAllPackageFragmentRoots();
+ } catch (JavaModelException e) {
+ // just ignore it!
+ //HibernateConsolePlugin.getDefault().logErrorMessage("JavaModelException: ", e); //$NON-NLS-1$
+ }
+ if (pfr != null) {
+ for (int i = 0; i < pfr.length; i++) {
+ processJavaElements(pfr[i]);
+ }
+ }
+ }
+ else if (obj instanceof PackageFragment) {
+ PackageFragment packageFragment = (PackageFragment)obj;
+ ICompilationUnit[] cus = null;
+ try {
+ cus = packageFragment.getCompilationUnits();
+ } catch (JavaModelException e) {
+ // just ignore it!
+ //HibernateConsolePlugin.getDefault().logErrorMessage("JavaModelException: ", e); //$NON-NLS-1$
+ }
+ if (cus != null) {
+ for (int i = 0; i < cus.length; i++) {
+ selectionCU.add(cus[i]);
+ }
+ }
+ }
+ else if (obj instanceof PackageFragmentRoot) {
+ PackageFragmentRoot packageFragmentRoot = (PackageFragmentRoot)obj;
+ JavaElement javaElement = (JavaElement)obj;
+ JavaElementInfo javaElementInfo = null;
+ try {
+ javaElementInfo = (JavaElementInfo)javaElement.getElementInfo();
+ } catch (JavaModelException e) {
+ // just ignore it!
+ //HibernateConsolePlugin.getDefault().logErrorMessage("JavaModelException: ", e); //$NON-NLS-1$
+ }
+ if (javaElementInfo != null) {
+ IJavaElement[] je = javaElementInfo.getChildren();
+ for (int i = 0; i < je.length; i++) {
+ processJavaElements(je[i]);
+ }
+ }
+ }
+ else if (obj instanceof JavaElement) {
+ JavaElement javaElement = (JavaElement)obj;
+ ICompilationUnit cu = javaElement.getCompilationUnit();
+ selectionCU.add(cu);
+ }
+ }
+
+}
Property changes on: trunk/hibernatetools/plugins/org.hibernate.eclipse.jdt.ui/src/org/hibernate/eclipse/jdt/ui/wizards/NewHibernateMappingFileWizard.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Name: svn:keywords
+ Author Id Revision Date
Name: svn:eol-style
+ native
Modified: trunk/hibernatetools/tests/org.hibernate.eclipse.console.test/src/org/hibernate/eclipse/console/test/mappingproject/Customization.java
===================================================================
--- trunk/hibernatetools/tests/org.hibernate.eclipse.console.test/src/org/hibernate/eclipse/console/test/mappingproject/Customization.java 2009-05-04 10:06:51 UTC (rev 14999)
+++ trunk/hibernatetools/tests/org.hibernate.eclipse.console.test/src/org/hibernate/eclipse/console/test/mappingproject/Customization.java 2009-05-04 12:08:45 UTC (rev 15000)
@@ -25,7 +25,8 @@
/**
* packages name pattern
*/
- public static final String TEST_PACKS_PATTERN = ".*\\.bidi"; //$NON-NLS-1$
+ public static final String TEST_PACKS_PATTERN =
+ "mapping\\.((idclass))"; //$NON-NLS-1$
/**
* is stop after missing package or run further
Added: trunk/hibernatetools/tests/org.hibernate.eclipse.console.test/src/org/hibernate/eclipse/console/test/mappingproject/HbmExportExceptionTest.java
===================================================================
--- trunk/hibernatetools/tests/org.hibernate.eclipse.console.test/src/org/hibernate/eclipse/console/test/mappingproject/HbmExportExceptionTest.java (rev 0)
+++ trunk/hibernatetools/tests/org.hibernate.eclipse.console.test/src/org/hibernate/eclipse/console/test/mappingproject/HbmExportExceptionTest.java 2009-05-04 12:08:45 UTC (rev 15000)
@@ -0,0 +1,197 @@
+/*******************************************************************************
+ * Copyright (c) 2007-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
+ *
+ * Contributor:
+ * Red Hat, Inc. - initial API and implementation
+ ******************************************************************************/
+package org.hibernate.eclipse.console.test.mappingproject;
+
+import java.io.File;
+import java.io.OutputStreamWriter;
+import java.io.PrintWriter;
+
+import junit.framework.TestCase;
+
+import org.eclipse.core.resources.IFile;
+import org.eclipse.core.resources.IResource;
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.core.runtime.jobs.Job;
+import org.eclipse.jdt.core.IPackageFragment;
+import org.eclipse.jdt.core.IPackageFragmentRoot;
+import org.eclipse.jdt.core.JavaModelException;
+import org.eclipse.jdt.internal.core.PackageFragmentRoot;
+import org.eclipse.osgi.util.NLS;
+import org.eclipse.swt.widgets.Display;
+import org.hibernate.cfg.Configuration;
+import org.hibernate.console.ConsoleConfiguration;
+import org.hibernate.console.KnownConfigurations;
+import org.hibernate.console.execution.ExecutionContext;
+import org.hibernate.eclipse.console.test.ConsoleTestMessages;
+import org.hibernate.tool.hbm2x.ArtifactCollector;
+import org.hibernate.tool.hbm2x.ExporterException;
+import org.hibernate.tool.hbm2x.HibernateMappingExporter;
+import org.hibernate.tool.hbm2x.HibernateMappingGlobalSettings;
+
+/**
+ * @author Dmitry Geraskov
+ *
+ */
+public class HbmExportExceptionTest extends TestCase {
+
+ public void testHbmExportExceptionTest() throws Exception {
+ IPackageFragment pack = HibernateAllMappingTests.getActivePackage();
+ try{
+ KnownConfigurations knownConfigurations = KnownConfigurations.getInstance();
+ final ConsoleConfiguration consCFG = knownConfigurations.find(ProjectUtil.ConsoleCFGName);
+ assertNotNull(consCFG);
+ consCFG.reset();
+ consCFG.build();
+ assertTrue(consCFG.hasConfiguration());
+ consCFG.execute( new ExecutionContext.Command() {
+
+ public Object execute() {
+ if(consCFG.hasConfiguration()) {
+ consCFG.getConfiguration().buildMappings();
+ }
+ return consCFG;
+ }
+ } );
+ Configuration config = consCFG.getConfiguration();
+
+ //delete old hbm files
+ assertNotNull( pack );
+ if (pack.getNonJavaResources().length > 0){
+ Object[] ress = pack.getNonJavaResources();
+ for (int i = 0; i < ress.length; i++) {
+ if (ress[i] instanceof IFile){
+ IFile res = (IFile)ress[i];
+ if (res.getName().endsWith(".hbm.xml")){ //$NON-NLS-1$
+ res.delete(true, false, null);
+ }
+ }
+ }
+ }
+
+ HibernateMappingGlobalSettings hmgs = new HibernateMappingGlobalSettings();
+
+
+ HibernateMappingExporter hce = new HibernateMappingExporter(config,
+ getSrcFolder());
+
+ hce.setGlobalSettings(hmgs);
+ try {
+ hce.start();
+ ArtifactCollector collector = hce.getArtifactCollector();
+ collector.formatFiles();
+
+ try {//build generated configuration
+ pack.getResource().refreshLocal(IResource.DEPTH_ONE, null);
+ waitForJobs();
+ ProjectUtil.customizeCFGFileForPack(pack);
+ assertNotNull(consCFG);
+ consCFG.reset();
+
+ consCFG.build();
+ assertTrue(consCFG.hasConfiguration());
+ consCFG.execute( new ExecutionContext.Command() {
+
+ public Object execute() {
+ if(consCFG.hasConfiguration()) {
+ consCFG.getConfiguration().buildMappings();
+ }
+ return consCFG;
+ }
+ } );
+ config = consCFG.getConfiguration();
+ } catch (CoreException e) {
+ String out = NLS.bind(ConsoleTestMessages.UpdateConfigurationTest_error_customising_file_for_package,
+ new Object[] { ProjectUtil.CFG_FILE_NAME, pack.getPath(), e.getMessage() } );
+ fail(out);
+ }
+ } catch (ExporterException e){
+ throw (Exception)e.getCause();
+ }
+ } catch (Exception e){
+ String newMessage = "\nPackage " + pack.getElementName() + ":";
+ throw new WripperException(newMessage, e);
+ }
+ }
+
+ private File getSrcFolder() throws JavaModelException{
+ MappingTestProject mapProject = MappingTestProject.getTestProject();
+ PackageFragmentRoot packageFragmentRoot = null;
+ IPackageFragmentRoot[] roots = mapProject.getIJavaProject().getAllPackageFragmentRoots();
+ for (int i = 0; i < roots.length; i++) {
+ if (roots[i].getClass() != PackageFragmentRoot.class) continue;
+ packageFragmentRoot = (PackageFragmentRoot) roots[i];
+ break;
+ }
+ assertNotNull(packageFragmentRoot);
+ return packageFragmentRoot.getResource().getLocation().toFile();
+ }
+
+ public void waitForJobs() {
+ long start = System.currentTimeMillis();
+ // Job.getJobManager().isIdle() is more efficient than EditorTestHelper.allJobsQuiet()
+ // EditorTestHelper.allJobsQuiet() isn't thread-safe
+ // https://bugs.eclipse.org/bugs/show_bug.cgi?id=198241 is fixed
+ //while (!EditorTestHelper.allJobsQuiet()) {
+ while (!Job.getJobManager().isIdle()) {
+ delay(1000);
+ if ( (System.currentTimeMillis()-start) > MAX_IDLE )
+ throw new RuntimeException("A long running task detected"); //$NON-NLS-1$
+ }
+ }
+ private static final long MAX_IDLE = 30*60*1000L;
+
+ protected void delay(long waitTimeMillis) {
+ if (waitTimeMillis <= 0) return;
+ Display display = Display.getCurrent();
+
+ // If this is the UI thread,
+ // then process input.
+ if (display != null) {
+ long endTimeMillis = System.currentTimeMillis() + waitTimeMillis;
+ while (System.currentTimeMillis() < endTimeMillis) {
+ if (!display.readAndDispatch())
+ display.sleep();
+ }
+ display.update();
+ }
+
+ // Otherwise, perform a simple sleep.
+ else {
+ try {
+ Thread.sleep(waitTimeMillis);
+ } catch (InterruptedException e) {
+ // Ignored.
+ }
+ }
+ }
+}
+
+class WripperException extends Exception {
+
+ private String message;
+
+ public WripperException(String message, Exception cause){
+ super(cause);
+ this.message = message;
+ setStackTrace(cause.getStackTrace());
+ }
+
+ @Override
+ public Throwable getCause() {
+ return null;
+ }
+
+ @Override
+ public void printStackTrace(PrintWriter s) {
+ s.println(message);
+ super.getCause().printStackTrace(s);
+ }
+}
Property changes on: trunk/hibernatetools/tests/org.hibernate.eclipse.console.test/src/org/hibernate/eclipse/console/test/mappingproject/HbmExportExceptionTest.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Name: svn:keywords
+ Author Id Revision Date
Name: svn:eol-style
+ native
Modified: trunk/hibernatetools/tests/org.hibernate.eclipse.console.test/src/org/hibernate/eclipse/console/test/mappingproject/TestSet.java
===================================================================
--- trunk/hibernatetools/tests/org.hibernate.eclipse.console.test/src/org/hibernate/eclipse/console/test/mappingproject/TestSet.java 2009-05-04 10:06:51 UTC (rev 14999)
+++ trunk/hibernatetools/tests/org.hibernate.eclipse.console.test/src/org/hibernate/eclipse/console/test/mappingproject/TestSet.java 2009-05-04 12:08:45 UTC (rev 15000)
@@ -40,9 +40,10 @@
}
private static void addPackTests(TestSuite suite){
- suite.addTestSuite( OpenSourceFileTest.class );
+ /*suite.addTestSuite( OpenSourceFileTest.class );
suite.addTestSuite( OpenMappingFileTest.class );
- suite.addTestSuite( OpenMappingDiagramTest.class );
+ suite.addTestSuite( OpenMappingDiagramTest.class );*/
+ suite.addTestSuite( HbmExportExceptionTest.class );
}
private static void addTestsPackTearDown(TestSuite suite){
Added: trunk/hibernatetools/tests/org.hibernate.eclipse.jdt.ui.test/res/hbm/pack/A.java
===================================================================
--- trunk/hibernatetools/tests/org.hibernate.eclipse.jdt.ui.test/res/hbm/pack/A.java (rev 0)
+++ trunk/hibernatetools/tests/org.hibernate.eclipse.jdt.ui.test/res/hbm/pack/A.java 2009-05-04 12:08:45 UTC (rev 15000)
@@ -0,0 +1,66 @@
+package pack;
+
+import java.util.List;
+import java.util.Map;
+import java.util.Set;
+
+/**
+ * @author Emmanuel Bernard
+ */
+public class A {
+ private Integer id;
+ private B prop;
+ private B[] bs;
+ private List<B> list;
+ private Set<B> set;
+
+ private Map<String, B> mapValue;
+
+ public Integer getId() {
+ return id;
+ }
+
+ public void setId(Integer id) {
+ this.id = id;
+ }
+
+ public B getProp() {
+ return prop;
+ }
+
+ public void setProp(B b) {
+ this.prop = b;
+ }
+
+ public List<B> getList() {
+ return list;
+ }
+
+ public void setList(List<B> list) {
+ this.list = list;
+ }
+
+ public Set<B> getSet() {
+ return set;
+ }
+
+ public void setSet(Set<B> set) {
+ this.set = set;
+ }
+
+ public Map<String, B> getMapValue() {
+ return mapValue;
+ }
+
+ public void setMapValue(Map<String, B> mapValue) {
+ this.mapValue = mapValue;
+ }
+
+ public B[] getBs() {
+ return bs;
+ }
+
+ public void setBs(B[] bs) {
+ this.bs = bs;
+ }
+}
Property changes on: trunk/hibernatetools/tests/org.hibernate.eclipse.jdt.ui.test/res/hbm/pack/A.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Name: svn:keywords
+ Author Id Revision Date
Name: svn:eol-style
+ native
Added: trunk/hibernatetools/tests/org.hibernate.eclipse.jdt.ui.test/res/hbm/pack/B.java
===================================================================
--- trunk/hibernatetools/tests/org.hibernate.eclipse.jdt.ui.test/res/hbm/pack/B.java (rev 0)
+++ trunk/hibernatetools/tests/org.hibernate.eclipse.jdt.ui.test/res/hbm/pack/B.java 2009-05-04 12:08:45 UTC (rev 15000)
@@ -0,0 +1,25 @@
+package pack;
+
+/**
+ * @author Emmanuel Bernard
+ */
+public class B {
+ private Integer id;
+ private int[] testIntArray;
+
+ public int[] getTestIntArray() {
+ return testIntArray;
+ }
+
+ public void setTestIntArray(int[] testIntArray) {
+ this.testIntArray = testIntArray;
+ }
+
+ public Integer getId() {
+ return id;
+ }
+
+ public void setId(Integer id) {
+ this.id = id;
+ }
+}
Property changes on: trunk/hibernatetools/tests/org.hibernate.eclipse.jdt.ui.test/res/hbm/pack/B.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Name: svn:keywords
+ Author Id Revision Date
Name: svn:eol-style
+ native
Added: trunk/hibernatetools/tests/org.hibernate.eclipse.jdt.ui.test/src/org/hibernate/eclipse/jdt/ui/test/hbmexporter/HbmExporterTest.java
===================================================================
--- trunk/hibernatetools/tests/org.hibernate.eclipse.jdt.ui.test/src/org/hibernate/eclipse/jdt/ui/test/hbmexporter/HbmExporterTest.java (rev 0)
+++ trunk/hibernatetools/tests/org.hibernate.eclipse.jdt.ui.test/src/org/hibernate/eclipse/jdt/ui/test/hbmexporter/HbmExporterTest.java 2009-05-04 12:08:45 UTC (rev 15000)
@@ -0,0 +1,260 @@
+package org.hibernate.eclipse.jdt.ui.test.hbmexporter;
+
+import java.io.File;
+import java.io.IOException;
+import java.net.URL;
+import java.util.HashSet;
+import java.util.List;
+import java.util.Map;
+import java.util.Set;
+
+import junit.framework.TestCase;
+
+import org.eclipse.core.resources.IFolder;
+import org.eclipse.core.resources.IProject;
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.core.runtime.FileLocator;
+import org.eclipse.core.runtime.IPath;
+import org.eclipse.core.runtime.Path;
+import org.eclipse.jdt.core.ICompilationUnit;
+import org.eclipse.jdt.core.IJavaProject;
+import org.eclipse.jdt.core.IPackageFragmentRoot;
+import org.eclipse.jdt.core.JavaModelException;
+import org.eclipse.osgi.util.NLS;
+import org.hibernate.cfg.Configuration;
+import org.hibernate.eclipse.console.test.ConsoleTestMessages;
+import org.hibernate.eclipse.console.test.mappingproject.TestUtilsCommon;
+import org.hibernate.eclipse.console.utils.ProjectUtils;
+import org.hibernate.eclipse.jdt.ui.internal.jpa.collect.AllEntitiesInfoCollector;
+import org.hibernate.eclipse.jdt.ui.internal.jpa.common.Utils;
+import org.hibernate.eclipse.jdt.ui.internal.jpa.process.AllEntitiesProcessor;
+import org.hibernate.eclipse.jdt.ui.test.HibernateJDTuiTestPlugin;
+import org.hibernate.eclipse.jdt.ui.wizards.ConfigurationActor;
+import org.hibernate.mapping.Array;
+import org.hibernate.mapping.ManyToOne;
+import org.hibernate.mapping.OneToMany;
+import org.hibernate.mapping.PersistentClass;
+import org.hibernate.mapping.PrimitiveArray;
+import org.hibernate.mapping.Property;
+import org.hibernate.mapping.SimpleValue;
+import org.hibernate.mapping.Value;
+import org.hibernate.type.IntegerType;
+
+public class HbmExporterTest extends TestCase {
+
+ public static final String PROJECT_NAME = "TestProject"; //$NON-NLS-1$
+ public static final String RESOURCE_PATH = "res/hbm/".replaceAll("//", File.separator); //$NON-NLS-1$ //$NON-NLS-2$
+ public static final String TESTRESOURCE_PATH = "testresources"; //$NON-NLS-1$
+
+ protected AllEntitiesInfoCollector collector = new AllEntitiesInfoCollector();
+ protected AllEntitiesProcessor processor = new AllEntitiesProcessor();
+
+ protected IProject project;
+ protected IJavaProject javaProject;
+
+ protected void setUp() throws Exception {
+ try {
+ createTestProject();
+ } catch (JavaModelException e1) {
+ fail(e1.getMessage());
+ } catch (CoreException e1) {
+ fail(e1.getMessage());
+ } catch (IOException e1) {
+ fail(e1.getMessage());
+ }
+ assertNotNull(project);
+ assertNotNull(javaProject);
+ assertNotNull(ProjectUtils.findJavaProject(PROJECT_NAME));
+ try {
+ javaProject.getProject().open(null);
+ } catch (CoreException e) {
+ fail(e.getMessage());
+ }
+ }
+
+ /**
+ * Method returns Configuration object for selected ICompilationUnits.
+ * Fails if configuration is null.
+ * @return
+ */
+ protected Configuration getConfigurationFor(String... cuNames){
+ Set<ICompilationUnit> selectionCU = new HashSet();
+ for (int i = 0; i < cuNames.length; i++) {
+ ICompilationUnit icu = Utils.findCompilationUnit(javaProject,
+ cuNames[i]);
+ assertNotNull(icu);
+ selectionCU.add(icu);
+ }
+ ConfigurationActor actor = new ConfigurationActor(selectionCU);
+ Map<IJavaProject, Configuration> configurations = actor.createConfigurations();
+ assertEquals(1, configurations.size());
+ Configuration config = configurations.get(javaProject);
+ assertNotNull(config);
+ return config;
+ }
+
+ protected void checkClassesMaped(Configuration config, String... classesNames){
+ for (int i = 0; i < classesNames.length; i++) {
+ assertNotNull(config.getClassMapping(classesNames[i]));
+ }
+ }
+
+ public void testId(){
+ Configuration config = getConfigurationFor("pack.A");
+ checkClassesMaped(config, "A", "B");
+ PersistentClass a = config.getClassMapping("A");
+ PersistentClass b = config.getClassMapping("B");
+
+ Property aId= a.getIdentifierProperty();
+ Property bId= b.getIdentifierProperty();
+ assertNotNull(aId);
+ assertNotNull(bId);
+ assertEquals("id", aId.getName());
+ assertEquals("id", bId.getName());
+ }
+
+ public void testProperty(){
+ Configuration config = getConfigurationFor("pack.A");
+ checkClassesMaped(config, "A", "B");
+ PersistentClass a = config.getClassMapping("A");
+
+ Property prop = a.getProperty("prop");
+ Value value = prop.getValue();
+ assertNotNull(value);
+ assertTrue("Expected to get ManyToOne-type mapping", value.getClass()== ManyToOne.class);
+ ManyToOne mto = (ManyToOne)value;
+ assertEquals("pack.B", mto.getTypeName());
+ }
+
+ public void testArray(){
+ Configuration config = getConfigurationFor("pack.A");
+ checkClassesMaped(config, "A", "B");
+ PersistentClass a = config.getClassMapping("A");
+ PersistentClass b = config.getClassMapping("B");
+
+ Property bs = a.getProperty("bs");
+ Value value = bs.getValue();
+ assertNotNull(value);
+ assertTrue("Expected to get Array-type mapping", value.getClass()==Array.class);
+ Array ar = (Array)value;
+ assertEquals("pack.B", ar.getElementClassName());
+ assertTrue("Expected to get one-to-many array's element type",
+ ar.getElement().getClass() == OneToMany.class);
+
+ Property testIntArray = b.getProperty("testIntArray");
+ assertNotNull(testIntArray);
+ value = testIntArray.getValue();
+ assertNotNull(value);
+ assertTrue("Expected to get PrimitiveArray-type mapping",
+ value.getClass()==PrimitiveArray.class);
+ PrimitiveArray pAr = (PrimitiveArray) value;
+ assertNotNull(pAr.getElement());
+ assertTrue("Expected to get int-type primitive array", pAr.getElement().getType().getClass()==IntegerType.class);
+ }
+
+ public void testList(){
+ Configuration config = getConfigurationFor("pack.A");
+ checkClassesMaped(config, "A", "B");
+ PersistentClass a = config.getClassMapping("A");
+ PersistentClass b = config.getClassMapping("B");
+
+ Property listProp = a.getProperty("list");
+ Value value = listProp.getValue();
+ assertNotNull(value);
+ assertTrue("Expected to get List-type mapping",
+ value.getClass()==org.hibernate.mapping.List.class);
+ org.hibernate.mapping.List list = (org.hibernate.mapping.List)value;
+ assertTrue(list.getElement() instanceof OneToMany);
+ assertTrue(list.getCollectionTable().equals(b.getTable()));
+ assertNotNull(list.getIndex());
+ assertNotNull(list.getKey());
+ }
+
+ public void testSet(){
+ Configuration config = getConfigurationFor("pack.A");
+ checkClassesMaped(config, "A", "B");
+ PersistentClass a = config.getClassMapping("A");
+ PersistentClass b = config.getClassMapping("B");
+
+ Property setProp = a.getProperty("set");
+ Value value = setProp.getValue();
+ assertNotNull(value);
+ assertTrue("Expected to get Set-type mapping",
+ value.getClass()==org.hibernate.mapping.Set.class);
+ org.hibernate.mapping.Set set = (org.hibernate.mapping.Set)value;
+ assertTrue(set.getElement() instanceof OneToMany);
+ assertTrue(set.getCollectionTable().equals(b.getTable()));
+ assertNotNull(set.getKey());
+ }
+
+ public void testMap(){
+ Configuration config = getConfigurationFor("pack.A");
+ checkClassesMaped(config, "A", "B");
+ PersistentClass a = config.getClassMapping("A");
+ PersistentClass b = config.getClassMapping("B");
+
+ Property mapValue = a.getProperty("mapValue");
+ Value value = mapValue.getValue();
+ assertNotNull(value);
+ assertTrue("Expected to get Map-type mapping",
+ value.getClass()==org.hibernate.mapping.Map.class);
+ org.hibernate.mapping.Map map = (org.hibernate.mapping.Map)value;
+ assertTrue(map.getElement() instanceof OneToMany);
+ assertTrue(map.getCollectionTable().equals(b.getTable()));
+ assertNotNull(map.getKey());
+ assertEquals("string", map.getKey().getType().getName());
+ }
+
+
+ protected void createTestProject() throws JavaModelException,
+ CoreException, IOException {
+ TestUtilsCommon commonUtil = new TestUtilsCommon();
+ project = commonUtil.buildNewProject(PROJECT_NAME);
+ javaProject = commonUtil.buildJavaProject(project);
+ File resourceFolder = getResourceItem(RESOURCE_PATH);
+ if (!resourceFolder.exists()) {
+ String out = NLS.bind(
+ ConsoleTestMessages.MappingTestProject_folder_not_found,
+ RESOURCE_PATH);
+ throw new RuntimeException(out);
+ }
+ IPackageFragmentRoot sourceFolder = commonUtil.createSourceFolder(
+ project, javaProject);
+ commonUtil.recursiveCopyFiles(resourceFolder, (IFolder) sourceFolder
+ .getResource());
+ File resourceFolderLib = getResourceItem(TESTRESOURCE_PATH);
+ if (!resourceFolderLib.exists()) {
+ String out = NLS.bind(
+ ConsoleTestMessages.MappingTestProject_folder_not_found,
+ RESOURCE_PATH);
+ throw new RuntimeException(out);
+ }
+ List<IPath> libs = commonUtil.copyLibs2(project, javaProject,
+ resourceFolderLib.getAbsolutePath());
+ commonUtil.generateClassPath(javaProject, libs, sourceFolder);
+ }
+
+ protected File getResourceItem(String strResPath) throws IOException {
+ IPath resourcePath = new Path(strResPath);
+ File resourceFolder = resourcePath.toFile();
+ URL entry = HibernateJDTuiTestPlugin.getDefault().getBundle().getEntry(
+ strResPath);
+ URL resProject = FileLocator.resolve(entry);
+ String tplPrjLcStr = FileLocator.resolve(resProject).getFile();
+ resourceFolder = new File(tplPrjLcStr);
+ return resourceFolder;
+ }
+
+ protected void tearDown() throws Exception {
+ try {
+ project.delete(true, true, null);
+ project = null;
+ javaProject = null;
+ } catch (CoreException e) {
+ fail(e.getMessage());
+ }
+ assertNull(project);
+ assertNull(javaProject);
+ }
+
+}
Property changes on: trunk/hibernatetools/tests/org.hibernate.eclipse.jdt.ui.test/src/org/hibernate/eclipse/jdt/ui/test/hbmexporter/HbmExporterTest.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Name: svn:keywords
+ Author Id Revision Date
Name: svn:eol-style
+ native
15 years, 8 months
JBoss Tools SVN: r14999 - in trunk/jbpm/plugins/org.jboss.tools.flow.jpdl4: src/org/jboss/tools/flow/jpdl4/editor and 2 other directories.
by jbosstools-commits@lists.jboss.org
Author: koen.aers(a)jboss.com
Date: 2009-05-04 06:06:51 -0400 (Mon, 04 May 2009)
New Revision: 14999
Added:
trunk/jbpm/plugins/org.jboss.tools.flow.jpdl4/src/org/jboss/tools/flow/jpdl4/model/SubprocessTask.java
trunk/jbpm/plugins/org.jboss.tools.flow.jpdl4/src/org/jboss/tools/flow/jpdl4/properties/SubprocessSection.java
Modified:
trunk/jbpm/plugins/org.jboss.tools.flow.jpdl4/plugin.xml
trunk/jbpm/plugins/org.jboss.tools.flow.jpdl4/src/org/jboss/tools/flow/jpdl4/editor/JpdlDeserializer.java
trunk/jbpm/plugins/org.jboss.tools.flow.jpdl4/src/org/jboss/tools/flow/jpdl4/editor/JpdlPaletteFactory.java
trunk/jbpm/plugins/org.jboss.tools.flow.jpdl4/src/org/jboss/tools/flow/jpdl4/editor/JpdlSerializer.java
trunk/jbpm/plugins/org.jboss.tools.flow.jpdl4/src/org/jboss/tools/flow/jpdl4/properties/JpdlPropertySection.java
Log:
subprocess support
Modified: trunk/jbpm/plugins/org.jboss.tools.flow.jpdl4/plugin.xml
===================================================================
--- trunk/jbpm/plugins/org.jboss.tools.flow.jpdl4/plugin.xml 2009-05-04 08:10:18 UTC (rev 14998)
+++ trunk/jbpm/plugins/org.jboss.tools.flow.jpdl4/plugin.xml 2009-05-04 10:06:51 UTC (rev 14999)
@@ -173,6 +173,16 @@
</node>
</element>
<element
+ class="org.jboss.tools.flow.jpdl4.model.SubprocessTask"
+ figure="icons/16/task_empty.png"
+ id="org.jboss.tools.flow.jpdl4.subprocessTask"
+ label="Subprocess"
+ language="org.jboss.tools.flow.jpdl4">
+ <node>
+ <figure class="org.jboss.tools.flow.jpdl4.figure.TaskFigure"></figure>
+ </node>
+ </element>
+ <element
class="org.jboss.tools.flow.jpdl4.model.ExclusiveGateway"
figure="icons/16/gateway_exclusive.png"
id="org.jboss.tools.flow.jpdl4.exclusiveGateway"
@@ -276,6 +286,11 @@
category="general"
id="org.jboss.tools.jpdl4.assignment"
label="Assignment"/>
+ <propertyTab
+ afterTab="org.jboss.tools.jpdl4.general"
+ category="general"
+ id="org.jboss.tools.jpdl4.subprocess"
+ label="Subprocess"/>
<!-- <propertyTab
afterTab="org.jboss.tools.jpdl4.general"
category="details"
@@ -318,6 +333,12 @@
<input type="org.jboss.tools.flow.jpdl4.model.Timer"/>
</propertySection>
<propertySection
+ class="org.jboss.tools.flow.jpdl4.properties.SubprocessSection"
+ id="org.jboss.tools.jpdl4.subprocess"
+ tab="org.jboss.tools.jpdl4.subprocess">
+ <input type="org.jboss.tools.flow.jpdl4.model.SubprocessTask"/>
+ </propertySection>
+ <propertySection
class="org.jboss.tools.flow.jpdl4.properties.EventTypeSection"
id="org.jboss.tools.jpdl4.eventType"
tab="org.jboss.tools.jpdl4.general">
Modified: trunk/jbpm/plugins/org.jboss.tools.flow.jpdl4/src/org/jboss/tools/flow/jpdl4/editor/JpdlDeserializer.java
===================================================================
--- trunk/jbpm/plugins/org.jboss.tools.flow.jpdl4/src/org/jboss/tools/flow/jpdl4/editor/JpdlDeserializer.java 2009-05-04 08:10:18 UTC (rev 14998)
+++ trunk/jbpm/plugins/org.jboss.tools.flow.jpdl4/src/org/jboss/tools/flow/jpdl4/editor/JpdlDeserializer.java 2009-05-04 10:06:51 UTC (rev 14999)
@@ -23,6 +23,7 @@
import org.jboss.tools.flow.jpdl4.model.EventListener;
import org.jboss.tools.flow.jpdl4.model.EventListenerContainer;
import org.jboss.tools.flow.jpdl4.model.HumanTask;
+import org.jboss.tools.flow.jpdl4.model.SubprocessTask;
import org.jboss.tools.flow.jpdl4.model.Swimlane;
import org.jboss.tools.flow.jpdl4.model.Timer;
import org.w3c.dom.Document;
@@ -126,6 +127,27 @@
}
}
+ class SubprocessTaskAttributeHandler extends NodeAttributeHandler {
+ protected List<String> getAttributesToRead() {
+ List<String> result = super.getAttributesToRead();
+ result.add(SubprocessTask.ID);
+ result.add(SubprocessTask.KEY);
+ result.add(SubprocessTask.OUTCOME);
+ return result;
+ }
+ protected String getXmlName(String attributeName) {
+ if (SubprocessTask.ID.equals(attributeName)) {
+ return "sub-process-id";
+ } else if (SubprocessTask.KEY.equals(attributeName)) {
+ return "sub-process-key";
+ } else if (SubprocessTask.OUTCOME.equals(attributeName)) {
+ return "outcome";
+ } else {
+ return super.getXmlName(attributeName);
+ }
+ }
+ }
+
class EventListenerContainerAttributeHandler extends DefaultAttributeDeserializer {
protected List<String> getAttributesToRead() {
ArrayList<String> result = new ArrayList<String>();
@@ -360,6 +382,8 @@
Object element = wrapper.getElement();
if (element instanceof HumanTask) {
return new HumanTaskAttributeHandler();
+ } else if (element instanceof SubprocessTask) {
+ return new SubprocessTaskAttributeHandler();
} else {
return new NodeAttributeHandler();
}
@@ -396,6 +420,7 @@
else if ("script".equals(nodeName)) return "org.jboss.tools.flow.jpdl4.scriptTask";
else if ("esb".equals(nodeName)) return "org.jboss.tools.flow.jpdl4.serviceTask";
else if ("task".equals(nodeName)) return "org.jboss.tools.flow.jpdl4.humanTask";
+ else if ("sub-process".equals(nodeName)) return "org.jboss.tools.flow.jpdl4.subprocessTask";
else if ("exclusive".equals(nodeName)) return "org.jboss.tools.flow.jpdl4.exclusiveGateway";
else if ("join".equals(nodeName)) return "org.jboss.tools.flow.jpdl4.parallelJoinGateway";
else if ("fork".equals(nodeName)) return "org.jboss.tools.flow.jpdl4.parallelForkGateway";
Modified: trunk/jbpm/plugins/org.jboss.tools.flow.jpdl4/src/org/jboss/tools/flow/jpdl4/editor/JpdlPaletteFactory.java
===================================================================
--- trunk/jbpm/plugins/org.jboss.tools.flow.jpdl4/src/org/jboss/tools/flow/jpdl4/editor/JpdlPaletteFactory.java 2009-05-04 08:10:18 UTC (rev 14998)
+++ trunk/jbpm/plugins/org.jboss.tools.flow.jpdl4/src/org/jboss/tools/flow/jpdl4/editor/JpdlPaletteFactory.java 2009-05-04 10:06:51 UTC (rev 14999)
@@ -169,6 +169,15 @@
ImageDescriptor.createFromURL(Activator.getDefault().getBundle().getEntry("icons/32/task_empty.png"))
);
entries.add(combined);
+ combined = new CombinedTemplateCreationEntry(
+ "subprocess",
+ "Create a new Subprocess",
+ "org.jboss.tools.flow.jpdl4.subprocess",
+ ElementRegistry.getCreationFactory("org.jboss.tools.flow.jpdl4.subprocessTask"),
+ ImageDescriptor.createFromURL(Activator.getDefault().getBundle().getEntry("icons/16/task_empty.png")),
+ ImageDescriptor.createFromURL(Activator.getDefault().getBundle().getEntry("icons/32/task_empty.png"))
+ );
+ entries.add(combined);
return entries;
}
Modified: trunk/jbpm/plugins/org.jboss.tools.flow.jpdl4/src/org/jboss/tools/flow/jpdl4/editor/JpdlSerializer.java
===================================================================
--- trunk/jbpm/plugins/org.jboss.tools.flow.jpdl4/src/org/jboss/tools/flow/jpdl4/editor/JpdlSerializer.java 2009-05-04 08:10:18 UTC (rev 14998)
+++ trunk/jbpm/plugins/org.jboss.tools.flow.jpdl4/src/org/jboss/tools/flow/jpdl4/editor/JpdlSerializer.java 2009-05-04 10:06:51 UTC (rev 14999)
@@ -47,6 +47,7 @@
import org.jboss.tools.flow.jpdl4.model.ServiceTask;
import org.jboss.tools.flow.jpdl4.model.SqlTask;
import org.jboss.tools.flow.jpdl4.model.StartEvent;
+import org.jboss.tools.flow.jpdl4.model.SubprocessTask;
import org.jboss.tools.flow.jpdl4.model.SuperState;
import org.jboss.tools.flow.jpdl4.model.Swimlane;
import org.jboss.tools.flow.jpdl4.model.TerminateEndEvent;
@@ -188,6 +189,7 @@
else if ("org.jboss.tools.flow.jpdl4.scriptTask".equals(elementId)) return "script";
else if ("org.jboss.tools.flow.jpdl4.serviceTask".equals(elementId)) return "esb";
else if ("org.jboss.tools.flow.jpdl4.humanTask".equals(elementId)) return "task";
+ else if ("org.jboss.tools.flow.jpdl4.subprocessTask".equals(elementId)) return "sub-process";
else if ("org.jboss.tools.flow.jpdl4.exclusiveGateway".equals(elementId)) return "exclusive";
else if ("org.jboss.tools.flow.jpdl4.parallelJoinGateway".equals(elementId)) return "join";
else if ("org.jboss.tools.flow.jpdl4.parallelForkGateway".equals(elementId)) return "fork";
@@ -393,6 +395,26 @@
}
}
+ class SubprocessTaskWrapperSerializer extends AbstractWrapperSerializer {
+ protected List<String> getAttributesToSave() {
+ ArrayList<String> result = new ArrayList<String>();
+ result.add("sub-process-id");
+ result.add("sub-process-key");
+ result.add("outcome");
+ return result;
+ }
+ protected String getPropertyName(String attributeName) {
+ if ("sub-process-id".equals(attributeName)) {
+ return SubprocessTask.ID;
+ } else if ("sub-process-key".equals(attributeName)) {
+ return SubprocessTask.KEY;
+ } else if ("outcome".equals(attributeName)) {
+ return SubprocessTask.OUTCOME;
+ }
+ return super.getPropertyName(attributeName);
+ }
+ }
+
class EventListenerContainerWrapperSerializer extends AbstractWrapperSerializer {
protected List<String> getAttributesToSave() {
ArrayList<String> result = new ArrayList<String>();
@@ -487,6 +509,8 @@
new ProcessNodeWrapperSerializer().appendOpening(buffer, wrapper, level);
} else if (element instanceof HumanTask) {
new HumanTaskSerializer().appendOpening(buffer, wrapper, level);
+ } else if (element instanceof SubprocessTask) {
+ new SubprocessTaskWrapperSerializer().appendOpening(buffer, wrapper, level);
} else if (element instanceof ExclusiveGateway) {
new ProcessNodeWrapperSerializer().appendOpening(buffer, wrapper, level);
} else if (element instanceof ForkParallelGateway) {
@@ -601,6 +625,8 @@
buffer.append("</esb>");
} else if (element instanceof HumanTask) {
buffer.append("</task>");
+ } else if (element instanceof HumanTask) {
+ buffer.append("</sub-process>");
} else if (element instanceof ExclusiveGateway) {
buffer.append("</exclusive>");
} else if (element instanceof ForkParallelGateway) {
Added: trunk/jbpm/plugins/org.jboss.tools.flow.jpdl4/src/org/jboss/tools/flow/jpdl4/model/SubprocessTask.java
===================================================================
--- trunk/jbpm/plugins/org.jboss.tools.flow.jpdl4/src/org/jboss/tools/flow/jpdl4/model/SubprocessTask.java (rev 0)
+++ trunk/jbpm/plugins/org.jboss.tools.flow.jpdl4/src/org/jboss/tools/flow/jpdl4/model/SubprocessTask.java 2009-05-04 10:06:51 UTC (rev 14999)
@@ -0,0 +1,121 @@
+package org.jboss.tools.flow.jpdl4.model;
+
+import org.eclipse.ui.views.properties.IPropertyDescriptor;
+import org.eclipse.ui.views.properties.IPropertySource;
+import org.eclipse.ui.views.properties.TextPropertyDescriptor;
+import org.jboss.tools.flow.common.properties.IPropertyId;
+
+
+public class SubprocessTask extends Task {
+
+ public final static String ID = "org.jboss.tools.flow.jpdl4.model.subprocess.id";
+ public final static String KEY = "org.jboss.tools.flow.jpdl4.model.subprocess.key";
+ public final static String OUTCOME = "org.jboss.tools.flow.jpdl4.model.subprocess.outcome";
+
+ private String subprocessId;
+ private String key;
+ private String outcome;
+
+ public SubprocessTask() {
+ setMetaData("propertySource", new PropertySource());
+ }
+
+ public String getSubprocessId() {
+ return subprocessId;
+ }
+
+ public void setSubprocessId(String id) {
+ this.subprocessId = id;
+ }
+
+ public String getKey() {
+ return key;
+ }
+
+ public void setKey(String key) {
+ this.key = key;
+ }
+
+ public String getOutcome() {
+ return outcome;
+ }
+
+ public void setOutcome(String outcome) {
+ this.outcome = outcome;
+ }
+
+ protected boolean isPropagationExclusive() {
+ return true;
+ }
+
+ private class PropertySource implements IPropertySource, IPropertyId {
+
+ private IPropertyDescriptor[] propertyDescriptors = new IPropertyDescriptor[] {
+ new TextPropertyDescriptor(ID, "Id") {
+ public String getCategory() {
+ return "General";
+ }
+ },
+ new TextPropertyDescriptor(KEY, "Key") {
+ public String getCategory() {
+ return "General";
+ }
+ },
+ new TextPropertyDescriptor(OUTCOME, "Outcome") {
+ public String getCategory() {
+ return "General";
+ }
+ }
+ };
+
+ public Object getEditableValue() {
+ return null;
+ }
+
+ public IPropertyDescriptor[] getPropertyDescriptors() {
+ return propertyDescriptors;
+ }
+
+ public Object getPropertyValue(Object id) {
+ if (ID.equals(id)) {
+ return getSubprocessId() != null ? getSubprocessId() : "";
+ } else if (KEY.equals(id)) {
+ return getKey() != null ? getKey() : "";
+ } else if (OUTCOME.equals(id)) {
+ return getOutcome() != null ? getOutcome() : "";
+ }
+ return null;
+ }
+
+ public boolean isPropertySet(Object id) {
+ if (ID.equals(id)) {
+ return getSubprocessId() != null;
+ } else if (KEY.equals(id)) {
+ return getKey() != null;
+ } else if (OUTCOME.equals(id)) {
+ return getOutcome() != null;
+ }
+ return false;
+ }
+
+ public void resetPropertyValue(Object id) {
+ }
+
+ public void setPropertyValue(Object id, Object value) {
+ if (ID.equals(id)) {
+ if (value == null || value instanceof String) {
+ setSubprocessId((String)value);
+ }
+ } else if (KEY.equals(id)) {
+ if (value == null || value instanceof String) {
+ setKey((String)value);
+ }
+ } else if (OUTCOME.equals(id)) {
+ if (value == null || value instanceof String) {
+ setOutcome((String)value);
+ }
+ }
+ }
+
+ }
+}
Property changes on: trunk/jbpm/plugins/org.jboss.tools.flow.jpdl4/src/org/jboss/tools/flow/jpdl4/model/SubprocessTask.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Modified: trunk/jbpm/plugins/org.jboss.tools.flow.jpdl4/src/org/jboss/tools/flow/jpdl4/properties/JpdlPropertySection.java
===================================================================
--- trunk/jbpm/plugins/org.jboss.tools.flow.jpdl4/src/org/jboss/tools/flow/jpdl4/properties/JpdlPropertySection.java 2009-05-04 08:10:18 UTC (rev 14998)
+++ trunk/jbpm/plugins/org.jboss.tools.flow.jpdl4/src/org/jboss/tools/flow/jpdl4/properties/JpdlPropertySection.java 2009-05-04 10:06:51 UTC (rev 14999)
@@ -73,7 +73,7 @@
changePropertyCommand.setPropertyId(propertyId);
changePropertyCommand.setTarget(input);
changePropertyCommand.setNewValue(newValue);
- commandStack.execute(changePropertyCommand);
+ commandStack.execute(changePropertyCommand);
}
public void aboutToBeShown() {
Added: trunk/jbpm/plugins/org.jboss.tools.flow.jpdl4/src/org/jboss/tools/flow/jpdl4/properties/SubprocessSection.java
===================================================================
--- trunk/jbpm/plugins/org.jboss.tools.flow.jpdl4/src/org/jboss/tools/flow/jpdl4/properties/SubprocessSection.java (rev 0)
+++ trunk/jbpm/plugins/org.jboss.tools.flow.jpdl4/src/org/jboss/tools/flow/jpdl4/properties/SubprocessSection.java 2009-05-04 10:06:51 UTC (rev 14999)
@@ -0,0 +1,130 @@
+package org.jboss.tools.flow.jpdl4.properties;
+
+import org.eclipse.gef.commands.CommandStack;
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.custom.CLabel;
+import org.eclipse.swt.events.ModifyEvent;
+import org.eclipse.swt.events.ModifyListener;
+import org.eclipse.swt.layout.FormAttachment;
+import org.eclipse.swt.layout.FormData;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.swt.widgets.Text;
+import org.eclipse.ui.views.properties.IPropertySource;
+import org.eclipse.ui.views.properties.tabbed.TabbedPropertySheetPage;
+import org.jboss.tools.flow.jpdl4.model.SubprocessTask;
+
+public class SubprocessSection extends JpdlPropertySection {
+
+ private Text idText;
+ private CLabel idLabel;
+ private Text keyText;
+ private CLabel keyLabel;
+ private Text outcomeText;
+ private CLabel outcomeLabel;
+
+ private ModifyListener textModifyListener = new ModifyListener() {
+ public void modifyText(ModifyEvent event) {
+ IPropertySource input = getInput();
+ CommandStack commandStack = getCommandStack();
+ if (input == null || commandStack == null) return;
+ if (idText == event.getSource()) {
+ changeProperty(SubprocessTask.ID, getValueNullsAllowed(idText.getText()));
+ } else if (keyText == event.getSource()) {
+ changeProperty(SubprocessTask.KEY, getValueNullsAllowed(keyText.getText()));
+ } else if (outcomeText == event.getSource()) {
+ changeProperty(SubprocessTask.OUTCOME, getValueNullsAllowed(outcomeText.getText()));
+ }
+ }
+ };
+
+ public void createControls(Composite parent,
+ TabbedPropertySheetPage aTabbedPropertySheetPage) {
+ super.createControls(parent, aTabbedPropertySheetPage);
+ Composite composite = getFlatFormComposite();
+ createIdLabel(composite);
+ createIdText(composite);
+ createKeyLabel(composite);
+ createKeyText(composite);
+ createOutcomeLabel(composite);
+ createOutcomeText(composite);
+ }
+
+
+ private void createIdLabel(Composite parent) {
+ idLabel = getWidgetFactory().createCLabel(parent, "Id ");
+ FormData data = new FormData();
+ data.left = new FormAttachment(0, 0);
+ data.top = new FormAttachment(0, 5);
+ idLabel.setLayoutData(data);
+ }
+
+ private void createIdText(Composite parent) {
+ idText = getWidgetFactory().createText(parent, "");
+ FormData data = new FormData();
+ data.top = new FormAttachment(0, 0);
+ data.left = new FormAttachment(idLabel, 0, SWT.RIGHT);
+ data.right = new FormAttachment(100, 0);
+ idText.setLayoutData(data);
+ }
+
+ private void createKeyLabel(Composite parent) {
+ keyLabel = getWidgetFactory().createCLabel(parent, "Key");
+ FormData data = new FormData();
+ data.left = new FormAttachment(0, 0);
+ data.top = new FormAttachment(idText, 5);
+ keyLabel.setLayoutData(data);
+ }
+
+ private void createKeyText(Composite parent) {
+ keyText = getWidgetFactory().createText(parent, "");
+ FormData data = new FormData();
+ data.top = new FormAttachment(idText, 0);
+ data.left = new FormAttachment(idLabel, 0, SWT.RIGHT);
+ data.right = new FormAttachment(100, 0);
+ keyText.setLayoutData(data);
+ }
+
+ private void createOutcomeLabel(Composite parent) {
+ outcomeLabel = getWidgetFactory().createCLabel(parent, "Outcome");
+ FormData data = new FormData();
+ data.left = new FormAttachment(0, 0);
+ data.top = new FormAttachment(keyText, 5);
+ outcomeLabel.setLayoutData(data);
+ }
+
+ private void createOutcomeText(Composite parent) {
+ outcomeText = getWidgetFactory().createText(parent, "");
+ FormData data = new FormData();
+ data.top = new FormAttachment(keyText, 0);
+ data.left = new FormAttachment(idLabel, 0, SWT.RIGHT);
+ data.right = new FormAttachment(100, 0);
+ outcomeText.setLayoutData(data);
+ }
+
+ protected void hookListeners() {
+ idText.addModifyListener(textModifyListener);
+ keyText.addModifyListener(textModifyListener);
+ outcomeText.addModifyListener(textModifyListener);
+ }
+
+ protected void unhookListeners() {
+ idText.removeModifyListener(textModifyListener);
+ keyText.removeModifyListener(textModifyListener);
+ outcomeText.removeModifyListener(textModifyListener);
+ }
+
+ protected void updateValues() {
+ IPropertySource input = getInput();
+ if (input != null) {
+ idText.setText(getValueNotNull((String)input.getPropertyValue(SubprocessTask.ID)));
+ keyText.setText(getValueNotNull((String)input.getPropertyValue(SubprocessTask.KEY)));
+ outcomeText.setText(getValueNotNull((String)input.getPropertyValue(SubprocessTask.OUTCOME)));
+ } else {
+ idText.setText("");
+ keyText.setText("");
+ outcomeText.setText("");
+ }
+ }
+
+
+}
Property changes on: trunk/jbpm/plugins/org.jboss.tools.flow.jpdl4/src/org/jboss/tools/flow/jpdl4/properties/SubprocessSection.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
15 years, 8 months
JBoss Tools SVN: r14998 - in trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/configuration: editors and 1 other directory.
by jbosstools-commits@lists.jboss.org
Author: DartPeng
Date: 2009-05-04 04:10:18 -0400 (Mon, 04 May 2009)
New Revision: 14998
Added:
trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/configuration/actions/AddSmooksResourceAction.java
Modified:
trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/configuration/editors/SmooksActionBarContributor.java
Log:
JBIDE-4260
Group the menu item for smooks-resource-list element
Added: trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/configuration/actions/AddSmooksResourceAction.java
===================================================================
--- trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/configuration/actions/AddSmooksResourceAction.java (rev 0)
+++ trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/configuration/actions/AddSmooksResourceAction.java 2009-05-04 08:10:18 UTC (rev 14998)
@@ -0,0 +1,47 @@
+/*******************************************************************************
+ * 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.configuration.actions;
+
+import org.eclipse.emf.edit.domain.EditingDomain;
+import org.eclipse.emf.edit.ui.action.CreateChildAction;
+import org.eclipse.jface.viewers.ISelection;
+import org.eclipse.ui.IEditorPart;
+import org.eclipse.ui.IWorkbenchPart;
+
+/**
+ * @author Dart (dpeng(a)redhat.com)
+ *
+ */
+public class AddSmooksResourceAction extends CreateChildAction {
+
+ public AddSmooksResourceAction(EditingDomain editingDomain, ISelection selection, Object descriptor) {
+ super(editingDomain, selection, descriptor);
+ // TODO Auto-generated constructor stub
+ }
+
+ public AddSmooksResourceAction(IEditorPart editorPart, ISelection selection, Object descriptor) {
+ super(editorPart, selection, descriptor);
+ // TODO Auto-generated constructor stub
+ }
+
+ public AddSmooksResourceAction(IWorkbenchPart workbenchPart, ISelection selection, Object descriptor) {
+ super(workbenchPart, selection, descriptor);
+ // TODO Auto-generated constructor stub
+ }
+
+ public Object getDescriptor() {
+ return descriptor;
+ }
+
+ public void setDescriptor(Object descriptor) {
+ this.descriptor = descriptor;
+ }
+}
Property changes on: trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/configuration/actions/AddSmooksResourceAction.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Modified: trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/configuration/editors/SmooksActionBarContributor.java
===================================================================
--- trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/configuration/editors/SmooksActionBarContributor.java 2009-05-03 21:36:07 UTC (rev 14997)
+++ trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/configuration/editors/SmooksActionBarContributor.java 2009-05-04 08:10:18 UTC (rev 14998)
@@ -8,6 +8,7 @@
import java.util.ArrayList;
import java.util.Collection;
+import java.util.Iterator;
import org.eclipse.emf.common.command.Command;
import org.eclipse.emf.common.ui.viewer.IViewerProvider;
@@ -19,7 +20,6 @@
import org.eclipse.emf.edit.domain.IEditingDomainProvider;
import org.eclipse.emf.edit.ui.action.ControlAction;
import org.eclipse.emf.edit.ui.action.CopyAction;
-import org.eclipse.emf.edit.ui.action.CreateChildAction;
import org.eclipse.emf.edit.ui.action.CreateSiblingAction;
import org.eclipse.emf.edit.ui.action.CutAction;
import org.eclipse.emf.edit.ui.action.EditingDomainActionBarContributor;
@@ -54,13 +54,26 @@
import org.eclipse.ui.PlatformUI;
import org.eclipse.ui.actions.ActionFactory;
import org.jboss.tools.smooks.configuration.SmooksConfigurationActivator;
+import org.jboss.tools.smooks.configuration.actions.AddSmooksResourceAction;
+import org.jboss.tools.smooks.model.datasource.DataSourceJndi;
+import org.jboss.tools.smooks.model.datasource.Direct;
+import org.jboss.tools.smooks.model.dbrouting.Executor;
+import org.jboss.tools.smooks.model.dbrouting.ResultSetRowSelector;
+import org.jboss.tools.smooks.model.fileRouting.OutputStream;
+import org.jboss.tools.smooks.model.freemarker.Freemarker;
+import org.jboss.tools.smooks.model.groovy.ScriptType;
+import org.jboss.tools.smooks.model.iorouting.IORouter;
+import org.jboss.tools.smooks.model.javabean.BindingsType;
+import org.jboss.tools.smooks.model.jmsrouting.JmsRouter;
import org.jboss.tools.smooks.model.medi.EdiMap;
import org.jboss.tools.smooks.model.medi.MEdiFactory;
import org.jboss.tools.smooks.model.medi.MEdiPackage;
+import org.jboss.tools.smooks.model.smooks.AbstractReader;
import org.jboss.tools.smooks.model.smooks.DocumentRoot;
import org.jboss.tools.smooks.model.smooks.SmooksFactory;
import org.jboss.tools.smooks.model.smooks.SmooksPackage;
import org.jboss.tools.smooks.model.smooks.SmooksResourceListType;
+import org.jboss.tools.smooks.model.xsl.Xsl;
/**
* This is the action bar contributor for the Smooks model editor. <!--
@@ -278,7 +291,7 @@
// Prepare for CreateChild item addition or removal.
//
- createChildMenuManager = new MenuManager("New Child");
+ createChildMenuManager = new MenuManager("Add Smooks Resource");
submenuManager.insertBefore("additions", createChildMenuManager);
// Prepare for CreateSibling item addition or removal.
@@ -470,7 +483,7 @@
// }
if (descriptors != null) {
for (Object descriptor : descriptors) {
- actions.add(new CreateChildAction(activeEditorPart, selection, descriptor));
+ actions.add(new AddSmooksResourceAction(activeEditorPart, selection, descriptor));
}
}
return actions;
@@ -579,16 +592,167 @@
menuManager.insertBefore("edit", addMap10ResourceListAction);
}
- submenuManager = new MenuManager("Create Child");
- populateManager(submenuManager, createChildActions, null);
+ submenuManager = new MenuManager("Add Smooks Resource");
+ if (isSmooksResourceListElement()) {
+ groupActions(submenuManager,createChildActions);
+ } else {
+ populateManager(submenuManager, createChildActions, null);
+ }
menuManager.insertBefore("edit", submenuManager);
submenuManager = new MenuManager("Create Sibling");
populateManager(submenuManager, createSiblingActions, null);
menuManager.insertBefore("edit", submenuManager);
+ }
+ private boolean isSmooksResourceListElement() {
+ if (this.selection != null && selection instanceof IStructuredSelection) {
+ Object element = ((IStructuredSelection) selection).getFirstElement();
+ if (element instanceof SmooksResourceListType) {
+ return true;
+ }
+ }
+ return false;
}
+ protected void groupActions(MenuManager manager,Collection<?> createChildActions) {
+ MenuManager readers = new MenuManager("Readers");
+ manager.add(readers);
+
+ MenuManager templating = new MenuManager("Templating");
+ manager.add(templating);
+
+ MenuManager jbinding = new MenuManager("Java Binding");
+ manager.add(jbinding);
+
+ MenuManager datasources = new MenuManager("Datasources");
+ manager.add(datasources);
+
+ MenuManager scripting = new MenuManager("Scripting");
+ manager.add(scripting);
+
+ MenuManager fragmentRouting = new MenuManager("Fragment Routing");
+ manager.add(fragmentRouting);
+
+ for (Iterator<?> iterator = createChildActions.iterator(); iterator.hasNext();) {
+ boolean added = false;
+ AddSmooksResourceAction action = (AddSmooksResourceAction) iterator.next();
+ Object descriptor = action.getDescriptor();
+ if (isReader(descriptor)) {
+ readers.add(action);
+ added = true;
+ }
+ if (isTemplate(descriptor)) {
+ templating.add(action);added = true;
+ }
+ if (isJavaBinding(descriptor)) {
+ jbinding.add(action);added = true;
+ }
+ if (isDatasources(descriptor)) {
+ datasources.add(action);added = true;
+ }
+ if (isScripting(descriptor)) {
+ scripting.add(action);added = true;
+ }
+ if (isFragmentRouting(descriptor)) {
+ fragmentRouting.add(action);added = true;
+ }
+ if(!added){
+ manager.add(action);
+ }
+ }
+ }
+
+ private boolean isFragmentRouting(Object descriptor) {
+ if(descriptor instanceof CommandParameter){
+ CommandParameter parameter = (CommandParameter)descriptor;
+ if(parameter.getValue() != null){
+ if(AdapterFactoryEditingDomain.unwrap(parameter.getValue()) instanceof JmsRouter){
+ return true;
+ }
+ if(AdapterFactoryEditingDomain.unwrap(parameter.getValue()) instanceof OutputStream){
+ return true;
+ }
+ if(AdapterFactoryEditingDomain.unwrap(parameter.getValue()) instanceof IORouter){
+ return true;
+ }
+ if(AdapterFactoryEditingDomain.unwrap(parameter.getValue()) instanceof Executor){
+ return true;
+ }
+ if(AdapterFactoryEditingDomain.unwrap(parameter.getValue()) instanceof ResultSetRowSelector){
+ return true;
+ }
+ }
+ }
+ return false;
+ }
+
+ private boolean isScripting(Object descriptor) {
+ if(descriptor instanceof CommandParameter){
+ CommandParameter parameter = (CommandParameter)descriptor;
+ if(parameter.getValue() != null){
+ if(AdapterFactoryEditingDomain.unwrap(parameter.getValue()) instanceof ScriptType){
+ return true;
+ }
+ }
+ }
+ return false;
+ }
+
+ private boolean isDatasources(Object descriptor) {
+ if(descriptor instanceof CommandParameter){
+ CommandParameter parameter = (CommandParameter)descriptor;
+ if(parameter.getValue() != null){
+ if(AdapterFactoryEditingDomain.unwrap(parameter.getValue()) instanceof DataSourceJndi){
+ return true;
+ }
+ if(AdapterFactoryEditingDomain.unwrap(parameter.getValue()) instanceof Direct){
+ return true;
+ }
+ }
+ }
+ return false;
+ }
+
+ private boolean isJavaBinding(Object descriptor) {
+ if(descriptor instanceof CommandParameter){
+ CommandParameter parameter = (CommandParameter)descriptor;
+ if(parameter.getValue() != null){
+ if(AdapterFactoryEditingDomain.unwrap(parameter.getValue()) instanceof BindingsType){
+ return true;
+ }
+ }
+ }
+ return false;
+ }
+
+ private boolean isTemplate(Object descriptor) {
+ if(descriptor instanceof CommandParameter){
+ CommandParameter parameter = (CommandParameter)descriptor;
+ if(parameter.getValue() != null){
+ if(AdapterFactoryEditingDomain.unwrap(parameter.getValue()) instanceof Freemarker){
+ return true;
+ }
+ if(AdapterFactoryEditingDomain.unwrap(parameter.getValue()) instanceof Xsl){
+ return true;
+ }
+ }
+ }
+ return false;
+ }
+
+ private boolean isReader(Object descriptor) {
+ if(descriptor instanceof CommandParameter){
+ CommandParameter parameter = (CommandParameter)descriptor;
+ if(parameter.getValue() != null){
+ if(AdapterFactoryEditingDomain.unwrap(parameter.getValue()) instanceof AbstractReader){
+ return true;
+ }
+ }
+ }
+ return false;
+ }
+
protected void updateRootElementAddAction() {
addSmooks11ResourceListAction.setEnabled(false);
addMap10ResourceListAction.setEnabled(false);
15 years, 8 months
JBoss Tools SVN: r14997 - in trunk/examples/plugins: org.jboss.tools.seam.tutorial and 3 other directories.
by jbosstools-commits@lists.jboss.org
Author: snjeza
Date: 2009-05-03 17:36:07 -0400 (Sun, 03 May 2009)
New Revision: 14997
Added:
trunk/examples/plugins/org.jboss.tools.seam.tutorial/plugin.properties
trunk/examples/plugins/org.jboss.tools.seam.tutorial/src/org/jboss/tools/seam/tutorial/Messages.java
trunk/examples/plugins/org.jboss.tools.seam.tutorial/src/org/jboss/tools/seam/tutorial/messages.properties
Modified:
trunk/examples/plugins/org.jboss.tools.project.examples/src/org/jboss/tools/project/examples/filetransfer/ECFExamplesTransport.java
trunk/examples/plugins/org.jboss.tools.seam.tutorial/META-INF/MANIFEST.MF
trunk/examples/plugins/org.jboss.tools.seam.tutorial/build.properties
trunk/examples/plugins/org.jboss.tools.seam.tutorial/src/org/jboss/tools/seam/tutorial/Activator.java
trunk/examples/plugins/org.jboss.tools.seam.tutorial/src/org/jboss/tools/seam/tutorial/actions/ImportProjectExample.java
trunk/examples/plugins/org.jboss.tools.seam.tutorial/src/org/jboss/tools/seam/tutorial/actions/OpenFileInEditor.java
Log:
https://jira.jboss.org/jira/browse/JBIDE-4180 We should have the projects featured in Seam tutorials available in Project Examples - i18n
Modified: trunk/examples/plugins/org.jboss.tools.project.examples/src/org/jboss/tools/project/examples/filetransfer/ECFExamplesTransport.java
===================================================================
--- trunk/examples/plugins/org.jboss.tools.project.examples/src/org/jboss/tools/project/examples/filetransfer/ECFExamplesTransport.java 2009-05-03 20:53:50 UTC (rev 14996)
+++ trunk/examples/plugins/org.jboss.tools.project.examples/src/org/jboss/tools/project/examples/filetransfer/ECFExamplesTransport.java 2009-05-03 21:36:07 UTC (rev 14997)
@@ -415,7 +415,7 @@
}
//need to prompt user for user name and password
// check if adminUIService has been started
- Bundle bundle = Platform.getBundle("org.eclipse.equinox.p2.ui.sdk");
+ Bundle bundle = Platform.getBundle("org.eclipse.equinox.p2.ui.sdk"); //$NON-NLS-1$
if (bundle != null && bundle.getState() != Bundle.ACTIVE) {
try {
bundle.start();
Modified: trunk/examples/plugins/org.jboss.tools.seam.tutorial/META-INF/MANIFEST.MF
===================================================================
--- trunk/examples/plugins/org.jboss.tools.seam.tutorial/META-INF/MANIFEST.MF 2009-05-03 20:53:50 UTC (rev 14996)
+++ trunk/examples/plugins/org.jboss.tools.seam.tutorial/META-INF/MANIFEST.MF 2009-05-03 21:36:07 UTC (rev 14997)
@@ -1,10 +1,11 @@
Manifest-Version: 1.0
Bundle-ManifestVersion: 2
-Bundle-Name: Seam Tutorials
+Bundle-Name: %BundleName
Bundle-SymbolicName: org.jboss.tools.seam.tutorial;singleton:=true
Bundle-Version: 1.0.0
Bundle-Activator: org.jboss.tools.seam.tutorial.Activator
-Bundle-Vendor: JBoss, a division of Red Hat
+Bundle-Vendor: %BundleVendor
+Bundle-Localization: plugin
Require-Bundle: org.eclipse.ui,
org.eclipse.core.runtime,
org.eclipse.ui.cheatsheets,
Modified: trunk/examples/plugins/org.jboss.tools.seam.tutorial/build.properties
===================================================================
--- trunk/examples/plugins/org.jboss.tools.seam.tutorial/build.properties 2009-05-03 20:53:50 UTC (rev 14996)
+++ trunk/examples/plugins/org.jboss.tools.seam.tutorial/build.properties 2009-05-03 21:36:07 UTC (rev 14997)
@@ -3,4 +3,5 @@
bin.includes = META-INF/,\
.,\
plugin.xml,\
- cheatsheets/
+ cheatsheets/,\
+ plugin.properties
Added: trunk/examples/plugins/org.jboss.tools.seam.tutorial/plugin.properties
===================================================================
--- trunk/examples/plugins/org.jboss.tools.seam.tutorial/plugin.properties (rev 0)
+++ trunk/examples/plugins/org.jboss.tools.seam.tutorial/plugin.properties 2009-05-03 21:36:07 UTC (rev 14997)
@@ -0,0 +1,3 @@
+#Properties file for org.jboss.tools.seam.tutorial
+BundleVendor = JBoss, a division of Red Hat
+BundleName = Seam Tutorials
\ No newline at end of file
Modified: trunk/examples/plugins/org.jboss.tools.seam.tutorial/src/org/jboss/tools/seam/tutorial/Activator.java
===================================================================
--- trunk/examples/plugins/org.jboss.tools.seam.tutorial/src/org/jboss/tools/seam/tutorial/Activator.java 2009-05-03 20:53:50 UTC (rev 14996)
+++ trunk/examples/plugins/org.jboss.tools.seam.tutorial/src/org/jboss/tools/seam/tutorial/Activator.java 2009-05-03 21:36:07 UTC (rev 14997)
@@ -9,7 +9,7 @@
public class Activator extends AbstractUIPlugin {
// The plug-in ID
- public static final String PLUGIN_ID = "org.jboss.tools.seam.tutorial";
+ public static final String PLUGIN_ID = "org.jboss.tools.seam.tutorial"; //$NON-NLS-1$
// The shared instance
private static Activator plugin;
Added: trunk/examples/plugins/org.jboss.tools.seam.tutorial/src/org/jboss/tools/seam/tutorial/Messages.java
===================================================================
--- trunk/examples/plugins/org.jboss.tools.seam.tutorial/src/org/jboss/tools/seam/tutorial/Messages.java (rev 0)
+++ trunk/examples/plugins/org.jboss.tools.seam.tutorial/src/org/jboss/tools/seam/tutorial/Messages.java 2009-05-03 21:36:07 UTC (rev 14997)
@@ -0,0 +1,15 @@
+package org.jboss.tools.seam.tutorial;
+
+import org.eclipse.osgi.util.NLS;
+
+public class Messages extends NLS {
+ private static final String BUNDLE_NAME = "org.jboss.tools.seam.tutorial.messages"; //$NON-NLS-1$
+ public static String OpenFileInEditor_Cannot_open;
+ static {
+ // initialize resource bundle
+ NLS.initializeMessages(BUNDLE_NAME, Messages.class);
+ }
+
+ private Messages() {
+ }
+}
Modified: trunk/examples/plugins/org.jboss.tools.seam.tutorial/src/org/jboss/tools/seam/tutorial/actions/ImportProjectExample.java
===================================================================
--- trunk/examples/plugins/org.jboss.tools.seam.tutorial/src/org/jboss/tools/seam/tutorial/actions/ImportProjectExample.java 2009-05-03 20:53:50 UTC (rev 14996)
+++ trunk/examples/plugins/org.jboss.tools.seam.tutorial/src/org/jboss/tools/seam/tutorial/actions/ImportProjectExample.java 2009-05-03 21:36:07 UTC (rev 14997)
@@ -34,7 +34,7 @@
Project project = new Project();
project.setName(params[0]);
- StringTokenizer tokenizer = new StringTokenizer(params[1],",");
+ StringTokenizer tokenizer = new StringTokenizer(params[1],","); //$NON-NLS-1$
List<String> includedProjects = new ArrayList<String>();
while (tokenizer.hasMoreTokens()) {
includedProjects.add(tokenizer.nextToken().trim());
Modified: trunk/examples/plugins/org.jboss.tools.seam.tutorial/src/org/jboss/tools/seam/tutorial/actions/OpenFileInEditor.java
===================================================================
--- trunk/examples/plugins/org.jboss.tools.seam.tutorial/src/org/jboss/tools/seam/tutorial/actions/OpenFileInEditor.java 2009-05-03 20:53:50 UTC (rev 14996)
+++ trunk/examples/plugins/org.jboss.tools.seam.tutorial/src/org/jboss/tools/seam/tutorial/actions/OpenFileInEditor.java 2009-05-03 21:36:07 UTC (rev 14997)
@@ -9,6 +9,7 @@
import org.eclipse.jface.action.IStatusLineManager;
import org.eclipse.jface.text.IDocument;
import org.eclipse.jface.text.IRegion;
+import org.eclipse.osgi.util.NLS;
import org.eclipse.ui.IActionBars;
import org.eclipse.ui.IEditorPart;
import org.eclipse.ui.IEditorSite;
@@ -24,6 +25,7 @@
import org.eclipse.ui.part.MultiPageEditorPart;
import org.eclipse.ui.texteditor.ITextEditor;
import org.jboss.tools.common.model.ui.editor.EditorPartWrapper;
+import org.jboss.tools.seam.tutorial.Messages;
public class OpenFileInEditor extends Action implements ICheatSheetAction {
@@ -49,7 +51,7 @@
editor = IDE.openEditor(page, file, true);
}
} catch (PartInitException e) {
- setStatusMessage(page,"Cannot open the " + params[0] + " file");
+ setStatusMessage(page,NLS.bind(Messages.OpenFileInEditor_Cannot_open, params[0]));
return;
}
ITextEditor textEditor = getTextEditor(editor);
Added: trunk/examples/plugins/org.jboss.tools.seam.tutorial/src/org/jboss/tools/seam/tutorial/messages.properties
===================================================================
--- trunk/examples/plugins/org.jboss.tools.seam.tutorial/src/org/jboss/tools/seam/tutorial/messages.properties (rev 0)
+++ trunk/examples/plugins/org.jboss.tools.seam.tutorial/src/org/jboss/tools/seam/tutorial/messages.properties 2009-05-03 21:36:07 UTC (rev 14997)
@@ -0,0 +1 @@
+OpenFileInEditor_Cannot_open=Cannot open the {0} file.
15 years, 8 months
JBoss Tools SVN: r14996 - in trunk/examples: plugins/org.jboss.tools.project.examples/META-INF and 12 other directories.
by jbosstools-commits@lists.jboss.org
Author: snjeza
Date: 2009-05-03 16:53:50 -0400 (Sun, 03 May 2009)
New Revision: 14996
Added:
trunk/examples/plugins/org.jboss.tools.seam.tutorial/.classpath
trunk/examples/plugins/org.jboss.tools.seam.tutorial/.project
trunk/examples/plugins/org.jboss.tools.seam.tutorial/.settings/
trunk/examples/plugins/org.jboss.tools.seam.tutorial/.settings/org.eclipse.jdt.core.prefs
trunk/examples/plugins/org.jboss.tools.seam.tutorial/META-INF/
trunk/examples/plugins/org.jboss.tools.seam.tutorial/META-INF/MANIFEST.MF
trunk/examples/plugins/org.jboss.tools.seam.tutorial/bin/
trunk/examples/plugins/org.jboss.tools.seam.tutorial/build.properties
trunk/examples/plugins/org.jboss.tools.seam.tutorial/cheatsheets/
trunk/examples/plugins/org.jboss.tools.seam.tutorial/cheatsheets/registration.xml
trunk/examples/plugins/org.jboss.tools.seam.tutorial/plugin.xml
trunk/examples/plugins/org.jboss.tools.seam.tutorial/src/
trunk/examples/plugins/org.jboss.tools.seam.tutorial/src/org/
trunk/examples/plugins/org.jboss.tools.seam.tutorial/src/org/jboss/
trunk/examples/plugins/org.jboss.tools.seam.tutorial/src/org/jboss/tools/
trunk/examples/plugins/org.jboss.tools.seam.tutorial/src/org/jboss/tools/seam/
trunk/examples/plugins/org.jboss.tools.seam.tutorial/src/org/jboss/tools/seam/tutorial/
trunk/examples/plugins/org.jboss.tools.seam.tutorial/src/org/jboss/tools/seam/tutorial/Activator.java
trunk/examples/plugins/org.jboss.tools.seam.tutorial/src/org/jboss/tools/seam/tutorial/actions/
trunk/examples/plugins/org.jboss.tools.seam.tutorial/src/org/jboss/tools/seam/tutorial/actions/ImportProjectExample.java
trunk/examples/plugins/org.jboss.tools.seam.tutorial/src/org/jboss/tools/seam/tutorial/actions/OpenFileInEditor.java
trunk/examples/plugins/org.jboss.tools.seam.tutorial/src/org/jboss/tools/seam/tutorial/actions/OpenPreferencePage.java
trunk/examples/plugins/org.jboss.tools.seam.tutorial/src/org/jboss/tools/seam/tutorial/actions/RunOnServer.java
Modified:
trunk/examples/features/org.jboss.tools.project.examples.feature/feature.xml
trunk/examples/plugins/org.jboss.tools.project.examples/META-INF/MANIFEST.MF
trunk/examples/plugins/org.jboss.tools.project.examples/src/org/jboss/tools/project/examples/wizard/NewProjectExamplesWizard.java
Log:
https://jira.jboss.org/jira/browse/JBIDE-4180 We should have the projects featured in Seam tutorials available in Project Examples
Modified: trunk/examples/features/org.jboss.tools.project.examples.feature/feature.xml
===================================================================
--- trunk/examples/features/org.jboss.tools.project.examples.feature/feature.xml 2009-05-03 20:52:00 UTC (rev 14995)
+++ trunk/examples/features/org.jboss.tools.project.examples.feature/feature.xml 2009-05-03 20:53:50 UTC (rev 14996)
@@ -2,7 +2,7 @@
<feature
id="org.jboss.tools.project.examples.feature"
label="%featureName"
- version="1.0.0"
+ version="1.0.1"
provider-name="%providerName"
plugin="org.jboss.tools.project.examples">
@@ -29,4 +29,11 @@
version="0.0.0"
unpack="false"/>
+ <plugin
+ id="org.jboss.tools.seam.tutorial"
+ download-size="0"
+ install-size="0"
+ version="0.0.0"
+ unpack="false"/>
+
</feature>
Modified: trunk/examples/plugins/org.jboss.tools.project.examples/META-INF/MANIFEST.MF
===================================================================
--- trunk/examples/plugins/org.jboss.tools.project.examples/META-INF/MANIFEST.MF 2009-05-03 20:52:00 UTC (rev 14995)
+++ trunk/examples/plugins/org.jboss.tools.project.examples/META-INF/MANIFEST.MF 2009-05-03 20:53:50 UTC (rev 14996)
@@ -2,7 +2,7 @@
Bundle-ManifestVersion: 2
Bundle-Name: %BundleName
Bundle-SymbolicName: org.jboss.tools.project.examples;singleton:=true
-Bundle-Version: 1.0.0
+Bundle-Version: 1.0.1
Bundle-Activator: org.jboss.tools.project.examples.ProjectExamplesActivator
Bundle-Vendor: %BunldeVendor
Require-Bundle: org.eclipse.ui,
@@ -24,3 +24,10 @@
org.eclipse.jdt.core
Bundle-ActivationPolicy: lazy
Bundle-Localization: plugin
+Export-Package: org.jboss.tools.project.examples,
+ org.jboss.tools.project.examples.actions,
+ org.jboss.tools.project.examples.dialog,
+ org.jboss.tools.project.examples.dialog.xpl,
+ org.jboss.tools.project.examples.filetransfer,
+ org.jboss.tools.project.examples.model,
+ org.jboss.tools.project.examples.wizard
Modified: trunk/examples/plugins/org.jboss.tools.project.examples/src/org/jboss/tools/project/examples/wizard/NewProjectExamplesWizard.java
===================================================================
--- trunk/examples/plugins/org.jboss.tools.project.examples/src/org/jboss/tools/project/examples/wizard/NewProjectExamplesWizard.java 2009-05-03 20:52:00 UTC (rev 14995)
+++ trunk/examples/plugins/org.jboss.tools.project.examples/src/org/jboss/tools/project/examples/wizard/NewProjectExamplesWizard.java 2009-05-03 20:53:50 UTC (rev 14996)
@@ -96,8 +96,10 @@
private IStructuredSelection selection;
private NewProjectExamplesWizardPage page;
+
+ private static Shell shell;
- protected boolean overwrite;
+ protected static boolean overwrite;
private WorkspaceJob workspaceJob;
@@ -174,7 +176,6 @@
};
workspaceJob.setUser(true);
final boolean showQuickFix = page.showQuickFix();
- workspaceJob.schedule();
if (showQuickFix) {
workspaceJob.addJobChangeListener(new IJobChangeListener() {
@@ -205,7 +206,7 @@
List<IMarker> markers = ProjectExamplesActivator
.getMarkers(projects);
if (markers != null && markers.size() > 0) {
- showQuickFix();
+ showQuickFix(projects);
}
}
openWelcome();
@@ -227,6 +228,7 @@
} else {
openWelcome();
}
+ workspaceJob.schedule();
return true;
}
@@ -288,7 +290,7 @@
}
}
- private void showQuickFix() {
+ public static void showQuickFix(final List<Project> projects) {
Display.getDefault().asyncExec(new Runnable() {
@@ -303,7 +305,7 @@
});
}
- private void importProject(Project projectDescription, File file,
+ public static void importProject(Project projectDescription, File file,
IProgressMonitor monitor) throws Exception {
if (projectDescription.getIncludedProjects() == null) {
importSingleProject(projectDescription, file, monitor);
@@ -316,7 +318,7 @@
Display.getDefault().syncExec(new Runnable() {
public void run() {
- overwrite = MessageDialog.openQuestion(getShell(),
+ overwrite = MessageDialog.openQuestion(getActiveShell(),
Messages.NewProjectExamplesWizard_Question, NLS.bind(Messages.NewProjectExamplesWizard_OverwriteProject,
projectName));
}
@@ -350,14 +352,26 @@
ImportOperation operation = new ImportOperation(workspace
.getRoot().getFullPath(), structureProvider.getRoot(),
structureProvider, OVERWRITE_ALL_QUERY, filesToImport);
- operation.setContext(getShell());
+ operation.setContext(getActiveShell());
operation.run(monitor);
reconfigure(project, monitor);
}
}
}
- private void importSingleProject(Project projectDescription, File file,
+ private static Shell getActiveShell() {
+ Display display = Display.getDefault();
+ shell = null;
+ display.syncExec(new Runnable() {
+
+ public void run() {
+ shell = Display.getCurrent().getActiveShell();
+ }
+
+ });
+ return shell;
+ }
+ private static void importSingleProject(Project projectDescription, File file,
IProgressMonitor monitor) throws CoreException, ZipException,
IOException, InvocationTargetException, InterruptedException {
final String projectName = projectDescription.getName();
@@ -367,7 +381,7 @@
Display.getDefault().syncExec(new Runnable() {
public void run() {
- overwrite = MessageDialog.openQuestion(getShell(),
+ overwrite = MessageDialog.openQuestion(getActiveShell(),
Messages.NewProjectExamplesWizard_Question, NLS.bind(Messages.NewProjectExamplesWizard_OverwriteProject,
projectName));
}
@@ -387,7 +401,7 @@
ImportOperation operation = new ImportOperation(workspace.getRoot()
.getFullPath(), structureProvider.getRoot(), structureProvider,
OVERWRITE_ALL_QUERY);
- operation.setContext(getShell());
+ operation.setContext(getActiveShell());
operation.run(monitor);
reconfigure(project, monitor);
}
Added: trunk/examples/plugins/org.jboss.tools.seam.tutorial/.classpath
===================================================================
--- trunk/examples/plugins/org.jboss.tools.seam.tutorial/.classpath (rev 0)
+++ trunk/examples/plugins/org.jboss.tools.seam.tutorial/.classpath 2009-05-03 20:53:50 UTC (rev 14996)
@@ -0,0 +1,7 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<classpath>
+ <classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/J2SE-1.5"/>
+ <classpathentry kind="con" path="org.eclipse.pde.core.requiredPlugins"/>
+ <classpathentry kind="src" path="src"/>
+ <classpathentry kind="output" path="bin"/>
+</classpath>
Added: trunk/examples/plugins/org.jboss.tools.seam.tutorial/.project
===================================================================
--- trunk/examples/plugins/org.jboss.tools.seam.tutorial/.project (rev 0)
+++ trunk/examples/plugins/org.jboss.tools.seam.tutorial/.project 2009-05-03 20:53:50 UTC (rev 14996)
@@ -0,0 +1,28 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<projectDescription>
+ <name>org.jboss.tools.seam.tutorial</name>
+ <comment></comment>
+ <projects>
+ </projects>
+ <buildSpec>
+ <buildCommand>
+ <name>org.eclipse.jdt.core.javabuilder</name>
+ <arguments>
+ </arguments>
+ </buildCommand>
+ <buildCommand>
+ <name>org.eclipse.pde.ManifestBuilder</name>
+ <arguments>
+ </arguments>
+ </buildCommand>
+ <buildCommand>
+ <name>org.eclipse.pde.SchemaBuilder</name>
+ <arguments>
+ </arguments>
+ </buildCommand>
+ </buildSpec>
+ <natures>
+ <nature>org.eclipse.pde.PluginNature</nature>
+ <nature>org.eclipse.jdt.core.javanature</nature>
+ </natures>
+</projectDescription>
Added: trunk/examples/plugins/org.jboss.tools.seam.tutorial/.settings/org.eclipse.jdt.core.prefs
===================================================================
--- trunk/examples/plugins/org.jboss.tools.seam.tutorial/.settings/org.eclipse.jdt.core.prefs (rev 0)
+++ trunk/examples/plugins/org.jboss.tools.seam.tutorial/.settings/org.eclipse.jdt.core.prefs 2009-05-03 20:53:50 UTC (rev 14996)
@@ -0,0 +1,7 @@
+#Wed Apr 29 22:17:17 CEST 2009
+eclipse.preferences.version=1
+org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.5
+org.eclipse.jdt.core.compiler.compliance=1.5
+org.eclipse.jdt.core.compiler.problem.assertIdentifier=error
+org.eclipse.jdt.core.compiler.problem.enumIdentifier=error
+org.eclipse.jdt.core.compiler.source=1.5
Added: trunk/examples/plugins/org.jboss.tools.seam.tutorial/META-INF/MANIFEST.MF
===================================================================
--- trunk/examples/plugins/org.jboss.tools.seam.tutorial/META-INF/MANIFEST.MF (rev 0)
+++ trunk/examples/plugins/org.jboss.tools.seam.tutorial/META-INF/MANIFEST.MF 2009-05-03 20:53:50 UTC (rev 14996)
@@ -0,0 +1,27 @@
+Manifest-Version: 1.0
+Bundle-ManifestVersion: 2
+Bundle-Name: Seam Tutorials
+Bundle-SymbolicName: org.jboss.tools.seam.tutorial;singleton:=true
+Bundle-Version: 1.0.0
+Bundle-Activator: org.jboss.tools.seam.tutorial.Activator
+Bundle-Vendor: JBoss, a division of Red Hat
+Require-Bundle: org.eclipse.ui,
+ org.eclipse.core.runtime,
+ org.eclipse.ui.cheatsheets,
+ org.eclipse.jdt.core,
+ org.eclipse.core.resources,
+ org.eclipse.ui.ide,
+ org.eclipse.ui.workbench.texteditor,
+ org.eclipse.text,
+ org.jboss.tools.jst.jsp,
+ org.eclipse.wst.sse.ui,
+ org.jboss.tools.common.text.ext,
+ org.jboss.tools.common,
+ org.jboss.tools.common.model,
+ org.jboss.tools.common.model.ui,
+ org.jboss.tools.project.examples,
+ org.eclipse.wst.server.core,
+ org.eclipse.wst.server.ui,
+ org.jboss.ide.eclipse.as.core
+Bundle-RequiredExecutionEnvironment: J2SE-1.5
+Bundle-ActivationPolicy: lazy
Added: trunk/examples/plugins/org.jboss.tools.seam.tutorial/build.properties
===================================================================
--- trunk/examples/plugins/org.jboss.tools.seam.tutorial/build.properties (rev 0)
+++ trunk/examples/plugins/org.jboss.tools.seam.tutorial/build.properties 2009-05-03 20:53:50 UTC (rev 14996)
@@ -0,0 +1,6 @@
+source.. = src/
+output.. = bin/
+bin.includes = META-INF/,\
+ .,\
+ plugin.xml,\
+ cheatsheets/
Added: trunk/examples/plugins/org.jboss.tools.seam.tutorial/cheatsheets/registration.xml
===================================================================
--- trunk/examples/plugins/org.jboss.tools.seam.tutorial/cheatsheets/registration.xml (rev 0)
+++ trunk/examples/plugins/org.jboss.tools.seam.tutorial/cheatsheets/registration.xml 2009-05-03 20:53:50 UTC (rev 14996)
@@ -0,0 +1,438 @@
+<?xml version="1.0" encoding="UTF-8" ?>
+<cheatsheet title="Your first Seam application: the registration example">
+
+ <intro>
+ <description>
+ The registration example is a simple application that lets a new user store his username, real name and password in the database. The example isn't intended to show off all of the cool functionality of Seam. However, it demonstrates the use of an EJB3 session bean as a JSF action listener, and basic configuration of Seam.
+<br/><br/>
+We'll go slowly, since we realize you might not yet be familiar with EJB 3.0.
+<br/><br/>
+The start page displays a very basic form with three input fields. Try filling them in and then submitting the form. This will save a user object in the database.
+ </description>
+ </intro>
+
+ <item title="Open the Seam perspective" dialog="false" skip="false" href="/org.eclipse.platform.doc.user/concepts/concepts-4.htm">
+ <description>
+ If you're not already in the Seam perspective, in the main menu select <b>Window</b> > <b>Open Perspective</b> > <b>Other</b> > <b>Seam</b> or click on the "Click to Perform" link below.
+ </description>
+ <command serialization="org.eclipse.ui.perspectives.showPerspective(org.eclipse.ui.perspectives.showPerspective.perspectiveId=org.jboss.tools.seam.ui.SeamPerspective)" required="false" translate="">
+ </command>
+ </item>
+
+ <item
+ title="Setup the Environment"
+ skip="true">
+ <description>
+ You must set up your environment before performing the steps in this tutorial.
+ <br/><br/>
+ <b>
+ If you have JBoss Developer Studio with EAP installed, your environment is already set correctly.
+ </b>
+ </description>
+ <subitem
+ label="Create JBoss AS Runtime and Server using "File > New > Other > Server > Server" and select "JBoss Comunity" or "JBoss Enterprise Middleware" server type or click the "Click to Perform" link."
+ skip="true">
+ <command
+ serialization="org.eclipse.ui.newWizard(newWizardId=org.eclipse.wst.server.ui.new.server)"
+ required="false" translate="">
+ </command>
+ </subitem>
+ <subitem
+ label="Create a Seam Runtime using "Window > Preferences > JBoss Tools > Web > Seam." or click the "Click to Perform" link."
+ skip="true">
+ <action
+ required="false"
+ pluginId="org.jboss.tools.seam.tutorial"
+ class="org.jboss.tools.seam.tutorial.actions.OpenPreferencePage"
+ param1="org.jboss.tools.common.model.ui.seam"/>
+ </subitem>
+ <subitem
+ label="Create a Database Connection Profile by selecting "File > New > Other > Connection Profiles > Connection Profile." or click the "Click to Perform" link."
+ skip="true">
+ <command
+ serialization="org.eclipse.ui.newWizard(newWizardId=org.eclipse.datatools.connectivity.internal.ui.wizards.newconnectionprofile)"
+ required="false" translate="">
+ </command>
+ </subitem>
+ </item>
+
+ <item
+ title="Import the registration example">
+ <description>
+ Import the registration example using <b>Help > Project Examples</b> and select "Seam Registration Example - EAR" or click the "Click to Perform" link below.
+ <br/><br/>
+ If you don't have JBoss Developer Studio with EAP, you will have to set your Server Runtime, Seam Runtime and Database Connection Profile.
+After importing the project example, you will be able to use the Quick Fix dialog to set them.
+ </description>
+ <action
+ required="true"
+ pluginId="org.jboss.tools.seam.tutorial"
+ class="org.jboss.tools.seam.tutorial.actions.ImportProjectExample"
+ param1="registration2"
+ param2="registration,registration-ejb,registration-ear"
+ param3="http://anonsvn.jboss.org/repos/jbosstools/workspace/snjeza/seam-examples/..."
+ />
+ </item>
+
+ <item
+ skip="true"
+ title="Understanding the code">
+ <description>
+ The example is implemented with two Facelets templates, one entity bean and one stateless session bean. Let's take a look at the code, starting from the "bottom".
+ </description>
+ </item>
+
+ <item
+ title="The entity bean: User.java">
+ <description>
+ The most important things to notice in this example are the @Name and @Scope annotations. These annotations establish that this class is a Seam component.
+<br/><br/>
+We'll see below that the properties of our User class are bound directly to JSF components and are populated by JSF during the update model values phase. We don't need any tedious glue code to copy data back and forth between the JSP pages and the entity bean domain model.
+<br/><br/>
+However, entity beans shouldn't do transaction management or database access. So we can't use this component as a JSF action listener. For that we need a session bean.
+
+ </description>
+ <subitem
+ label="The EJB3 standard @Entity annotation indicates that the User class is an entity bean."
+ skip="true">
+ <action
+ pluginId="org.jboss.tools.seam.tutorial"
+ class="org.jboss.tools.seam.tutorial.actions.OpenFileInEditor"
+ param1="/registration-ejb/ejbModule/org/jboss/seam/example/registration/User.java"
+ param2="17" />
+ </subitem>
+ <subitem
+ label="A Seam component needs a component name specified by the @Name annotation. This name must be unique within the Seam application. When JSF asks Seam to resolve a context variable with a name that is the same as a Seam component name, and the context variable is currently undefined (null), Seam will instantiate that component, and bind the new instance to the context variable. In this case, Seam will instantiate a User the first time JSF encounters a variable named user."
+ skip="true">
+ <action
+ pluginId="org.jboss.tools.seam.tutorial"
+ class="org.jboss.tools.seam.tutorial.actions.OpenFileInEditor"
+ param1="/registration-ejb/ejbModule/org/jboss/seam/example/registration/User.java"
+ param2="18"/>
+ </subitem>
+ <subitem
+ label="Whenever Seam instantiates a component, it binds the new instance to a context variable in the component's default context. The default context is specified using the @Scope annotation. The User bean is a session scoped component. "
+ skip="true">
+ <action
+ pluginId="org.jboss.tools.seam.tutorial"
+ class="org.jboss.tools.seam.tutorial.actions.OpenFileInEditor"
+ param1="/registration-ejb/ejbModule/org/jboss/seam/example/registration/User.java"
+ param2="19"/>
+ </subitem>
+ <subitem
+ label="The EJB standard @Table annotation indicates that the User class is mapped to the users table. "
+ skip="true">
+ <action
+ pluginId="org.jboss.tools.seam.tutorial"
+ class="org.jboss.tools.seam.tutorial.actions.OpenFileInEditor"
+ param1="/registration-ejb/ejbModule/org/jboss/seam/example/registration/User.java"
+ param2="20"/>
+ </subitem>
+ <subitem
+ label="name, password and username are the persistent attributes of the entity bean. All of our persistent attributes define accessor methods. These are needed when this component is used by JSF in the render response and update model values phases. "
+ skip="true">
+ <action
+ pluginId="org.jboss.tools.seam.tutorial"
+ class="org.jboss.tools.seam.tutorial.actions.OpenFileInEditor"
+ param1="/registration-ejb/ejbModule/org/jboss/seam/example/registration/User.java"
+ param2="25"
+ param3="27"/>
+ </subitem>
+ <subitem
+ label="An empty constructor is both required by both the EJB specification and by Seam. "
+ skip="true">
+ <action
+ pluginId="org.jboss.tools.seam.tutorial"
+ class="org.jboss.tools.seam.tutorial.actions.OpenFileInEditor"
+ param1="/registration-ejb/ejbModule/org/jboss/seam/example/registration/User.java"
+ param2="36"/>
+ </subitem>
+ <subitem
+ label="The @NotNull and @Length annotations are part of the Hibernate Validator framework. Seam integrates Hibernate Validator and lets you use it for data validation (even if you are not using Hibernate for persistence). "
+ skip="true">
+ <action
+ pluginId="org.jboss.tools.seam.tutorial"
+ class="org.jboss.tools.seam.tutorial.actions.OpenFileInEditor"
+ param1="/registration-ejb/ejbModule/org/jboss/seam/example/registration/User.java"
+ param2="49"/>
+ </subitem>
+ <subitem
+ label="The EJB standard @Id annotation indicates the primary key attribute of the entity bean. "
+ skip="true">
+ <action
+ pluginId="org.jboss.tools.seam.tutorial"
+ class="org.jboss.tools.seam.tutorial.actions.OpenFileInEditor"
+ param1="/registration-ejb/ejbModule/org/jboss/seam/example/registration/User.java"
+ param2="60"/>
+ </subitem>
+ </item>
+
+ <item
+ title="The stateless session bean class: RegisterAction.java">
+ <description>
+ Most Seam application use session beans as JSF action listeners (you can use JavaBeans instead if you like).
+<br/><br/>
+We have exactly one JSF action in our application, and one session bean method attached to it. In this case, we'll use a stateless session bean, since all the state associated with our action is held by the User bean.
+<br/><br/>
+This is the only really interesting code in the example!
+ </description>
+ <subitem
+ label="The EJB @Stateless annotation marks this class as a stateless session bean."
+ skip="true">
+ <action
+ pluginId="org.jboss.tools.seam.tutorial"
+ class="org.jboss.tools.seam.tutorial.actions.OpenFileInEditor"
+ param1="/registration-ejb/ejbModule/org/jboss/seam/example/registration/RegisterAction.java"
+ param2="16" />
+ </subitem>
+ <subitem
+ label="The @In annotation marks an attribute of the bean as injected by Seam. In this case, the attribute is injected from a context variable named user (the instance variable name). "
+ skip="true">
+ <action
+ pluginId="org.jboss.tools.seam.tutorial"
+ class="org.jboss.tools.seam.tutorial.actions.OpenFileInEditor"
+ param1="/registration-ejb/ejbModule/org/jboss/seam/example/registration/RegisterAction.java"
+ param2="21" />
+ </subitem>
+ <subitem
+ label="The EJB standard @PersistenceContext annotation is used to inject the EJB3 entity manager."
+ skip="true">
+ <action
+ pluginId="org.jboss.tools.seam.tutorial"
+ class="org.jboss.tools.seam.tutorial.actions.OpenFileInEditor"
+ param1="/registration-ejb/ejbModule/org/jboss/seam/example/registration/RegisterAction.java"
+ param2="24" />
+ </subitem>
+ <subitem
+ label="The Seam @Logger annotation is used to inject the component's Log instance."
+ skip="true">
+ <action
+ pluginId="org.jboss.tools.seam.tutorial"
+ class="org.jboss.tools.seam.tutorial.actions.OpenFileInEditor"
+ param1="/registration-ejb/ejbModule/org/jboss/seam/example/registration/RegisterAction.java"
+ param2="27" />
+ </subitem>
+ <subitem
+ label="The action listener method uses the standard EJB3 EntityManager API to interact with the database, and returns the JSF outcome. Note that, since this is a session bean, a transaction is automatically begun when the register() method is called, and committed when it completes. "
+ skip="true">
+ <action
+ pluginId="org.jboss.tools.seam.tutorial"
+ class="org.jboss.tools.seam.tutorial.actions.OpenFileInEditor"
+ param1="/registration-ejb/ejbModule/org/jboss/seam/example/registration/RegisterAction.java"
+ param2="30"
+ param3="46" />
+ </subitem>
+ <subitem
+ label="Notice that Seam lets you use a JSF EL expression inside EJB-QL. Under the covers, this results in an ordinary JPA setParameter() call on the standard JPA Query object. Nice, huh?"
+ skip="true">
+ <action
+ pluginId="org.jboss.tools.seam.tutorial"
+ class="org.jboss.tools.seam.tutorial.actions.OpenFileInEditor"
+ param1="/registration-ejb/ejbModule/org/jboss/seam/example/registration/RegisterAction.java"
+ param2="32"/>
+ </subitem>
+ <subitem
+ label="The Log API lets us easily display templated log messages which can also make use of JSF EL expressions. "
+ skip="true">
+ <action
+ pluginId="org.jboss.tools.seam.tutorial"
+ class="org.jboss.tools.seam.tutorial.actions.OpenFileInEditor"
+ param1="/registration-ejb/ejbModule/org/jboss/seam/example/registration/RegisterAction.java"
+ param2="38"/>
+ </subitem>
+ <subitem
+ label="JSF action listener methods return a string-valued outcome that determines what page will be displayed next. A null outcome (or a void action listener method) redisplays the previous page. In plain JSF, it is normal to always use a JSF navigation rule to determine the JSF view id from the outcome. For complex application this indirection is useful and a good practice. However, for very simple examples like this one, Seam lets you use the JSF view id as the outcome, eliminating the requirement for a navigation rule. Note that when you use a view id as an outcome, Seam always performs a browser redirect."
+ skip="true">
+ <action
+ pluginId="org.jboss.tools.seam.tutorial"
+ class="org.jboss.tools.seam.tutorial.actions.OpenFileInEditor"
+ param1="/registration-ejb/ejbModule/org/jboss/seam/example/registration/RegisterAction.java"
+ param2="39"/>
+ </subitem>
+ <subitem
+ label="Seam provides a number of built-in components to help solve common problems. The FacesMessages component makes it easy to display templated error or success messages. (As of Seam 2.1, you can use StatusMessages instead to remove the semantic dependency on JSF). Built-in Seam components may be obtained by injection, or by calling the instance() method on the class of the built-in component."
+ skip="true">
+ <action
+ pluginId="org.jboss.tools.seam.tutorial"
+ class="org.jboss.tools.seam.tutorial.actions.OpenFileInEditor"
+ param1="/registration-ejb/ejbModule/org/jboss/seam/example/registration/RegisterAction.java"
+ param2="43"/>
+ </subitem>
+ <subitem
+ label="Note that we did not explicitly specify a @Scope this time. Each Seam component type has a default scope if not explicitly specified. For stateless session beans, the default scope is the stateless context, which is the only sensible value."
+ skip="true">
+ </subitem>
+ <subitem
+ label="Our session bean action listener performs the business and persistence logic for our mini-application. In more complex applications, we might need require a separate service layer. This is easy to achieve with Seam, but it's overkill for most web applications. Seam does not force you into any particular strategy for application layering, allowing your application to be as simple, or as complex, as you want."
+ skip="true">
+ </subitem>
+ <subitem
+ label="Note that in this simple application, we've actually made it far more complex than it needs to be. If we had used the Seam application framework controllers, we would have eliminated all of our application code. However, then we wouldn't have had much of an application to explain."
+ skip="true">
+ </subitem>
+ </item>
+
+ <item
+ skip="true"
+ title="The session bean local interface: Register.java">
+ <description>
+ Naturally, our session bean needs a local interface.
+ </description>
+ <action
+ pluginId="org.jboss.tools.seam.tutorial"
+ class="org.jboss.tools.seam.tutorial.actions.OpenFileInEditor"
+ param1="/registration-ejb/ejbModule/org/jboss/seam/example/registration/Register.java"/>
+ </item>
+
+ <item
+ title="The view: register.xhtml">
+ <description>
+ The view pages for a Seam application could be implemented using any technology that supports JSF. In this example we use Facelets, because we think it's better than JSP.
+ </description>
+ <subitem
+ label="The only thing here that is specific to Seam is the <s:validateAll> tag. This JSF component tells JSF to validate all the contained input fields against the Hibernate Validator annotations specified on the entity bean."
+ skip="true">
+ <action
+ pluginId="org.jboss.tools.seam.tutorial"
+ class="org.jboss.tools.seam.tutorial.actions.OpenFileInEditor"
+ param1="/registration/WebContent/register.xhtml"
+ param2="15"
+ param4="org.jboss.tools.jst.jsp.jspeditor.JSPTextEditor"/>
+ </subitem>
+
+ </item>
+ <item
+ title="The view: registered.xhtml">
+ <description>
+ This is a simple Facelets page using some inline EL. There's nothing specific to Seam here.
+ </description>
+ <subitem
+ label="Open registered.xhtml"
+ skip="true">
+ <action
+ pluginId="org.jboss.tools.seam.tutorial"
+ class="org.jboss.tools.seam.tutorial.actions.OpenFileInEditor"
+ param1="/registration/WebContent/registered.xhtml"
+ param4="org.jboss.tools.jst.jsp.jspeditor.JSPTextEditor"/>
+ </subitem>
+
+ </item>
+
+ <item
+ title="The Seam component deployment descriptor: components.xml">
+ <description>
+ Since this is the first Seam app we've seen, we'll take a look at the deployment descriptors. Before we get into them, it is worth noting that Seam strongly values minimal configuration. These configuration files will be created for you when you create a Seam application. You'll never need to touch most of these files. We're presenting them now only to help you understand what all the pieces in the example are doing.
+<br/><br/>
+If you've used many Java frameworks before, you'll be used to having to declare all your component classes in some kind of XML file that gradually grows more and more unmanageable as your project matures. You'll be relieved to know that Seam does not require that application components be accompanied by XML. Most Seam applications require a very small amount of XML that does not grow very much as the project gets bigger.
+<br/><br/>
+Nevertheless, it is often useful to be able to provide for some external configuration of some components (particularly the components built in to Seam). You have a couple of options here, but the most flexible option is to provide this configuration in a file called components.xml, located in the WEB-INF directory. We'll use the components.xml file to tell Seam how to find our EJB components in JNDI.
+<br/><br/>
+This code configures a property named jndiPattern of a built-in Seam component named org.jboss.seam.core.init. The funny @ symbols are there because our Ant build script puts the correct JNDI pattern in when we deploy the application, which it reads from the components.properties file.
+ </description>
+ <subitem label="Open components.xml"
+ skip="true">
+ <action
+ pluginId="org.jboss.tools.seam.tutorial"
+ class="org.jboss.tools.seam.tutorial.actions.OpenFileInEditor"
+ param1="/registration/WebContent/WEB-INF/components.xml"
+ param2="9"/>
+ </subitem>
+ <subitem label="Open components.properties"
+ skip="true">
+ <action
+ pluginId="org.jboss.tools.seam.tutorial"
+ class="org.jboss.tools.seam.tutorial.actions.OpenFileInEditor"
+ param1="/registration-ejb/ejbModule/components.properties"/>
+ </subitem>
+ </item>
+
+ <item
+ title="The web deployment description: web.xml">
+ <description>
+ The presentation layer for our mini-application will be deployed in a WAR. So we'll need a web deployment descriptor.
+ </description>
+ <subitem
+ label="This web.xml file configures Seam and JSF. The configuration you see here is pretty much identical in all Seam applications."
+ skip="true">
+ <action
+ pluginId="org.jboss.tools.seam.tutorial"
+ class="org.jboss.tools.seam.tutorial.actions.OpenFileInEditor"
+ param1="/registration/WebContent/WEB-INF/web.xml"/>
+ </subitem>
+
+ </item>
+ <item
+ skip="true"
+ title="The JSF configuration: faces-config.xml">
+ <description>
+ Most Seam applications use JSF views as the presentation layer. So usually we'll need faces-config.xml. In our case, we are going to use Facelets for defining our views, so we need to tell JSF to use Facelets as its templating engine.
+<br/><br/>
+ Note that we don't need any JSF managed bean declarations! Our managed beans are annotated Seam components. In Seam applications, the faces-config.xml is used much less often than in plain JSF. Here, we are simply using it to enable Facelets as the view handler instead of JSP.
+<br/><br/>
+In fact, once you have all the basic descriptors set up, the only XML you need to write as you add new functionality to a Seam application is orchestration: navigation rules or jBPM process definitions. Seam's stand is that process flow and configuration data are the only things that truly belong in XML.
+<br/><br/>
+In this simple example, we don't even need a navigation rule, since we decided to embed the view id in our action code.
+ </description>
+ <action
+ pluginId="org.jboss.tools.seam.tutorial"
+ class="org.jboss.tools.seam.tutorial.actions.OpenFileInEditor"
+ param1="/registration/WebContent/WEB-INF/faces-config.xml"/>
+
+ </item>
+
+ <item
+ skip="true"
+ title="The EJB deployment descriptor: ejb-jar.xml">
+ <description>
+ The ejb-jar.xml file integrates Seam with EJB3, by attaching the SeamInterceptor to all session beans in the archive.
+ </description>
+ <action
+ pluginId="org.jboss.tools.seam.tutorial"
+ class="org.jboss.tools.seam.tutorial.actions.OpenFileInEditor"
+ param1="/registration-ejb/ejbModule/META-INF/ejb-jar.xml"/>
+
+ </item>
+
+ <item
+ skip="true"
+ title="The EJB persistence deployment descriptor: persistence.xml">
+ <description>
+ The persistence.xml file tells the EJB persistence provider where to find the datasource, and contains some vendor-specific settings. In this case, enables automatic schema export at startup time.
+ </description>
+ <action
+ pluginId="org.jboss.tools.seam.tutorial"
+ class="org.jboss.tools.seam.tutorial.actions.OpenFileInEditor"
+ param1="/registration-ejb/ejbModule/META-INF/persistence.xml"/>
+
+ </item>
+
+ <item
+ skip="true"
+ title="The EAR deployment descriptor: application.xml">
+ <description>
+ The persistence.xml file tells the EJB persistence provider where to find the datasource, and contains some vendor-specific settings. In this case, enables automatic schema export at startup time.
+<br/><br/>
+This deployment descriptor links modules in the enterprise archive and binds the web application to the context root /registration.
+ </description>
+ <action
+ pluginId="org.jboss.tools.seam.tutorial"
+ class="org.jboss.tools.seam.tutorial.actions.OpenFileInEditor"
+ param1="/registration-ear/EarContent/META-INF/application.xml"/>
+ </item>
+
+ <item
+ skip="true"
+ title="Run and deploy the application">
+ <description>
+ Right-click the registration-ear/resources/registration-ds.xml file and select <b>Make Deployable.</b>
+ <br/>
+ Right-click the registration project and select <b>Run As</b> > <b>Run On Server</b> or click on the "Click to Perform" link below.
+ </description>
+ <action
+ pluginId="org.jboss.tools.seam.tutorial"
+ class="org.jboss.tools.seam.tutorial.actions.RunOnServer"
+ param1="registration"
+ param2="registration-ear/resources/registration-ds.xml"/>
+
+ </item>
+</cheatsheet>
Added: trunk/examples/plugins/org.jboss.tools.seam.tutorial/plugin.xml
===================================================================
--- trunk/examples/plugins/org.jboss.tools.seam.tutorial/plugin.xml (rev 0)
+++ trunk/examples/plugins/org.jboss.tools.seam.tutorial/plugin.xml 2009-05-03 20:53:50 UTC (rev 14996)
@@ -0,0 +1,21 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<?eclipse version="3.4"?>
+<plugin>
+ <extension
+ point="org.eclipse.ui.cheatsheets.cheatSheetContent">
+ <category
+ id="org.jboss.tools.seam.tutorial"
+ name="JBoss Seam Tutorials">
+ </category>
+ <cheatsheet
+ category="org.jboss.tools.seam.tutorial"
+ contentFile="$nl$/cheatsheets/registration.xml"
+ id="org.jboss.tools.seam.tutorial.registration"
+ name="Your first Seam application: the registration example">
+ <description>
+ The registration example is a simple application that lets a new user store his username, real name and password in the database.
+ </description>
+ </cheatsheet>
+ </extension>
+
+</plugin>
Added: trunk/examples/plugins/org.jboss.tools.seam.tutorial/src/org/jboss/tools/seam/tutorial/Activator.java
===================================================================
--- trunk/examples/plugins/org.jboss.tools.seam.tutorial/src/org/jboss/tools/seam/tutorial/Activator.java (rev 0)
+++ trunk/examples/plugins/org.jboss.tools.seam.tutorial/src/org/jboss/tools/seam/tutorial/Activator.java 2009-05-03 20:53:50 UTC (rev 14996)
@@ -0,0 +1,50 @@
+package org.jboss.tools.seam.tutorial;
+
+import org.eclipse.ui.plugin.AbstractUIPlugin;
+import org.osgi.framework.BundleContext;
+
+/**
+ * The activator class controls the plug-in life cycle
+ */
+public class Activator extends AbstractUIPlugin {
+
+ // The plug-in ID
+ public static final String PLUGIN_ID = "org.jboss.tools.seam.tutorial";
+
+ // The shared instance
+ private static Activator plugin;
+
+ /**
+ * The constructor
+ */
+ public Activator() {
+ }
+
+ /*
+ * (non-Javadoc)
+ * @see org.eclipse.ui.plugin.AbstractUIPlugin#start(org.osgi.framework.BundleContext)
+ */
+ public void start(BundleContext context) throws Exception {
+ super.start(context);
+ plugin = this;
+ }
+
+ /*
+ * (non-Javadoc)
+ * @see org.eclipse.ui.plugin.AbstractUIPlugin#stop(org.osgi.framework.BundleContext)
+ */
+ public void stop(BundleContext context) throws Exception {
+ plugin = null;
+ super.stop(context);
+ }
+
+ /**
+ * Returns the shared instance
+ *
+ * @return the shared instance
+ */
+ public static Activator getDefault() {
+ return plugin;
+ }
+
+}
Added: trunk/examples/plugins/org.jboss.tools.seam.tutorial/src/org/jboss/tools/seam/tutorial/actions/ImportProjectExample.java
===================================================================
--- trunk/examples/plugins/org.jboss.tools.seam.tutorial/src/org/jboss/tools/seam/tutorial/actions/ImportProjectExample.java (rev 0)
+++ trunk/examples/plugins/org.jboss.tools.seam.tutorial/src/org/jboss/tools/seam/tutorial/actions/ImportProjectExample.java 2009-05-03 20:53:50 UTC (rev 14996)
@@ -0,0 +1,129 @@
+package org.jboss.tools.seam.tutorial.actions;
+
+import java.io.File;
+import java.net.MalformedURLException;
+import java.net.URL;
+import java.util.ArrayList;
+import java.util.List;
+import java.util.StringTokenizer;
+
+import org.eclipse.core.resources.IMarker;
+import org.eclipse.core.resources.WorkspaceJob;
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.core.runtime.IProgressMonitor;
+import org.eclipse.core.runtime.IStatus;
+import org.eclipse.core.runtime.Status;
+import org.eclipse.core.runtime.jobs.IJobChangeEvent;
+import org.eclipse.core.runtime.jobs.IJobChangeListener;
+import org.eclipse.jface.action.Action;
+import org.eclipse.ui.cheatsheets.ICheatSheetAction;
+import org.eclipse.ui.cheatsheets.ICheatSheetManager;
+import org.jboss.tools.project.examples.Messages;
+import org.jboss.tools.project.examples.ProjectExamplesActivator;
+import org.jboss.tools.project.examples.model.Project;
+import org.jboss.tools.project.examples.model.ProjectUtil;
+import org.jboss.tools.project.examples.wizard.NewProjectExamplesWizard;
+import org.jboss.tools.seam.tutorial.Activator;
+
+public class ImportProjectExample extends Action implements ICheatSheetAction {
+
+ public void run(String[] params, ICheatSheetManager manager) {
+ if(params == null || params[0] == null || params[1] == null || params[2] == null ) {
+ return;
+ }
+
+ Project project = new Project();
+ project.setName(params[0]);
+ StringTokenizer tokenizer = new StringTokenizer(params[1],",");
+ List<String> includedProjects = new ArrayList<String>();
+ while (tokenizer.hasMoreTokens()) {
+ includedProjects.add(tokenizer.nextToken().trim());
+ }
+ project.setIncludedProjects(includedProjects);
+ project.setUrl(params[2]);
+ importProject(project);
+
+ }
+
+ private void importProject(final Project project) {
+ WorkspaceJob workspaceJob = new WorkspaceJob(Messages.NewProjectExamplesWizard_Downloading) {
+
+ @Override
+ public IStatus runInWorkspace(IProgressMonitor monitor)
+ throws CoreException {
+ String urlString = project.getUrl();
+ String name = project.getName();
+ URL url = null;
+ try {
+ url = new URL(urlString);
+ } catch (MalformedURLException e) {
+ ProjectExamplesActivator.log(e);
+ return Status.CANCEL_STATUS;
+ }
+ final File file = ProjectUtil.getProjectExamplesFile(
+ url, name, ".zip", monitor); //$NON-NLS-1$
+ if (file == null) {
+ return Status.CANCEL_STATUS;
+ }
+
+ setName(Messages.NewProjectExamplesWizard_Importing);
+ try {
+ NewProjectExamplesWizard.importProject(project, file, monitor);
+ } catch (Exception e) {
+ IStatus status = new Status(IStatus.ERROR,Activator.PLUGIN_ID,e.getMessage(),e);
+ throw new CoreException(status);
+ }
+
+ return Status.OK_STATUS;
+ }
+
+ };
+ workspaceJob.setUser(true);
+
+ workspaceJob.addJobChangeListener(new IJobChangeListener() {
+
+ public void aboutToRun(IJobChangeEvent event) {
+
+ }
+
+ public void awake(IJobChangeEvent event) {
+
+ }
+
+ public void done(IJobChangeEvent event) {
+ try {
+ ProjectExamplesActivator.waitForBuildAndValidation
+ .schedule();
+ ProjectExamplesActivator.waitForBuildAndValidation
+ .join();
+ } catch (InterruptedException e) {
+ return;
+ }
+ List<Project> projects = new ArrayList<Project>();
+ projects.add(project);
+ List<IMarker> markers = ProjectExamplesActivator
+ .getMarkers(projects);
+ if (markers != null && markers.size() > 0) {
+ NewProjectExamplesWizard.showQuickFix(projects);
+ }
+
+ }
+
+ public void running(IJobChangeEvent event) {
+
+ }
+
+ public void scheduled(IJobChangeEvent event) {
+
+ }
+
+ public void sleeping(IJobChangeEvent event) {
+
+ }
+
+ });
+ workspaceJob.schedule();
+ }
+
+
+}
Added: trunk/examples/plugins/org.jboss.tools.seam.tutorial/src/org/jboss/tools/seam/tutorial/actions/OpenFileInEditor.java
===================================================================
--- trunk/examples/plugins/org.jboss.tools.seam.tutorial/src/org/jboss/tools/seam/tutorial/actions/OpenFileInEditor.java (rev 0)
+++ trunk/examples/plugins/org.jboss.tools.seam.tutorial/src/org/jboss/tools/seam/tutorial/actions/OpenFileInEditor.java 2009-05-03 20:53:50 UTC (rev 14996)
@@ -0,0 +1,119 @@
+package org.jboss.tools.seam.tutorial.actions;
+
+import org.eclipse.core.resources.IFile;
+import org.eclipse.core.resources.IWorkspaceRoot;
+import org.eclipse.core.resources.ResourcesPlugin;
+import org.eclipse.core.runtime.IPath;
+import org.eclipse.core.runtime.Path;
+import org.eclipse.jface.action.Action;
+import org.eclipse.jface.action.IStatusLineManager;
+import org.eclipse.jface.text.IDocument;
+import org.eclipse.jface.text.IRegion;
+import org.eclipse.ui.IActionBars;
+import org.eclipse.ui.IEditorPart;
+import org.eclipse.ui.IEditorSite;
+import org.eclipse.ui.IViewSite;
+import org.eclipse.ui.IWorkbenchPage;
+import org.eclipse.ui.IWorkbenchPart;
+import org.eclipse.ui.IWorkbenchPartSite;
+import org.eclipse.ui.PartInitException;
+import org.eclipse.ui.PlatformUI;
+import org.eclipse.ui.cheatsheets.ICheatSheetAction;
+import org.eclipse.ui.cheatsheets.ICheatSheetManager;
+import org.eclipse.ui.ide.IDE;
+import org.eclipse.ui.part.MultiPageEditorPart;
+import org.eclipse.ui.texteditor.ITextEditor;
+import org.jboss.tools.common.model.ui.editor.EditorPartWrapper;
+
+public class OpenFileInEditor extends Action implements ICheatSheetAction {
+
+ public void run(String[] params, ICheatSheetManager manager) {
+ if(params == null || params[0] == null ) {
+ return;
+ }
+ IWorkspaceRoot workspaceRoot = ResourcesPlugin.getWorkspace().getRoot();
+
+ IPath path = new Path(params[0]);
+ IFile file = workspaceRoot.getFile(path);
+ IWorkbenchPage page = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage();
+ IEditorPart editor = null;
+ try {
+ if (params[3] != null && params[3].trim().length() > 0) {
+ String editorID = params[3];
+ try {
+ editor = IDE.openEditor(page, file, editorID, true);
+ } catch (Exception e) {
+ }
+ }
+ if (editor == null) {
+ editor = IDE.openEditor(page, file, true);
+ }
+ } catch (PartInitException e) {
+ setStatusMessage(page,"Cannot open the " + params[0] + " file");
+ return;
+ }
+ ITextEditor textEditor = getTextEditor(editor);
+ if (params[1] != null && textEditor != null) {
+ try {
+ int lineStart = Integer.parseInt(params[1]);
+ int lineEnd = lineStart;
+ if (params[2] != null) {
+ lineEnd = Integer.parseInt(params[2]);
+ }
+ IDocument document = textEditor.getDocumentProvider().getDocument(textEditor.getEditorInput());
+ IRegion lineInfoStart = document.getLineInformation(lineStart-1);
+ IRegion lineInfoEnd = document.getLineInformation(lineEnd-1);
+ textEditor.selectAndReveal(lineInfoStart.getOffset(), lineInfoEnd.getOffset() - lineInfoStart.getOffset() + lineInfoEnd.getLength());
+ } catch (Exception e) {
+ setStatusMessage(page, e.getLocalizedMessage());
+ }
+
+ }
+ }
+
+ private ITextEditor getTextEditor(IEditorPart editor) {
+ if (editor instanceof ITextEditor) {
+ return (ITextEditor) editor;
+ }
+ if (editor instanceof MultiPageEditorPart) {
+ MultiPageEditorPart multiPageEditor = (MultiPageEditorPart) editor;
+ IEditorPart[] editors = multiPageEditor.findEditors(editor.getEditorInput());
+ for (int i = 0; i < editors.length; i++) {
+ if (editors[i] instanceof ITextEditor) {
+ ITextEditor textEditor = (ITextEditor) editors[i];
+ if (textEditor.getDocumentProvider() != null) {
+ return (ITextEditor) editors[i];
+ }
+ }
+ }
+ }
+ if (editor instanceof EditorPartWrapper) {
+ EditorPartWrapper wrapper = (EditorPartWrapper) editor;
+ IEditorPart nestedEditor = wrapper.getEditor();
+ return getTextEditor(nestedEditor);
+ }
+ return null;
+ }
+
+ private void setStatusMessage(IWorkbenchPage page,String message) {
+ IWorkbenchPart activePart = page.getActivePart();
+ IWorkbenchPartSite site = activePart.getSite();
+ IActionBars actionBar = null;
+ if (site instanceof IViewSite) {
+ IViewSite viewSite = (IViewSite) site;
+ actionBar = viewSite.getActionBars();
+ } else if (site instanceof IEditorSite) {
+ IEditorSite editorSite = (IEditorSite) site;
+ actionBar = editorSite.getActionBars();
+ }
+ if (actionBar == null) {
+ return;
+ }
+ IStatusLineManager lineManager = actionBar.getStatusLineManager();
+ if (lineManager == null) {
+ return;
+ }
+ lineManager.setMessage(message);
+ }
+
+}
Added: trunk/examples/plugins/org.jboss.tools.seam.tutorial/src/org/jboss/tools/seam/tutorial/actions/OpenPreferencePage.java
===================================================================
--- trunk/examples/plugins/org.jboss.tools.seam.tutorial/src/org/jboss/tools/seam/tutorial/actions/OpenPreferencePage.java (rev 0)
+++ trunk/examples/plugins/org.jboss.tools.seam.tutorial/src/org/jboss/tools/seam/tutorial/actions/OpenPreferencePage.java 2009-05-03 20:53:50 UTC (rev 14996)
@@ -0,0 +1,24 @@
+package org.jboss.tools.seam.tutorial.actions;
+
+import org.eclipse.jface.action.Action;
+import org.eclipse.jface.preference.PreferenceDialog;
+import org.eclipse.swt.widgets.Shell;
+import org.eclipse.ui.PlatformUI;
+import org.eclipse.ui.cheatsheets.ICheatSheetAction;
+import org.eclipse.ui.cheatsheets.ICheatSheetManager;
+import org.eclipse.ui.internal.dialogs.WorkbenchPreferenceDialog;
+
+public class OpenPreferencePage extends Action implements ICheatSheetAction {
+
+ public void run(String[] params, ICheatSheetManager manager) {
+ if(params == null || params[0] == null) {
+ return;
+ }
+ Shell shell = PlatformUI.getWorkbench().getActiveWorkbenchWindow()
+ .getShell();
+ PreferenceDialog dialog = WorkbenchPreferenceDialog.createDialogOn(
+ shell, params[0]);
+ dialog.open();
+ }
+
+}
Added: trunk/examples/plugins/org.jboss.tools.seam.tutorial/src/org/jboss/tools/seam/tutorial/actions/RunOnServer.java
===================================================================
--- trunk/examples/plugins/org.jboss.tools.seam.tutorial/src/org/jboss/tools/seam/tutorial/actions/RunOnServer.java (rev 0)
+++ trunk/examples/plugins/org.jboss.tools.seam.tutorial/src/org/jboss/tools/seam/tutorial/actions/RunOnServer.java 2009-05-03 20:53:50 UTC (rev 14996)
@@ -0,0 +1,65 @@
+package org.jboss.tools.seam.tutorial.actions;
+
+import org.eclipse.core.resources.IFile;
+import org.eclipse.core.resources.IProject;
+import org.eclipse.core.resources.IWorkspaceRoot;
+import org.eclipse.core.resources.ResourcesPlugin;
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.core.runtime.IStatus;
+import org.eclipse.core.runtime.NullProgressMonitor;
+import org.eclipse.core.runtime.Path;
+import org.eclipse.core.runtime.Status;
+import org.eclipse.jface.action.Action;
+import org.eclipse.jface.action.IAction;
+import org.eclipse.ui.cheatsheets.ICheatSheetAction;
+import org.eclipse.ui.cheatsheets.ICheatSheetManager;
+import org.eclipse.wst.server.core.IModule;
+import org.eclipse.wst.server.core.IServer;
+import org.eclipse.wst.server.core.IServerWorkingCopy;
+import org.eclipse.wst.server.ui.actions.RunOnServerAction;
+import org.jboss.ide.eclipse.as.core.modules.SingleDeployableFactory;
+import org.jboss.ide.eclipse.as.core.util.ServerConverter;
+import org.jboss.tools.seam.tutorial.Activator;
+
+public class RunOnServer extends Action implements ICheatSheetAction {
+
+ public void run(String[] params, ICheatSheetManager manager) {
+ if(params == null || params[0] == null) {
+ return;
+ }
+ IWorkspaceRoot wRoot = ResourcesPlugin.getWorkspace().getRoot();
+ IProject project = wRoot.getProject(params[0]);
+ if (project == null || !project.isOpen()) {
+ return;
+ }
+ if (params[1] != null) {
+ IFile file = wRoot.getFile(new Path(params[1]));
+ if (file != null || file.exists()) {
+ try {
+ SingleDeployableFactory.makeDeployable(file.getFullPath());
+ IServer[] deployableServersAsIServers = ServerConverter
+ .getDeployableServersAsIServers();
+ if (deployableServersAsIServers.length == 1) {
+ IServer server = deployableServersAsIServers[0];
+ IServerWorkingCopy copy = server.createWorkingCopy();
+ IModule[] modules = new IModule[1];
+ modules[0] = SingleDeployableFactory.findModule(file
+ .getFullPath());
+ copy.modifyModules(modules, new IModule[0],
+ new NullProgressMonitor());
+ IServer saved = copy.save(false,
+ new NullProgressMonitor());
+ saved.publish(IServer.PUBLISH_INCREMENTAL,
+ new NullProgressMonitor());
+ }
+ } catch (CoreException e) {
+ IStatus status = new Status(IStatus.INFO,Activator.PLUGIN_ID,e.getMessage(),e);
+ Activator.getDefault().getLog().log(status);
+ }
+ }
+ }
+ IAction action = new RunOnServerAction(project);
+ action.run();
+ }
+
+}
15 years, 8 months
JBoss Tools SVN: r14995 - trunk/examples/plugins.
by jbosstools-commits@lists.jboss.org
Author: snjeza
Date: 2009-05-03 16:52:00 -0400 (Sun, 03 May 2009)
New Revision: 14995
Added:
trunk/examples/plugins/org.jboss.tools.seam.tutorial/
Log:
Initial import.
15 years, 8 months
JBoss Tools SVN: r14994 - in workspace: snjeza/seam-examples and 1 other directory.
by jbosstools-commits@lists.jboss.org
Author: snjeza
Date: 2009-05-03 16:24:59 -0400 (Sun, 03 May 2009)
New Revision: 14994
Added:
workspace/snjeza/seam-examples/registration2.zip
Modified:
workspace/examples/project-examples-3.0.xml
Log:
https://jira.jboss.org/jira/browse/JBIDE-4180 We should have the projects featured in Seam tutorials available in Project Examples
Modified: workspace/examples/project-examples-3.0.xml
===================================================================
--- workspace/examples/project-examples-3.0.xml 2009-05-01 13:40:20 UTC (rev 14993)
+++ workspace/examples/project-examples-3.0.xml 2009-05-03 20:24:59 UTC (rev 14994)
@@ -151,6 +151,22 @@
</project>
<project>
+ <category>Seam</category>
+ <name>registration2</name>
+ <included-projects>
+ registration,registration-ejb,registration-ear
+ </included-projects>
+ <shortDescription>Seam Registration Example - EAR</shortDescription>
+ <description>This is a trivial example for the Seam tutorial. It runs on both JBoss AS and Tomcat.
+It includes the registration,registration-ejb,registration-ear,registration-test projects.
+</description>
+ <size>8450048</size>
+ <url>
+ http://anonsvn.jboss.org/repos/jbosstools/workspace/snjeza/seam-examples/...
+ </url>
+ </project>
+
+ <project>
<category>Portlet</category>
<name>testjavaportlet</name>
<shortDescription>JBoss Java Portlet Example</shortDescription>
Added: workspace/snjeza/seam-examples/registration2.zip
===================================================================
(Binary files differ)
Property changes on: workspace/snjeza/seam-examples/registration2.zip
___________________________________________________________________
Name: svn:mime-type
+ application/octet-stream
15 years, 8 months
JBoss Tools SVN: r14993 - trunk/jbpm/plugins/org.jboss.tools.flow.jpdl4/src/org/jboss/tools/flow/jpdl4/view.
by jbosstools-commits@lists.jboss.org
Author: koen.aers(a)jboss.com
Date: 2009-05-01 09:40:20 -0400 (Fri, 01 May 2009)
New Revision: 14993
Modified:
trunk/jbpm/plugins/org.jboss.tools.flow.jpdl4/src/org/jboss/tools/flow/jpdl4/view/DetailsView.java
Log:
fix NPE if detailsview is opened without editor active
Modified: trunk/jbpm/plugins/org.jboss.tools.flow.jpdl4/src/org/jboss/tools/flow/jpdl4/view/DetailsView.java
===================================================================
--- trunk/jbpm/plugins/org.jboss.tools.flow.jpdl4/src/org/jboss/tools/flow/jpdl4/view/DetailsView.java 2009-05-01 11:53:16 UTC (rev 14992)
+++ trunk/jbpm/plugins/org.jboss.tools.flow.jpdl4/src/org/jboss/tools/flow/jpdl4/view/DetailsView.java 2009-05-01 13:40:20 UTC (rev 14993)
@@ -116,7 +116,7 @@
@SuppressWarnings("unchecked")
public Object getAdapter(Class adapter) {
- if (adapter == IPropertySheetPage.class)
+ if (adapter == IPropertySheetPage.class && getCurrentContributingPart() != null)
return getCurrentContributingPart().getAdapter(adapter);
return super.getAdapter(adapter);
}
15 years, 8 months
JBoss Tools SVN: r14992 - in trunk/jbpm/builders/org.jboss.tools.flow.jpdl4.builder: maps and 1 other directory.
by jbosstools-commits@lists.jboss.org
Author: koen.aers(a)jboss.com
Date: 2009-05-01 07:53:16 -0400 (Fri, 01 May 2009)
New Revision: 14992
Modified:
trunk/jbpm/builders/org.jboss.tools.flow.jpdl4.builder/build_local.properties
trunk/jbpm/builders/org.jboss.tools.flow.jpdl4.builder/maps/all.map
trunk/jbpm/builders/org.jboss.tools.flow.jpdl4.builder/pluginbuilder.config
Log:
getting build ready for 1.0.0.beta2
Modified: trunk/jbpm/builders/org.jboss.tools.flow.jpdl4.builder/build_local.properties
===================================================================
--- trunk/jbpm/builders/org.jboss.tools.flow.jpdl4.builder/build_local.properties 2009-05-01 11:52:29 UTC (rev 14991)
+++ trunk/jbpm/builders/org.jboss.tools.flow.jpdl4.builder/build_local.properties 2009-05-01 11:53:16 UTC (rev 14992)
@@ -1,7 +1,7 @@
# The location of this pluginbuilder project. It provides the base directory for the build scripts.
# @category localsettings
# @type Directory
-buildHome=/Users/koen/Workspace/Eclipse/3.4.1/GPD-4.0/org.jboss.tools.flow.jpdl4.builder
+buildHome=/Users/koen/Workspace/Eclipse/3.4.2/GPD-4.0/org.jboss.tools.flow.jpdl4.builder
# The directory where the build takes place. This directory WILL BE DELETED before every build.
# @category localsettings
@@ -11,7 +11,7 @@
# The eclipse build host. Must be an Eclipse SDK installation with JDT and PDE. And in the case of RCP builds the RCP Delta Pack must be included, too.
# @category localsettings
# @type Directory
-eclipseDir=/Users/koen/Software/Eclipse/SDK/3.4.1/eclipse/
+eclipseDir=/Users/koen/Software/Eclipse/SDK/3.4.2/eclipse/
# Environment for both the Eclipse build and test host. Determines baseos.
# @category localsettings
Modified: trunk/jbpm/builders/org.jboss.tools.flow.jpdl4.builder/maps/all.map
===================================================================
--- trunk/jbpm/builders/org.jboss.tools.flow.jpdl4.builder/maps/all.map 2009-05-01 11:52:29 UTC (rev 14991)
+++ trunk/jbpm/builders/org.jboss.tools.flow.jpdl4.builder/maps/all.map 2009-05-01 11:53:16 UTC (rev 14992)
@@ -1,5 +1,5 @@
-feature(a)org.jboss.tools.flow.jpdl4.feature=COPY,/Users/koen/Workspace/Eclipse/3.4.1/GPD-4.0,org.jboss.tools.flow.jpdl4.feature
-plugin(a)org.jboss.tools.flow.jpdl4=COPY,/Users/koen/Workspace/Eclipse/3.4.1/GPD-4.0,org.jboss.tools.flow.jpdl4
-plugin(a)org.jboss.tools.flow.jpdl4.multipage=COPY,/Users/koen/Workspace/Eclipse/3.4.1/GPD-4.0,org.jboss.tools.flow.jpdl4.multipage
-feature(a)org.jboss.tools.flow.common.feature=COPY,/Users/koen/Workspace/Eclipse/3.4.1/GPD-4.0,org.jboss.tools.flow.common.feature
-plugin(a)org.jboss.tools.flow.common=COPY,/Users/koen/Workspace/Eclipse/3.4.1/GPD-4.0,org.jboss.tools.flow.common
+feature(a)org.jboss.tools.flow.jpdl4.feature=COPY,/Users/koen/Workspace/Eclipse/3.4.2/GPD-4.0,org.jboss.tools.flow.jpdl4.feature
+plugin(a)org.jboss.tools.flow.jpdl4=COPY,/Users/koen/Workspace/Eclipse/3.4.2/GPD-4.0,org.jboss.tools.flow.jpdl4
+plugin(a)org.jboss.tools.flow.jpdl4.multipage=COPY,/Users/koen/Workspace/Eclipse/3.4.2/GPD-4.0,org.jboss.tools.flow.jpdl4.multipage
+feature(a)org.jboss.tools.flow.common.feature=COPY,/Users/koen/Workspace/Eclipse/3.4.2/GPD-4.0,org.jboss.tools.flow.common.feature
+plugin(a)org.jboss.tools.flow.common=COPY,/Users/koen/Workspace/Eclipse/3.4.2/GPD-4.0,org.jboss.tools.flow.common
Modified: trunk/jbpm/builders/org.jboss.tools.flow.jpdl4.builder/pluginbuilder.config
===================================================================
--- trunk/jbpm/builders/org.jboss.tools.flow.jpdl4.builder/pluginbuilder.config 2009-05-01 11:52:29 UTC (rev 14991)
+++ trunk/jbpm/builders/org.jboss.tools.flow.jpdl4.builder/pluginbuilder.config 2009-05-01 11:53:16 UTC (rev 14992)
@@ -1,4 +1,4 @@
-#Wed Apr 01 18:29:02 EDT 2009
+#Thu Apr 02 09:58:13 EDT 2009
autotestsuite.class.exclusions=.*All(Tests|PDE_Tests|_Tests|PDETests).*
pluginbuilder.features=org.jboss.tools.flow.jpdl4.feature,org.jboss.tools.flow.common.feature
pluginbuilder.is.svn=false
15 years, 8 months
JBoss Tools SVN: r14991 - in trunk/jbpm/plugins/org.jboss.tools.flow.jpdl4.multipage: src/org/jboss/tools/flow/jpdl4/multipage/editors and 1 other directory.
by jbosstools-commits@lists.jboss.org
Author: koen.aers(a)jboss.com
Date: 2009-05-01 07:52:29 -0400 (Fri, 01 May 2009)
New Revision: 14991
Modified:
trunk/jbpm/plugins/org.jboss.tools.flow.jpdl4.multipage/META-INF/MANIFEST.MF
trunk/jbpm/plugins/org.jboss.tools.flow.jpdl4.multipage/src/org/jboss/tools/flow/jpdl4/multipage/editors/MultiPageEditor.java
Log:
bump version to 1.0.0.beta2
Modified: trunk/jbpm/plugins/org.jboss.tools.flow.jpdl4.multipage/META-INF/MANIFEST.MF
===================================================================
--- trunk/jbpm/plugins/org.jboss.tools.flow.jpdl4.multipage/META-INF/MANIFEST.MF 2009-05-01 11:51:53 UTC (rev 14990)
+++ trunk/jbpm/plugins/org.jboss.tools.flow.jpdl4.multipage/META-INF/MANIFEST.MF 2009-05-01 11:52:29 UTC (rev 14991)
@@ -2,7 +2,7 @@
Bundle-ManifestVersion: 2
Bundle-Name: %pluginName
Bundle-SymbolicName: org.jboss.tools.flow.jpdl4.multipage;singleton:=true
-Bundle-Version: 1.0.0.beta1
+Bundle-Version: 1.0.0.beta2
Bundle-Activator: org.jboss.tools.flow.jpdl4.multipage.MultiPageEditorPlugin
Bundle-Vendor: %providerName
Bundle-Localization: plugin
Modified: trunk/jbpm/plugins/org.jboss.tools.flow.jpdl4.multipage/src/org/jboss/tools/flow/jpdl4/multipage/editors/MultiPageEditor.java
===================================================================
--- trunk/jbpm/plugins/org.jboss.tools.flow.jpdl4.multipage/src/org/jboss/tools/flow/jpdl4/multipage/editors/MultiPageEditor.java 2009-05-01 11:51:53 UTC (rev 14990)
+++ trunk/jbpm/plugins/org.jboss.tools.flow.jpdl4.multipage/src/org/jboss/tools/flow/jpdl4/multipage/editors/MultiPageEditor.java 2009-05-01 11:52:29 UTC (rev 14991)
@@ -99,10 +99,7 @@
if(model != null && model.getElement() != null) {
jpdlEditor.setModel(model);
((GraphicalViewer) jpdlEditor.getAdapter(GraphicalViewer.class)).setContents(model);
- } else {
- System.out.println("Ha!");
- }
-
+ }
try {
in.close();
} catch (IOException e) {
15 years, 8 months