diff options
author | tle | 2010-08-08 19:57:33 +0000 |
---|---|---|
committer | tle | 2010-08-08 19:57:33 +0000 |
commit | 61f5970a70a256dfebbcdebf365b3049937b013e (patch) | |
tree | 1e76df7b2a0eb6c66ef001003d33b0651ab307d5 | |
parent | 31449c4d801f4f7aa508400a1dd9d0ef33233c38 (diff) | |
download | webtools.dali-61f5970a70a256dfebbcdebf365b3049937b013e.tar.gz webtools.dali-61f5970a70a256dfebbcdebf365b3049937b013e.tar.xz webtools.dali-61f5970a70a256dfebbcdebf365b3049937b013e.zip |
Added proxy settings group
4 files changed, 185 insertions, 123 deletions
diff --git a/jpa/plugins/org.eclipse.jpt.jaxb.ui/property_files/jpt_jaxb_ui.properties b/jpa/plugins/org.eclipse.jpt.jaxb.ui/property_files/jpt_jaxb_ui.properties index a610587ff6..f4da52a466 100644 --- a/jpa/plugins/org.eclipse.jpt.jaxb.ui/property_files/jpt_jaxb_ui.properties +++ b/jpa/plugins/org.eclipse.jpt.jaxb.ui/property_files/jpt_jaxb_ui.properties @@ -30,8 +30,11 @@ ClassesGeneratorWizardPage_chooseACatalog = Catalog File Selection ClassesGeneratorOptionsWizardPage_title = Classes Generator Options ClassesGeneratorOptionsWizardPage_desc = Configure JAXB compiler options. +ClassesGeneratorOptionsWizardPage_proxyGroup = Proxy +ClassesGeneratorOptionsWizardPage_noProxy = No Proxy ClassesGeneratorOptionsWizardPage_proxy = Proxy: ClassesGeneratorOptionsWizardPage_proxyFile = Proxy file: +ClassesGeneratorOptionsWizardPage_chooseAProxyFile = Proxy File Selection ClassesGeneratorOptionsWizardPage_useStrictValidation = Use strict validation ClassesGeneratorOptionsWizardPage_makeReadOnly = Generate read-only files diff --git a/jpa/plugins/org.eclipse.jpt.jaxb.ui/src/org/eclipse/jpt/jaxb/ui/internal/JptJaxbUiMessages.java b/jpa/plugins/org.eclipse.jpt.jaxb.ui/src/org/eclipse/jpt/jaxb/ui/internal/JptJaxbUiMessages.java index 096fb5ba70..6abf2ec125 100644 --- a/jpa/plugins/org.eclipse.jpt.jaxb.ui/src/org/eclipse/jpt/jaxb/ui/internal/JptJaxbUiMessages.java +++ b/jpa/plugins/org.eclipse.jpt.jaxb.ui/src/org/eclipse/jpt/jaxb/ui/internal/JptJaxbUiMessages.java @@ -39,8 +39,11 @@ public class JptJaxbUiMessages { public static String ClassesGeneratorOptionsWizardPage_title; public static String ClassesGeneratorOptionsWizardPage_desc; + public static String ClassesGeneratorOptionsWizardPage_proxyGroup; + public static String ClassesGeneratorOptionsWizardPage_noProxy; public static String ClassesGeneratorOptionsWizardPage_proxy; public static String ClassesGeneratorOptionsWizardPage_proxyFile; + public static String ClassesGeneratorOptionsWizardPage_chooseAProxyFile; public static String ClassesGeneratorOptionsWizardPage_useStrictValidation; public static String ClassesGeneratorOptionsWizardPage_makeReadOnly; diff --git a/jpa/plugins/org.eclipse.jpt.jaxb.ui/src/org/eclipse/jpt/jaxb/ui/internal/wizards/classesgen/ClassesGeneratorOptionsWizardPage.java b/jpa/plugins/org.eclipse.jpt.jaxb.ui/src/org/eclipse/jpt/jaxb/ui/internal/wizards/classesgen/ClassesGeneratorOptionsWizardPage.java index 098501ad69..17abdb442c 100644 --- a/jpa/plugins/org.eclipse.jpt.jaxb.ui/src/org/eclipse/jpt/jaxb/ui/internal/wizards/classesgen/ClassesGeneratorOptionsWizardPage.java +++ b/jpa/plugins/org.eclipse.jpt.jaxb.ui/src/org/eclipse/jpt/jaxb/ui/internal/wizards/classesgen/ClassesGeneratorOptionsWizardPage.java @@ -9,8 +9,12 @@ *******************************************************************************/ package org.eclipse.jpt.jaxb.ui.internal.wizards.classesgen; +import org.eclipse.core.runtime.IPath; +import org.eclipse.core.runtime.Path; +import org.eclipse.jdt.core.IJavaProject; import org.eclipse.jface.wizard.WizardPage; import org.eclipse.jpt.jaxb.ui.internal.JptJaxbUiMessages; +import org.eclipse.jpt.utility.internal.StringTools; import org.eclipse.swt.SWT; import org.eclipse.swt.events.SelectionEvent; import org.eclipse.swt.events.SelectionListener; @@ -19,7 +23,8 @@ import org.eclipse.swt.layout.GridLayout; import org.eclipse.swt.widgets.Button; import org.eclipse.swt.widgets.Composite; import org.eclipse.swt.widgets.Control; -import org.eclipse.swt.widgets.Label; +import org.eclipse.swt.widgets.FileDialog; +import org.eclipse.swt.widgets.Group; import org.eclipse.swt.widgets.Text; /** @@ -31,11 +36,17 @@ public class ClassesGeneratorOptionsWizardPage extends WizardPage private Options1Composite options1Composite; private Options2Composite options2Composite; + private final IJavaProject javaProject; + // ********** constructor ********** - protected ClassesGeneratorOptionsWizardPage() { + protected ClassesGeneratorOptionsWizardPage(IJavaProject javaProject) { super("Classes Generator Options"); //$NON-NLS-1$ - + if (javaProject == null) { + throw new NullPointerException(); + } + this.javaProject = javaProject; + this.initialize(); } @@ -56,7 +67,7 @@ public class ClassesGeneratorOptionsWizardPage extends WizardPage composite.setLayout(new GridLayout()); this.proxyOptionsComposite = new ProxyOptionsComposite(composite); - + this.buildOptionsComposites(composite); return composite; @@ -138,61 +149,175 @@ public class ClassesGeneratorOptionsWizardPage extends WizardPage return this.options2Composite.showsHelp(); } + // ********** UI controls ********** + protected Button buildCheckBox(Composite parent, String text, SelectionListener listener, int verticalIndent) { + Button checkBox = new Button(parent, SWT.CHECK); + GridData gridData = new GridData(); + gridData.verticalIndent= verticalIndent; + checkBox.setLayoutData(gridData); + checkBox.setText(text); + checkBox.addSelectionListener(listener); + return checkBox; + } + + protected Button buildRadioButton(Composite parent, String text, SelectionListener listener, int horizontalSpan, int verticalIndent) { + Button radioButton = new Button(parent, SWT.NONE | SWT.RADIO); + GridData gridData = new GridData(GridData.HORIZONTAL_ALIGN_FILL); + gridData.horizontalSpan = horizontalSpan; + gridData.horizontalIndent= 5; + gridData.verticalIndent = verticalIndent; + radioButton.setLayoutData(gridData); + radioButton.setText(text); + radioButton.addSelectionListener(listener); + return radioButton; + } + + protected Text buildText(Composite parent, int horizontalSpan, int verticalIndent) { + Text text = new Text(parent, SWT.SINGLE | SWT.BORDER); + GridData gridData = new GridData(GridData.FILL_HORIZONTAL); + gridData.horizontalSpan = horizontalSpan; + gridData.verticalIndent = verticalIndent; + text.setLayoutData(gridData); + return text; + } + + protected void disableText(Text text) { + text.setEnabled(false); + text.setText(""); + } + + // ********** internal methods ********** + + private String makeRelativeToProjectPath(String filePath) { + Path path = new Path(filePath); + IPath relativePath = path.makeRelativeTo(javaProject.getProject().getLocation()); + return relativePath.toOSString(); + } + + // ********** ProxyOptionsComposite ********** class ProxyOptionsComposite { - + + private final Button noProxyRadioButton; + + private final Button proxyRadioButton; private final Text proxyText; + + private final Button proxyFileRadioButton; private final Text proxyFileText; + private Button browseButton; // ********** constructor ********** private ProxyOptionsComposite(Composite parent) { super(); - Composite composite = new Composite(parent, SWT.NONE); + Group proxyGroup = new Group(parent, SWT.NONE); GridLayout layout = new GridLayout(3, false); layout.marginHeight = 0; layout.marginWidth = 0; - composite.setLayout(layout); - composite.setLayoutData(new GridData(GridData.FILL_HORIZONTAL)); - // TODO PlatformUI.getWorkbench().getHelpSystem().setHelp(this.group, JpaHelpContextIds.XXX); - - // Proxy - Label proxyLabel = new Label(composite, SWT.NONE); - proxyLabel.setText(JptJaxbUiMessages.ClassesGeneratorOptionsWizardPage_proxy); - GridData gridData = new GridData(); - gridData.verticalIndent = 5; - proxyLabel.setLayoutData(gridData); - this.proxyText = this.buildProxyText(composite); + proxyGroup.setLayout(layout); + proxyGroup.setLayoutData(new GridData(GridData.FILL_HORIZONTAL)); + proxyGroup.setText(JptJaxbUiMessages.ClassesGeneratorOptionsWizardPage_proxyGroup); + + SelectionListener proxyButtonListener = this.buildProxyRadioButtonListener(); + + this.noProxyRadioButton = buildRadioButton(proxyGroup, + JptJaxbUiMessages.ClassesGeneratorOptionsWizardPage_noProxy, proxyButtonListener, 3, 1); + this.proxyRadioButton = buildRadioButton(proxyGroup, + JptJaxbUiMessages.ClassesGeneratorOptionsWizardPage_proxy, proxyButtonListener, 1, 1); + this.proxyText = buildText(proxyGroup, 2, 1); + + this.proxyFileRadioButton = buildRadioButton(proxyGroup, + JptJaxbUiMessages.ClassesGeneratorOptionsWizardPage_proxyFile, proxyButtonListener, 1, 1); + this.proxyFileText = buildText(proxyGroup, 1, 1); + this.browseButton = this.buildBrowseButton(proxyGroup); - // ProxyFile - Label proxyFileLabel = new Label(composite, SWT.NONE); - proxyFileLabel.setText(JptJaxbUiMessages.ClassesGeneratorOptionsWizardPage_proxyFile); + this.noProxyRadioButton.setSelection(true); + this.proxyButtonChanged(); + } + + private Button buildBrowseButton(Composite parent) { + Composite buttonComposite = new Composite(parent, SWT.NULL); + GridLayout buttonLayout = new GridLayout(1, false); + buttonComposite.setLayout(buttonLayout); + GridData gridData = new GridData(); + gridData.horizontalAlignment = GridData.FILL; + gridData.verticalAlignment = GridData.BEGINNING; + buttonComposite.setLayoutData(gridData); + + // Browse buttons + Button browseButton = new Button(buttonComposite, SWT.PUSH); + browseButton.setText(JptJaxbUiMessages.ClassesGeneratorWizardPage_browseButton); gridData = new GridData(); - gridData.verticalIndent = 5; - proxyFileLabel.setLayoutData(gridData); - this.proxyFileText = this.buildProxyFileText(composite); + gridData.horizontalAlignment= GridData.FILL; + gridData.verticalIndent = 1; + gridData.grabExcessHorizontalSpace= true; + browseButton.setLayoutData(gridData); + + browseButton.addSelectionListener(new SelectionListener() { + public void widgetDefaultSelected(SelectionEvent e) {} + + public void widgetSelected(SelectionEvent e) { + + String filePath = promptProxyFile(); + if( ! StringTools.stringIsEmpty(filePath)) { + + proxyFileText.setText(makeRelativeToProjectPath(filePath)); + } + } + }); + return browseButton; } + + // ********** listeners ********** - // ********** UI components ********** + private SelectionListener buildProxyRadioButtonListener() { + return new SelectionListener() { + public void widgetDefaultSelected(SelectionEvent event) { + this.widgetSelected(event); + } + public void widgetSelected(SelectionEvent event) { + proxyButtonChanged(); + } + }; + } - private Text buildProxyText(Composite parent) { - Text text = new Text(parent, SWT.BORDER); - GridData gridData = new GridData(GridData.FILL_HORIZONTAL); - gridData.horizontalSpan = 2; - gridData.verticalIndent = 5; - text.setLayoutData(gridData); - return text; + private void proxyButtonChanged() { + boolean usesProxy = ! this.noProxyRadioButton.getSelection(); + if(usesProxy) { + if(this.proxyRadioButton.getSelection()) { + this.proxyText.setEnabled(true); + disableText(this.proxyFileText); + this.browseButton.setEnabled(false); + } + else if(this.proxyFileRadioButton.getSelection()) { + this.proxyFileText.setEnabled(true); + this.browseButton.setEnabled(true); + disableText(this.proxyText); + } + } + else { + disableText(this.proxyText); + disableText(this.proxyFileText); + this.browseButton.setEnabled(false); + } } - private Text buildProxyFileText(Composite parent) { - Text text = new Text(parent, SWT.BORDER); - GridData gridData = new GridData(GridData.FILL_HORIZONTAL); - gridData.horizontalSpan = 2; - gridData.verticalIndent = 5; - text.setLayoutData(gridData); - return text; + // ********** internal methods ********** + /** + * The Add button was clicked, its action invokes this action which should + * prompt the user to select a file and return it. + */ + private String promptProxyFile() { + String projectPath= javaProject.getProject().getLocation().toString(); + + FileDialog dialog = new FileDialog(getShell()); + dialog.setText(JptJaxbUiMessages.ClassesGeneratorOptionsWizardPage_chooseAProxyFile); + dialog.setFilterPath(projectPath); + + return dialog.open(); } // ********** intra-wizard methods ********** @@ -205,6 +330,7 @@ public class ClassesGeneratorOptionsWizardPage extends WizardPage return this.proxyFileText.getText(); } } + // ********** Options1Composite ********** @@ -258,79 +384,44 @@ public class ClassesGeneratorOptionsWizardPage extends WizardPage // ********** UI components ********** private Button buildUsesStrictValidationCheckBox(Composite parent, SelectionListener listener) { - Button checkBox = new Button(parent, SWT.CHECK); - GridData gridData = new GridData(); - gridData.verticalIndent = 5; - checkBox.setLayoutData(gridData); - checkBox.setText(JptJaxbUiMessages.ClassesGeneratorOptionsWizardPage_useStrictValidation); + Button checkBox = buildCheckBox(parent, JptJaxbUiMessages.ClassesGeneratorOptionsWizardPage_useStrictValidation, listener, 5); checkBox.setSelection(this.usesStrictValidation()); - checkBox.addSelectionListener(listener); return checkBox; } private Button buildMakesReadOnlyCheckBox(Composite parent, SelectionListener listener) { - Button checkBox = new Button(parent, SWT.CHECK); - GridData gridData = new GridData(); - gridData.verticalIndent = 5; - checkBox.setLayoutData(gridData); - checkBox.setText(JptJaxbUiMessages.ClassesGeneratorOptionsWizardPage_makeReadOnly); + Button checkBox = buildCheckBox(parent, JptJaxbUiMessages.ClassesGeneratorOptionsWizardPage_makeReadOnly, listener, 5); checkBox.setSelection(this.makesReadOnly()); - checkBox.addSelectionListener(listener); return checkBox; } private Button buildSuppressesPackageInfoGenCheckBox(Composite parent, SelectionListener listener) { - Button checkBox = new Button(parent, SWT.CHECK); - GridData gridData = new GridData(); - gridData.verticalIndent = 5; - checkBox.setLayoutData(gridData); - checkBox.setText(JptJaxbUiMessages.ClassesGeneratorOptionsWizardPage_suppressPackageInfoGen); + Button checkBox = buildCheckBox(parent, JptJaxbUiMessages.ClassesGeneratorOptionsWizardPage_suppressPackageInfoGen, listener, 5); checkBox.setSelection(this.suppressesPackageInfoGen()); - checkBox.addSelectionListener(listener); return checkBox; } private Button buildSuppressesHeaderGenCheckBox(Composite parent, SelectionListener listener) { - Button checkBox = new Button(parent, SWT.CHECK); - GridData gridData = new GridData(); - gridData.verticalIndent = 5; - checkBox.setLayoutData(gridData); - checkBox.setText(JptJaxbUiMessages.ClassesGeneratorOptionsWizardPage_suppressesHeaderGen); + Button checkBox = buildCheckBox(parent, JptJaxbUiMessages.ClassesGeneratorOptionsWizardPage_suppressesHeaderGen, listener, 5); checkBox.setSelection(this.suppressesHeaderGen()); - checkBox.addSelectionListener(listener); return checkBox; } private Button buildTargetCheckBox(Composite parent, SelectionListener listener) { - Button checkBox = new Button(parent, SWT.CHECK); - GridData gridData = new GridData(); - gridData.verticalIndent = 5; - checkBox.setLayoutData(gridData); - checkBox.setText(JptJaxbUiMessages.ClassesGeneratorOptionsWizardPage_target); + Button checkBox = buildCheckBox(parent, JptJaxbUiMessages.ClassesGeneratorOptionsWizardPage_target, listener, 5); checkBox.setSelection(this.targetIs20()); - checkBox.addSelectionListener(listener); return checkBox; } private Button buildIsVerboseCheckBox(Composite parent, SelectionListener listener) { - Button checkBox = new Button(parent, SWT.CHECK); - GridData gridData = new GridData(); - gridData.verticalIndent = 5; - checkBox.setLayoutData(gridData); - checkBox.setText(JptJaxbUiMessages.ClassesGeneratorOptionsWizardPage_verbose); + Button checkBox = buildCheckBox(parent, JptJaxbUiMessages.ClassesGeneratorOptionsWizardPage_verbose, listener, 5); checkBox.setSelection(this.isVerbose()); - checkBox.addSelectionListener(listener); return checkBox; } private Button buildIsQuietCheckBox(Composite parent, SelectionListener listener) { - Button checkBox = new Button(parent, SWT.CHECK); - GridData gridData = new GridData(); - gridData.verticalIndent = 5; - checkBox.setLayoutData(gridData); - checkBox.setText(JptJaxbUiMessages.ClassesGeneratorOptionsWizardPage_quiet); + Button checkBox = buildCheckBox(parent, JptJaxbUiMessages.ClassesGeneratorOptionsWizardPage_quiet, listener, 5); checkBox.setSelection(this.isQuiet()); - checkBox.addSelectionListener(listener); return checkBox; } @@ -532,78 +623,43 @@ public class ClassesGeneratorOptionsWizardPage extends WizardPage // ********** UI components ********** private Button buildTreatsAsXmlSchemaCheckBox(Composite parent, SelectionListener listener) { - Button checkBox = new Button(parent, SWT.CHECK); - GridData gridData = new GridData(); - gridData.verticalIndent = 5; - checkBox.setLayoutData(gridData); - checkBox.setText(JptJaxbUiMessages.ClassesGeneratorOptionsWizardPage_treatsAsXmlSchema); + Button checkBox = buildCheckBox(parent, JptJaxbUiMessages.ClassesGeneratorOptionsWizardPage_treatsAsXmlSchema, listener, 5); checkBox.setSelection(this.treatsAsXmlSchema()); - checkBox.addSelectionListener(listener); return checkBox; } private Button buildTreatsAsRelaxNgCheckBox(Composite parent, SelectionListener listener) { - Button checkBox = new Button(parent, SWT.CHECK); - GridData gridData = new GridData(); - gridData.verticalIndent = 5; - checkBox.setLayoutData(gridData); - checkBox.setText(JptJaxbUiMessages.ClassesGeneratorOptionsWizardPage_treatsAsRelaxNg); + Button checkBox = buildCheckBox(parent, JptJaxbUiMessages.ClassesGeneratorOptionsWizardPage_treatsAsRelaxNg, listener, 5); checkBox.setSelection(this.treatsAsRelaxNg()); - checkBox.addSelectionListener(listener); return checkBox; } private Button buildTreatsAsRelaxNgCompactCheckBox(Composite parent, SelectionListener listener) { - Button checkBox = new Button(parent, SWT.CHECK); - GridData gridData = new GridData(); - gridData.verticalIndent = 5; - checkBox.setLayoutData(gridData); - checkBox.setText(JptJaxbUiMessages.ClassesGeneratorOptionsWizardPage_treatsAsRelaxNgCompact); + Button checkBox = buildCheckBox(parent, JptJaxbUiMessages.ClassesGeneratorOptionsWizardPage_treatsAsRelaxNgCompact, listener, 5); checkBox.setSelection(this.treatsAsRelaxNgCompact()); - checkBox.addSelectionListener(listener); return checkBox; } private Button buildTreatsAsDtdCheckBox(Composite parent, SelectionListener listener) { - Button checkBox = new Button(parent, SWT.CHECK); - GridData gridData = new GridData(); - gridData.verticalIndent = 5; - checkBox.setLayoutData(gridData); - checkBox.setText(JptJaxbUiMessages.ClassesGeneratorOptionsWizardPage_treatsAsDtd); + Button checkBox = buildCheckBox(parent, JptJaxbUiMessages.ClassesGeneratorOptionsWizardPage_treatsAsDtd, listener, 5); checkBox.setSelection(this.treatsAsDtd()); - checkBox.addSelectionListener(listener); return checkBox; } private Button buildTreatsAsWsdlCheckBox(Composite parent, SelectionListener listener) { - Button checkBox = new Button(parent, SWT.CHECK); - GridData gridData = new GridData(); - gridData.verticalIndent = 5; - checkBox.setLayoutData(gridData); - checkBox.setText(JptJaxbUiMessages.ClassesGeneratorOptionsWizardPage_treatsAsWsdl); + Button checkBox = buildCheckBox(parent, JptJaxbUiMessages.ClassesGeneratorOptionsWizardPage_treatsAsWsdl, listener, 5); checkBox.setSelection(this.treatsAsWsdl()); - checkBox.addSelectionListener(listener); return checkBox; } private Button buildVersionCheckBox(Composite parent, SelectionListener listener) { - Button checkBox = new Button(parent, SWT.CHECK); - GridData gridData = new GridData(); - gridData.verticalIndent = 5; - checkBox.setLayoutData(gridData); - checkBox.setText(JptJaxbUiMessages.ClassesGeneratorOptionsWizardPage_showsVersion); + Button checkBox = buildCheckBox(parent, JptJaxbUiMessages.ClassesGeneratorOptionsWizardPage_showsVersion, listener, 5); checkBox.setSelection(this.showsVersion()); - checkBox.addSelectionListener(listener); return checkBox; } private Button buildHelpCheckBox(Composite parent, SelectionListener listener) { - Button checkBox = new Button(parent, SWT.CHECK); - GridData gridData = new GridData(); - gridData.verticalIndent = 5; - checkBox.setLayoutData(gridData); - checkBox.setText(JptJaxbUiMessages.ClassesGeneratorOptionsWizardPage_showsHelp); + Button checkBox = buildCheckBox(parent, JptJaxbUiMessages.ClassesGeneratorOptionsWizardPage_showsHelp, listener, 5); checkBox.setSelection(this.showsHelp()); - checkBox.addSelectionListener(listener); return checkBox; } diff --git a/jpa/plugins/org.eclipse.jpt.jaxb.ui/src/org/eclipse/jpt/jaxb/ui/internal/wizards/classesgen/ClassesGeneratorWizard.java b/jpa/plugins/org.eclipse.jpt.jaxb.ui/src/org/eclipse/jpt/jaxb/ui/internal/wizards/classesgen/ClassesGeneratorWizard.java index 92eb73c7c6..b5900d43c4 100644 --- a/jpa/plugins/org.eclipse.jpt.jaxb.ui/src/org/eclipse/jpt/jaxb/ui/internal/wizards/classesgen/ClassesGeneratorWizard.java +++ b/jpa/plugins/org.eclipse.jpt.jaxb.ui/src/org/eclipse/jpt/jaxb/ui/internal/wizards/classesgen/ClassesGeneratorWizard.java @@ -164,7 +164,7 @@ public class ClassesGeneratorWizard extends Wizard { } private ClassesGeneratorOptionsWizardPage buildClassesGeneratorOptionsPage() { - return new ClassesGeneratorOptionsWizardPage(); + return new ClassesGeneratorOptionsWizardPage(this.javaProject); } private ClassesGeneratorExtensionOptionsWizardPage buildExtensionOptionsPage() { |