outputpage.java

来自「开源的axis2框架的源码。用于开发WEBSERVER」· Java 代码 · 共 644 行 · 第 1/2 页

JAVA
644
字号
		//filling label 
		gd = new GridData(GridData.FILL_HORIZONTAL);
		gd.horizontalSpan = 3;
		Label fillLabel3 = new Label(container, SWT.HORIZONTAL | SWT.SEPARATOR);
		fillLabel3.setLayoutData(gd);
		
		gd = new GridData(GridData.FILL_HORIZONTAL);
		gd.horizontalSpan = 3; 
		
		hintButton = new Button(container, SWT.PUSH);
		hintButton.setText(CodegenWizardPlugin
				.getResourceString("page3.hint.off"));
		hintButton.addSelectionListener(new SelectionAdapter() {
			public void widgetSelected(SelectionEvent e) {
				handleHintBrowse();
			}
		});
		
		gd = new GridData(GridData.FILL_HORIZONTAL);
		gd.horizontalSpan = 3;
		hintLabel = new Label(container, SWT.NULL);
		hintLabel
				.setText(CodegenWizardPlugin
						.getResourceString("page3.hint.caption"));
		hintLabel.setLayoutData(gd);
		hintLabel.setVisible(hintVisible);
		
		disableControls();
		
		setControl(container);

		/*
		 * Update the buttons, in case this was restored from an earlier setting
		 */
		if (restoredFromPreviousSettings) {
			handleModifyEvent();
		}
	}
	
	private void handleHintBrowse() {
		if (hintVisible) {
			hintButton.setText(CodegenWizardPlugin
					.getResourceString("page3.hint.off"));
			hintVisible = false;
			hintLabel.setVisible(hintVisible);
		} else {
			hintButton.setText(CodegenWizardPlugin
					.getResourceString("page3.hint.on"));
			hintVisible = true;
			hintLabel.setVisible(hintVisible);
		}
		
	}

	/**
	 * get the output location
	 * 
	 * @return a string containing the full pathname of the output location
	 */
	public String getOutputLocation() {
		return outputLocation.getText();
	}

	public String getAxisHomeLocation() {
		return axisHomeLocation.getText();
	}
	
	public String getJarFilename() {
		return jarFileNameText.getText();
	}
	
	public boolean getAxis2PluginLibCopyCheckBoxSelection(){
//		return settings.getBoolean(PREF_CHECK_AXIS_PLUGIN_LIB_COPY);
		return this.copyPluginLibButton.getSelection();
	}
	
	public boolean getAxisLibCopyCheckBoxSelection(){
//		return settings.getBoolean(PREF_CHECK_AXIS_LIB_COPY);
		return this.copyLibButton.getSelection();
	}
	
	public boolean getCreateJarCheckBoxSelection(){
//		return settings.getBoolean(PREF_CHECK_JAR_CREATION);
		return jarCreationButton.getSelection();
		
	}
	
	public String getAxisJarsLocation(){
		return this.axis2LibsLocation;
		
	}
	
	public boolean oktoLoadLibs(){
		return this.jarFileCopyOption;
	}
	
	public void setJarFileName(String jarFileName){
		this.jarFileNameText.setText(jarFileName);
	}
	
	/**
	 * Worker method for handling modifications to the textbox
	 * 
	 */
	private void handleModifyEvent() {
		String text = this.outputLocation.getText();
		if ((text == null) || (text.trim().equals(""))) {
			updateStatus(org.apache.axis2.tool.codegen.eclipse.plugin.CodegenWizardPlugin
					.getResourceString("page3.error.nolocation"));
			return;
		}
		updateStatus(null);
	}

	
	private void handleAxisHomeModifyEvent() {
		String text = this.axisHomeLocation.getText();
		if ((text == null) || (text.trim().equals(""))) {
			updateStatus(org.apache.axis2.tool.codegen.eclipse.plugin.CodegenWizardPlugin
					.getResourceString("page3.error.nolocation"));
			return;
		}
		updateStatus(null);
	}
	
//	private void handleJarNameModifyEvent() {
//		String text = this.jarFileNameText.getText();
//		if ((text == null) || (text.trim().equals(""))) {
//			updateStatus(org.apache.axis2.tool.codegen.eclipse.plugin.CodegenWizardPlugin
//					.getResourceString("page3.error.nolocation"));
//			return;
//		}
//		updateStatus(null);
//	}

	private void handleCheckboxSelection() {
		if (workspaceProjectOptionsButton.getSelection()) {
			settings.put(PREF_CHECK_WORKSPACE, true);
			settings.put(PREF_CHECK_FILE_SYSTEM, false);
			workspaceSaveOption = true;
		} else if (filesyStemOptionsButton.getSelection()) {
			settings.put(PREF_CHECK_FILE_SYSTEM, true);
			settings.put(PREF_CHECK_WORKSPACE, false);
			workspaceSaveOption = false;
		}
	}
	
	
	private void handlejarCheckBox() {
		if(copyLibButton.getSelection()){
			enableControls();
			settings.put(PREF_CHECK_AXIS_LIB_COPY, true);
		}else{
			disableControls();
			settings.put(PREF_CHECK_AXIS_LIB_COPY, false);
		}
	}
	
	private void handleCopyPluginLibsCheckBox() {
		if(copyPluginLibButton.getSelection()){
			settings.put(PREF_CHECK_AXIS_PLUGIN_LIB_COPY, true);
		}else{
			settings.put(PREF_CHECK_AXIS_PLUGIN_LIB_COPY, false);
		}
	}
	
	private void handlejarCreationCheckBox() {
		if(jarCreationButton.getSelection()== true){
			settings.put(PREF_CHECK_JAR_CREATION, true);
		}else{
			settings.put(PREF_CHECK_JAR_CREATION, false);
			this.jarFileNameText.setText("");
		}
		if(jarFileNameLabel.equals("")){
			updateStatus("Please enter a valid name to the jar file");
		}
	}
	
	private void disableControls(){
		this.axisHomeLocation.setText("Unpacked Axis2 binary home Or Axis2 source location");
		this.axisHomeBrowseButton.setEnabled(false);
		this.axisHomeLocation.setEnabled(false);
		this.jarCreationButton.setSelection(false);
		this.jarCreationButton.setEnabled(false);
		this.axisHomeLabel.setEnabled(false);
		this.axisLoadLibResultsLabel.setText("");
		this.axisLoadLibResultsLabel.setEnabled(false);
		this.axisLoadLibsButton.setEnabled(false);
		this.jarFileNameLabel.setEnabled(false);
		this.jarFileNameText.setText("");
		this.jarFileNameText.setEnabled(false);
		settings.put(PREF_CHECK_JAR_CREATION, false);
		jarFileCopyOption = false;
		Color color = getShell().getDisplay().getSystemColor(SWT.COLOR_INFO_BACKGROUND);
		axisLoadLibResultsLabel.setBackground(color);
	}
	
	private void enableControls(){
		this.axisHomeBrowseButton.setEnabled(true);
		this.axisHomeLocation.setEnabled(true);
		this.jarCreationButton.setEnabled(true);
		this.axisHomeLabel.setEnabled(true);
		this.axisLoadLibResultsLabel.setEnabled(true);
		this.axisLoadLibsButton.setEnabled(true);
		this.jarFileNameLabel.setEnabled(true);
		this.jarFileNameText.setEnabled(true);
		if (axisLoadLibResultsLabel.getText().equals("")){
			updateStatus("Please enter a valid path to the Axis2 libs and then try to load the libraries using the check libs button");
		}
	     axisLoadLibResultsLabel.setText(CodegenWizardPlugin
					.getResourceString("page3.loadlib.fail.caption"));
	     Color color = getShell().getDisplay().getSystemColor(SWT.COLOR_RED);
	     axisLoadLibResultsLabel.setBackground(color);
	}
	
	private void handleAxisHomeBrowse() {
		    this.axisHomeLocation.setText("unpacked Axis2 binary home Or Axis2 source Location");
			DirectoryDialog dialog = new DirectoryDialog(this.getShell());
			String returnString = dialog.open();
			if (returnString != null) {
				axisHomeLocation.setText(returnString);
				settings.put(PREF_AXIS_HOME_OUTPUT_LOCATION, axisHomeLocation.getText());
			}
	}
	
	private void handleLoadLibsBrowse() {
		if(axisHomeLocation.getText().equals("")){
			 axisLoadLibResultsLabel.setText(CodegenWizardPlugin
						.getResourceString("page3.loadlib.fail.caption"));
			 jarFileCopyOption=false;
		     if (axisLoadLibResultsLabel.getText().equals("")){
					updateStatus("Please enter a valid path to the Axis2 libs and then try to load the libraries using the check libs button");
		     }
		}else{
			settings.put(PREF_AXIS_HOME_OUTPUT_LOCATION, axisHomeLocation.getText());
			String axis_home = settings.get(PREF_AXIS_HOME_OUTPUT_LOCATION);
			String axis_target_lib=axis_home+File.separator+UIConstants.TARGET+File.separator+UIConstants.LIB;
			String axis_std_lib_directory=axis_home+File.separator+UIConstants.LIB;

			File axis_target_libs_directory = new File(axis_target_lib);
			File axis_libs_directory = new File(axis_std_lib_directory);
			 if (axis_libs_directory.isDirectory() || axis_target_libs_directory.isDirectory()) {
				 axisLoadLibResultsLabel.setText(CodegenWizardPlugin
							.getResourceString("page3.loadlib.success.caption"));
				if(axis_libs_directory.isDirectory()){
					axis2LibsLocation=axis_std_lib_directory;
				}
				else if(axis_target_libs_directory.isDirectory()){
					axis2LibsLocation=axis_target_lib;
				}
				 jarFileCopyOption =true;
				 Color color = getShell().getDisplay().getSystemColor(SWT.COLOR_INFO_BACKGROUND);
				 axisLoadLibResultsLabel.setBackground(color);
			 }else{
			     axisLoadLibResultsLabel.setText(CodegenWizardPlugin
							.getResourceString("page3.loadlib.fail.caption"));
			     Color color = getShell().getDisplay().getSystemColor(SWT.COLOR_RED);
			     axisLoadLibResultsLabel.setBackground(color);
			     updateStatus(org.apache.axis2.tool.codegen.eclipse.plugin.CodegenWizardPlugin
						.getResourceString("page3.loadlib.fail.message"));
			     jarFileCopyOption=false;
			 }
		}
	}

	
	/**
	 * Handle the browse button events: opens a dialog where the user can choose
	 * an external directory location
	 * 
	 */
	private void handleBrowse() {
		// Change this to add the clarity of 2 option buttions
		// boolean location = locationSelectCheckBox.getSelection();
		boolean location = false;
		if(settings.getBoolean(PREF_CHECK_FILE_SYSTEM)){
			location = false;
		}else if(settings.getBoolean(PREF_CHECK_WORKSPACE)){
			location = true;
		}

		if (workspaceSaveOption) {
			location = true;
		}

		if (!location) {
			DirectoryDialog dialog = new DirectoryDialog(this.getShell());
			String returnString = dialog.open();
			if (returnString != null) {
				outputLocation.setText(returnString);
			}
		} else {
			IWorkspaceRoot root = ResourcesPlugin.getWorkspace().getRoot();

			ContainerSelectionDialog dialog = new ContainerSelectionDialog(
					getShell(), root, false, CodegenWizardPlugin
							.getResourceString("page3.containerbox.title"));
			if (dialog.open() == ContainerSelectionDialog.OK) {
				Object[] result = dialog.getResult();
				if (result.length == 1) {
					Path path = ((Path) result[0]);
					// append to the workspace path
					if (root.exists(path)) {
						outputLocation.setText(root.getLocation().append(path)
								.toFile().getAbsolutePath());
					}
				}
			}
		}

	}

	/*
	 * (non-Javadoc)
	 * 
	 * @see org.apache.axis2.tool.codegen.eclipse.ui.CodegenPage#getPageType()
	 */
	public int getPageType() {
		return WSDL_2_JAVA_TYPE;
	}
}

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?