1
0
Fork 0
mirror of https://github.com/eclipse-cdt/cdt synced 2025-04-23 14:42:11 +02:00

2004-07-24 Chris Wiebe

Major clean up patch on the wizards.
	New button to access them.
This commit is contained in:
Alain Magloire 2004-07-26 20:52:26 +00:00
parent 75b012b2ec
commit b4270454a9
30 changed files with 525 additions and 67 deletions

View file

@ -1,3 +1,8 @@
2004-07-24 Chris Wiebe
Major clean up patch on the wizards.
New button to access them.
2004-07-23 Alain Magloire 2004-07-23 Alain Magloire
Support for addInclude action, implementation base Support for addInclude action, implementation base

View file

@ -50,7 +50,7 @@ public class CBrowsingPerspectiveFactory implements IPerspectiveFactory {
folder3.addView(IPageLayout.ID_OUTLINE); folder3.addView(IPageLayout.ID_OUTLINE);
layout.addActionSet(CUIPlugin.SEARCH_ACTION_SET_ID); layout.addActionSet(CUIPlugin.SEARCH_ACTION_SET_ID);
layout.addActionSet(CUIPlugin.FOLDER_ACTION_SET_ID); layout.addActionSet(CUIPlugin.ID_CELEMENT_CREATION_ACTION_SET);
// views - build console // views - build console
layout.addShowViewShortcut(IConsoleConstants.ID_CONSOLE_VIEW); layout.addShowViewShortcut(IConsoleConstants.ID_CONSOLE_VIEW);
@ -70,9 +70,13 @@ public class CBrowsingPerspectiveFactory implements IPerspectiveFactory {
layout.addShowInPart(IPageLayout.ID_RES_NAV); layout.addShowInPart(IPageLayout.ID_RES_NAV);
// new actions - C project creation wizard // new actions - C project creation wizard
String[] wizIDs = CUIPlugin.getCProjectWizardIDs();
for (int i = 0; i < wizIDs.length; ++i) {
layout.addNewWizardShortcut(wizIDs[i]);
}
layout.addNewWizardShortcut(CUIPlugin.CLASS_WIZARD_ID); layout.addNewWizardShortcut(CUIPlugin.CLASS_WIZARD_ID);
layout.addNewWizardShortcut(CUIPlugin.FILE_WIZARD_ID);
layout.addNewWizardShortcut(CUIPlugin.FOLDER_WIZARD_ID); layout.addNewWizardShortcut(CUIPlugin.FOLDER_WIZARD_ID);
layout.addNewWizardShortcut(CUIPlugin.FILE_WIZARD_ID);
} }
public void createInitialLayout(IPageLayout layout) { public void createInitialLayout(IPageLayout layout) {
@ -83,14 +87,13 @@ public class CBrowsingPerspectiveFactory implements IPerspectiveFactory {
// action sets // action sets
layout.addActionSet(CUIPlugin.SEARCH_ACTION_SET_ID); layout.addActionSet(CUIPlugin.SEARCH_ACTION_SET_ID);
layout.addActionSet(CUIPlugin.FOLDER_ACTION_SET_ID);
// layout.addActionSet(IDebugUIConstants.LAUNCH_ACTION_SET); // layout.addActionSet(IDebugUIConstants.LAUNCH_ACTION_SET);
// layout.addActionSet(JavaUI.ID_ACTION_SET); // layout.addActionSet(JavaUI.ID_ACTION_SET);
// layout.addActionSet(JavaUI.ID_ELEMENT_CREATION_ACTION_SET); layout.addActionSet(CUIPlugin.ID_CELEMENT_CREATION_ACTION_SET);
layout.addActionSet(IPageLayout.ID_NAVIGATE_ACTION_SET); layout.addActionSet(IPageLayout.ID_NAVIGATE_ACTION_SET);
// views - java // views - java
// layout.addShowViewShortcut(CUIPlugin.ID_TYPE_HIERARCHY); layout.addShowViewShortcut(CUIPlugin.ID_TYPE_HIERARCHY);
layout.addShowViewShortcut(CUIPlugin.CVIEW_ID); layout.addShowViewShortcut(CUIPlugin.CVIEW_ID);
layout.addShowViewShortcut(CUIPlugin.ID_PROJECTS_VIEW); layout.addShowViewShortcut(CUIPlugin.ID_PROJECTS_VIEW);
layout.addShowViewShortcut(CUIPlugin.ID_NAMESPACES_VIEW); layout.addShowViewShortcut(CUIPlugin.ID_NAMESPACES_VIEW);
@ -111,9 +114,13 @@ public class CBrowsingPerspectiveFactory implements IPerspectiveFactory {
layout.addShowViewShortcut(IPageLayout.ID_RES_NAV); layout.addShowViewShortcut(IPageLayout.ID_RES_NAV);
// new actions - C project creation wizard // new actions - C project creation wizard
String[] wizIDs = CUIPlugin.getCProjectWizardIDs();
for (int i = 0; i < wizIDs.length; ++i) {
layout.addNewWizardShortcut(wizIDs[i]);
}
layout.addNewWizardShortcut(CUIPlugin.CLASS_WIZARD_ID); layout.addNewWizardShortcut(CUIPlugin.CLASS_WIZARD_ID);
layout.addNewWizardShortcut(CUIPlugin.FILE_WIZARD_ID);
layout.addNewWizardShortcut(CUIPlugin.FOLDER_WIZARD_ID); layout.addNewWizardShortcut(CUIPlugin.FOLDER_WIZARD_ID);
layout.addNewWizardShortcut(CUIPlugin.FILE_WIZARD_ID);
} }
private void createVerticalLayout(IPageLayout layout) { private void createVerticalLayout(IPageLayout layout) {
@ -121,7 +128,7 @@ public class CBrowsingPerspectiveFactory implements IPerspectiveFactory {
int relativePos= IPageLayout.LEFT; int relativePos= IPageLayout.LEFT;
IPlaceholderFolderLayout placeHolderLeft= layout.createPlaceholderFolder("left", IPageLayout.LEFT, (float)0.25, IPageLayout.ID_EDITOR_AREA); //$NON-NLS-1$ IPlaceholderFolderLayout placeHolderLeft= layout.createPlaceholderFolder("left", IPageLayout.LEFT, (float)0.25, IPageLayout.ID_EDITOR_AREA); //$NON-NLS-1$
// placeHolderLeft.addPlaceholder(JavaUI.ID_TYPE_HIERARCHY); placeHolderLeft.addPlaceholder(CUIPlugin.ID_TYPE_HIERARCHY);
placeHolderLeft.addPlaceholder(IPageLayout.ID_OUTLINE); placeHolderLeft.addPlaceholder(IPageLayout.ID_OUTLINE);
placeHolderLeft.addPlaceholder(CUIPlugin.CVIEW_ID); placeHolderLeft.addPlaceholder(CUIPlugin.CVIEW_ID);
placeHolderLeft.addPlaceholder(IPageLayout.ID_RES_NAV); placeHolderLeft.addPlaceholder(IPageLayout.ID_RES_NAV);
@ -166,7 +173,7 @@ public class CBrowsingPerspectiveFactory implements IPerspectiveFactory {
layout.addView(CUIPlugin.ID_MEMBERS_VIEW, IPageLayout.RIGHT, (float)0.50, CUIPlugin.ID_TYPES_VIEW); layout.addView(CUIPlugin.ID_MEMBERS_VIEW, IPageLayout.RIGHT, (float)0.50, CUIPlugin.ID_TYPES_VIEW);
IPlaceholderFolderLayout placeHolderLeft= layout.createPlaceholderFolder("left", IPageLayout.LEFT, (float)0.25, IPageLayout.ID_EDITOR_AREA); //$NON-NLS-1$ IPlaceholderFolderLayout placeHolderLeft= layout.createPlaceholderFolder("left", IPageLayout.LEFT, (float)0.25, IPageLayout.ID_EDITOR_AREA); //$NON-NLS-1$
// placeHolderLeft.addPlaceholder(JavaUI.ID_TYPE_HIERARCHY); placeHolderLeft.addPlaceholder(CUIPlugin.ID_TYPE_HIERARCHY);
placeHolderLeft.addPlaceholder(IPageLayout.ID_OUTLINE); placeHolderLeft.addPlaceholder(IPageLayout.ID_OUTLINE);
placeHolderLeft.addPlaceholder(CUIPlugin.CVIEW_ID); placeHolderLeft.addPlaceholder(CUIPlugin.CVIEW_ID);
placeHolderLeft.addPlaceholder(IPageLayout.ID_RES_NAV); placeHolderLeft.addPlaceholder(IPageLayout.ID_RES_NAV);

Binary file not shown.

Before

Width:  |  Height:  |  Size: 238 B

After

Width:  |  Height:  |  Size: 598 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 360 B

After

Width:  |  Height:  |  Size: 185 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 227 B

After

Width:  |  Height:  |  Size: 353 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 182 B

After

Width:  |  Height:  |  Size: 349 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 104 B

After

Width:  |  Height:  |  Size: 571 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 104 B

After

Width:  |  Height:  |  Size: 188 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 104 B

After

Width:  |  Height:  |  Size: 219 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 221 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 143 B

After

Width:  |  Height:  |  Size: 598 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 183 B

After

Width:  |  Height:  |  Size: 185 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 173 B

After

Width:  |  Height:  |  Size: 353 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 349 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 2.3 KiB

After

Width:  |  Height:  |  Size: 3.2 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 3.1 KiB

After

Width:  |  Height:  |  Size: 2.8 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.9 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.8 KiB

View file

@ -41,11 +41,21 @@ NewWizards.file.description = Create a new file resource
NewWizards.class = Class NewWizards.class = Class
NewWizards.class.description = Create a new C++ class NewWizards.class.description = Create a new C++ class
OpenNewFileWizardAction.label=&File OpenNewFileWizardAction.label=&File
OpenNewFileWizardAction.tooltip=Create a file OpenNewFileWizardAction.tooltip=New File
OpenNewFolderWizardAction.label=&Folder OpenNewFolderWizardAction.label=&Folder
OpenNewFolderWizardAction.tooltip=Create a folder OpenNewFolderWizardAction.tooltip=New Folder
OpenClassWizardAction.label=&Class OpenClassWizardAction.label=&Class...
OpenClassWizardAction.tooltip=Create a new C++ 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
# Editor # Editor

View file

@ -294,9 +294,11 @@
name="%NewWizards.class" name="%NewWizards.class"
icon="icons/full/ctool16/newclass_wiz.gif" icon="icons/full/ctool16/newclass_wiz.gif"
category="org.eclipse.cdt.ui.newCCWizards" category="org.eclipse.cdt.ui.newCCWizards"
class="org.eclipse.cdt.ui.wizards.NewClassWizard"
finalPerspective="org.eclipse.cdt.ui.CPerspective" finalPerspective="org.eclipse.cdt.ui.CPerspective"
id="org.eclipse.cdt.ui.wizards.NewClassWizard"> id="org.eclipse.cdt.ui.wizards.NewClassWizard">
<class class="org.eclipse.cdt.ui.wizards.NewClassWizard">
<parameter name="ctype" value="true"/>
</class>
<description> <description>
%NewWizards.class.description %NewWizards.class.description
</description> </description>
@ -498,16 +500,26 @@
<extension <extension
point="org.eclipse.ui.actionSets"> point="org.eclipse.ui.actionSets">
<actionSet <actionSet
label="%CFolderActionSet.label" label="%CElementCreationActionSet.label"
description="%CFolderActionSet.description" description="%CElementCreationActionSet.description"
visible="false" visible="false"
id="org.eclipse.cdt.ui.CFolderActionSet"> id="org.eclipse.cdt.ui.CElementCreationActionSet">
<action
id="org.eclipse.cdt.ui.actions.NewTypeDropDown"
toolbarPath="Normal/CCWizards"
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"
pulldown="true"
tooltip="%OpenClassWizardAction.tooltip">
</action>
<action <action
label="%OpenNewFileWizardAction.label" label="%OpenNewFileWizardAction.label"
icon="icons/full/ctool16/newfile_wiz.gif" icon="icons/full/ctool16/newfile_wiz.gif"
class="org.eclipse.cdt.internal.ui.wizards.OpenNewFileWizardAction" class="org.eclipse.cdt.internal.ui.wizards.OpenNewFileWizardAction"
tooltip="%OpenNewFileWizardAction.tooltip" tooltip="%OpenNewFileWizardAction.tooltip"
toolbarPath="Normal/FolderWizards" toolbarPath="Normal/CCWizards"
id="org.eclipse.cdt.ui.actions.OpenNewFileWizardAction"> id="org.eclipse.cdt.ui.actions.OpenNewFileWizardAction">
</action> </action>
<action <action
@ -515,22 +527,18 @@
icon="icons/full/ctool16/newfolder_wiz.gif" icon="icons/full/ctool16/newfolder_wiz.gif"
class="org.eclipse.cdt.internal.ui.wizards.OpenNewFolderWizardAction" class="org.eclipse.cdt.internal.ui.wizards.OpenNewFolderWizardAction"
tooltip="%OpenNewFolderWizardAction.tooltip" tooltip="%OpenNewFolderWizardAction.tooltip"
toolbarPath="Normal/FolderWizards" toolbarPath="Normal/CCWizards"
id="org.eclipse.cdt.ui.actions.OpenNewFolderWizardAction"> id="org.eclipse.cdt.ui.actions.OpenNewFolderWizardAction">
</action> </action>
<action <action
label="%OpenClassWizardAction.label" id="org.eclipse.cdt.ui.actions.NewProjectDropDown"
icon="icons/full/ctool16/newclass_wiz.gif" toolbarPath="Normal/CCWizards"
class="org.eclipse.cdt.ui.actions.OpenClassWizardAction" class="org.eclipse.cdt.internal.ui.wizards.NewProjectDropDownAction"
tooltip="%OpenClassWizardAction.tooltip" disabledIcon="icons/full/dtool16/newcprj_wiz.gif"
toolbarPath="Normal/FolderWizards" icon="icons/full/etool16/newcprj_wiz.gif"
id="org.eclipse.cdt.ui.actions.OpenClassWizardAction"> label="%OpenProjectWizardAction.label"
<enablement> pulldown="true"
<objectState tooltip="%OpenProjectWizardAction.tooltip">
name="projectNature"
value="org.eclipse.cdt.core.ccnature">
</objectState>
</enablement>
</action> </action>
</actionSet> </actionSet>
</extension> </extension>

View file

@ -5,7 +5,8 @@ package org.eclipse.cdt.internal.ui;
* All Rights Reserved. * All Rights Reserved.
*/ */
import org.eclipse.cdt.ui.*; import org.eclipse.cdt.ui.CUIPlugin;
import org.eclipse.cdt.ui.wizards.NewCProjectWizard;
import org.eclipse.search.ui.SearchUI; import org.eclipse.search.ui.SearchUI;
import org.eclipse.ui.IFolderLayout; import org.eclipse.ui.IFolderLayout;
import org.eclipse.ui.IPageLayout; import org.eclipse.ui.IPageLayout;
@ -41,7 +42,7 @@ public class CPerspectiveFactory implements IPerspectiveFactory {
folder3.addView(IPageLayout.ID_OUTLINE); folder3.addView(IPageLayout.ID_OUTLINE);
layout.addActionSet(CUIPlugin.SEARCH_ACTION_SET_ID); layout.addActionSet(CUIPlugin.SEARCH_ACTION_SET_ID);
layout.addActionSet(CUIPlugin.FOLDER_ACTION_SET_ID); layout.addActionSet(CUIPlugin.ID_CELEMENT_CREATION_ACTION_SET);
// views - build console // views - build console
layout.addShowViewShortcut(IConsoleConstants.ID_CONSOLE_VIEW); layout.addShowViewShortcut(IConsoleConstants.ID_CONSOLE_VIEW);
@ -61,8 +62,12 @@ public class CPerspectiveFactory implements IPerspectiveFactory {
layout.addShowInPart(IPageLayout.ID_RES_NAV); layout.addShowInPart(IPageLayout.ID_RES_NAV);
// new actions - C project creation wizard // new actions - C project creation wizard
String[] wizIDs = CUIPlugin.getCProjectWizardIDs();
for (int i = 0; i < wizIDs.length; ++i) {
layout.addNewWizardShortcut(wizIDs[i]);
}
layout.addNewWizardShortcut(CUIPlugin.CLASS_WIZARD_ID); layout.addNewWizardShortcut(CUIPlugin.CLASS_WIZARD_ID);
layout.addNewWizardShortcut(CUIPlugin.FILE_WIZARD_ID);
layout.addNewWizardShortcut(CUIPlugin.FOLDER_WIZARD_ID); layout.addNewWizardShortcut(CUIPlugin.FOLDER_WIZARD_ID);
layout.addNewWizardShortcut(CUIPlugin.FILE_WIZARD_ID);
} }
} }

View file

@ -22,6 +22,14 @@ public class CUIStatus extends Status {
super(severity, CUIPlugin.getPluginId(), code, message, throwable); super(severity, CUIPlugin.getPluginId(), code, message, throwable);
} }
public static IStatus createError(int code, Throwable throwable) {
String message= throwable.getMessage();
if (message == null) {
message= throwable.getClass().getName();
}
return new CUIStatus(IStatus.ERROR, code, message, throwable);
}
public static IStatus createError(int code, String message, Throwable throwable) { public static IStatus createError(int code, String message, Throwable throwable) {
return new CUIStatus(IStatus.ERROR, code, message, throwable); return new CUIStatus(IStatus.ERROR, code, message, throwable);
} }

View file

@ -21,6 +21,7 @@ public interface ICHelpContextIds {
public static final String NEW_LAUNCH_WIZARD_PAGE = PREFIX + "new_launch_wizard_page_context"; //$NON-NLS-1$ public static final String NEW_LAUNCH_WIZARD_PAGE = PREFIX + "new_launch_wizard_page_context"; //$NON-NLS-1$
public static final String NEW_CLASS_WIZARD_PAGE = PREFIX + "new_class_wizard_page_context"; //$NON-NLS-1$ public static final String NEW_CLASS_WIZARD_PAGE = PREFIX + "new_class_wizard_page_context"; //$NON-NLS-1$
public static final String OPEN_CLASS_WIZARD_ACTION = PREFIX + "open_class_wizard_action"; //$NON-NLS-1$ public static final String OPEN_CLASS_WIZARD_ACTION = PREFIX + "open_class_wizard_action"; //$NON-NLS-1$
public static final String OPEN_PROJECT_WIZARD_ACTION = PREFIX + "open_project_wizard_action"; //$NON-NLS-1$
// Actions // Actions

View file

@ -8,13 +8,13 @@
* Contributors: * Contributors:
* Rational Software - initial implementation * Rational Software - initial implementation
******************************************************************************/ ******************************************************************************/
package org.eclipse.cdt.ui.actions; package org.eclipse.cdt.internal.ui.wizards;
import java.util.Iterator; 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.ExceptionHandler;
import org.eclipse.cdt.internal.ui.util.PixelConverter; import org.eclipse.cdt.internal.ui.util.PixelConverter;
import org.eclipse.cdt.internal.ui.wizards.NewWizardMessages;
import org.eclipse.cdt.ui.CUIPlugin; import org.eclipse.cdt.ui.CUIPlugin;
import org.eclipse.core.resources.IWorkspace; import org.eclipse.core.resources.IWorkspace;
import org.eclipse.core.resources.ResourcesPlugin; import org.eclipse.core.resources.ResourcesPlugin;
@ -37,7 +37,6 @@ public abstract class AbstractOpenWizardAction extends Action implements IWorkbe
private Class[] fActivatedOnTypes; private Class[] fActivatedOnTypes;
private boolean fAcceptEmptySelection; private boolean fAcceptEmptySelection;
private boolean fNoChecking;
/** /**
* Creates a AbstractOpenWizardAction. * Creates a AbstractOpenWizardAction.
@ -59,7 +58,6 @@ public abstract class AbstractOpenWizardAction extends Action implements IWorkbe
super(label); super(label);
fActivatedOnTypes= activatedOnTypes; fActivatedOnTypes= activatedOnTypes;
fAcceptEmptySelection= acceptEmptySelection; fAcceptEmptySelection= acceptEmptySelection;
fNoChecking= false;
} }
/** /**
@ -69,7 +67,6 @@ public abstract class AbstractOpenWizardAction extends Action implements IWorkbe
protected AbstractOpenWizardAction() { protected AbstractOpenWizardAction() {
fActivatedOnTypes= null; fActivatedOnTypes= null;
fAcceptEmptySelection= true; fAcceptEmptySelection= true;
fNoChecking= true;
} }
protected IWorkbench getWorkbench() { protected IWorkbench getWorkbench() {
@ -209,5 +206,4 @@ public abstract class AbstractOpenWizardAction extends Action implements IWorkbe
} }
return true; return true;
} }
} }

View file

@ -0,0 +1,136 @@
/*******************************************************************************
* Copyright (c) 2000, 2004 IBM Corporation 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:
* IBM Corporation - initial API and implementation
*******************************************************************************/
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.Platform;
import org.eclipse.jface.action.Action;
import org.eclipse.jface.action.ActionContributionItem;
import org.eclipse.jface.action.IAction;
import org.eclipse.jface.action.IMenuCreator;
import org.eclipse.jface.viewers.ISelection;
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$
private Menu fMenu;
public AbstractWizardDropDownAction() {
fMenu= null;
setMenuCreator(this);
}
public void dispose() {
if (fMenu != null) {
fMenu.dispose();
fMenu= null;
}
}
public Menu getMenu(Menu parent) {
return null;
}
public Menu getMenu(Control parent) {
if (fMenu == null) {
fMenu= new Menu(parent);
Action[] actions= getActionFromDescriptors();
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;
}
}
}
}
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);
}
}
}
}
}
}
//TODO: check for duplicate actions
// show C actions, then C++ Actions
CActions.addAll(CCActions);
return (Action[]) CActions.toArray(new Action[CActions.size()]);
}
public abstract AbstractOpenWizardAction createWizardAction(IConfigurationElement element);
/* (non-Javadoc)
* @see org.eclipse.ui.IWorkbenchWindowActionDelegate#init(org.eclipse.ui.IWorkbenchWindow)
*/
public void init(IWorkbenchWindow window) {
}
/* (non-Javadoc)
* @see org.eclipse.ui.IActionDelegate#run(org.eclipse.jface.action.IAction)
*/
public void run(IAction action) {
run();
}
/* (non-Javadoc)
* @see org.eclipse.ui.IActionDelegate#selectionChanged(org.eclipse.jface.action.IAction, org.eclipse.jface.viewers.ISelection)
*/
public void selectionChanged(IAction action, ISelection selection) {
}
}

View file

@ -0,0 +1,102 @@
/*******************************************************************************
* Copyright (c) 2000, 2004 IBM Corporation 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:
* IBM Corporation - initial API and implementation
*******************************************************************************/
package org.eclipse.cdt.internal.ui.wizards;
import org.eclipse.cdt.internal.ui.ICHelpContextIds;
import org.eclipse.core.runtime.IConfigurationElement;
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;
}
}
}

View file

@ -0,0 +1,74 @@
/*******************************************************************************
* Copyright (c) 2000, 2004 IBM Corporation 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:
* IBM Corporation - initial API and implementation
*******************************************************************************/
package org.eclipse.cdt.internal.ui.wizards;
import org.eclipse.cdt.internal.ui.ICHelpContextIds;
import org.eclipse.core.runtime.IConfigurationElement;
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;
}
}

View file

@ -0,0 +1,73 @@
/*******************************************************************************
* Copyright (c) 2000, 2004 IBM Corporation 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:
* IBM Corporation - initial API and implementation
*******************************************************************************/
package org.eclipse.cdt.internal.ui.wizards;
import java.net.MalformedURLException;
import java.net.URL;
import org.eclipse.cdt.internal.ui.util.CoreUtility;
import org.eclipse.cdt.ui.CUIPlugin;
import org.eclipse.core.runtime.CoreException;
import org.eclipse.core.runtime.IConfigurationElement;
import org.eclipse.core.runtime.Platform;
import org.eclipse.jface.resource.ImageDescriptor;
import org.eclipse.jface.wizard.Wizard;
public class OpenNewWizardAction extends AbstractOpenWizardAction {
private static final String TAG_DESCRIPTION = "description"; //$NON-NLS-1$
private final static String ATT_NAME = "name";//$NON-NLS-1$
private final static String ATT_CLASS = "class";//$NON-NLS-1$
private final static String ATT_ICON = "icon";//$NON-NLS-1$
private IConfigurationElement fConfigurationElement;
public OpenNewWizardAction(IConfigurationElement element) {
fConfigurationElement= element;
setText(element.getAttribute(ATT_NAME));
String description= getDescriptionFromConfig(fConfigurationElement);
setDescription(description);
setToolTipText(description);
setImageDescriptor(getIconFromConfig(fConfigurationElement));
}
private String getDescriptionFromConfig(IConfigurationElement config) {
IConfigurationElement [] children = config.getChildren(TAG_DESCRIPTION);
if (children.length>=1) {
return children[0].getValue();
}
return ""; //$NON-NLS-1$
}
private ImageDescriptor getIconFromConfig(IConfigurationElement config) {
try {
String iconName = config.getAttribute(ATT_ICON);
if (iconName != null) {
URL pluginInstallUrl = Platform.getBundle(config.getDeclaringExtension().getNamespace()).getEntry("/"); //$NON-NLS-1$
return ImageDescriptor.createFromURL(new URL(pluginInstallUrl, iconName));
}
return null;
} catch (MalformedURLException exception) {
CUIPlugin.getDefault().logErrorMessage("Unable to load wizard icon"); //$NON-NLS-1$
}
return ImageDescriptor.getMissingImageDescriptor();
}
/* (non-Javadoc)
* @see org.eclipse.jdt.internal.ui.wizards.AbstractOpenWizardAction#createWizard()
*/
protected Wizard createWizard() throws CoreException {
return (Wizard) CoreUtility.createExtension(fConfigurationElement, ATT_CLASS);
}
}

View file

@ -50,9 +50,11 @@ import org.eclipse.core.resources.ResourcesPlugin;
import org.eclipse.core.runtime.CoreException; import org.eclipse.core.runtime.CoreException;
import org.eclipse.core.runtime.IAdapterManager; import org.eclipse.core.runtime.IAdapterManager;
import org.eclipse.core.runtime.IConfigurationElement; import org.eclipse.core.runtime.IConfigurationElement;
import org.eclipse.core.runtime.IExtensionPoint;
import org.eclipse.core.runtime.IStatus; import org.eclipse.core.runtime.IStatus;
import org.eclipse.core.runtime.Platform; import org.eclipse.core.runtime.Platform;
import org.eclipse.core.runtime.Status; import org.eclipse.core.runtime.Status;
import org.eclipse.jface.action.Action;
import org.eclipse.jface.action.GroupMarker; import org.eclipse.jface.action.GroupMarker;
import org.eclipse.jface.action.IMenuManager; import org.eclipse.jface.action.IMenuManager;
import org.eclipse.jface.action.Separator; import org.eclipse.jface.action.Separator;
@ -67,7 +69,9 @@ import org.eclipse.ui.IEditorReference;
import org.eclipse.ui.IWorkbench; import org.eclipse.ui.IWorkbench;
import org.eclipse.ui.IWorkbenchPage; import org.eclipse.ui.IWorkbenchPage;
import org.eclipse.ui.IWorkbenchWindow; import org.eclipse.ui.IWorkbenchWindow;
import org.eclipse.ui.PlatformUI;
import org.eclipse.ui.editors.text.EditorsUI; import org.eclipse.ui.editors.text.EditorsUI;
import org.eclipse.ui.internal.IWorkbenchConstants;
import org.eclipse.ui.plugin.AbstractUIPlugin; import org.eclipse.ui.plugin.AbstractUIPlugin;
import org.eclipse.ui.texteditor.ChainedPreferenceStore; import org.eclipse.ui.texteditor.ChainedPreferenceStore;
import org.eclipse.ui.texteditor.ConfigurationElementSorter; import org.eclipse.ui.texteditor.ConfigurationElementSorter;
@ -86,11 +90,13 @@ public class CUIPlugin extends AbstractUIPlugin {
public static final String C_PROJECT_WIZARD_ID = PLUGIN_ID + ".wizards.StdCWizard"; //$NON-NLS-1$ public static final String C_PROJECT_WIZARD_ID = PLUGIN_ID + ".wizards.StdCWizard"; //$NON-NLS-1$
public static final String CPP_PROJECT_WIZARD_ID = PLUGIN_ID + ".wizards.StdCCWizard"; //$NON-NLS-1$ public static final String CPP_PROJECT_WIZARD_ID = PLUGIN_ID + ".wizards.StdCCWizard"; //$NON-NLS-1$
public final static String CWIZARD_CATEGORY_ID = "org.eclipse.cdt.ui.newCWizards"; //$NON-NLS-1$
public final static String CCWIZARD_CATEGORY_ID = "org.eclipse.cdt.ui.newCCWizards"; //$NON-NLS-1$
public static final String FILE_WIZARD_ID = "org.eclipse.ui.wizards.new.file"; //$NON-NLS-1$ public static final String FILE_WIZARD_ID = "org.eclipse.ui.wizards.new.file"; //$NON-NLS-1$
public static final String FOLDER_WIZARD_ID = "org.eclipse.ui.wizards.new.folder"; //$NON-NLS-1$ public static final String FOLDER_WIZARD_ID = "org.eclipse.ui.wizards.new.folder"; //$NON-NLS-1$
public static final String CLASS_WIZARD_ID = "org.eclipse.cdt.ui.wizards.NewClassWizard"; //$NON-NLS-1$ public static final String CLASS_WIZARD_ID = "org.eclipse.cdt.ui.wizards.NewClassWizard"; //$NON-NLS-1$
public static final String SEARCH_ACTION_SET_ID = PLUGIN_ID + ".SearchActionSet"; //$NON-NLS-1$ public static final String SEARCH_ACTION_SET_ID = PLUGIN_ID + ".SearchActionSet"; //$NON-NLS-1$
public static final String FOLDER_ACTION_SET_ID = PLUGIN_ID + ".CFolderActionSet"; //$NON-NLS-1$
public static final String BUILDER_ID = PLUGIN_CORE_ID + ".cbuilder"; //$NON-NLS-1$ public static final String BUILDER_ID = PLUGIN_CORE_ID + ".cbuilder"; //$NON-NLS-1$
private static CUIPlugin fgCPlugin; private static CUIPlugin fgCPlugin;
@ -178,6 +184,14 @@ public class CUIPlugin extends AbstractUIPlugin {
public static final String ID_TYPE_HIERARCHY = "org.eclipse.cdt.ui.TypeHierarchyView"; //$NON-NLS-1$ public static final String ID_TYPE_HIERARCHY = "org.eclipse.cdt.ui.TypeHierarchyView"; //$NON-NLS-1$
/**
* The id of the C Element Creation action set
* (value <code>"org.eclipse.cdt.ui.CElementCreationActionSet"</code>).
*
* @since 2.0
*/
public static final String ID_CELEMENT_CREATION_ACTION_SET= "org.eclipse.cdt.ui.CElementCreationActionSet"; //$NON-NLS-1$
// -------- static methods -------- // -------- static methods --------
static { static {
@ -647,5 +661,50 @@ public class CUIPlugin extends AbstractUIPlugin {
fCEditorTextHoverDescriptors= null; fCEditorTextHoverDescriptors= null;
} }
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$
/**
* Returns IDs of all C project wizards contributed to the workbench.
*
* @return an array of wizard ids
*/
public static String[] getCProjectWizardIDs() {
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 && (category.equals(CUIPlugin.CCWIZARD_CATEGORY_ID)
|| category.equals(CUIPlugin.CWIZARD_CATEGORY_ID))) {
String project = element.getAttribute(ATT_PROJECT);
if (project != null && Boolean.valueOf(project).booleanValue()) {
String id = element.getAttribute(IWorkbenchConstants.TAG_ID);
if (id != null) {
if (category.equals(CUIPlugin.CWIZARD_CATEGORY_ID)) {
if (!CActions.contains(id))
CActions.add(id);
} else {
if (!CCActions.contains(id))
CCActions.add(id);
}
}
}
}
}
}
}
//TODO: check for duplicate actions
// show C actions, then C++ Actions
CActions.addAll(CCActions);
return (String[]) CActions.toArray(new String[CActions.size()]);
}
} }

View file

@ -1,26 +0,0 @@
package org.eclipse.cdt.ui.actions;
import org.eclipse.cdt.internal.ui.ICHelpContextIds;
import org.eclipse.cdt.ui.wizards.NewClassWizard;
import org.eclipse.jface.wizard.Wizard;
import org.eclipse.ui.IWorkbenchWindowActionDelegate;
import org.eclipse.ui.help.WorkbenchHelp;
/**
* TODO: Provide description for "OpenClassWizardAction".
* @see IWorkbenchWindowActionDelegate
*/
public class OpenClassWizardAction extends AbstractOpenWizardAction implements IWorkbenchWindowActionDelegate {
public OpenClassWizardAction() {
WorkbenchHelp.setHelp(this, ICHelpContextIds.OPEN_CLASS_WIZARD_ACTION);
}
public OpenClassWizardAction(String label, Class[] acceptedTypes) {
super(label, acceptedTypes, false);
WorkbenchHelp.setHelp(this, ICHelpContextIds.OPEN_CLASS_WIZARD_ACTION);
}
protected Wizard createWizard() {
return new NewClassWizard();
}
}