From 727981016342909a60563ab3a2643b578ab380e3 Mon Sep 17 00:00:00 2001 From: Hoda Amer Date: Thu, 24 Jun 2004 19:56:54 +0000 Subject: [PATCH] Bug Fixing --- core/org.eclipse.cdt.ui/ChangeLog | 1 + .../ui/wizards/NewWizardMessages.properties | 10 +++ .../wizards/dialogfields/LinkToFileGroup.java | 71 +++---------------- .../dialogfields/StringDialogField.java | 2 +- 4 files changed, 21 insertions(+), 63 deletions(-) diff --git a/core/org.eclipse.cdt.ui/ChangeLog b/core/org.eclipse.cdt.ui/ChangeLog index 402e6a4de8a..b7b3b84b7e6 100644 --- a/core/org.eclipse.cdt.ui/ChangeLog +++ b/core/org.eclipse.cdt.ui/ChangeLog @@ -1,5 +1,6 @@ 2004-06-24 Hoda Amer A small fix to the New Class Wizard "link to file" option. + Fix for PR# 47570 : [New Class Wizard] Use of internal Eclipse classes in CDT(LinkToFileGroup) 2004-06-24 Chris Wiebe Fix for PR 48783 : [New Class Wizard] Err Create C++ Class with "Link to File" checkbox selected diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/wizards/NewWizardMessages.properties b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/wizards/NewWizardMessages.properties index 461519029ff..b0798d31579 100644 --- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/wizards/NewWizardMessages.properties +++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/wizards/NewWizardMessages.properties @@ -156,6 +156,16 @@ CreateLinkedResourceGroup.resolvedPathLabel=Resolved Location: CreateLinkedResourceGroup.browseButton=Browse... CreateLinkedResourceGroup.variablesButton=Variables... CreateLinkedResourceGroup.open=Open +CreateLinkedResourceGroup.targetSelectionLabel= Select the link target. +CreateLinkedResourceGroup.linkTargetNotFile= Link target must be a file +CreateLinkedResourceGroup.linkTargetNotFolder= Link target must be a folder +CreateLinkedResourceGroup.linkTargetNonExistent= Link target does not exist +CreateLinkedResourceGroup.linkTargetEmpty = Link target must be specified +CreateLinkedResourceGroup.linkTargetInvalid = Link target name is invalid +CreateLinkedResourceGroup.linkTargetNotAbsolute = Link target must be absolute path or path variable and relative path. + + + NewClassWizardPage.error.EnterClassName=Class name is empty. NewClassWizardPage.error.ClassNameExists=Class already exists. diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/wizards/dialogfields/LinkToFileGroup.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/wizards/dialogfields/LinkToFileGroup.java index 82e8cfbc7a7..2fc04c8798c 100644 --- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/wizards/dialogfields/LinkToFileGroup.java +++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/wizards/dialogfields/LinkToFileGroup.java @@ -13,6 +13,7 @@ package org.eclipse.cdt.internal.ui.wizards.dialogfields; import java.io.File; import org.eclipse.cdt.internal.ui.wizards.NewWizardMessages; +import org.eclipse.cdt.ui.CUIPlugin; import org.eclipse.core.resources.IPathVariableManager; import org.eclipse.core.resources.IResource; import org.eclipse.core.resources.IWorkspace; @@ -38,11 +39,10 @@ import org.eclipse.swt.widgets.FileDialog; import org.eclipse.swt.widgets.Label; import org.eclipse.swt.widgets.Listener; import org.eclipse.swt.widgets.Text; -import org.eclipse.ui.internal.WorkbenchMessages; -import org.eclipse.ui.internal.WorkbenchPlugin; -import org.eclipse.ui.internal.ide.dialogs.PathVariableSelectionDialog; /** + * This class is part of the NewClassWizard + * It handels the Link to file part */ public class LinkToFileGroup extends StringButtonDialogField { private String fText; @@ -59,7 +59,6 @@ public class LinkToFileGroup extends StringButtonDialogField { protected Text linkTargetField; protected Button linkButton; protected Button browseButton; - protected Button variablesButton; private Label resolvedPathLabelText; private Label resolvedPathLabelData; private boolean preventDialogFieldChanged = false; @@ -80,13 +79,10 @@ public class LinkToFileGroup extends StringButtonDialogField { getLinkCheckButtonControl(parent); Text text= getTextControl(parent); - text.setLayoutData(gridDataForText(1)); + text.setLayoutData(gridDataForText(2)); Button browseButton = getBrowseButtonControl(parent); browseButton.setLayoutData(gridDataForButton(browseButton, 1)); - - Button variablesButton = getVariablesButtonControl(parent); - variablesButton.setLayoutData(gridDataForButton(variablesButton, 1)); DialogField.createEmptySpace(parent); @@ -120,7 +116,6 @@ public class LinkToFileGroup extends StringButtonDialogField { public void widgetSelected(SelectionEvent e) { createLink = linkButton.getSelection(); browseButton.setEnabled(createLink); - variablesButton.setEnabled(createLink); linkTargetField.setEnabled(createLink); resolveVariable(); if (listener != null) @@ -196,23 +191,6 @@ public class LinkToFileGroup extends StringButtonDialogField { return browseButton; } - public Button getVariablesButtonControl(Composite parent){ - // variables button - if(variablesButton == null){ - assertCompositeNotNull(parent); - variablesButton = new Button(parent, SWT.PUSH); - //setButtonLayoutData(variablesButton); - variablesButton.setFont(parent.getFont()); - variablesButton.setText(NewWizardMessages.getString("CreateLinkedResourceGroup.variablesButton")); //$NON-NLS-1$ - variablesButton.addSelectionListener(new SelectionAdapter() { - public void widgetSelected(SelectionEvent event) { - handleVariablesButtonPressed(); - } - }); - variablesButton.setEnabled(createLink); - } - return variablesButton; - } /** * Returns a new status object with the given severity and message. * @@ -221,7 +199,7 @@ public class LinkToFileGroup extends StringButtonDialogField { private IStatus createStatus(int severity, String message) { return new Status( severity, - WorkbenchPlugin.getDefault().getBundle().getSymbolicName(), + CUIPlugin.getPluginId(), severity, message, null); @@ -279,7 +257,7 @@ public class LinkToFileGroup extends StringButtonDialogField { if (linkTargetName != null) dialog.setFilterPath(linkTargetName); } - dialog.setMessage(WorkbenchMessages.getString("CreateLinkedResourceGroup.targetSelectionLabel")); //$NON-NLS-1$ + dialog.setMessage(NewWizardMessages.getString("CreateLinkedResourceGroup.targetSelectionLabel")); //$NON-NLS-1$ selection = dialog.open(); } if (selection != null) { @@ -288,29 +266,6 @@ public class LinkToFileGroup extends StringButtonDialogField { dialogFieldChanged(); } } - /** - * Opens a path variable selection dialog - */ - protected void handleVariablesButtonPressed() { - int variableTypes = IResource.FOLDER; - - // allow selecting file and folder variables when creating a - // linked file - if (type == IResource.FILE) - variableTypes |= IResource.FILE; - - PathVariableSelectionDialog dialog = - new PathVariableSelectionDialog(linkTargetField.getShell(), variableTypes); - if (dialog.open() == IDialogConstants.OK_ID) { - String[] variableNames = (String[]) dialog.getResult(); - if (variableNames != null && variableNames.length == 1) - { - linkTargetField.setText(variableNames[0]); - if (!preventDialogFieldChanged) - dialogFieldChanged(); - } - } - } /** * Tries to resolve the value entered in the link target field as * a variable, if the value is a relative path. @@ -326,14 +281,6 @@ public class LinkToFileGroup extends StringButtonDialogField { IPath path = new Path(linkTargetField.getText()); IPath resolvedPath = pathVariableManager.resolvePath(path); - /* (path.equals(resolvedPath)) { - resolvedPathLabelText.setVisible(false); - resolvedPathLabelData.setVisible(false); - } else { - resolvedPathLabelText.setVisible(true); - resolvedPathLabelData.setVisible(true); - } - */ resolvedPathLabelData.setText(resolvedPath.toOSString()); } /** @@ -361,11 +308,11 @@ public class LinkToFileGroup extends StringButtonDialogField { if (type == IResource.FILE && linkTargetFile.isFile() == false) { return createStatus( IStatus.ERROR, - WorkbenchMessages.getString("CreateLinkedResourceGroup.linkTargetNotFile")); //$NON-NLS-1$ + NewWizardMessages.getString("CreateLinkedResourceGroup.linkTargetNotFile")); //$NON-NLS-1$ } else if (type == IResource.FOLDER && linkTargetFile.isDirectory() == false) { return createStatus( IStatus.ERROR, - WorkbenchMessages.getString("CreateLinkedResourceGroup.linkTargetNotFolder")); //$NON-NLS-1$ + NewWizardMessages.getString("CreateLinkedResourceGroup.linkTargetNotFolder")); //$NON-NLS-1$ } return createStatus(IStatus.OK, ""); //$NON-NLS-1$ } @@ -402,7 +349,7 @@ public class LinkToFileGroup extends StringButtonDialogField { // locationStatus takes precedence over missing location warning. return createStatus( IStatus.WARNING, - WorkbenchMessages.getString("CreateLinkedResourceGroup.linkTargetNonExistent")); //$NON-NLS-1$ + NewWizardMessages.getString("CreateLinkedResourceGroup.linkTargetNonExistent")); //$NON-NLS-1$ } return locationStatus; } diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/wizards/dialogfields/StringDialogField.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/wizards/dialogfields/StringDialogField.java index 2bc15ba7a4d..e9937723454 100644 --- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/wizards/dialogfields/StringDialogField.java +++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/wizards/dialogfields/StringDialogField.java @@ -53,7 +53,7 @@ public class StringDialogField extends DialogField { protected static GridData gridDataForText(int span) { GridData gd= new GridData(); gd.horizontalAlignment= GridData.FILL; - gd.grabExcessHorizontalSpace= false; + gd.grabExcessHorizontalSpace= true; gd.horizontalSpan= span; return gd; }