blob: ada5133187b0f7161b4892e7250671ecaee2d447 [file] [log] [blame]
/*******************************************************************************
* Copyright (c) 2017 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
*
* This is an implementation of an early-draft specification developed under the Java
* Community Process (JCP) and is made available for testing and evaluation purposes
* only. The code is not compatible with any specification of the JCP.
*
* Contributors:
* IBM Corporation - initial API and implementation
*******************************************************************************/
package org.eclipse.jdt.internal.ui.wizards.buildpaths;
import org.eclipse.swt.widgets.Shell;
import org.eclipse.jface.resource.ImageDescriptor;
import org.eclipse.jdt.core.IClasspathAttribute;
import org.eclipse.jdt.core.JavaCore;
import org.eclipse.jdt.ui.wizards.ClasspathAttributeConfiguration;
import org.eclipse.jdt.internal.ui.JavaPluginImages;
import org.eclipse.jdt.internal.ui.wizards.NewWizardMessages;
public class WithoutTestCodeAttributeConfiguration extends ClasspathAttributeConfiguration {
public static final String TRUE= "true"; //$NON-NLS-1$
@Override
public ImageDescriptor getImageDescriptor(ClasspathAttributeAccess attribute) {
return JavaPluginImages.DESC_OBJS_TEST_ATTRIB;
}
@Override
public String getNameLabel(ClasspathAttributeAccess attribute) {
return NewWizardMessages.CPListLabelProvider_without_test_code_label;
}
@Override
public String getValueLabel(ClasspathAttributeAccess access) {
String value= access.getClasspathAttribute().getValue();
return TRUE.equals(value) ? NewWizardMessages.CPListLabelProvider_test_yes : NewWizardMessages.CPListLabelProvider_test_no;
}
@Override
public boolean canEdit(ClasspathAttributeAccess attribute) {
return true;
}
@Override
public boolean canRemove(ClasspathAttributeAccess attribute) {
return false;
}
@Override
public IClasspathAttribute performEdit(Shell shell, ClasspathAttributeAccess attribute) {
String initialValue= attribute.getClasspathAttribute().getValue();
String newValue= TRUE.equals(initialValue) ? null : TRUE;
return JavaCore.newClasspathAttribute(CPListElement.WITHOUT_TEST_CODE, newValue);
}
@Override
public IClasspathAttribute performRemove(ClasspathAttributeAccess attribute) {
return JavaCore.newClasspathAttribute(CPListElement.WITHOUT_TEST_CODE, null);
}
}