Author: vyemialyanchyk
Date: 2009-02-10 10:34:26 -0500 (Tue, 10 Feb 2009)
New Revision: 13563
Modified:
trunk/hibernatetools/plugins/org.hibernate.eclipse.console/src/org/hibernate/eclipse/console/HibernateConsoleMessages.java
trunk/hibernatetools/plugins/org.hibernate.eclipse.console/src/org/hibernate/eclipse/console/HibernateConsoleMessages.properties
trunk/hibernatetools/plugins/org.hibernate.eclipse.console/src/org/hibernate/eclipse/launch/AddPropertyDialog.java
trunk/hibernatetools/plugins/org.hibernate.eclipse.console/src/org/hibernate/eclipse/launch/ExporterSettingsTab.java
Log:
JBIDE-3604
Modified:
trunk/hibernatetools/plugins/org.hibernate.eclipse.console/src/org/hibernate/eclipse/console/HibernateConsoleMessages.java
===================================================================
---
trunk/hibernatetools/plugins/org.hibernate.eclipse.console/src/org/hibernate/eclipse/console/HibernateConsoleMessages.java 2009-02-10
15:27:40 UTC (rev 13562)
+++
trunk/hibernatetools/plugins/org.hibernate.eclipse.console/src/org/hibernate/eclipse/console/HibernateConsoleMessages.java 2009-02-10
15:34:26 UTC (rev 13563)
@@ -366,12 +366,16 @@
//
public static String AddPropertyDialog_add_exporter_property;
public static String AddPropertyDialog_add_property_to;
+ public static String AddPropertyDialog_edit_exporter_property;
+ public static String AddPropertyDialog_edit_property_to;
public static String AddPropertyDialog_name;
public static String AddPropertyDialog_the_property_is_already_set;
public static String AddPropertyDialog_the_property_name_may_not_contain_whitespaces;
public static String AddPropertyDialog_the_property_name_must_be_chosen_or_entered;
public static String AddPropertyDialog_the_property_value_must_be_non_empty;
public static String AddPropertyDialog_value;
+ public static String AddPropertyDialog_add_path;
+ public static String AddPropertyDialog_browse;
public static String CodeGenerationLaunchDelegate_console_configuration_not_found_in;
public static String
CodeGenerationLaunchDelegate_console_configuration_name_is_empty_in;
public static String
CodeGenerationLaunchDelegate_could_not_create_or_find_with_default_noarg_constructor;
@@ -485,6 +489,7 @@
public static String ExporterSettingsTab_description;
public static String ExporterSettingsTab_deselect_all;
public static String ExporterSettingsTab_does_not_exist;
+ public static String ExporterSettingsTab_edit;
public static String ExporterSettingsTab_exporters;
public static String ExporterSettingsTab_exporters_2;
public static String ExporterSettingsTab_general_settings;
Modified:
trunk/hibernatetools/plugins/org.hibernate.eclipse.console/src/org/hibernate/eclipse/console/HibernateConsoleMessages.properties
===================================================================
---
trunk/hibernatetools/plugins/org.hibernate.eclipse.console/src/org/hibernate/eclipse/console/HibernateConsoleMessages.properties 2009-02-10
15:27:40 UTC (rev 13562)
+++
trunk/hibernatetools/plugins/org.hibernate.eclipse.console/src/org/hibernate/eclipse/console/HibernateConsoleMessages.properties 2009-02-10
15:34:26 UTC (rev 13563)
@@ -358,12 +358,16 @@
AddPropertyDialog_add_exporter_property=Add exporter property
AddPropertyDialog_add_property_to=Add property to
+AddPropertyDialog_edit_exporter_property=Edit exporter property
+AddPropertyDialog_edit_property_to=Edit property to
AddPropertyDialog_name=Name:
AddPropertyDialog_the_property_is_already_set=The property {0} is already set, pressing
ok will overwrite the current value
AddPropertyDialog_the_property_name_may_not_contain_whitespaces=The property name may not
contain whitespaces
AddPropertyDialog_the_property_name_must_be_chosen_or_entered=The property name must be
chosen or entered
AddPropertyDialog_the_property_value_must_be_non_empty=The property value must be
non-empty
AddPropertyDialog_value=Value:
+AddPropertyDialog_add_path=Add path...
+AddPropertyDialog_browse=Browse
CodeGenerationLaunchDelegate_console_configuration_not_found_in=Console configuration {0}
not found in {1}
CodeGenerationLaunchDelegate_console_configuration_name_is_empty_in=Console configuration
name is empty in
CodeGenerationLaunchDelegate_could_not_create_or_find_with_default_noarg_constructor=Could
not create or find {0} with default no-arg constructor
@@ -476,6 +480,7 @@
ExporterSettingsTab_description=Description
ExporterSettingsTab_deselect_all=Deselect all
ExporterSettingsTab_does_not_exist=\ does not exist
+ExporterSettingsTab_edit=Edit...
ExporterSettingsTab_exporters=Exporters:
ExporterSettingsTab_exporters_2=Exporters
ExporterSettingsTab_general_settings=General settings:
Modified:
trunk/hibernatetools/plugins/org.hibernate.eclipse.console/src/org/hibernate/eclipse/launch/AddPropertyDialog.java
===================================================================
---
trunk/hibernatetools/plugins/org.hibernate.eclipse.console/src/org/hibernate/eclipse/launch/AddPropertyDialog.java 2009-02-10
15:27:40 UTC (rev 13562)
+++
trunk/hibernatetools/plugins/org.hibernate.eclipse.console/src/org/hibernate/eclipse/launch/AddPropertyDialog.java 2009-02-10
15:34:26 UTC (rev 13563)
@@ -1,6 +1,5 @@
package org.hibernate.eclipse.launch;
-import java.io.File;
import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;
@@ -49,6 +48,8 @@
public class AddPropertyDialog extends TitleAreaDialog {
private final ExporterFactory ef;
+ private final String selectedPropertyId;
+ private final boolean flagEdit;
private ComboViewer propertyCombo;
private Control value;
private Button addPathButton;
@@ -62,14 +63,23 @@
};
- protected AddPropertyDialog(Shell parentShell, ExporterFactory ef) {
+ protected AddPropertyDialog(Shell parentShell, ExporterFactory ef, String
selectedPropertyId, boolean flagEdit) {
super( parentShell );
this.ef = ef;
+ this.selectedPropertyId = selectedPropertyId;
+ this.flagEdit = flagEdit;
}
protected Control createDialogArea(Composite parent) {
- getShell().setText(HibernateConsoleMessages.AddPropertyDialog_add_exporter_property);
- setTitle(HibernateConsoleMessages.AddPropertyDialog_add_property_to +
ef.getExporterDefinition().getDescription());
+
+ String dialogTitle = HibernateConsoleMessages.AddPropertyDialog_add_exporter_property;
+ String editTitle = HibernateConsoleMessages.AddPropertyDialog_add_property_to;
+ if (flagEdit) {
+ dialogTitle = HibernateConsoleMessages.AddPropertyDialog_edit_exporter_property;
+ editTitle = HibernateConsoleMessages.AddPropertyDialog_edit_property_to;
+ }
+ getShell().setText(dialogTitle);
+ setTitle(editTitle + ef.getExporterDefinition().getDescription());
Composite control = (Composite) super.createDialogArea( parent );
Composite composite = new Composite(control,SWT.NONE);
@@ -117,6 +127,9 @@
});
+ if (flagEdit) {
+ propertyCombo.getControl().setEnabled(false);
+ }
label = new Label(composite, SWT.NONE);
label.setText( HibernateConsoleMessages.AddPropertyDialog_value );
@@ -224,7 +237,7 @@
} else if (answer == 1){ // workspace
IPath[] paths = DialogSelectionHelper.chooseFileEntries(getShell(), (IPath)null,
new Path[0],
title, description,
- new String[0], isPath, true, false);//$NON-NLS-1$
+ new String[0], isPath, true, false);
if (paths != null && paths.length > 0){
strPath = paths[0].toOSString();
if (isPath){
@@ -272,7 +285,14 @@
} );
viewer.setInput( ef );
if(viewer.getCombo().getItemCount()>0) {
- viewer.setSelection( new StructuredSelection(viewer.getElementAt( 0 )));
+ Object selected = null;
+ if (selectedPropertyId != null) {
+ selected = ef.getExporterProperty(selectedPropertyId);
+ }
+ else {
+ selected = viewer.getElementAt( 0 );
+ }
+ viewer.setSelection(new StructuredSelection(selected));
}
}
@@ -288,10 +308,10 @@
private void createBrowseButton(SelectionListener listener, ExporterProperty prop){
disposeBrowseButton();
addPathButton = new Button(value.getParent(), SWT.PUSH);
- if ("path".equals(prop.getType())){
- addPathButton.setText("Add path...");
+ if ("path".equals(prop.getType())){ //$NON-NLS-1$
+ addPathButton.setText(HibernateConsoleMessages.AddPropertyDialog_add_path);
} else {
- addPathButton.setText("Browse");
+ addPathButton.setText(HibernateConsoleMessages.AddPropertyDialog_browse);
}
addPathButton.setLayoutData(new GridData(GridData.END));
addPathButton.addSelectionListener(listener);
@@ -347,7 +367,7 @@
} else if(StringHelper.isEmpty( getPropertyValue() )) {
setMessage(
HibernateConsoleMessages.AddPropertyDialog_the_property_value_must_be_non_empty,
IMessageProvider.ERROR);
} else {
- if (ef.hasLocalValueFor( getPropertyName() )) {
+ if (!flagEdit && ef.hasLocalValueFor( getPropertyName() )) {
String out =
NLS.bind(HibernateConsoleMessages.AddPropertyDialog_the_property_is_already_set,
getPropertyName());
setMessage(out, IMessageProvider.WARNING);
} else {
Modified:
trunk/hibernatetools/plugins/org.hibernate.eclipse.console/src/org/hibernate/eclipse/launch/ExporterSettingsTab.java
===================================================================
---
trunk/hibernatetools/plugins/org.hibernate.eclipse.console/src/org/hibernate/eclipse/launch/ExporterSettingsTab.java 2009-02-10
15:27:40 UTC (rev 13562)
+++
trunk/hibernatetools/plugins/org.hibernate.eclipse.console/src/org/hibernate/eclipse/launch/ExporterSettingsTab.java 2009-02-10
15:34:26 UTC (rev 13563)
@@ -42,10 +42,6 @@
import org.eclipse.debug.core.ILaunchConfiguration;
import org.eclipse.debug.core.ILaunchConfigurationWorkingCopy;
import org.eclipse.debug.ui.AbstractLaunchConfigurationTab;
-import org.eclipse.jdt.core.IJavaProject;
-import org.eclipse.jdt.core.JavaCore;
-import org.eclipse.jdt.core.JavaModelException;
-import org.eclipse.jdt.ui.JavaElementLabelProvider;
import org.eclipse.jface.dialogs.Dialog;
import org.eclipse.jface.dialogs.IDialogPage;
import org.eclipse.jface.preference.IPreferenceStore;
@@ -61,7 +57,6 @@
import org.eclipse.jface.viewers.IStructuredSelection;
import org.eclipse.jface.viewers.ITableLabelProvider;
import org.eclipse.jface.viewers.SelectionChangedEvent;
-import org.eclipse.jface.viewers.StructuredSelection;
import org.eclipse.jface.viewers.Viewer;
import org.eclipse.jface.window.Window;
import org.eclipse.osgi.util.NLS;
@@ -85,6 +80,7 @@
import org.eclipse.swt.widgets.TreeColumn;
import org.eclipse.ui.dialogs.ElementListSelectionDialog;
import org.eclipse.ui.views.properties.IPropertyDescriptor;
+import org.eclipse.ui.views.properties.IPropertySheetEntry;
import org.eclipse.ui.views.properties.IPropertySource;
import org.eclipse.ui.views.properties.IPropertySourceProvider;
import org.eclipse.ui.views.properties.PropertySheetEntry;
@@ -124,6 +120,8 @@
private Button remove;
+ private Button edit;
+
/**
* Constructor for SampleNewWizardPage.
*
@@ -184,7 +182,7 @@
gr.setLayout( gridLayout );
gd = new GridData( SWT.FILL, SWT.FILL, true, true );
- gd.verticalSpan = 2;
+ gd.verticalSpan = 3;
gr.setLayoutData( gd );
Control sheet = createPropertySheet( gr );
@@ -205,7 +203,7 @@
ExporterFactory ef = (ExporterFactory) ss.getFirstElement();
if(ef!=null) {
- AddPropertyDialog dialog = new AddPropertyDialog(getShell(), ef);
+ AddPropertyDialog dialog = new AddPropertyDialog(getShell(), ef, null, false);
if(dialog.open()==Dialog.OK) {
ef.setProperty( dialog.getPropertyName(), dialog.getPropertyValue() );
dialogChanged();
@@ -238,6 +236,34 @@
gd.horizontalIndent = 5;
remove.setLayoutData( gd );
+ edit = new Button( exportersComposite, SWT.PUSH );
+ edit.setEnabled( false );
+ edit.setText( HibernateConsoleMessages.ExporterSettingsTab_edit );
+ gd = new GridData( GridData.HORIZONTAL_ALIGN_FILL
+ | GridData.VERTICAL_ALIGN_BEGINNING );
+ gd.horizontalIndent = 5;
+ edit.setLayoutData( gd );
+ edit.addSelectionListener( new SelectionAdapter() {
+ public void widgetSelected(SelectionEvent e) {
+ IStructuredSelection ss = (IStructuredSelection) getExporterTable().getSelection();
+ ExporterFactory ef = (ExporterFactory) ss.getFirstElement();
+
+ if(ef!=null) {
+ String selectedPropertyId = null;
+ if(currentDescriptor!=null) {
+ selectedPropertyId = (String) currentDescriptor.getId();
+ }
+ AddPropertyDialog dialog =
+ new AddPropertyDialog(getShell(), ef, selectedPropertyId, true);
+ if(dialog.open()==Dialog.OK) {
+ ef.setProperty( dialog.getPropertyName(), dialog.getPropertyValue() );
+ dialogChanged();
+ refreshPropertySheet();
+ }
+ }
+ }
+ } );
+
}
public class MyPropertySheetEntry extends PropertySheetEntry {
@@ -265,6 +291,7 @@
hasSelection = true;
}
if (remove != null) remove.setEnabled(hasSelection);
+ if (edit != null) edit.setEnabled(hasSelection);
}
private Control createPropertySheet(Composite exportersComposite) {
@@ -317,6 +344,7 @@
if(s.isEmpty()) {
if(add!=null) add.setEnabled( false );
if(remove!=null) remove.setEnabled( false );
+ if(edit!=null) edit.setEnabled( false );
propertySheetEntry.setValues(new Object[0]);
@@ -327,6 +355,7 @@
hasSelection = true;
}
if(remove!=null) remove.setEnabled( hasSelection );
+ if(edit!=null) edit.setEnabled( hasSelection );
ExporterFactory ep = (ExporterFactory) s
.getFirstElement();