mirror of
https://github.com/eclipse-cdt/cdt
synced 2025-06-05 08:46:02 +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
|
2004-06-23 Tanya Wolff
|
||||||
Fix for bugs 66134,66145
|
Fix for bugs 66134,66145
|
||||||
* src/org/eclipse/cdt/internal/ui/dialogs/cpaths/CPathEntryMessages.properties
|
* 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.title=Class Selection
|
||||||
NewClassWizardPage.getProjectClasses.noclasses.message=No classes available.
|
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 -----
|
||||||
|
|
||||||
BaseClassSelectionDialog.title=Choose Base Class
|
BaseClassSelectionDialog.title=Choose Base Class
|
||||||
|
|
|
@ -121,8 +121,10 @@ public class LinkToFileGroup extends StringButtonDialogField {
|
||||||
browseButton.setEnabled(createLink);
|
browseButton.setEnabled(createLink);
|
||||||
variablesButton.setEnabled(createLink);
|
variablesButton.setEnabled(createLink);
|
||||||
linkTargetField.setEnabled(createLink);
|
linkTargetField.setEnabled(createLink);
|
||||||
|
resolveVariable();
|
||||||
if (listener != null)
|
if (listener != null)
|
||||||
listener.handleEvent(new Event());
|
listener.handleEvent(new Event());
|
||||||
|
dialogFieldChanged();
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
linkButton.addSelectionListener(selectionListener);
|
linkButton.addSelectionListener(selectionListener);
|
||||||
|
@ -138,9 +140,8 @@ public class LinkToFileGroup extends StringButtonDialogField {
|
||||||
fText= text;
|
fText= text;
|
||||||
if (isOkToUse(linkTargetField)) {
|
if (isOkToUse(linkTargetField)) {
|
||||||
linkTargetField.setText(text);
|
linkTargetField.setText(text);
|
||||||
} else {
|
}
|
||||||
dialogFieldChanged();
|
dialogFieldChanged();
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public Text getTextControl(Composite parent){
|
public Text getTextControl(Composite parent){
|
||||||
|
@ -154,6 +155,7 @@ public class LinkToFileGroup extends StringButtonDialogField {
|
||||||
resolveVariable();
|
resolveVariable();
|
||||||
if (listener != null)
|
if (listener != null)
|
||||||
listener.handleEvent(new Event());
|
listener.handleEvent(new Event());
|
||||||
|
dialogFieldChanged();
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
if (initialLinkTarget != null)
|
if (initialLinkTarget != null)
|
||||||
|
@ -275,8 +277,10 @@ public class LinkToFileGroup extends StringButtonDialogField {
|
||||||
dialog.setMessage(WorkbenchMessages.getString("CreateLinkedResourceGroup.targetSelectionLabel")); //$NON-NLS-1$
|
dialog.setMessage(WorkbenchMessages.getString("CreateLinkedResourceGroup.targetSelectionLabel")); //$NON-NLS-1$
|
||||||
selection = dialog.open();
|
selection = dialog.open();
|
||||||
}
|
}
|
||||||
if (selection != null)
|
if (selection != null) {
|
||||||
linkTargetField.setText(selection);
|
linkTargetField.setText(selection);
|
||||||
|
dialogFieldChanged();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
/**
|
/**
|
||||||
* Opens a path variable selection dialog
|
* Opens a path variable selection dialog
|
||||||
|
@ -294,7 +298,10 @@ public class LinkToFileGroup extends StringButtonDialogField {
|
||||||
if (dialog.open() == IDialogConstants.OK_ID) {
|
if (dialog.open() == IDialogConstants.OK_ID) {
|
||||||
String[] variableNames = (String[]) dialog.getResult();
|
String[] variableNames = (String[]) dialog.getResult();
|
||||||
if (variableNames != null && variableNames.length == 1)
|
if (variableNames != null && variableNames.length == 1)
|
||||||
|
{
|
||||||
linkTargetField.setText(variableNames[0]);
|
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.
|
* Displays the resolved value if the entered value is a variable.
|
||||||
*/
|
*/
|
||||||
protected void resolveVariable() {
|
protected void resolveVariable() {
|
||||||
if(!linkTargetField.isEnabled())
|
if(!linkTargetField.isEnabled()) {
|
||||||
|
resolvedPathLabelData.setText("");
|
||||||
return;
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
IPathVariableManager pathVariableManager = ResourcesPlugin.getWorkspace().getPathVariableManager();
|
IPathVariableManager pathVariableManager = ResourcesPlugin.getWorkspace().getPathVariableManager();
|
||||||
IPath path = new Path(linkTargetField.getText());
|
IPath path = new Path(linkTargetField.getText());
|
||||||
|
@ -327,8 +336,10 @@ public class LinkToFileGroup extends StringButtonDialogField {
|
||||||
*/
|
*/
|
||||||
public void setLinkTarget(String target) {
|
public void setLinkTarget(String target) {
|
||||||
initialLinkTarget = target;
|
initialLinkTarget = target;
|
||||||
if (linkTargetField != null && linkTargetField.isDisposed() == false)
|
if (linkTargetField != null && linkTargetField.isDisposed() == false) {
|
||||||
linkTargetField.setText(target);
|
linkTargetField.setText(target);
|
||||||
|
dialogFieldChanged();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
/**
|
/**
|
||||||
* Validates the type of the given file against the link type specified
|
* 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.ByteArrayInputStream;
|
||||||
|
import java.io.File;
|
||||||
import java.io.InputStream;
|
import java.io.InputStream;
|
||||||
import java.lang.reflect.InvocationTargetException;
|
import java.lang.reflect.InvocationTargetException;
|
||||||
import java.text.MessageFormat;
|
import java.text.MessageFormat;
|
||||||
|
@ -132,6 +133,8 @@ public class NewClassWizardPage extends WizardPage implements Listener {
|
||||||
private IStatus fCurrStatus;
|
private IStatus fCurrStatus;
|
||||||
protected IStatus fClassNameStatus;
|
protected IStatus fClassNameStatus;
|
||||||
protected IStatus fBaseClassStatus;
|
protected IStatus fBaseClassStatus;
|
||||||
|
protected IStatus fLinkedResourceGroupForHeaderStatus;
|
||||||
|
protected IStatus fLinkedResourceGroupForBodyStatus;
|
||||||
|
|
||||||
private boolean hasCppNature = false;
|
private boolean hasCppNature = false;
|
||||||
|
|
||||||
|
@ -179,12 +182,16 @@ public class NewClassWizardPage extends WizardPage implements Listener {
|
||||||
fConstDestButtons.setDialogFieldListener(adapter);
|
fConstDestButtons.setDialogFieldListener(adapter);
|
||||||
|
|
||||||
linkedResourceGroupForHeader = new LinkToFileGroup(adapter, this);
|
linkedResourceGroupForHeader = new LinkToFileGroup(adapter, this);
|
||||||
|
linkedResourceGroupForHeader.setDialogFieldListener(adapter);
|
||||||
linkedResourceGroupForHeader.setLabelText(NewWizardMessages.getString("NewClassWizardPage.files.header")); //$NON-NLS-1$
|
linkedResourceGroupForHeader.setLabelText(NewWizardMessages.getString("NewClassWizardPage.files.header")); //$NON-NLS-1$
|
||||||
linkedResourceGroupForBody = new LinkToFileGroup(adapter, this);
|
linkedResourceGroupForBody = new LinkToFileGroup(adapter, this);
|
||||||
|
linkedResourceGroupForBody.setDialogFieldListener(adapter);
|
||||||
linkedResourceGroupForBody.setLabelText(NewWizardMessages.getString("NewClassWizardPage.files.body")); //$NON-NLS-1$
|
linkedResourceGroupForBody.setLabelText(NewWizardMessages.getString("NewClassWizardPage.files.body")); //$NON-NLS-1$
|
||||||
|
|
||||||
fClassNameStatus= new StatusInfo();
|
fClassNameStatus= new StatusInfo();
|
||||||
fBaseClassStatus= new StatusInfo();
|
fBaseClassStatus= new StatusInfo();
|
||||||
|
fLinkedResourceGroupForHeaderStatus= new StatusInfo();
|
||||||
|
fLinkedResourceGroupForBodyStatus= new StatusInfo();
|
||||||
}
|
}
|
||||||
|
|
||||||
public void init() {
|
public void init() {
|
||||||
|
@ -376,17 +383,49 @@ public class NewClassWizardPage extends WizardPage implements Listener {
|
||||||
}
|
}
|
||||||
|
|
||||||
if(field == fBaseClassDialogField){
|
if(field == fBaseClassDialogField){
|
||||||
if(fBaseClassDialogField.getText().length() >= 0)
|
String text = fBaseClassDialogField.getText();
|
||||||
{
|
fAccessButtons.setEnabled(text.length() > 0);
|
||||||
fAccessButtons.setEnabled(true);
|
fBaseClassStatus = baseClassNameChanged();
|
||||||
fBaseClassStatus = baseClassNameChanged();
|
}
|
||||||
}
|
|
||||||
else{
|
if (field == linkedResourceGroupForHeader) {
|
||||||
fAccessButtons.setEnabled(false);
|
fLinkedResourceGroupForHeaderStatus = linkedResourceGroupChanged(linkedResourceGroupForHeader, true);
|
||||||
}
|
}
|
||||||
}
|
if (field == linkedResourceGroupForBody) {
|
||||||
|
fLinkedResourceGroupForBodyStatus = linkedResourceGroupChanged(linkedResourceGroupForBody, false);
|
||||||
|
}
|
||||||
|
|
||||||
doStatusUpdate();
|
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 -----
|
// --------------- Helper methods for creating controls -----
|
||||||
public boolean selectionIsCpp(){
|
public boolean selectionIsCpp(){
|
||||||
|
@ -986,7 +1025,9 @@ public class NewClassWizardPage extends WizardPage implements Listener {
|
||||||
IStatus[] status= new IStatus[] {
|
IStatus[] status= new IStatus[] {
|
||||||
fClassNameStatus,
|
fClassNameStatus,
|
||||||
fBaseClassStatus,
|
fBaseClassStatus,
|
||||||
};
|
fLinkedResourceGroupForHeaderStatus,
|
||||||
|
fLinkedResourceGroupForBodyStatus
|
||||||
|
};
|
||||||
|
|
||||||
// the mode severe status will be displayed and the ok button enabled/disabled.
|
// the mode severe status will be displayed and the ok button enabled/disabled.
|
||||||
updateStatus(status);
|
updateStatus(status);
|
||||||
|
|
Loading…
Add table
Reference in a new issue