Start line:  
End line:  

Snippet Preview

Snippet HTML Code

Stack Overflow Questions
Copyright (c) 2005, 2008 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 java.util.Map;
 
 import  org.eclipse.swt.SWT;
 import  org.eclipse.swt.events.SelectionAdapter;
 import  org.eclipse.swt.events.SelectionEvent;
 import  org.eclipse.swt.events.SelectionListener;
 import  org.eclipse.swt.graphics.Image;
 import  org.eclipse.swt.layout.GridData;
 import  org.eclipse.swt.layout.GridLayout;
 import  org.eclipse.swt.widgets.Button;
 import  org.eclipse.swt.widgets.Composite;
 import  org.eclipse.swt.widgets.Label;
 import  org.eclipse.swt.widgets.Text;
 
 	
     
 	private Button fAfterCleanTarget;
 	private Button fManualBuildTarget;
 	private Button fAutoBuildTarget;
 	private Button fDuringCleanTarget;
     
     private Text fAfterCleanTargetText;
     private Text fManualBuildTargetText;
     private Text fAutoBuildTargetText;
     private Text fDuringCleanTargetText;
     
     private Map fAttributeToTargetsnew HashMap();
     
     
 	private SelectionListener fSelectionListenernew SelectionAdapter() {
 		/* (non-Javadoc)
 		 * @see org.eclipse.swt.events.SelectionListener#widgetSelected(org.eclipse.swt.events.SelectionEvent)
 		 */
 		public void widgetSelected(SelectionEvent e) {
             String attributenull;
 			Object source = e.getSource();
             Text textnull;
 			if (source == ) {
                 text;
 			} else if (source == ) {
                 text;
 			} else if (source == ) {
                 attribute......;
                 text;
 			} else if (source == ) {
                 text;
 			}
 			
             setTargets(attributetext);
             updateLaunchConfigurationDialog();
 		}
 	};
 	
 	public AntBuilderTargetsTab() {
 		super();
 	}
 	
 	protected void createTargetsComponent(Composite parent) {
 	    createText(parent);
 		GridData gd = new GridData(GridData.HORIZONTAL_ALIGN_END);
 		.setLayoutData(gd);
 		.addSelectionListener();
         = createText(parent);
		gd = new GridData(GridData.HORIZONTAL_ALIGN_END);
		.setLayoutData(gd);
        
         = createText(parent);
		gd = new GridData(GridData.HORIZONTAL_ALIGN_END);
		.setLayoutData(gd);
		.addSelectionListener();
        
         = createText(parent);
		gd = new GridData(GridData.HORIZONTAL_ALIGN_END);
		.setLayoutData(gd);
	}
    private Label createLabel(String text, Composite parent) {
        Label newLabelnew Label(parent, SWT.NONE);
        newLabel.setText(text);
        GridData gd = new GridData(GridData.FILL_HORIZONTAL);
        gd.horizontalSpan = 2;
        newLabel.setLayoutData(gd);
        newLabel.setFont(parent.getFont());
        return newLabel;
    }
    private Text createText(Composite parent) {
        GridData gd;
        Text newText = new Text(parent, SWT.MULTI | SWT.WRAP | SWT.BORDER | SWT.V_SCROLL | SWT.READ_ONLY);
        newText.setFont(parent.getFont());
        gd = new GridData(GridData.FILL_HORIZONTAL);
        gd.heightHint = 40;
        gd.widthHint = .;
        newText.setLayoutData(gd);
        return newText;
    }
    
	protected void setTargets(String attribute, Text text) {
        ILaunchConfigurationWorkingCopy copynull;
        try {
            copy = .getWorkingCopy();
        } catch (CoreException e) {
           return;
        }
		SetTargetsDialog dialognew SetTargetsDialog(getShell(), copy);
		if (dialog.open() != .) {
		    return;
        }
		String targetsSelecteddialog.getTargetsSelected();
       
        if (targetsSelected == null) {//default
			 text.setEnabled(true);
             setTargetsForUser(textnull);
         } else if (targetsSelected.length() == 0) {
			 text.setEnabled(false);
			 text.setText();
         } else {
             text.setEnabled(true);
             .put(attributetargetsSelected);
             setTargetsForUser(texttargetsSelectednull);
         }
	}
    private void setTargetsForUser(Text textString targetsSelectedString configTargets) {
		if (!text.isEnabled()) {
			text.setText();
			return;
		}
        if (targetsSelected == null) {
            if (configTargets == null) {
				//build kind has been specified..see initializeBuildKinds
                return;
            }
            targetsSelectedconfigTargets;
        }
        String[] targets= AntUtil.parseRunTargets(targetsSelected);
        StringBuffer resultnew StringBuffer(targets[0]);
        for (int i = 1; i < targets.lengthi++) {
             result.append(", "); //$NON-NLS-1$
             result.append(targets[i]);
        }
        text.setText(result.toString());
    }
    public void createControl(Composite parent) {
        Composite mainComposite = new Composite(parent, SWT.NONE);
        setControl(mainComposite);
        
        GridLayout layout = new GridLayout();
        GridData gridData = new GridData(GridData.FILL_HORIZONTAL);
        gridData.horizontalSpan = 2;
        layout.numColumns = 2;
        layout.makeColumnsEqualWidth = false;
        layout.horizontalSpacing=0;
        layout.verticalSpacing=0;
        mainComposite.setLayout(layout);
        mainComposite.setLayoutData(gridData);
        mainComposite.setFont(parent.getFont());
        createTargetsComponent(mainComposite);
    }
    public void setDefaults(ILaunchConfigurationWorkingCopy configuration) {
        configuration.setAttribute(.true);
    }
    public void initializeFrom(ILaunchConfiguration configuration) {
        configuration;
        
        .setEnabled(false);
        .setEnabled(false);
        .setEnabled(false);
        .setEnabled(false);
        initializeBuildKinds(configuration);
        intializeTargets(configuration);
    }
    private void intializeTargets(ILaunchConfiguration configuration) {
        String configTargetsnull;
        String autoTargetsnull;
        String manualTargetsnull;
        String afterCleanTargetsnull;
        String duringCleanTargetsnull;
        try {
				//not yet migrated to new format
			}
            
            autoTargetsconfiguration.getAttribute(......, (String)null);
            manualTargetsconfiguration.getAttribute(......, (String)null);
            afterCleanTargetsconfiguration.getAttribute(......, (String)null);
            duringCleanTargetsconfiguration.getAttribute(......, (String)null);
        } catch (CoreException ce) {
            AntUIPlugin.log("Error reading configuration"ce); //$NON-NLS-1$
        }
        
        setTargetsForUser(manualTargetsconfigTargets);
        setTargetsForUser(afterCleanTargetsconfigTargets);
        setTargetsForUser(duringCleanTargetsconfigTargets);
        setTargetsForUser(autoTargetsconfigTargets);
    }
	private void initializeAttributeToTargets(Text textComponentString specificTargetsString configTargetsString attribute) {
		if (textComponent.isEnabled()) {
			if (specificTargets == null && configTargets != null) {
				.put(attributeconfigTargets);
else {
				.put(attributespecificTargets);
			}
		}
	}
    private void initializeBuildKinds(ILaunchConfiguration configuration) {
        String buildKindStringnull;
        try {
            buildKindStringconfiguration.getAttribute(.""); //$NON-NLS-1$
        } catch (CoreException e) {
            AntUIPlugin.log("Error reading configuration"e); //$NON-NLS-1$
        }
        int buildTypes[]= BuilderUtils.buildTypesToArray(buildKindString);
        for (int i = 0; i < buildTypes.lengthi++) {
            switch (buildTypes[i]) {
                case .:
                    .setEnabled(true);
                    break;
                case .:
                    .setEnabled(true);
                    break;
                case .:
                    .setEnabled(true);
                    break;
                case .:
                    .setEnabled(true);
                    break;
            }
        }
    }
    public void performApply(ILaunchConfigurationWorkingCopy configuration) {
        StringBuffer buffernew StringBuffer();
        if (!.getText().equals()) {
            buffer.append(.).append(',');
        } 
        if (!.getText().equals()){
            buffer.append(.).append(','); 
        } 
        if (!.getText().equals()) {
            buffer.append(.).append(',');
        }
        if (!.getText().equals()) {
            buffer.append(.);
        }
        configuration.setAttribute(.buffer.toString());
        
    }
    /* (non-Javadoc)
     * @see org.eclipse.debug.ui.ILaunchConfigurationTab#getName()
     */
    public String getName() {
    }
        
    /* (non-Javadoc)
     * @see org.eclipse.debug.ui.ILaunchConfigurationTab#getImage()
     */
    public Image getImage() {
        return AntUIImages.getImage(.);
    }
New to GrepCode? Check out our FAQ X