1
0
Fork 0
mirror of https://github.com/eclipse-cdt/cdt synced 2025-04-29 19:45:01 +02:00

autotools: Bin dead code in property pages.

Removing unused code, making methods private to make it obvious when no
longer used (uncovered few cases), delete commented code and remove
methods that were simply one line invoking some method as they don't
create anything more but pollution.

Change-Id: I9aa0feedaedeb6509fe27772b1015ec953efa9e8
Signed-off-by: Alexander Kurtakov <akurtako@redhat.com>
This commit is contained in:
Alexander Kurtakov 2015-12-03 10:35:51 +02:00
parent f1a21f5c64
commit e01d886f1e
7 changed files with 15 additions and 147 deletions

View file

@ -38,17 +38,10 @@ public abstract class AbstractConfigurePropertyOptionsPage extends
@Override
protected void createFieldEditors() {
// Get the preference store for the build settings
IPreferenceStore settings = getConfigurePrefStore();
IPreferenceStore settings = AutotoolsConfigurePrefStore.getInstance();
setPreferenceStore(settings);
}
/**
* Return the tool settings preference store
*/
protected AutotoolsConfigurePrefStore getConfigurePrefStore() {
return AutotoolsConfigurePrefStore.getInstance();
}
/**
* Method called when the value of a dialog field changes
*/

View file

@ -116,7 +116,7 @@ public class AutotoolsCategoryPropertyOptionPage extends
fieldEditors.add(b);
break;
case IConfigureOption.FLAG:
FieldEditor l = createLabelEditor(area, option.getDescription());
FieldEditor l = new LabelFieldEditor(area, option.getDescription());
addField(l);
fieldEditors.add(l);
break;
@ -124,10 +124,6 @@ public class AutotoolsCategoryPropertyOptionPage extends
}
}
protected FieldEditor createLabelEditor( Composite parent, String title ) {
return new LabelFieldEditor( parent, title );
}
/**
* Update the field editor that displays all the build options
*/

View file

@ -55,10 +55,6 @@ public class AutotoolsConfigurePropertyTab extends AbstractAutotoolsCPropertyTab
private Map<String, List<AbstractConfigurePropertyOptionsPage>> configToPageListMap;
private IProject getProject() {
return page.getProject();
}
@Override
public boolean canBeVisible() {
if (page.isForProject() || page.isForPrefs()) {
@ -67,7 +63,7 @@ public class AutotoolsConfigurePropertyTab extends AbstractAutotoolsCPropertyTab
return false;
}
public IAConfiguration getAutotoolsCfg() {
private IAConfiguration getAutotoolsCfg() {
AutotoolsConfigurePropertyPage ap = (AutotoolsConfigurePropertyPage)page;
// We call getConfigurationData() to get the name because if the configuration has been renamed,
// it will cause the option value handler to clone the IAConfiguration
@ -88,7 +84,7 @@ public class AutotoolsConfigurePropertyTab extends AbstractAutotoolsCPropertyTab
@Override
public void createControls(Composite parent) {
AutotoolsConfigurationManager.getInstance().clearTmpConfigurations(getProject());
AutotoolsConfigurationManager.getInstance().clearTmpConfigurations(page.getProject());
syncClones();
super.createControls(parent);
@ -102,9 +98,6 @@ public class AutotoolsConfigurePropertyTab extends AbstractAutotoolsCPropertyTab
| GridData.FILL_VERTICAL);
composite.setLayoutData(gd);
GridLayout layout= new GridLayout();
// layout.numColumns= 2;
//PixelConverter pc= new PixelConverter(composite);
//layout.verticalSpacing= pc.convertHeightInCharsToPixels(1) / 2;
composite.setLayout(layout);
// Create the sash form
@ -117,25 +110,19 @@ public class AutotoolsConfigurePropertyTab extends AbstractAutotoolsCPropertyTab
sashForm.setLayout(layout);
createSelectionArea(sashForm);
createEditArea(sashForm);
// usercomp.addControlListener(new ControlAdapter() {
// @Override
// public void controlResized(ControlEvent e) {
// specificResize();
// }});
}
protected void createSelectionArea (Composite parent) {
private void createSelectionArea(Composite parent) {
fTree = new TreeViewer(parent, SWT.SINGLE|SWT.H_SCROLL|SWT.V_SCROLL|SWT.BORDER);
fTree.addSelectionChangedListener(event -> handleOptionSelection());
fTree.getControl().setLayoutData(new GridData(GridData.FILL_BOTH));
// Create a temporary default AutotoolsConfiguration to use for label info
IAConfiguration tmp = AutotoolsConfigurationManager.getInstance().createDefaultConfiguration(getProject(), "");
IAConfiguration tmp = AutotoolsConfigurationManager.getInstance().createDefaultConfiguration(page.getProject(),
"");
fTree.setLabelProvider(new ToolListLabelProvider(tmp));
}
protected void createEditArea(Composite parent) {
private void createEditArea(Composite parent) {
containerSC = new ScrolledComposite(parent, SWT.H_SCROLL | SWT.V_SCROLL | SWT.BORDER);
containerSC.setExpandHorizontal(true);
containerSC.setExpandVertical(true);
@ -149,7 +136,7 @@ public class AutotoolsConfigurePropertyTab extends AbstractAutotoolsCPropertyTab
settingsPageContainer.layout();
}
protected void setValues() {
private void setValues() {
/*
* This method updates the context of the build property pages
* - Which configuration/resource configuration is selected
@ -189,32 +176,6 @@ public class AutotoolsConfigurePropertyTab extends AbstractAutotoolsCPropertyTab
selectedElement = newElements[0];
fTree.setSelection(new StructuredSelection(selectedElement), true);
// // Determine what the selection in the tree should be
// // If the saved selection is not null, try to match the saved selection
// // with an object in the new element list.
// // Otherwise, select the first tool in the tree
// Object primaryObject = null;
// if (selectedElement != null) {
// selectedElement = matchSelectionElement(selectedElement, newElements);
// }
//
// if (selectedElement == null) {
// selectedElement = (newElements != null && newElements.length > 0 ? newElements[0] : null);
// }
//
// if (selectedElement != null) {
// primaryObject = selectedElement.getTool();
// if (primaryObject == null) {
// primaryObject = selectedElement.getOptionCategory();
// }
// if (primaryObject != null) {
// if (primaryObject instanceof IOptionCategory) {
// ((ToolSettingsPrefStore)settingsStore).setSelection(getResDesc(), selectedElement, (IOptionCategory)primaryObject);
// }
// optionList.setSelection(new StructuredSelection(selectedElement), true);
// }
// }
// specificResize();
}
private void handleOptionSelection() {
@ -287,8 +248,8 @@ public class AutotoolsConfigurePropertyTab extends AbstractAutotoolsCPropertyTab
}
/* (non-Javadoc)
* Answers the list of settings pages for the selected configuration
/**
* Answers the list of settings pages for the selected configuration
*/
private List<AbstractConfigurePropertyOptionsPage> getPagesForConfig() {
if (getCfg() == null) return null;
@ -300,26 +261,6 @@ public class AutotoolsConfigurePropertyTab extends AbstractAutotoolsCPropertyTab
return pages;
}
/**
* Returns the "dirty" state
*/
public boolean isDirty() {
// Check each settings page
List<AbstractConfigurePropertyOptionsPage> pages = getPagesForConfig();
// Make sure we have something to work on
if (pages == null) {
// Nothing to do
return false;
}
ListIterator<AbstractConfigurePropertyOptionsPage> iter = pages.listIterator();
while (iter.hasNext()) {
AbstractConfigurePropertyOptionsPage page = iter.next();
if (page == null) continue;
if (page.isDirty()) return true;
}
return false;
}
@Override
protected void performOK() {
ICConfigurationDescription[] cfgs = page.getCfgsEditable();
@ -330,19 +271,19 @@ public class AutotoolsConfigurePropertyTab extends AbstractAutotoolsCPropertyTab
IAConfiguration acfg = ap.getConfiguration(cd);
cfgList.put(cd.getId(), acfg);
}
IProject project = getProject();
IProject project = page.getProject();
AutotoolsConfigurationManager.getInstance().replaceProjectConfigurations(project, cfgList, cfgs);
AutotoolsConfigurationManager.getInstance().clearTmpConfigurations(project);
}
@Override
protected void performCancel() {
AutotoolsConfigurationManager.getInstance().clearTmpConfigurations(getProject());
AutotoolsConfigurationManager.getInstance().clearTmpConfigurations(page.getProject());
}
@Override
protected void performApply(ICResourceDescription src, ICResourceDescription dst) {
IProject project = getProject();
IProject project = page.getProject();
ICConfigurationDescription[] cfgs = page.getCfgsEditable();
// Apply all changes to existing saved configurations and new configurations, but do not perform
// deletions.

View file

@ -31,10 +31,6 @@ public class AutotoolsEditorPropertyTab extends AbstractAutotoolsCPropertyTab {
protected Combo fAMVersionCombo;
IProject project;
private IProject getProject() {
return page.getProject();
}
@Override
public boolean canBeVisible() {
return true;
@ -42,7 +38,6 @@ public class AutotoolsEditorPropertyTab extends AbstractAutotoolsCPropertyTab {
@Override
public void createControls(Composite parent) {
// TODO Auto-generated method stub
super.createControls(parent);
Composite composite= usercomp;
@ -55,7 +50,7 @@ public class AutotoolsEditorPropertyTab extends AbstractAutotoolsCPropertyTab {
//layout.verticalSpacing= pc.convertHeightInCharsToPixels(1) / 2;
composite.setLayout(layout);
project = getProject();
project = page.getProject();
/* check box for new editors */
fACVersionCombo= new Combo(composite, SWT.CHECK | SWT.DROP_DOWN | SWT.READ_ONLY);

View file

@ -14,7 +14,6 @@ import org.eclipse.cdt.internal.autotools.core.configure.IAConfiguration;
import org.eclipse.cdt.ui.newui.AbstractCPropertyTab;
import org.eclipse.cdt.ui.newui.MultiLineTextFieldEditor;
import org.eclipse.jface.dialogs.Dialog;
import org.eclipse.jface.preference.FieldEditor;
import org.eclipse.jface.preference.StringFieldEditor;
import org.eclipse.jface.util.PropertyChangeEvent;
import org.eclipse.swt.SWT;
@ -22,65 +21,20 @@ import org.eclipse.swt.graphics.FontMetrics;
import org.eclipse.swt.layout.GridData;
import org.eclipse.swt.layout.GridLayout;
import org.eclipse.swt.widgets.Composite;
import org.eclipse.swt.widgets.Label;
public class AutotoolsToolPropertyOptionPage extends
AbstractConfigurePropertyOptionsPage {
private static final int MARGIN = 3;
private ToolListElement element;
private String toolName = "";
private IAConfiguration cfg;
// Label class for a preference page.
static class LabelFieldEditor extends FieldEditor {
private String fTitle;
private Label fTitleLabel;
public LabelFieldEditor( Composite parent, String title ) {
fTitle = title;
this.createControl( parent );
}
@Override
protected void adjustForNumColumns( int numColumns ) {
((GridData)fTitleLabel.getLayoutData()).horizontalSpan = 2;
}
@Override
protected void doFillIntoGrid( Composite parent, int numColumns ) {
fTitleLabel = new Label( parent, SWT.WRAP );
fTitleLabel.setText( fTitle );
GridData gd = new GridData();
gd.verticalAlignment = SWT.TOP;
gd.grabExcessHorizontalSpace = false;
gd.horizontalSpan = 2;
fTitleLabel.setLayoutData( gd );
}
@Override
public int getNumberOfControls() { return 1; }
/**
* The label field editor is only used to present a text label on a preference page.
*/
@Override
protected void doLoad() {}
@Override
protected void doLoadDefault() {}
@Override
protected void doStore() {}
}
public AutotoolsToolPropertyOptionPage(ToolListElement element, IAConfiguration cfg) {
super(element.getName());
this.element = element;
this.toolName = element.getName();
this.cfg = cfg;
}
public ToolListElement getElement() {
return element;
}
@Override
protected void createFieldEditors() {
super.createFieldEditors();
@ -113,10 +67,6 @@ public class AutotoolsToolPropertyOptionPage extends
addField(allOptionFieldEditor);
}
protected FieldEditor createLabelEditor( Composite parent, String title ) {
return new LabelFieldEditor( parent, title );
}
// field editor that displays all the build options for a particular tool
private MultiLineTextFieldEditor allOptionFieldEditor;
//tool command field

View file

@ -12,7 +12,6 @@ package org.eclipse.cdt.internal.autotools.ui.properties;
import org.eclipse.cdt.core.settings.model.ICResourceDescription;
import org.eclipse.cdt.internal.autotools.core.AutotoolsPropertyConstants;
import org.eclipse.cdt.internal.autotools.core.configure.AutotoolsConfiguration;
import org.eclipse.cdt.internal.autotools.ui.AbstractAutotoolsCPropertyTab;
import org.eclipse.core.resources.IProject;
import org.eclipse.core.runtime.CoreException;
@ -50,13 +49,8 @@ public class AutotoolsToolsPropertyTab extends AbstractAutotoolsCPropertyTab {
return true;
}
public void cfgChanged(AutotoolsConfiguration cfg) {
// Nothing to do
}
@Override
public void createControls(Composite parent) {
// TODO Auto-generated method stub
super.createControls(parent);
Composite composite= usercomp;

View file

@ -72,7 +72,6 @@ public class ToolListContentProvider implements ITreeContentProvider {
@Override
public void inputChanged(Viewer viewer, Object oldInput, Object newInput) {
// TODO Auto-generated method stub
elements = createElements();
}