View Javadoc
1 package net.sf.panoptes.view.wizard; 2 3 import org.eclipse.core.runtime.IStatus; 4 import org.eclipse.core.runtime.Status; 5 import org.eclipse.jface.viewers.IStructuredSelection; 6 import org.eclipse.jface.wizard.WizardPage; 7 import org.eclipse.swt.SWT; 8 import org.eclipse.swt.layout.GridData; 9 import org.eclipse.swt.layout.GridLayout; 10 import org.eclipse.swt.widgets.Button; 11 import org.eclipse.swt.widgets.Composite; 12 import org.eclipse.swt.widgets.Event; 13 import org.eclipse.swt.widgets.Label; 14 import org.eclipse.swt.widgets.Listener; 15 import org.eclipse.swt.widgets.Text; 16 import org.eclipse.ui.IWorkbench; 17 18 /*** 19 * Class representing the first page of the wizard 20 */ 21 22 public class NodeConnectionPage extends WizardPage { 23 24 private boolean isReady; 25 26 IWorkbench workbench; 27 IStructuredSelection selection; 28 29 Text hostUrl; 30 Text rmiPort; 31 Text hostName; 32 Button connectImmediately; 33 IStatus formStatus; 34 35 /*** 36 * Constructor 37 */ 38 public NodeConnectionPage( 39 IWorkbench workbench, 40 IStructuredSelection selection) { 41 super("Page1"); 42 isReady = false; 43 setTitle("Create"); 44 setDescription("Create a new JMX Connection"); 45 formStatus = new Status(IStatus.ERROR, "not_used", 0, "", null); 46 } 47 48 /*** 49 * @see IDialogPage#createControl(Composite) 50 */ 51 public void createControl(Composite parent) { 52 53 GridData gd; 54 Composite composite = new Composite(parent, SWT.NULL); 55 56 GridLayout gl = new GridLayout(); 57 int ncol = 2; 58 gl.numColumns = ncol; 59 composite.setLayout(new GridLayout(2, false)); 60 61 new Label(composite, SWT.NONE).setText("Name (description):"); 62 hostName = new Text(composite, SWT.BORDER); 63 hostName.setLayoutData(new GridData(GridData.FILL_HORIZONTAL)); 64 65 new Label(composite, SWT.NONE).setText("Host:"); 66 hostUrl = new Text(composite, SWT.BORDER); 67 hostUrl.setLayoutData(new GridData(GridData.FILL_HORIZONTAL)); 68 69 new Label(composite, SWT.NONE).setText("RMI Port:"); 70 rmiPort = new Text(composite, SWT.BORDER); 71 rmiPort.setLayoutData(new GridData(GridData.FILL_HORIZONTAL)); 72 73 /*** 74 * Add listener to reject non-numeric inputs 75 */ 76 rmiPort.addListener(SWT.Verify, new Listener() { 77 public void handleEvent(Event event) { 78 String text = event.text; 79 char[] chars = new char[text.length()]; 80 text.getChars(0, chars.length, chars, 0); 81 for (int i = 0; i < chars.length; i++) { 82 if (!('0' <= chars[i] && chars[i] <= '9')) { 83 event.doit = false; 84 return; 85 } 86 } 87 } 88 }); 89 90 new Label(composite, SWT.NONE).setText("Connect immediately:"); 91 connectImmediately = new Button(composite, SWT.CHECK); 92 93 // set the composite as the control for this page 94 setControl(composite); 95 setInitValues(); 96 97 } 98 /*** 99 * Method setInitValues. 100 */ 101 private void setInitValues() { 102 103 hostUrl.setText("localhost"); 104 rmiPort.setText("1099"); 105 hostName.setText("localhost"); 106 connectImmediately.setSelection(true); 107 isReady = true; 108 } 109 110 /*** 111 * cant flip to next page since is only one page now. 112 * @see IWizardPage#canFlipToNextPage() 113 */ 114 public boolean canFlipToNextPage() { 115 return false; 116 } 117 118 119 public boolean isPageComplete() { 120 return isReady; 121 } 122 123 /*** 124 * @return the descriptional name of the server 125 */ 126 public String getHostName() { 127 return hostName.getText(); 128 } 129 130 /*** 131 * @return the server address 132 */ 133 public String getHostUrl() { 134 return hostUrl.getText(); 135 } 136 137 /*** 138 * @return the server port 139 */ 140 public int getRmiPort() { 141 return Integer.parseInt(rmiPort.getText()); 142 } 143 144 /*** 145 * 146 * @return boolean true if the user has chosen to connect immediately 147 */ 148 public boolean connectImmediately() { 149 return connectImmediately.getSelection(); 150 } 151 152 }

This page was automatically generated by Maven