Start line:  
End line:  

Snippet Preview

Snippet HTML Code

Stack Overflow Questions
Copyright (c) 2000, 2007 IBM Corporation and others. All rights reserved. This program and the accompanying materials are made available under the terms of the Eclipse Public License v1.0 which accompanies this distribution, and is available at http://www.eclipse.org/legal/epl-v10.html Contributors: IBM Corporation - initial API and implementation /
 
 package org.eclipse.ant.internal.ui.launchConfigurations;
 
 import  org.eclipse.swt.SWT;
 import  org.eclipse.swt.events.SelectionAdapter;
 import  org.eclipse.swt.events.SelectionEvent;
 import  org.eclipse.swt.layout.GridData;
 import  org.eclipse.swt.layout.GridLayout;
 import  org.eclipse.swt.widgets.Button;
 import  org.eclipse.swt.widgets.Composite;
 
 public class AntMainTab extends ExternalToolsMainTab {
 
 	private String fCurrentLocationnull;
 	private Button fSetInputHandlerButton;
     private IFile fNewFile;
 
 	/* (non-Javadoc)
 	 * @see org.eclipse.debug.ui.ILaunchConfigurationTab#initializeFrom(org.eclipse.debug.core.ILaunchConfiguration)
 	 */
 	public void initializeFrom(ILaunchConfiguration configuration) {
 		super.initializeFrom(configuration);
 		try {
 		} catch (CoreException e) {
 		}
 		updateCheckButtons(configuration);
 	}
 	
 	/* (non-Javadoc)
 	 * @see org.eclipse.debug.ui.ILaunchConfigurationTab#performApply(org.eclipse.debug.core.ILaunchConfigurationWorkingCopy)
 	 */
 	public void performApply(ILaunchConfigurationWorkingCopy configuration) {
 		super.performApply(configuration);
 		try {
 			//has the location changed
 			String newLocationconfiguration.getAttribute(., (String)null);
 			if (newLocation != null) {
 				if (!newLocation.equals()) {
 				    updateTargetsTab();
 				    newLocation;
                     updateProjectName(configuration);
 				}
 			} else if ( != null){
 				newLocation;
                 updateProjectName(configuration);
 			}
 		} catch (CoreException e) {
 		}
        
 		setMappedResources(configuration);
 		setAttribute(.configuration.getSelection(), true);
 	}
 
 	private void setMappedResources(ILaunchConfigurationWorkingCopy configuration) {
 		IFile filegetIFile(configuration);
 		configuration.setMappedResources(new IResource[] {file});
 	}
 
 	private void updateProjectName(ILaunchConfigurationWorkingCopy configuration) {
         IFile file = getIFile(configuration);
         String projectName""//$NON-NLS-1$
         if (file != null) {
             projectNamefile.getProject().getName();
         }
         configuration.setAttribute(.projectName);
     }
 
 	private IFile getIFile(ILaunchConfigurationWorkingCopy configuration) {
		IFile filenull;
        if ( != null) {
            file;
            null;
        } else {
            IStringVariableManager manager = VariablesPlugin.getDefault().getStringVariableManager();
            try {
            	String locationconfiguration.getAttribute(., (String)null);
                if (location != null) {
                    String expandedLocationmanager.performStringSubstitution(location);
                    if (expandedLocation != null) {
                        file= AntUtil.getFileForLocation(expandedLocationnull);
                    }
                }
            } catch (CoreException e) {
            }
        }
		return file;
	}
    /* (non-Javadoc)
	 * @see org.eclipse.debug.ui.ILaunchConfigurationTab#createControl(org.eclipse.swt.widgets.Composite)
	 */
	public void createControl(Composite parent) {
		Composite mainComposite = new Composite(parent, SWT.NONE);
		setControl(mainComposite);
		GridLayout layout = new GridLayout();
		layout.numColumns = 1;
		GridData gridData = new GridData(GridData.FILL_HORIZONTAL);
		mainComposite.setLayout(layout);
		mainComposite.setLayoutData(gridData);
		mainComposite.setFont(parent.getFont());
		createVerticalSpacer(mainComposite, 2);
		Dialog.applyDialogFont(parent);
	}

Creates the controls needed to edit the set input handler attribute of an Ant build

Parameters:
parent the composite to create the controls in
	private void createSetInputHandlerComponent(Composite parent) {
		GridData data = new GridData(GridData.HORIZONTAL_ALIGN_FILL);
		data.horizontalSpan = 2;
		.setLayoutData(data);
		.addSelectionListener(new SelectionAdapter() {
			public void widgetSelected(SelectionEvent e) {
			}
		});
	}
	private void updateCheckButtons(ILaunchConfiguration configuration) {
		boolean setInputHandlertrue;
		try {
			setInputHandlerconfiguration.getAttribute(.true);
catch (CoreException ce) {
		}
		.setSelection(setInputHandler);
	}
	/* (non-Javadoc)
	 * @see org.eclipse.ui.externaltools.internal.launchConfigurations.ExternalToolsMainTab#handleWorkspaceLocationButtonSelected()
	 */
		dialog.open();
		IStructuredSelection result = dialog.getResult();
		if (result == null) {
			return;
		}
		Object fileresult.getFirstElement();
		if (file instanceof IFile) {
            = (IFile)file;
			.setText(VariablesPlugin.getDefault().getStringVariableManager().generateVariableExpression("workspace_loc".getFullPath().toString())); //$NON-NLS-1$
		}
	}
	/* (non-Javadoc)
	 * @see org.eclipse.ui.externaltools.internal.launchConfigurations.ExternalToolsMainTab#getWorkingDirectoryLabel()
	 */
	}
	private void updateTargetsTab() {
		//the location has changed...set the targets tab to 
		//need to be recomputed
		for (int i = 0; i < tabs.lengthi++) {
			ILaunchConfigurationTab tab = tabs[i];
			if (tab instanceof AntTargetsTab) {
				((AntTargetsTab)tab).setDirty(true);
				break;
			}
		}
	}
	/* (non-Javadoc)
	 * @see org.eclipse.ui.externaltools.internal.launchConfigurations.ExternalToolsMainTab#getLocationLabel()
	 */
	protected String getLocationLabel() {
	}
New to GrepCode? Check out our FAQ X