Skip to content
This repository
Browse code

impl TestNGContainerWizardPage so that users can add "TestNG Library"

via
"Build Path -> Add Libraries... -> TestNG"
  • Loading branch information...
commit d1b9a4665b17a22ef84aced5849c32bdc08b2e17 1 parent 6dd335f
Nick Tan missedone authored
BIN  icons/full/wizban/addlibrary_wiz.png
8 plugin.xml
@@ -373,5 +373,13 @@
373 373
374 374 </menuContribution>
375 375 </extension>
  376 + <extension
  377 + point="org.eclipse.jdt.ui.classpathContainerPage">
  378 + <classpathContainerPage
  379 + class="org.testng.eclipse.ui.buildpath.TestNGContainerWizardPage"
  380 + id="org.testng.TESTNG_CONTAINER"
  381 + name="TestNG">
  382 + </classpathContainerPage>
  383 + </extension>
376 384
377 385 </plugin>
3  src/main/org/testng/eclipse/TestNGMessages.properties
@@ -125,3 +125,6 @@ NewTestNGClassWizard.alreadyExists.message=File {0} already exists. Overwrite it
125 125
126 126 TestNGMethodWizardPage.description=Select which methods you'd like to test.
127 127
  128 +TestNGContainerWizardPage.title=TestNG Library
  129 +TestNGContainerWizardPage.description=Set the TestNG Library for this project.
  130 +TestNGContainerWizardPage.message=This will set the default TestNG Library to this project.
49 src/main/org/testng/eclipse/ui/buildpath/TestNGContainerWizardPage.java
... ... @@ -0,0 +1,49 @@
  1 +package org.testng.eclipse.ui.buildpath;
  2 +
  3 +import org.eclipse.jdt.core.IClasspathEntry;
  4 +import org.eclipse.jdt.core.JavaCore;
  5 +import org.eclipse.jdt.ui.wizards.IClasspathContainerPage;
  6 +import org.eclipse.jface.dialogs.Dialog;
  7 +import org.eclipse.jface.wizard.WizardPage;
  8 +import org.eclipse.swt.SWT;
  9 +import org.eclipse.swt.layout.GridLayout;
  10 +import org.eclipse.swt.widgets.Composite;
  11 +import org.eclipse.swt.widgets.Label;
  12 +import org.testng.eclipse.TestNGPlugin;
  13 +import org.testng.eclipse.buildpath.TestNGContainerInitializer;
  14 +import org.testng.eclipse.util.ResourceUtil;
  15 +
  16 +public class TestNGContainerWizardPage extends WizardPage implements IClasspathContainerPage {
  17 +
  18 + public TestNGContainerWizardPage() {
  19 + super("TestNGContainerWizardPage"); //$NON-NLS-1$
  20 + setTitle(ResourceUtil.getString("TestNGContainerWizardPage.title")); //$NON-NLS-1$
  21 + setDescription(ResourceUtil.getString("TestNGContainerWizardPage.description")); //$NON-NLS-1$
  22 + setImageDescriptor(TestNGPlugin.getImageDescriptor("wizban/addlibrary_wiz.png")); //$NON-NLS-1$
  23 + }
  24 +
  25 + public void createControl(Composite parent) {
  26 + Composite container = new Composite(parent, SWT.NONE);
  27 + GridLayout layout = new GridLayout();
  28 + layout.marginHeight = 0;
  29 + layout.marginWidth = 0;
  30 + container.setLayout(layout);
  31 +
  32 + new Label(container, SWT.NONE).setText(ResourceUtil.getString("TestNGContainerWizardPage.message")); //$NON-NLS-1$
  33 +
  34 + setControl(container);
  35 + Dialog.applyDialogFont(container);
  36 + }
  37 +
  38 + public boolean finish() {
  39 + return true;
  40 + }
  41 +
  42 + public IClasspathEntry getSelection() {
  43 + return JavaCore.newContainerEntry(TestNGContainerInitializer.TESTNG_PATH);
  44 + }
  45 +
  46 + public void setSelection(IClasspathEntry containerEntry) {
  47 + }
  48 +
  49 +}

0 comments on commit d1b9a46

Please sign in to comment.
Something went wrong with that request. Please try again.