|
From: <caw...@us...> - 2007-07-24 17:31:02
|
Revision: 2832
http://svn.sourceforge.net/rubyeclipse/?rev=2832&view=rev
Author: cawilliams
Date: 2007-07-24 10:30:58 -0700 (Tue, 24 Jul 2007)
Log Message:
-----------
fix #5141 - Ruby Class Wizard folder/source root folder fields are confusing. Combine the two dialog fields into one. Now user just selects the ultimate folder they want the type/test placed into.
Modified Paths:
--------------
trunk/org.rubypeople.rdt.ui/src/org/rubypeople/rdt/internal/corext/util/RubyModelUtil.java
trunk/org.rubypeople.rdt.ui/src/org/rubypeople/rdt/ui/StandardRubyElementContentProvider.java
trunk/org.rubypeople.rdt.ui/src/org/rubypeople/rdt/ui/wizards/NewClassWizardPage.java
trunk/org.rubypeople.rdt.ui/src/org/rubypeople/rdt/ui/wizards/NewContainerWizardPage.java
trunk/org.rubypeople.rdt.ui/src/org/rubypeople/rdt/ui/wizards/NewTypeWizardPage.java
Modified: trunk/org.rubypeople.rdt.ui/src/org/rubypeople/rdt/internal/corext/util/RubyModelUtil.java
===================================================================
--- trunk/org.rubypeople.rdt.ui/src/org/rubypeople/rdt/internal/corext/util/RubyModelUtil.java 2007-07-24 15:29:07 UTC (rev 2831)
+++ trunk/org.rubypeople.rdt.ui/src/org/rubypeople/rdt/internal/corext/util/RubyModelUtil.java 2007-07-24 17:30:58 UTC (rev 2832)
@@ -78,6 +78,10 @@
public static ISourceFolderRoot getSourceFolderRoot(IRubyElement element) {
return (ISourceFolderRoot) element.getAncestor(IRubyElement.SOURCE_FOLDER_ROOT);
}
+
+ public static ISourceFolder getSourceFolder(IRubyElement element) {
+ return (ISourceFolder) element.getAncestor(IRubyElement.SOURCE_FOLDER);
+ }
public static boolean isExcludedPath(IPath resourcePath, IPath[] exclusionPatterns) {
char[] path = resourcePath.toString().toCharArray();
Modified: trunk/org.rubypeople.rdt.ui/src/org/rubypeople/rdt/ui/StandardRubyElementContentProvider.java
===================================================================
--- trunk/org.rubypeople.rdt.ui/src/org/rubypeople/rdt/ui/StandardRubyElementContentProvider.java 2007-07-24 15:29:07 UTC (rev 2831)
+++ trunk/org.rubypeople.rdt.ui/src/org/rubypeople/rdt/ui/StandardRubyElementContentProvider.java 2007-07-24 17:30:58 UTC (rev 2832)
@@ -10,6 +10,7 @@
*******************************************************************************/
package org.rubypeople.rdt.ui;
+import java.io.File;
import java.util.ArrayList;
import java.util.List;
@@ -193,6 +194,17 @@
private Object[] getSourceFolders(ISourceFolderRoot root) throws RubyModelException {
IRubyElement[] fragments= root.getChildren();
+ List<IRubyElement> list = new ArrayList<IRubyElement>();
+ for (int i = 0; i < fragments.length; i++) {
+ if (!(fragments[i] instanceof ISourceFolder)) continue;
+ ISourceFolder folder = (ISourceFolder) fragments[i];
+ if (folder.isDefaultPackage()) continue;
+ String name = folder.getElementName();
+ int index = name.indexOf(File.separatorChar);
+ if (index == -1) list.add(folder);
+ }
+ fragments = new IRubyElement[list.size()];
+ fragments = list.toArray(fragments);
Object[] nonRubyResources= root.getNonRubyResources();
if (nonRubyResources == null)
return fragments;
@@ -210,7 +222,7 @@
for (int i= 0; i < roots.length; i++) {
ISourceFolderRoot root= roots[i];
if (isProjectSourceFolderRoot(root)) {
- Object[] children= root.getChildren();
+ Object[] children= getChildren(root);
for (int k= 0; k < children.length; k++)
list.add(children[k]);
}
@@ -230,7 +242,21 @@
}
private Object[] getFoldersAndRubyScripts(ISourceFolder folder) throws RubyModelException {
- return concatenate(folder.getRubyScripts(), folder.getNonRubyResources());
+ ISourceFolderRoot root = (ISourceFolderRoot) folder.getParent();
+ IRubyElement[] children = root.getChildren();
+ List<IRubyElement> list = new ArrayList<IRubyElement>();
+ for (int i = 0; i < children.length; i++) {
+ if (children[i].equals(folder)) continue;
+ if (!children[i].getElementName().startsWith(folder.getElementName())) continue;
+ String name = children[i].getElementName();
+ name = name.substring(folder.getElementName().length() + 1);
+ int index = name.indexOf(File.separator);
+ if (index != -1) continue;
+ list.add(children[i]);
+ }
+ IRubyElement[] folders = new IRubyElement[list.size()];
+ folders = list.toArray(folders);
+ return concatenate(folders, concatenate(folder.getRubyScripts(), folder.getNonRubyResources()));
}
Modified: trunk/org.rubypeople.rdt.ui/src/org/rubypeople/rdt/ui/wizards/NewClassWizardPage.java
===================================================================
--- trunk/org.rubypeople.rdt.ui/src/org/rubypeople/rdt/ui/wizards/NewClassWizardPage.java 2007-07-24 15:29:07 UTC (rev 2831)
+++ trunk/org.rubypeople.rdt.ui/src/org/rubypeople/rdt/ui/wizards/NewClassWizardPage.java 2007-07-24 17:30:58 UTC (rev 2832)
@@ -111,7 +111,7 @@
// pick & choose the wanted UI components
createContainerControls(composite, nColumns);
- createPackageControls(composite, nColumns);
+// createPackageControls(composite, nColumns);
// createEnclosingTypeControls(composite, nColumns);
createSeparator(composite, nColumns);
Modified: trunk/org.rubypeople.rdt.ui/src/org/rubypeople/rdt/ui/wizards/NewContainerWizardPage.java
===================================================================
--- trunk/org.rubypeople.rdt.ui/src/org/rubypeople/rdt/ui/wizards/NewContainerWizardPage.java 2007-07-24 15:29:07 UTC (rev 2831)
+++ trunk/org.rubypeople.rdt.ui/src/org/rubypeople/rdt/ui/wizards/NewContainerWizardPage.java 2007-07-24 17:30:58 UTC (rev 2832)
@@ -25,6 +25,7 @@
import org.rubypeople.rdt.core.IRubyElement;
import org.rubypeople.rdt.core.IRubyModel;
import org.rubypeople.rdt.core.IRubyProject;
+import org.rubypeople.rdt.core.ISourceFolder;
import org.rubypeople.rdt.core.ISourceFolderRoot;
import org.rubypeople.rdt.core.RubyCore;
import org.rubypeople.rdt.core.RubyModelException;
@@ -55,7 +56,7 @@
private IWorkspaceRoot fWorkspaceRoot;
private StringButtonDialogField fContainerDialogField;
- private ISourceFolderRoot fCurrRoot;
+ private ISourceFolder fCurrSourceFolder;
/**
* Create a new <code>NewContainerWizardPage</code>
@@ -74,7 +75,7 @@
fContainerDialogField.setButtonLabel(NewWizardMessages.NewContainerWizardPage_container_button);
fContainerStatus= new StatusInfo();
- fCurrRoot= null;
+ fCurrSourceFolder= null;
}
/**
@@ -202,9 +203,9 @@
private void containerChangeControlPressed(DialogField field) {
// take the current rproject as init element of the dialog
- ISourceFolderRoot root= chooseContainer();
+ ISourceFolder root= chooseContainer();
if (root != null) {
- setSourceFolderRoot(root, true);
+ setSourceFolder(root, true);
}
}
@@ -222,7 +223,7 @@
*
* @return the text of the source folder text field
*/
- public String getSourceFolderRootText() {
+ public String getSourceFolderText() {
return fContainerDialogField.getText();
}
@@ -237,8 +238,8 @@
protected IStatus containerChanged() {
StatusInfo status= new StatusInfo();
- fCurrRoot= null;
- String str= getSourceFolderRootText();
+ fCurrSourceFolder= null;
+ String str= getSourceFolderText();
if (str.length() == 0) {
status.setError(NewWizardMessages.NewContainerWizardPage_error_EnterContainerName);
return status;
@@ -254,7 +255,8 @@
return status;
}
IRubyProject rproject= RubyCore.create(proj);
- fCurrRoot= rproject.getSourceFolderRoot(res);
+ IRubyElement element = RubyCore.create(res);
+ fCurrSourceFolder= RubyModelUtil.getSourceFolder(element);
if (res.exists()) {
try {
if (!proj.hasNature(RubyCore.NATURE_ID)) {
@@ -265,7 +267,7 @@
}
return status;
}
- if (!rproject.isOnLoadpath(fCurrRoot)) {
+ if (!rproject.isOnLoadpath(fCurrSourceFolder)) {
status.setWarning(Messages.format(NewWizardMessages.NewContainerWizardPage_warning_NotOnLoadPath, str));
}
} catch (CoreException e) {
@@ -284,14 +286,49 @@
}
/**
+ * A hook method that gets called when the package field has changed. The method
+ * validates the package name and returns the status of the validation. The validation
+ * also updates the package fragment model.
+ * <p>
+ * Subclasses may extend this method to perform their own validation.
+ * </p>
+ *
+ * @return the status of the validation
+ */
+// protected IStatus packageChanged() { FIXME Combine this with chooseContainer to properly validate the selection
+// StatusInfo status= new StatusInfo();
+// fSourceFolderDialogField.enableButton(getSourceFolderRoot() != null);
+//
+// String packName= getPackageText();
+// if (packName.length() > 0) {
+// IStatus val= RubyConventions.validateSourceFolderName(packName);
+// if (val.getSeverity() == IStatus.ERROR) {
+// status.setError(Messages.format(NewWizardMessages.NewTypeWizardPage_error_InvalidPackageName, val.getMessage()));
+// return status;
+// } else if (val.getSeverity() == IStatus.WARNING) {
+// status.setWarning(Messages.format(NewWizardMessages.NewTypeWizardPage_warning_DiscouragedPackageName, val.getMessage()));
+// // continue
+// }
+// }
+//
+// ISourceFolderRoot root= getSourceFolderRoot();
+// if (root != null) {
+// fCurrSourceFolder= root.getSourceFolder(packName);
+// } else {
+// status.setError(""); //$NON-NLS-1$
+// }
+// return status;
+// }
+
+ /**
* Sets the current source folder (model and text field) to the given source folder
* root.
* @param root The new root.
* @param canBeModified if <code>false</code> the source folder field can
* not be changed by the user. If <code>true</code> the field is editable
*/
- public void setSourceFolderRoot(ISourceFolderRoot root, boolean canBeModified) {
- fCurrRoot= root;
+ public void setSourceFolder(ISourceFolder root, boolean canBeModified) {
+ fCurrSourceFolder= root;
String str= (root == null) ? "" : root.getPath().makeRelative().toString(); //$NON-NLS-1$
fContainerDialogField.setText(str);
fContainerDialogField.setEnabled(canBeModified);
@@ -304,11 +341,11 @@
* fragment root used as the source folder
*/
protected void initContainerPage(IRubyElement elem) {
- ISourceFolderRoot initRoot= null;
+ ISourceFolder initRoot= null;
if (elem != null) {
- initRoot= RubyModelUtil.getSourceFolderRoot(elem);
+ initRoot= RubyModelUtil.getSourceFolder(elem);
try {
- if (initRoot == null || initRoot.isExternal()) {
+ if (initRoot == null || ((ISourceFolderRoot)initRoot.getParent()).isExternal()) {
IRubyProject rproject= elem.getRubyProject();
if (rproject != null) {
initRoot= null;
@@ -316,13 +353,13 @@
ISourceFolderRoot[] roots= rproject.getSourceFolderRoots();
for (int i= 0; i < roots.length; i++) {
if (!roots[i].isExternal()) {
- initRoot= roots[i];
+ initRoot= roots[i].getSourceFolder("");
break;
}
}
}
if (initRoot == null) {
- initRoot= rproject.getSourceFolderRoot(rproject.getResource());
+ initRoot= rproject.getSourceFolderRoot(rproject.getResource()).getSourceFolder("");
}
}
}
@@ -330,7 +367,7 @@
RubyCore.log(e);
}
}
- setSourceFolderRoot(initRoot, true);
+ setSourceFolder(initRoot, true);
}
private void containerDialogFieldChanged(DialogField field) {
@@ -382,9 +419,9 @@
*
* @since 0.9.0
*/
- protected ISourceFolderRoot chooseContainer() {
- IRubyElement initElement= getSourceFolderRoot();
- Class[] acceptedClasses= new Class[] { IRubyProject.class, ISourceFolderRoot.class };
+ protected ISourceFolder chooseContainer() {
+ IRubyElement initElement= getSourceFolder();
+ Class[] acceptedClasses= new Class[] { IRubyProject.class, ISourceFolderRoot.class, ISourceFolder.class };
TypedElementSelectionValidator validator= new TypedElementSelectionValidator(acceptedClasses, false) {
public boolean isSelectedValid(Object element) {
try {
@@ -403,7 +440,7 @@
}
};
- acceptedClasses= new Class[] { IRubyModel.class, ISourceFolderRoot.class, IRubyProject.class };
+ acceptedClasses= new Class[] { IRubyModel.class, ISourceFolderRoot.class, IRubyProject.class, ISourceFolder.class };
ViewerFilter filter= new TypedViewerFilter(acceptedClasses) {
public boolean select(Viewer viewer, Object parent, Object element) {
if (element instanceof ISourceFolderRoot) {
@@ -413,7 +450,7 @@
}
};
- StandardRubyElementContentProvider provider= new StandardRubyElementContentProvider();
+ StandardRubyElementContentProvider provider= new StandardRubyElementContentProvider(); // FIXME Labels shouldn't give fulle path for source folders, just last name segment
ILabelProvider labelProvider= new RubyElementLabelProvider(RubyElementLabelProvider.SHOW_DEFAULT);
ElementTreeSelectionDialog dialog= new ElementTreeSelectionDialog(getShell(), labelProvider, provider);
dialog.setValidator(validator);
@@ -429,9 +466,11 @@
Object element= dialog.getFirstResult();
if (element instanceof IRubyProject) {
IRubyProject jproject= (IRubyProject)element;
- return jproject.getSourceFolderRoot(jproject.getProject());
+ return jproject.getSourceFolderRoot(jproject.getProject()).getSourceFolder("");
} else if (element instanceof ISourceFolderRoot) {
- return (ISourceFolderRoot)element;
+ return ((ISourceFolderRoot)element).getSourceFolder("");
+ } else if (element instanceof ISourceFolder) {
+ return (ISourceFolder)element;
}
return null;
}
@@ -446,8 +485,8 @@
* folder value is not a valid package fragment root
*
*/
- public ISourceFolderRoot getSourceFolderRoot() {
- return fCurrRoot;
+ public ISourceFolder getSourceFolder() {
+ return fCurrSourceFolder;
}
}
Modified: trunk/org.rubypeople.rdt.ui/src/org/rubypeople/rdt/ui/wizards/NewTypeWizardPage.java
===================================================================
--- trunk/org.rubypeople.rdt.ui/src/org/rubypeople/rdt/ui/wizards/NewTypeWizardPage.java 2007-07-24 15:29:07 UTC (rev 2831)
+++ trunk/org.rubypeople.rdt.ui/src/org/rubypeople/rdt/ui/wizards/NewTypeWizardPage.java 2007-07-24 17:30:58 UTC (rev 2832)
@@ -20,27 +20,21 @@
import org.eclipse.swt.graphics.Image;
import org.eclipse.swt.widgets.Composite;
import org.eclipse.swt.widgets.Text;
-import org.eclipse.ui.dialogs.ElementListSelectionDialog;
import org.rubypeople.rdt.core.IBuffer;
import org.rubypeople.rdt.core.IRubyElement;
import org.rubypeople.rdt.core.IRubyProject;
import org.rubypeople.rdt.core.IRubyScript;
import org.rubypeople.rdt.core.ISourceFolder;
-import org.rubypeople.rdt.core.ISourceFolderRoot;
import org.rubypeople.rdt.core.ISourceRange;
import org.rubypeople.rdt.core.IType;
import org.rubypeople.rdt.core.RubyConventions;
-import org.rubypeople.rdt.core.RubyModelException;
import org.rubypeople.rdt.core.formatter.CodeFormatter;
import org.rubypeople.rdt.core.search.IRubySearchConstants;
import org.rubypeople.rdt.core.search.IRubySearchScope;
import org.rubypeople.rdt.core.search.SearchEngine;
-import org.rubypeople.rdt.internal.core.RubyProject;
import org.rubypeople.rdt.internal.corext.codemanipulation.StubUtility;
import org.rubypeople.rdt.internal.corext.util.CodeFormatterUtil;
-import org.rubypeople.rdt.internal.corext.util.Messages;
import org.rubypeople.rdt.internal.corext.util.RubyModelUtil;
-import org.rubypeople.rdt.internal.ui.RubyPlugin;
import org.rubypeople.rdt.internal.ui.RubyPluginImages;
import org.rubypeople.rdt.internal.ui.dialogs.StatusInfo;
import org.rubypeople.rdt.internal.ui.dialogs.TypeSelectionDialog2;
@@ -54,9 +48,7 @@
import org.rubypeople.rdt.internal.ui.wizards.dialogfields.ListDialogField;
import org.rubypeople.rdt.internal.ui.wizards.dialogfields.Separator;
import org.rubypeople.rdt.internal.ui.wizards.dialogfields.StringButtonDialogField;
-import org.rubypeople.rdt.internal.ui.wizards.dialogfields.StringButtonStatusDialogField;
import org.rubypeople.rdt.internal.ui.wizards.dialogfields.StringDialogField;
-import org.rubypeople.rdt.ui.RubyElementLabelProvider;
public abstract class NewTypeWizardPage extends NewContainerWizardPage {
@@ -115,7 +107,6 @@
*/
private IType fCurrType;
private StringDialogField fTypeNameDialogField;
- private StringButtonStatusDialogField fPackageDialogField;
private StringButtonDialogField fSuperClassDialogField;
private ListDialogField fSuperModulesDialogField;
@@ -127,7 +118,6 @@
protected IStatus fSuperModulesStatus;
private int fTypeKind;
- private ISourceFolder fCurrSourceFolder;
private boolean fCanModifySourceFolder;
@@ -170,12 +160,6 @@
TypeFieldsAdapter adapter= new TypeFieldsAdapter();
- fPackageDialogField= new StringButtonStatusDialogField(adapter);
- fPackageDialogField.setDialogFieldListener(adapter);
- fPackageDialogField.setLabelText(getPackageLabel());
- fPackageDialogField.setButtonLabel(NewWizardMessages.NewTypeWizardPage_package_button);
- fPackageDialogField.setStatusWidthHint(NewWizardMessages.NewTypeWizardPage_default);
-
fTypeNameDialogField= new StringDialogField();
fTypeNameDialogField.setDialogFieldListener(adapter);
fTypeNameDialogField.setLabelText(getTypeNameLabel());
@@ -207,71 +191,11 @@
* @return the label that is used for the package input field.
* @since 3.2
*/
- protected String getPackageLabel() {
+ protected String getSourceFolderLabel() {
return NewWizardMessages.NewTypeWizardPage_package_label;
}
/**
- * A hook method that gets called when the package field has changed. The method
- * validates the package name and returns the status of the validation. The validation
- * also updates the package fragment model.
- * <p>
- * Subclasses may extend this method to perform their own validation.
- * </p>
- *
- * @return the status of the validation
- */
- protected IStatus packageChanged() {
- StatusInfo status= new StatusInfo();
- fPackageDialogField.enableButton(getSourceFolderRoot() != null);
-
- String packName= getPackageText();
- if (packName.length() > 0) {
- IStatus val= RubyConventions.validateSourceFolderName(packName);
- if (val.getSeverity() == IStatus.ERROR) {
- status.setError(Messages.format(NewWizardMessages.NewTypeWizardPage_error_InvalidPackageName, val.getMessage()));
- return status;
- } else if (val.getSeverity() == IStatus.WARNING) {
- status.setWarning(Messages.format(NewWizardMessages.NewTypeWizardPage_warning_DiscouragedPackageName, val.getMessage()));
- // continue
- }
- }
-
- ISourceFolderRoot root= getSourceFolderRoot();
- if (root != null) {
- fCurrSourceFolder= root.getSourceFolder(packName);
- } else {
- status.setError(""); //$NON-NLS-1$
- }
- return status;
- }
-
- /**
- * Returns the text of the package input field.
- *
- * @return the text of the package input field
- */
- public String getPackageText() {
- return fPackageDialogField.getText();
- }
-
- /**
- * Creates the controls for the package name field. Expects a <code>GridLayout</code> with at
- * least 4 columns.
- *
- * @param composite the parent composite
- * @param nColumns number of columns to span
- */
- protected void createPackageControls(Composite composite, int nColumns) {
- fPackageDialogField.doFillIntoGrid(composite, nColumns);
- Text text= fPackageDialogField.getTextControl(null);
- LayoutUtil.setWidthHint(text, getMaxFieldWidth());
- LayoutUtil.setHorizontalGrabbing(text);
-// ControlContentAssistHelper.createTextContentAssistant(text, fCurrPackageCompletionProcessor);
-// TextFieldNavigationHandler.install(text);
- }
-
- /**
* Creates the controls for the type name field. Expects a <code>GridLayout</code> with at
* least 2 columns.
*
@@ -408,7 +332,7 @@
}
private void typePageLinkActivated(SelectionEvent e) {
- ISourceFolderRoot root= getSourceFolderRoot();
+ ISourceFolder root= getSourceFolder();
if (root != null) {
// TODO Uncomment!
// PreferenceDialog dialog= PreferencesUtil.createPropertyDialogOn(getShell(), root.getProject(), CodeTemplatePreferencePage.PROP_ID, null, null);
@@ -421,12 +345,7 @@
}
private void typePageChangeControlPressed(DialogField field) {
- if (field == fPackageDialogField) {
- ISourceFolder pack= chooseSourceFolder();
- if (pack != null) {
- fPackageDialogField.setText(pack.getElementName());
- }
- } else if (field == fSuperClassDialogField) {
+ if (field == fSuperClassDialogField) {
IType type= chooseSuperClass();
if (type != null) {
// TODO Spit out fully qualified name?!
@@ -435,50 +354,6 @@
}
}
- /**
- * Opens a selection dialog that allows to select a package.
- *
- * @return returns the selected package or <code>null</code> if the dialog has been canceled.
- * The caller typically sets the result to the package input field.
- * <p>
- * Clients can override this method if they want to offer a different dialog.
- * </p>
- *
- * @since 0.9.0
- */
- protected ISourceFolder chooseSourceFolder() {
- ISourceFolderRoot froot= getSourceFolderRoot();
- IRubyElement[] packages= null;
- try {
- if (froot != null && froot.exists()) {
- packages= froot.getChildren();
- }
- } catch (RubyModelException e) {
- RubyPlugin.log(e);
- }
- if (packages == null) {
- packages= new IRubyElement[0];
- }
-
- ElementListSelectionDialog dialog= new ElementListSelectionDialog(getShell(), new RubyElementLabelProvider(RubyElementLabelProvider.SHOW_DEFAULT));
- dialog.setIgnoreCase(false);
- dialog.setTitle(NewWizardMessages.NewTypeWizardPage_ChoosePackageDialog_title);
- dialog.setMessage(NewWizardMessages.NewTypeWizardPage_ChoosePackageDialog_description);
- dialog.setEmptyListMessage(NewWizardMessages.NewTypeWizardPage_ChoosePackageDialog_empty);
- dialog.setElements(packages);
- dialog.setHelpAvailable(false);
-
- ISourceFolder pack= getSourceFolder();
- if (pack != null) {
- dialog.setInitialSelections(new Object[] { pack });
- }
-
- if (dialog.open() == Window.OK) {
- return (ISourceFolder) dialog.getFirstResult();
- }
- return null;
- }
-
private void typePageCustomButtonPressed(DialogField field, int index) {
if (field == fSuperModulesDialogField) {
chooseSuperModules();
@@ -553,39 +428,12 @@
}
return newName.toString();
}
-
- /**
- * Returns the package fragment corresponding to the current input.
- *
- * @return a package fragment or <code>null</code> if the input
- * could not be resolved.
- */
- public ISourceFolder getSourceFolder() {
- return fCurrSourceFolder;
- }
- /**
- * Sets the source folder to the given value. The method updates the model
- * and the text of the control.
- *
- * @param pack the source folder to be set
- * @param canBeModified if <code>true</code> the package fragment is
- * editable; otherwise it is read-only.
- */
- public void setSourceFolder(ISourceFolder pack, boolean canBeModified) {
- fCurrSourceFolder= pack;
- fCanModifySourceFolder= canBeModified;
- String str= (pack == null) ? "" : pack.getElementName(); //$NON-NLS-1$
- fPackageDialogField.setText(str);
- updateEnableState();
- }
-
/*
* Updates the enable state of buttons related to the enclosing type selection checkbox.
*/
private void updateEnableState() {
- boolean enclosing= isEnclosingTypeSelected();
- fPackageDialogField.setEnabled(fCanModifySourceFolder && !enclosing);
+
}
private boolean isEnclosingTypeSelected() {
@@ -607,18 +455,14 @@
monitor.beginTask(NewWizardMessages.NewTypeWizardPage_operationdesc, 8);
- ISourceFolderRoot root = getSourceFolderRoot();
ISourceFolder pack= getSourceFolder();
- if (pack == null) {
- pack= root.getSourceFolder(new String[] {});
- }
- if (!pack.exists()) {
- String packName= pack.getElementName();
- pack= root.createSourceFolder(packName, true, new SubProgressMonitor(monitor, 1));
- } else {
+// if (!pack.exists()) {
+// String packName= pack.getElementName();
+// pack= root.createSourceFolder(packName, true, new SubProgressMonitor(monitor, 1));
+// } else {
monitor.worked(1);
- }
+// }
boolean needsSave;
IRubyScript connectedCU= null;
@@ -727,7 +571,7 @@
* @since 1.0
*/
protected void chooseSuperModules() {
- ISourceFolderRoot root= getSourceFolderRoot();
+ ISourceFolder root= getSourceFolder();
if (root == null) {
return;
}
@@ -811,14 +655,8 @@
*/
private void typePageDialogFieldChanged(DialogField field) {
String fieldName= null;
- if (field == fPackageDialogField) {
- /*fPackageStatus=*/ packageChanged();
-// updatePackageStatusLabel();
+ if (field == fTypeNameDialogField) {
fTypeNameStatus= typeNameChanged();
- fSuperClassStatus= superClassChanged();
- fieldName= PACKAGE;
- } else if (field == fTypeNameDialogField) {
- fTypeNameStatus= typeNameChanged();
fieldName= TYPENAME;
} else if (field == fSuperClassDialogField) {
fSuperClassStatus= superClassChanged();
@@ -853,7 +691,7 @@
*/
protected IStatus superClassChanged() {
StatusInfo status= new StatusInfo();
- ISourceFolderRoot root= getSourceFolderRoot();
+ ISourceFolder root= getSourceFolder();
fSuperClassDialogField.enableButton(root != null);
String sclassName= getSuperClass();
@@ -916,7 +754,7 @@
protected void handleFieldChanged(String fieldName) {
super.handleFieldChanged(fieldName);
if (fieldName == CONTAINER) {
- /*fPackageStatus=*/ packageChanged();
+// /*fPackageStatus=*/ packageChanged();
// fEnclosingTypeStatus= enclosingTypeChanged();
fTypeNameStatus= typeNameChanged();
fSuperClassStatus= superClassChanged();
@@ -936,17 +774,12 @@
ArrayList initSuperinterfaces= new ArrayList(5);
IRubyProject project= null;
- ISourceFolder folder= null;
+ ISourceFolder folder= getSourceFolder();
IType enclosingType= null;
if (elem != null) {
// evaluate the enclosing type
project= elem.getRubyProject();
- if (elem instanceof RubyProject) {
- folder = getSourceFolderRoot().getSourceFolder(new String[0]);
- } else {
- folder= (ISourceFolder) elem.getAncestor(IRubyElement.SOURCE_FOLDER);
- }
IType typeInCU= (IType) elem.getAncestor(IRubyElement.TYPE);
if (typeInCU != null) {
if (typeInCU.getRubyScript() != null) {
@@ -1019,7 +852,7 @@
protected IStatus superInterfacesChanged() {
StatusInfo status= new StatusInfo();
- ISourceFolderRoot root= getSourceFolderRoot();
+ ISourceFolder root= getSourceFolder();
fSuperModulesDialogField.enableButton(0, root != null);
if (root != null) {
@@ -1052,7 +885,7 @@
* @since 0.9
*/
protected IType chooseSuperClass() {
- ISourceFolderRoot root= getSourceFolderRoot();
+ ISourceFolder root= getSourceFolder();
if (root == null) {
return null;
}
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|