Author: dgeraskov
Date: 2009-11-24 11:04:51 -0500 (Tue, 24 Nov 2009)
New Revision: 18806
Modified:
trunk/hibernatetools/plugins/org.hibernate.eclipse.console/plugin.xml
trunk/hibernatetools/plugins/org.hibernate.eclipse.console/src/org/hibernate/eclipse/console/ConfigurationCombo.java
trunk/hibernatetools/plugins/org.hibernate.eclipse.console/src/org/hibernate/eclipse/console/properties/HibernatePropertyPage.java
trunk/hibernatetools/plugins/org.hibernate.eclipse.console/src/org/hibernate/eclipse/console/utils/LaunchHelper.java
trunk/hibernatetools/plugins/org.hibernate.eclipse.console/src/org/hibernate/eclipse/console/views/ConsoleConfigurationPropertySource.java
trunk/hibernatetools/plugins/org.hibernate.eclipse.console/src/org/hibernate/eclipse/console/views/KnownConfigurationsProvider.java
trunk/hibernatetools/plugins/org.hibernate.eclipse.console/src/org/hibernate/eclipse/console/views/KnownConfigurationsView.java
trunk/hibernatetools/plugins/org.hibernate.eclipse.console/src/org/hibernate/eclipse/console/wizards/ConsoleConfigurationWizardPage.java
trunk/hibernatetools/plugins/org.hibernate.eclipse.console/src/org/hibernate/eclipse/console/wizards/TableFilterWizardPage.java
trunk/hibernatetools/plugins/org.hibernate.eclipse.console/src/org/hibernate/eclipse/console/workbench/KnownConfigurationsWorkbenchAdapter.java
trunk/hibernatetools/plugins/org.hibernate.eclipse.console/src/org/hibernate/eclipse/launch/CodeGenerationSettingsTab.java
trunk/hibernatetools/plugins/org.hibernate.eclipse.console/src/org/hibernate/eclipse/launch/ConsoleConfigurationMainTab.java
trunk/hibernatetools/plugins/org.hibernate.eclipse.mapper/src/org/hibernate/eclipse/mapper/editors/ChooseConsoleConfigurationDialog.java
trunk/hibernatetools/plugins/org.hibernate.eclipse.mapper/src/org/hibernate/eclipse/mapper/editors/reveng/ConsoleConfigNamePart.java
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.core/src/org/jboss/tools/hibernate/jpt/core/internal/JPAPostInstallFasetListener.java
Log:
https://jira.jboss.org/jira/browse/JBIDE-5222
Support filtering console configurations in closed or deleted projects.
Modified: trunk/hibernatetools/plugins/org.hibernate.eclipse.console/plugin.xml
===================================================================
--- trunk/hibernatetools/plugins/org.hibernate.eclipse.console/plugin.xml 2009-11-24
15:56:52 UTC (rev 18805)
+++ trunk/hibernatetools/plugins/org.hibernate.eclipse.console/plugin.xml 2009-11-24
16:04:51 UTC (rev 18806)
@@ -723,7 +723,7 @@
</moveParticipant>
</extension>
- <extension
+ <!-- extension
point="org.eclipse.ltk.core.refactoring.deleteParticipants">
<deleteParticipant
class="org.hibernate.eclipse.console.DeleteProjectParticipant"
@@ -737,7 +737,7 @@
</instanceof>
</with></enablement>
</deleteParticipant>
- </extension>
+ </extension -->
<extension
point="org.eclipse.ui.popupMenus">
<!--<objectContribution
Modified:
trunk/hibernatetools/plugins/org.hibernate.eclipse.console/src/org/hibernate/eclipse/console/ConfigurationCombo.java
===================================================================
---
trunk/hibernatetools/plugins/org.hibernate.eclipse.console/src/org/hibernate/eclipse/console/ConfigurationCombo.java 2009-11-24
15:56:52 UTC (rev 18805)
+++
trunk/hibernatetools/plugins/org.hibernate.eclipse.console/src/org/hibernate/eclipse/console/ConfigurationCombo.java 2009-11-24
16:04:51 UTC (rev 18806)
@@ -13,6 +13,7 @@
import org.hibernate.console.KnownConfigurations;
import org.hibernate.console.KnownConfigurationsAdapter;
import org.hibernate.console.KnownConfigurationsListener;
+import org.hibernate.eclipse.console.utils.LaunchHelper;
final class ConfigurationCombo extends ComboContribution {
@@ -65,8 +66,7 @@
}
protected void populateComboBox() {
- ConsoleConfiguration[] configurations = KnownConfigurations
- .getInstance().getConfigurationsSortedByName();
+ ConsoleConfiguration[] configurations =
LaunchHelper.findFilteredSortedConsoleConfigs();
final String[] names = new String[configurations.length];
for (int i = 0; i < configurations.length; i++) {
names[i] = configurations[i].getName();
Modified:
trunk/hibernatetools/plugins/org.hibernate.eclipse.console/src/org/hibernate/eclipse/console/properties/HibernatePropertyPage.java
===================================================================
---
trunk/hibernatetools/plugins/org.hibernate.eclipse.console/src/org/hibernate/eclipse/console/properties/HibernatePropertyPage.java 2009-11-24
15:56:52 UTC (rev 18805)
+++
trunk/hibernatetools/plugins/org.hibernate.eclipse.console/src/org/hibernate/eclipse/console/properties/HibernatePropertyPage.java 2009-11-24
16:04:51 UTC (rev 18806)
@@ -65,6 +65,7 @@
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.LaunchHelper;
import org.hibernate.eclipse.console.utils.ProjectUtils;
import org.osgi.service.prefs.BackingStoreException;
import org.osgi.service.prefs.Preferences;
@@ -196,7 +197,7 @@
selectedConfiguration.setLayoutData(gd);
// Populate owner text field
- ConsoleConfiguration[] configurations =
KnownConfigurations.getInstance().getConfigurationsSortedByName();
+ ConsoleConfiguration[] configurations =
LaunchHelper.findFilteredSortedConsoleConfigs();
for (int i = 0; i < configurations.length; i++) {
ConsoleConfiguration configuration = configurations[i];
selectedConfiguration.add(configuration.getName() );
Modified:
trunk/hibernatetools/plugins/org.hibernate.eclipse.console/src/org/hibernate/eclipse/console/utils/LaunchHelper.java
===================================================================
---
trunk/hibernatetools/plugins/org.hibernate.eclipse.console/src/org/hibernate/eclipse/console/utils/LaunchHelper.java 2009-11-24
15:56:52 UTC (rev 18805)
+++
trunk/hibernatetools/plugins/org.hibernate.eclipse.console/src/org/hibernate/eclipse/console/utils/LaunchHelper.java 2009-11-24
16:04:51 UTC (rev 18806)
@@ -1,5 +1,8 @@
package org.hibernate.eclipse.console.utils;
+import java.util.ArrayList;
+import java.util.List;
+
import org.eclipse.core.runtime.Assert;
import org.eclipse.core.runtime.CoreException;
import org.eclipse.core.runtime.Platform;
@@ -7,12 +10,17 @@
import org.eclipse.debug.core.ILaunchConfiguration;
import org.eclipse.debug.core.ILaunchConfigurationType;
import org.eclipse.debug.core.ILaunchManager;
+import org.eclipse.debug.internal.ui.DebugUIPlugin;
+import org.eclipse.jdt.launching.IJavaLaunchConfigurationConstants;
import org.eclipse.osgi.util.NLS;
+import org.hibernate.console.ConsoleConfiguration;
+import org.hibernate.console.KnownConfigurations;
import org.hibernate.eclipse.console.HibernateConsoleMessages;
import org.hibernate.eclipse.console.HibernateConsolePlugin;
import org.hibernate.eclipse.console.actions.AddConfigurationAction;
import org.hibernate.eclipse.launch.ICodeGenerationLaunchConstants;
+@SuppressWarnings("restriction")
public class LaunchHelper {
public static ILaunchConfiguration findHibernateLaunchConfig(String name) throws
CoreException {
@@ -20,6 +28,48 @@
ICodeGenerationLaunchConstants.CONSOLE_CONFIGURATION_LAUNCH_TYPE_ID, name);
}
+ /**
+ * UI elements should use this method as it does filtering of launch configuration
related
+ * to deleted or closed projects if the settings are set.
+ * @return
+ * @throws CoreException
+ */
+ public static ILaunchConfiguration[] findFilteredHibernateLaunchConfigs() throws
CoreException{
+ ILaunchConfiguration[] allHibernateLaunchConfigurations =
findHibernateLaunchConfigs();
+ List<ILaunchConfiguration> launchConfigurations = new
ArrayList<ILaunchConfiguration>();
+ for (ILaunchConfiguration config : allHibernateLaunchConfigurations) {
+ if (DebugUIPlugin.doLaunchConfigurationFiltering(config))
launchConfigurations.add(config);
+ }
+ return launchConfigurations.toArray(new
ILaunchConfiguration[launchConfigurations.size()]);
+ }
+
+ /**
+ * UI elements should use this method as it does filtering of console configuration
related
+ * to deleted or closed projects if the settings are set.
+ * @return
+ * @throws CoreException
+ */
+ public static ConsoleConfiguration[] findFilteredSortedConsoleConfigs() {
+ ConsoleConfiguration[] ccs =
KnownConfigurations.getInstance().getConfigurationsSortedByName();
+ List<ConsoleConfiguration> consoleConfigurations = new
ArrayList<ConsoleConfiguration>();
+ for (ConsoleConfiguration cc : ccs) {
+ boolean isAccepted = true;
+ try {
+ ILaunchConfiguration config = LaunchHelper.findHibernateLaunchConfig(cc.getName());
+ if (config != null){
+ isAccepted = DebugUIPlugin.doLaunchConfigurationFiltering(config);
+ }
+ } catch (CoreException e) {
+ HibernateConsolePlugin.getDefault().showError(null, e.getLocalizedMessage(), e);
+ }
+ if (isAccepted){
+ consoleConfigurations .add(cc);
+ }
+ }
+ return consoleConfigurations.toArray(new
ConsoleConfiguration[consoleConfigurations.size()]);
+
+ }
+
public static ILaunchConfigurationType getHibernateLaunchConfigsType(){
ILaunchManager launchManager = DebugPlugin.getDefault().getLaunchManager();
return launchManager.getLaunchConfigurationType(
@@ -53,6 +103,17 @@
return null;
}
+ public static ILaunchConfiguration[] findProjectRelatedHibernateLaunchConfigs(String
projectName) throws CoreException {
+ ILaunchManager launchManager = DebugPlugin.getDefault().getLaunchManager();
+ ILaunchConfiguration[] configs =
launchManager.getLaunchConfigurations(getHibernateLaunchConfigsType());
+ List<ILaunchConfiguration> list = new ArrayList<ILaunchConfiguration>();
+ for(int i = 0; i < configs.length && configs[i].exists(); i++) {
+ String project =
configs[i].getAttribute(IJavaLaunchConfigurationConstants.ATTR_PROJECT_NAME,
(String)null);
+ if (projectName.equals(project)) list.add(configs[i]);
+ }
+ return list.toArray(new ILaunchConfiguration[list.size()]);
+ }
+
public static String verifyConfigurationName(String currentName) {
if (currentName == null || currentName.length() < 1) {
return HibernateConsoleMessages.ConsoleConfigurationWizardPage_name_must_specified;
Modified:
trunk/hibernatetools/plugins/org.hibernate.eclipse.console/src/org/hibernate/eclipse/console/views/ConsoleConfigurationPropertySource.java
===================================================================
---
trunk/hibernatetools/plugins/org.hibernate.eclipse.console/src/org/hibernate/eclipse/console/views/ConsoleConfigurationPropertySource.java 2009-11-24
15:56:52 UTC (rev 18805)
+++
trunk/hibernatetools/plugins/org.hibernate.eclipse.console/src/org/hibernate/eclipse/console/views/ConsoleConfigurationPropertySource.java 2009-11-24
16:04:51 UTC (rev 18806)
@@ -23,15 +23,18 @@
import java.util.ArrayList;
import java.util.Arrays;
+import java.util.Collections;
import java.util.List;
import org.eclipse.core.resources.IProject;
+import org.eclipse.core.resources.IResource;
import org.eclipse.core.resources.ResourcesPlugin;
import org.eclipse.core.runtime.CoreException;
import org.eclipse.datatools.connectivity.IConnectionProfile;
import org.eclipse.datatools.connectivity.ProfileManager;
import org.eclipse.debug.core.ILaunchConfiguration;
import org.eclipse.debug.core.ILaunchConfigurationWorkingCopy;
+import org.eclipse.debug.internal.core.LaunchConfiguration;
import org.eclipse.jdt.launching.IJavaLaunchConfigurationConstants;
import org.eclipse.jface.viewers.ICellEditorValidator;
import org.eclipse.jface.viewers.LabelProvider;
@@ -50,6 +53,7 @@
import org.hibernate.eclipse.console.utils.LaunchHelper;
import org.hibernate.eclipse.launch.IConsoleConfigurationLaunchConstants;
+@SuppressWarnings("restriction")
public class ConsoleConfigurationPropertySource implements IPropertySource {
private ConsoleConfiguration cfg;
@@ -220,7 +224,16 @@
ILaunchConfiguration lc =
HibernateConsolePlugin.getDefault().findLaunchConfig(cfg.getName());
if (lc != null){
ILaunchConfigurationWorkingCopy wc = lc.getWorkingCopy();
- wc.setAttribute(IJavaLaunchConfigurationConstants.ATTR_PROJECT_NAME,
getSortedProjectNames()[index]);
+ String projectName = getSortedProjectNames()[index];
+ wc.setAttribute(IJavaLaunchConfigurationConstants.ATTR_PROJECT_NAME, projectName);
+ if (projectName != null){
+ wc.setAttribute(LaunchConfiguration.ATTR_MAPPED_RESOURCE_PATHS,
+ Collections.singletonList(projectName));
+ wc.setAttribute(LaunchConfiguration.ATTR_MAPPED_RESOURCE_TYPES,
Collections.singletonList(Integer.toString(IResource.PROJECT)));
+ } else {
+ wc.removeAttribute(LaunchConfiguration.ATTR_MAPPED_RESOURCE_PATHS);
+ wc.removeAttribute(LaunchConfiguration.ATTR_MAPPED_RESOURCE_TYPES);
+ }
wc.doSave();
} else {
HibernateConsolePlugin.getDefault().log("Can't find Console Configuration
\"" + cfg.getName() + "\"");//$NON-NLS-1$//$NON-NLS-2$
Modified:
trunk/hibernatetools/plugins/org.hibernate.eclipse.console/src/org/hibernate/eclipse/console/views/KnownConfigurationsProvider.java
===================================================================
---
trunk/hibernatetools/plugins/org.hibernate.eclipse.console/src/org/hibernate/eclipse/console/views/KnownConfigurationsProvider.java 2009-11-24
15:56:52 UTC (rev 18805)
+++
trunk/hibernatetools/plugins/org.hibernate.eclipse.console/src/org/hibernate/eclipse/console/views/KnownConfigurationsProvider.java 2009-11-24
16:04:51 UTC (rev 18806)
@@ -21,8 +21,20 @@
*/
package org.hibernate.eclipse.console.views;
+import org.eclipse.core.resources.IProject;
+import org.eclipse.core.resources.IResource;
+import org.eclipse.core.resources.IResourceChangeEvent;
+import org.eclipse.core.resources.IResourceChangeListener;
+import org.eclipse.core.resources.IResourceDelta;
+import org.eclipse.core.resources.IResourceDeltaVisitor;
+import org.eclipse.core.resources.ResourcesPlugin;
+import org.eclipse.core.runtime.CoreException;
import org.eclipse.core.runtime.IAdaptable;
import org.eclipse.core.runtime.Platform;
+import org.eclipse.debug.core.ILaunchConfiguration;
+import org.eclipse.debug.internal.ui.IInternalDebugUIConstants;
+import org.eclipse.jface.util.IPropertyChangeListener;
+import org.eclipse.jface.util.PropertyChangeEvent;
import org.eclipse.jface.viewers.AbstractTreeViewer;
import org.eclipse.jface.viewers.TreeViewer;
import org.eclipse.jface.viewers.Viewer;
@@ -32,13 +44,18 @@
import org.hibernate.console.ConsoleConfiguration;
import org.hibernate.console.KnownConfigurations;
import org.hibernate.console.KnownConfigurationsListener;
+import org.hibernate.eclipse.console.utils.LaunchHelper;
import org.hibernate.eclipse.console.workbench.DeferredContentProvider;
-public class KnownConfigurationsProvider extends DeferredContentProvider implements
KnownConfigurationsListener {
+@SuppressWarnings("restriction")
+public class KnownConfigurationsProvider extends DeferredContentProvider implements
KnownConfigurationsListener,
+ IResourceChangeListener, IPropertyChangeListener {
private TreeViewer tv;
public KnownConfigurationsProvider() {
+ ResourcesPlugin.getWorkspace().addResourceChangeListener(this,
IResourceChangeEvent.POST_CHANGE | IResourceChangeEvent.PRE_DELETE);
+
}
public void inputChanged(Viewer v, Object oldInput, Object newInput) {
@@ -108,4 +125,68 @@
public void configurationBuilt(ConsoleConfiguration ccfg) {
//TODO refresh tree?
}
+
+ public void resourceChanged(IResourceChangeEvent event) {
+ IResourceDelta delta = event.getDelta();
+ if (delta != null) {
+ try {
+ delta.accept(new KnownConfigurationsVisitor());
+ } catch (CoreException e) {
+ e.printStackTrace();
+ }
+ }
+ }
+
+ class KnownConfigurationsVisitor implements IResourceDeltaVisitor {
+
+ /**
+ * @see IResourceDeltaVisitor#visit(IResourceDelta)
+ */
+ public boolean visit(IResourceDelta delta) {
+ if (delta == null) {
+ return false;
+ }
+ if (0 != (delta.getFlags() & IResourceDelta.OPEN)) {
+ if (delta.getResource() instanceof IProject) {
+ IProject project = (IProject)delta.getResource();
+ if (project.isOpen()) {
+ try {
+ ILaunchConfiguration[] configs =
LaunchHelper.findProjectRelatedHibernateLaunchConfigs(project.getName());
+ if (configs.length > 0) refreshTree();
+ } catch (CoreException e) {
+ e.printStackTrace();
+ refreshTree();
+ }
+ }
+ }
+ return false;
+ }
+ IResource resource = delta.getResource();
+ if (resource instanceof IProject) {
+ IProject project = (IProject)resource;
+ switch (delta.getKind()) {
+ case IResourceDelta.ADDED:
+ case IResourceDelta.REMOVED :
+ try {
+ ILaunchConfiguration[] configs =
LaunchHelper.findProjectRelatedHibernateLaunchConfigs(project.getName());
+ if (configs.length > 0) refreshTree();
+ } catch (CoreException e) {
+ e.printStackTrace();
+ refreshTree();
+ }
+ }
+ return false;
+ }
+ return true;
+ }
+ }
+
+ public void propertyChange(PropertyChangeEvent event) {
+ if(event.getProperty().equals(IInternalDebugUIConstants.PREF_FILTER_LAUNCH_CLOSED) ||
+ event.getProperty().equals(IInternalDebugUIConstants.PREF_FILTER_LAUNCH_DELETED)) {
+ refreshTree();
+ }
+ }
+
+
}
\ No newline at end of file
Modified:
trunk/hibernatetools/plugins/org.hibernate.eclipse.console/src/org/hibernate/eclipse/console/views/KnownConfigurationsView.java
===================================================================
---
trunk/hibernatetools/plugins/org.hibernate.eclipse.console/src/org/hibernate/eclipse/console/views/KnownConfigurationsView.java 2009-11-24
15:56:52 UTC (rev 18805)
+++
trunk/hibernatetools/plugins/org.hibernate.eclipse.console/src/org/hibernate/eclipse/console/views/KnownConfigurationsView.java 2009-11-24
16:04:51 UTC (rev 18806)
@@ -24,6 +24,7 @@
import java.io.FileNotFoundException;
+import org.eclipse.debug.internal.ui.DebugUIPlugin;
import org.eclipse.jdt.core.JavaModelException;
import org.eclipse.jface.action.Action;
import org.eclipse.jface.action.IMenuListener;
@@ -38,6 +39,8 @@
import org.eclipse.jface.viewers.TreeSelection;
import org.eclipse.jface.viewers.TreeViewer;
import org.eclipse.swt.SWT;
+import org.eclipse.swt.events.DisposeEvent;
+import org.eclipse.swt.events.DisposeListener;
import org.eclipse.swt.widgets.Composite;
import org.eclipse.swt.widgets.Menu;
import org.eclipse.ui.IActionBars;
@@ -64,6 +67,7 @@
* @author max
*
*/
+@SuppressWarnings("restriction")
public class KnownConfigurationsView extends ViewPart {
public static final String ID =
"org.hibernate.eclipse.console.views.KnownConfigurationsView"; //$NON-NLS-1$
@@ -88,8 +92,17 @@
viewer.setLabelProvider(new AnyAdaptableLabelProvider());
- viewer.setContentProvider(new KnownConfigurationsProvider());
+ final KnownConfigurationsProvider cp = new KnownConfigurationsProvider();
+ viewer.setContentProvider(cp);
+ DebugUIPlugin.getDefault().getPreferenceStore().addPropertyChangeListener(cp);
+ viewer.getTree().addDisposeListener(new DisposeListener() {
+
+ public void widgetDisposed(DisposeEvent e) {
+ DebugUIPlugin.getDefault().getPreferenceStore().removePropertyChangeListener(cp);
+ }
+ });
+
//viewer.setInput(KnownConfigurations.getInstance().getRootNode() );
viewer.setInput( KnownConfigurations.getInstance() );
Modified:
trunk/hibernatetools/plugins/org.hibernate.eclipse.console/src/org/hibernate/eclipse/console/wizards/ConsoleConfigurationWizardPage.java
===================================================================
---
trunk/hibernatetools/plugins/org.hibernate.eclipse.console/src/org/hibernate/eclipse/console/wizards/ConsoleConfigurationWizardPage.java 2009-11-24
15:56:52 UTC (rev 18805)
+++
trunk/hibernatetools/plugins/org.hibernate.eclipse.console/src/org/hibernate/eclipse/console/wizards/ConsoleConfigurationWizardPage.java 2009-11-24
16:04:51 UTC (rev 18806)
@@ -23,6 +23,7 @@
import java.lang.reflect.InvocationTargetException;
import java.util.ArrayList;
+import java.util.Collections;
import java.util.List;
import org.eclipse.core.resources.IContainer;
@@ -31,9 +32,11 @@
import org.eclipse.core.resources.ResourcesPlugin;
import org.eclipse.core.runtime.CoreException;
import org.eclipse.core.runtime.IPath;
+import org.eclipse.core.runtime.Path;
import org.eclipse.debug.core.DebugPlugin;
import org.eclipse.debug.core.ILaunchConfigurationWorkingCopy;
import org.eclipse.debug.core.ILaunchManager;
+import org.eclipse.debug.internal.core.LaunchConfiguration;
import org.eclipse.debug.ui.ILaunchConfigurationDialog;
import org.eclipse.debug.ui.ILaunchConfigurationTab;
import org.eclipse.jdt.core.IJavaElement;
@@ -81,6 +84,7 @@
*
* @author max
*/
+@SuppressWarnings("restriction")
public class ConsoleConfigurationWizardPage extends WizardPage implements
ILaunchConfigurationDialog {
@@ -421,9 +425,14 @@
static protected void setProjAttribute(ILaunchConfigurationWorkingCopy
currentLaunchConfig, String attr, IJavaProject proj) {
if (proj != null) {
currentLaunchConfig.setAttribute(attr, nonEmptyTrimOrNull(proj.getElementName()));
+ currentLaunchConfig.setAttribute(LaunchConfiguration.ATTR_MAPPED_RESOURCE_PATHS,
+ Collections.singletonList(new
Path(nonEmptyTrimOrNull(proj.getElementName())).makeAbsolute().toString()));
+ currentLaunchConfig.setAttribute(LaunchConfiguration.ATTR_MAPPED_RESOURCE_TYPES,
Collections.singletonList(Integer.toString(IResource.PROJECT)));
}
else {
currentLaunchConfig.setAttribute(attr, (String)null);
+ currentLaunchConfig.removeAttribute(LaunchConfiguration.ATTR_MAPPED_RESOURCE_PATHS);
+ currentLaunchConfig.removeAttribute(LaunchConfiguration.ATTR_MAPPED_RESOURCE_TYPES);
}
}
Modified:
trunk/hibernatetools/plugins/org.hibernate.eclipse.console/src/org/hibernate/eclipse/console/wizards/TableFilterWizardPage.java
===================================================================
---
trunk/hibernatetools/plugins/org.hibernate.eclipse.console/src/org/hibernate/eclipse/console/wizards/TableFilterWizardPage.java 2009-11-24
15:56:52 UTC (rev 18805)
+++
trunk/hibernatetools/plugins/org.hibernate.eclipse.console/src/org/hibernate/eclipse/console/wizards/TableFilterWizardPage.java 2009-11-24
16:04:51 UTC (rev 18806)
@@ -35,13 +35,14 @@
import org.eclipse.swt.layout.GridLayout;
import org.eclipse.swt.widgets.Composite;
import org.hibernate.console.ConsoleConfiguration;
-import org.hibernate.console.KnownConfigurations;
import org.hibernate.eclipse.console.HibernateConsoleMessages;
import org.hibernate.eclipse.console.model.IReverseEngineeringDefinition;
import org.hibernate.eclipse.console.model.ITableFilter;
import org.hibernate.eclipse.console.model.impl.ReverseEngineeringDefinitionImpl;
+import org.hibernate.eclipse.console.utils.LaunchHelper;
+@SuppressWarnings("restriction")
public class TableFilterWizardPage extends WizardPage {
// TODO: clean this up to use a shared wizard model
@@ -75,7 +76,7 @@
consoleConfigurationName = new ComboDialogField(SWT.READ_ONLY);
consoleConfigurationName.setLabelText(HibernateConsoleMessages.TableFilterWizardPage_console_configuration);
- ConsoleConfiguration[] cfg =
KnownConfigurations.getInstance().getConfigurationsSortedByName();
+ ConsoleConfiguration[] cfg = LaunchHelper.findFilteredSortedConsoleConfigs();
String[] names = new String[cfg.length];
for (int i = 0; i < cfg.length; i++) {
ConsoleConfiguration configuration = cfg[i];
Modified:
trunk/hibernatetools/plugins/org.hibernate.eclipse.console/src/org/hibernate/eclipse/console/workbench/KnownConfigurationsWorkbenchAdapter.java
===================================================================
---
trunk/hibernatetools/plugins/org.hibernate.eclipse.console/src/org/hibernate/eclipse/console/workbench/KnownConfigurationsWorkbenchAdapter.java 2009-11-24
15:56:52 UTC (rev 18805)
+++
trunk/hibernatetools/plugins/org.hibernate.eclipse.console/src/org/hibernate/eclipse/console/workbench/KnownConfigurationsWorkbenchAdapter.java 2009-11-24
16:04:51 UTC (rev 18806)
@@ -26,14 +26,13 @@
import org.eclipse.jface.resource.ImageDescriptor;
import org.eclipse.ui.progress.IDeferredWorkbenchAdapter;
import org.eclipse.ui.progress.IElementCollector;
-import org.hibernate.console.KnownConfigurations;
import org.hibernate.eclipse.console.HibernateConsoleMessages;
+import org.hibernate.eclipse.console.utils.LaunchHelper;
public class KnownConfigurationsWorkbenchAdapter implements IDeferredWorkbenchAdapter {
public Object[] getChildren(Object o) {
- KnownConfigurations kc = (KnownConfigurations) o;
- return kc.getConfigurationsSortedByName();
+ return LaunchHelper.findFilteredSortedConsoleConfigs();
}
public ImageDescriptor getImageDescriptor(Object object) {
Modified:
trunk/hibernatetools/plugins/org.hibernate.eclipse.console/src/org/hibernate/eclipse/launch/CodeGenerationSettingsTab.java
===================================================================
---
trunk/hibernatetools/plugins/org.hibernate.eclipse.console/src/org/hibernate/eclipse/launch/CodeGenerationSettingsTab.java 2009-11-24
15:56:52 UTC (rev 18805)
+++
trunk/hibernatetools/plugins/org.hibernate.eclipse.console/src/org/hibernate/eclipse/launch/CodeGenerationSettingsTab.java 2009-11-24
16:04:51 UTC (rev 18806)
@@ -58,11 +58,11 @@
import org.hibernate.cfg.reveng.ReverseEngineeringStrategy;
import org.hibernate.console.ConsoleConfiguration;
import org.hibernate.console.ImageConstants;
-import org.hibernate.console.KnownConfigurations;
import org.hibernate.eclipse.console.HibernateConsoleMessages;
import org.hibernate.eclipse.console.HibernateConsolePlugin;
import org.hibernate.eclipse.console.utils.DialogSelectionHelper;
import org.hibernate.eclipse.console.utils.EclipseImages;
+import org.hibernate.eclipse.console.utils.LaunchHelper;
import org.hibernate.eclipse.console.wizards.NewReverseEngineeringFileWizard;
@SuppressWarnings("restriction")
@@ -113,7 +113,7 @@
consoleConfigurationName = new ComboDialogField(SWT.READ_ONLY);
consoleConfigurationName.setLabelText(HibernateConsoleMessages.CodeGenerationSettingsTab_console_configuration);
- ConsoleConfiguration[] cfg =
KnownConfigurations.getInstance().getConfigurationsSortedByName();
+ ConsoleConfiguration[] cfg = LaunchHelper.findFilteredSortedConsoleConfigs();
String[] names = new String[cfg.length];
for (int i = 0; i < cfg.length; i++) {
ConsoleConfiguration configuration = cfg[i];
Modified:
trunk/hibernatetools/plugins/org.hibernate.eclipse.console/src/org/hibernate/eclipse/launch/ConsoleConfigurationMainTab.java
===================================================================
---
trunk/hibernatetools/plugins/org.hibernate.eclipse.console/src/org/hibernate/eclipse/launch/ConsoleConfigurationMainTab.java 2009-11-24
15:56:52 UTC (rev 18805)
+++
trunk/hibernatetools/plugins/org.hibernate.eclipse.console/src/org/hibernate/eclipse/launch/ConsoleConfigurationMainTab.java 2009-11-24
16:04:51 UTC (rev 18806)
@@ -3,6 +3,8 @@
*/
package org.hibernate.eclipse.launch;
+import java.util.Collections;
+
import org.eclipse.core.resources.IFile;
import org.eclipse.core.resources.IResource;
import org.eclipse.core.runtime.CoreException;
@@ -10,6 +12,7 @@
import org.eclipse.core.runtime.Path;
import org.eclipse.debug.core.ILaunchConfiguration;
import org.eclipse.debug.core.ILaunchConfigurationWorkingCopy;
+import org.eclipse.debug.internal.core.LaunchConfiguration;
import org.eclipse.debug.internal.ui.SWTFactory;
import org.eclipse.jdt.core.IJavaProject;
import org.eclipse.jdt.launching.IJavaLaunchConfigurationConstants;
@@ -165,9 +168,17 @@
public void performApply(ILaunchConfigurationWorkingCopy configuration) {
-
+ String projectName = nonEmptyTrimOrNull( projectNameText );
configuration.setAttribute(IConsoleConfigurationLaunchConstants.CONFIGURATION_FACTORY,
getConfigurationMode().toString());
- configuration.setAttribute(IJavaLaunchConfigurationConstants.ATTR_PROJECT_NAME,
nonEmptyTrimOrNull( projectNameText ));
+ configuration.setAttribute(IJavaLaunchConfigurationConstants.ATTR_PROJECT_NAME,
projectName);
+ if (projectName != null){
+ configuration.setAttribute(LaunchConfiguration.ATTR_MAPPED_RESOURCE_PATHS,
+ Collections.singletonList(nonEmptyTrimOrNull( projectName )));
+ configuration.setAttribute(LaunchConfiguration.ATTR_MAPPED_RESOURCE_TYPES,
Collections.singletonList(Integer.toString(IResource.PROJECT)));
+ } else {
+ configuration.removeAttribute(LaunchConfiguration.ATTR_MAPPED_RESOURCE_PATHS);
+ configuration.removeAttribute(LaunchConfiguration.ATTR_MAPPED_RESOURCE_TYPES);
+ }
configuration.setAttribute(IConsoleConfigurationLaunchConstants.PROPERTY_FILE,
nonEmptyTrimOrNull(propertyFileText));
configuration.setAttribute(IConsoleConfigurationLaunchConstants.CFG_XML_FILE,
nonEmptyTrimOrNull(configurationFileText));
configuration.setAttribute(IConsoleConfigurationLaunchConstants.PERSISTENCE_UNIT_NAME,
nonEmptyTrimOrNull(persistenceUnitNameText));
Modified:
trunk/hibernatetools/plugins/org.hibernate.eclipse.mapper/src/org/hibernate/eclipse/mapper/editors/ChooseConsoleConfigurationDialog.java
===================================================================
---
trunk/hibernatetools/plugins/org.hibernate.eclipse.mapper/src/org/hibernate/eclipse/mapper/editors/ChooseConsoleConfigurationDialog.java 2009-11-24
15:56:52 UTC (rev 18805)
+++
trunk/hibernatetools/plugins/org.hibernate.eclipse.mapper/src/org/hibernate/eclipse/mapper/editors/ChooseConsoleConfigurationDialog.java 2009-11-24
16:04:51 UTC (rev 18806)
@@ -16,7 +16,7 @@
import org.eclipse.swt.widgets.Label;
import org.eclipse.swt.widgets.Shell;
import org.hibernate.console.ConsoleConfiguration;
-import org.hibernate.console.KnownConfigurations;
+import org.hibernate.eclipse.console.utils.LaunchHelper;
import org.hibernate.eclipse.mapper.MapperMessages;
public class ChooseConsoleConfigurationDialog extends TitleAreaDialog {
@@ -103,7 +103,7 @@
}
private void setInitialTextValues(Combo text) {
- ConsoleConfiguration[] recentWorkspaces =
KnownConfigurations.getInstance().getConfigurationsSortedByName();
+ ConsoleConfiguration[] recentWorkspaces =
LaunchHelper.findFilteredSortedConsoleConfigs();
for (int i = 0; i < recentWorkspaces.length; ++i) {
text.add(recentWorkspaces[i].getName());
}
Modified:
trunk/hibernatetools/plugins/org.hibernate.eclipse.mapper/src/org/hibernate/eclipse/mapper/editors/reveng/ConsoleConfigNamePart.java
===================================================================
---
trunk/hibernatetools/plugins/org.hibernate.eclipse.mapper/src/org/hibernate/eclipse/mapper/editors/reveng/ConsoleConfigNamePart.java 2009-11-24
15:56:52 UTC (rev 18805)
+++
trunk/hibernatetools/plugins/org.hibernate.eclipse.mapper/src/org/hibernate/eclipse/mapper/editors/reveng/ConsoleConfigNamePart.java 2009-11-24
16:04:51 UTC (rev 18806)
@@ -30,8 +30,8 @@
import org.eclipse.ui.forms.IManagedForm;
import org.eclipse.ui.forms.widgets.FormToolkit;
import org.hibernate.console.ConsoleConfiguration;
-import org.hibernate.console.KnownConfigurations;
import org.hibernate.eclipse.console.model.IReverseEngineeringDefinition;
+import org.hibernate.eclipse.console.utils.LaunchHelper;
import org.hibernate.eclipse.mapper.MapperMessages;
import org.hibernate.eclipse.mapper.MapperPlugin;
import org.hibernate.eclipse.mapper.editors.ReverseEngineeringEditor;
@@ -76,7 +76,7 @@
text.setEditable(false);
adaptRecursively(toolkit, text);
- ConsoleConfiguration[] cfg =
KnownConfigurations.getInstance().getConfigurationsSortedByName();
+ ConsoleConfiguration[] cfg = LaunchHelper.findFilteredSortedConsoleConfigs();
String[] names = new String[cfg.length];
for (int i = 0; i < cfg.length; i++) {
ConsoleConfiguration configuration = cfg[i];
Modified:
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.core/src/org/jboss/tools/hibernate/jpt/core/internal/JPAPostInstallFasetListener.java
===================================================================
---
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.core/src/org/jboss/tools/hibernate/jpt/core/internal/JPAPostInstallFasetListener.java 2009-11-24
15:56:52 UTC (rev 18805)
+++
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.core/src/org/jboss/tools/hibernate/jpt/core/internal/JPAPostInstallFasetListener.java 2009-11-24
16:04:51 UTC (rev 18806)
@@ -11,16 +11,20 @@
package org.jboss.tools.hibernate.jpt.core.internal;
import java.util.ArrayList;
+import java.util.Collections;
import java.util.List;
import java.util.regex.Pattern;
import org.eclipse.core.resources.IProject;
+import org.eclipse.core.resources.IResource;
import org.eclipse.core.runtime.CoreException;
+import org.eclipse.core.runtime.Path;
import org.eclipse.debug.core.DebugPlugin;
import org.eclipse.debug.core.ILaunchConfiguration;
import org.eclipse.debug.core.ILaunchConfigurationType;
import org.eclipse.debug.core.ILaunchConfigurationWorkingCopy;
import org.eclipse.debug.core.ILaunchManager;
+import org.eclipse.debug.internal.core.LaunchConfiguration;
import org.eclipse.jdt.launching.IJavaLaunchConfigurationConstants;
import org.eclipse.jpt.core.JptCorePlugin;
import org.eclipse.wst.common.project.facet.core.events.IFacetedProjectEvent;
@@ -75,7 +79,7 @@
for (int i = 0; i < lcs.length; i++){
ILaunchConfiguration lc = lcs[i];
if (project.getName().equals(
- lc.getAttribute(IJavaLaunchConfigurationConstants.ATTR_PROJECT_NAME,
""))){//lc uses this project //$NON-NLS-1$
+ lc.getAttribute(IJavaLaunchConfigurationConstants.ATTR_PROJECT_NAME,
(String)null))){//lc uses this project //$NON-NLS-1$
if (project.getName().equals(lc.getName())) return lc;
configs.add(lc);
}
@@ -96,11 +100,14 @@
ILaunchConfigurationWorkingCopy wc;
try {
wc = lct.newInstance(null, launchName);
+ wc.setAttribute(LaunchConfiguration.ATTR_MAPPED_RESOURCE_PATHS,
+ Collections.singletonList(new Path(project.getName()).makeAbsolute().toString()));
+ wc.setAttribute(LaunchConfiguration.ATTR_MAPPED_RESOURCE_TYPES,
Collections.singletonList(Integer.toString(IResource.PROJECT)));
wc.setAttribute(IConsoleConfigurationLaunchConstants.CONFIGURATION_FACTORY,
ConfigurationMode.JPA.toString());
wc.setAttribute(IJavaLaunchConfigurationConstants.ATTR_PROJECT_NAME,
project.getName());
wc.setAttribute(IJavaLaunchConfigurationConstants.ATTR_DEFAULT_CLASSPATH, true );
wc.setAttribute(IConsoleConfigurationLaunchConstants.FILE_MAPPINGS,
(List<String>)null);
- wc.setAttribute(IConsoleConfigurationLaunchConstants.USE_JPA_PROJECT_PROFILE,
"true");//$NON-NLS-1$
+ wc.setAttribute(IConsoleConfigurationLaunchConstants.USE_JPA_PROJECT_PROFILE,
Boolean.toString(true));
wc.doSave();
ProjectUtils.toggleHibernateOnProject(project, true, launchName);