### Eclipse Workspace Patch 1.0
#P org.hibernate.eclipse.console_3.1.x
Index: src/org/hibernate/eclipse/console/HibernateConsoleMessages.java
===================================================================
--- src/org/hibernate/eclipse/console/HibernateConsoleMessages.java (revision 20828)
+++ src/org/hibernate/eclipse/console/HibernateConsoleMessages.java (working copy)
@@ -102,6 +102,8 @@
public static String HibernateConsolePreferencePage_text_pref;
//
public static String HibernatePropertyPage_default_hibernate_console_config;
+
+ public static String HibernatePropertyPage_details;
public static String HibernatePropertyPage_enable_hibernate3_support;
public static String HibernatePropertyPage_open_url;
public static String HibernatePropertyPage_unable_open_webbrowser_for_url;
Index: src/org/hibernate/eclipse/console/HibernateConsoleMessages.properties
===================================================================
--- src/org/hibernate/eclipse/console/HibernateConsoleMessages.properties (revision 20828)
+++ src/org/hibernate/eclipse/console/HibernateConsoleMessages.properties (working copy)
@@ -95,6 +95,7 @@
HibernateConsolePreferencePage_text_pref=A &text preference:
HibernatePropertyPage_default_hibernate_console_config=Default Hibernate Console configuration:
+HibernatePropertyPage_details=Details ...
HibernatePropertyPage_enable_hibernate3_support=Enable Hibernate 3 support
HibernatePropertyPage_open_url=Open URL
HibernatePropertyPage_unable_open_webbrowser_for_url=Unable to open webbrowser for url:
Index: src/org/hibernate/eclipse/console/properties/HibernatePropertyPage.java
===================================================================
--- src/org/hibernate/eclipse/console/properties/HibernatePropertyPage.java (revision 20828)
+++ src/org/hibernate/eclipse/console/properties/HibernatePropertyPage.java (working copy)
@@ -54,6 +54,7 @@
import org.eclipse.swt.widgets.Composite;
import org.eclipse.swt.widgets.Control;
import org.eclipse.swt.widgets.Label;
+import org.eclipse.swt.widgets.Link;
import org.eclipse.ui.PartInitException;
import org.eclipse.ui.PlatformUI;
import org.eclipse.ui.browser.IWebBrowser;
@@ -64,12 +65,14 @@
import org.hibernate.console.KnownConfigurations;
import org.hibernate.eclipse.console.HibernateConsoleMessages;
import org.hibernate.eclipse.console.HibernateConsolePlugin;
+import org.hibernate.eclipse.console.actions.EditConsoleConfiguration;
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;
+@SuppressWarnings("restriction")
public class HibernatePropertyPage extends PropertyPage {
Control[] settings;
@@ -78,11 +81,15 @@
private Combo selectedConfiguration;
+ private Link details;
+
private Button enableNamingStrategy;
private Label nsSeparator;
private boolean initNamingStrategy;
+
+ private static final String NONE = ""; //$NON-NLS-1$
/**
@@ -185,25 +192,43 @@
}
private void addSecondSection(Composite parent) {
- Composite settingsPart = createDefaultComposite(parent,2);
-
// Label for owner field
- Label ownerLabel = new Label(settingsPart, SWT.NONE);
+ Label ownerLabel = new Label(parent, SWT.NONE);
ownerLabel.setText(HibernateConsoleMessages.HibernatePropertyPage_default_hibernate_console_config);
- selectedConfiguration = new Combo(parent, SWT.DROP_DOWN);
+ Composite settingsPart = createDefaultComposite(parent,2);
+ selectedConfiguration = new Combo(settingsPart, SWT.DROP_DOWN | SWT.READ_ONLY);
GridData gd = new GridData();
gd.widthHint = convertWidthInCharsToPixels(50);
selectedConfiguration.setLayoutData(gd);
+ selectedConfiguration.add(NONE);
// Populate owner text field
ConsoleConfiguration[] configurations = LaunchHelper.findFilteredSortedConsoleConfigs();
for (int i = 0; i < configurations.length; i++) {
ConsoleConfiguration configuration = configurations[i];
selectedConfiguration.add(configuration.getName() );
}
+
+ details = new Link(settingsPart, SWT.NONE);
+ details.setText(HibernateConsoleMessages.HibernatePropertyPage_details);
+ details.addSelectionListener(new SelectionAdapter() {
+ public void widgetSelected(SelectionEvent e) {
+ ConsoleConfiguration config = KnownConfigurations.getInstance().find(selectedConfiguration.getText());
+ if (config != null) {
+ new EditConsoleConfiguration(config).run();
+ }
+ }
+ });
+
+ selectedConfiguration.addSelectionListener(new SelectionAdapter() {
+ public void widgetSelected(SelectionEvent e) {
+ details.setEnabled(selectedConfiguration.getSelectionIndex() != 0);
+ }
+ });
+
- settings = new Control[] { ownerLabel, selectedConfiguration };
+ settings = new Control[] { ownerLabel, selectedConfiguration, details};
}
private void addThirdSection(Composite parent) {
@@ -255,7 +280,7 @@
protected void performDefaults() {
enableHibernate.setSelection(false);
- selectedConfiguration.setText(""); //$NON-NLS-1$
+ selectedConfiguration.select(0);
}
private boolean isHibernateJpaProject(){
@@ -293,9 +318,10 @@
String cfg = node.get(HibernatePropertiesConstants.DEFAULT_CONFIGURATION, project.getName() );
ConsoleConfiguration configuration = KnownConfigurations.getInstance().find(cfg);
if(configuration==null) {
- selectedConfiguration.setText(""); //$NON-NLS-1$
+ selectedConfiguration.select(0);
+ details.setEnabled(false);
} else {
- selectedConfiguration.setText(cfg);
+ selectedConfiguration.setText(cfg);
}
initNamingStrategy = node.getBoolean(HibernatePropertiesConstants.NAMING_STRATEGY_ENABLED, true);
enableNamingStrategy.setSelection(initNamingStrategy);
@@ -313,7 +339,6 @@
try {
node.flush();
final IWorkspaceRunnable wr = new IWorkspaceRunnable() {
- @SuppressWarnings("restriction")
public void run(IProgressMonitor monitor)
throws CoreException {
JpaModelManager.instance().rebuildJpaProject(getProject());
@@ -338,7 +363,7 @@
new ProgressMonitorDialog(getShell()).run(true, false, op);
}
catch (InterruptedException e) {
- return false;
+ return false;
}
catch (InvocationTargetException e) {
final Throwable te = e.getTargetException();
@@ -355,7 +380,8 @@
}
public boolean performOk() {
- ProjectUtils.toggleHibernateOnProject( getProject(), enableHibernate.getSelection(), selectedConfiguration.getText());
+ ProjectUtils.toggleHibernateOnProject( getProject(), enableHibernate.getSelection(),
+ selectedConfiguration.getSelectionIndex() != 0 ? selectedConfiguration.getText() : ""); //$NON-NLS-1$
saveNamigStrategyChanges();
return true;
}
@@ -366,6 +392,9 @@
Control comp = settings[i];
comp.setEnabled(selection);
}
+ if (selection) {
+ details.setEnabled(selectedConfiguration.getSelectionIndex() != 0);
+ }
}
}
\ No newline at end of file