1
0
Fork 0
mirror of https://github.com/eclipse-cdt/cdt synced 2025-04-23 14:42:11 +02:00

Bug 133881 - Make refreshing after building optional - UI changes

Work in progress.
This commit is contained in:
Vivian Kong 2011-04-21 21:08:26 +00:00
parent 60e7c6cda0
commit a3fc8296c8
8 changed files with 100 additions and 54 deletions

View file

@ -211,6 +211,8 @@ public class Messages extends NLS {
public static String PropertyPageDefsTab_9;
public static String PropertyPageDefsTab_showIncludeFileTab;
public static String RefreshPolicyExceptionDialog_addDialogLabel;
public static String RefreshPolicyExceptionDialog_AddExceptionInfoDialog_message;
public static String RefreshPolicyExceptionDialog_AddExceptionInfoDialog_title;
public static String RefreshPolicyExceptionDialog_editDialogLabel;
public static String RefreshPolicyExceptionDialog_exceptionPropertiesGroupLabel;
public static String RefreshPolicyExceptionDialog_exceptionTypeDropdownLabel;
@ -222,7 +224,7 @@ public class Messages extends NLS {
public static String RefreshPolicyTab_deleteConfirmationDialog_question_exception;
public static String RefreshPolicyTab_deleteConfirmationDialog_question_resource;
public static String RefreshPolicyTab_deleteConfirmationDialog_title;
public static String RefreshPolicyTab_editButtonLabel;
public static String RefreshPolicyTab_editExceptionButtonLabel;
public static String RefreshPolicyTab_exceptionsLabel;
public static String RefreshPolicyTab_resourcesGroupLabel;
public static String RefreshPolicyTab_tabLabel;

View file

@ -200,6 +200,8 @@ NewBuildMacroDialog_label_list_title=Value of Build Variable
# ----------- Refresh Policy Tab and Exception Dialog -----------
RefreshPolicyExceptionDialog_addDialogLabel=Add Exception
RefreshPolicyExceptionDialog_AddExceptionInfoDialog_message=Exceptions of all available exception types already exist for the selection. Please edit the existing exclusions instead.
RefreshPolicyExceptionDialog_AddExceptionInfoDialog_title=Cannot Add Exception
RefreshPolicyExceptionDialog_editDialogLabel=Edit Exception
RefreshPolicyExceptionDialog_exceptionPropertiesGroupLabel=Exception Properties
RefreshPolicyExceptionDialog_exceptionTypeDropdownLabel=Exception Type:
@ -211,7 +213,7 @@ RefreshPolicyTab_deleteButtonLabel=Delete...
RefreshPolicyTab_deleteConfirmationDialog_question_exception=You are removing an exception that has nested exceptions. Removing this exception will remove all nested exceptions. Do you want to continue?
RefreshPolicyTab_deleteConfirmationDialog_question_resource=You are removing a resource that has exceptions. Removing this resource will also remove all associated exceptions. Do you want to continue?
RefreshPolicyTab_deleteConfirmationDialog_title=Delete
RefreshPolicyTab_editButtonLabel=Edit...
RefreshPolicyTab_editExceptionButtonLabel=Edit Exception...
RefreshPolicyTab_exceptionsLabel=Exceptions
RefreshPolicyTab_resourcesGroupLabel=Resources
RefreshPolicyTab_tabLabel=The following resources will be refreshed after the project is built:

View file

@ -11,6 +11,7 @@
package org.eclipse.cdt.managedbuilder.ui.properties;
import java.util.Iterator;
import java.util.LinkedList;
import org.eclipse.cdt.core.resources.RefreshExclusion;
import org.eclipse.cdt.managedbuilder.internal.ui.Messages;
@ -44,8 +45,9 @@ import org.eclipse.swt.widgets.Shell;
*/
public class RefreshPolicyExceptionDialog extends Dialog {
private Combo exceptionTypeCombo;
private Group exceptionPropertiesGroup;
private Combo fExceptionTypeCombo;
private Group fExceptionPropertiesGroup;
private Shell fShell;
private IResource fResourceRoot = null;
private RefreshExclusion fExclusionRoot = null;
@ -60,7 +62,7 @@ public class RefreshPolicyExceptionDialog extends Dialog {
setShellStyle(getShellStyle());
fContrManager = RefreshExclusionContributionManager.getInstance();
fAddException = addException;
fExclusionContributors = fContrManager.getContributors();
fExclusionContributors = new LinkedList<RefreshExclusionContributor>(fContrManager.getContributors());
}
public RefreshPolicyExceptionDialog(Shell parent, IResource resource, java.util.List<RefreshExclusion> exclusions, boolean addException) {
@ -68,11 +70,29 @@ public class RefreshPolicyExceptionDialog extends Dialog {
//this is only called when an user is adding a RefreshException to a given resource
fResourceRoot = resource;
if (fAddException) {
removeExistingContributors(exclusions);
}
}
public RefreshPolicyExceptionDialog(Shell parent, RefreshExclusion exclusion, boolean addException) {
this(parent, addException);
fExclusionRoot = exclusion;
fExclusionRoot = exclusion;
if (fAddException) {
removeExistingContributors(exclusion.getNestedExclusions());
}
}
private void removeExistingContributors(java.util.List<RefreshExclusion> exclusions) {
if (exclusions != null) {
Iterator<RefreshExclusion> iterator = exclusions.iterator();
while (iterator.hasNext()) {
RefreshExclusion exclusion = iterator.next();
RefreshExclusionContributor contributor = fContrManager.getContributor(exclusion.getContributorId());
if (fExclusionContributors.contains(contributor))
fExclusionContributors.remove(contributor);
}
}
}
/* (non-Javadoc)
@ -85,6 +105,7 @@ public class RefreshPolicyExceptionDialog extends Dialog {
newShell.setText(Messages.RefreshPolicyExceptionDialog_addDialogLabel);
else
newShell.setText(Messages.RefreshPolicyExceptionDialog_editDialogLabel);
fShell = newShell;
}
/* (non-Javadoc)
@ -96,55 +117,65 @@ public class RefreshPolicyExceptionDialog extends Dialog {
comp.setLayout(new GridLayout(2, false));
comp.setLayoutData(new GridData(GridData.FILL_HORIZONTAL | GridData.FILL_VERTICAL));
Label exceptionType = new Label(comp, SWT.NONE);
exceptionType.setText(Messages.RefreshPolicyExceptionDialog_exceptionTypeDropdownLabel);
exceptionTypeCombo = new Combo(comp, SWT.READ_ONLY);
GridData gridData = new GridData(GridData.FILL_HORIZONTAL);
gridData.grabExcessHorizontalSpace = true;
exceptionTypeCombo.setLayoutData(gridData);
if (fAddException) {
Iterator<RefreshExclusionContributor> iterator = fExclusionContributors.iterator();
while (iterator.hasNext()) {
RefreshExclusionContributor contributor = iterator.next();
exceptionTypeCombo.add(contributor.getName());
}
} else {
exceptionTypeCombo.add(fContrManager.getContributor(fExclusionRoot.getContributorId()).getName());
}
exceptionTypeCombo.select(0);
exceptionTypeCombo.addSelectionListener(new SelectionAdapter() {
if (fExclusionContributors.size() == 0) {
fShell.setText(Messages.RefreshPolicyExceptionDialog_AddExceptionInfoDialog_title);
Label information = new Label(comp, SWT.NONE);
information.setText(Messages.RefreshPolicyExceptionDialog_AddExceptionInfoDialog_message);
information = new Label(comp, SWT.NONE);
fNewExclusion = null;
/* (non-Javadoc)
* @see org.eclipse.swt.events.SelectionAdapter#widgetSelected(org.eclipse.swt.events.SelectionEvent)
*/
@Override
public void widgetSelected(SelectionEvent e) {
if (exceptionPropertiesGroup != null)
exceptionPropertiesGroup.dispose();
generateExceptionPropertiesGroup(comp, exceptionTypeCombo.getSelectionIndex());
comp.layout();
} else {
Label exceptionType = new Label(comp, SWT.NONE);
exceptionType.setText(Messages.RefreshPolicyExceptionDialog_exceptionTypeDropdownLabel);
fExceptionTypeCombo = new Combo(comp, SWT.READ_ONLY);
GridData gridData = new GridData(GridData.FILL_HORIZONTAL);
gridData.grabExcessHorizontalSpace = true;
fExceptionTypeCombo.setLayoutData(gridData);
if (fAddException) {
Iterator<RefreshExclusionContributor> iterator = fExclusionContributors.iterator();
while (iterator.hasNext()) {
RefreshExclusionContributor contributor = iterator.next();
fExceptionTypeCombo.add(contributor.getName());
}
} else {
fExceptionTypeCombo.add(fContrManager.getContributor(fExclusionRoot.getContributorId()).getName());
}
});
generateExceptionPropertiesGroup(comp, exceptionTypeCombo.getSelectionIndex());
fExceptionTypeCombo.select(0);
fExceptionTypeCombo.addSelectionListener(new SelectionAdapter() {
/* (non-Javadoc)
* @see org.eclipse.swt.events.SelectionAdapter#widgetSelected(org.eclipse.swt.events.SelectionEvent)
*/
@Override
public void widgetSelected(SelectionEvent e) {
if (fExceptionPropertiesGroup != null)
fExceptionPropertiesGroup.dispose();
generateExceptionPropertiesGroup(comp, fExceptionTypeCombo.getSelectionIndex());
comp.layout();
}
});
generateExceptionPropertiesGroup(comp, fExceptionTypeCombo.getSelectionIndex());
}
return comp;
}
private void generateExceptionPropertiesGroup(Composite parent, int selectionIndex) {
exceptionPropertiesGroup = new Group(parent, SWT.NONE);
exceptionPropertiesGroup.setText(Messages.RefreshPolicyExceptionDialog_exceptionPropertiesGroupLabel);
exceptionPropertiesGroup.setLayout(new GridLayout(3, false));
fExceptionPropertiesGroup = new Group(parent, SWT.NONE);
fExceptionPropertiesGroup.setText(Messages.RefreshPolicyExceptionDialog_exceptionPropertiesGroupLabel);
fExceptionPropertiesGroup.setLayout(new GridLayout(3, false));
GridData gd = new GridData(GridData.FILL_HORIZONTAL | GridData.FILL_VERTICAL);
gd.verticalAlignment = GridData.FILL;
gd.horizontalSpan = 2;
exceptionPropertiesGroup.setLayoutData(gd);
fExceptionPropertiesGroup.setLayoutData(gd);
if (fAddException) {
if (fNewExclusion == null || fNewExclusion.getContributorId() != fExclusionContributors.get(selectionIndex).getID()){
@ -156,11 +187,11 @@ public class RefreshPolicyExceptionDialog extends Dialog {
fNewExclusion.setParentExclusion(fExclusionRoot);
}
fExclusionContributors.get(selectionIndex).createProperiesUI(exceptionPropertiesGroup, fNewExclusion);
fExclusionContributors.get(selectionIndex).createProperiesUI(fExceptionPropertiesGroup, fNewExclusion);
} else { //edit an exception
fContrManager.getContributor(fExclusionRoot.getContributorId()).createProperiesUI(exceptionPropertiesGroup, fExclusionRoot);
fContrManager.getContributor(fExclusionRoot.getContributorId()).createProperiesUI(fExceptionPropertiesGroup, fExclusionRoot);
}
}

View file

@ -73,7 +73,7 @@ public class RefreshPolicyTab extends AbstractCPropertyTab {
private final static int IDX_ADD_RESOURCE = 0;
private final static int IDX_ADD_EXCEPTION = 1;
private final static int IDX_EDIT = 2;
private final static int IDX_EDIT_EXCEPTION = 2;
private final static int IDX_DELETE = 3;
private TreeViewer fTree;
@ -299,7 +299,7 @@ public class RefreshPolicyTab extends AbstractCPropertyTab {
parent.exclusion.removeExclusionInstance(instance);
parent.exclusion_instances.remove(this);
if (parent.exclusion_instances.size() < 1) {
if (parent.exclusion_instances.size() < 1 && parent.exclusion.supportsExclusionInstances()) {
parent.remove();
}
}
@ -318,7 +318,7 @@ public class RefreshPolicyTab extends AbstractCPropertyTab {
initButtons(new String[] {
Messages.RefreshPolicyTab_addResourceButtonLabel,
Messages.RefreshPolicyTab_addExceptionButtonLabel,
Messages.RefreshPolicyTab_editButtonLabel,
Messages.RefreshPolicyTab_editExceptionButtonLabel,
Messages.RefreshPolicyTab_deleteButtonLabel}, 120);
usercomp.setLayout(new GridLayout(1, false));
@ -465,7 +465,7 @@ public class RefreshPolicyTab extends AbstractCPropertyTab {
TreeItem[] sel = fTree.getTree().getSelection();
buttonSetEnabled(IDX_ADD_RESOURCE, true);
buttonSetEnabled(IDX_ADD_EXCEPTION, sel.length == 1 && sel[0].getData() instanceof _Entry);
buttonSetEnabled(IDX_EDIT, sel.length == 1 && sel[0].getData() instanceof _Entry && ((_Entry) sel[0].getData()).isExclusion());
buttonSetEnabled(IDX_EDIT_EXCEPTION, sel.length == 1 && sel[0].getData() instanceof _Entry && ((_Entry) sel[0].getData()).isExclusion());
buttonSetEnabled(IDX_DELETE, sel.length == 1 && (sel[0].getData() instanceof _Entry || sel[0].getData() instanceof _Exclusion_Instance));
}
@ -519,7 +519,7 @@ public class RefreshPolicyTab extends AbstractCPropertyTab {
fTree.expandAll();
break;
case IDX_EDIT: //can only edit a refresh exclusion
case IDX_EDIT_EXCEPTION: //can only edit a refresh exclusion
if (selection == null)
break;
_Entry selectedExclusion = (_Entry) selection.getFirstElement();
@ -566,7 +566,7 @@ public class RefreshPolicyTab extends AbstractCPropertyTab {
} else { //exclusion instance
_Exclusion_Instance sel1 = (_Exclusion_Instance) selection.getFirstElement();
boolean remove = false;
if (sel1.parent.exclusion_instances.size() == 1 && sel1.parent.exceptions_node != null) {
if (sel1.parent.exclusion.supportsExclusionInstances() && sel1.parent.exclusion_instances.size() == 1 && sel1.parent.exceptions_node != null) {
//this is the only exclusion instance for an exclusion and the exclusion has nested exclusions
if (MessageDialog.openQuestion(shell, Messages.RefreshPolicyTab_deleteConfirmationDialog_title, Messages.RefreshPolicyTab_deleteConfirmationDialog_question_exception)) {
remove = true;

View file

@ -23,6 +23,7 @@ public class Messages extends NLS {
public static String RefreshScopeManager_1;
public static String RefreshScopeManager_2;
public static String RefreshScopeManager_3;
public static String ResourceExclusion_name;
static {
// initialize resource bundle
NLS.initializeMessages(BUNDLE_NAME, Messages.class);

View file

@ -347,4 +347,9 @@ public abstract class RefreshExclusion {
return exclusions;
}
/**
* @return true if this exclusion supports exclusion instances
*/
public abstract boolean supportsExclusionInstances();
}

View file

@ -33,8 +33,7 @@ public class ResourceExclusion extends RefreshExclusion {
*/
@Override
public String getName() {
// TODO Auto-generated method stub
return "Resource Exclusions";
return Messages.ResourceExclusion_name;
}
/* (non-Javadoc)
@ -46,4 +45,9 @@ public class ResourceExclusion extends RefreshExclusion {
return false;
}
@Override
public boolean supportsExclusionInstances() {
return true;
}
}

View file

@ -14,3 +14,4 @@ RefreshScopeManager_1=Error instantiating XML transformer.
RefreshScopeManager_2=Error transforming XML.
RefreshScopeManager_3=Error parsing refresh settings from project {0}
ResourceExclusion_name=Resource Exclusions