mirror of
https://github.com/eclipse-cdt/cdt
synced 2025-04-29 19:45:01 +02:00
This commit is contained in:
parent
88bb7ba72b
commit
df342408d4
3 changed files with 76 additions and 12 deletions
|
@ -116,10 +116,10 @@ BuildTargetDialog.button.build=Build
|
||||||
BuildTargetDialog.title.makeTargetsFor=Make Targets for:
|
BuildTargetDialog.title.makeTargetsFor=Make Targets for:
|
||||||
|
|
||||||
MakeTargetDialog.exception.noTargetBuilderOnProject=Not target builders on the project
|
MakeTargetDialog.exception.noTargetBuilderOnProject=Not target builders on the project
|
||||||
MakeTargetDialog.title.createMakeTarget=Create a new Make target.
|
MakeTargetDialog.title.createMakeTarget=Create a new Make target
|
||||||
MakeTargetDialog.title.modifyMakeTarget=Modify a Make target,
|
MakeTargetDialog.title.modifyMakeTarget=Modify a Make target
|
||||||
MakeTargetDialog.message.mustSpecifyName=Must specify a target name.
|
MakeTargetDialog.message.mustSpecifyName=Must specify a target name.
|
||||||
MakeTargetDialog.message.targetWithNameExists=Target with that name already exits
|
MakeTargetDialog.message.targetWithNameExists=Target with that name already exits.
|
||||||
MakeTargetDialog.message.mustSpecifyBuildCommand=Must specify a build command
|
MakeTargetDialog.message.mustSpecifyBuildCommand=Must specify a build command
|
||||||
MakeTargetDialog.button.update=Update
|
MakeTargetDialog.button.update=Update
|
||||||
MakeTargetDialog.button.create=Create
|
MakeTargetDialog.button.create=Create
|
||||||
|
|
|
@ -22,6 +22,8 @@ public class MessageLine extends CLabel {
|
||||||
|
|
||||||
private Color fNormalMsgAreaBackground;
|
private Color fNormalMsgAreaBackground;
|
||||||
|
|
||||||
|
private boolean hasErrorMessage;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Creates a new message line as a child of the given parent.
|
* Creates a new message line as a child of the given parent.
|
||||||
*/
|
*/
|
||||||
|
@ -44,10 +46,13 @@ public class MessageLine extends CLabel {
|
||||||
*/
|
*/
|
||||||
public void setErrorMessage(String message) {
|
public void setErrorMessage(String message) {
|
||||||
if (message != null && message.length() > 0) {
|
if (message != null && message.length() > 0) {
|
||||||
|
hasErrorMessage = true;
|
||||||
setText(message);
|
setText(message);
|
||||||
setImage(MakeUIImages.getImage(MakeUIImages.IMG_OBJS_ERROR));
|
setImage(MakeUIImages.getImage(MakeUIImages.IMG_OBJS_ERROR));
|
||||||
setBackground(JFaceColors.getErrorBackground(getDisplay()));
|
setBackground(JFaceColors.getErrorBackground(getDisplay()));
|
||||||
return;
|
return;
|
||||||
|
} else {
|
||||||
|
hasErrorMessage = false;
|
||||||
}
|
}
|
||||||
setText(fMessage);
|
setText(fMessage);
|
||||||
setImage(null);
|
setImage(null);
|
||||||
|
@ -58,4 +63,8 @@ public class MessageLine extends CLabel {
|
||||||
fMessage = message;
|
fMessage = message;
|
||||||
setText(message);
|
setText(message);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public boolean hasErrorMessage() {
|
||||||
|
return hasErrorMessage;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -75,6 +75,7 @@ public class MakeTargetDialog extends Dialog {
|
||||||
private String targetName;
|
private String targetName;
|
||||||
private String targetBuildID;
|
private String targetBuildID;
|
||||||
protected IMakeTarget fTarget;
|
protected IMakeTarget fTarget;
|
||||||
|
private boolean initializing = true;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param parentShell
|
* @param parentShell
|
||||||
|
@ -147,7 +148,7 @@ public class MakeTargetDialog extends Dialog {
|
||||||
GridData gd = new GridData(GridData.FILL_HORIZONTAL);
|
GridData gd = new GridData(GridData.FILL_HORIZONTAL);
|
||||||
gd.widthHint = convertWidthInCharsToPixels(50);
|
gd.widthHint = convertWidthInCharsToPixels(50);
|
||||||
fStatusLine.setLayoutData(gd);
|
fStatusLine.setLayoutData(gd);
|
||||||
|
initializing = false;
|
||||||
return composite;
|
return composite;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -167,21 +168,18 @@ public class MakeTargetDialog extends Dialog {
|
||||||
String newName = targetNameText.getText().trim();
|
String newName = targetNameText.getText().trim();
|
||||||
if (newName.equals("")) { //$NON-NLS-1$
|
if (newName.equals("")) { //$NON-NLS-1$
|
||||||
fStatusLine.setErrorMessage(MakeUIPlugin.getResourceString("MakeTargetDialog.message.mustSpecifyName")); //$NON-NLS-1$
|
fStatusLine.setErrorMessage(MakeUIPlugin.getResourceString("MakeTargetDialog.message.mustSpecifyName")); //$NON-NLS-1$
|
||||||
getButton(IDialogConstants.OK_ID).setEnabled(false);
|
|
||||||
} else
|
} else
|
||||||
try {
|
try {
|
||||||
if (fTarget != null && fTarget.getName().equals(newName)
|
if (fTarget != null && fTarget.getName().equals(newName)
|
||||||
|| fTargetManager.findTarget(fContainer, newName) == null) {
|
|| fTargetManager.findTarget(fContainer, newName) == null) {
|
||||||
fStatusLine.setErrorMessage(null);
|
fStatusLine.setErrorMessage(null);
|
||||||
getButton(IDialogConstants.OK_ID).setEnabled(true);
|
|
||||||
} else {
|
} else {
|
||||||
fStatusLine.setErrorMessage(MakeUIPlugin.getResourceString("MakeTargetDialog.message.targetWithNameExists")); //$NON-NLS-1$
|
fStatusLine.setErrorMessage(MakeUIPlugin.getResourceString("MakeTargetDialog.message.targetWithNameExists")); //$NON-NLS-1$
|
||||||
getButton(IDialogConstants.OK_ID).setEnabled(false);
|
|
||||||
}
|
}
|
||||||
} catch (CoreException ex) {
|
} catch (CoreException ex) {
|
||||||
fStatusLine.setErrorMessage(ex.getLocalizedMessage());
|
fStatusLine.setErrorMessage(ex.getLocalizedMessage());
|
||||||
getButton(IDialogConstants.OK_ID).setEnabled(false);
|
|
||||||
}
|
}
|
||||||
|
updateButtons();
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
@ -190,6 +188,13 @@ public class MakeTargetDialog extends Dialog {
|
||||||
Group group = ControlFactory.createGroup(parent, MakeUIPlugin.getResourceString(MAKE_SETTING_GROUP), 1);
|
Group group = ControlFactory.createGroup(parent, MakeUIPlugin.getResourceString(MAKE_SETTING_GROUP), 1);
|
||||||
stopOnErrorButton = new Button(group, SWT.CHECK);
|
stopOnErrorButton = new Button(group, SWT.CHECK);
|
||||||
stopOnErrorButton.setText(MakeUIPlugin.getResourceString(MAKE_SETTING_STOP_ERROR));
|
stopOnErrorButton.setText(MakeUIPlugin.getResourceString(MAKE_SETTING_STOP_ERROR));
|
||||||
|
stopOnErrorButton.addSelectionListener(new SelectionAdapter() {
|
||||||
|
|
||||||
|
public void widgetSelected(SelectionEvent e) {
|
||||||
|
updateButtons();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
if (isStopOnError) {
|
if (isStopOnError) {
|
||||||
stopOnErrorButton.setSelection(true);
|
stopOnErrorButton.setSelection(true);
|
||||||
}
|
}
|
||||||
|
@ -200,6 +205,12 @@ public class MakeTargetDialog extends Dialog {
|
||||||
}
|
}
|
||||||
runAllBuildersButton = new Button(group, SWT.CHECK);
|
runAllBuildersButton = new Button(group, SWT.CHECK);
|
||||||
runAllBuildersButton.setText(MakeUIPlugin.getResourceString("SettingsBlock.makeSetting.runAllBuilders")); //$NON-NLS-1$
|
runAllBuildersButton.setText(MakeUIPlugin.getResourceString("SettingsBlock.makeSetting.runAllBuilders")); //$NON-NLS-1$
|
||||||
|
runAllBuildersButton.addSelectionListener(new SelectionAdapter() {
|
||||||
|
|
||||||
|
public void widgetSelected(SelectionEvent e) {
|
||||||
|
updateButtons();
|
||||||
|
}
|
||||||
|
});
|
||||||
if (runAllBuilders) {
|
if (runAllBuilders) {
|
||||||
runAllBuildersButton.setSelection(true);
|
runAllBuildersButton.setSelection(true);
|
||||||
}
|
}
|
||||||
|
@ -223,6 +234,7 @@ public class MakeTargetDialog extends Dialog {
|
||||||
commandText.setEnabled(true);
|
commandText.setEnabled(true);
|
||||||
stopOnErrorButton.setEnabled(false);
|
stopOnErrorButton.setEnabled(false);
|
||||||
}
|
}
|
||||||
|
updateButtons();
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
GridData gd = new GridData(GridData.FILL_HORIZONTAL);
|
GridData gd = new GridData(GridData.FILL_HORIZONTAL);
|
||||||
|
@ -240,6 +252,7 @@ public class MakeTargetDialog extends Dialog {
|
||||||
if (commandText.getText().equals("")) { //$NON-NLS-1$
|
if (commandText.getText().equals("")) { //$NON-NLS-1$
|
||||||
fStatusLine.setErrorMessage(MakeUIPlugin.getResourceString("MakeTargetDialog.message.mustSpecifyBuildCommand")); //$NON-NLS-1$
|
fStatusLine.setErrorMessage(MakeUIPlugin.getResourceString("MakeTargetDialog.message.mustSpecifyBuildCommand")); //$NON-NLS-1$
|
||||||
}
|
}
|
||||||
|
updateButtons();
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
if (buildCommand != null) {
|
if (buildCommand != null) {
|
||||||
|
@ -275,6 +288,12 @@ public class MakeTargetDialog extends Dialog {
|
||||||
((GridData) (targetText.getLayoutData())).horizontalAlignment = GridData.FILL;
|
((GridData) (targetText.getLayoutData())).horizontalAlignment = GridData.FILL;
|
||||||
((GridData) (targetText.getLayoutData())).grabExcessHorizontalSpace = true;
|
((GridData) (targetText.getLayoutData())).grabExcessHorizontalSpace = true;
|
||||||
targetText.setText(targetString);
|
targetText.setText(targetString);
|
||||||
|
targetText.addListener(SWT.Modify, new Listener() {
|
||||||
|
|
||||||
|
public void handleEvent(Event e) {
|
||||||
|
updateButtons();
|
||||||
|
}
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
protected void createButtonsForButtonBar(Composite parent) {
|
protected void createButtonsForButtonBar(Composite parent) {
|
||||||
|
@ -295,6 +314,34 @@ public class MakeTargetDialog extends Dialog {
|
||||||
targetNameText.selectAll();
|
targetNameText.selectAll();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
protected void updateButtons() {
|
||||||
|
if (getButton(IDialogConstants.OK_ID) != null) {
|
||||||
|
getButton(IDialogConstants.OK_ID).setEnabled(targetHasChanged() && !fStatusLine.hasErrorMessage());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
protected boolean targetHasChanged() {
|
||||||
|
if (initializing || fTarget == null)
|
||||||
|
return true;
|
||||||
|
if (isStopOnError != isStopOnError())
|
||||||
|
return true;
|
||||||
|
if (runAllBuilders != runAllBuilders())
|
||||||
|
return true;
|
||||||
|
if (isDefaultCommand != useDefaultBuildCmd())
|
||||||
|
return true;
|
||||||
|
if (!targetName.equals(getTargetName()))
|
||||||
|
return true;
|
||||||
|
if (!targetString.equals(getTarget()))
|
||||||
|
return true;
|
||||||
|
if (!isDefaultCommand) {
|
||||||
|
StringBuffer cmd = new StringBuffer(buildCommand.toOSString()).append(buildArguments);
|
||||||
|
if (!getBuildLine().equals(cmd.toString())) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
private String generateUniqueName(String targetString) {
|
private String generateUniqueName(String targetString) {
|
||||||
String newName = targetString;
|
String newName = targetString;
|
||||||
int i = 0;
|
int i = 0;
|
||||||
|
@ -329,11 +376,19 @@ public class MakeTargetDialog extends Dialog {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private String getTarget() {
|
||||||
|
return targetText.getText().trim();
|
||||||
|
}
|
||||||
|
|
||||||
|
private String getTargetName() {
|
||||||
|
return targetNameText.getText().trim();
|
||||||
|
}
|
||||||
|
|
||||||
protected void okPressed() {
|
protected void okPressed() {
|
||||||
IMakeTarget target = fTarget;
|
IMakeTarget target = fTarget;
|
||||||
try {
|
try {
|
||||||
if (fTarget == null) {
|
if (fTarget == null) {
|
||||||
target = fTargetManager.createTarget(fContainer.getProject(), targetNameText.getText().trim(), targetBuildID);
|
target = fTargetManager.createTarget(fContainer.getProject(), getTargetName(), targetBuildID);
|
||||||
}
|
}
|
||||||
target.setStopOnError(isStopOnError());
|
target.setStopOnError(isStopOnError());
|
||||||
target.setRunAllBuilders(runAllBuilders());
|
target.setRunAllBuilders(runAllBuilders());
|
||||||
|
@ -361,13 +416,13 @@ public class MakeTargetDialog extends Dialog {
|
||||||
}
|
}
|
||||||
target.setBuildArguments(args);
|
target.setBuildArguments(args);
|
||||||
}
|
}
|
||||||
target.setBuildTarget(targetText.getText().trim());
|
target.setBuildTarget(getTarget());
|
||||||
|
|
||||||
if (fTarget == null) {
|
if (fTarget == null) {
|
||||||
fTargetManager.addTarget(fContainer, target);
|
fTargetManager.addTarget(fContainer, target);
|
||||||
} else {
|
} else {
|
||||||
if (!target.getName().equals(targetNameText.getText().trim())) {
|
if (!target.getName().equals(getTargetName())) {
|
||||||
fTargetManager.renameTarget(target, targetNameText.getText().trim());
|
fTargetManager.renameTarget(target, getTargetName());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} catch (CoreException e) {
|
} catch (CoreException e) {
|
||||||
|
|
Loading…
Add table
Reference in a new issue