2004-09-22 Chris Wiebe
new file wizards * src/org/eclipse/cdt/internal/ui/wizards/classwizard/NewClassCodeGenerator.java * src/org/eclipse/cdt/internal/ui/wizards/classwizard/NewClassCreationWizardPage.java * src/org/eclipse/cdt/internal/ui/wizards/classwizard/NewClassWizardMessages.properties * src/org/eclipse/cdt/internal/ui/wizards/classwizard/SourceFileSelectionDialog.java * src/org/eclipse/cdt/internal/ui/wizards/AbstractOpenWizardAction.java * src/org/eclipse/cdt/internal/ui/wizards/AbstractWizardDropDownAction.java * src/org/eclipse/cdt/internal/ui/wizards/BaseClassSelectionDialog.java * src/org/eclipse/cdt/internal/ui/wizards/CWizardRegistry.java * src/org/eclipse/cdt/internal/ui/wizards/NewFileDropDownAction.java * src/org/eclipse/cdt/internal/ui/wizards/NewProjectDropDownAction.java * src/org/eclipse/cdt/internal/ui/wizards/NewTypeDropDownAction.java * src/org/eclipse/cdt/internal/ui/wizards/OpenNewFileWizardAction.java * src/org/eclipse/cdt/internal/ui/CPluginImages.java * icons/full/ctool16/newcfile_wiz.gif * icons/full/ctool16/newhfile_wiz.gif * icons/full/dtool16/newcfile_wiz.gif * icons/full/dtool16/newhfile_wiz.gif * icons/full/etool16/newcfile_wiz.gif * icons/full/etool16/newhfile_wiz.gif * icons/full/wizban/newcfile_wiz.gif * icons/full/wizban/newhfile_wiz.gif * src/org/eclipse/cdt/internal/ui/wizards/filewizard/AbstractFileCreationWizard.java * src/org/eclipse/cdt/internal/ui/wizards/filewizard/AbstractFileCreationWizardPage.java * src/org/eclipse/cdt/internal/ui/wizards/filewizard/NewFileWizardMessages.java * src/org/eclipse/cdt/internal/ui/wizards/filewizard/NewFileWizardMessages.properties * src/org/eclipse/cdt/internal/ui/wizards/filewizard/NewHeaderFileCreationWizardPage.java * src/org/eclipse/cdt/internal/ui/wizards/filewizard/NewSourceFileCreationWizardPage.java * src/org/eclipse/cdt/internal/ui/wizards/filewizard/NewSourceFileGenerator.java * src/org/eclipse/cdt/ui/wizards/NewClassWizard.java * src/org/eclipse/cdt/ui/wizards/NewClassWizardPage.java * src/org/eclipse/cdt/ui/wizards/NewFileCreationWizard.java * src/org/eclipse/cdt/ui/wizards/NewHeaderFileCreationWizard.java * src/org/eclipse/cdt/ui/wizards/NewSourceFileCreationWizard.java * plugin.properties * plugin.xml
|
@ -1,3 +1,42 @@
|
|||
2004-09-22 Chris Wiebe
|
||||
|
||||
new file wizards
|
||||
* src/org/eclipse/cdt/internal/ui/wizards/classwizard/NewClassCodeGenerator.java
|
||||
* src/org/eclipse/cdt/internal/ui/wizards/classwizard/NewClassCreationWizardPage.java
|
||||
* src/org/eclipse/cdt/internal/ui/wizards/classwizard/NewClassWizardMessages.properties
|
||||
* src/org/eclipse/cdt/internal/ui/wizards/classwizard/SourceFileSelectionDialog.java
|
||||
* src/org/eclipse/cdt/internal/ui/wizards/AbstractOpenWizardAction.java
|
||||
* src/org/eclipse/cdt/internal/ui/wizards/AbstractWizardDropDownAction.java
|
||||
* src/org/eclipse/cdt/internal/ui/wizards/BaseClassSelectionDialog.java
|
||||
* src/org/eclipse/cdt/internal/ui/wizards/CWizardRegistry.java
|
||||
* src/org/eclipse/cdt/internal/ui/wizards/NewFileDropDownAction.java
|
||||
* src/org/eclipse/cdt/internal/ui/wizards/NewProjectDropDownAction.java
|
||||
* src/org/eclipse/cdt/internal/ui/wizards/NewTypeDropDownAction.java
|
||||
* src/org/eclipse/cdt/internal/ui/wizards/OpenNewFileWizardAction.java
|
||||
* src/org/eclipse/cdt/internal/ui/CPluginImages.java
|
||||
* icons/full/ctool16/newcfile_wiz.gif
|
||||
* icons/full/ctool16/newhfile_wiz.gif
|
||||
* icons/full/dtool16/newcfile_wiz.gif
|
||||
* icons/full/dtool16/newhfile_wiz.gif
|
||||
* icons/full/etool16/newcfile_wiz.gif
|
||||
* icons/full/etool16/newhfile_wiz.gif
|
||||
* icons/full/wizban/newcfile_wiz.gif
|
||||
* icons/full/wizban/newhfile_wiz.gif
|
||||
* src/org/eclipse/cdt/internal/ui/wizards/filewizard/AbstractFileCreationWizard.java
|
||||
* src/org/eclipse/cdt/internal/ui/wizards/filewizard/AbstractFileCreationWizardPage.java
|
||||
* src/org/eclipse/cdt/internal/ui/wizards/filewizard/NewFileWizardMessages.java
|
||||
* src/org/eclipse/cdt/internal/ui/wizards/filewizard/NewFileWizardMessages.properties
|
||||
* src/org/eclipse/cdt/internal/ui/wizards/filewizard/NewHeaderFileCreationWizardPage.java
|
||||
* src/org/eclipse/cdt/internal/ui/wizards/filewizard/NewSourceFileCreationWizardPage.java
|
||||
* src/org/eclipse/cdt/internal/ui/wizards/filewizard/NewSourceFileGenerator.java
|
||||
* src/org/eclipse/cdt/ui/wizards/NewClassWizard.java
|
||||
* src/org/eclipse/cdt/ui/wizards/NewClassWizardPage.java
|
||||
* src/org/eclipse/cdt/ui/wizards/NewFileCreationWizard.java
|
||||
* src/org/eclipse/cdt/ui/wizards/NewHeaderFileCreationWizard.java
|
||||
* src/org/eclipse/cdt/ui/wizards/NewSourceFileCreationWizard.java
|
||||
* plugin.properties
|
||||
* plugin.xml
|
||||
|
||||
2004-09-21 Alain Magloire
|
||||
Duplication in the CView ILibraryReferece.
|
||||
* src/org/eclipse/cdt/internal/ui/cview/CViewContentProvider.java
|
||||
|
|
BIN
core/org.eclipse.cdt.ui/icons/full/ctool16/newcfile_wiz.gif
Normal file
After Width: | Height: | Size: 376 B |
BIN
core/org.eclipse.cdt.ui/icons/full/ctool16/newhfile_wiz.gif
Normal file
After Width: | Height: | Size: 379 B |
BIN
core/org.eclipse.cdt.ui/icons/full/dtool16/newcfile_wiz.gif
Normal file
After Width: | Height: | Size: 240 B |
BIN
core/org.eclipse.cdt.ui/icons/full/dtool16/newhfile_wiz.gif
Normal file
After Width: | Height: | Size: 244 B |
BIN
core/org.eclipse.cdt.ui/icons/full/etool16/newcfile_wiz.gif
Normal file
After Width: | Height: | Size: 376 B |
BIN
core/org.eclipse.cdt.ui/icons/full/etool16/newhfile_wiz.gif
Normal file
After Width: | Height: | Size: 379 B |
BIN
core/org.eclipse.cdt.ui/icons/full/wizban/newcfile_wiz.gif
Normal file
After Width: | Height: | Size: 2.7 KiB |
BIN
core/org.eclipse.cdt.ui/icons/full/wizban/newhfile_wiz.gif
Normal file
After Width: | Height: | Size: 2.8 KiB |
|
@ -34,28 +34,30 @@ newCCWizardsCategory.name=C++
|
|||
ConversionWizard.name=Convert a project's nature
|
||||
ConversionWizard.description=Convert a project's nature
|
||||
|
||||
NewWizards.folder = Folder
|
||||
NewWizards.folder.description = Create a new folder resource
|
||||
NewWizards.file = File
|
||||
NewWizards.file.description = Create a new file resource
|
||||
NewWizards.class = Class
|
||||
NewWizards.class.description = Create a new C++ class
|
||||
OpenNewFileWizardAction.label=&File
|
||||
OpenNewFileWizardAction.tooltip=New File
|
||||
OpenNewFolderWizardAction.label=&Folder
|
||||
OpenNewFolderWizardAction.tooltip=New Folder
|
||||
OpenClassWizardAction.label=&Class...
|
||||
OpenClassWizardAction.tooltip=New C++ Class
|
||||
OpenProjectWizardAction.label=&Project...
|
||||
OpenProjectWizardAction.tooltip=New C Project
|
||||
CElementCreationActionSet.label= C Element Creation
|
||||
CElementCreationActionSet.description= C Element Creation Action Set
|
||||
NewCClass.label= C++ Class
|
||||
NewCClass.description=Create a C++ class
|
||||
NewCProject.label= C Project
|
||||
NewCProject.description=Create a C project
|
||||
NewCCProject.label= C++ Project
|
||||
NewCCProject.description=Create a C++ project
|
||||
|
||||
NewProjectDropDownAction.label=&Project...
|
||||
NewProjectDropDownAction.tooltip=New C/C++ Project
|
||||
|
||||
OpenNewFolderWizardAction.label=&Folder
|
||||
OpenNewFolderWizardAction.tooltip=New Folder
|
||||
NewWizards.folder = Folder
|
||||
NewWizards.folder.description = Create a new folder resource
|
||||
|
||||
NewFileDropDownAction.label=&Source File...
|
||||
NewFileDropDownAction.tooltip=New C/C++ Source File
|
||||
NewWizards.sourceFile = Source File
|
||||
NewWizards.sourceFile.description = Create a new source file
|
||||
NewWizards.headerFile = Header File
|
||||
NewWizards.headerFile.description = Create a new header file
|
||||
NewWizards.file = File
|
||||
NewWizards.file.description = Create a new file resource
|
||||
|
||||
NewTypeDropDownAction.label=&Class...
|
||||
NewTypeDropDownAction.tooltip=New C++ Class
|
||||
NewWizards.class = Class
|
||||
NewWizards.class.description = Create a new C++ class
|
||||
|
||||
# Editor
|
||||
|
||||
|
|
|
@ -309,26 +309,50 @@
|
|||
name="%newCWizardsCategory.name"
|
||||
id="org.eclipse.cdt.ui.newCWizards">
|
||||
</category>
|
||||
<wizard
|
||||
name="%NewWizards.sourceFile"
|
||||
icon="icons/full/ctool16/newcfile_wiz.gif"
|
||||
category="org.eclipse.cdt.ui.newCWizards"
|
||||
finalPerspective="org.eclipse.cdt.ui.CPerspective"
|
||||
id="org.eclipse.cdt.ui.wizards.NewSourceFileCreationWizard">
|
||||
<class class="org.eclipse.cdt.ui.wizards.NewSourceFileCreationWizard">
|
||||
<parameter name="cfile" value="true"/>
|
||||
</class>
|
||||
<description>
|
||||
%NewWizards.sourceFile.description
|
||||
</description>
|
||||
</wizard>
|
||||
<wizard
|
||||
name="%NewWizards.headerFile"
|
||||
icon="icons/full/ctool16/newhfile_wiz.gif"
|
||||
category="org.eclipse.cdt.ui.newCWizards"
|
||||
finalPerspective="org.eclipse.cdt.ui.CPerspective"
|
||||
id="org.eclipse.cdt.ui.wizards.NewHeaderFileCreationWizard">
|
||||
<class class="org.eclipse.cdt.ui.wizards.NewHeaderFileCreationWizard">
|
||||
<parameter name="cfile" value="true"/>
|
||||
</class>
|
||||
<description>
|
||||
%NewWizards.headerFile.description
|
||||
</description>
|
||||
</wizard>
|
||||
<wizard
|
||||
name="%NewWizards.file"
|
||||
icon="icons/full/ctool16/newfile_wiz.gif"
|
||||
category="org.eclipse.cdt.ui.newCWizards"
|
||||
finalPerspective="org.eclipse.cdt.ui.CPerspective"
|
||||
id="org.eclipse.cdt.ui.wizards.NewFileCreationWizard">
|
||||
<class class="org.eclipse.cdt.ui.wizards.NewFileCreationWizard">
|
||||
<parameter name="cfile" value="true"/>
|
||||
</class>
|
||||
<description>
|
||||
%NewWizards.file.description
|
||||
</description>
|
||||
</wizard>
|
||||
<!-- For C++ Wizards -->
|
||||
<category
|
||||
name="%newCCWizardsCategory.name"
|
||||
id="org.eclipse.cdt.ui.newCCWizards">
|
||||
</category>
|
||||
<!-- old class wizard
|
||||
<wizard
|
||||
name="%NewWizards.class"
|
||||
icon="icons/full/ctool16/newclass_wiz.gif"
|
||||
category="org.eclipse.cdt.ui.newCCWizards"
|
||||
finalPerspective="org.eclipse.cdt.ui.CPerspective"
|
||||
id="org.eclipse.cdt.ui.wizards.NewClassWizard">
|
||||
<class class="org.eclipse.cdt.ui.wizards.NewClassWizard">
|
||||
<parameter name="ctype" value="true"/>
|
||||
</class>
|
||||
<description>
|
||||
%NewWizards.class.description
|
||||
</description>
|
||||
</wizard>
|
||||
-->
|
||||
<wizard
|
||||
name="%NewWizards.class"
|
||||
icon="icons/full/ctool16/newclass_wiz.gif"
|
||||
|
@ -337,11 +361,51 @@
|
|||
id="org.eclipse.cdt.ui.wizards.NewClassCreationWizard">
|
||||
<class class="org.eclipse.cdt.ui.wizards.NewClassCreationWizard">
|
||||
<parameter name="ctype" value="true"/>
|
||||
<parameter targetId="org.eclipse.cdt.ui.actions.NewTypeDropDown"/>
|
||||
</class>
|
||||
<description>
|
||||
%NewWizards.class.description
|
||||
</description>
|
||||
</wizard>
|
||||
<wizard
|
||||
name="%NewWizards.sourceFile"
|
||||
icon="icons/full/ctool16/newcfile_wiz.gif"
|
||||
category="org.eclipse.cdt.ui.newCCWizards"
|
||||
finalPerspective="org.eclipse.cdt.ui.CPerspective"
|
||||
id="org.eclipse.cdt.ui.wizards.NewSourceFileCreationWizard">
|
||||
<class class="org.eclipse.cdt.ui.wizards.NewSourceFileCreationWizard">
|
||||
<parameter name="cfile" value="true"/>
|
||||
</class>
|
||||
<description>
|
||||
%NewWizards.sourceFile.description
|
||||
</description>
|
||||
</wizard>
|
||||
<wizard
|
||||
name="%NewWizards.headerFile"
|
||||
icon="icons/full/ctool16/newhfile_wiz.gif"
|
||||
category="org.eclipse.cdt.ui.newCCWizards"
|
||||
finalPerspective="org.eclipse.cdt.ui.CPerspective"
|
||||
id="org.eclipse.cdt.ui.wizards.NewHeaderFileCreationWizard">
|
||||
<class class="org.eclipse.cdt.ui.wizards.NewHeaderFileCreationWizard">
|
||||
<parameter name="cfile" value="true"/>
|
||||
</class>
|
||||
<description>
|
||||
%NewWizards.headerFile.description
|
||||
</description>
|
||||
</wizard>
|
||||
<wizard
|
||||
name="%NewWizards.file"
|
||||
icon="icons/full/ctool16/newfile_wiz.gif"
|
||||
category="org.eclipse.cdt.ui.newCCWizards"
|
||||
finalPerspective="org.eclipse.cdt.ui.CPerspective"
|
||||
id="org.eclipse.cdt.ui.wizards.NewFileCreationWizard">
|
||||
<class class="org.eclipse.cdt.ui.wizards.NewFileCreationWizard">
|
||||
<parameter name="cfile" value="true"/>
|
||||
</class>
|
||||
<description>
|
||||
%NewWizards.file.description
|
||||
</description>
|
||||
</wizard>
|
||||
</extension>
|
||||
<!-- Define the document provider and partitionner for the CEditor -->
|
||||
<extension
|
||||
|
@ -589,17 +653,19 @@
|
|||
class="org.eclipse.cdt.internal.ui.wizards.NewTypeDropDownAction"
|
||||
disabledIcon="icons/full/dtool16/newclass_wiz.gif"
|
||||
icon="icons/full/etool16/newclass_wiz.gif"
|
||||
label="%OpenClassWizardAction.label"
|
||||
label="%NewTypeDropDownAction.label"
|
||||
pulldown="true"
|
||||
tooltip="%OpenClassWizardAction.tooltip">
|
||||
tooltip="%NewTypeDropDownAction.tooltip">
|
||||
</action>
|
||||
<action
|
||||
label="%OpenNewFileWizardAction.label"
|
||||
icon="icons/full/ctool16/newfile_wiz.gif"
|
||||
class="org.eclipse.cdt.internal.ui.wizards.OpenNewFileWizardAction"
|
||||
tooltip="%OpenNewFileWizardAction.tooltip"
|
||||
id="org.eclipse.cdt.ui.actions.NewFileDropDown"
|
||||
toolbarPath="Normal/CCWizards"
|
||||
id="org.eclipse.cdt.ui.actions.OpenNewFileWizardAction">
|
||||
class="org.eclipse.cdt.internal.ui.wizards.NewFileDropDownAction"
|
||||
disabledIcon="icons/full/dtool16/newcfile_wiz.gif"
|
||||
icon="icons/full/etool16/newcfile_wiz.gif"
|
||||
label="%NewFileDropDownAction.label"
|
||||
pulldown="true"
|
||||
tooltip="%NewFileDropDownAction.tooltip">
|
||||
</action>
|
||||
<action
|
||||
label="%OpenNewFolderWizardAction.label"
|
||||
|
@ -615,9 +681,9 @@
|
|||
class="org.eclipse.cdt.internal.ui.wizards.NewProjectDropDownAction"
|
||||
disabledIcon="icons/full/dtool16/newcprj_wiz.gif"
|
||||
icon="icons/full/etool16/newcprj_wiz.gif"
|
||||
label="%OpenProjectWizardAction.label"
|
||||
label="%NewProjectDropDownAction.label"
|
||||
pulldown="true"
|
||||
tooltip="%OpenProjectWizardAction.tooltip">
|
||||
tooltip="%NewProjectDropDownAction.tooltip">
|
||||
</action>
|
||||
</actionSet>
|
||||
</extension>
|
||||
|
|
|
@ -200,6 +200,9 @@ public class CPluginImages {
|
|||
public static final ImageDescriptor DESC_WIZABAN_NEW_PROJ= create(T_WIZBAN, "newcprj_wiz.gif"); //$NON-NLS-1$
|
||||
public static final ImageDescriptor DESC_WIZBAN_NEWCLASS= create(T_WIZBAN, "newclass_wiz.gif"); //$NON-NLS-1$
|
||||
public static final ImageDescriptor DESC_WIZABAN_C_APP= create(T_WIZBAN, "c_app_wiz.gif"); //$NON-NLS-1$
|
||||
public static final ImageDescriptor DESC_WIZBAN_NEW_FILE= create(T_WIZBAN, "newfile_wiz.gif"); //$NON-NLS-1$
|
||||
public static final ImageDescriptor DESC_WIZBAN_NEW_HEADERFILE= create(T_WIZBAN, "newhfile_wiz.gif"); //$NON-NLS-1$
|
||||
public static final ImageDescriptor DESC_WIZBAN_NEW_SOURCEFILE= create(T_WIZBAN, "newcfile_wiz.gif"); //$NON-NLS-1$
|
||||
|
||||
public static final ImageDescriptor DESC_TOOL_NEWCLASS= create(T_TOOL, "newclass_wiz.gif"); //$NON-NLS-1$
|
||||
|
||||
|
|
|
@ -12,10 +12,10 @@ package org.eclipse.cdt.internal.ui.wizards;
|
|||
|
||||
import java.util.Iterator;
|
||||
|
||||
import org.eclipse.cdt.core.model.ICElement;
|
||||
import org.eclipse.cdt.internal.ui.util.ExceptionHandler;
|
||||
import org.eclipse.cdt.internal.ui.util.PixelConverter;
|
||||
import org.eclipse.cdt.ui.CUIPlugin;
|
||||
import org.eclipse.core.resources.IFile;
|
||||
import org.eclipse.core.resources.IWorkspace;
|
||||
import org.eclipse.core.resources.ResourcesPlugin;
|
||||
import org.eclipse.core.runtime.CoreException;
|
||||
|
@ -24,10 +24,15 @@ import org.eclipse.jface.action.IAction;
|
|||
import org.eclipse.jface.dialogs.MessageDialog;
|
||||
import org.eclipse.jface.viewers.ISelection;
|
||||
import org.eclipse.jface.viewers.IStructuredSelection;
|
||||
import org.eclipse.jface.viewers.StructuredSelection;
|
||||
import org.eclipse.jface.wizard.Wizard;
|
||||
import org.eclipse.jface.wizard.WizardDialog;
|
||||
import org.eclipse.swt.widgets.Shell;
|
||||
import org.eclipse.ui.IEditorInput;
|
||||
import org.eclipse.ui.IEditorPart;
|
||||
import org.eclipse.ui.IFileEditorInput;
|
||||
import org.eclipse.ui.IWorkbench;
|
||||
import org.eclipse.ui.IWorkbenchPart;
|
||||
import org.eclipse.ui.IWorkbenchWindow;
|
||||
import org.eclipse.ui.IWorkbenchWindowActionDelegate;
|
||||
import org.eclipse.ui.IWorkbenchWizard;
|
||||
|
@ -118,10 +123,20 @@ public abstract class AbstractOpenWizardAction extends Action implements IWorkbe
|
|||
ISelection selection= window.getSelectionService().getSelection();
|
||||
if (selection instanceof IStructuredSelection) {
|
||||
return (IStructuredSelection) selection;
|
||||
} else {
|
||||
// Build the selection from the IFile of the editor
|
||||
IWorkbenchPart part = window.getPartService().getActivePart();
|
||||
if (part instanceof IEditorPart) {
|
||||
IEditorInput input = ((IEditorPart) part).getEditorInput();
|
||||
if (input instanceof IFileEditorInput) {
|
||||
IFile file = ((IFileEditorInput) input).getFile();
|
||||
if (file != null)
|
||||
return new StructuredSelection(file);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
return null;
|
||||
return StructuredSelection.EMPTY;
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -10,11 +10,8 @@
|
|||
*******************************************************************************/
|
||||
package org.eclipse.cdt.internal.ui.wizards;
|
||||
|
||||
import java.util.ArrayList;
|
||||
|
||||
import org.eclipse.cdt.ui.CUIPlugin;
|
||||
import org.eclipse.core.runtime.IConfigurationElement;
|
||||
import org.eclipse.core.runtime.IExtensionPoint;
|
||||
import org.eclipse.core.runtime.IRegistryChangeEvent;
|
||||
import org.eclipse.core.runtime.IRegistryChangeListener;
|
||||
import org.eclipse.core.runtime.Platform;
|
||||
import org.eclipse.jface.action.Action;
|
||||
import org.eclipse.jface.action.ActionContributionItem;
|
||||
|
@ -25,25 +22,47 @@ import org.eclipse.swt.widgets.Control;
|
|||
import org.eclipse.swt.widgets.Menu;
|
||||
import org.eclipse.ui.IWorkbenchWindow;
|
||||
import org.eclipse.ui.IWorkbenchWindowPulldownDelegate2;
|
||||
import org.eclipse.ui.PlatformUI;
|
||||
import org.eclipse.ui.internal.IWorkbenchConstants;
|
||||
|
||||
public abstract class AbstractWizardDropDownAction extends Action implements IMenuCreator, IWorkbenchWindowPulldownDelegate2 {
|
||||
|
||||
private final static String TAG_WIZARD = "wizard"; //$NON-NLS-1$
|
||||
private final static String ATT_CATEGORY = "category";//$NON-NLS-1$
|
||||
protected final static IAction[] NO_ACTIONS = new IAction[0];
|
||||
private Menu fMenu;
|
||||
private IAction[] fActions;
|
||||
private IRegistryChangeListener fListener;
|
||||
|
||||
public AbstractWizardDropDownAction() {
|
||||
fMenu= null;
|
||||
fActions= null;
|
||||
setMenuCreator(this);
|
||||
|
||||
// listen for changes to wizard extensions
|
||||
fListener = new IRegistryChangeListener() {
|
||||
public void registryChanged(IRegistryChangeEvent event) {
|
||||
refreshActions();
|
||||
}
|
||||
};
|
||||
Platform.getExtensionRegistry().addRegistryChangeListener(fListener);
|
||||
}
|
||||
|
||||
public void refreshActions() {
|
||||
// force menu and actions to be created again
|
||||
fActions = null;
|
||||
if (fMenu != null) {
|
||||
fMenu.dispose();
|
||||
fMenu = null;
|
||||
}
|
||||
}
|
||||
|
||||
public void dispose() {
|
||||
if (fListener != null) {
|
||||
Platform.getExtensionRegistry().removeRegistryChangeListener(fListener);
|
||||
fListener= null;
|
||||
}
|
||||
if (fMenu != null) {
|
||||
fMenu.dispose();
|
||||
fMenu= null;
|
||||
}
|
||||
fActions= null;
|
||||
}
|
||||
|
||||
public Menu getMenu(Menu parent) {
|
||||
|
@ -53,67 +72,52 @@ public abstract class AbstractWizardDropDownAction extends Action implements IMe
|
|||
public Menu getMenu(Control parent) {
|
||||
if (fMenu == null) {
|
||||
fMenu= new Menu(parent);
|
||||
|
||||
Action[] actions= getActionFromDescriptors();
|
||||
IAction[] actions= getActions();
|
||||
for (int i= 0; i < actions.length; i++) {
|
||||
ActionContributionItem item= new ActionContributionItem(actions[i]);
|
||||
item.fill(fMenu, -1);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
return fMenu;
|
||||
}
|
||||
|
||||
public void run() {
|
||||
// for now, just run the first available action
|
||||
Action[] actions = getActionFromDescriptors();
|
||||
if (actions != null) {
|
||||
for (int i = 0; i < actions.length; ++i) {
|
||||
AbstractOpenWizardAction action = (AbstractOpenWizardAction) actions[0];
|
||||
if (action.isEnabled()) {
|
||||
action.run();
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
// for now, run the default action
|
||||
// we might want the last run action at some point
|
||||
IAction action = getDefaultAction();
|
||||
if (action != null) {
|
||||
action.run();
|
||||
}
|
||||
}
|
||||
|
||||
public Action[] getActionFromDescriptors() {
|
||||
ArrayList CActions = new ArrayList();
|
||||
ArrayList CCActions = new ArrayList();
|
||||
|
||||
IExtensionPoint extensionPoint = Platform.getExtensionRegistry().getExtensionPoint(PlatformUI.PLUGIN_ID, IWorkbenchConstants.PL_NEW);
|
||||
if (extensionPoint != null) {
|
||||
IConfigurationElement[] elements = extensionPoint.getConfigurationElements();
|
||||
for (int i = 0; i < elements.length; i++) {
|
||||
IConfigurationElement element= elements[i];
|
||||
if (element.getName().equals(TAG_WIZARD)) {
|
||||
String category = element.getAttribute(ATT_CATEGORY);
|
||||
if (category != null) {
|
||||
if (category.equals(CUIPlugin.CCWIZARD_CATEGORY_ID)) {
|
||||
AbstractOpenWizardAction action = createWizardAction(element);
|
||||
if (action != null) {
|
||||
CCActions.add(action);
|
||||
}
|
||||
} else if (category.equals(CUIPlugin.CWIZARD_CATEGORY_ID)) {
|
||||
AbstractOpenWizardAction action = createWizardAction(element);
|
||||
if (action != null) {
|
||||
CActions.add(action);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
public IAction getDefaultAction() {
|
||||
IAction[] actions = getActions();
|
||||
if (actions.length > 0) {
|
||||
actions[0].getId();
|
||||
return actions[0];
|
||||
// for (int i = 0; i < actions.length; ++i) {
|
||||
// IAction action = actions[i];
|
||||
// if (action.isEnabled()) {
|
||||
// return action;
|
||||
// }
|
||||
// }
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
private IAction[] getActions() {
|
||||
if (fActions == null) {
|
||||
fActions = getWizardActions();
|
||||
if (fActions == null)
|
||||
fActions = NO_ACTIONS;
|
||||
|
||||
//TODO: check for duplicate actions
|
||||
// show C actions, then C++ Actions
|
||||
CActions.addAll(CCActions);
|
||||
return (Action[]) CActions.toArray(new Action[CActions.size()]);
|
||||
//TODO provide a way to sort the actions
|
||||
}
|
||||
return fActions;
|
||||
}
|
||||
|
||||
public abstract AbstractOpenWizardAction createWizardAction(IConfigurationElement element);
|
||||
|
||||
protected abstract IAction[] getWizardActions();
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.eclipse.ui.IWorkbenchWindowActionDelegate#init(org.eclipse.ui.IWorkbenchWindow)
|
||||
*/
|
||||
|
|
|
@ -18,6 +18,8 @@ import org.eclipse.swt.widgets.Shell;
|
|||
/**
|
||||
* A dialog to select a type from a list of types. The selected type will be
|
||||
* opened in the editor.
|
||||
*
|
||||
* @deprecated use NewBaseClassSelectionDialog instead
|
||||
*/
|
||||
public class BaseClassSelectionDialog extends TypeSelectionDialog {
|
||||
|
||||
|
|
|
@ -0,0 +1,350 @@
|
|||
/*******************************************************************************
|
||||
* Copyright (c) 2004 QNX Software Systems and others. All rights reserved. This
|
||||
* program and the accompanying materials are made available under the terms of
|
||||
* the Common Public License v1.0 which accompanies this distribution, and is
|
||||
* available at http://www.eclipse.org/legal/cpl-v10.html
|
||||
*
|
||||
* Contributors: QNX Software Systems - initial API and implementation
|
||||
******************************************************************************/
|
||||
package org.eclipse.cdt.internal.ui.wizards;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import org.eclipse.cdt.ui.CUIPlugin;
|
||||
import org.eclipse.core.runtime.IConfigurationElement;
|
||||
import org.eclipse.core.runtime.IExtensionPoint;
|
||||
import org.eclipse.core.runtime.Platform;
|
||||
import org.eclipse.jface.action.IAction;
|
||||
import org.eclipse.ui.PlatformUI;
|
||||
import org.eclipse.ui.internal.IWorkbenchConstants;
|
||||
|
||||
/**
|
||||
* Convenience class for drop-in C/C++ Wizard contributions.
|
||||
*/
|
||||
public class CWizardRegistry {
|
||||
|
||||
private final static String TAG_WIZARD = "wizard"; //$NON-NLS-1$
|
||||
private final static String ATT_CATEGORY = "category";//$NON-NLS-1$
|
||||
private final static String ATT_PROJECT = "project";//$NON-NLS-1$
|
||||
private final static String TAG_PARAMETER = "parameter";//$NON-NLS-1$
|
||||
private final static String TAG_NAME = "name";//$NON-NLS-1$
|
||||
private final static String TAG_VALUE = "value";//$NON-NLS-1$
|
||||
private final static String ATT_CTYPE = "ctype";//$NON-NLS-1$
|
||||
private final static String ATT_CFILE = "cfile";//$NON-NLS-1$
|
||||
private final static String ATT_CPROJECT = "cproject";//$NON-NLS-1$
|
||||
private final static String ATT_CCPROJECT = "ccproject";//$NON-NLS-1$
|
||||
|
||||
/**
|
||||
* Checks if wizard supports C projects.
|
||||
*
|
||||
* @param element the wizard element
|
||||
*
|
||||
* @return <code>true</code> if the given wizard element applies to a C Project
|
||||
*/
|
||||
public static boolean isCProjectWizard(IConfigurationElement element) {
|
||||
String category = element.getAttribute(ATT_CATEGORY);
|
||||
return (category != null && category.equals(CUIPlugin.CWIZARD_CATEGORY_ID));
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks if wizard supports C++ project.
|
||||
*
|
||||
* @param element the wizard element
|
||||
*
|
||||
* @return <code>true</code> if the given wizard element applies to a C++ Project
|
||||
*/
|
||||
public static boolean isCCProjectWizard(IConfigurationElement element) {
|
||||
String category = element.getAttribute(ATT_CATEGORY);
|
||||
return (category != null && category.equals(CUIPlugin.CCWIZARD_CATEGORY_ID));
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns IDs of all C/C++ project wizards contributed to the workbench.
|
||||
*
|
||||
* @return an array of wizard ids
|
||||
*/
|
||||
public static String[] getProjectWizardIDs() {
|
||||
return getWizardIDs(getProjectWizardElements());
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns extension data for all the C/C++ project wizards contributed to the workbench.
|
||||
* <wizard
|
||||
* name="My C Wizard"
|
||||
* icon="icons/cwiz.gif"
|
||||
* category="org.eclipse.cdt.ui.newCWizards"
|
||||
* id="xx.MyCWizard"
|
||||
* class="org.xx.MyCWizard"
|
||||
* project="true">
|
||||
* <description>
|
||||
* My C Wizard
|
||||
* </description>
|
||||
* </wizard>
|
||||
*
|
||||
*
|
||||
* @return an array of IConfigurationElement
|
||||
*/
|
||||
public static IConfigurationElement[] getProjectWizardElements() {
|
||||
List elemList = new ArrayList();
|
||||
IConfigurationElement[] elements = getAllWizardElements();
|
||||
for (int i = 0; i < elements.length; ++i) {
|
||||
IConfigurationElement element = elements[i];
|
||||
if (isProjectWizard(element)) {
|
||||
elemList.add(element);
|
||||
}
|
||||
}
|
||||
return (IConfigurationElement[]) elemList.toArray(new IConfigurationElement[elemList.size()]);
|
||||
}
|
||||
|
||||
private static boolean isProjectWizard(IConfigurationElement element) {
|
||||
String project = element.getAttribute(ATT_PROJECT);
|
||||
if (project != null) {
|
||||
return Boolean.valueOf(project).booleanValue();
|
||||
}
|
||||
|
||||
IConfigurationElement[] classElements = element.getChildren(IWorkbenchConstants.TAG_CLASS);
|
||||
if (classElements.length > 0) {
|
||||
for (int i = 0; i < classElements.length; i++) {
|
||||
IConfigurationElement[] paramElements = classElements[i].getChildren(TAG_PARAMETER);
|
||||
for (int k = 0; k < paramElements.length; k++) {
|
||||
IConfigurationElement curr = paramElements[k];
|
||||
String name = curr.getAttribute(TAG_NAME);
|
||||
if (name != null && (name.equals(ATT_CPROJECT) || name.equals(ATT_CCPROJECT))) {
|
||||
String value = curr.getAttribute(TAG_VALUE);
|
||||
if (value != null)
|
||||
return Boolean.valueOf(value).booleanValue();
|
||||
}
|
||||
}
|
||||
}
|
||||
return false;
|
||||
} else {
|
||||
// fall back, if no <class> element found then assume it's a project wizard
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
public static IAction[] getProjectWizardActions() {
|
||||
return createActions(getProjectWizardElements());
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns IDs of all C/C++ type wizards contributed to the workbench.
|
||||
*
|
||||
* @return an array of wizard ids
|
||||
*/
|
||||
public static String[] getTypeWizardIDs() {
|
||||
return getWizardIDs(getTypeWizardElements());
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns extension data for all the C/C++ type wizards contributed to the workbench.
|
||||
* <wizard
|
||||
* name="My C Wizard"
|
||||
* icon="icons/cwiz.gif"
|
||||
* category="org.eclipse.cdt.ui.newCWizards"
|
||||
* id="xx.MyCWizard">
|
||||
* <class class="org.xx.MyCWizard">
|
||||
* <parameter name="ctype" value="true" />
|
||||
* </class>
|
||||
* <description>
|
||||
* My C Wizard
|
||||
* </description>
|
||||
* </wizard>
|
||||
*
|
||||
* @return an array of IConfigurationElement
|
||||
*/
|
||||
public static IConfigurationElement[] getTypeWizardElements() {
|
||||
List elemList = new ArrayList();
|
||||
IConfigurationElement[] elements = getAllWizardElements();
|
||||
for (int i = 0; i < elements.length; ++i) {
|
||||
IConfigurationElement element = elements[i];
|
||||
if (isTypeWizard(element)) {
|
||||
elemList.add(element);
|
||||
}
|
||||
}
|
||||
return (IConfigurationElement[]) elemList.toArray(new IConfigurationElement[elemList.size()]);
|
||||
}
|
||||
|
||||
private static boolean isTypeWizard(IConfigurationElement element) {
|
||||
IConfigurationElement[] classElements = element.getChildren(IWorkbenchConstants.TAG_CLASS);
|
||||
if (classElements.length > 0) {
|
||||
for (int i = 0; i < classElements.length; i++) {
|
||||
IConfigurationElement[] paramElements = classElements[i].getChildren(TAG_PARAMETER);
|
||||
for (int k = 0; k < paramElements.length; k++) {
|
||||
IConfigurationElement curr = paramElements[k];
|
||||
String name = curr.getAttribute(TAG_NAME);
|
||||
if (name != null && name.equals(ATT_CTYPE)) {
|
||||
String value = curr.getAttribute(TAG_VALUE);
|
||||
if (value != null)
|
||||
return Boolean.valueOf(value).booleanValue();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
public static IAction[] getTypeWizardActions() {
|
||||
return createActions(getTypeWizardElements());
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns IDs of all C/C++ file wizards contributed to the workbench.
|
||||
*
|
||||
* @return an array of wizard ids
|
||||
*/
|
||||
public static String[] getFileWizardIDs() {
|
||||
return getWizardIDs(getFileWizardElements());
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns extension data for all the C/C++ file wizards contributed to the workbench.
|
||||
* <wizard
|
||||
* name="My C File Wizard"
|
||||
* icon="icons/cwiz.gif"
|
||||
* category="org.eclipse.cdt.ui.newCWizards"
|
||||
* id="xx.MyCWizard">
|
||||
* <class class="org.xx.MyCFileWizard">
|
||||
* <parameter name="cfile" value="true" />
|
||||
* </class>
|
||||
* <description>
|
||||
* My C File Wizard
|
||||
* </description>
|
||||
* </wizard>
|
||||
*
|
||||
* @return an array of IConfigurationElement
|
||||
*/
|
||||
public static IConfigurationElement[] getFileWizardElements() {
|
||||
List elemList = new ArrayList();
|
||||
IConfigurationElement[] elements = getAllWizardElements();
|
||||
for (int i = 0; i < elements.length; ++i) {
|
||||
IConfigurationElement element = elements[i];
|
||||
if (isFileWizard(element)) {
|
||||
elemList.add(element);
|
||||
}
|
||||
}
|
||||
return (IConfigurationElement[]) elemList.toArray(new IConfigurationElement[elemList.size()]);
|
||||
}
|
||||
|
||||
private static boolean isFileWizard(IConfigurationElement element) {
|
||||
IConfigurationElement[] classElements = element.getChildren(IWorkbenchConstants.TAG_CLASS);
|
||||
if (classElements.length > 0) {
|
||||
for (int i = 0; i < classElements.length; i++) {
|
||||
IConfigurationElement[] paramElements = classElements[i].getChildren(TAG_PARAMETER);
|
||||
for (int k = 0; k < paramElements.length; k++) {
|
||||
IConfigurationElement curr = paramElements[k];
|
||||
String name = curr.getAttribute(TAG_NAME);
|
||||
if (name != null && name.equals(ATT_CFILE)) {
|
||||
String value = curr.getAttribute(TAG_VALUE);
|
||||
if (value != null)
|
||||
return Boolean.valueOf(value).booleanValue();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
public static IAction[] getFileWizardActions() {
|
||||
return createActions(getFileWizardElements());
|
||||
}
|
||||
|
||||
private static String[] getWizardIDs(IConfigurationElement[] elements) {
|
||||
List idList = new ArrayList();
|
||||
|
||||
// add C wizards first
|
||||
for (int i = 0; i < elements.length; ++i) {
|
||||
IConfigurationElement element= elements[i];
|
||||
if (isCProjectWizard(element)) {
|
||||
String id = element.getAttribute(IWorkbenchConstants.TAG_ID);
|
||||
if (id != null && !idList.contains(id)) {
|
||||
idList.add(id);
|
||||
}
|
||||
}
|
||||
}
|
||||
// now add C++ wizards
|
||||
for (int i = 0; i < elements.length; ++i) {
|
||||
IConfigurationElement element= elements[i];
|
||||
if (isCCProjectWizard(element)) {
|
||||
String id = element.getAttribute(IWorkbenchConstants.TAG_ID);
|
||||
if (id != null && !idList.contains(id)) {
|
||||
idList.add(id);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return (String[]) idList.toArray(new String[idList.size()]);
|
||||
}
|
||||
|
||||
private static IAction[] createActions(IConfigurationElement[] elements) {
|
||||
List idList = new ArrayList();
|
||||
List actionList = new ArrayList();
|
||||
|
||||
// add C wizards first
|
||||
for (int i = 0; i < elements.length; ++i) {
|
||||
IConfigurationElement element = elements[i];
|
||||
if (isCProjectWizard(element)) {
|
||||
String id = element.getAttribute(IWorkbenchConstants.TAG_ID);
|
||||
if (id != null && !idList.contains(id)) {
|
||||
idList.add(id);
|
||||
IAction action = new OpenNewWizardAction(element);
|
||||
if (action != null) {
|
||||
actionList.add(action);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
// now add C++ wizards
|
||||
for (int i = 0; i < elements.length; ++i) {
|
||||
IConfigurationElement element = elements[i];
|
||||
if (isCCProjectWizard(element)) {
|
||||
String id = element.getAttribute(IWorkbenchConstants.TAG_ID);
|
||||
if (id != null && !idList.contains(id)) {
|
||||
idList.add(id);
|
||||
IAction action = new OpenNewWizardAction(element);
|
||||
if (action != null) {
|
||||
actionList.add(action);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return (IAction[]) actionList.toArray(new IAction[actionList.size()]);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns extension data for all the C/C++ wizards contributed to the workbench.
|
||||
* <wizard
|
||||
* name="My C Wizard"
|
||||
* icon="icons/cwiz.gif"
|
||||
* category="org.eclipse.cdt.ui.newCWizards"
|
||||
* id="xx.MyCWizard">
|
||||
* <description>
|
||||
* My C Wizard
|
||||
* </description>
|
||||
* </wizard>
|
||||
*
|
||||
* @return an array of IConfigurationElement
|
||||
*/
|
||||
public static IConfigurationElement[] getAllWizardElements() {
|
||||
List elemList = new ArrayList();
|
||||
IExtensionPoint extensionPoint = Platform.getExtensionRegistry().getExtensionPoint(PlatformUI.PLUGIN_ID, IWorkbenchConstants.PL_NEW);
|
||||
if (extensionPoint != null) {
|
||||
IConfigurationElement[] elements = extensionPoint.getConfigurationElements();
|
||||
for (int i = 0; i < elements.length; i++) {
|
||||
IConfigurationElement element= elements[i];
|
||||
if (element.getName().equals(TAG_WIZARD)) {
|
||||
String category = element.getAttribute(ATT_CATEGORY);
|
||||
if (category != null &&
|
||||
(category.equals(CUIPlugin.CCWIZARD_CATEGORY_ID)
|
||||
|| category.equals(CUIPlugin.CWIZARD_CATEGORY_ID))) {
|
||||
elemList.add(element);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return (IConfigurationElement[]) elemList.toArray(new IConfigurationElement[elemList.size()]);
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,23 @@
|
|||
/*******************************************************************************
|
||||
* Copyright (c) 2004 QNX Software Systems and others. All rights reserved. This
|
||||
* program and the accompanying materials are made available under the terms of
|
||||
* the Common Public License v1.0 which accompanies this distribution, and is
|
||||
* available at http://www.eclipse.org/legal/cpl-v10.html
|
||||
*
|
||||
* Contributors: QNX Software Systems - initial API and implementation
|
||||
******************************************************************************/
|
||||
package org.eclipse.cdt.internal.ui.wizards;
|
||||
|
||||
import org.eclipse.jface.action.IAction;
|
||||
|
||||
public class NewFileDropDownAction extends AbstractWizardDropDownAction {
|
||||
|
||||
public NewFileDropDownAction() {
|
||||
super();
|
||||
// WorkbenchHelp.setHelp(this, ICHelpContextIds.OPEN_FILE_WIZARD_ACTION);
|
||||
}
|
||||
|
||||
protected IAction[] getWizardActions() {
|
||||
return CWizardRegistry.getFileWizardActions();
|
||||
}
|
||||
}
|
|
@ -11,92 +11,17 @@
|
|||
package org.eclipse.cdt.internal.ui.wizards;
|
||||
|
||||
import org.eclipse.cdt.internal.ui.ICHelpContextIds;
|
||||
import org.eclipse.core.runtime.IConfigurationElement;
|
||||
import org.eclipse.jface.action.IAction;
|
||||
import org.eclipse.ui.help.WorkbenchHelp;
|
||||
import org.eclipse.ui.internal.IWorkbenchConstants;
|
||||
|
||||
/* <wizard
|
||||
* name="My C Wizard"
|
||||
* icon="icons/cwiz.gif"
|
||||
* category="org.eclipse.cdt.ui.newCWizards"
|
||||
* id="xx.MyCWizard"
|
||||
* class="org.xx.MyCWizard"
|
||||
* project="true">
|
||||
* <class class="org.xx.MyCWizard">
|
||||
* <parameter name="cproject" value="true" />
|
||||
* <parameter name="ccproject" value="true" />
|
||||
* </class>
|
||||
* <description>
|
||||
* My C Wizard
|
||||
* </description>
|
||||
* </wizard>
|
||||
*
|
||||
* for backward compatibility:
|
||||
* <wizard
|
||||
* name="My C Wizard"
|
||||
* icon="icons/cwiz.gif"
|
||||
* category="org.eclipse.cdt.ui.newCWizards"
|
||||
* id="xx.MyCWizard"
|
||||
* class="org.xx.MyCWizard"
|
||||
* project="true">
|
||||
* <description>
|
||||
* My C Wizard
|
||||
* </description>
|
||||
* </wizard>
|
||||
*/
|
||||
public class NewProjectDropDownAction extends AbstractWizardDropDownAction {
|
||||
|
||||
private final static String ATT_PROJECT = "project";//$NON-NLS-1$
|
||||
private final static String TAG_PARAMETER = "parameter";//$NON-NLS-1$
|
||||
private final static String TAG_NAME = "name";//$NON-NLS-1$
|
||||
private final static String TAG_VALUE = "value";//$NON-NLS-1$
|
||||
private final static String ATT_CPROJECT = "cproject";//$NON-NLS-1$
|
||||
private final static String ATT_CCPROJECT = "ccproject";//$NON-NLS-1$
|
||||
|
||||
public NewProjectDropDownAction() {
|
||||
super();
|
||||
WorkbenchHelp.setHelp(this, ICHelpContextIds.OPEN_PROJECT_WIZARD_ACTION);
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.eclipse.cdt.internal.ui.wizards.AbstractWizardDropDownAction#createWizardAction(org.eclipse.core.runtime.IConfigurationElement)
|
||||
*/
|
||||
public AbstractOpenWizardAction createWizardAction(IConfigurationElement element) {
|
||||
if (isProjectWizard(element)) {
|
||||
return new OpenNewWizardAction(element);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.eclipse.cdt.internal.ui.wizards.AbstractWizardDropDownAction#isValidWizard(org.eclipse.core.runtime.IConfigurationElement)
|
||||
*/
|
||||
private static boolean isProjectWizard(IConfigurationElement element) {
|
||||
boolean isProject = false;
|
||||
String project = element.getAttribute(ATT_PROJECT);
|
||||
if (project != null)
|
||||
isProject = Boolean.valueOf(project).booleanValue();
|
||||
if (!isProject)
|
||||
return false;
|
||||
|
||||
IConfigurationElement[] classElements = element.getChildren(IWorkbenchConstants.TAG_CLASS);
|
||||
if (classElements.length > 0) {
|
||||
for (int i = 0; i < classElements.length; i++) {
|
||||
IConfigurationElement[] paramElements = classElements[i].getChildren(TAG_PARAMETER);
|
||||
for (int k = 0; k < paramElements.length; k++) {
|
||||
IConfigurationElement curr = paramElements[k];
|
||||
String name = curr.getAttribute(TAG_NAME);
|
||||
if (name != null && (name.equals(ATT_CPROJECT) || name.equals(ATT_CCPROJECT))) {
|
||||
String value = curr.getAttribute(TAG_VALUE);
|
||||
if (value != null)
|
||||
return Boolean.valueOf(value).booleanValue();
|
||||
}
|
||||
}
|
||||
}
|
||||
return false;
|
||||
} else {
|
||||
// fall back, if no <class> element found then assume it's a project wizard
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
protected IAction[] getWizardActions() {
|
||||
return CWizardRegistry.getProjectWizardActions();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -11,64 +11,17 @@
|
|||
package org.eclipse.cdt.internal.ui.wizards;
|
||||
|
||||
import org.eclipse.cdt.internal.ui.ICHelpContextIds;
|
||||
import org.eclipse.core.runtime.IConfigurationElement;
|
||||
import org.eclipse.jface.action.IAction;
|
||||
import org.eclipse.ui.help.WorkbenchHelp;
|
||||
import org.eclipse.ui.internal.IWorkbenchConstants;
|
||||
|
||||
/** <wizard
|
||||
* name="My C Wizard"
|
||||
* icon="icons/cwiz.gif"
|
||||
* category="org.eclipse.cdt.ui.newCWizards"
|
||||
* id="xx.MyCWizard">
|
||||
* <class class="org.xx.MyCWizard">
|
||||
* <parameter name="ctype" value="true" />
|
||||
* </class>
|
||||
* <description>
|
||||
* My C Wizard
|
||||
* </description>
|
||||
* </wizard>
|
||||
*/
|
||||
public class NewTypeDropDownAction extends AbstractWizardDropDownAction {
|
||||
|
||||
private final static String ATT_CTYPE = "ctype";//$NON-NLS-1$
|
||||
private final static String TAG_PARAMETER = "parameter";//$NON-NLS-1$
|
||||
private final static String TAG_NAME = "name";//$NON-NLS-1$
|
||||
private final static String TAG_VALUE = "value";//$NON-NLS-1$
|
||||
|
||||
public NewTypeDropDownAction() {
|
||||
super();
|
||||
WorkbenchHelp.setHelp(this, ICHelpContextIds.OPEN_CLASS_WIZARD_ACTION);
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.eclipse.cdt.internal.ui.wizards.AbstractWizardDropDownAction#createWizardAction(org.eclipse.core.runtime.IConfigurationElement)
|
||||
*/
|
||||
public AbstractOpenWizardAction createWizardAction(IConfigurationElement element) {
|
||||
if (isTypeWizard(element)) {
|
||||
return new OpenNewWizardAction(element);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.eclipse.cdt.internal.ui.wizards.AbstractWizardDropDownAction#isValidWizard(org.eclipse.core.runtime.IConfigurationElement)
|
||||
*/
|
||||
private static boolean isTypeWizard(IConfigurationElement element) {
|
||||
IConfigurationElement[] classElements = element.getChildren(IWorkbenchConstants.TAG_CLASS);
|
||||
if (classElements.length > 0) {
|
||||
for (int i = 0; i < classElements.length; i++) {
|
||||
IConfigurationElement[] paramElements = classElements[i].getChildren(TAG_PARAMETER);
|
||||
for (int k = 0; k < paramElements.length; k++) {
|
||||
IConfigurationElement curr = paramElements[k];
|
||||
String name = curr.getAttribute(TAG_NAME);
|
||||
if (name != null && name.equals(ATT_CTYPE)) {
|
||||
String value = curr.getAttribute(TAG_VALUE);
|
||||
if (value != null)
|
||||
return Boolean.valueOf(value).booleanValue();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
protected IAction[] getWizardActions() {
|
||||
return CWizardRegistry.getTypeWizardActions();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -18,6 +18,10 @@ import org.eclipse.ui.wizards.newresource.BasicNewFileResourceWizard;
|
|||
|
||||
import org.eclipse.cdt.ui.CUIPlugin;
|
||||
|
||||
/**
|
||||
* @deprecated use NewFileCreationWizard instead
|
||||
*/
|
||||
|
||||
public class OpenNewFileWizardAction extends Action implements IWorkbenchWindowActionDelegate {
|
||||
|
||||
|
||||
|
|
|
@ -31,6 +31,7 @@ import org.eclipse.cdt.core.parser.IScannerInfo;
|
|||
import org.eclipse.cdt.core.parser.IScannerInfoProvider;
|
||||
import org.eclipse.cdt.core.parser.ast.ASTAccessVisibility;
|
||||
import org.eclipse.cdt.internal.corext.util.CModelUtil;
|
||||
import org.eclipse.cdt.internal.ui.wizards.filewizard.NewSourceFileGenerator;
|
||||
import org.eclipse.core.resources.IFile;
|
||||
import org.eclipse.core.resources.IProject;
|
||||
import org.eclipse.core.runtime.CoreException;
|
||||
|
@ -135,7 +136,7 @@ public class NewClassCodeGenerator {
|
|||
}
|
||||
|
||||
if (fSourcePath != null) {
|
||||
IFile sourceFile = NewSourceFileGenerator.createHeaderFile(fSourcePath, true, new SubProgressMonitor(monitor, 50));
|
||||
IFile sourceFile = NewSourceFileGenerator.createSourceFile(fSourcePath, true, new SubProgressMonitor(monitor, 50));
|
||||
if (sourceFile != null) {
|
||||
sourceTU = (ITranslationUnit) CoreModel.getDefault().create(sourceFile);
|
||||
}
|
||||
|
|
|
@ -44,6 +44,7 @@ import org.eclipse.cdt.internal.ui.util.ExceptionHandler;
|
|||
import org.eclipse.cdt.internal.ui.util.SWTUtil;
|
||||
import org.eclipse.cdt.internal.ui.viewsupport.IViewPartInputProvider;
|
||||
import org.eclipse.cdt.internal.ui.wizards.NewElementWizardPage;
|
||||
import org.eclipse.cdt.internal.ui.wizards.SourceFolderSelectionDialog;
|
||||
import org.eclipse.cdt.internal.ui.wizards.classwizard.NewBaseClassSelectionDialog.ITypeSelectionListener;
|
||||
import org.eclipse.cdt.internal.ui.wizards.classwizard.NewClassCodeGenerator.CodeGeneratorException;
|
||||
import org.eclipse.cdt.internal.ui.wizards.dialogfields.DialogField;
|
||||
|
@ -57,6 +58,7 @@ import org.eclipse.cdt.internal.ui.wizards.dialogfields.SelectionButtonDialogFie
|
|||
import org.eclipse.cdt.internal.ui.wizards.dialogfields.Separator;
|
||||
import org.eclipse.cdt.internal.ui.wizards.dialogfields.StringButtonDialogField;
|
||||
import org.eclipse.cdt.internal.ui.wizards.dialogfields.StringDialogField;
|
||||
import org.eclipse.cdt.internal.ui.wizards.filewizard.NewSourceFileGenerator;
|
||||
import org.eclipse.cdt.ui.CUIPlugin;
|
||||
import org.eclipse.core.resources.IFile;
|
||||
import org.eclipse.core.resources.IProject;
|
||||
|
@ -1363,7 +1365,7 @@ public class NewClassCreationWizardPage extends NewElementWizardPage {
|
|||
}
|
||||
|
||||
if (!fileExists) {
|
||||
IStatus val = validateHeaderFileName(getCurrentProject(), path.lastSegment());
|
||||
IStatus val = CConventions.validateHeaderFileName(getCurrentProject(), path.lastSegment());
|
||||
if (val.getSeverity() == IStatus.ERROR) {
|
||||
status.setError(NewClassWizardMessages.getFormattedString("NewClassCreationWizardPage.error.InvalidHeaderFileName", val.getMessage())); //$NON-NLS-1$
|
||||
return status;
|
||||
|
@ -1447,7 +1449,7 @@ public class NewClassCreationWizardPage extends NewElementWizardPage {
|
|||
}
|
||||
|
||||
if (!fileExists) {
|
||||
IStatus val = validateSourceFileName(getCurrentProject(), path.lastSegment());
|
||||
IStatus val = CConventions.validateSourceFileName(getCurrentProject(), path.lastSegment());
|
||||
if (val.getSeverity() == IStatus.ERROR) {
|
||||
status.setError(NewClassWizardMessages.getFormattedString("NewClassCreationWizardPage.error.InvalidSourceFileName", val.getMessage())); //$NON-NLS-1$
|
||||
return status;
|
||||
|
@ -1458,63 +1460,6 @@ public class NewClassCreationWizardPage extends NewElementWizardPage {
|
|||
return status;
|
||||
}
|
||||
|
||||
//TODO should this method be part of CConventions.java?
|
||||
private static IStatus validateHeaderFileName(IProject project, String name) {
|
||||
IStatus val = validateFileName(name);
|
||||
if (val.getSeverity() == IStatus.ERROR) {
|
||||
return val;
|
||||
}
|
||||
|
||||
StatusInfo status = new StatusInfo(val.getSeverity(), val.getMessage());
|
||||
|
||||
if (!CoreModel.isValidHeaderUnitName(project, name)) {
|
||||
status.setWarning(NewClassWizardMessages.getString("NewClassCreationWizardPage.convention.headerFilename.filetype")); //$NON-NLS-1$
|
||||
}
|
||||
|
||||
//TODO could use a prefs option for header file naming conventions
|
||||
return status;
|
||||
}
|
||||
|
||||
//TODO should this method be part of CConventions.java?
|
||||
private static IStatus validateSourceFileName(IProject project, String name) {
|
||||
IStatus val = validateFileName(name);
|
||||
if (val.getSeverity() == IStatus.ERROR) {
|
||||
return val;
|
||||
}
|
||||
|
||||
StatusInfo status = new StatusInfo(val.getSeverity(), val.getMessage());
|
||||
|
||||
if (!CoreModel.isValidSourceUnitName(project, name)) {
|
||||
status.setWarning(NewClassWizardMessages.getString("NewClassCreationWizardPage.convention.sourceFilename.filetype")); //$NON-NLS-1$
|
||||
}
|
||||
|
||||
//TODO could use a prefs option for source file naming conventions
|
||||
return status;
|
||||
}
|
||||
|
||||
//TODO should this method be part of CConventions.java?
|
||||
private static IStatus validateFileName(String name) {
|
||||
StatusInfo status = new StatusInfo();
|
||||
|
||||
if (name == null || name.length() == 0) {
|
||||
status.setError(NewClassWizardMessages.getString("NewClassCreationWizardPage.convention.filename.nullName")); //$NON-NLS-1$
|
||||
return status;
|
||||
}
|
||||
|
||||
IPath path = new Path(name);
|
||||
if (!path.isValidSegment(name)) {
|
||||
status.setError(NewClassWizardMessages.getString("NewClassCreationWizardPage.convention.filename.invalid")); //$NON-NLS-1$
|
||||
return status;
|
||||
}
|
||||
|
||||
if (name.indexOf(" ") != -1) { //$NON-NLS-1$
|
||||
status.setWarning(NewClassWizardMessages.getString("NewClassCreationWizardPage.convention.filename.nameWithBlanks")); //$NON-NLS-1$
|
||||
}
|
||||
|
||||
//TODO could use a prefs option for file naming conventions
|
||||
return status;
|
||||
}
|
||||
|
||||
/**
|
||||
* Hook method that gets called when a field on this page has changed.
|
||||
*
|
||||
|
|
|
@ -26,8 +26,6 @@ NewClassCreationWizardPage.getClasses.noclasses.message=No classes available.
|
|||
|
||||
NewClassCreationWizardPage.sourceFolder.label=Source &Folder:
|
||||
NewClassCreationWizardPage.sourceFolder.button=Br&owse...
|
||||
NewClassCreationWizardPage.ChooseSourceFolderDialog.title=Folder Selection
|
||||
NewClassCreationWizardPage.ChooseSourceFolderDialog.description=&Choose a source folder:
|
||||
NewClassCreationWizardPage.error.EnterSourceFolderName=Source folder name is empty.
|
||||
NewClassCreationWizardPage.error.NotAFolder=''{0}'' is not a project or folder.
|
||||
NewClassCreationWizardPage.error.NotASourceFolder=Folder ''{0}'' is not a source folder.
|
||||
|
@ -75,12 +73,6 @@ NewClassCreationWizardPage.error.BaseClassNotExistsInProject=Base class ''{0}''
|
|||
|
||||
NewClassCreationWizardPage.methodStubs.label=Method &Stubs:
|
||||
|
||||
NewClassCreationWizardPage.convention.filename.nullName=File name is blank
|
||||
NewClassCreationWizardPage.convention.filename.invalid=File name contains illegal characters
|
||||
NewClassCreationWizardPage.convention.filename.nameWithBlanks=File name contains spaces
|
||||
NewClassCreationWizardPage.convention.headerFilename.filetype=File extension does not correspond to known header file types
|
||||
NewClassCreationWizardPage.convention.sourceFilename.filetype=File extension does not correspond to known source file types
|
||||
|
||||
NewClassCreationWizardPage.error.NotAFile=''{0}'' is not a file.
|
||||
NewClassCreationWizardPage.error.FolderDoesNotExist=Folder ''{0}'' does not exist.
|
||||
NewClassCreationWizardPage.error.SourceFolderRequired=The source folder is required.
|
||||
|
@ -179,4 +171,3 @@ NewClassCodeGeneration.createType.task.source=Creating source file....
|
|||
NewClassCodeGeneration.createFile.task=Creating
|
||||
NewClassCodeGeneration.stub.constructor.name=Constructor
|
||||
NewClassCodeGeneration.stub.destructor.name=Destructor
|
||||
NewClassCodeGeneration.includeGuard.suffix=_H
|
||||
|
|
|
@ -23,7 +23,7 @@ import org.eclipse.cdt.core.model.ITranslationUnit;
|
|||
import org.eclipse.cdt.internal.corext.util.CModelUtil;
|
||||
import org.eclipse.cdt.internal.ui.dialogs.StatusInfo;
|
||||
import org.eclipse.cdt.internal.ui.dialogs.StatusUtil;
|
||||
import org.eclipse.cdt.internal.ui.wizards.TypedViewerFilter;
|
||||
import org.eclipse.cdt.internal.ui.dialogs.TypedViewerFilter;
|
||||
import org.eclipse.cdt.internal.ui.wizards.dialogfields.DialogField;
|
||||
import org.eclipse.cdt.internal.ui.wizards.dialogfields.IDialogFieldListener;
|
||||
import org.eclipse.cdt.internal.ui.wizards.dialogfields.LayoutUtil;
|
||||
|
|
|
@ -0,0 +1,73 @@
|
|||
/*******************************************************************************
|
||||
* Copyright (c) 2004 QNX Software Systems and others.
|
||||
* All rights reserved. This program and the accompanying materials
|
||||
* are made available under the terms of the Common Public License v1.0
|
||||
* which accompanies this distribution, and is available at
|
||||
* http://www.eclipse.org/legal/cpl-v10.html
|
||||
*
|
||||
* Contributors:
|
||||
* QNX Software Systems - initial API and implementation
|
||||
*******************************************************************************/
|
||||
package org.eclipse.cdt.internal.ui.wizards.filewizard;
|
||||
|
||||
import org.eclipse.cdt.core.model.ITranslationUnit;
|
||||
import org.eclipse.cdt.internal.ui.CPluginImages;
|
||||
import org.eclipse.cdt.internal.ui.wizards.NewElementWizard;
|
||||
import org.eclipse.cdt.ui.CUIPlugin;
|
||||
import org.eclipse.core.resources.IFile;
|
||||
import org.eclipse.core.resources.IResource;
|
||||
import org.eclipse.core.runtime.CoreException;
|
||||
import org.eclipse.core.runtime.IProgressMonitor;
|
||||
|
||||
public abstract class AbstractFileCreationWizard extends NewElementWizard {
|
||||
|
||||
protected AbstractFileCreationWizardPage fPage = null;
|
||||
|
||||
public AbstractFileCreationWizard() {
|
||||
super();
|
||||
setDefaultPageImageDescriptor(CPluginImages.DESC_WIZBAN_NEW_FILE);
|
||||
setDialogSettings(CUIPlugin.getDefault().getDialogSettings());
|
||||
setWindowTitle(NewFileWizardMessages.getString("AbstractFileCreationWizard.title")); //$NON-NLS-1$
|
||||
}
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
*
|
||||
* @see org.eclipse.cdt.internal.ui.wizards.NewElementWizard#canRunForked()
|
||||
*/
|
||||
protected boolean canRunForked() {
|
||||
return true;
|
||||
}
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
*
|
||||
* @see org.eclipse.cdt.internal.ui.wizards.NewElementWizard#finishPage(org.eclipse.core.runtime.IProgressMonitor)
|
||||
*/
|
||||
protected void finishPage(IProgressMonitor monitor) throws InterruptedException, CoreException {
|
||||
fPage.createFile(monitor); // use the full progress monitor
|
||||
}
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
*
|
||||
* @see org.eclipse.jface.wizard.IWizard#performFinish()
|
||||
*/
|
||||
public boolean performFinish() {
|
||||
boolean res = super.performFinish();
|
||||
if (res) {
|
||||
//TODO need prefs option for opening editor
|
||||
boolean openInEditor = true;
|
||||
|
||||
ITranslationUnit headerTU = fPage.getCreatedFileTU();
|
||||
if (headerTU != null) {
|
||||
IResource resource= headerTU.getResource();
|
||||
selectAndReveal(resource);
|
||||
if (openInEditor) {
|
||||
openResource((IFile) resource);
|
||||
}
|
||||
}
|
||||
}
|
||||
return res;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,583 @@
|
|||
/*******************************************************************************
|
||||
* Copyright (c) 2004 QNX Software Systems and others.
|
||||
* All rights reserved. This program and the accompanying materials
|
||||
* are made available under the terms of the Common Public License v1.0
|
||||
* which accompanies this distribution, and is available at
|
||||
* http://www.eclipse.org/legal/cpl-v10.html
|
||||
*
|
||||
* Contributors:
|
||||
* QNX Software Systems - initial API and implementation
|
||||
*******************************************************************************/
|
||||
package org.eclipse.cdt.internal.ui.wizards.filewizard;
|
||||
|
||||
import org.eclipse.cdt.core.browser.PathUtil;
|
||||
import org.eclipse.cdt.core.model.CModelException;
|
||||
import org.eclipse.cdt.core.model.CoreModel;
|
||||
import org.eclipse.cdt.core.model.ICContainer;
|
||||
import org.eclipse.cdt.core.model.ICElement;
|
||||
import org.eclipse.cdt.core.model.ICProject;
|
||||
import org.eclipse.cdt.core.model.ISourceRoot;
|
||||
import org.eclipse.cdt.core.model.ITranslationUnit;
|
||||
import org.eclipse.cdt.internal.corext.util.CModelUtil;
|
||||
import org.eclipse.cdt.internal.ui.dialogs.StatusInfo;
|
||||
import org.eclipse.cdt.internal.ui.editor.CEditor;
|
||||
import org.eclipse.cdt.internal.ui.viewsupport.IViewPartInputProvider;
|
||||
import org.eclipse.cdt.internal.ui.wizards.NewElementWizardPage;
|
||||
import org.eclipse.cdt.internal.ui.wizards.SourceFolderSelectionDialog;
|
||||
import org.eclipse.cdt.internal.ui.wizards.dialogfields.DialogField;
|
||||
import org.eclipse.cdt.internal.ui.wizards.dialogfields.IDialogFieldListener;
|
||||
import org.eclipse.cdt.internal.ui.wizards.dialogfields.IStringButtonAdapter;
|
||||
import org.eclipse.cdt.internal.ui.wizards.dialogfields.LayoutUtil;
|
||||
import org.eclipse.cdt.internal.ui.wizards.dialogfields.Separator;
|
||||
import org.eclipse.cdt.internal.ui.wizards.dialogfields.StringButtonDialogField;
|
||||
import org.eclipse.cdt.ui.CUIPlugin;
|
||||
import org.eclipse.core.resources.IFile;
|
||||
import org.eclipse.core.resources.IProject;
|
||||
import org.eclipse.core.resources.IResource;
|
||||
import org.eclipse.core.resources.IWorkspaceRoot;
|
||||
import org.eclipse.core.resources.ResourcesPlugin;
|
||||
import org.eclipse.core.runtime.CoreException;
|
||||
import org.eclipse.core.runtime.IAdaptable;
|
||||
import org.eclipse.core.runtime.IPath;
|
||||
import org.eclipse.core.runtime.IProgressMonitor;
|
||||
import org.eclipse.core.runtime.IStatus;
|
||||
import org.eclipse.core.runtime.Path;
|
||||
import org.eclipse.jface.text.ITextSelection;
|
||||
import org.eclipse.jface.viewers.ISelection;
|
||||
import org.eclipse.jface.viewers.ISelectionProvider;
|
||||
import org.eclipse.jface.viewers.IStructuredSelection;
|
||||
import org.eclipse.jface.window.Window;
|
||||
import org.eclipse.swt.SWT;
|
||||
import org.eclipse.swt.events.FocusEvent;
|
||||
import org.eclipse.swt.events.FocusListener;
|
||||
import org.eclipse.swt.layout.GridData;
|
||||
import org.eclipse.swt.layout.GridLayout;
|
||||
import org.eclipse.swt.widgets.Composite;
|
||||
import org.eclipse.swt.widgets.Text;
|
||||
import org.eclipse.ui.IEditorInput;
|
||||
import org.eclipse.ui.IEditorPart;
|
||||
import org.eclipse.ui.IWorkbenchPart;
|
||||
import org.eclipse.ui.views.contentoutline.ContentOutline;
|
||||
|
||||
public abstract class AbstractFileCreationWizardPage extends NewElementWizardPage {
|
||||
|
||||
private static final int MAX_FIELD_CHARS = 50;
|
||||
|
||||
private IWorkspaceRoot fWorkspaceRoot;
|
||||
|
||||
// field IDs
|
||||
private static final int SOURCE_FOLDER_ID = 1;
|
||||
protected static final int NEW_FILE_ID = 2;
|
||||
private static final int ALL_FIELDS = SOURCE_FOLDER_ID | NEW_FILE_ID;
|
||||
private int fLastFocusedField = 0;
|
||||
private StringButtonDialogField fSourceFolderDialogField;
|
||||
private IStatus fSourceFolderStatus;
|
||||
private IStatus fNewFileStatus;
|
||||
private final IStatus STATUS_OK = new StatusInfo();
|
||||
|
||||
public AbstractFileCreationWizardPage(String name) {
|
||||
super(name);
|
||||
|
||||
setDescription(NewFileWizardMessages.getString("AbstractFileCreationWizardPage.description")); //$NON-NLS-1$
|
||||
|
||||
fWorkspaceRoot = ResourcesPlugin.getWorkspace().getRoot();
|
||||
|
||||
SourceFolderFieldAdapter sourceFolderAdapter = new SourceFolderFieldAdapter();
|
||||
fSourceFolderDialogField = new StringButtonDialogField(sourceFolderAdapter);
|
||||
fSourceFolderDialogField.setDialogFieldListener(sourceFolderAdapter);
|
||||
fSourceFolderDialogField.setLabelText(NewFileWizardMessages.getString("AbstractFileCreationWizardPage.sourceFolder.label")); //$NON-NLS-1$
|
||||
fSourceFolderDialogField.setButtonLabel(NewFileWizardMessages.getString("AbstractFileCreationWizardPage.sourceFolder.button")); //$NON-NLS-1$
|
||||
|
||||
fSourceFolderStatus = STATUS_OK;
|
||||
fNewFileStatus = STATUS_OK;
|
||||
fLastFocusedField = 0;
|
||||
}
|
||||
|
||||
// -------- UI Creation ---------
|
||||
|
||||
public void createControl(Composite parent) {
|
||||
initializeDialogUnits(parent);
|
||||
|
||||
Composite composite = new Composite(parent, SWT.NONE);
|
||||
int nColumns = 3;
|
||||
|
||||
GridLayout layout = new GridLayout();
|
||||
layout.numColumns = nColumns;
|
||||
composite.setLayout(layout);
|
||||
composite.setLayoutData(new GridData(GridData.FILL_BOTH));
|
||||
composite.setFont(parent.getFont());
|
||||
|
||||
createSourceFolderControls(composite, nColumns);
|
||||
|
||||
createFileControls(composite, nColumns);
|
||||
|
||||
composite.layout();
|
||||
|
||||
setErrorMessage(null);
|
||||
setMessage(null);
|
||||
setControl(composite);
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates a separator line. Expects a <code>GridLayout</code> with at least 1 column.
|
||||
*
|
||||
* @param composite the parent composite
|
||||
* @param nColumns number of columns to span
|
||||
*/
|
||||
protected void createSeparator(Composite composite, int nColumns) {
|
||||
(new Separator(SWT.SEPARATOR | SWT.HORIZONTAL)).doFillIntoGrid(composite, nColumns, convertHeightInCharsToPixels(1));
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates the necessary controls (label, text field and browse button) to edit
|
||||
* the source folder location. The method expects that the parent composite
|
||||
* uses a <code>GridLayout</code> as its layout manager and that the
|
||||
* grid layout has at least 3 columns.
|
||||
*
|
||||
* @param parent the parent composite
|
||||
* @param nColumns the number of columns to span. This number must be
|
||||
* greater or equal three
|
||||
*/
|
||||
protected void createSourceFolderControls(Composite parent, int nColumns) {
|
||||
fSourceFolderDialogField.doFillIntoGrid(parent, nColumns);
|
||||
Text textControl = fSourceFolderDialogField.getTextControl(null);
|
||||
LayoutUtil.setWidthHint(textControl, getMaxFieldWidth());
|
||||
textControl.addFocusListener(new StatusFocusListener(SOURCE_FOLDER_ID));
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates the controls for the file name field. Expects a <code>GridLayout</code> with at
|
||||
* least 3 columns.
|
||||
*
|
||||
* @param composite the parent composite
|
||||
* @param nColumns number of columns to span
|
||||
*/
|
||||
protected abstract void createFileControls(Composite parent, int nColumns);
|
||||
|
||||
/**
|
||||
* The wizard owning this page is responsible for calling this method with the
|
||||
* current selection. The selection is used to initialize the fields of the wizard
|
||||
* page.
|
||||
*
|
||||
* @param selection used to initialize the fields
|
||||
*/
|
||||
public void init(IStructuredSelection selection) {
|
||||
ICElement celem = getInitialCElement(selection);
|
||||
initFields(celem);
|
||||
doStatusUpdate();
|
||||
}
|
||||
|
||||
/**
|
||||
* Utility method to inspect a selection to find a C element.
|
||||
*
|
||||
* @param selection the selection to be inspected
|
||||
* @return a C element to be used as the initial selection, or <code>null</code>,
|
||||
* if no C element exists in the given selection
|
||||
*/
|
||||
protected ICElement getInitialCElement(IStructuredSelection selection) {
|
||||
ICElement celem = null;
|
||||
if (selection != null && !selection.isEmpty()) {
|
||||
Object selectedElement = selection.getFirstElement();
|
||||
if (selectedElement instanceof IAdaptable) {
|
||||
IAdaptable adaptable = (IAdaptable) selectedElement;
|
||||
|
||||
celem = (ICElement) adaptable.getAdapter(ICElement.class);
|
||||
if (celem == null) {
|
||||
IResource resource = (IResource) adaptable.getAdapter(IResource.class);
|
||||
if (resource != null && resource.getType() != IResource.ROOT) {
|
||||
while (celem == null && resource.getType() != IResource.PROJECT) {
|
||||
resource = resource.getParent();
|
||||
celem = (ICElement) resource.getAdapter(ICElement.class);
|
||||
}
|
||||
if (celem == null) {
|
||||
celem = CoreModel.getDefault().create(resource); // c project
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
if (celem == null) {
|
||||
IWorkbenchPart part = CUIPlugin.getActivePage().getActivePart();
|
||||
if (part instanceof ContentOutline) {
|
||||
part = CUIPlugin.getActivePage().getActiveEditor();
|
||||
}
|
||||
|
||||
if (part instanceof IViewPartInputProvider) {
|
||||
Object elem = ((IViewPartInputProvider)part).getViewPartInput();
|
||||
if (elem instanceof ICElement) {
|
||||
celem = (ICElement) elem;
|
||||
}
|
||||
}
|
||||
|
||||
if (celem == null && part instanceof CEditor) {
|
||||
IEditorInput input = ((IEditorPart)part).getEditorInput();
|
||||
if (input != null) {
|
||||
final IResource res = (IResource) input.getAdapter(IResource.class);
|
||||
if (res != null && res instanceof IFile) {
|
||||
celem = CoreModel.getDefault().create((IFile)res);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (celem == null || celem.getElementType() == ICElement.C_MODEL) {
|
||||
try {
|
||||
ICProject[] projects = CoreModel.create(getWorkspaceRoot()).getCProjects();
|
||||
if (projects.length == 1) {
|
||||
celem = projects[0];
|
||||
}
|
||||
} catch (CModelException e) {
|
||||
CUIPlugin.getDefault().log(e);
|
||||
}
|
||||
}
|
||||
return celem;
|
||||
}
|
||||
|
||||
/**
|
||||
* Initializes all fields provided by the page with a given selection.
|
||||
*
|
||||
* @param elem the selection used to initialize this page or <code>
|
||||
* null</code> if no selection was available
|
||||
*/
|
||||
protected void initFields(ICElement elem) {
|
||||
initSourceFolder(elem);
|
||||
handleFieldChanged(ALL_FIELDS);
|
||||
}
|
||||
|
||||
/**
|
||||
* Initializes the source folder field.
|
||||
*
|
||||
* @param elem the C element used to compute the initial folder
|
||||
*/
|
||||
protected void initSourceFolder(ICElement elem) {
|
||||
ICContainer folder = null;
|
||||
if (elem != null) {
|
||||
folder = CModelUtil.getSourceFolder(elem);
|
||||
if (folder == null) {
|
||||
ICProject cproject = elem.getCProject();
|
||||
if (cproject != null) {
|
||||
try {
|
||||
if (cproject.exists()) {
|
||||
ISourceRoot[] roots = cproject.getSourceRoots();
|
||||
if (roots != null && roots.length > 0)
|
||||
folder = roots[0];
|
||||
}
|
||||
} catch (CModelException e) {
|
||||
CUIPlugin.getDefault().log(e);
|
||||
}
|
||||
if (folder == null) {
|
||||
folder = cproject.findSourceRoot(cproject.getResource());
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
setSourceFolderFullPath(folder != null ? folder.getResource().getFullPath() : null, false);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the recommended maximum width for text fields (in pixels). This
|
||||
* method requires that createContent has been called before this method is
|
||||
* call. Subclasses may override to change the maximum width for text
|
||||
* fields.
|
||||
*
|
||||
* @return the recommended maximum width for text fields.
|
||||
*/
|
||||
protected int getMaxFieldWidth() {
|
||||
return convertWidthInCharsToPixels(MAX_FIELD_CHARS);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the test selection of the current editor. <code>null</code> is returned
|
||||
* when the current editor does not have focus or does not return a text selection.
|
||||
* @return Returns the test selection of the current editor or <code>null</code>.
|
||||
*
|
||||
* @since 3.0
|
||||
*/
|
||||
protected ITextSelection getCurrentTextSelection() {
|
||||
IWorkbenchPart part = CUIPlugin.getActivePage().getActivePart();
|
||||
if (part instanceof IEditorPart) {
|
||||
ISelectionProvider selectionProvider = part.getSite().getSelectionProvider();
|
||||
if (selectionProvider != null) {
|
||||
ISelection selection = selectionProvider.getSelection();
|
||||
if (selection instanceof ITextSelection) {
|
||||
return (ITextSelection) selection;
|
||||
}
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the focus to the source folder's text field.
|
||||
*/
|
||||
protected void setFocusOnSourceFolder() {
|
||||
fSourceFolderDialogField.setFocus();
|
||||
}
|
||||
|
||||
protected final class StatusFocusListener implements FocusListener {
|
||||
private int fieldID;
|
||||
|
||||
public StatusFocusListener(int fieldID) {
|
||||
this.fieldID = fieldID;
|
||||
}
|
||||
|
||||
public void focusGained(FocusEvent e) {
|
||||
fLastFocusedField = this.fieldID;
|
||||
doStatusUpdate();
|
||||
}
|
||||
|
||||
public void focusLost(FocusEvent e) {
|
||||
fLastFocusedField = 0;
|
||||
doStatusUpdate();
|
||||
}
|
||||
}
|
||||
|
||||
private class SourceFolderFieldAdapter implements IStringButtonAdapter, IDialogFieldListener {
|
||||
public void changeControlPressed(DialogField field) {
|
||||
IPath oldFolderPath = getSourceFolderFullPath();
|
||||
IPath newFolderPath = chooseSourceFolder(oldFolderPath);
|
||||
if (newFolderPath != null) {
|
||||
IPath filePath = getFileFullPath();
|
||||
setSourceFolderFullPath(newFolderPath, false);
|
||||
handleFieldChanged(ALL_FIELDS);
|
||||
}
|
||||
}
|
||||
|
||||
public void dialogFieldChanged(DialogField field) {
|
||||
handleFieldChanged(ALL_FIELDS);
|
||||
}
|
||||
}
|
||||
|
||||
// ----------- validation ----------
|
||||
|
||||
/**
|
||||
* This method is a hook which gets called after the source folder's
|
||||
* text input field has changed. This default implementation updates
|
||||
* the model and returns an error status. The underlying model
|
||||
* is only valid if the returned status is OK.
|
||||
*
|
||||
* @return the model's error status
|
||||
*/
|
||||
protected IStatus sourceFolderChanged() {
|
||||
StatusInfo status = new StatusInfo();
|
||||
|
||||
IPath folderPath = getSourceFolderFullPath();
|
||||
if (folderPath == null) {
|
||||
status.setError(NewFileWizardMessages.getString("AbstractFileCreationWizardPage.error.EnterSourceFolderName")); //$NON-NLS-1$
|
||||
return status;
|
||||
}
|
||||
|
||||
IResource res = fWorkspaceRoot.findMember(folderPath);
|
||||
if (res != null && res.exists()) {
|
||||
int resType = res.getType();
|
||||
if (resType == IResource.PROJECT || resType == IResource.FOLDER) {
|
||||
IProject proj = res.getProject();
|
||||
if (!proj.isOpen()) {
|
||||
status.setError(NewFileWizardMessages.getFormattedString("AbstractFileCreationWizardPage.error.NotAFolder", folderPath)); //$NON-NLS-1$
|
||||
return status;
|
||||
}
|
||||
if (!CoreModel.hasCCNature(proj) && !CoreModel.hasCNature(proj)) {
|
||||
if (resType == IResource.PROJECT) {
|
||||
status.setError(NewFileWizardMessages.getString("AbstractFileCreationWizardPage.warning.NotACProject")); //$NON-NLS-1$
|
||||
return status;
|
||||
} else {
|
||||
status.setWarning(NewFileWizardMessages.getString("AbstractFileCreationWizardPage.warning.NotInACProject")); //$NON-NLS-1$
|
||||
}
|
||||
}
|
||||
ICElement e = CoreModel.getDefault().create(res.getFullPath());
|
||||
if (CModelUtil.getSourceFolder(e) == null) {
|
||||
status.setError(NewFileWizardMessages.getFormattedString("AbstractFileCreationWizardPage.error.NotASourceFolder", folderPath)); //$NON-NLS-1$
|
||||
return status;
|
||||
}
|
||||
} else {
|
||||
status.setError(NewFileWizardMessages.getFormattedString("AbstractFileCreationWizardPage.error.NotAFolder", folderPath)); //$NON-NLS-1$
|
||||
return status;
|
||||
}
|
||||
} else {
|
||||
status.setError(NewFileWizardMessages.getFormattedString("AbstractFileCreationWizardPage.error.FolderDoesNotExist", folderPath)); //$NON-NLS-1$
|
||||
return status;
|
||||
}
|
||||
|
||||
return status;
|
||||
}
|
||||
|
||||
/**
|
||||
* Hook method that gets called when a field on this page has changed.
|
||||
*
|
||||
* @param fields Bitwise-OR'd ids of the fields that changed.
|
||||
*/
|
||||
protected void handleFieldChanged(int fields) {
|
||||
if (fields == 0)
|
||||
return; // no change
|
||||
|
||||
if (fieldChanged(fields, SOURCE_FOLDER_ID)) {
|
||||
fSourceFolderStatus = sourceFolderChanged();
|
||||
}
|
||||
if (fieldChanged(fields, NEW_FILE_ID)) {
|
||||
fNewFileStatus = fileNameChanged();
|
||||
}
|
||||
doStatusUpdate();
|
||||
}
|
||||
|
||||
private boolean fieldChanged(int fields, int fieldID) {
|
||||
return ((fields & fieldID) != 0);
|
||||
}
|
||||
|
||||
protected void doStatusUpdate() {
|
||||
// do the last focused field first
|
||||
IStatus lastStatus = getLastFocusedStatus();
|
||||
|
||||
// status of all used components
|
||||
IStatus[] status = new IStatus[] {
|
||||
lastStatus,
|
||||
(fSourceFolderStatus != lastStatus) ? fSourceFolderStatus : STATUS_OK,
|
||||
(fNewFileStatus != lastStatus) ? fNewFileStatus : STATUS_OK,
|
||||
};
|
||||
|
||||
// the mode severe status will be displayed and the ok button enabled/disabled.
|
||||
updateStatus(status);
|
||||
}
|
||||
|
||||
private IStatus getLastFocusedStatus() {
|
||||
switch (fLastFocusedField) {
|
||||
case SOURCE_FOLDER_ID:
|
||||
return fSourceFolderStatus;
|
||||
case NEW_FILE_ID:
|
||||
return fNewFileStatus;
|
||||
default:
|
||||
return STATUS_OK;
|
||||
}
|
||||
}
|
||||
|
||||
public IPath getSourceFolderFullPath() {
|
||||
String text = fSourceFolderDialogField.getText();
|
||||
if (text.length() > 0)
|
||||
return new Path(text).makeAbsolute();
|
||||
return null;
|
||||
}
|
||||
|
||||
public void setSourceFolderFullPath(IPath folderPath, boolean update) {
|
||||
String str = (folderPath != null) ? folderPath.makeRelative().toString() : ""; //.makeRelative().toString(); //$NON-NLS-1$
|
||||
fSourceFolderDialogField.setTextWithoutUpdate(str);
|
||||
if (update) {
|
||||
fSourceFolderDialogField.dialogFieldChanged();
|
||||
}
|
||||
}
|
||||
|
||||
protected IProject getCurrentProject() {
|
||||
IPath folderPath = getSourceFolderFullPath();
|
||||
if (folderPath != null) {
|
||||
return PathUtil.getEnclosingProject(folderPath);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the workspace root.
|
||||
*
|
||||
* @return the workspace root
|
||||
*/
|
||||
protected IWorkspaceRoot getWorkspaceRoot() {
|
||||
return fWorkspaceRoot;
|
||||
}
|
||||
|
||||
/*
|
||||
* @see WizardPage#becomesVisible
|
||||
*/
|
||||
public void setVisible(boolean visible) {
|
||||
super.setVisible(visible);
|
||||
if (visible) {
|
||||
setFocus();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the focus on the starting input field.
|
||||
*/
|
||||
protected abstract void setFocus();
|
||||
|
||||
private IPath chooseSourceFolder(IPath initialPath) {
|
||||
ICElement initElement = getSourceFolderFromPath(initialPath);
|
||||
if (initElement instanceof ISourceRoot) {
|
||||
ICProject cProject = initElement.getCProject();
|
||||
ISourceRoot projRoot = cProject.findSourceRoot(cProject.getProject());
|
||||
if (projRoot != null && projRoot.equals(initElement))
|
||||
initElement = cProject;
|
||||
}
|
||||
|
||||
SourceFolderSelectionDialog dialog = new SourceFolderSelectionDialog(getShell());
|
||||
dialog.setInput(CoreModel.create(fWorkspaceRoot));
|
||||
dialog.setInitialSelection(initElement);
|
||||
|
||||
if (dialog.open() == Window.OK) {
|
||||
Object result = dialog.getFirstResult();
|
||||
if (result instanceof ICElement) {
|
||||
ICElement element = (ICElement)result;
|
||||
if (element instanceof ICProject) {
|
||||
ICProject cproject = (ICProject)element;
|
||||
ISourceRoot folder = cproject.findSourceRoot(cproject.getProject());
|
||||
if (folder != null)
|
||||
return folder.getResource().getFullPath();
|
||||
}
|
||||
return element.getResource().getFullPath();
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
private ICElement getSourceFolderFromPath(IPath path) {
|
||||
if (path == null)
|
||||
return null;
|
||||
while (!path.isEmpty()) {
|
||||
IResource res = fWorkspaceRoot.findMember(path);
|
||||
if (res != null && res.exists()) {
|
||||
int resType = res.getType();
|
||||
if (resType == IResource.PROJECT || resType == IResource.FOLDER) {
|
||||
ICElement elem = CoreModel.getDefault().create(res.getFullPath());
|
||||
ICContainer sourceFolder = CModelUtil.getSourceFolder(elem);
|
||||
if (sourceFolder != null)
|
||||
return sourceFolder;
|
||||
if (resType == IResource.PROJECT) {
|
||||
return elem;
|
||||
}
|
||||
}
|
||||
}
|
||||
path = path.removeLastSegments(1);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the full path computed from the file name field
|
||||
* and the source folder.
|
||||
*
|
||||
* @return the file path
|
||||
*/
|
||||
public abstract IPath getFileFullPath();
|
||||
|
||||
/**
|
||||
* Hook method that gets called when the file name has changed. The method validates the
|
||||
* file name and returns the status of the validation.
|
||||
*
|
||||
* @return the status of the validation
|
||||
*/
|
||||
protected abstract IStatus fileNameChanged();
|
||||
|
||||
/**
|
||||
* Creates the new file using the entered field values.
|
||||
*
|
||||
* @param monitor a progress monitor to report progress.
|
||||
* @throws CoreException Thrown when the creation failed.
|
||||
* @throws InterruptedException Thrown when the operation was cancelled.
|
||||
*/
|
||||
public abstract void createFile(IProgressMonitor monitor);
|
||||
|
||||
/**
|
||||
* Returns the created file. The method only returns a valid translation unit
|
||||
* after <code>createFile</code> has been called.
|
||||
*
|
||||
* @return the created translation unit
|
||||
* @see #createFile(IProgressMonitor)
|
||||
*/
|
||||
public abstract ITranslationUnit getCreatedFileTU();
|
||||
}
|
|
@ -0,0 +1,60 @@
|
|||
/*******************************************************************************
|
||||
* Copyright (c) 2004 QNX Software Systems and others.
|
||||
* All rights reserved. This program and the accompanying materials
|
||||
* are made available under the terms of the Common Public License v1.0
|
||||
* which accompanies this distribution, and is available at
|
||||
* http://www.eclipse.org/legal/cpl-v10.html
|
||||
*
|
||||
* Contributors:
|
||||
* QNX Software Systems - initial API and implementation
|
||||
*******************************************************************************/
|
||||
package org.eclipse.cdt.internal.ui.wizards.filewizard;
|
||||
|
||||
|
||||
import java.text.MessageFormat;
|
||||
import java.util.MissingResourceException;
|
||||
import java.util.ResourceBundle;
|
||||
|
||||
|
||||
public class NewFileWizardMessages {
|
||||
|
||||
private static final String RESOURCE_BUNDLE= NewFileWizardMessages.class.getName();
|
||||
private static ResourceBundle fgResourceBundle;
|
||||
static {
|
||||
try {
|
||||
fgResourceBundle = ResourceBundle.getBundle(RESOURCE_BUNDLE);
|
||||
} catch (MissingResourceException x) {
|
||||
fgResourceBundle = null;
|
||||
}
|
||||
}
|
||||
|
||||
private NewFileWizardMessages() {
|
||||
}
|
||||
|
||||
public static String getString(String key) {
|
||||
try {
|
||||
return fgResourceBundle.getString(key);
|
||||
} catch (MissingResourceException e) {
|
||||
return '!' + key + '!';
|
||||
} catch (NullPointerException e) {
|
||||
return "#" + key + "#"; //$NON-NLS-1$ //$NON-NLS-2$
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets a string from the resource bundle and formats it with the argument
|
||||
*
|
||||
* @param key the string used to get the bundle value, must not be null
|
||||
*/
|
||||
public static String getFormattedString(String key, Object arg) {
|
||||
return MessageFormat.format(getString(key), new Object[] { arg });
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets a string from the resource bundle and formats it with arguments
|
||||
*/
|
||||
public static String getFormattedString(String key, Object[] args) {
|
||||
return MessageFormat.format(getString(key), args);
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,68 @@
|
|||
###############################################################################
|
||||
# Copyright (c) 2004 QNX Software Systems and others.
|
||||
# All rights reserved. This program and the accompanying materials
|
||||
# are made available under the terms of the Common Public License v1.0
|
||||
# which accompanies this distribution, and is available at
|
||||
# http://www.eclipse.org/legal/cpl-v10.html
|
||||
#
|
||||
# Contributors:
|
||||
# QNX Software Systems - Initial API and implementation
|
||||
###############################################################################
|
||||
|
||||
# ------- AbstractFileCreationWizard -------
|
||||
AbstractFileCreationWizard.title= New File
|
||||
|
||||
# ----------- AbstractFileCreationWizardPage -------------
|
||||
AbstractFileCreationWizardPage.error.SelectedProjectError= Error in determining the selected project.
|
||||
AbstractFileCreationWizardPage.error.DefaultSourceFolderError= Error in determining the default source folder.
|
||||
AbstractFileCreationWizardPage.error.NotAvailableForNonCProjects= The wizard is not available for non C/C++ projects.
|
||||
|
||||
AbstractFileCreationWizardPage.sourceFolder.label=Source &Folder:
|
||||
AbstractFileCreationWizardPage.sourceFolder.button=Br&owse...
|
||||
AbstractFileCreationWizardPage.ChooseSourceFolderDialog.title=Folder Selection
|
||||
AbstractFileCreationWizardPage.ChooseSourceFolderDialog.description=&Choose a source folder:
|
||||
AbstractFileCreationWizardPage.error.EnterSourceFolderName=Source folder name is empty.
|
||||
AbstractFileCreationWizardPage.error.NotAFolder=''{0}'' is not a project or folder.
|
||||
AbstractFileCreationWizardPage.error.NotASourceFolder=Folder ''{0}'' is not a source folder.
|
||||
AbstractFileCreationWizardPage.error.ProjectClosed=Project ''{0}'' must be accessible.
|
||||
NewHeaderFileCreationWizardPagewarning.NotACProject=Folder is not a C/C++ project.
|
||||
AbstractFileCreationWizardPage.warning.NotInACProject=Folder is not in a C/C++ project.
|
||||
|
||||
AbstractFileCreationWizardPage.error.NotAFile=''{0}'' is not a file.
|
||||
AbstractFileCreationWizardPage.error.FolderDoesNotExist=Folder ''{0}'' does not exist.
|
||||
AbstractFileCreationWizardPage.error.SourceFolderRequired=The source folder is required.
|
||||
|
||||
# ------- NewHeaderFileCreationWizard -------
|
||||
NewHeaderFileCreationWizard.title= New Header File
|
||||
|
||||
# ------- NewSourceFileCreationWizard -------
|
||||
NewSourceFileCreationWizard.title= New Source File
|
||||
|
||||
# ----------- NewHeaderFileCreationWizardPage -------------
|
||||
NewHeaderFileCreationWizardPage.title= New Header File
|
||||
NewHeaderFileCreationWizardPage.description= Create a new header file.
|
||||
NewHeaderFileCreationWizardPage.headerFile.label= Header File:
|
||||
NewHeaderFileCreationWizardPage.error.EnterFileName=File name is empty.
|
||||
NewHeaderFileCreationWizardPage.error.FileNotInSourceFolder=File must be inside source folder.
|
||||
NewHeaderFileCreationWizardPage.error.FileExists=File already exists.
|
||||
NewHeaderFileCreationWizardPage.error.MatchingFolderExists=A folder with the same name already exists.
|
||||
NewHeaderFileCreationWizardPage.error.MatchingResourceExists=A resource with the same name already exists.
|
||||
NewHeaderFileCreationWizardPage.warning.FileNameDiscouraged=File name is discouraged. {0}.
|
||||
NewHeaderFileCreationWizardPage.error.InvalidFileName=File name is not valid. {0}.
|
||||
|
||||
# ----------- NewSourceFileCreationWizardPage -------------
|
||||
NewSourceFileCreationWizardPage.title= New Source File
|
||||
NewSourceFileCreationWizardPage.description= Create a new source file.
|
||||
NewSourceFileCreationWizardPage.sourceFile.label= Source File:
|
||||
NewSourceFileCreationWizardPage.error.EnterFileName=File name is empty.
|
||||
NewSourceFileCreationWizardPage.error.FileNotInSourceFolder=File must be inside source folder.
|
||||
NewSourceFileCreationWizardPage.error.FileExists=File already exists.
|
||||
NewSourceFileCreationWizardPage.error.MatchingFolderExists=A folder with the same name already exists.
|
||||
NewSourceFileCreationWizardPage.error.MatchingResourceExists=A resource with the same name already exists.
|
||||
NewSourceFileCreationWizardPage.warning.FileNameDiscouraged=File name is discouraged. {0}.
|
||||
NewSourceFileCreationWizardPage.error.InvalidFileName=File name is not valid. {0}.
|
||||
|
||||
# ----------- NewSourceFileGenerator -------------
|
||||
NewSourceFileGenerator.createFile.task= Creating
|
||||
NewSourceFileGenerator.createFile.mainTask= Creating file....
|
||||
NewSourceFileGenerator.includeGuard.suffix= _H
|
|
@ -0,0 +1,168 @@
|
|||
/*******************************************************************************
|
||||
* Copyright (c) 2004 QNX Software Systems and others.
|
||||
* All rights reserved. This program and the accompanying materials
|
||||
* are made available under the terms of the Common Public License v1.0
|
||||
* which accompanies this distribution, and is available at
|
||||
* http://www.eclipse.org/legal/cpl-v10.html
|
||||
*
|
||||
* Contributors:
|
||||
* QNX Software Systems - initial API and implementation
|
||||
*******************************************************************************/
|
||||
package org.eclipse.cdt.internal.ui.wizards.filewizard;
|
||||
|
||||
import java.io.File;
|
||||
|
||||
import org.eclipse.cdt.core.CConventions;
|
||||
import org.eclipse.cdt.core.browser.PathUtil;
|
||||
import org.eclipse.cdt.core.model.CoreModel;
|
||||
import org.eclipse.cdt.core.model.ITranslationUnit;
|
||||
import org.eclipse.cdt.internal.ui.dialogs.StatusInfo;
|
||||
import org.eclipse.cdt.internal.ui.wizards.dialogfields.DialogField;
|
||||
import org.eclipse.cdt.internal.ui.wizards.dialogfields.IDialogFieldListener;
|
||||
import org.eclipse.cdt.internal.ui.wizards.dialogfields.LayoutUtil;
|
||||
import org.eclipse.cdt.internal.ui.wizards.dialogfields.StringDialogField;
|
||||
import org.eclipse.core.resources.IFile;
|
||||
import org.eclipse.core.runtime.CoreException;
|
||||
import org.eclipse.core.runtime.IPath;
|
||||
import org.eclipse.core.runtime.IProgressMonitor;
|
||||
import org.eclipse.core.runtime.IStatus;
|
||||
import org.eclipse.core.runtime.NullProgressMonitor;
|
||||
import org.eclipse.core.runtime.Path;
|
||||
import org.eclipse.swt.widgets.Composite;
|
||||
import org.eclipse.swt.widgets.Text;
|
||||
|
||||
public class NewHeaderFileCreationWizardPage extends AbstractFileCreationWizardPage {
|
||||
|
||||
private ITranslationUnit fNewFileTU = null;
|
||||
private StringDialogField fNewFileDialogField;
|
||||
|
||||
public NewHeaderFileCreationWizardPage() {
|
||||
super(NewFileWizardMessages.getString("NewHeaderFileCreationWizardPage.title"));
|
||||
setDescription(NewFileWizardMessages.getString("NewHeaderFileCreationWizardPage.description")); //$NON-NLS-1$
|
||||
|
||||
fNewFileDialogField = new StringDialogField();
|
||||
fNewFileDialogField.setDialogFieldListener(new IDialogFieldListener() {
|
||||
public void dialogFieldChanged(DialogField field) {
|
||||
handleFieldChanged(NEW_FILE_ID);
|
||||
}
|
||||
});
|
||||
fNewFileDialogField.setLabelText(NewFileWizardMessages.getString("NewHeaderFileCreationWizardPage.headerFile.label")); //$NON-NLS-1$
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the focus on the starting input field.
|
||||
*/
|
||||
protected void setFocus() {
|
||||
fNewFileDialogField.setFocus();
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates the controls for the file name field. Expects a <code>GridLayout</code> with at
|
||||
* least 3 columns.
|
||||
*
|
||||
* @param composite the parent composite
|
||||
* @param nColumns number of columns to span
|
||||
*/
|
||||
protected void createFileControls(Composite parent, int nColumns) {
|
||||
fNewFileDialogField.doFillIntoGrid(parent, nColumns);
|
||||
Text textControl = fNewFileDialogField.getTextControl(null);
|
||||
LayoutUtil.setWidthHint(textControl, getMaxFieldWidth());
|
||||
textControl.addFocusListener(new StatusFocusListener(NEW_FILE_ID));
|
||||
}
|
||||
|
||||
public IPath getFileFullPath() {
|
||||
String str = fNewFileDialogField.getText();
|
||||
IPath path = null;
|
||||
if (str.length() > 0) {
|
||||
path = new Path(str);
|
||||
if (!path.isAbsolute()) {
|
||||
IPath folderPath = getSourceFolderFullPath();
|
||||
if (folderPath != null)
|
||||
path = folderPath.append(path);
|
||||
}
|
||||
}
|
||||
return path;
|
||||
}
|
||||
|
||||
protected IStatus fileNameChanged() {
|
||||
StatusInfo status = new StatusInfo();
|
||||
|
||||
IPath filePath = getFileFullPath();
|
||||
if (filePath == null) {
|
||||
status.setError(NewFileWizardMessages.getString("NewHeaderFileCreationWizardPage.error.EnterFileName")); //$NON-NLS-1$
|
||||
return status;
|
||||
}
|
||||
|
||||
// check if file already exists
|
||||
IPath workspacePath = getWorkspaceRoot().getLocation();
|
||||
File file = workspacePath.append(filePath).toFile();
|
||||
// if (file == null || !file.exists()) {
|
||||
// IResource res = fWorkspaceRoot.findMember(path);
|
||||
// if (res != null && res.exists()) {
|
||||
// file = res.getLocation().toFile();
|
||||
// }
|
||||
// }
|
||||
if (file != null && file.exists()) {
|
||||
if (file.isFile()) {
|
||||
status.setError(NewFileWizardMessages.getString("NewHeaderFileCreationWizardPage.error.FileExists")); //$NON-NLS-1$
|
||||
} else if (file.isDirectory()) {
|
||||
status.setError(NewFileWizardMessages.getString("NewHeaderFileCreationWizardPage.error.MatchingFolderExists")); //$NON-NLS-1$
|
||||
} else {
|
||||
status.setError(NewFileWizardMessages.getString("NewHeaderFileCreationWizardPage.error.MatchingResourceExists")); //$NON-NLS-1$
|
||||
}
|
||||
return status;
|
||||
} else if (filePath.segmentCount() > 1) {
|
||||
IPath parentFolderPath = workspacePath.append(filePath).removeLastSegments(1);
|
||||
File folder = parentFolderPath.toFile();
|
||||
if (folder != null && folder.exists() && folder.isDirectory()) {
|
||||
// folder exists
|
||||
} else {
|
||||
status.setError(NewFileWizardMessages.getFormattedString("NewHeaderFileCreationWizardPage.error.FolderDoesNotExist", PathUtil.getWorkspaceRelativePath(parentFolderPath))); //$NON-NLS-1$
|
||||
return status;
|
||||
}
|
||||
}
|
||||
|
||||
// make sure file is inside source folder
|
||||
IPath folderPath = getSourceFolderFullPath();
|
||||
if (folderPath != null && !folderPath.isPrefixOf(filePath)) {
|
||||
status.setError(NewFileWizardMessages.getString("NewHeaderFileCreationWizardPage.error.FileNotInSourceFolder")); //$NON-NLS-1$
|
||||
return status;
|
||||
}
|
||||
|
||||
IStatus convStatus = CConventions.validateHeaderFileName(getCurrentProject(), filePath.lastSegment());
|
||||
if (convStatus.getSeverity() == IStatus.ERROR) {
|
||||
status.setError(NewFileWizardMessages.getFormattedString("NewHeaderFileCreationWizardPage.error.InvalidFileName", convStatus.getMessage())); //$NON-NLS-1$
|
||||
return status;
|
||||
} else if (convStatus.getSeverity() == IStatus.WARNING) {
|
||||
status.setWarning(NewFileWizardMessages.getFormattedString("NewHeaderFileCreationWizardPage.warning.FileNameDiscouraged", convStatus.getMessage())); //$NON-NLS-1$
|
||||
}
|
||||
return status;
|
||||
}
|
||||
|
||||
public void createFile(IProgressMonitor monitor) {
|
||||
IPath filePath = getFileFullPath();
|
||||
if (filePath != null) {
|
||||
if (monitor == null)
|
||||
monitor = new NullProgressMonitor();
|
||||
try {
|
||||
fNewFileTU = null;
|
||||
IFile newFile = NewSourceFileGenerator.createHeaderFile(filePath, true, monitor);
|
||||
if (newFile != null) {
|
||||
fNewFileTU = (ITranslationUnit) CoreModel.getDefault().create(newFile);
|
||||
}
|
||||
} catch (CoreException e) {
|
||||
// TODO Auto-generated catch block
|
||||
e.printStackTrace();
|
||||
} finally {
|
||||
monitor.done();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.eclipse.cdt.internal.ui.wizards.filewizard.AbstractFileCreationWizardPage#getCreatedFileTU()
|
||||
*/
|
||||
public ITranslationUnit getCreatedFileTU() {
|
||||
return fNewFileTU;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,167 @@
|
|||
/*******************************************************************************
|
||||
* Copyright (c) 2004 QNX Software Systems and others.
|
||||
* All rights reserved. This program and the accompanying materials
|
||||
* are made available under the terms of the Common Public License v1.0
|
||||
* which accompanies this distribution, and is available at
|
||||
* http://www.eclipse.org/legal/cpl-v10.html
|
||||
*
|
||||
* Contributors:
|
||||
* QNX Software Systems - initial API and implementation
|
||||
*******************************************************************************/
|
||||
package org.eclipse.cdt.internal.ui.wizards.filewizard;
|
||||
|
||||
import java.io.File;
|
||||
|
||||
import org.eclipse.cdt.core.CConventions;
|
||||
import org.eclipse.cdt.core.browser.PathUtil;
|
||||
import org.eclipse.cdt.core.model.CoreModel;
|
||||
import org.eclipse.cdt.core.model.ITranslationUnit;
|
||||
import org.eclipse.cdt.internal.ui.dialogs.StatusInfo;
|
||||
import org.eclipse.cdt.internal.ui.wizards.dialogfields.DialogField;
|
||||
import org.eclipse.cdt.internal.ui.wizards.dialogfields.IDialogFieldListener;
|
||||
import org.eclipse.cdt.internal.ui.wizards.dialogfields.LayoutUtil;
|
||||
import org.eclipse.cdt.internal.ui.wizards.dialogfields.StringDialogField;
|
||||
import org.eclipse.core.resources.IFile;
|
||||
import org.eclipse.core.runtime.CoreException;
|
||||
import org.eclipse.core.runtime.IPath;
|
||||
import org.eclipse.core.runtime.IProgressMonitor;
|
||||
import org.eclipse.core.runtime.IStatus;
|
||||
import org.eclipse.core.runtime.NullProgressMonitor;
|
||||
import org.eclipse.core.runtime.Path;
|
||||
import org.eclipse.swt.widgets.Composite;
|
||||
import org.eclipse.swt.widgets.Text;
|
||||
|
||||
public class NewSourceFileCreationWizardPage extends AbstractFileCreationWizardPage {
|
||||
private ITranslationUnit fNewFileTU = null;
|
||||
private StringDialogField fNewFileDialogField;
|
||||
|
||||
public NewSourceFileCreationWizardPage() {
|
||||
super(NewFileWizardMessages.getString("NewSourceFileCreationWizardPage.title"));
|
||||
setDescription(NewFileWizardMessages.getString("NewSourceFileCreationWizardPage.description")); //$NON-NLS-1$
|
||||
|
||||
fNewFileDialogField = new StringDialogField();
|
||||
fNewFileDialogField.setDialogFieldListener(new IDialogFieldListener() {
|
||||
public void dialogFieldChanged(DialogField field) {
|
||||
handleFieldChanged(NEW_FILE_ID);
|
||||
}
|
||||
});
|
||||
fNewFileDialogField.setLabelText(NewFileWizardMessages.getString("NewSourceFileCreationWizardPage.sourceFile.label")); //$NON-NLS-1$
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the focus on the starting input field.
|
||||
*/
|
||||
protected void setFocus() {
|
||||
fNewFileDialogField.setFocus();
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates the controls for the file name field. Expects a <code>GridLayout</code> with at
|
||||
* least 3 columns.
|
||||
*
|
||||
* @param composite the parent composite
|
||||
* @param nColumns number of columns to span
|
||||
*/
|
||||
protected void createFileControls(Composite parent, int nColumns) {
|
||||
fNewFileDialogField.doFillIntoGrid(parent, nColumns);
|
||||
Text textControl = fNewFileDialogField.getTextControl(null);
|
||||
LayoutUtil.setWidthHint(textControl, getMaxFieldWidth());
|
||||
textControl.addFocusListener(new StatusFocusListener(NEW_FILE_ID));
|
||||
}
|
||||
|
||||
public IPath getFileFullPath() {
|
||||
String str = fNewFileDialogField.getText();
|
||||
IPath path = null;
|
||||
if (str.length() > 0) {
|
||||
path = new Path(str);
|
||||
if (!path.isAbsolute()) {
|
||||
IPath folderPath = getSourceFolderFullPath();
|
||||
if (folderPath != null)
|
||||
path = folderPath.append(path);
|
||||
}
|
||||
}
|
||||
return path;
|
||||
}
|
||||
|
||||
protected IStatus fileNameChanged() {
|
||||
StatusInfo status = new StatusInfo();
|
||||
|
||||
IPath filePath = getFileFullPath();
|
||||
if (filePath == null) {
|
||||
status.setError(NewFileWizardMessages.getString("NewSourceFileCreationWizardPage.error.EnterFileName")); //$NON-NLS-1$
|
||||
return status;
|
||||
}
|
||||
|
||||
// check if file already exists
|
||||
IPath workspacePath = getWorkspaceRoot().getLocation();
|
||||
File file = workspacePath.append(filePath).toFile();
|
||||
// if (file == null || !file.exists()) {
|
||||
// IResource res = fWorkspaceRoot.findMember(path);
|
||||
// if (res != null && res.exists()) {
|
||||
// file = res.getLocation().toFile();
|
||||
// }
|
||||
// }
|
||||
if (file != null && file.exists()) {
|
||||
if (file.isFile()) {
|
||||
status.setError(NewFileWizardMessages.getString("NewSourceFileCreationWizardPage.error.FileExists")); //$NON-NLS-1$
|
||||
} else if (file.isDirectory()) {
|
||||
status.setError(NewFileWizardMessages.getString("NewSourceFileCreationWizardPage.error.MatchingFolderExists")); //$NON-NLS-1$
|
||||
} else {
|
||||
status.setError(NewFileWizardMessages.getString("NewSourceFileCreationWizardPage.error.MatchingResourceExists")); //$NON-NLS-1$
|
||||
}
|
||||
return status;
|
||||
} else if (filePath.segmentCount() > 1) {
|
||||
IPath parentFolderPath = workspacePath.append(filePath).removeLastSegments(1);
|
||||
File folder = parentFolderPath.toFile();
|
||||
if (folder != null && folder.exists() && folder.isDirectory()) {
|
||||
// folder exists
|
||||
} else {
|
||||
status.setError(NewFileWizardMessages.getFormattedString("NewSourceFileCreationWizardPage.error.FolderDoesNotExist", PathUtil.getWorkspaceRelativePath(parentFolderPath))); //$NON-NLS-1$
|
||||
return status;
|
||||
}
|
||||
}
|
||||
|
||||
// make sure file is inside source folder
|
||||
IPath folderPath = getSourceFolderFullPath();
|
||||
if (folderPath != null && !folderPath.isPrefixOf(filePath)) {
|
||||
status.setError(NewFileWizardMessages.getString("NewSourceFileCreationWizardPage.error.FileNotInSourceFolder")); //$NON-NLS-1$
|
||||
return status;
|
||||
}
|
||||
|
||||
IStatus convStatus = CConventions.validateSourceFileName(getCurrentProject(), filePath.lastSegment());
|
||||
if (convStatus.getSeverity() == IStatus.ERROR) {
|
||||
status.setError(NewFileWizardMessages.getFormattedString("NewSourceFileCreationWizardPage.error.InvalidFileName", convStatus.getMessage())); //$NON-NLS-1$
|
||||
return status;
|
||||
} else if (convStatus.getSeverity() == IStatus.WARNING) {
|
||||
status.setWarning(NewFileWizardMessages.getFormattedString("NewSourceFileCreationWizardPage.warning.FileNameDiscouraged", convStatus.getMessage())); //$NON-NLS-1$
|
||||
}
|
||||
return status;
|
||||
}
|
||||
|
||||
public void createFile(IProgressMonitor monitor) {
|
||||
IPath filePath = getFileFullPath();
|
||||
if (filePath != null) {
|
||||
if (monitor == null)
|
||||
monitor = new NullProgressMonitor();
|
||||
try {
|
||||
fNewFileTU = null;
|
||||
IFile newFile = NewSourceFileGenerator.createSourceFile(filePath, true, monitor);
|
||||
if (newFile != null) {
|
||||
fNewFileTU = (ITranslationUnit) CoreModel.getDefault().create(newFile);
|
||||
}
|
||||
} catch (CoreException e) {
|
||||
// TODO Auto-generated catch block
|
||||
e.printStackTrace();
|
||||
} finally {
|
||||
monitor.done();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.eclipse.cdt.internal.ui.wizards.filewizard.AbstractFileCreationWizardPage#getCreatedFileTU()
|
||||
*/
|
||||
public ITranslationUnit getCreatedFileTU() {
|
||||
return fNewFileTU;
|
||||
}
|
||||
}
|
|
@ -8,7 +8,7 @@
|
|||
* Contributors:
|
||||
* QNX Software Systems - initial API and implementation
|
||||
*******************************************************************************/
|
||||
package org.eclipse.cdt.internal.ui.wizards.classwizard;
|
||||
package org.eclipse.cdt.internal.ui.wizards.filewizard;
|
||||
|
||||
import java.io.ByteArrayInputStream;
|
||||
import java.io.InputStream;
|
||||
|
@ -94,7 +94,7 @@ public class NewSourceFileGenerator {
|
|||
return null;
|
||||
}
|
||||
|
||||
public static IFile createSourceFile(IPath filePath, boolean useIncludeGuard, boolean force, IProgressMonitor monitor) throws CoreException {
|
||||
public static IFile createSourceFile(IPath filePath, boolean force, IProgressMonitor monitor) throws CoreException {
|
||||
//TODO should use code templates
|
||||
ByteArrayInputStream stream = new ByteArrayInputStream(new byte[0]);
|
||||
return createNewFile(filePath, stream, force, monitor);
|
||||
|
@ -104,7 +104,7 @@ public class NewSourceFileGenerator {
|
|||
int totalWork = 100;
|
||||
int createFileWork = totalWork;
|
||||
|
||||
monitor.beginTask(NewClassWizardMessages.getString("NewClassCodeGeneration.createFile.task"), totalWork); //$NON-NLS-1$
|
||||
monitor.beginTask(NewFileWizardMessages.getString("NewSourceFileGenerator.createFile.task"), totalWork); //$NON-NLS-1$
|
||||
|
||||
IWorkspaceRoot root = CUIPlugin.getWorkspace().getRoot();
|
||||
IFile newFile = root.getFileForLocation(newFilePath);
|
|
@ -36,6 +36,7 @@ import org.eclipse.ui.wizards.newresource.BasicNewResourceWizard;
|
|||
/**
|
||||
* description for "NewClassWizard".
|
||||
* @see Wizard
|
||||
* @deprecated use NewClassCreationWizard instead
|
||||
*/
|
||||
public class NewClassWizard extends BasicNewResourceWizard implements INewWizard {
|
||||
private NewClassWizardPage fPage;
|
||||
|
|
|
@ -26,8 +26,8 @@ import org.eclipse.cdt.core.browser.ITypeInfo;
|
|||
import org.eclipse.cdt.core.browser.ITypeReference;
|
||||
import org.eclipse.cdt.core.browser.ITypeSearchScope;
|
||||
import org.eclipse.cdt.core.browser.QualifiedTypeName;
|
||||
import org.eclipse.cdt.core.browser.UnknownTypeInfo;
|
||||
import org.eclipse.cdt.core.browser.TypeSearchScope;
|
||||
import org.eclipse.cdt.core.browser.UnknownTypeInfo;
|
||||
import org.eclipse.cdt.core.model.CModelException;
|
||||
import org.eclipse.cdt.core.model.CoreModel;
|
||||
import org.eclipse.cdt.core.model.ICElement;
|
||||
|
@ -48,9 +48,9 @@ import org.eclipse.cdt.internal.ui.wizards.dialogfields.LayoutUtil;
|
|||
import org.eclipse.cdt.internal.ui.wizards.dialogfields.LinkToFileGroup;
|
||||
import org.eclipse.cdt.internal.ui.wizards.dialogfields.ListDialogField;
|
||||
import org.eclipse.cdt.internal.ui.wizards.dialogfields.SelectionButtonDialogFieldGroup;
|
||||
import org.eclipse.cdt.internal.ui.wizards.dialogfields.StringDialogField;
|
||||
import org.eclipse.cdt.internal.ui.wizards.dialogfields.StringButtonDialogField;
|
||||
import org.eclipse.cdt.internal.ui.wizards.dialogfields.Separator;
|
||||
import org.eclipse.cdt.internal.ui.wizards.dialogfields.StringButtonDialogField;
|
||||
import org.eclipse.cdt.internal.ui.wizards.dialogfields.StringDialogField;
|
||||
import org.eclipse.cdt.ui.CUIPlugin;
|
||||
import org.eclipse.cdt.ui.CodeGeneration;
|
||||
import org.eclipse.cdt.ui.PreferenceConstants;
|
||||
|
@ -84,7 +84,6 @@ import org.eclipse.swt.widgets.Event;
|
|||
import org.eclipse.swt.widgets.Listener;
|
||||
import org.eclipse.ui.actions.WorkspaceModifyOperation;
|
||||
import org.eclipse.ui.dialogs.ContainerGenerator;
|
||||
import org.eclipse.ui.internal.WorkbenchPlugin;
|
||||
|
||||
/**
|
||||
* Wizard page to create a new class.
|
||||
|
@ -93,8 +92,8 @@ import org.eclipse.ui.internal.WorkbenchPlugin;
|
|||
* a new class wizard page, extend <code>NewTypeWizardPage</code>.
|
||||
* </p>
|
||||
*
|
||||
* @deprecated use NewClassCreationWizardPage instead
|
||||
*/
|
||||
|
||||
public class NewClassWizardPage extends WizardPage implements Listener {
|
||||
// the page name
|
||||
private final static String PAGE_NAME= "NewClassWizardPage"; //$NON-NLS-1$
|
||||
|
@ -646,7 +645,7 @@ public class NewClassWizardPage extends WizardPage implements Listener {
|
|||
monitor= new NullProgressMonitor();
|
||||
}
|
||||
|
||||
monitor.beginTask(NewWizardMessages.getString("NewTypeWizardPage.operationdesc"), 10); //$NON-NLS-1$
|
||||
monitor.beginTask(NewWizardMessages.getString("NewClassWizardPage.operationdesc"), 10); //$NON-NLS-1$
|
||||
|
||||
// resolve location of base class
|
||||
String baseClassName = getBaseClassName();
|
||||
|
|
|
@ -0,0 +1,16 @@
|
|||
/*******************************************************************************
|
||||
* Copyright (c) 2004 QNX Software Systems and others.
|
||||
* All rights reserved. This program and the accompanying materials
|
||||
* are made available under the terms of the Common Public License v1.0
|
||||
* which accompanies this distribution, and is available at
|
||||
* http://www.eclipse.org/legal/cpl-v10.html
|
||||
*
|
||||
* Contributors:
|
||||
* QNX Software Systems - initial API and implementation
|
||||
*******************************************************************************/
|
||||
package org.eclipse.cdt.ui.wizards;
|
||||
|
||||
import org.eclipse.ui.wizards.newresource.BasicNewFileResourceWizard;
|
||||
|
||||
public class NewFileCreationWizard extends BasicNewFileResourceWizard {
|
||||
}
|
|
@ -0,0 +1,37 @@
|
|||
/*******************************************************************************
|
||||
* Copyright (c) 2004 QNX Software Systems and others.
|
||||
* All rights reserved. This program and the accompanying materials
|
||||
* are made available under the terms of the Common Public License v1.0
|
||||
* which accompanies this distribution, and is available at
|
||||
* http://www.eclipse.org/legal/cpl-v10.html
|
||||
*
|
||||
* Contributors:
|
||||
* QNX Software Systems - initial API and implementation
|
||||
*******************************************************************************/
|
||||
package org.eclipse.cdt.ui.wizards;
|
||||
|
||||
import org.eclipse.cdt.internal.ui.CPluginImages;
|
||||
import org.eclipse.cdt.internal.ui.wizards.filewizard.AbstractFileCreationWizard;
|
||||
import org.eclipse.cdt.internal.ui.wizards.filewizard.NewFileWizardMessages;
|
||||
import org.eclipse.cdt.internal.ui.wizards.filewizard.NewHeaderFileCreationWizardPage;
|
||||
import org.eclipse.cdt.ui.CUIPlugin;
|
||||
|
||||
public class NewHeaderFileCreationWizard extends AbstractFileCreationWizard {
|
||||
|
||||
public NewHeaderFileCreationWizard() {
|
||||
super();
|
||||
setDefaultPageImageDescriptor(CPluginImages.DESC_WIZBAN_NEW_HEADERFILE);
|
||||
setDialogSettings(CUIPlugin.getDefault().getDialogSettings());
|
||||
setWindowTitle(NewFileWizardMessages.getString("NewHeaderFileCreationWizard.title")); //$NON-NLS-1$
|
||||
}
|
||||
|
||||
/*
|
||||
* @see Wizard#createPages
|
||||
*/
|
||||
public void addPages() {
|
||||
super.addPages();
|
||||
fPage = new NewHeaderFileCreationWizardPage();
|
||||
addPage(fPage);
|
||||
fPage.init(getSelection());
|
||||
}
|
||||
}
|
|
@ -0,0 +1,37 @@
|
|||
/*******************************************************************************
|
||||
* Copyright (c) 2004 QNX Software Systems and others.
|
||||
* All rights reserved. This program and the accompanying materials
|
||||
* are made available under the terms of the Common Public License v1.0
|
||||
* which accompanies this distribution, and is available at
|
||||
* http://www.eclipse.org/legal/cpl-v10.html
|
||||
*
|
||||
* Contributors:
|
||||
* QNX Software Systems - initial API and implementation
|
||||
*******************************************************************************/
|
||||
package org.eclipse.cdt.ui.wizards;
|
||||
|
||||
import org.eclipse.cdt.internal.ui.CPluginImages;
|
||||
import org.eclipse.cdt.internal.ui.wizards.filewizard.AbstractFileCreationWizard;
|
||||
import org.eclipse.cdt.internal.ui.wizards.filewizard.NewFileWizardMessages;
|
||||
import org.eclipse.cdt.internal.ui.wizards.filewizard.NewSourceFileCreationWizardPage;
|
||||
import org.eclipse.cdt.ui.CUIPlugin;
|
||||
|
||||
public class NewSourceFileCreationWizard extends AbstractFileCreationWizard {
|
||||
|
||||
public NewSourceFileCreationWizard() {
|
||||
super();
|
||||
setDefaultPageImageDescriptor(CPluginImages.DESC_WIZBAN_NEW_SOURCEFILE);
|
||||
setDialogSettings(CUIPlugin.getDefault().getDialogSettings());
|
||||
setWindowTitle(NewFileWizardMessages.getString("NewSourceFileCreationWizard.title")); //$NON-NLS-1$
|
||||
}
|
||||
|
||||
/*
|
||||
* @see Wizard#createPages
|
||||
*/
|
||||
public void addPages() {
|
||||
super.addPages();
|
||||
fPage = new NewSourceFileCreationWizardPage();
|
||||
addPage(fPage);
|
||||
fPage.init(getSelection());
|
||||
}
|
||||
}
|