mirror of
https://github.com/eclipse-cdt/cdt
synced 2025-04-29 19:45:01 +02:00
Patch for Chris W.
This commit is contained in:
parent
09c86e033a
commit
aed8d9ac91
4 changed files with 76 additions and 16 deletions
|
@ -1,3 +1,6 @@
|
|||
2004-06-24 Chris Wiebe
|
||||
Fix for PR 48783 : [New Class Wizard] Err Create C++ Class with "Link to File" checkbox selected
|
||||
|
||||
2004-06-23 Tanya Wolff
|
||||
Fix for bugs 66134,66145
|
||||
* src/org/eclipse/cdt/internal/ui/dialogs/cpaths/CPathEntryMessages.properties
|
||||
|
|
|
@ -175,6 +175,11 @@ NewClassWizardPage.getProjectClasses.exception.message=Unexpected exception. See
|
|||
NewClassWizardPage.getProjectClasses.noclasses.title=Class Selection
|
||||
NewClassWizardPage.getProjectClasses.noclasses.message=No classes available.
|
||||
|
||||
NewClassWizardPage.error.EnterHeaderFile=Header file is empty.
|
||||
NewClassWizardPage.error.EnterBodyFile=Body file is empty.
|
||||
NewClassWizardPage.error.NoHeaderFile=Header file does not exist.
|
||||
NewClassWizardPage.error.NoBodyFile=Body file does not exist.
|
||||
|
||||
# ------- BaseClassSelectionDialog -----
|
||||
|
||||
BaseClassSelectionDialog.title=Choose Base Class
|
||||
|
|
|
@ -121,8 +121,10 @@ public class LinkToFileGroup extends StringButtonDialogField {
|
|||
browseButton.setEnabled(createLink);
|
||||
variablesButton.setEnabled(createLink);
|
||||
linkTargetField.setEnabled(createLink);
|
||||
resolveVariable();
|
||||
if (listener != null)
|
||||
listener.handleEvent(new Event());
|
||||
dialogFieldChanged();
|
||||
}
|
||||
};
|
||||
linkButton.addSelectionListener(selectionListener);
|
||||
|
@ -138,9 +140,8 @@ public class LinkToFileGroup extends StringButtonDialogField {
|
|||
fText= text;
|
||||
if (isOkToUse(linkTargetField)) {
|
||||
linkTargetField.setText(text);
|
||||
} else {
|
||||
dialogFieldChanged();
|
||||
}
|
||||
}
|
||||
dialogFieldChanged();
|
||||
}
|
||||
|
||||
public Text getTextControl(Composite parent){
|
||||
|
@ -154,6 +155,7 @@ public class LinkToFileGroup extends StringButtonDialogField {
|
|||
resolveVariable();
|
||||
if (listener != null)
|
||||
listener.handleEvent(new Event());
|
||||
dialogFieldChanged();
|
||||
}
|
||||
});
|
||||
if (initialLinkTarget != null)
|
||||
|
@ -275,8 +277,10 @@ public class LinkToFileGroup extends StringButtonDialogField {
|
|||
dialog.setMessage(WorkbenchMessages.getString("CreateLinkedResourceGroup.targetSelectionLabel")); //$NON-NLS-1$
|
||||
selection = dialog.open();
|
||||
}
|
||||
if (selection != null)
|
||||
if (selection != null) {
|
||||
linkTargetField.setText(selection);
|
||||
dialogFieldChanged();
|
||||
}
|
||||
}
|
||||
/**
|
||||
* Opens a path variable selection dialog
|
||||
|
@ -294,7 +298,10 @@ public class LinkToFileGroup extends StringButtonDialogField {
|
|||
if (dialog.open() == IDialogConstants.OK_ID) {
|
||||
String[] variableNames = (String[]) dialog.getResult();
|
||||
if (variableNames != null && variableNames.length == 1)
|
||||
{
|
||||
linkTargetField.setText(variableNames[0]);
|
||||
dialogFieldChanged();
|
||||
}
|
||||
}
|
||||
}
|
||||
/**
|
||||
|
@ -303,8 +310,10 @@ public class LinkToFileGroup extends StringButtonDialogField {
|
|||
* Displays the resolved value if the entered value is a variable.
|
||||
*/
|
||||
protected void resolveVariable() {
|
||||
if(!linkTargetField.isEnabled())
|
||||
if(!linkTargetField.isEnabled()) {
|
||||
resolvedPathLabelData.setText("");
|
||||
return;
|
||||
}
|
||||
|
||||
IPathVariableManager pathVariableManager = ResourcesPlugin.getWorkspace().getPathVariableManager();
|
||||
IPath path = new Path(linkTargetField.getText());
|
||||
|
@ -327,8 +336,10 @@ public class LinkToFileGroup extends StringButtonDialogField {
|
|||
*/
|
||||
public void setLinkTarget(String target) {
|
||||
initialLinkTarget = target;
|
||||
if (linkTargetField != null && linkTargetField.isDisposed() == false)
|
||||
if (linkTargetField != null && linkTargetField.isDisposed() == false) {
|
||||
linkTargetField.setText(target);
|
||||
dialogFieldChanged();
|
||||
}
|
||||
}
|
||||
/**
|
||||
* Validates the type of the given file against the link type specified
|
||||
|
|
|
@ -12,6 +12,7 @@ package org.eclipse.cdt.ui.wizards;
|
|||
|
||||
|
||||
import java.io.ByteArrayInputStream;
|
||||
import java.io.File;
|
||||
import java.io.InputStream;
|
||||
import java.lang.reflect.InvocationTargetException;
|
||||
import java.text.MessageFormat;
|
||||
|
@ -132,6 +133,8 @@ public class NewClassWizardPage extends WizardPage implements Listener {
|
|||
private IStatus fCurrStatus;
|
||||
protected IStatus fClassNameStatus;
|
||||
protected IStatus fBaseClassStatus;
|
||||
protected IStatus fLinkedResourceGroupForHeaderStatus;
|
||||
protected IStatus fLinkedResourceGroupForBodyStatus;
|
||||
|
||||
private boolean hasCppNature = false;
|
||||
|
||||
|
@ -179,12 +182,16 @@ public class NewClassWizardPage extends WizardPage implements Listener {
|
|||
fConstDestButtons.setDialogFieldListener(adapter);
|
||||
|
||||
linkedResourceGroupForHeader = new LinkToFileGroup(adapter, this);
|
||||
linkedResourceGroupForHeader.setDialogFieldListener(adapter);
|
||||
linkedResourceGroupForHeader.setLabelText(NewWizardMessages.getString("NewClassWizardPage.files.header")); //$NON-NLS-1$
|
||||
linkedResourceGroupForBody = new LinkToFileGroup(adapter, this);
|
||||
linkedResourceGroupForBody.setDialogFieldListener(adapter);
|
||||
linkedResourceGroupForBody.setLabelText(NewWizardMessages.getString("NewClassWizardPage.files.body")); //$NON-NLS-1$
|
||||
|
||||
fClassNameStatus= new StatusInfo();
|
||||
fBaseClassStatus= new StatusInfo();
|
||||
fLinkedResourceGroupForHeaderStatus= new StatusInfo();
|
||||
fLinkedResourceGroupForBodyStatus= new StatusInfo();
|
||||
}
|
||||
|
||||
public void init() {
|
||||
|
@ -376,17 +383,49 @@ public class NewClassWizardPage extends WizardPage implements Listener {
|
|||
}
|
||||
|
||||
if(field == fBaseClassDialogField){
|
||||
if(fBaseClassDialogField.getText().length() >= 0)
|
||||
{
|
||||
fAccessButtons.setEnabled(true);
|
||||
fBaseClassStatus = baseClassNameChanged();
|
||||
}
|
||||
else{
|
||||
fAccessButtons.setEnabled(false);
|
||||
}
|
||||
}
|
||||
String text = fBaseClassDialogField.getText();
|
||||
fAccessButtons.setEnabled(text.length() > 0);
|
||||
fBaseClassStatus = baseClassNameChanged();
|
||||
}
|
||||
|
||||
if (field == linkedResourceGroupForHeader) {
|
||||
fLinkedResourceGroupForHeaderStatus = linkedResourceGroupChanged(linkedResourceGroupForHeader, true);
|
||||
}
|
||||
if (field == linkedResourceGroupForBody) {
|
||||
fLinkedResourceGroupForBodyStatus = linkedResourceGroupChanged(linkedResourceGroupForBody, false);
|
||||
}
|
||||
|
||||
doStatusUpdate();
|
||||
}
|
||||
|
||||
IStatus linkedResourceGroupChanged(LinkToFileGroup linkedGroup, boolean isHeader) {
|
||||
StatusInfo status = new StatusInfo();
|
||||
String text = linkedGroup.getText();
|
||||
if (linkedGroup.linkCreated()) {
|
||||
// must not be empty
|
||||
if (text == null || text.length() == 0) {
|
||||
if (isHeader)
|
||||
status.setError(NewWizardMessages.getString("NewClassWizardPage.error.EnterHeaderFile")); //$NON-NLS-1$
|
||||
else
|
||||
status.setError(NewWizardMessages.getString("NewClassWizardPage.error.EnterBodyFile")); //$NON-NLS-1$
|
||||
} else {
|
||||
// check if file exists
|
||||
IPath filePath = getContainerFullPath(linkedGroup);
|
||||
boolean validFile = false;
|
||||
if (filePath != null) {
|
||||
File f = filePath.toFile();
|
||||
validFile = (f != null && f.exists() && f.isFile());
|
||||
}
|
||||
if (!validFile) {
|
||||
if (isHeader)
|
||||
status.setError(NewWizardMessages.getString("NewClassWizardPage.error.NoHeaderFile")); //$NON-NLS-1$
|
||||
else
|
||||
status.setError(NewWizardMessages.getString("NewClassWizardPage.error.NoBodyFile")); //$NON-NLS-1$
|
||||
}
|
||||
}
|
||||
}
|
||||
return status;
|
||||
}
|
||||
|
||||
// --------------- Helper methods for creating controls -----
|
||||
public boolean selectionIsCpp(){
|
||||
|
@ -986,7 +1025,9 @@ public class NewClassWizardPage extends WizardPage implements Listener {
|
|||
IStatus[] status= new IStatus[] {
|
||||
fClassNameStatus,
|
||||
fBaseClassStatus,
|
||||
};
|
||||
fLinkedResourceGroupForHeaderStatus,
|
||||
fLinkedResourceGroupForBodyStatus
|
||||
};
|
||||
|
||||
// the mode severe status will be displayed and the ok button enabled/disabled.
|
||||
updateStatus(status);
|
||||
|
|
Loading…
Add table
Reference in a new issue