1
0
Fork 0
mirror of https://github.com/eclipse-cdt/cdt synced 2025-04-23 22:52: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_9;
public static String PropertyPageDefsTab_showIncludeFileTab; public static String PropertyPageDefsTab_showIncludeFileTab;
public static String RefreshPolicyExceptionDialog_addDialogLabel; 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_editDialogLabel;
public static String RefreshPolicyExceptionDialog_exceptionPropertiesGroupLabel; public static String RefreshPolicyExceptionDialog_exceptionPropertiesGroupLabel;
public static String RefreshPolicyExceptionDialog_exceptionTypeDropdownLabel; 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_exception;
public static String RefreshPolicyTab_deleteConfirmationDialog_question_resource; public static String RefreshPolicyTab_deleteConfirmationDialog_question_resource;
public static String RefreshPolicyTab_deleteConfirmationDialog_title; 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_exceptionsLabel;
public static String RefreshPolicyTab_resourcesGroupLabel; public static String RefreshPolicyTab_resourcesGroupLabel;
public static String RefreshPolicyTab_tabLabel; 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 ----------- # ----------- Refresh Policy Tab and Exception Dialog -----------
RefreshPolicyExceptionDialog_addDialogLabel=Add Exception 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_editDialogLabel=Edit Exception
RefreshPolicyExceptionDialog_exceptionPropertiesGroupLabel=Exception Properties RefreshPolicyExceptionDialog_exceptionPropertiesGroupLabel=Exception Properties
RefreshPolicyExceptionDialog_exceptionTypeDropdownLabel=Exception Type: 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_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_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_deleteConfirmationDialog_title=Delete
RefreshPolicyTab_editButtonLabel=Edit... RefreshPolicyTab_editExceptionButtonLabel=Edit Exception...
RefreshPolicyTab_exceptionsLabel=Exceptions RefreshPolicyTab_exceptionsLabel=Exceptions
RefreshPolicyTab_resourcesGroupLabel=Resources RefreshPolicyTab_resourcesGroupLabel=Resources
RefreshPolicyTab_tabLabel=The following resources will be refreshed after the project is built: 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; package org.eclipse.cdt.managedbuilder.ui.properties;
import java.util.Iterator; import java.util.Iterator;
import java.util.LinkedList;
import org.eclipse.cdt.core.resources.RefreshExclusion; import org.eclipse.cdt.core.resources.RefreshExclusion;
import org.eclipse.cdt.managedbuilder.internal.ui.Messages; import org.eclipse.cdt.managedbuilder.internal.ui.Messages;
@ -44,8 +45,9 @@ import org.eclipse.swt.widgets.Shell;
*/ */
public class RefreshPolicyExceptionDialog extends Dialog { public class RefreshPolicyExceptionDialog extends Dialog {
private Combo exceptionTypeCombo; private Combo fExceptionTypeCombo;
private Group exceptionPropertiesGroup; private Group fExceptionPropertiesGroup;
private Shell fShell;
private IResource fResourceRoot = null; private IResource fResourceRoot = null;
private RefreshExclusion fExclusionRoot = null; private RefreshExclusion fExclusionRoot = null;
@ -60,7 +62,7 @@ public class RefreshPolicyExceptionDialog extends Dialog {
setShellStyle(getShellStyle()); setShellStyle(getShellStyle());
fContrManager = RefreshExclusionContributionManager.getInstance(); fContrManager = RefreshExclusionContributionManager.getInstance();
fAddException = addException; fAddException = addException;
fExclusionContributors = fContrManager.getContributors(); fExclusionContributors = new LinkedList<RefreshExclusionContributor>(fContrManager.getContributors());
} }
public RefreshPolicyExceptionDialog(Shell parent, IResource resource, java.util.List<RefreshExclusion> exclusions, boolean addException) { 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 //this is only called when an user is adding a RefreshException to a given resource
fResourceRoot = resource; fResourceRoot = resource;
if (fAddException) {
removeExistingContributors(exclusions);
}
} }
public RefreshPolicyExceptionDialog(Shell parent, RefreshExclusion exclusion, boolean addException) { public RefreshPolicyExceptionDialog(Shell parent, RefreshExclusion exclusion, boolean addException) {
this(parent, 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) /* (non-Javadoc)
@ -85,6 +105,7 @@ public class RefreshPolicyExceptionDialog extends Dialog {
newShell.setText(Messages.RefreshPolicyExceptionDialog_addDialogLabel); newShell.setText(Messages.RefreshPolicyExceptionDialog_addDialogLabel);
else else
newShell.setText(Messages.RefreshPolicyExceptionDialog_editDialogLabel); newShell.setText(Messages.RefreshPolicyExceptionDialog_editDialogLabel);
fShell = newShell;
} }
/* (non-Javadoc) /* (non-Javadoc)
@ -96,55 +117,65 @@ public class RefreshPolicyExceptionDialog extends Dialog {
comp.setLayout(new GridLayout(2, false)); comp.setLayout(new GridLayout(2, false));
comp.setLayoutData(new GridData(GridData.FILL_HORIZONTAL | GridData.FILL_VERTICAL)); comp.setLayoutData(new GridData(GridData.FILL_HORIZONTAL | GridData.FILL_VERTICAL));
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;
} else {
Label exceptionType = new Label(comp, SWT.NONE); Label exceptionType = new Label(comp, SWT.NONE);
exceptionType.setText(Messages.RefreshPolicyExceptionDialog_exceptionTypeDropdownLabel); exceptionType.setText(Messages.RefreshPolicyExceptionDialog_exceptionTypeDropdownLabel);
exceptionTypeCombo = new Combo(comp, SWT.READ_ONLY); fExceptionTypeCombo = new Combo(comp, SWT.READ_ONLY);
GridData gridData = new GridData(GridData.FILL_HORIZONTAL); GridData gridData = new GridData(GridData.FILL_HORIZONTAL);
gridData.grabExcessHorizontalSpace = true; gridData.grabExcessHorizontalSpace = true;
exceptionTypeCombo.setLayoutData(gridData); fExceptionTypeCombo.setLayoutData(gridData);
if (fAddException) { if (fAddException) {
Iterator<RefreshExclusionContributor> iterator = fExclusionContributors.iterator(); Iterator<RefreshExclusionContributor> iterator = fExclusionContributors.iterator();
while (iterator.hasNext()) { while (iterator.hasNext()) {
RefreshExclusionContributor contributor = iterator.next(); RefreshExclusionContributor contributor = iterator.next();
exceptionTypeCombo.add(contributor.getName()); fExceptionTypeCombo.add(contributor.getName());
} }
} else { } else {
exceptionTypeCombo.add(fContrManager.getContributor(fExclusionRoot.getContributorId()).getName()); fExceptionTypeCombo.add(fContrManager.getContributor(fExclusionRoot.getContributorId()).getName());
} }
exceptionTypeCombo.select(0); fExceptionTypeCombo.select(0);
exceptionTypeCombo.addSelectionListener(new SelectionAdapter() { fExceptionTypeCombo.addSelectionListener(new SelectionAdapter() {
/* (non-Javadoc) /* (non-Javadoc)
* @see org.eclipse.swt.events.SelectionAdapter#widgetSelected(org.eclipse.swt.events.SelectionEvent) * @see org.eclipse.swt.events.SelectionAdapter#widgetSelected(org.eclipse.swt.events.SelectionEvent)
*/ */
@Override @Override
public void widgetSelected(SelectionEvent e) { public void widgetSelected(SelectionEvent e) {
if (exceptionPropertiesGroup != null) if (fExceptionPropertiesGroup != null)
exceptionPropertiesGroup.dispose(); fExceptionPropertiesGroup.dispose();
generateExceptionPropertiesGroup(comp, exceptionTypeCombo.getSelectionIndex()); generateExceptionPropertiesGroup(comp, fExceptionTypeCombo.getSelectionIndex());
comp.layout(); comp.layout();
} }
}); });
generateExceptionPropertiesGroup(comp, exceptionTypeCombo.getSelectionIndex()); generateExceptionPropertiesGroup(comp, fExceptionTypeCombo.getSelectionIndex());
}
return comp; return comp;
} }
private void generateExceptionPropertiesGroup(Composite parent, int selectionIndex) { private void generateExceptionPropertiesGroup(Composite parent, int selectionIndex) {
exceptionPropertiesGroup = new Group(parent, SWT.NONE); fExceptionPropertiesGroup = new Group(parent, SWT.NONE);
exceptionPropertiesGroup.setText(Messages.RefreshPolicyExceptionDialog_exceptionPropertiesGroupLabel); fExceptionPropertiesGroup.setText(Messages.RefreshPolicyExceptionDialog_exceptionPropertiesGroupLabel);
exceptionPropertiesGroup.setLayout(new GridLayout(3, false)); fExceptionPropertiesGroup.setLayout(new GridLayout(3, false));
GridData gd = new GridData(GridData.FILL_HORIZONTAL | GridData.FILL_VERTICAL); GridData gd = new GridData(GridData.FILL_HORIZONTAL | GridData.FILL_VERTICAL);
gd.verticalAlignment = GridData.FILL; gd.verticalAlignment = GridData.FILL;
gd.horizontalSpan = 2; gd.horizontalSpan = 2;
exceptionPropertiesGroup.setLayoutData(gd); fExceptionPropertiesGroup.setLayoutData(gd);
if (fAddException) { if (fAddException) {
if (fNewExclusion == null || fNewExclusion.getContributorId() != fExclusionContributors.get(selectionIndex).getID()){ if (fNewExclusion == null || fNewExclusion.getContributorId() != fExclusionContributors.get(selectionIndex).getID()){
@ -156,11 +187,11 @@ public class RefreshPolicyExceptionDialog extends Dialog {
fNewExclusion.setParentExclusion(fExclusionRoot); fNewExclusion.setParentExclusion(fExclusionRoot);
} }
fExclusionContributors.get(selectionIndex).createProperiesUI(exceptionPropertiesGroup, fNewExclusion); fExclusionContributors.get(selectionIndex).createProperiesUI(fExceptionPropertiesGroup, fNewExclusion);
} else { //edit an exception } 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_RESOURCE = 0;
private final static int IDX_ADD_EXCEPTION = 1; 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 final static int IDX_DELETE = 3;
private TreeViewer fTree; private TreeViewer fTree;
@ -299,7 +299,7 @@ public class RefreshPolicyTab extends AbstractCPropertyTab {
parent.exclusion.removeExclusionInstance(instance); parent.exclusion.removeExclusionInstance(instance);
parent.exclusion_instances.remove(this); parent.exclusion_instances.remove(this);
if (parent.exclusion_instances.size() < 1) { if (parent.exclusion_instances.size() < 1 && parent.exclusion.supportsExclusionInstances()) {
parent.remove(); parent.remove();
} }
} }
@ -318,7 +318,7 @@ public class RefreshPolicyTab extends AbstractCPropertyTab {
initButtons(new String[] { initButtons(new String[] {
Messages.RefreshPolicyTab_addResourceButtonLabel, Messages.RefreshPolicyTab_addResourceButtonLabel,
Messages.RefreshPolicyTab_addExceptionButtonLabel, Messages.RefreshPolicyTab_addExceptionButtonLabel,
Messages.RefreshPolicyTab_editButtonLabel, Messages.RefreshPolicyTab_editExceptionButtonLabel,
Messages.RefreshPolicyTab_deleteButtonLabel}, 120); Messages.RefreshPolicyTab_deleteButtonLabel}, 120);
usercomp.setLayout(new GridLayout(1, false)); usercomp.setLayout(new GridLayout(1, false));
@ -465,7 +465,7 @@ public class RefreshPolicyTab extends AbstractCPropertyTab {
TreeItem[] sel = fTree.getTree().getSelection(); TreeItem[] sel = fTree.getTree().getSelection();
buttonSetEnabled(IDX_ADD_RESOURCE, true); buttonSetEnabled(IDX_ADD_RESOURCE, true);
buttonSetEnabled(IDX_ADD_EXCEPTION, sel.length == 1 && sel[0].getData() instanceof _Entry); 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)); 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(); fTree.expandAll();
break; break;
case IDX_EDIT: //can only edit a refresh exclusion case IDX_EDIT_EXCEPTION: //can only edit a refresh exclusion
if (selection == null) if (selection == null)
break; break;
_Entry selectedExclusion = (_Entry) selection.getFirstElement(); _Entry selectedExclusion = (_Entry) selection.getFirstElement();
@ -566,7 +566,7 @@ public class RefreshPolicyTab extends AbstractCPropertyTab {
} else { //exclusion instance } else { //exclusion instance
_Exclusion_Instance sel1 = (_Exclusion_Instance) selection.getFirstElement(); _Exclusion_Instance sel1 = (_Exclusion_Instance) selection.getFirstElement();
boolean remove = false; 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 //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)) { if (MessageDialog.openQuestion(shell, Messages.RefreshPolicyTab_deleteConfirmationDialog_title, Messages.RefreshPolicyTab_deleteConfirmationDialog_question_exception)) {
remove = true; remove = true;

View file

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

View file

@ -347,4 +347,9 @@ public abstract class RefreshExclusion {
return exclusions; 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 @Override
public String getName() { public String getName() {
// TODO Auto-generated method stub return Messages.ResourceExclusion_name;
return "Resource Exclusions";
} }
/* (non-Javadoc) /* (non-Javadoc)
@ -46,4 +45,9 @@ public class ResourceExclusion extends RefreshExclusion {
return false; 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_2=Error transforming XML.
RefreshScopeManager_3=Error parsing refresh settings from project {0} RefreshScopeManager_3=Error parsing refresh settings from project {0}
ResourceExclusion_name=Resource Exclusions